KiCad PCB EDA Suite
toolbars_pcb_editor.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@gmail.com>
7  * Copyright (C) 1992-2019 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 
27 #include <memory>
28 
29 #include <bitmaps.h>
30 #include <class_board.h>
31 #include <dialog_helpers.h>
32 #include <kiface_i.h>
33 #include <pcb_edit_frame.h>
34 #include <pcb_layer_box_selector.h>
35 #include <pcbnew_id.h>
36 #include <pcbnew_settings.h>
37 #include <pgm_base.h>
39 #include <router/router_tool.h>
42 #include <tool/action_toolbar.h>
43 #include <tool/actions.h>
44 #include <tool/common_tools.h>
45 #include <tool/tool_manager.h>
46 #include <tools/pcb_actions.h>
47 #include <tools/selection_tool.h>
48 #include <wx/wupdlock.h>
49 
50 #if defined(KICAD_SCRIPTING) || defined(KICAD_SCRIPTING_WXPYTHON)
51 #include <python_scripting.h>
52 #endif
53 
54 
55 /* Data to build the layer pair indicator button */
56 static std::unique_ptr<wxBitmap> LayerPairBitmap;
57 
58 #define BM_LAYERICON_SIZE 24
60 {
61  // 0 = draw pixel with active layer color
62  // 1 = draw pixel with top layer color (top/bottom layer used inautoroute and place via)
63  // 2 = draw pixel with bottom layer color
64  // 3 = draw pixel with via color
65  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0 },
66  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0 },
67  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0 },
68  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0 },
69  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 },
70  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0 },
71  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 },
72  { 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 0, 1, 1, 1, 1, 3, 0, 0, 0, 0, 0, 0, 0 },
73  { 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 0, 1, 1, 1, 1, 3, 3, 2, 2, 2, 2, 2, 2, 2 },
74  { 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 1, 1, 1, 1, 0, 3, 3, 2, 2, 2, 2, 2, 2, 2 },
75  { 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 1, 1, 1, 1, 0, 3, 3, 2, 2, 2, 2, 2, 2, 2 },
76  { 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 1, 1, 1, 0, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0 },
77  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
78  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
79  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
80  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
81  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
82  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
83  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
84  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
85  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
86  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
87 };
88 
89 
90 void PCB_EDIT_FRAME::PrepareLayerIndicator( bool aForceRebuild )
91 {
92  int ii, jj;
93  COLOR4D active_layer_color, top_color, bottom_color, via_color, background_color;
94  bool change = aForceRebuild;
95 
96  int requested_scale = Pgm().GetCommonSettings()->m_Appearance.icon_scale;
97 
98  if( m_prevIconVal.previous_requested_scale != requested_scale )
99  {
100  m_prevIconVal.previous_requested_scale = requested_scale;
101  change = true;
102  }
103 
104  active_layer_color = GetColorSettings()->GetColor( GetActiveLayer() );
105 
106  if( m_prevIconVal.previous_active_layer_color != active_layer_color )
107  {
108  m_prevIconVal.previous_active_layer_color = active_layer_color;
109  change = true;
110  }
111 
112  top_color = GetColorSettings()->GetColor( GetScreen()->m_Route_Layer_TOP );
113 
115  {
117  change = true;
118  }
119 
120  bottom_color = GetColorSettings()->GetColor( GetScreen()->m_Route_Layer_BOTTOM );
121 
123  {
125  change = true;
126  }
127 
128  int via_type = static_cast<int>( GetDesignSettings().m_CurrentViaType );
129  via_color = GetColorSettings()->GetColor( LAYER_VIAS + via_type );
130 
131  if( m_prevIconVal.previous_via_color != via_color )
132  {
133  m_prevIconVal.previous_via_color = via_color;
134  change = true;
135  }
136 
137  background_color = GetColorSettings()->GetColor( LAYER_PCB_BACKGROUND );
138 
139  if( m_prevIconVal.previous_background_color != background_color )
140  {
141  m_prevIconVal.previous_background_color = background_color;
142  change = true;
143  }
144 
145  if( change || !LayerPairBitmap )
146  {
147  LayerPairBitmap = std::make_unique<wxBitmap>( 24, 24 );
148 
149  // Draw the icon, with colors according to the active layer and layer pairs for via
150  // command (change layer)
151  wxMemoryDC iconDC;
152  iconDC.SelectObject( *LayerPairBitmap );
153  wxBrush brush;
154  wxPen pen;
155  int buttonColor = -1;
156 
157  brush.SetStyle( wxBRUSHSTYLE_SOLID );
158  brush.SetColour( background_color.WithAlpha(1.0).ToColour() );
159  iconDC.SetBrush( brush );
160  iconDC.DrawRectangle( 0, 0, BM_LAYERICON_SIZE, BM_LAYERICON_SIZE );
161 
162  for( ii = 0; ii < BM_LAYERICON_SIZE; ii++ )
163  {
164  for( jj = 0; jj < BM_LAYERICON_SIZE; jj++ )
165  {
166  if( s_BitmapLayerIcon[ii][jj] != buttonColor )
167  {
168  switch( s_BitmapLayerIcon[ii][jj] )
169  {
170  default:
171  case 0: pen.SetColour( active_layer_color.ToColour() ); break;
172  case 1: pen.SetColour( top_color.ToColour() ); break;
173  case 2: pen.SetColour( bottom_color.ToColour() ); break;
174  case 3: pen.SetColour( via_color.ToColour() ); break;
175  }
176 
177  buttonColor = s_BitmapLayerIcon[ii][jj];
178  iconDC.SetPen( pen );
179  }
180 
181  iconDC.DrawPoint( jj, ii );
182  }
183  }
184 
185  // Deselect the bitmap from the DC in order to delete the MemoryDC safely without
186  // deleting the bitmap
187  iconDC.SelectObject( wxNullBitmap );
188 
189  // Scale the bitmap
190  const int scale = ( requested_scale <= 0 ) ? KiIconScale( this ) : requested_scale;
191  wxImage image = LayerPairBitmap->ConvertToImage();
192 
193  // "NEAREST" causes less mixing of colors
194  image.Rescale( scale * image.GetWidth() / 4, scale * image.GetHeight() / 4,
195  wxIMAGE_QUALITY_NEAREST );
196 
197  LayerPairBitmap = std::make_unique<wxBitmap>( image );
198 
199  if( m_mainToolBar )
200  {
202  m_mainToolBar->Refresh();
203  }
204  }
205 }
206 
207 
209 {
210  // Note:
211  // To rebuild the aui toolbar, the more easy way is to clear ( calling m_mainToolBar.Clear() )
212  // all wxAuiToolBarItems.
213  // However the wxAuiToolBarItems are not the owners of controls managed by
214  // them and therefore do not delete them
215  // So we do not recreate them after clearing the tools.
216 
217  wxWindowUpdateLocker dummy( this );
218 
219  if( m_mainToolBar )
220  {
222  }
223  else
224  {
225  m_mainToolBar = new ACTION_TOOLBAR( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
226  KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT );
228 
229  // The layer indicator is special, so we register a callback directly that will regenerate the
230  // bitmap instead of using the conditions system
231  auto layerIndicatorUpdate =
232  [this] ( wxUpdateUIEvent& )
233  {
235  };
236 
237  Bind( wxEVT_UPDATE_UI, layerIndicatorUpdate, PCB_ACTIONS::selectLayerPair.GetUIId() );
238  }
239 
240  // Set up toolbar
241  if( Kiface().IsSingle() )
242  {
245  }
246 
248 
251 
256 
260 
263 
271 
275 
279 
281 
282  if( m_SelLayerBox == nullptr )
283  {
285  m_SelLayerBox->SetBoardFrame( this );
286  }
287 
288  ReCreateLayerBox( false );
289  m_mainToolBar->AddControl( m_SelLayerBox );
290 
292  PrepareLayerIndicator( true ); // Force rebuild of the bitmap with the active layer colors
293 
296 
297  // Access to the scripting console
298 #if defined(KICAD_SCRIPTING_WXPYTHON)
299  if( IsWxPythonLoaded() )
300  {
303 
304 #if defined(KICAD_SCRIPTING) && defined(KICAD_SCRIPTING_ACTION_MENU)
305  AddActionPluginTools();
306 #endif
307  }
308 #endif
309 
310  // after adding the buttons to the toolbar, must call Realize() to reflect the changes
311  m_mainToolBar->Realize();
312 }
313 
314 
316 {
317  // Note:
318  // To rebuild the aui toolbar, the more easy way is to clear ( calling m_mainToolBar.Clear() )
319  // all wxAuiToolBarItems.
320  // However the wxAuiToolBarItems are not the owners of controls managed by
321  // them and therefore do not delete them
322  // So we do not recreate them after clearing the tools.
323 
324  wxWindowUpdateLocker dummy( this );
325 
326  if( m_optionsToolBar )
327  {
329  }
330  else
331  {
333  wxDefaultPosition, wxDefaultSize,
334  KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
336  }
337 
339 
345 
349 
354 
360 
361  // Tools to show/hide toolbars:
364 
366  std::unique_ptr<ACTION_MENU> gridMenu = std::make_unique<ACTION_MENU>( false, selTool );
367  gridMenu->Add( ACTIONS::gridProperties );
368  m_optionsToolBar->AddToolContextMenu( ACTIONS::toggleGrid, std::move( gridMenu ) );
369 
370  m_optionsToolBar->Realize();
371 }
372 
373 
375 {
376  wxWindowUpdateLocker dummy( this );
377 
378  if( m_drawToolBar )
379  {
381  }
382  else
383  {
384  m_drawToolBar = new ACTION_TOOLBAR( this, ID_V_TOOLBAR, wxDefaultPosition, wxDefaultSize,
385  KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
387  }
388 
389  // Groups contained on this toolbar
390  static ACTION_GROUP* dimensionGroup = nullptr;
391  static ACTION_GROUP* originGroup = nullptr;
392  static ACTION_GROUP* routingGroup = nullptr;
393  static ACTION_GROUP* microwaveGroup = nullptr;
394 
395  if( !dimensionGroup )
396  {
397  dimensionGroup = new ACTION_GROUP( "group.pcbDimensions",
402  }
403 
404  if( !originGroup )
405  {
406  originGroup = new ACTION_GROUP( "group.pcbOrigins",
409  }
410 
411  if( !routingGroup )
412  {
413  routingGroup = new ACTION_GROUP( "group.pcbRouting",
416  }
417 
418  if( !microwaveGroup )
419  {
420  microwaveGroup = new ACTION_GROUP( "group.pcbMicrowave",
426  }
427 
431 
436  m_drawToolBar->AddGroup( microwaveGroup, ACTION_TOOLBAR::TOGGLE );
439 
447  m_drawToolBar->AddGroup( dimensionGroup, ACTION_TOOLBAR::TOGGLE );
450 
454 
456 
457  std::unique_ptr<ACTION_MENU> routeMenu = std::make_unique<ACTION_MENU>( false, selTool );
461 
462  routeMenu->AppendSeparator();
463  routeMenu->Add( PCB_ACTIONS::routerSettingsDialog );
465 
466  std::unique_ptr<ACTION_MENU> zoneMenu = std::make_unique<ACTION_MENU>( false, selTool );
467  zoneMenu->Add( PCB_ACTIONS::zoneFillAll );
468  zoneMenu->Add( PCB_ACTIONS::zoneUnfillAll );
469  m_drawToolBar->AddToolContextMenu( PCB_ACTIONS::drawZone, std::move( zoneMenu ) );
470 
471  m_drawToolBar->Realize();
472 }
473 
474 
476 {
477  wxWindowUpdateLocker dummy( this );
478 
479  if( m_auxiliaryToolBar )
480  {
484 
485  // combobox sizes can have changed: apply new best sizes
486  wxAuiToolBarItem* item = m_auxiliaryToolBar->FindTool( ID_AUX_TOOLBAR_PCB_TRACK_WIDTH );
487  item->SetMinSize( m_SelTrackWidthBox->GetBestSize() );
489  item->SetMinSize( m_SelViaSizeBox->GetBestSize() );
490 
491  m_auxiliaryToolBar->Realize();
492  m_auimgr.Update();
493  return;
494  }
495 
497  wxDefaultPosition, wxDefaultSize,
498  KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT );
499 
500  /* Set up toolbar items */
501 
502  // Creates box to display and choose tracks widths:
503  if( m_SelTrackWidthBox == nullptr )
505  wxDefaultPosition, wxDefaultSize, 0, NULL );
506 
508  m_auxiliaryToolBar->AddControl( m_SelTrackWidthBox );
509 
510  // Creates box to display and choose vias diameters:
511 
512  if( m_SelViaSizeBox == nullptr )
514  wxDefaultPosition, wxDefaultSize, 0, NULL );
515 
517  m_auxiliaryToolBar->AddControl( m_SelViaSizeBox );
519 
520  // Creates box to display and choose strategy to handle tracks an vias sizes:
523  _( "Auto track width: when starting on an existing track "
524  "use its width\notherwise, use current width setting" ),
525  wxITEM_CHECK );
526 
527  // Add the box to display and select the current grid size:
529 
530  if( m_gridSelectBox == nullptr )
532  wxDefaultPosition, wxDefaultSize, 0, NULL );
533 
535 
536  m_auxiliaryToolBar->AddControl( m_gridSelectBox );
537 
538  // Add the box to display and select the current Zoom
540 
541  if( m_zoomSelectBox == nullptr )
543  wxDefaultPosition, wxDefaultSize, 0, NULL );
544 
546  m_auxiliaryToolBar->AddControl( m_zoomSelectBox );
547 
548  // after adding the buttons to the toolbar, must call Realize()
549  m_auxiliaryToolBar->Realize();
550 }
551 
552 
553 static wxString ComboBoxUnits( EDA_UNITS aUnits, double aValue, bool aIncludeLabel = true )
554 {
555  wxString text;
556  const wxChar* format;
557 
558  switch( aUnits )
559  {
560  default: wxASSERT_MSG( false, "Invalid unit" ); KI_FALLTHROUGH;
561  case EDA_UNITS::UNSCALED: format = wxT( "%.0f" ); break;
562  case EDA_UNITS::MILLIMETRES: format = wxT( "%.3f" ); break;
563  case EDA_UNITS::MILS: format = wxT( "%.2f" ); break;
564  case EDA_UNITS::INCHES: format = wxT( "%.5f" ); break;
565  }
566 
567  text.Printf( format, To_User_Unit( aUnits, aValue ) );
568 
569  if( aIncludeLabel )
570  {
571  text += " ";
573  }
574 
575  return text;
576 }
577 
578 
579 void PCB_EDIT_FRAME::UpdateTrackWidthSelectBox( wxChoice* aTrackWidthSelectBox, bool aEdit )
580 {
581  if( aTrackWidthSelectBox == NULL )
582  return;
583 
584  EDA_UNITS primaryUnit;
585  EDA_UNITS secondaryUnit;
586 
587  GetUnitPair( primaryUnit, secondaryUnit );
588 
589  wxString msg;
590 
591  aTrackWidthSelectBox->Clear();
592 
593  aTrackWidthSelectBox->Append( _( "Track: use netclass width" ) );
594 
595  for( unsigned ii = 1; ii < GetDesignSettings().m_TrackWidthList.size(); ii++ )
596  {
597  int size = GetDesignSettings().m_TrackWidthList[ii];
598 
599  msg.Printf( _( "Track: %s (%s)" ), ComboBoxUnits( primaryUnit, size ),
600  ComboBoxUnits( secondaryUnit, size ) );
601 
602  aTrackWidthSelectBox->Append( msg );
603  }
604 
605  if( aEdit )
606  {
607  aTrackWidthSelectBox->Append( wxT( "---" ) );
608  aTrackWidthSelectBox->Append( _( "Edit Pre-defined Sizes..." ) );
609  }
610 
611  if( GetDesignSettings().GetTrackWidthIndex() >= GetDesignSettings().m_TrackWidthList.size() )
613 
614  aTrackWidthSelectBox->SetSelection( GetDesignSettings().GetTrackWidthIndex() );
615 }
616 
617 
618 void PCB_EDIT_FRAME::UpdateViaSizeSelectBox( wxChoice* aViaSizeSelectBox, bool aEdit )
619 {
620  if( aViaSizeSelectBox == NULL )
621  return;
622 
623  aViaSizeSelectBox->Clear();
624 
626 
627  EDA_UNITS primaryUnit = GetUserUnits();
628  EDA_UNITS secondaryUnit = EDA_UNITS::MILS;
629 
630  if( EDA_UNIT_UTILS::IsImperialUnit( primaryUnit ) )
631  {
632  if( cmnTool )
633  secondaryUnit = cmnTool->GetLastMetricUnits();
634  else
635  secondaryUnit = EDA_UNITS::MILLIMETRES;
636  }
637  else
638  {
639  if( cmnTool )
640  secondaryUnit = cmnTool->GetLastImperialUnits();
641  else
642  secondaryUnit = EDA_UNITS::MILS;
643  }
644 
645  aViaSizeSelectBox->Append( _( "Via: use netclass sizes" ) );
646 
647  for( unsigned ii = 1; ii < GetDesignSettings().m_ViasDimensionsList.size(); ii++ )
648  {
650  wxString msg, priStr, secStr;
651 
652  double diam = viaDimension.m_Diameter;
653  double hole = viaDimension.m_Drill;
654 
655  if( hole > 0 )
656  {
657  priStr = ComboBoxUnits( primaryUnit, diam, false ) + " / "
658  + ComboBoxUnits( primaryUnit, hole, true );
659  secStr = ComboBoxUnits( secondaryUnit, diam, false ) + " / "
660  + ComboBoxUnits( secondaryUnit, hole, true );
661  }
662  else
663  {
664  priStr = ComboBoxUnits( primaryUnit, diam, true );
665  secStr = ComboBoxUnits( secondaryUnit, diam, true );
666  }
667 
668  msg.Printf( _( "Via: %s (%s)" ), priStr, secStr );
669 
670  aViaSizeSelectBox->Append( msg );
671  }
672 
673  if( aEdit )
674  {
675  aViaSizeSelectBox->Append( wxT( "---" ) );
676  aViaSizeSelectBox->Append( _( "Edit Pre-defined Sizes..." ) );
677  }
678 
679  if( GetDesignSettings().GetViaSizeIndex() >= GetDesignSettings().m_ViasDimensionsList.size() )
681 
682  aViaSizeSelectBox->SetSelection( GetDesignSettings().GetViaSizeIndex() );
683 }
684 
685 
686 void PCB_EDIT_FRAME::ReCreateLayerBox( bool aForceResizeToolbar )
687 {
688  if( m_SelLayerBox == NULL || m_mainToolBar == NULL )
689  return;
690 
691  m_SelLayerBox->SetToolTip( _( "+/- to switch" ) );
693 
694  if( aForceResizeToolbar )
695  {
696  // the layer box can have its size changed
697  // Update the aui manager, to take in account the new size
698  m_auimgr.Update();
699  }
700 }
701 
702 
704 {
705  // show auxiliary Vertical layers and visibility manager toolbar
707  m_auimgr.GetPane( "LayersManager" ).Show( m_show_layer_manager_tools );
708  m_auimgr.GetPane( "SelectionFilter" ).Show( m_show_layer_manager_tools );
709  m_auimgr.Update();
710 }
711 
712 
713 void PCB_EDIT_FRAME::OnUpdateSelectTrackWidth( wxUpdateUIEvent& aEvent )
714 {
715  if( aEvent.GetId() == ID_AUX_TOOLBAR_PCB_TRACK_WIDTH )
716  {
718  int sel;
719 
720  if( bds.UseCustomTrackViaSize() )
721  sel = wxNOT_FOUND;
722  else
723  sel = bds.GetTrackWidthIndex();
724 
725  if( m_SelTrackWidthBox->GetSelection() != sel )
726  m_SelTrackWidthBox->SetSelection( sel );
727  }
728 }
729 
730 
731 void PCB_EDIT_FRAME::OnUpdateSelectViaSize( wxUpdateUIEvent& aEvent )
732 {
733  if( aEvent.GetId() == ID_AUX_TOOLBAR_PCB_VIA_SIZE )
734  {
736  int sel = 0;
737 
738  if( bds.UseCustomTrackViaSize() )
739  sel = wxNOT_FOUND;
740  else
741  sel = bds.GetViaSizeIndex();
742 
743  if( m_SelViaSizeBox->GetSelection() != sel )
744  m_SelViaSizeBox->SetSelection( sel );
745  }
746 }
747 
748 
749 void PCB_EDIT_FRAME::OnUpdateSelectAutoWidth( wxUpdateUIEvent& aEvent )
750 {
752 
753  aEvent.Check( bds.m_UseConnectedTrackWidth && !bds.UseCustomTrackViaSize() );
754 }
755 
756 
757 void PCB_EDIT_FRAME::OnUpdateLayerSelectBox( wxUpdateUIEvent& aEvent )
758 {
761 }
static TOOL_ACTION drawLine
Definition: pcb_actions.h:145
static TOOL_ACTION drawCenterDimension
Definition: pcb_actions.h:152
Struct VIA_DIMENSION is a small helper container to handle a stock of specific vias each with unique ...
static TOOL_ACTION placeModule
Definition: pcb_actions.h:161
ACTION_TOOLBAR.
void SetTrackWidthIndex(unsigned aIndex)
Function SetTrackWidthIndex sets the current track width list index to aIndex.
virtual BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Returns the BOARD_DESIGN_SETTINGS for the open project Overloaded in FOOTPRINT_EDIT_FRAME.
static TOOL_ACTION selectLayerPair
Definition: pcb_actions.h:132
static TOOL_ACTION zoomInCenter
Definition: actions.h:91
EDA_UNITS GetLastMetricUnits()
Definition: common_tools.h:75
static TOOL_ACTION pageSettings
Definition: actions.h:59
static const char s_BitmapLayerIcon[BM_LAYERICON_SIZE][BM_LAYERICON_SIZE]
static TOOL_ACTION drillOrigin
Definition: pcb_actions.h:427
ACTION_TOOLBAR * m_auxiliaryToolBar
static TOOL_ACTION zoneFillAll
Definition: pcb_actions.h:303
void AddToolContextMenu(const TOOL_ACTION &aAction, std::unique_ptr< ACTION_MENU > aMenu)
Add a context menu to a specific tool item on the toolbar.
static TOOL_ACTION drawArc
Definition: pcb_actions.h:149
std::vector< int > m_TrackWidthList
ACTION_TOOLBAR * m_optionsToolBar
static TOOL_ACTION microwaveCreateStubArc
Definition: pcb_actions.h:405
static constexpr bool TOGGLE
static TOOL_ACTION ratsnestLineMode
Definition: pcb_actions.h:239
static TOOL_ACTION zoomTool
Definition: actions.h:97
static TOOL_ACTION zoneDisplayOutlines
Definition: pcb_actions.h:245
SELECTION_TOOL.
void AddScaledSeparator(wxWindow *aWindow)
Add a separator that introduces space on either side to not squash the tools when scaled.
void OnUpdateLayerSelectBox(wxUpdateUIEvent &aEvent)
wxChoice * m_SelViaSizeBox
void Add(const TOOL_ACTION &aAction, bool aIsToggleEntry=false, bool aIsCancellable=false)
Adds a TOOL_ACTION-based button to the toolbar.
static TOOL_ACTION drawAlignedDimension
Definition: pcb_actions.h:151
int KiIconScale(wxWindow *aWindow)
Return the automatic scale factor that would be used for a given window by KiScaledBitmap and KiScale...
Definition: bitmap.cpp:92
static TOOL_ACTION zoneDisplayDisable
Definition: pcb_actions.h:244
static TOOL_ACTION drawOrthogonalDimension
Definition: pcb_actions.h:153
static TOOL_ACTION zoomFitScreen
Definition: actions.h:94
static TOOL_ACTION millimetersUnits
Definition: actions.h:144
static TOOL_ACTION drawPolygon
Definition: pcb_actions.h:146
void ReCreateLayerBox(bool aForceResizeToolbar=true)
Re create the layer Box by clearing the old list, and building le new one, from the new layers names ...
static TOOL_ACTION routerHighlightMode
Actions to enable switching modes via hotkey assignments.
Definition: pcb_actions.h:200
COLOR4D WithAlpha(double aAlpha) const
Function WithAlpha Returns a colour with the same colour, but the given alpha.
Definition: color4d.h:315
static TOOL_ACTION microwaveCreateLine
Definition: pcb_actions.h:409
static TOOL_ACTION showPythonConsole
Definition: pcb_actions.h:342
void SetAuiManager(wxAuiManager *aManager)
Set the AUI manager that this toolbar belongs to.
void UpdateZoomSelectBox()
Rebuild the grid combobox to respond to any changes in the GUI (units, user grid changes,...
static TOOL_ACTION showLayersManager
Definition: pcb_actions.h:341
#define KI_FALLTHROUGH
The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely fallthrough from ...
Definition: macros.h:83
void AddGroup(ACTION_GROUP *aGroup, bool aIsToggleEntry=false)
Add a set of actions to a toolbar as a group.
static TOOL_ACTION updatePcbFromSchematic
Definition: actions.h:161
Class to display a pcb layer list in a wxBitmapComboBox.
wxString GetAbbreviatedUnitsLabel(EDA_UNITS aUnit, EDA_DATA_TYPE aType)
Get the units string for a given units type.
Definition: base_units.cpp:467
wxAuiManager m_auimgr
static TOOL_ACTION zoomFitObjects
Definition: actions.h:95
void SetBoardFrame(PCB_BASE_FRAME *aFrame)
ACTION_TOOLBAR * m_mainToolBar
void ReCreateHToolbar() override
static TOOL_ACTION print
Definition: actions.h:60
static TOOL_ACTION localRatsnestTool
Definition: pcb_actions.h:449
static TOOL_ACTION find
Definition: actions.h:79
#define BM_LAYERICON_SIZE
wxChoice * m_SelTrackWidthBox
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:102
wxBitmap KiScaledBitmap(BITMAP_DEF aBitmap, wxWindow *aWindow)
Construct a wxBitmap from a memory record, scaling it if device DPI demands it.
Definition: bitmap.cpp:118
wxChoice * m_gridSelectBox
static TOOL_ACTION placeText
Definition: pcb_actions.h:150
bool IsImperialUnit(EDA_UNITS aUnit)
Definition: eda_units.cpp:26
static TOOL_ACTION zoomOutCenter
Definition: actions.h:92
bool m_show_layer_manager_tools
virtual PCB_LAYER_ID GetActiveLayer() const
void UpdateGridSelectBox()
Rebuild the grid combobox to respond to any changes in the GUI (units, user grid changes,...
void UpdateTrackWidthSelectBox(wxChoice *aTrackWidthSelectBox, bool aEdit=true)
void SetViaSizeIndex(unsigned aIndex)
Function SetViaSizeIndex sets the current via size list index to aIndex.
static TOOL_ACTION highlightNetTool
Definition: pcb_actions.h:442
LAYER_NUM GetLayerSelection() const
static TOOL_ACTION measureTool
Definition: actions.h:152
A group of actions that will be displayed together on a toolbar palette.
static constexpr bool CANCEL
static TOOL_ACTION routerSettingsDialog
Activation of the Push and Shove settings dialogs.
Definition: pcb_actions.h:196
#define NULL
COLOR_SETTINGS * GetColorSettings() override
Helper to retrieve the current color settings.
static TOOL_ACTION toggleGrid
Definition: actions.h:138
unsigned GetViaSizeIndex() const
Function GetViaSizeIndex.
static TOOL_ACTION open
Definition: actions.h:53
static TOOL_ACTION showFootprintBrowser
Definition: actions.h:159
static TOOL_ACTION inchesUnits
Definition: actions.h:142
static TOOL_ACTION save
Definition: actions.h:54
wxChoice * m_zoomSelectBox
static TOOL_ACTION doNew
Definition: actions.h:47
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
void ReCreateVToolbar() override
unsigned GetTrackWidthIndex() const
Function GetTrackWidthIndex.
static TOOL_ACTION togglePolarCoords
Definition: actions.h:147
void OnUpdateSelectAutoWidth(wxUpdateUIEvent &aEvent)
Helper dialog and control classes.
static TOOL_ACTION showRatsnest
Definition: pcb_actions.h:238
static TOOL_ACTION drawRectangle
Definition: pcb_actions.h:147
EDA_UNITS GetLastImperialUnits()
Definition: common_tools.h:76
int SetLayerSelection(LAYER_NUM layer)
static TOOL_ACTION microwaveCreateGap
Definition: pcb_actions.h:401
static TOOL_ACTION plot
Definition: actions.h:61
static TOOL_ACTION drawVia
Definition: pcb_actions.h:156
static TOOL_ACTION showEeschema
Definition: pcb_actions.h:430
const BITMAP_OPAQUE auto_track_width_xpm[1]
static TOOL_ACTION routerWalkaroundMode
Definition: pcb_actions.h:202
static TOOL_ACTION placeTarget
Definition: pcb_actions.h:160
static TOOL_ACTION zoneUnfillAll
Definition: pcb_actions.h:305
static TOOL_ACTION milsUnits
Definition: actions.h:143
static TOOL_ACTION boardSetup
Definition: pcb_actions.h:312
COMMON_TOOLS.
Definition: common_tools.h:38
static TOOL_ACTION microwaveCreateStub
Definition: pcb_actions.h:403
void PrepareLayerIndicator(bool aForceRebuild=false)
static TOOL_ACTION padDisplayMode
Definition: pcb_actions.h:241
static TOOL_ACTION drawCircle
Definition: pcb_actions.h:148
static TOOL_ACTION viaDisplayMode
Definition: pcb_actions.h:242
EDA_UNITS
Definition: eda_units.h:38
static TOOL_ACTION redo
Definition: actions.h:68
COLOR4D GetColor(int aLayer) const
static TOOL_ACTION microwaveCreateFunctionShape
Definition: pcb_actions.h:407
double To_User_Unit(EDA_UNITS aUnit, double aValue)
Function To_User_Unit convert aValue in internal units to the appropriate user units defined by aUnit...
Definition: base_units.cpp:91
static constexpr bool CHECK
Definition: action_menu.h:162
static TOOL_ACTION drawLeader
Definition: pcb_actions.h:154
const int scale
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:48
static TOOL_ACTION drawRuleArea
Definition: pcb_actions.h:157
see class PGM_BASE
Meta control for all vias opacity/visibility.
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
static TOOL_ACTION routeSingleTrack
Activation of the Push and Shove router.
Definition: pcb_actions.h:179
LAYER_TOOLBAR_ICON_VALUES m_prevIconVal
#define _(s)
Definition: 3d_actions.cpp:33
static TOOL_ACTION zoomRedraw
Definition: actions.h:88
void OnUpdateSelectViaSize(wxUpdateUIEvent &aEvent)
void ReCreateOptToolbar() override
void SetToolBitmap(const TOOL_ACTION &aAction, const wxBitmap &aBitmap)
Updates the bitmap of a particular tool.
static TOOL_ACTION runDRC
Definition: pcb_actions.h:338
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
std::vector< VIA_DIMENSION > m_ViasDimensionsList
static constexpr int KICAD_AUI_TB_STYLE
Default style flags used for wxAUI toolbars
static TOOL_ACTION gridProperties
Definition: actions.h:139
static TOOL_ACTION deleteTool
Definition: actions.h:76
void OnUpdateSelectTrackWidth(wxUpdateUIEvent &aEvent)
static TOOL_ACTION undo
Definition: actions.h:67
bool IsWxPythonLoaded()
void UpdateViaSizeSelectBox(wxChoice *aViaSizeSelectBox, bool aEdit=true)
static TOOL_ACTION toggleCursorStyle
Definition: actions.h:100
PCB_LAYER_BOX_SELECTOR * m_SelLayerBox
static TOOL_ACTION gridSetOrigin
Definition: actions.h:135
static std::unique_ptr< wxBitmap > LayerPairBitmap
static TOOL_ACTION routerShoveMode
Definition: pcb_actions.h:201
static TOOL_ACTION highContrastMode
Definition: actions.h:101
static TOOL_ACTION showFootprintEditor
Definition: actions.h:160
static TOOL_ACTION drawZone
Definition: pcb_actions.h:155
void ReCreateAuxiliaryToolbar() override
void GetUnitPair(EDA_UNITS &aPrimaryUnit, EDA_UNITS &aSecondaryUnits)
Get the pair or units in current use.
EDA_UNITS GetUserUnits() const
Return the user units currently in use.
static TOOL_ACTION trackDisplayMode
Definition: pcb_actions.h:240
static TOOL_ACTION selectionTool
Definition: actions.h:151
void UseCustomTrackViaSize(bool aEnabled)
Function UseCustomTrackViaSize Enables/disables custom track/via size settings.
static wxString ComboBoxUnits(EDA_UNITS aUnits, double aValue, bool aIncludeLabel=true)
BOARD_DESIGN_SETTINGS contains design settings for a BOARD object.
void ClearToolbar()
Clear the toolbar and remove all associated menus.
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:100
static TOOL_ACTION zoneDisplayEnable
Definition: pcb_actions.h:243
ACTION_TOOLBAR * m_drawToolBar
static TOOL_ACTION routeDiffPair
Activation of the Push and Shove router (differential pair mode)
Definition: pcb_actions.h:182