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 <board.h>
31 #include <dialog_helpers.h>
32 #include <kiface_i.h>
33 #include <macros.h>
34 #include <pcb_edit_frame.h>
35 #include <pcb_layer_box_selector.h>
36 #include <pcbnew_id.h>
37 #include <pcbnew_settings.h>
38 #include <pgm_base.h>
40 #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>
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 white
62  // 1 = draw pixel with black
63  // 2 = draw pixel with top layer from router pair
64  // 3 = draw pixel with bottom layer from router pair
65  { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3 },
66  { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3 },
67  { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3, 3 },
68  { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3, 3 },
69  { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3, 3, 3 },
70  { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3, 3, 3 },
71  { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3, 3, 3, 3 },
72  { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3, 3, 3, 3 },
73  { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
74  { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
75  { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
76  { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
77  { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
78  { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
79  { 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
80  { 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
81  { 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
82  { 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
83  { 2, 2, 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
84  { 2, 2, 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
85  { 2, 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
86  { 2, 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
87  { 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
88  { 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
89 };
90 
91 static COLOR4D ICON_WHITE { 0.86, 0.86, 0.86, 1.0 };
92 static COLOR4D ICON_BLACK { 0.28, 0.28, 0.28, 1.0 };
93 
94 
95 void PCB_EDIT_FRAME::PrepareLayerIndicator( bool aForceRebuild )
96 {
97  int ii, jj;
98  COLOR4D top_color, bottom_color, background_color;
99  bool change = aForceRebuild;
100 
101  int requested_scale = Pgm().GetCommonSettings()->m_Appearance.icon_scale;
102 
103  if( m_prevIconVal.previous_requested_scale != requested_scale )
104  {
105  m_prevIconVal.previous_requested_scale = requested_scale;
106  change = true;
107  }
108 
109  top_color = GetColorSettings()->GetColor( GetScreen()->m_Route_Layer_TOP );
110 
112  {
114  change = true;
115  }
116 
117  bottom_color = GetColorSettings()->GetColor( GetScreen()->m_Route_Layer_BOTTOM );
118 
120  {
122  change = true;
123  }
124 
125  background_color = GetColorSettings()->GetColor( LAYER_PCB_BACKGROUND );
126 
127  if( m_prevIconVal.previous_background_color != background_color )
128  {
129  m_prevIconVal.previous_background_color = background_color;
130  change = true;
131  }
132 
133  if( change || !LayerPairBitmap )
134  {
135  LayerPairBitmap = std::make_unique<wxBitmap>( 24, 24 );
136 
137  // Draw the icon, with colors according to the router's layer pair
138  wxMemoryDC iconDC;
139  iconDC.SelectObject( *LayerPairBitmap );
140  wxBrush brush;
141  wxPen pen;
142  int buttonColor = -1;
143 
144  brush.SetStyle( wxBRUSHSTYLE_SOLID );
145  brush.SetColour( background_color.WithAlpha(1.0).ToColour() );
146  iconDC.SetBrush( brush );
147  iconDC.DrawRectangle( 0, 0, BM_LAYERICON_SIZE, BM_LAYERICON_SIZE );
148 
149  for( ii = 0; ii < BM_LAYERICON_SIZE; ii++ )
150  {
151  for( jj = 0; jj < BM_LAYERICON_SIZE; jj++ )
152  {
153  if( s_BitmapLayerIcon[ii][jj] != buttonColor )
154  {
155  switch( s_BitmapLayerIcon[ii][jj] )
156  {
157  default:
158  case 0: pen.SetColour( ICON_WHITE.ToColour() ); break;
159  case 1: pen.SetColour( ICON_BLACK.ToColour() ); break;
160  case 2: pen.SetColour( top_color.ToColour() ); break;
161  case 3: pen.SetColour( bottom_color.ToColour() ); break;
162  }
163 
164  buttonColor = s_BitmapLayerIcon[ii][jj];
165  iconDC.SetPen( pen );
166  }
167 
168  iconDC.DrawPoint( jj, ii );
169  }
170  }
171 
172  // Deselect the bitmap from the DC in order to delete the MemoryDC safely without
173  // deleting the bitmap
174  iconDC.SelectObject( wxNullBitmap );
175 
176  // Scale the bitmap
177  const int scale = ( requested_scale <= 0 ) ? KiIconScale( this ) : requested_scale;
178  wxImage image = LayerPairBitmap->ConvertToImage();
179 
180  // "NEAREST" causes less mixing of colors
181  image.Rescale( scale * image.GetWidth() / 4, scale * image.GetHeight() / 4,
182  wxIMAGE_QUALITY_NEAREST );
183 
184  LayerPairBitmap = std::make_unique<wxBitmap>( image );
185 
186  if( m_mainToolBar )
187  {
189  m_mainToolBar->Refresh();
190  }
191  }
192 }
193 
194 
196 {
197  // Note:
198  // To rebuild the aui toolbar, the more easy way is to clear ( calling m_mainToolBar.Clear() )
199  // all wxAuiToolBarItems.
200  // However the wxAuiToolBarItems are not the owners of controls managed by
201  // them and therefore do not delete them
202  // So we do not recreate them after clearing the tools.
203 
204  wxWindowUpdateLocker dummy( this );
205 
206  if( m_mainToolBar )
207  {
209  }
210  else
211  {
212  m_mainToolBar = new ACTION_TOOLBAR( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
213  KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT | wxAUI_TB_HORIZONTAL );
215 
216  // The layer indicator is special, so we register a callback directly that will regenerate the
217  // bitmap instead of using the conditions system
218  auto layerIndicatorUpdate =
219  [this] ( wxUpdateUIEvent& )
220  {
222  };
223 
224  Bind( wxEVT_UPDATE_UI, layerIndicatorUpdate, PCB_ACTIONS::selectLayerPair.GetUIId() );
225  }
226 
227  // Set up toolbar
228  if( Kiface().IsSingle() )
229  {
232  }
233 
235 
238 
243 
247 
250 
258 
266 
270 
272 
273  if( !Kiface().IsSingle() )
275  else
277 
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  // Go through and ensure the comboboxes are the correct size, since the strings in the
311  // box could have changed widths.
313 
314  // after adding the buttons to the toolbar, must call Realize() to reflect the changes
316 }
317 
318 
320 {
321  // Note:
322  // To rebuild the aui toolbar, the more easy way is to clear ( calling m_mainToolBar.Clear() )
323  // all wxAuiToolBarItems.
324  // However the wxAuiToolBarItems are not the owners of controls managed by
325  // them and therefore do not delete them
326  // So we do not recreate them after clearing the tools.
327 
328  wxWindowUpdateLocker dummy( this );
329 
330  if( m_optionsToolBar )
331  {
333  }
334  else
335  {
337  wxDefaultPosition, wxDefaultSize,
338  KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
340  }
341 
343 
349 
353 
358 
364 
365  // Tools to show/hide toolbars:
368 
370  std::unique_ptr<ACTION_MENU> gridMenu = std::make_unique<ACTION_MENU>( false, selTool );
371  gridMenu->Add( ACTIONS::gridProperties );
372  m_optionsToolBar->AddToolContextMenu( ACTIONS::toggleGrid, std::move( gridMenu ) );
373 
375 }
376 
377 
379 {
380  wxWindowUpdateLocker dummy( this );
381 
382  if( m_drawToolBar )
383  {
385  }
386  else
387  {
388  m_drawToolBar = new ACTION_TOOLBAR( this, ID_V_TOOLBAR, wxDefaultPosition, wxDefaultSize,
389  KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
391  }
392 
393  // Groups contained on this toolbar
394  static ACTION_GROUP* dimensionGroup = nullptr;
395  static ACTION_GROUP* originGroup = nullptr;
396  static ACTION_GROUP* routingGroup = nullptr;
397  static ACTION_GROUP* microwaveGroup = nullptr;
398 
399  if( !dimensionGroup )
400  {
401  dimensionGroup = new ACTION_GROUP( "group.pcbDimensions",
406  }
407 
408  if( !originGroup )
409  {
410  originGroup = new ACTION_GROUP( "group.pcbOrigins",
413  }
414 
415  if( !routingGroup )
416  {
417  routingGroup = new ACTION_GROUP( "group.pcbRouting",
420  }
421 
422  if( !microwaveGroup )
423  {
424  microwaveGroup = new ACTION_GROUP( "group.pcbMicrowave",
430  }
431 
435 
440  m_drawToolBar->AddGroup( microwaveGroup, ACTION_TOOLBAR::TOGGLE );
443 
451  m_drawToolBar->AddGroup( dimensionGroup, ACTION_TOOLBAR::TOGGLE );
454 
458 
460 
461  std::unique_ptr<ACTION_MENU> routeMenu = std::make_unique<ACTION_MENU>( false, selTool );
465 
466  routeMenu->AppendSeparator();
467  routeMenu->Add( PCB_ACTIONS::routerSettingsDialog );
469 
470  std::unique_ptr<ACTION_MENU> zoneMenu = std::make_unique<ACTION_MENU>( false, selTool );
471  zoneMenu->Add( PCB_ACTIONS::zoneFillAll );
472  zoneMenu->Add( PCB_ACTIONS::zoneUnfillAll );
473  m_drawToolBar->AddToolContextMenu( PCB_ACTIONS::drawZone, std::move( zoneMenu ) );
474 
475  std::unique_ptr<ACTION_MENU> lineMenu = std::make_unique<ACTION_MENU>( false, selTool );
477  m_drawToolBar->AddToolContextMenu( PCB_ACTIONS::drawLine, std::move( lineMenu ) );
478 
480 }
481 
482 
484 {
485  wxWindowUpdateLocker dummy( this );
486 
487  if( m_auxiliaryToolBar )
488  {
490  }
491  else
492  {
493  m_auxiliaryToolBar = new ACTION_TOOLBAR( this, ID_AUX_TOOLBAR, wxDefaultPosition, wxDefaultSize,
494  KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT );
496  }
497 
498  /* Set up toolbar items */
499 
500  // Creates box to display and choose tracks widths:
501  if( m_SelTrackWidthBox == nullptr )
503  wxDefaultPosition, wxDefaultSize, 0, NULL );
504 
506  m_auxiliaryToolBar->AddControl( m_SelTrackWidthBox );
507 
508  // Creates box to display and choose vias diameters:
509 
510  if( m_SelViaSizeBox == nullptr )
512  wxDefaultPosition, wxDefaultSize, 0, NULL );
513 
515  m_auxiliaryToolBar->AddControl( m_SelViaSizeBox );
517 
518  // Creates box to display and choose strategy to handle tracks an vias sizes:
521  _( "When routing from an existing track use its width instead "
522  "of the current width setting" ),
523  wxITEM_CHECK );
524 
525  // Add the box to display and select the current grid size:
527 
528  if( m_gridSelectBox == nullptr )
530  wxDefaultPosition, wxDefaultSize, 0, NULL );
531 
533 
534  m_auxiliaryToolBar->AddControl( m_gridSelectBox );
535 
536  // Add the box to display and select the current Zoom
538 
539  if( m_zoomSelectBox == nullptr )
541  wxDefaultPosition, wxDefaultSize, 0, NULL );
542 
544  m_auxiliaryToolBar->AddControl( m_zoomSelectBox );
545 
546  // Go through and ensure the comboboxes are the correct size, since the strings in the
547  // box could have changed widths.
552 
553  // after adding the buttons to the toolbar, must call Realize()
555 }
556 
557 
559 {
560  if( m_mainToolBar )
561  {
562  // Update the item widths
564  }
565 
566  if( m_auxiliaryToolBar )
567  {
568  // Update the item widths
573  }
574 }
575 
576 
577 static wxString ComboBoxUnits( EDA_UNITS aUnits, double aValue, bool aIncludeLabel = true )
578 {
579  wxString text;
580  const wxChar* format;
581 
582  switch( aUnits )
583  {
584  default: wxASSERT_MSG( false, "Invalid unit" ); KI_FALLTHROUGH;
585  case EDA_UNITS::UNSCALED: format = wxT( "%.0f" ); break;
586  case EDA_UNITS::MILLIMETRES: format = wxT( "%.3f" ); break;
587  case EDA_UNITS::MILS: format = wxT( "%.2f" ); break;
588  case EDA_UNITS::INCHES: format = wxT( "%.5f" ); break;
589  }
590 
591  text.Printf( format, To_User_Unit( aUnits, aValue ) );
592 
593  if( aIncludeLabel )
594  {
595  text += " ";
597  }
598 
599  return text;
600 }
601 
602 
603 void PCB_EDIT_FRAME::UpdateTrackWidthSelectBox( wxChoice* aTrackWidthSelectBox, bool aEdit )
604 {
605  if( aTrackWidthSelectBox == NULL )
606  return;
607 
608  EDA_UNITS primaryUnit;
609  EDA_UNITS secondaryUnit;
610 
611  GetUnitPair( primaryUnit, secondaryUnit );
612 
613  wxString msg;
614 
615  aTrackWidthSelectBox->Clear();
616 
617  aTrackWidthSelectBox->Append( _( "Track: use netclass width" ) );
618 
619  for( unsigned ii = 1; ii < GetDesignSettings().m_TrackWidthList.size(); ii++ )
620  {
621  int size = GetDesignSettings().m_TrackWidthList[ii];
622 
623  msg.Printf( _( "Track: %s (%s)" ), ComboBoxUnits( primaryUnit, size ),
624  ComboBoxUnits( secondaryUnit, size ) );
625 
626  aTrackWidthSelectBox->Append( msg );
627  }
628 
629  if( aEdit )
630  {
631  aTrackWidthSelectBox->Append( wxT( "---" ) );
632  aTrackWidthSelectBox->Append( _( "Edit Pre-defined Sizes..." ) );
633  }
634 
635  if( GetDesignSettings().GetTrackWidthIndex() >= GetDesignSettings().m_TrackWidthList.size() )
637 
638  aTrackWidthSelectBox->SetSelection( GetDesignSettings().GetTrackWidthIndex() );
639 }
640 
641 
642 void PCB_EDIT_FRAME::UpdateViaSizeSelectBox( wxChoice* aViaSizeSelectBox, bool aEdit )
643 {
644  if( aViaSizeSelectBox == NULL )
645  return;
646 
647  aViaSizeSelectBox->Clear();
648 
650 
651  EDA_UNITS primaryUnit = GetUserUnits();
652  EDA_UNITS secondaryUnit = EDA_UNITS::MILS;
653 
654  if( EDA_UNIT_UTILS::IsImperialUnit( primaryUnit ) )
655  {
656  if( cmnTool )
657  secondaryUnit = cmnTool->GetLastMetricUnits();
658  else
659  secondaryUnit = EDA_UNITS::MILLIMETRES;
660  }
661  else
662  {
663  if( cmnTool )
664  secondaryUnit = cmnTool->GetLastImperialUnits();
665  else
666  secondaryUnit = EDA_UNITS::MILS;
667  }
668 
669  aViaSizeSelectBox->Append( _( "Via: use netclass sizes" ) );
670 
671  for( unsigned ii = 1; ii < GetDesignSettings().m_ViasDimensionsList.size(); ii++ )
672  {
674  wxString msg, priStr, secStr;
675 
676  double diam = viaDimension.m_Diameter;
677  double hole = viaDimension.m_Drill;
678 
679  if( hole > 0 )
680  {
681  priStr = ComboBoxUnits( primaryUnit, diam, false ) + " / "
682  + ComboBoxUnits( primaryUnit, hole, true );
683  secStr = ComboBoxUnits( secondaryUnit, diam, false ) + " / "
684  + ComboBoxUnits( secondaryUnit, hole, true );
685  }
686  else
687  {
688  priStr = ComboBoxUnits( primaryUnit, diam, true );
689  secStr = ComboBoxUnits( secondaryUnit, diam, true );
690  }
691 
692  msg.Printf( _( "Via: %s (%s)" ), priStr, secStr );
693 
694  aViaSizeSelectBox->Append( msg );
695  }
696 
697  if( aEdit )
698  {
699  aViaSizeSelectBox->Append( wxT( "---" ) );
700  aViaSizeSelectBox->Append( _( "Edit Pre-defined Sizes..." ) );
701  }
702 
703  if( GetDesignSettings().GetViaSizeIndex() >= GetDesignSettings().m_ViasDimensionsList.size() )
705 
706  aViaSizeSelectBox->SetSelection( GetDesignSettings().GetViaSizeIndex() );
707 }
708 
709 
710 void PCB_EDIT_FRAME::ReCreateLayerBox( bool aForceResizeToolbar )
711 {
712  if( m_SelLayerBox == NULL || m_mainToolBar == NULL )
713  return;
714 
715  m_SelLayerBox->SetToolTip( _( "+/- to switch" ) );
717 
718  if( aForceResizeToolbar )
720 }
721 
722 
724 {
725  // show auxiliary Vertical layers and visibility manager toolbar
727  m_auimgr.GetPane( "LayersManager" ).Show( m_show_layer_manager_tools );
728  m_auimgr.GetPane( "SelectionFilter" ).Show( m_show_layer_manager_tools );
729  m_auimgr.Update();
730 }
731 
732 
733 void PCB_EDIT_FRAME::OnUpdateSelectTrackWidth( wxUpdateUIEvent& aEvent )
734 {
735  if( aEvent.GetId() == ID_AUX_TOOLBAR_PCB_TRACK_WIDTH )
736  {
738  int sel;
739 
740  if( bds.UseCustomTrackViaSize() )
741  sel = wxNOT_FOUND;
742  else
743  sel = bds.GetTrackWidthIndex();
744 
745  if( m_SelTrackWidthBox->GetSelection() != sel )
746  m_SelTrackWidthBox->SetSelection( sel );
747  }
748 }
749 
750 
751 void PCB_EDIT_FRAME::OnUpdateSelectViaSize( wxUpdateUIEvent& aEvent )
752 {
753  if( aEvent.GetId() == ID_AUX_TOOLBAR_PCB_VIA_SIZE )
754  {
756  int sel = 0;
757 
758  if( bds.UseCustomTrackViaSize() )
759  sel = wxNOT_FOUND;
760  else
761  sel = bds.GetViaSizeIndex();
762 
763  if( m_SelViaSizeBox->GetSelection() != sel )
764  m_SelViaSizeBox->SetSelection( sel );
765  }
766 }
767 
768 
769 void PCB_EDIT_FRAME::OnUpdateSelectAutoWidth( wxUpdateUIEvent& aEvent )
770 {
772 
773  aEvent.Check( bds.m_UseConnectedTrackWidth && !bds.UseCustomTrackViaSize() );
774 }
775 
776 
777 void PCB_EDIT_FRAME::OnUpdateLayerSelectBox( wxUpdateUIEvent& aEvent )
778 {
781 }
static TOOL_ACTION drawLine
Definition: pcb_actions.h:146
static TOOL_ACTION drawCenterDimension
Definition: pcb_actions.h:153
Container to handle a stock of specific vias each with unique diameter and drill sizes in the BOARD c...
Define the structure of a toolbar with buttons that invoke ACTIONs.
void SetTrackWidthIndex(unsigned aIndex)
Set the current track width list index to aIndex.
static TOOL_ACTION unlock
Definition: pcb_actions.h:423
virtual BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Returns the BOARD_DESIGN_SETTINGS for the open project.
static TOOL_ACTION selectLayerPair
Definition: pcb_actions.h:133
static TOOL_ACTION zoomInCenter
Definition: actions.h:96
EDA_UNITS GetLastMetricUnits()
Definition: common_tools.h:74
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:436
ACTION_TOOLBAR * m_auxiliaryToolBar
static TOOL_ACTION lock
Definition: pcb_actions.h:422
static TOOL_ACTION zoneFillAll
Definition: pcb_actions.h:309
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:150
std::vector< int > m_TrackWidthList
ACTION_TOOLBAR * m_optionsToolBar
static TOOL_ACTION microwaveCreateStubArc
Definition: pcb_actions.h:414
static constexpr bool TOGGLE
static TOOL_ACTION ratsnestLineMode
Definition: pcb_actions.h:245
static TOOL_ACTION zoomTool
Definition: actions.h:102
static TOOL_ACTION zoneDisplayOutlines
Definition: pcb_actions.h:251
void AddScaledSeparator(wxWindow *aWindow)
Add a separator that introduces space on either side to not squash the tools when scaled.
void OnUpdateLayerSelectBox(wxUpdateUIEvent &aEvent)
static TOOL_ACTION toggleLine45degMode
Toggle 45 degree line drawing mode.
Definition: pcb_actions.h:171
wxChoice * m_SelViaSizeBox
void Add(const TOOL_ACTION &aAction, bool aIsToggleEntry=false, bool aIsCancellable=false)
Add a TOOL_ACTION-based button to the toolbar.
static TOOL_ACTION drawAlignedDimension
Definition: pcb_actions.h:152
int KiIconScale(wxWindow *aWindow)
Return the automatic scale factor that would be used for a given window by KiScaledBitmap and KiScale...
Definition: bitmap.cpp:121
static TOOL_ACTION zoneDisplayDisable
Definition: pcb_actions.h:250
static TOOL_ACTION drawOrthogonalDimension
Definition: pcb_actions.h:154
static TOOL_ACTION zoomFitScreen
Definition: actions.h:99
static TOOL_ACTION millimetersUnits
Definition: actions.h:149
static TOOL_ACTION drawPolygon
Definition: pcb_actions.h:147
void ReCreateLayerBox(bool aForceResizeToolbar=true)
Recreate the layer box by clearing the old list and building a new one from the new layer names and c...
static TOOL_ACTION routerHighlightMode
Actions to enable switching modes via hotkey assignments.
Definition: pcb_actions.h:206
COLOR4D WithAlpha(double aAlpha) const
Return a color with the same color, but the given alpha.
Definition: color4d.h:300
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
Definition: sch_symbol.cpp:69
static TOOL_ACTION microwaveCreateLine
Definition: pcb_actions.h:418
static TOOL_ACTION showPythonConsole
Definition: pcb_actions.h:348
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:347
#define KI_FALLTHROUGH
The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely fallthrough from ...
Definition: macros.h:83
static TOOL_ACTION group
Definition: pcb_actions.h:426
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:166
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:410
wxAuiManager m_auimgr
static TOOL_ACTION zoomFitObjects
Definition: actions.h:100
void SetBoardFrame(PCB_BASE_FRAME *aFrame)
ACTION_TOOLBAR * m_mainToolBar
void ReCreateHToolbar() override
static TOOL_ACTION print
Definition: actions.h:60
static TOOL_ACTION ungroup
Definition: pcb_actions.h:427
static TOOL_ACTION localRatsnestTool
Definition: pcb_actions.h:458
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:106
wxChoice * m_gridSelectBox
static TOOL_ACTION placeText
Definition: pcb_actions.h:151
bool KiRealize()
Use this over Realize() to avoid a rendering glitch with fixed orientation toolbars.
bool IsImperialUnit(EDA_UNITS aUnit)
Definition: eda_units.cpp:26
static TOOL_ACTION zoomOutCenter
Definition: actions.h:97
This file contains miscellaneous commonly used macros and functions.
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)
Set the current via size list index to aIndex.
static TOOL_ACTION highlightNetTool
Definition: pcb_actions.h:451
LAYER_NUM GetLayerSelection() const
static TOOL_ACTION measureTool
Definition: actions.h:157
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:202
static TOOL_ACTION rotateCw
Rotation of selected objects.
Definition: pcb_actions.h:105
static TOOL_ACTION importNetlist
Definition: pcb_actions.h:331
#define NULL
static TOOL_ACTION toggleGrid
Definition: actions.h:143
unsigned GetViaSizeIndex() const
static TOOL_ACTION open
Definition: actions.h:53
static TOOL_ACTION showFootprintBrowser
Definition: actions.h:164
static TOOL_ACTION inchesUnits
Definition: actions.h:147
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 UpdateControlWidth(int aID)
Update the toolbar item width of a control using its best size.
void ReCreateVToolbar() override
unsigned GetTrackWidthIndex() const
static TOOL_ACTION togglePolarCoords
Definition: actions.h:152
void OnUpdateSelectAutoWidth(wxUpdateUIEvent &aEvent)
Helper dialog and control classes.
static TOOL_ACTION showRatsnest
Definition: pcb_actions.h:244
static TOOL_ACTION drawRectangle
Definition: pcb_actions.h:148
EDA_UNITS GetLastImperialUnits()
Definition: common_tools.h:75
int SetLayerSelection(LAYER_NUM layer)
static TOOL_ACTION microwaveCreateGap
Definition: pcb_actions.h:410
static TOOL_ACTION plot
Definition: actions.h:61
static TOOL_ACTION drawVia
Definition: pcb_actions.h:157
static COLOR4D ICON_WHITE
static TOOL_ACTION showEeschema
Definition: pcb_actions.h:439
static TOOL_ACTION routerWalkaroundMode
Definition: pcb_actions.h:208
static TOOL_ACTION placeTarget
Definition: pcb_actions.h:162
static TOOL_ACTION zoneUnfillAll
Definition: pcb_actions.h:311
static TOOL_ACTION milsUnits
Definition: actions.h:148
static TOOL_ACTION boardSetup
Definition: pcb_actions.h:318
Handles action that are shared between different applications.
Definition: common_tools.h:37
static TOOL_ACTION microwaveCreateStub
Definition: pcb_actions.h:412
void PrepareLayerIndicator(bool aForceRebuild=false)
static TOOL_ACTION padDisplayMode
Definition: pcb_actions.h:247
static TOOL_ACTION rotateCcw
Definition: pcb_actions.h:106
static TOOL_ACTION drawCircle
Definition: pcb_actions.h:149
static TOOL_ACTION viaDisplayMode
Definition: pcb_actions.h:248
EDA_UNITS
Definition: eda_units.h:38
void UpdateToolbarControlSizes() override
Update the sizes of any controls in the toolbars of the frame.
static TOOL_ACTION redo
Definition: actions.h:68
static COLOR4D ICON_BLACK
COLOR4D GetColor(int aLayer) const
static TOOL_ACTION microwaveCreateFunctionShape
Definition: pcb_actions.h:416
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:56
static constexpr bool CHECK
Definition: action_menu.h:182
static TOOL_ACTION placeFootprint
Definition: pcb_actions.h:164
static TOOL_ACTION drawLeader
Definition: pcb_actions.h:155
const int scale
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:157
static TOOL_ACTION drawRuleArea
Definition: pcb_actions.h:158
see class PGM_BASE
static TOOL_ACTION routeSingleTrack
Activation of the Push and Shove router.
Definition: pcb_actions.h:185
LAYER_TOOLBAR_ICON_VALUES m_prevIconVal
#define _(s)
Definition: 3d_actions.cpp:33
static TOOL_ACTION zoomRedraw
Definition: actions.h:93
void OnUpdateSelectViaSize(wxUpdateUIEvent &aEvent)
void ReCreateOptToolbar() override
void SetToolBitmap(const TOOL_ACTION &aAction, const wxBitmap &aBitmap)
Updates the bitmap of a particular tool.
The selection tool: currently supports:
static TOOL_ACTION runDRC
Definition: pcb_actions.h:344
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:144
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:105
PCB_LAYER_BOX_SELECTOR * m_SelLayerBox
static TOOL_ACTION gridSetOrigin
Definition: actions.h:140
static std::unique_ptr< wxBitmap > LayerPairBitmap
static TOOL_ACTION routerShoveMode
Definition: pcb_actions.h:207
static TOOL_ACTION highContrastMode
Definition: actions.h:106
static TOOL_ACTION showFootprintEditor
Definition: actions.h:165
static TOOL_ACTION drawZone
Definition: pcb_actions.h:156
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:246
static TOOL_ACTION selectionTool
Definition: actions.h:156
void UseCustomTrackViaSize(bool aEnabled)
Enables/disables custom track/via size settings.
static wxString ComboBoxUnits(EDA_UNITS aUnits, double aValue, bool aIncludeLabel=true)
COLOR_SETTINGS * GetColorSettings() const override
Helper to retrieve the current color settings.
wxBitmap KiScaledBitmap(BITMAPS aBitmap, wxWindow *aWindow, int aHeight)
Construct a wxBitmap from a memory record, scaling it if device DPI demands it.
Definition: bitmap.cpp:147
Container for design settings for a BOARD object.
void ClearToolbar()
Clear the toolbar and remove all associated menus.
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:98
static TOOL_ACTION zoneDisplayEnable
Definition: pcb_actions.h:249
ACTION_TOOLBAR * m_drawToolBar
static TOOL_ACTION routeDiffPair
Activation of the Push and Shove router (differential pair mode)
Definition: pcb_actions.h:188