KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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 The 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#include <sch_commit.h>
27
28
30 std::deque<SCH_JUNCTION*>& aJunctions ) :
32 m_frame( aParent ),
33 m_junctions( aJunctions ),
36{
37 m_colorSwatch->SetDefaultColor( COLOR4D::UNSPECIFIED );
38
39 KIGFX::COLOR4D canvas = m_frame->GetColorSettings()->GetColor( LAYER_SCHEMATIC_BACKGROUND );
40 m_colorSwatch->SetSwatchBackground( canvas.ToColour() );
41
42 m_helpLabel1->SetFont( KIUI::GetInfoFont( this ).Italic() );
43 m_helpLabel2->SetFont( KIUI::GetInfoFont( this ).Italic() );
44
46
47 SetupStandardButtons( { { wxID_APPLY, _( "Default" ) } } );
48
49 // Now all widgets have the size fixed, call FinishDialogSettings
51}
52
53
55{
56 auto firstJunction = m_junctions.front();
57
58 if( std::all_of( m_junctions.begin() + 1, m_junctions.end(),
59 [&]( const SCH_JUNCTION* r )
60 {
61 return r->GetDiameter() == firstJunction->GetDiameter();
62 } ) )
63 {
64 m_diameter.SetValue( firstJunction->GetDiameter() );
65 }
66 else
67 {
69 }
70
71 if( std::all_of( m_junctions.begin() + 1, m_junctions.end(),
72 [&]( const SCH_JUNCTION* r )
73 {
74 return r->GetColor() == firstJunction->GetColor();
75 } ) )
76 {
77 m_colorSwatch->SetSwatchColor( firstJunction->GetColor(), false );
78 }
79 else
80 {
81 m_colorSwatch->SetSwatchColor( COLOR4D::UNSPECIFIED, false );
82 }
83
84 return true;
85}
86
87
88void DIALOG_JUNCTION_PROPS::resetDefaults( wxCommandEvent& event )
89{
90 m_diameter.SetValue( 0 );
91 m_colorSwatch->SetSwatchColor( COLOR4D::UNSPECIFIED, false );
92
93 Refresh();
94}
95
96
98{
99 SCH_COMMIT commit( m_frame );
100
101 for( SCH_JUNCTION* junction : m_junctions )
102 {
103 commit.Modify( junction, m_frame->GetScreen() );
104
105 if( !m_diameter.IsIndeterminate() )
106 junction->SetDiameter( m_diameter.GetValue() );
107
108 junction->SetColor( m_colorSwatch->GetSwatchColor() );
109
110 m_frame->GetCanvas()->GetView()->Update( junction );
111 }
112
113 commit.Push( m_junctions.size() == 1 ? _( "Edit Junction" ) : _( "Edit Junctions" ) );
114
115 return true;
116}
static const COLOR4D UNSPECIFIED
For legacy support; used as a value to indicate color hasn't been set yet.
Definition color4d.h:398
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE)
Modify a given item in the model.
Definition commit.h:106
DIALOG_JUNCTION_PROPS_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Junction Properties"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
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
void SetInitialFocus(wxWindow *aWindow)
Sets the window (usually a wxTextCtrl) that should be focused when the dialog is shown.
Definition dialog_shim.h:82
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...
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:104
wxColour ToColour() const
Definition color4d.cpp:220
virtual void Push(const wxString &aMessage=wxT("A commit"), int aCommitFlags=0) override
Execute the changes.
Schematic editor (Eeschema) main window.
#define _(s)
@ LAYER_SCHEMATIC_BACKGROUND
Definition layer_ids.h:487
KICOMMON_API wxFont GetInfoFont(wxWindow *aWindow)
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:47