KiCad PCB EDA Suite
dialog_junction_props.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2020 Wayne Stambaugh <[email protected]>
5 * Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software: you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation, either version 3 of the License, or (at your
10 * option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#include <sch_junction.h>
24#include <sch_edit_frame.h>
26
27
29 std::deque<SCH_JUNCTION*>& aJunctions ) :
31 m_frame( aParent ),
32 m_junctions( aJunctions ),
33 m_diameter( aParent, m_staticTextDiameter, m_textCtrlDiameter,
34 m_staticTextDiameterUnits, true )
35{
36 m_colorSwatch->SetDefaultColor( COLOR4D::UNSPECIFIED );
37
39 m_colorSwatch->SetSwatchBackground( canvas.ToColour() );
40
41 m_helpLabel1->SetFont( KIUI::GetInfoFont( this ).Italic() );
42 m_helpLabel2->SetFont( KIUI::GetInfoFont( this ).Italic() );
43
45
46 SetupStandardButtons( { { wxID_APPLY, _( "Default" ) } } );
47
48 // Now all widgets have the size fixed, call FinishDialogSettings
50}
51
52
54{
55 auto firstJunction = m_junctions.front();
56
57 if( std::all_of( m_junctions.begin() + 1, m_junctions.end(),
58 [&]( const SCH_JUNCTION* r )
59 {
60 return r->GetDiameter() == firstJunction->GetDiameter();
61 } ) )
62 {
63 m_diameter.SetValue( firstJunction->GetDiameter() );
64 }
65 else
66 {
68 }
69
70 if( std::all_of( m_junctions.begin() + 1, m_junctions.end(),
71 [&]( const SCH_JUNCTION* r )
72 {
73 return r->GetColor() == firstJunction->GetColor();
74 } ) )
75 {
76 m_colorSwatch->SetSwatchColor( firstJunction->GetColor(), false );
77 }
78 else
79 {
80 m_colorSwatch->SetSwatchColor( COLOR4D::UNSPECIFIED, false );
81 }
82
83 return true;
84}
85
86
87void DIALOG_JUNCTION_PROPS::resetDefaults( wxCommandEvent& event )
88{
90 m_colorSwatch->SetSwatchColor( COLOR4D::UNSPECIFIED, false );
91
92 Refresh();
93}
94
95
97{
98 PICKED_ITEMS_LIST pickedItems;
99
100 for( SCH_JUNCTION* junction : m_junctions )
101 pickedItems.PushItem( ITEM_PICKER( m_frame->GetScreen(), junction, UNDO_REDO::CHANGED ) );
102
103 m_frame->SaveCopyInUndoList( pickedItems, UNDO_REDO::CHANGED, false, false );
104
105 for( SCH_JUNCTION* junction : m_junctions )
106 {
108 junction->SetDiameter( m_diameter.GetValue() );
109
110 junction->SetColor( m_colorSwatch->GetSwatchColor() );
111
112 m_frame->GetCanvas()->GetView()->Update( junction );
113 }
114
116 m_frame->OnModify();
117
118 return true;
119}
COLOR4D GetColor(int aLayer) const
void SetSwatchColor(const KIGFX::COLOR4D &aColor, bool aSendEvent)
Set the current swatch color directly.
KIGFX::COLOR4D GetSwatchColor() const
void SetDefaultColor(const KIGFX::COLOR4D &aColor)
Sets the color that will be chosen with the "Reset to Default" button in the chooser.
void SetSwatchBackground(const KIGFX::COLOR4D &aBackground)
Set the swatch background color.
Class DIALOG_JUNCTION_PROPS_BASE.
void resetDefaults(wxCommandEvent &event) override
std::deque< SCH_JUNCTION * > m_junctions
DIALOG_JUNCTION_PROPS(SCH_EDIT_FRAME *aParent, std::deque< SCH_JUNCTION * > &aJunctions)
bool TransferDataFromWindow() override
bool TransferDataToWindow() override
void SetInitialFocus(wxWindow *aWindow)
Sets the window (usually a wxTextCtrl) that should be focused when the dialog is shown.
Definition: dialog_shim.h:97
void SetupStandardButtons(std::map< int, wxString > aLabels={})
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
Definition: view.cpp:1574
A holder to handle information on schematic or board items.
void PushItem(const ITEM_PICKER &aItem)
Push aItem to the top of the list.
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
COLOR_SETTINGS * GetColorSettings(bool aForceRefresh=false) const override
Returns a pointer to the active color theme settings.
KIGFX::SCH_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
Schematic editor (Eeschema) main window.
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag and update other data struc...
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
void SaveCopyInUndoList(SCH_SCREEN *aScreen, SCH_ITEM *aItemToCopy, UNDO_REDO aTypeCommand, bool aAppend, bool aDirtyConnectivity=true)
Create a copy of the current schematic item, and put it in the undo list.
virtual long long int GetValue()
Return the current value in Internal Units.
bool IsIndeterminate() const
Return true if the control holds the indeterminate value (for instance, if it represents a multiple s...
virtual void SetValue(long long int aValue)
Set new value (in Internal Units) for the text field, taking care of units conversion.
#define _(s)
E_SERIE r
Definition: eserie.cpp:41
@ LAYER_SCHEMATIC_BACKGROUND
Definition: layer_ids.h:376
wxFont GetInfoFont(wxWindow *aWindow)
Definition: ui_common.cpp:144
void Refresh()
Update the board display after modifying it by a python script (note: it is automatically called by a...
#define INDETERMINATE_ACTION
Definition: ui_common.h:43