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, jp.charras at wanadoo.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 <pcb_edit_frame.h>
36 #include <dialog_helpers.h>
37 #include <class_board.h>
38 #include <pcbnew.h>
39 #include <pcbnew_id.h>
40 #include <drc.h>
41 #include <pcb_layer_box_selector.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 }
58 
59 
60 void PCB_EDIT_FRAME::OnUpdateSelectViaSize( wxUpdateUIEvent& aEvent )
61 {
62  if( aEvent.GetId() == ID_AUX_TOOLBAR_PCB_VIA_SIZE )
63  {
64  if( m_SelViaSizeBox->GetSelection() != (int) GetDesignSettings().GetViaSizeIndex() )
65  m_SelViaSizeBox->SetSelection( GetDesignSettings().GetViaSizeIndex() );
66  }
67 }
68 
69 
70 void PCB_EDIT_FRAME::OnUpdateLayerSelectBox( wxUpdateUIEvent& aEvent )
71 {
73 }
74 
75 
76 #if defined( KICAD_SCRIPTING_WXPYTHON )
77 
78 // Used only when the DKICAD_SCRIPTING_WXPYTHON option is on
79 void PCB_EDIT_FRAME::OnUpdateScriptingConsoleState( wxUpdateUIEvent& aEvent )
80 {
81  if( aEvent.GetEventObject() != m_mainToolBar )
82  return;
83 
84  wxMiniFrame* pythonPanelFrame = (wxMiniFrame *) findPythonConsole();
85  bool pythonPanelShown = pythonPanelFrame ? pythonPanelFrame->IsShown() : false;
86  aEvent.Check( pythonPanelShown );
87 }
88 
89 #endif
90 
91 
92 void PCB_EDIT_FRAME::OnUpdateZoneDisplayStyle( wxUpdateUIEvent& aEvent )
93 {
94 
95 }
96 
97 
98 void PCB_EDIT_FRAME::OnUpdateDrcEnable( wxUpdateUIEvent& aEvent )
99 {
100  bool state = !Settings().m_legacyDrcOn;
101  aEvent.Check( state );
102  m_optionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_DRC_OFF,
103  Settings().m_legacyDrcOn ?
104  _( "Disable design rule checking while routing/editing tracks using Legacy Toolset.\nUse Route > Interactive Router Settings... for Modern Toolset." ) :
105  _( "Enable design rule checking while routing/editing tracks using Legacy Toolset.\nUse Route > Interactive Router Settings... for Modern Toolset." ) );
106 }
107 
108 void PCB_EDIT_FRAME::OnUpdateShowBoardRatsnest( wxUpdateUIEvent& aEvent )
109 {
110  aEvent.Check( GetBoard()->IsElementVisible( LAYER_RATSNEST ) );
113  _( "Hide board ratsnest" ) :
114  _( "Show board ratsnest" ) );
115 }
116 
117 
118 void PCB_EDIT_FRAME::OnUpdateViaDrawMode( wxUpdateUIEvent& aEvent )
119 {
120  auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
121  aEvent.Check( !displ_opts->m_DisplayViaFill );
123  displ_opts->m_DisplayViaFill ?
124  _( "Show vias in outline mode" ) :
125  _( "Show vias in fill mode" ) );
126 }
127 
128 
129 void PCB_EDIT_FRAME::OnUpdateTraceDrawMode( wxUpdateUIEvent& aEvent )
130 {
131  auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
132  aEvent.Check( !displ_opts->m_DisplayPcbTrackFill );
134  displ_opts->m_DisplayPcbTrackFill ?
135  _( "Show tracks in outline mode" ) :
136  _( "Show tracks in fill mode" ) );
137 }
138 
139 
140 void PCB_EDIT_FRAME::OnUpdateHighContrastDisplayMode( wxUpdateUIEvent& aEvent )
141 {
142  auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
143  aEvent.Check( displ_opts->m_ContrastModeDisplay );
145  displ_opts->m_ContrastModeDisplay ?
146  _( "Normal contrast display mode" ) :
147  _( "High contrast display mode" ) );
148 }
149 
150 
151 void PCB_EDIT_FRAME::OnUpdateShowLayerManager( wxUpdateUIEvent& aEvent )
152 {
153  aEvent.Check( m_auimgr.GetPane( "LayersManager" ).IsShown() );
154 }
155 
156 void PCB_EDIT_FRAME::OnUpdateShowMicrowaveToolbar( wxUpdateUIEvent& aEvent )
157 {
158  aEvent.Check( m_auimgr.GetPane( "MicrowaveToolbar" ).IsShown() );
159 }
160 
161 
162 void PCB_EDIT_FRAME::OnUpdateSave( wxUpdateUIEvent& aEvent )
163 {
164  aEvent.Enable( GetScreen()->IsModify() );
165 }
166 
167 
168 void PCB_EDIT_FRAME::OnUpdateVerticalToolbar( wxUpdateUIEvent& aEvent )
169 {
170  if( aEvent.GetEventObject() == m_drawToolBar || aEvent.GetEventObject() == m_mainToolBar )
171  aEvent.Check( GetToolId() == aEvent.GetId() );
172 }
173 
174 void PCB_EDIT_FRAME::OnUpdateMuWaveToolbar( wxUpdateUIEvent& aEvent )
175 {
176  if( aEvent.GetEventObject() == m_microWaveToolBar )
177  aEvent.Check( GetToolId() == aEvent.GetId() );
178 }
179 
180 
182 {
183  auto displOpts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
184  auto menuBar = GetMenuBar();
185 
186  m_optionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_ZONES, false );
189 
190  switch( displOpts->m_DisplayZonesMode )
191  {
192  case 0:
193  menuBar->FindItem( ID_TB_OPTIONS_SHOW_ZONES )->Check( true );
194  m_optionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_ZONES, true );
195  break;
196 
197  case 1:
198  menuBar->FindItem( ID_TB_OPTIONS_SHOW_ZONES_DISABLE )->Check( true );
200  break;
201 
202  case 2:
203  menuBar->FindItem( ID_TB_OPTIONS_SHOW_ZONES_OUTLINES_ONLY )->Check( true );
205  break;
206  }
207 
208  m_optionsToolBar->ToggleTool( ID_TB_OPTIONS_SELECT_UNIT_MM, false );
209  m_optionsToolBar->ToggleTool( ID_TB_OPTIONS_SELECT_UNIT_INCH, false );
210 
211  if( GetUserUnits() == INCHES )
212  {
213  menuBar->FindItem( ID_TB_OPTIONS_SELECT_UNIT_INCH )->Check( true );
215  }
216  else
217  {
218  menuBar->FindItem( ID_TB_OPTIONS_SELECT_UNIT_MM )->Check( true );
219  m_optionsToolBar->ToggleTool( ID_TB_OPTIONS_SELECT_UNIT_MM, true );
220  }
221 }
void OnUpdateLayerPair(wxUpdateUIEvent &aEvent)
void PrepareLayerIndicator()
Class BOARD to handle a board.
void OnUpdateLayerSelectBox(wxUpdateUIEvent &aEvent)
wxChoice * m_SelViaSizeBox
void OnUpdateSave(wxUpdateUIEvent &aEvent)
BOARD * GetBoard() const
wxAuiManager m_auimgr
void SyncMenusAndToolbars(wxEvent &aEvent) override
Update the toolbars and menus (mostly settings/check buttons/checkboxes) with the current controller ...
wxChoice * m_SelTrackWidthBox
static wxWindow * findPythonConsole()
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 IsElementVisible(GAL_LAYER_ID aElement) const
Function IsElementVisible tests whether a given element category is visible.
Class PCB_DISPLAY_OPTIONS handles display options like enable/disable some optional drawings...
wxAuiToolBar * m_microWaveToolBar
The auxiliary right vertical tool bar used to access the microwave tools.
wxAuiToolBar * m_optionsToolBar
The options tool bar typcially located on the left edge of the main window.
Definition: draw_frame.h:160
EDA_DRAW_FRAME::OnSelectGrid ID_TB_OPTIONS_SELECT_UNIT_INCH
void OnUpdateShowLayerManager(wxUpdateUIEvent &aEvent)
PCB_GENERAL_SETTINGS & Settings()
EDA_UNITS_T GetUserUnits() const override
Return the user units currently in use.
Definition: draw_frame.h:284
Definition: common.h:160
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...
wxAuiToolBar * m_drawToolBar
The tool bar that contains the buttons for quick access to the application draw tools.
Definition: draw_frame.h:157
wxAuiToolBar * m_mainToolBar
Standard horizontal Toolbar.
void OnUpdateDrcEnable(wxUpdateUIEvent &aEvent)
void OnUpdateViaDrawMode(wxUpdateUIEvent &aEvent)
see class PGM_BASE
void OnUpdateHighContrastDisplayMode(wxUpdateUIEvent &aEvent)
int GetToolId() const
Definition: draw_frame.h:519
void OnUpdateSelectViaSize(wxUpdateUIEvent &aEvent)
void OnUpdateVerticalToolbar(wxUpdateUIEvent &aEvent)
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
void OnUpdateTraceDrawMode(wxUpdateUIEvent &aEvent)
void OnUpdateMuWaveToolbar(wxUpdateUIEvent &aEvent)
unsigned GetTrackWidthIndex() const
Function GetTrackWidthIndex.
void OnUpdateSelectTrackWidth(wxUpdateUIEvent &aEvent)
PCB_LAYER_BOX_SELECTOR * m_SelLayerBox
void OnUpdateShowBoardRatsnest(wxUpdateUIEvent &aEvent)
virtual PCB_LAYER_ID GetActiveLayer() const
Function GetActiveLayer returns the active layer.