KiCad PCB EDA Suite
toolbars_update_user_interface.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) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
5  * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
6  * Copyright (C) 2012 Wayne Stambaugh <stambaughw@verizon.net>
7  * Copyright (C) 2012-2016 KiCad Developers, see AUTHORS.txt for contributors.
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; either version 2
12  * of the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, you may find one here:
21  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
22  * or you may search the http://www.gnu.org website for the version 2 license,
23  * or you may write to the Free Software Foundation, Inc.,
24  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
25  */
26 
32 #include <fctsys.h>
33 #include <pgm_base.h>
34 #include <class_drawpanel.h>
35 #include <wxPcbStruct.h>
36 #include <dialog_helpers.h>
37 #include <class_board.h>
38 #include <pcbnew.h>
39 #include <pcbnew_id.h>
40 #include <drc_stuff.h>
42 
43 
44 void PCB_EDIT_FRAME::OnUpdateLayerPair( wxUpdateUIEvent& aEvent )
45 {
47 }
48 
49 
50 void PCB_EDIT_FRAME::OnUpdateSelectTrackWidth( wxUpdateUIEvent& aEvent )
51 {
52  if( aEvent.GetId() == ID_AUX_TOOLBAR_PCB_TRACK_WIDTH )
53  {
54  if( m_SelTrackWidthBox->GetSelection() != (int) GetDesignSettings().GetTrackWidthIndex() )
55  m_SelTrackWidthBox->SetSelection( GetDesignSettings().GetTrackWidthIndex() );
56  }
57  else
58  {
59  bool check = ( ( ( ID_POPUP_PCB_SELECT_WIDTH1 +
60  (int) GetDesignSettings().GetTrackWidthIndex() ) == aEvent.GetId() ) &&
63 
64  aEvent.Check( check );
65  }
66 }
67 
68 
69 void PCB_EDIT_FRAME::OnUpdateSelectAutoTrackWidth( wxUpdateUIEvent& aEvent )
70 {
71  aEvent.Check( GetDesignSettings().m_UseConnectedTrackWidth &&
72  !GetDesignSettings().UseCustomTrackViaSize() );
73 }
74 
75 
76 void PCB_EDIT_FRAME::OnUpdateSelectCustomTrackWidth( wxUpdateUIEvent& aEvent )
77 {
78  aEvent.Check( GetDesignSettings().UseCustomTrackViaSize() );
79 }
80 
81 
82 void PCB_EDIT_FRAME::OnUpdateSelectViaSize( wxUpdateUIEvent& aEvent )
83 {
84  if( aEvent.GetId() == ID_AUX_TOOLBAR_PCB_VIA_SIZE )
85  {
86  if( m_SelViaSizeBox->GetSelection() != (int) GetDesignSettings().GetViaSizeIndex() )
87  m_SelViaSizeBox->SetSelection( GetDesignSettings().GetViaSizeIndex() );
88  }
89  else
90  {
91  bool check = ( ( ( ID_POPUP_PCB_SELECT_VIASIZE1 +
92  (int) GetDesignSettings().GetViaSizeIndex() ) == aEvent.GetId() ) &&
95 
96  aEvent.Check( check );
97  }
98 }
99 
100 
101 void PCB_EDIT_FRAME::OnUpdateLayerSelectBox( wxUpdateUIEvent& aEvent )
102 {
104 }
105 
106 
107 #if defined( KICAD_SCRIPTING_WXPYTHON )
108 
109 // Used only when the DKICAD_SCRIPTING_WXPYTHON option is on
110 void PCB_EDIT_FRAME::OnUpdateScriptingConsoleState( wxUpdateUIEvent& aEvent )
111 {
112  wxMiniFrame * pythonPanelFrame = (wxMiniFrame *) findPythonConsole();
113  bool pythonPanelShown = pythonPanelFrame ? pythonPanelFrame->IsShown() : false;
114  aEvent.Check( pythonPanelShown );
115 }
116 
117 #endif
118 
119 
120 void PCB_EDIT_FRAME::OnUpdateZoneDisplayStyle( wxUpdateUIEvent& aEvent )
121 {
122  int selected = aEvent.GetId() - ID_TB_OPTIONS_SHOW_ZONES;
124 
125  if( aEvent.IsChecked() && ( displ_opts->m_DisplayZonesMode == selected ) )
126  return;
127 
128  aEvent.Check( displ_opts->m_DisplayZonesMode == selected );
129 }
130 
131 
132 void PCB_EDIT_FRAME::OnUpdateDrcEnable( wxUpdateUIEvent& aEvent )
133 {
134  bool state = !Settings().m_legacyDrcOn;
135  aEvent.Check( state );
136  m_optionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_DRC_OFF,
137  Settings().m_legacyDrcOn ?
138  _( "Disable design rule checking while routing/editing tracks" ) :
139  _( "Enable design rule checking while routing/editing tracks" ) );
140 }
141 
142 void PCB_EDIT_FRAME::OnUpdateShowBoardRatsnest( wxUpdateUIEvent& aEvent )
143 {
144  aEvent.Check( GetBoard()->IsElementVisible( LAYER_RATSNEST ) );
147  _( "Hide board ratsnest" ) :
148  _( "Show board ratsnest" ) );
149 }
150 
151 
152 void PCB_EDIT_FRAME::OnUpdateAutoDeleteTrack( wxUpdateUIEvent& aEvent )
153 {
154  aEvent.Check( Settings().m_legacyAutoDeleteOldTrack );
156  Settings().m_legacyAutoDeleteOldTrack ?
157  _( "Disable auto delete old track" ) :
158  _( "Enable auto delete old track" ) );
159 }
160 
161 
162 void PCB_EDIT_FRAME::OnUpdateViaDrawMode( wxUpdateUIEvent& aEvent )
163 {
165  aEvent.Check( !displ_opts->m_DisplayViaFill );
167  displ_opts->m_DisplayViaFill ?
168  _( "Show vias in outline mode" ) :
169  _( "Show vias in fill mode" ) );
170 }
171 
172 
173 void PCB_EDIT_FRAME::OnUpdateTraceDrawMode( wxUpdateUIEvent& aEvent )
174 {
176  aEvent.Check( !displ_opts->m_DisplayPcbTrackFill );
178  displ_opts->m_DisplayPcbTrackFill ?
179  _( "Show tracks in outline mode" ) :
180  _( "Show tracks in fill mode" ) );
181 }
182 
183 
184 void PCB_EDIT_FRAME::OnUpdateHighContrastDisplayMode( wxUpdateUIEvent& aEvent )
185 {
187  aEvent.Check( displ_opts->m_ContrastModeDisplay );
189  displ_opts->m_ContrastModeDisplay ?
190  _( "Normal contrast display mode" ) :
191  _( "High contrast display mode" ) );
192 }
193 
194 
195 void PCB_EDIT_FRAME::OnUpdateShowLayerManager( wxUpdateUIEvent& aEvent )
196 {
197  aEvent.Check( m_auimgr.GetPane( wxT( "m_LayersManagerToolBar" ) ).IsShown() );
198 }
199 
200 void PCB_EDIT_FRAME::OnUpdateShowMicrowaveToolbar( wxUpdateUIEvent& aEvent )
201 {
202  aEvent.Check( m_auimgr.GetPane( wxT( "m_microWaveToolBar" ) ).IsShown() );
203 }
204 
205 
206 void PCB_EDIT_FRAME::OnUpdateSave( wxUpdateUIEvent& aEvent )
207 {
208  aEvent.Enable( GetScreen()->IsModify() );
209 }
210 
211 
212 void PCB_EDIT_FRAME::OnUpdateVerticalToolbar( wxUpdateUIEvent& aEvent )
213 {
214  aEvent.Check( GetToolId() == aEvent.GetId() );
215 }
216 
217 void PCB_EDIT_FRAME::OnUpdateMuWaveToolbar( wxUpdateUIEvent& aEvent )
218 {
219  if( aEvent.GetEventObject() == m_microWaveToolBar )
220  aEvent.Check( GetToolId() == aEvent.GetId() );
221 }
222 
223 
224 void PCB_EDIT_FRAME::OnUpdateAutoPlaceTracksMode( wxUpdateUIEvent& aEvent )
225 {
226  //Nothing to do.
227 }
228 
229 
230 void PCB_EDIT_FRAME::OnUpdateAutoPlaceModulesMode( wxUpdateUIEvent& aEvent )
231 {
232  //Nothing to do.
233 }
void OnUpdateLayerPair(wxUpdateUIEvent &aEvent)
void OnUpdateAutoPlaceTracksMode(wxUpdateUIEvent &aEvent)
void PrepareLayerIndicator()
Definition: tool_pcb.cpp:92
Class BOARD to handle a board.
void OnUpdateLayerSelectBox(wxUpdateUIEvent &aEvent)
wxChoice * m_SelViaSizeBox
Definition: wxPcbStruct.h:242
void OnUpdateSave(wxUpdateUIEvent &aEvent)
BOARD * GetBoard() const
wxAuiManager m_auimgr
Definition: wxstruct.h:144
wxChoice * m_SelTrackWidthBox
Definition: wxPcbStruct.h:241
static wxWindow * findPythonConsole()
Definition: wxPcbStruct.h:166
bool m_UseConnectedTrackWidth
if true, when creating a new track starting on an existing track, use this track width ...
void * GetDisplayOptions() override
Function GetDisplayOptions returns the display options current in use Display options are relative to...
unsigned GetViaSizeIndex() const
Function GetViaSizeIndex.
void OnUpdateShowMicrowaveToolbar(wxUpdateUIEvent &aEvent)
void OnUpdateZoneDisplayStyle(wxUpdateUIEvent &aEvent)
bool m_DisplayPcbTrackFill
Definition: pcbstruct.h:71
bool IsElementVisible(GAL_LAYER_ID aElement) const
Function IsElementVisible tests whether a given element category is visible.
Definition: pcbframe.cpp:933
wxAuiToolBar * m_microWaveToolBar
The auxiliary right vertical tool bar used to access the microwave tools.
Definition: wxPcbStruct.h:90
wxAuiToolBar * m_optionsToolBar
The options tool bar typcially located on the left edge of the main window.
Definition: draw_frame.h:126
void OnUpdateAutoDeleteTrack(wxUpdateUIEvent &aEvent)
void OnUpdateShowLayerManager(wxUpdateUIEvent &aEvent)
PCB_GENERAL_SETTINGS & Settings()
static list_size_check check
bool m_ContrastModeDisplay
Definition: pcbstruct.h:85
Helper dialog and control classes.
int SetLayerSelection(LAYER_NUM layer)
virtual BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings returns the BOARD_DESIGN_SETTINGS for the BOARD owned by this frame...
int m_DisplayZonesMode
Definition: pcbstruct.h:77
void OnUpdateDrcEnable(wxUpdateUIEvent &aEvent)
Class DISPLAY_OPTIONS handles display options like enable/disable some optional drawings.
Definition: pcbstruct.h:62
void OnUpdateViaDrawMode(wxUpdateUIEvent &aEvent)
void OnUpdateSelectCustomTrackWidth(wxUpdateUIEvent &aEvent)
see class PGM_BASE
void OnUpdateHighContrastDisplayMode(wxUpdateUIEvent &aEvent)
int GetToolId() const
Definition: draw_frame.h:458
void OnUpdateSelectViaSize(wxUpdateUIEvent &aEvent)
void OnUpdateVerticalToolbar(wxUpdateUIEvent &aEvent)
PCB_SCREEN * GetScreen() const override
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
void OnUpdateTraceDrawMode(wxUpdateUIEvent &aEvent)
void OnUpdateMuWaveToolbar(wxUpdateUIEvent &aEvent)
void OnUpdateSelectAutoTrackWidth(wxUpdateUIEvent &aEvent)
unsigned GetTrackWidthIndex() const
Function GetTrackWidthIndex.
void OnUpdateSelectTrackWidth(wxUpdateUIEvent &aEvent)
PCB_LAYER_BOX_SELECTOR * m_SelLayerBox
Definition: wxPcbStruct.h:240
void OnUpdateShowBoardRatsnest(wxUpdateUIEvent &aEvent)
bool m_DisplayViaFill
Definition: pcbstruct.h:66
void OnUpdateAutoPlaceModulesMode(wxUpdateUIEvent &aEvent)
virtual PCB_LAYER_ID GetActiveLayer() const
Function GetActiveLayer returns the active layer.
void UseCustomTrackViaSize(bool aEnabled)
Function UseCustomTrackViaSize Enables/disables custom track/via size settings.