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 <advanced_config.h>
30 #include <bitmaps.h>
31 #include <board.h>
32 #include <board_design_settings.h>
33 #include <kiface_base.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>
50 #include <widgets/wx_aui_utils.h>
51 #include <wx/wupdlock.h>
52 #include <wx/dcmemory.h>
53 #include <wx/choice.h>
54 
55 #include "../scripting/python_scripting.h"
56 
57 
58 /* Data to build the layer pair indicator button */
59 static std::unique_ptr<wxBitmap> LayerPairBitmap;
60 
61 #define BM_LAYERICON_SIZE 24
63 {
64  // 0 = draw pixel with white
65  // 1 = draw pixel with black
66  // 2 = draw pixel with top layer from router pair
67  // 3 = draw pixel with bottom layer from router pair
68  { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3 },
69  { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3 },
70  { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3, 3 },
71  { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3, 3 },
72  { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3, 3, 3 },
73  { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3, 3, 3 },
74  { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3, 3, 3, 3 },
75  { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3, 3, 3, 3 },
76  { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
77  { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
78  { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
79  { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
80  { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
81  { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
82  { 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
83  { 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
84  { 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
85  { 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
86  { 2, 2, 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
87  { 2, 2, 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
88  { 2, 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
89  { 2, 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
90  { 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
91  { 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
92 };
93 
94 static COLOR4D ICON_WHITE { 0.86, 0.86, 0.86, 1.0 };
95 static COLOR4D ICON_BLACK { 0.28, 0.28, 0.28, 1.0 };
96 
97 
98 void PCB_EDIT_FRAME::PrepareLayerIndicator( bool aForceRebuild )
99 {
100  int ii, jj;
101  COLOR4D top_color, bottom_color, background_color;
102  bool change = aForceRebuild;
103 
104  int requested_scale = Pgm().GetCommonSettings()->m_Appearance.icon_scale;
105 
106  if( m_prevIconVal.previous_requested_scale != requested_scale )
107  {
108  m_prevIconVal.previous_requested_scale = requested_scale;
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  background_color = GetColorSettings()->GetColor( LAYER_PCB_BACKGROUND );
129 
130  if( m_prevIconVal.previous_background_color != background_color )
131  {
132  m_prevIconVal.previous_background_color = background_color;
133  change = true;
134  }
135 
136  if( change || !LayerPairBitmap )
137  {
138  LayerPairBitmap = std::make_unique<wxBitmap>( 24, 24 );
139 
140  // Draw the icon, with colors according to the router's layer pair
141  wxMemoryDC iconDC;
142  iconDC.SelectObject( *LayerPairBitmap );
143  wxBrush brush;
144  wxPen pen;
145  int buttonColor = -1;
146 
147  brush.SetStyle( wxBRUSHSTYLE_SOLID );
148  brush.SetColour( background_color.WithAlpha(1.0).ToColour() );
149  iconDC.SetBrush( brush );
150  iconDC.DrawRectangle( 0, 0, BM_LAYERICON_SIZE, BM_LAYERICON_SIZE );
151 
152  for( ii = 0; ii < BM_LAYERICON_SIZE; ii++ )
153  {
154  for( jj = 0; jj < BM_LAYERICON_SIZE; jj++ )
155  {
156  if( s_BitmapLayerIcon[ii][jj] != buttonColor )
157  {
158  switch( s_BitmapLayerIcon[ii][jj] )
159  {
160  default:
161  case 0: pen.SetColour( ICON_WHITE.ToColour() ); break;
162  case 1: pen.SetColour( ICON_BLACK.ToColour() ); break;
163  case 2: pen.SetColour( top_color.ToColour() ); break;
164  case 3: pen.SetColour( bottom_color.ToColour() ); break;
165  }
166 
167  buttonColor = s_BitmapLayerIcon[ii][jj];
168  iconDC.SetPen( pen );
169  }
170 
171  iconDC.DrawPoint( jj, ii );
172  }
173  }
174 
175  // Deselect the bitmap from the DC in order to delete the MemoryDC safely without
176  // deleting the bitmap
177  iconDC.SelectObject( wxNullBitmap );
178 
179  // Scale the bitmap
180  const int scale = ( requested_scale <= 0 ) ? KiIconScale( this ) : requested_scale;
181  wxImage image = LayerPairBitmap->ConvertToImage();
182 
183  // "NEAREST" causes less mixing of colors
184  image.Rescale( scale * image.GetWidth() / 4, scale * image.GetHeight() / 4,
185  wxIMAGE_QUALITY_NEAREST );
186 
187  LayerPairBitmap = std::make_unique<wxBitmap>( image );
188 
189  if( m_mainToolBar )
190  {
192  m_mainToolBar->Refresh();
193  }
194  }
195 }
196 
197 
199 {
200  // Note:
201  // To rebuild the aui toolbar, the more easy way is to clear ( calling m_mainToolBar.Clear() )
202  // all wxAuiToolBarItems.
203  // However the wxAuiToolBarItems are not the owners of controls managed by
204  // them and therefore do not delete them
205  // So we do not recreate them after clearing the tools.
206 
207  wxWindowUpdateLocker dummy( this );
208 
209  if( m_mainToolBar )
210  {
212  }
213  else
214  {
215  m_mainToolBar = new ACTION_TOOLBAR( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
216  KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT |
217  wxAUI_TB_HORIZONTAL );
219 
220  // The layer indicator is special, so we register a callback directly that will
221  // regenerate the bitmap instead of using the conditions system.
222  auto layerIndicatorUpdate =
223  [this] ( wxUpdateUIEvent& )
224  {
226  };
227 
228  Bind( wxEVT_UPDATE_UI, layerIndicatorUpdate, PCB_ACTIONS::selectLayerPair.GetUIId() );
229  }
230 
231  // Set up toolbar
232  if( Kiface().IsSingle() )
233  {
236  }
237 
239 
242 
247 
251 
254 
262 
270 
274 
276 
277  if( !Kiface().IsSingle() )
279  else
281 
283 
285 
286  if( m_SelLayerBox == nullptr )
287  {
289  m_SelLayerBox->SetBoardFrame( this );
290  }
291 
292  ReCreateLayerBox( false );
293  m_mainToolBar->AddControl( m_SelLayerBox );
294 
296  PrepareLayerIndicator( true ); // Force rebuild of the bitmap with the active layer colors
297 
300 
301  // Access to the scripting console
302  if( SCRIPTING::IsWxAvailable() )
303  {
307  }
308 
309  // Go through and ensure the comboboxes are the correct size, since the strings in the
310  // box could have changed widths.
312 
313  // after adding the buttons to the toolbar, must call Realize() to reflect the changes
315 }
316 
317 
319 {
320  // Note:
321  // To rebuild the aui toolbar, the more easy way is to clear ( calling m_mainToolBar.Clear() )
322  // all wxAuiToolBarItems.
323  // However the wxAuiToolBarItems are not the owners of controls managed by
324  // them and therefore do not delete them
325  // So we do not recreate them after clearing the tools.
326 
327  wxWindowUpdateLocker dummy( this );
328 
329  if( m_optionsToolBar )
330  {
332  }
333  else
334  {
336  wxDefaultPosition, wxDefaultSize,
337  KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
339  }
340 
342 
348 
352 
356 
360 
361  if( ADVANCED_CFG::GetCfg().m_ExtraZoneDisplayModes )
362  {
365  }
366 
371 
372  // Tools to show/hide toolbars:
375 
377  std::unique_ptr<ACTION_MENU> gridMenu = std::make_unique<ACTION_MENU>( false, selTool );
378  gridMenu->Add( ACTIONS::gridProperties );
379  m_optionsToolBar->AddToolContextMenu( ACTIONS::toggleGrid, std::move( gridMenu ) );
380 
382 }
383 
384 
386 {
387  wxWindowUpdateLocker dummy( this );
388 
389  if( m_drawToolBar )
390  {
392  }
393  else
394  {
395  m_drawToolBar = new ACTION_TOOLBAR( this, ID_V_TOOLBAR, wxDefaultPosition, wxDefaultSize,
396  KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
398  }
399 
400  // Groups contained on this toolbar
401  static ACTION_GROUP* dimensionGroup = nullptr;
402  static ACTION_GROUP* originGroup = nullptr;
403  static ACTION_GROUP* routingGroup = nullptr;
404  static ACTION_GROUP* tuneGroup = nullptr;
405 
406  if( !dimensionGroup )
407  {
408  dimensionGroup = new ACTION_GROUP( "group.pcbDimensions",
413  }
414 
415  if( !originGroup )
416  {
417  originGroup = new ACTION_GROUP( "group.pcbOrigins",
420  }
421 
422  if( !routingGroup )
423  {
424  routingGroup = new ACTION_GROUP( "group.pcbRouting",
427  }
428 
429  if( !tuneGroup )
430  {
431  tuneGroup = new ACTION_GROUP( "group.pcbTune",
435  }
436 
439 
447 
455  m_drawToolBar->AddGroup( dimensionGroup, ACTION_TOOLBAR::TOGGLE );
458 
462 
464 
465  auto makeRouteMenu =
466  [&]()
467  {
468  std::unique_ptr<ACTION_MENU> routeMenu =
469  std::make_unique<ACTION_MENU>( false, selTool );
470 
474 
475  routeMenu->AppendSeparator();
476  routeMenu->Add( PCB_ACTIONS::routerSettingsDialog );
477 
478  return routeMenu;
479  };
480 
483 
484  auto makeTuneMenu =
485  [&]()
486  {
487  std::unique_ptr<ACTION_MENU> tuneMenu = std::make_unique<ACTION_MENU>( false, selTool );
489  return tuneMenu;
490  };
491 
495 
496  std::unique_ptr<ACTION_MENU> zoneMenu = std::make_unique<ACTION_MENU>( false, selTool );
497  zoneMenu->Add( PCB_ACTIONS::zoneFillAll );
498  zoneMenu->Add( PCB_ACTIONS::zoneUnfillAll );
499  m_drawToolBar->AddToolContextMenu( PCB_ACTIONS::drawZone, std::move( zoneMenu ) );
500 
501  std::unique_ptr<ACTION_MENU> lineMenu = std::make_unique<ACTION_MENU>( false, selTool );
502  m_drawToolBar->AddToolContextMenu( PCB_ACTIONS::drawLine, std::move( lineMenu ) );
503 
505 }
506 
507 
509 {
510  wxWindowUpdateLocker dummy( this );
511 
512  if( m_auxiliaryToolBar )
513  {
515  }
516  else
517  {
518  m_auxiliaryToolBar = new ACTION_TOOLBAR( this, ID_AUX_TOOLBAR, wxDefaultPosition,
519  wxDefaultSize,
520  KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT );
522  }
523 
524  /* Set up toolbar items */
525 
526  // Creates box to display and choose tracks widths:
527  if( m_SelTrackWidthBox == nullptr )
529  wxDefaultPosition, wxDefaultSize, 0, nullptr );
530 
532  m_auxiliaryToolBar->AddControl( m_SelTrackWidthBox );
533  m_SelTrackWidthBox->SetToolTip( _( "Select the default width for new tracks. Note that this "
534  "width can be overridden by the board minimum width, or by "
535  "the width of an existing track if the 'Use Existing Track "
536  "Width' feature is enabled." ) );
537 
540  _( "When routing from an existing track use its width instead "
541  "of the current width setting" ),
542  wxITEM_CHECK );
543 
545 
546  // Creates box to display and choose vias diameters:
547 
548  if( m_SelViaSizeBox == nullptr )
550  wxDefaultPosition, wxDefaultSize, 0, nullptr );
551 
553  m_auxiliaryToolBar->AddControl( m_SelViaSizeBox );
554 
555  // Add the box to display and select the current grid size:
557 
558  if( m_gridSelectBox == nullptr )
560  wxDefaultPosition, wxDefaultSize, 0, nullptr );
561 
563 
564  m_auxiliaryToolBar->AddControl( m_gridSelectBox );
565 
566  // Add the box to display and select the current Zoom
568 
569  if( m_zoomSelectBox == nullptr )
571  wxDefaultPosition, wxDefaultSize, 0, nullptr );
572 
574  m_auxiliaryToolBar->AddControl( m_zoomSelectBox );
575 
576  // Go through and ensure the comboboxes are the correct size, since the strings in the
577  // box could have changed widths.
582 
583  // after adding the buttons to the toolbar, must call Realize()
585 }
586 
587 
589 {
590  if( m_mainToolBar )
591  {
592  // Update the item widths
594  }
595 
596  if( m_auxiliaryToolBar )
597  {
598  // Update the item widths
603  }
604 }
605 
606 
607 static wxString ComboBoxUnits( EDA_UNITS aUnits, double aValue, bool aIncludeLabel = true )
608 {
609  wxString text;
610  const wxChar* format;
611 
612  switch( aUnits )
613  {
614  default: wxASSERT_MSG( false, "Invalid unit" ); KI_FALLTHROUGH;
615  case EDA_UNITS::UNSCALED: format = wxT( "%.0f" ); break;
616  case EDA_UNITS::MILLIMETRES: format = wxT( "%.3f" ); break;
617  case EDA_UNITS::MILS: format = wxT( "%.2f" ); break;
618  case EDA_UNITS::INCHES: format = wxT( "%.5f" ); break;
619  }
620 
621  text.Printf( format, To_User_Unit( aUnits, aValue ) );
622 
623  if( aIncludeLabel )
624  {
625  text += " ";
627  }
628 
629  return text;
630 }
631 
632 
633 void PCB_EDIT_FRAME::UpdateTrackWidthSelectBox( wxChoice* aTrackWidthSelectBox, bool aEdit )
634 {
635  if( aTrackWidthSelectBox == nullptr )
636  return;
637 
638  EDA_UNITS primaryUnit;
639  EDA_UNITS secondaryUnit;
640 
641  GetUnitPair( primaryUnit, secondaryUnit );
642 
643  wxString msg;
644 
645  aTrackWidthSelectBox->Clear();
646 
647  aTrackWidthSelectBox->Append( _( "Track: use netclass width" ) );
648 
649  for( unsigned ii = 1; ii < GetDesignSettings().m_TrackWidthList.size(); ii++ )
650  {
651  int size = GetDesignSettings().m_TrackWidthList[ii];
652 
653  msg.Printf( _( "Track: %s (%s)" ), ComboBoxUnits( primaryUnit, size ),
654  ComboBoxUnits( secondaryUnit, size ) );
655 
656  aTrackWidthSelectBox->Append( msg );
657  }
658 
659  if( aEdit )
660  {
661  aTrackWidthSelectBox->Append( wxT( "---" ) );
662  aTrackWidthSelectBox->Append( _( "Edit Pre-defined Sizes..." ) );
663  }
664 
665  if( GetDesignSettings().GetTrackWidthIndex() >= GetDesignSettings().m_TrackWidthList.size() )
667 
668  aTrackWidthSelectBox->SetSelection( GetDesignSettings().GetTrackWidthIndex() );
669 }
670 
671 
672 void PCB_EDIT_FRAME::UpdateViaSizeSelectBox( wxChoice* aViaSizeSelectBox, bool aEdit )
673 {
674  if( aViaSizeSelectBox == nullptr )
675  return;
676 
677  aViaSizeSelectBox->Clear();
678 
680 
681  EDA_UNITS primaryUnit = GetUserUnits();
682  EDA_UNITS secondaryUnit = EDA_UNITS::MILS;
683 
684  if( EDA_UNIT_UTILS::IsImperialUnit( primaryUnit ) )
685  {
686  if( cmnTool )
687  secondaryUnit = cmnTool->GetLastMetricUnits();
688  else
689  secondaryUnit = EDA_UNITS::MILLIMETRES;
690  }
691  else
692  {
693  if( cmnTool )
694  secondaryUnit = cmnTool->GetLastImperialUnits();
695  else
696  secondaryUnit = EDA_UNITS::MILS;
697  }
698 
699  aViaSizeSelectBox->Append( _( "Via: use netclass sizes" ) );
700 
701  for( unsigned ii = 1; ii < GetDesignSettings().m_ViasDimensionsList.size(); ii++ )
702  {
704  wxString msg, priStr, secStr;
705 
706  double diam = viaDimension.m_Diameter;
707  double hole = viaDimension.m_Drill;
708 
709  if( hole > 0 )
710  {
711  priStr = ComboBoxUnits( primaryUnit, diam, false ) + " / "
712  + ComboBoxUnits( primaryUnit, hole, true );
713  secStr = ComboBoxUnits( secondaryUnit, diam, false ) + " / "
714  + ComboBoxUnits( secondaryUnit, hole, true );
715  }
716  else
717  {
718  priStr = ComboBoxUnits( primaryUnit, diam, true );
719  secStr = ComboBoxUnits( secondaryUnit, diam, true );
720  }
721 
722  msg.Printf( _( "Via: %s (%s)" ), priStr, secStr );
723 
724  aViaSizeSelectBox->Append( msg );
725  }
726 
727  if( aEdit )
728  {
729  aViaSizeSelectBox->Append( wxT( "---" ) );
730  aViaSizeSelectBox->Append( _( "Edit Pre-defined Sizes..." ) );
731  }
732 
733  if( GetDesignSettings().GetViaSizeIndex() >= GetDesignSettings().m_ViasDimensionsList.size() )
735 
736  aViaSizeSelectBox->SetSelection( GetDesignSettings().GetViaSizeIndex() );
737 }
738 
739 
740 void PCB_EDIT_FRAME::ReCreateLayerBox( bool aForceResizeToolbar )
741 {
742  if( m_SelLayerBox == nullptr || m_mainToolBar == nullptr )
743  return;
744 
745  m_SelLayerBox->SetToolTip( _( "+/- to switch" ) );
747 
748  if( aForceResizeToolbar )
750 }
751 
752 
754 {
755  PCBNEW_SETTINGS* settings = GetPcbNewSettings();
756  wxAuiPaneInfo& layersManager = m_auimgr.GetPane( "LayersManager" );
757 
758  // show auxiliary Vertical layers and visibility manager toolbar
760  layersManager.Show( m_show_layer_manager_tools );
761  m_auimgr.GetPane( "SelectionFilter" ).Show( m_show_layer_manager_tools );
762 
764  {
765  SetAuiPaneSize( m_auimgr, layersManager, settings->m_AuiPanels.right_panel_width, -1 );
766  }
767  else
768  {
769  settings->m_AuiPanels.right_panel_width = m_appearancePanel->GetSize().x;
770  m_auimgr.Update();
771  }
772 }
773 
774 
775 void PCB_EDIT_FRAME::OnUpdateSelectTrackWidth( wxUpdateUIEvent& aEvent )
776 {
777  if( aEvent.GetId() == ID_AUX_TOOLBAR_PCB_TRACK_WIDTH )
778  {
780  int sel;
781 
782  if( bds.UseCustomTrackViaSize() )
783  sel = wxNOT_FOUND;
784  else
785  sel = bds.GetTrackWidthIndex();
786 
787  if( m_SelTrackWidthBox->GetSelection() != sel )
788  m_SelTrackWidthBox->SetSelection( sel );
789  }
790 }
791 
792 
793 void PCB_EDIT_FRAME::OnUpdateSelectViaSize( wxUpdateUIEvent& aEvent )
794 {
795  if( aEvent.GetId() == ID_AUX_TOOLBAR_PCB_VIA_SIZE )
796  {
798  int sel = 0;
799 
800  if( bds.UseCustomTrackViaSize() )
801  sel = wxNOT_FOUND;
802  else
803  sel = bds.GetViaSizeIndex();
804 
805  if( m_SelViaSizeBox->GetSelection() != sel )
806  m_SelViaSizeBox->SetSelection( sel );
807  }
808 }
809 
810 
811 void PCB_EDIT_FRAME::OnUpdateSelectAutoWidth( wxUpdateUIEvent& aEvent )
812 {
814 
815  aEvent.Check( bds.m_UseConnectedTrackWidth && !bds.UseCustomTrackViaSize() );
816 }
817 
818 
819 void PCB_EDIT_FRAME::OnUpdateLayerSelectBox( wxUpdateUIEvent& aEvent )
820 {
823 }
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:425
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]
void SetAuiPaneSize(wxAuiManager &aManager, wxAuiPaneInfo &aPane, int aWidth, int aHeight)
Sets the size of an AUI pane, working around http://trac.wxwidgets.org/ticket/13180.
static TOOL_ACTION drillOrigin
Definition: pcb_actions.h:438
ACTION_TOOLBAR * m_auxiliaryToolBar
static TOOL_ACTION lock
Definition: pcb_actions.h:424
void AddActionPluginTools()
Append action plugin buttons to main toolbar.
APPEARANCE_CONTROLS * m_appearancePanel
static TOOL_ACTION zoneFillAll
Definition: pcb_actions.h:305
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
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
static constexpr bool TOGGLE
static TOOL_ACTION ratsnestLineMode
Definition: pcb_actions.h:239
static TOOL_ACTION zoomTool
Definition: actions.h:99
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)
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:187
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 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:200
COLOR4D WithAlpha(double aAlpha) const
Return a color with the same color, but the given alpha.
Definition: color4d.h:314
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:428
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:429
static TOOL_ACTION localRatsnestTool
Definition: pcb_actions.h:460
static TOOL_ACTION find
Definition: actions.h:76
static TOOL_ACTION zoneDisplayFilled
Definition: pcb_actions.h:245
#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:190
static TOOL_ACTION toggleNetHighlight
Definition: pcb_actions.h:453
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:72
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:197
static TOOL_ACTION zoneDisplayFractured
Definition: pcb_actions.h:247
static constexpr bool CANCEL
static TOOL_ACTION routerSettingsDialog
Activation of the Push and Shove settings dialogs.
Definition: pcb_actions.h:195
static TOOL_ACTION rotateCw
Rotation of selected objects.
Definition: pcb_actions.h:101
static TOOL_ACTION importNetlist
Definition: pcb_actions.h:331
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
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)
static TOOL_ACTION showRatsnest
Definition: pcb_actions.h:238
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 zoneDisplayTriangulated
Definition: pcb_actions.h:248
static TOOL_ACTION showEeschema
Definition: pcb_actions.h:441
static TOOL_ACTION routerWalkaroundMode
Definition: pcb_actions.h:202
static TOOL_ACTION placeTarget
Definition: pcb_actions.h:158
static TOOL_ACTION zoneUnfillAll
Definition: pcb_actions.h:307
static TOOL_ACTION milsUnits
Definition: actions.h:145
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 zoneDisplayOutline
Definition: pcb_actions.h:246
wxBitmap KiScaledBitmap(BITMAPS aBitmap, wxWindow *aWindow, int aHeight, bool aQuantized)
Construct a wxBitmap from a memory record, scaling it if device DPI demands it.
Definition: bitmap.cpp:148
void PrepareLayerIndicator(bool aForceRebuild=false)
static TOOL_ACTION padDisplayMode
Definition: pcb_actions.h:243
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:244
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:178
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.
AUI_PANELS m_AuiPanels
PCBNEW_SETTINGS * GetPcbNewSettings() const
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.
PCB background color.
Definition: layer_ids.h:216
static TOOL_ACTION gridProperties
Definition: actions.h:141
static TOOL_ACTION deleteTool
Definition: actions.h:73
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
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:201
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:242
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.
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 routerTuneSingleTrace
Activation of the Push and Shove router (tune single line mode)
Definition: pcb_actions.h:184
ACTION_TOOLBAR * m_drawToolBar
static TOOL_ACTION routeDiffPair
Activation of the Push and Shove router (differential pair mode)
Definition: pcb_actions.h:181