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-2021 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 <board_design_settings.h>
32 #include <dialog_helpers.h>
33 #include <kiface_i.h>
34 #include <macros.h>
35 #include <pcb_edit_frame.h>
36 #include <pcb_layer_box_selector.h>
37 #include <pcbnew_id.h>
38 #include <pcbnew_settings.h>
39 #include <pgm_base.h>
41 #include <router/router_tool.h>
43 #include <tool/action_toolbar.h>
44 #include <tool/actions.h>
45 #include <tool/common_tools.h>
46 #include <tool/tool_manager.h>
47 #include <tools/pcb_actions.h>
49 #include <wx/wupdlock.h>
50 #include <wx/dcmemory.h>
51 #include <wx/choice.h>
52 
53 #include "../scripting/python_scripting.h"
54 
55 
56 /* Data to build the layer pair indicator button */
57 static std::unique_ptr<wxBitmap> LayerPairBitmap;
58 
59 #define BM_LAYERICON_SIZE 24
61 {
62  // 0 = draw pixel with white
63  // 1 = draw pixel with black
64  // 2 = draw pixel with top layer from router pair
65  // 3 = draw pixel with bottom layer from router pair
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, 2, 0, 1, 0, 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, 2, 0, 1, 0, 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, 2, 0, 1, 0, 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, 2, 0, 1, 0, 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, 2, 0, 1, 0, 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, 2, 0, 1, 0, 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, 2, 0, 1, 0, 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, 2, 0, 1, 0, 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, 2, 0, 1, 0, 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, 2, 0, 1, 0, 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, 2, 0, 1, 0, 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  { 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
90 };
91 
92 static COLOR4D ICON_WHITE { 0.86, 0.86, 0.86, 1.0 };
93 static COLOR4D ICON_BLACK { 0.28, 0.28, 0.28, 1.0 };
94 
95 
96 void PCB_EDIT_FRAME::PrepareLayerIndicator( bool aForceRebuild )
97 {
98  int ii, jj;
99  COLOR4D top_color, bottom_color, background_color;
100  bool change = aForceRebuild;
101 
102  int requested_scale = Pgm().GetCommonSettings()->m_Appearance.icon_scale;
103 
104  if( m_prevIconVal.previous_requested_scale != requested_scale )
105  {
106  m_prevIconVal.previous_requested_scale = requested_scale;
107  change = true;
108  }
109 
110  top_color = GetColorSettings()->GetColor( GetScreen()->m_Route_Layer_TOP );
111 
113  {
115  change = true;
116  }
117 
118  bottom_color = GetColorSettings()->GetColor( GetScreen()->m_Route_Layer_BOTTOM );
119 
121  {
123  change = true;
124  }
125 
126  background_color = GetColorSettings()->GetColor( LAYER_PCB_BACKGROUND );
127 
128  if( m_prevIconVal.previous_background_color != background_color )
129  {
130  m_prevIconVal.previous_background_color = background_color;
131  change = true;
132  }
133 
134  if( change || !LayerPairBitmap )
135  {
136  LayerPairBitmap = std::make_unique<wxBitmap>( 24, 24 );
137 
138  // Draw the icon, with colors according to the router's layer pair
139  wxMemoryDC iconDC;
140  iconDC.SelectObject( *LayerPairBitmap );
141  wxBrush brush;
142  wxPen pen;
143  int buttonColor = -1;
144 
145  brush.SetStyle( wxBRUSHSTYLE_SOLID );
146  brush.SetColour( background_color.WithAlpha(1.0).ToColour() );
147  iconDC.SetBrush( brush );
148  iconDC.DrawRectangle( 0, 0, BM_LAYERICON_SIZE, BM_LAYERICON_SIZE );
149 
150  for( ii = 0; ii < BM_LAYERICON_SIZE; ii++ )
151  {
152  for( jj = 0; jj < BM_LAYERICON_SIZE; jj++ )
153  {
154  if( s_BitmapLayerIcon[ii][jj] != buttonColor )
155  {
156  switch( s_BitmapLayerIcon[ii][jj] )
157  {
158  default:
159  case 0: pen.SetColour( ICON_WHITE.ToColour() ); break;
160  case 1: pen.SetColour( ICON_BLACK.ToColour() ); break;
161  case 2: pen.SetColour( top_color.ToColour() ); break;
162  case 3: pen.SetColour( bottom_color.ToColour() ); break;
163  }
164 
165  buttonColor = s_BitmapLayerIcon[ii][jj];
166  iconDC.SetPen( pen );
167  }
168 
169  iconDC.DrawPoint( jj, ii );
170  }
171  }
172 
173  // Deselect the bitmap from the DC in order to delete the MemoryDC safely without
174  // deleting the bitmap
175  iconDC.SelectObject( wxNullBitmap );
176 
177  // Scale the bitmap
178  const int scale = ( requested_scale <= 0 ) ? KiIconScale( this ) : requested_scale;
179  wxImage image = LayerPairBitmap->ConvertToImage();
180 
181  // "NEAREST" causes less mixing of colors
182  image.Rescale( scale * image.GetWidth() / 4, scale * image.GetHeight() / 4,
183  wxIMAGE_QUALITY_NEAREST );
184 
185  LayerPairBitmap = std::make_unique<wxBitmap>( image );
186 
187  if( m_mainToolBar )
188  {
190  m_mainToolBar->Refresh();
191  }
192  }
193 }
194 
195 
197 {
198  // Note:
199  // To rebuild the aui toolbar, the more easy way is to clear ( calling m_mainToolBar.Clear() )
200  // all wxAuiToolBarItems.
201  // However the wxAuiToolBarItems are not the owners of controls managed by
202  // them and therefore do not delete them
203  // So we do not recreate them after clearing the tools.
204 
205  wxWindowUpdateLocker dummy( this );
206 
207  if( m_mainToolBar )
208  {
210  }
211  else
212  {
213  m_mainToolBar = new ACTION_TOOLBAR( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
214  KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT |
215  wxAUI_TB_HORIZONTAL );
217 
218  // The layer indicator is special, so we register a callback directly that will
219  // regenerate the bitmap instead of using the conditions system.
220  auto layerIndicatorUpdate =
221  [this] ( wxUpdateUIEvent& )
222  {
224  };
225 
226  Bind( wxEVT_UPDATE_UI, layerIndicatorUpdate, PCB_ACTIONS::selectLayerPair.GetUIId() );
227  }
228 
229  // Set up toolbar
230  if( Kiface().IsSingle() )
231  {
234  }
235 
237 
240 
245 
249 
252 
260 
268 
272 
274 
275  if( !Kiface().IsSingle() )
277  else
279 
281 
283 
284  if( m_SelLayerBox == nullptr )
285  {
287  m_SelLayerBox->SetBoardFrame( this );
288  }
289 
290  ReCreateLayerBox( false );
291  m_mainToolBar->AddControl( m_SelLayerBox );
292 
294  PrepareLayerIndicator( true ); // Force rebuild of the bitmap with the active layer colors
295 
298 
299  // Access to the scripting console
300  if( SCRIPTING::IsWxAvailable() )
301  {
305  }
306 
307  // Go through and ensure the comboboxes are the correct size, since the strings in the
308  // box could have changed widths.
310 
311  // after adding the buttons to the toolbar, must call Realize() to reflect the changes
313 }
314 
315 
317 {
318  // Note:
319  // To rebuild the aui toolbar, the more easy way is to clear ( calling m_mainToolBar.Clear() )
320  // all wxAuiToolBarItems.
321  // However the wxAuiToolBarItems are not the owners of controls managed by
322  // them and therefore do not delete them
323  // So we do not recreate them after clearing the tools.
324 
325  wxWindowUpdateLocker dummy( this );
326 
327  if( m_optionsToolBar )
328  {
330  }
331  else
332  {
334  wxDefaultPosition, wxDefaultSize,
335  KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
337  }
338 
340 
346 
350 
354 
359 
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* tuneGroup = 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( !tuneGroup )
423  {
424  tuneGroup = new ACTION_GROUP( "group.pcbTune",
428  }
429 
432 
440 
448  m_drawToolBar->AddGroup( dimensionGroup, ACTION_TOOLBAR::TOGGLE );
451 
455 
457 
458  auto makeRouteMenu =
459  [&]()
460  {
461  std::unique_ptr<ACTION_MENU> routeMenu =
462  std::make_unique<ACTION_MENU>( false, selTool );
463 
467 
468  routeMenu->AppendSeparator();
469  routeMenu->Add( PCB_ACTIONS::routerSettingsDialog );
470 
471  return routeMenu;
472  };
473 
476 
477  auto makeTuneMenu =
478  [&]()
479  {
480  std::unique_ptr<ACTION_MENU> tuneMenu = std::make_unique<ACTION_MENU>( false, selTool );
482  return tuneMenu;
483  };
484 
488 
489  std::unique_ptr<ACTION_MENU> zoneMenu = std::make_unique<ACTION_MENU>( false, selTool );
490  zoneMenu->Add( PCB_ACTIONS::zoneFillAll );
491  zoneMenu->Add( PCB_ACTIONS::zoneUnfillAll );
492  m_drawToolBar->AddToolContextMenu( PCB_ACTIONS::drawZone, std::move( zoneMenu ) );
493 
494  std::unique_ptr<ACTION_MENU> lineMenu = std::make_unique<ACTION_MENU>( false, selTool );
496  m_drawToolBar->AddToolContextMenu( PCB_ACTIONS::drawLine, std::move( lineMenu ) );
497 
499 }
500 
501 
503 {
504  wxWindowUpdateLocker dummy( this );
505 
506  if( m_auxiliaryToolBar )
507  {
509  }
510  else
511  {
512  m_auxiliaryToolBar = new ACTION_TOOLBAR( this, ID_AUX_TOOLBAR, wxDefaultPosition,
513  wxDefaultSize,
514  KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT );
516  }
517 
518  /* Set up toolbar items */
519 
520  // Creates box to display and choose tracks widths:
521  if( m_SelTrackWidthBox == nullptr )
523  wxDefaultPosition, wxDefaultSize, 0, nullptr );
524 
526  m_auxiliaryToolBar->AddControl( m_SelTrackWidthBox );
527  m_SelTrackWidthBox->SetToolTip( _( "Select the default width for new tracks. Note that this "
528  "width can be overridden by the board minimum width, or by "
529  "the width of an existing track if the 'Use Existing Track "
530  "Width' feature is enabled." ) );
531 
534  _( "When routing from an existing track use its width instead "
535  "of the current width setting" ),
536  wxITEM_CHECK );
537 
539 
540  // Creates box to display and choose vias diameters:
541 
542  if( m_SelViaSizeBox == nullptr )
544  wxDefaultPosition, wxDefaultSize, 0, nullptr );
545 
547  m_auxiliaryToolBar->AddControl( m_SelViaSizeBox );
548 
549  // Add the box to display and select the current grid size:
551 
552  if( m_gridSelectBox == nullptr )
554  wxDefaultPosition, wxDefaultSize, 0, nullptr );
555 
557 
558  m_auxiliaryToolBar->AddControl( m_gridSelectBox );
559 
560  // Add the box to display and select the current Zoom
562 
563  if( m_zoomSelectBox == nullptr )
565  wxDefaultPosition, wxDefaultSize, 0, nullptr );
566 
568  m_auxiliaryToolBar->AddControl( m_zoomSelectBox );
569 
570  // Go through and ensure the comboboxes are the correct size, since the strings in the
571  // box could have changed widths.
576 
577  // after adding the buttons to the toolbar, must call Realize()
579 }
580 
581 
583 {
584  if( m_mainToolBar )
585  {
586  // Update the item widths
588  }
589 
590  if( m_auxiliaryToolBar )
591  {
592  // Update the item widths
597  }
598 }
599 
600 
601 static wxString ComboBoxUnits( EDA_UNITS aUnits, double aValue, bool aIncludeLabel = true )
602 {
603  wxString text;
604  const wxChar* format;
605 
606  switch( aUnits )
607  {
608  default: wxASSERT_MSG( false, "Invalid unit" ); KI_FALLTHROUGH;
609  case EDA_UNITS::UNSCALED: format = wxT( "%.0f" ); break;
610  case EDA_UNITS::MILLIMETRES: format = wxT( "%.3f" ); break;
611  case EDA_UNITS::MILS: format = wxT( "%.2f" ); break;
612  case EDA_UNITS::INCHES: format = wxT( "%.5f" ); break;
613  }
614 
615  text.Printf( format, To_User_Unit( aUnits, aValue ) );
616 
617  if( aIncludeLabel )
618  {
619  text += " ";
621  }
622 
623  return text;
624 }
625 
626 
627 void PCB_EDIT_FRAME::UpdateTrackWidthSelectBox( wxChoice* aTrackWidthSelectBox, bool aEdit )
628 {
629  if( aTrackWidthSelectBox == nullptr )
630  return;
631 
632  EDA_UNITS primaryUnit;
633  EDA_UNITS secondaryUnit;
634 
635  GetUnitPair( primaryUnit, secondaryUnit );
636 
637  wxString msg;
638 
639  aTrackWidthSelectBox->Clear();
640 
641  aTrackWidthSelectBox->Append( _( "Track: use netclass width" ) );
642 
643  for( unsigned ii = 1; ii < GetDesignSettings().m_TrackWidthList.size(); ii++ )
644  {
645  int size = GetDesignSettings().m_TrackWidthList[ii];
646 
647  msg.Printf( _( "Track: %s (%s)" ), ComboBoxUnits( primaryUnit, size ),
648  ComboBoxUnits( secondaryUnit, size ) );
649 
650  aTrackWidthSelectBox->Append( msg );
651  }
652 
653  if( aEdit )
654  {
655  aTrackWidthSelectBox->Append( wxT( "---" ) );
656  aTrackWidthSelectBox->Append( _( "Edit Pre-defined Sizes..." ) );
657  }
658 
659  if( GetDesignSettings().GetTrackWidthIndex() >= GetDesignSettings().m_TrackWidthList.size() )
661 
662  aTrackWidthSelectBox->SetSelection( GetDesignSettings().GetTrackWidthIndex() );
663 }
664 
665 
666 void PCB_EDIT_FRAME::UpdateViaSizeSelectBox( wxChoice* aViaSizeSelectBox, bool aEdit )
667 {
668  if( aViaSizeSelectBox == nullptr )
669  return;
670 
671  aViaSizeSelectBox->Clear();
672 
674 
675  EDA_UNITS primaryUnit = GetUserUnits();
676  EDA_UNITS secondaryUnit = EDA_UNITS::MILS;
677 
678  if( EDA_UNIT_UTILS::IsImperialUnit( primaryUnit ) )
679  {
680  if( cmnTool )
681  secondaryUnit = cmnTool->GetLastMetricUnits();
682  else
683  secondaryUnit = EDA_UNITS::MILLIMETRES;
684  }
685  else
686  {
687  if( cmnTool )
688  secondaryUnit = cmnTool->GetLastImperialUnits();
689  else
690  secondaryUnit = EDA_UNITS::MILS;
691  }
692 
693  aViaSizeSelectBox->Append( _( "Via: use netclass sizes" ) );
694 
695  for( unsigned ii = 1; ii < GetDesignSettings().m_ViasDimensionsList.size(); ii++ )
696  {
698  wxString msg, priStr, secStr;
699 
700  double diam = viaDimension.m_Diameter;
701  double hole = viaDimension.m_Drill;
702 
703  if( hole > 0 )
704  {
705  priStr = ComboBoxUnits( primaryUnit, diam, false ) + " / "
706  + ComboBoxUnits( primaryUnit, hole, true );
707  secStr = ComboBoxUnits( secondaryUnit, diam, false ) + " / "
708  + ComboBoxUnits( secondaryUnit, hole, true );
709  }
710  else
711  {
712  priStr = ComboBoxUnits( primaryUnit, diam, true );
713  secStr = ComboBoxUnits( secondaryUnit, diam, true );
714  }
715 
716  msg.Printf( _( "Via: %s (%s)" ), priStr, secStr );
717 
718  aViaSizeSelectBox->Append( msg );
719  }
720 
721  if( aEdit )
722  {
723  aViaSizeSelectBox->Append( wxT( "---" ) );
724  aViaSizeSelectBox->Append( _( "Edit Pre-defined Sizes..." ) );
725  }
726 
727  if( GetDesignSettings().GetViaSizeIndex() >= GetDesignSettings().m_ViasDimensionsList.size() )
729 
730  aViaSizeSelectBox->SetSelection( GetDesignSettings().GetViaSizeIndex() );
731 }
732 
733 
734 void PCB_EDIT_FRAME::ReCreateLayerBox( bool aForceResizeToolbar )
735 {
736  if( m_SelLayerBox == nullptr || m_mainToolBar == nullptr )
737  return;
738 
739  m_SelLayerBox->SetToolTip( _( "+/- to switch" ) );
741 
742  if( aForceResizeToolbar )
744 }
745 
746 
748 {
749  // show auxiliary Vertical layers and visibility manager toolbar
751  m_auimgr.GetPane( "LayersManager" ).Show( m_show_layer_manager_tools );
752  m_auimgr.GetPane( "SelectionFilter" ).Show( m_show_layer_manager_tools );
753  m_auimgr.Update();
754 }
755 
756 
757 void PCB_EDIT_FRAME::OnUpdateSelectTrackWidth( wxUpdateUIEvent& aEvent )
758 {
759  if( aEvent.GetId() == ID_AUX_TOOLBAR_PCB_TRACK_WIDTH )
760  {
762  int sel;
763 
764  if( bds.UseCustomTrackViaSize() )
765  sel = wxNOT_FOUND;
766  else
767  sel = bds.GetTrackWidthIndex();
768 
769  if( m_SelTrackWidthBox->GetSelection() != sel )
770  m_SelTrackWidthBox->SetSelection( sel );
771  }
772 }
773 
774 
775 void PCB_EDIT_FRAME::OnUpdateSelectViaSize( wxUpdateUIEvent& aEvent )
776 {
777  if( aEvent.GetId() == ID_AUX_TOOLBAR_PCB_VIA_SIZE )
778  {
780  int sel = 0;
781 
782  if( bds.UseCustomTrackViaSize() )
783  sel = wxNOT_FOUND;
784  else
785  sel = bds.GetViaSizeIndex();
786 
787  if( m_SelViaSizeBox->GetSelection() != sel )
788  m_SelViaSizeBox->SetSelection( sel );
789  }
790 }
791 
792 
793 void PCB_EDIT_FRAME::OnUpdateSelectAutoWidth( wxUpdateUIEvent& aEvent )
794 {
796 
797  aEvent.Check( bds.m_UseConnectedTrackWidth && !bds.UseCustomTrackViaSize() );
798 }
799 
800 
801 void PCB_EDIT_FRAME::OnUpdateLayerSelectBox( wxUpdateUIEvent& aEvent )
802 {
805 }
static TOOL_ACTION drawLine
Definition: pcb_actions.h:142
static TOOL_ACTION drawCenterDimension
Definition: pcb_actions.h:149
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:424
virtual BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Returns the BOARD_DESIGN_SETTINGS for the open project.
static TOOL_ACTION selectLayerPair
Definition: pcb_actions.h:129
static TOOL_ACTION zoomInCenter
Definition: actions.h:93
EDA_UNITS GetLastMetricUnits()
Definition: common_tools.h:74
static TOOL_ACTION pageSettings
Definition: actions.h:56
static const char s_BitmapLayerIcon[BM_LAYERICON_SIZE][BM_LAYERICON_SIZE]
static TOOL_ACTION drillOrigin
Definition: pcb_actions.h:437
ACTION_TOOLBAR * m_auxiliaryToolBar
static TOOL_ACTION lock
Definition: pcb_actions.h:423
void AddActionPluginTools()
Append action plugin buttons to main toolbar.
static TOOL_ACTION zoneFillAll
Definition: pcb_actions.h:306
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:146
std::vector< int > m_TrackWidthList
ACTION_TOOLBAR * m_optionsToolBar
static constexpr bool TOGGLE
static TOOL_ACTION ratsnestLineMode
Definition: pcb_actions.h:242
static TOOL_ACTION zoomTool
Definition: actions.h:99
static TOOL_ACTION zoneDisplayOutlines
Definition: pcb_actions.h:248
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:167
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 routerTuneDiffPair
Activation of the Push and Shove router (diff pair tuning mode)
Definition: pcb_actions.h:190
static TOOL_ACTION drawAlignedDimension
Definition: pcb_actions.h:148
int KiIconScale(wxWindow *aWindow)
Return the automatic scale factor that would be used for a given window by KiScaledBitmap and KiScale...
Definition: bitmap.cpp:122
static TOOL_ACTION zoneDisplayDisable
Definition: pcb_actions.h:247
static TOOL_ACTION drawOrthogonalDimension
Definition: pcb_actions.h:150
static TOOL_ACTION zoomFitScreen
Definition: actions.h:96
static TOOL_ACTION millimetersUnits
Definition: actions.h:146
static TOOL_ACTION drawPolygon
Definition: pcb_actions.h:143
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:203
COLOR4D WithAlpha(double aAlpha) const
Return a color with the same color, but the given alpha.
Definition: color4d.h:305
static TOOL_ACTION showPythonConsole
Definition: pcb_actions.h:349
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:348
#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:427
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:163
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:424
wxAuiManager m_auimgr
static TOOL_ACTION zoomFitObjects
Definition: actions.h:97
void SetBoardFrame(PCB_BASE_FRAME *aFrame)
ACTION_TOOLBAR * m_mainToolBar
void ReCreateHToolbar() override
static TOOL_ACTION print
Definition: actions.h:57
static TOOL_ACTION ungroup
Definition: pcb_actions.h:428
static TOOL_ACTION localRatsnestTool
Definition: pcb_actions.h:459
static TOOL_ACTION find
Definition: actions.h:76
#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:147
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:94
This file contains miscellaneous commonly used macros and functions.
static TOOL_ACTION routerTuneDiffPairSkew
Activation of the Push and Shove router (skew tuning mode)
Definition: pcb_actions.h:193
static TOOL_ACTION toggleNetHighlight
Definition: pcb_actions.h:452
bool m_show_layer_manager_tools
static LIB_SYMBOL * dummy()
Used to draw a dummy shape when a LIB_SYMBOL is not found in library.
Definition: sch_symbol.cpp:71
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.
LAYER_NUM GetLayerSelection() const
static TOOL_ACTION measureTool
Definition: actions.h:154
A group of actions that will be displayed together on a toolbar palette.
static TOOL_ACTION lengthTunerSettingsDialog
Definition: pcb_actions.h:200
static constexpr bool CANCEL
static TOOL_ACTION routerSettingsDialog
Activation of the Push and Shove settings dialogs.
Definition: pcb_actions.h:198
static TOOL_ACTION rotateCw
Rotation of selected objects.
Definition: pcb_actions.h:101
static TOOL_ACTION importNetlist
Definition: pcb_actions.h:332
static TOOL_ACTION toggleGrid
Definition: actions.h:140
unsigned GetViaSizeIndex() const
static TOOL_ACTION open
Definition: actions.h:50
static TOOL_ACTION showFootprintBrowser
Definition: actions.h:161
static TOOL_ACTION inchesUnits
Definition: actions.h:144
static TOOL_ACTION save
Definition: actions.h:51
wxChoice * m_zoomSelectBox
static TOOL_ACTION doNew
Definition: actions.h:44
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:149
void OnUpdateSelectAutoWidth(wxUpdateUIEvent &aEvent)
Helper dialog and control classes.
static TOOL_ACTION showRatsnest
Definition: pcb_actions.h:241
static TOOL_ACTION drawRectangle
Definition: pcb_actions.h:144
EDA_UNITS GetLastImperialUnits()
Definition: common_tools.h:75
#define _(s)
int SetLayerSelection(LAYER_NUM layer)
static TOOL_ACTION plot
Definition: actions.h:58
static TOOL_ACTION drawVia
Definition: pcb_actions.h:153
static COLOR4D ICON_WHITE
static TOOL_ACTION showEeschema
Definition: pcb_actions.h:440
static TOOL_ACTION routerWalkaroundMode
Definition: pcb_actions.h:205
static TOOL_ACTION placeTarget
Definition: pcb_actions.h:158
static TOOL_ACTION zoneUnfillAll
Definition: pcb_actions.h:308
static TOOL_ACTION milsUnits
Definition: actions.h:145
static TOOL_ACTION boardSetup
Definition: pcb_actions.h:319
Handles action that are shared between different applications.
Definition: common_tools.h:37
void PrepareLayerIndicator(bool aForceRebuild=false)
static TOOL_ACTION padDisplayMode
Definition: pcb_actions.h:244
static TOOL_ACTION rotateCcw
Definition: pcb_actions.h:102
static TOOL_ACTION drawCircle
Definition: pcb_actions.h:145
static TOOL_ACTION viaDisplayMode
Definition: pcb_actions.h:245
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:65
static COLOR4D ICON_BLACK
COLOR4D GetColor(int aLayer) const
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:68
static constexpr bool CHECK
Definition: action_menu.h:183
static TOOL_ACTION placeFootprint
Definition: pcb_actions.h:160
static TOOL_ACTION drawLeader
Definition: pcb_actions.h:151
const int scale
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:158
static TOOL_ACTION drawRuleArea
Definition: pcb_actions.h:154
see class PGM_BASE
static TOOL_ACTION routeSingleTrack
Activation of the Push and Shove router.
Definition: pcb_actions.h:181
LAYER_TOOLBAR_ICON_VALUES m_prevIconVal
static TOOL_ACTION zoomRedraw
Definition: actions.h:90
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:345
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:141
static TOOL_ACTION deleteTool
Definition: actions.h:73
void OnUpdateSelectTrackWidth(wxUpdateUIEvent &aEvent)
static TOOL_ACTION undo
Definition: actions.h:64
void UpdateViaSizeSelectBox(wxChoice *aViaSizeSelectBox, bool aEdit=true)
static TOOL_ACTION toggleCursorStyle
Definition: actions.h:102
PCB_LAYER_BOX_SELECTOR * m_SelLayerBox
static TOOL_ACTION gridSetOrigin
Definition: actions.h:137
static std::unique_ptr< wxBitmap > LayerPairBitmap
static TOOL_ACTION routerShoveMode
Definition: pcb_actions.h:204
static TOOL_ACTION highContrastMode
Definition: actions.h:103
static TOOL_ACTION showFootprintEditor
Definition: actions.h:162
static TOOL_ACTION drawZone
Definition: pcb_actions.h:152
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:243
static TOOL_ACTION selectionTool
Definition: actions.h:153
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:148
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:103
static TOOL_ACTION zoneDisplayEnable
Definition: pcb_actions.h:246
static TOOL_ACTION routerTuneSingleTrace
Activation of the Push and Shove router (tune single line mode)
Definition: pcb_actions.h:187
ACTION_TOOLBAR * m_drawToolBar
static TOOL_ACTION routeDiffPair
Activation of the Push and Shove router (differential pair mode)
Definition: pcb_actions.h:184