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, [email protected]
5 * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <[email protected]>
6 * Copyright (C) 2012 Wayne Stambaugh <[email protected]>
7 * Copyright (C) 1992-2022 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>
33#include <kiface_base.h>
34#include <macros.h>
35#include <pcb_edit_frame.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>
52#include <wx/wupdlock.h>
53#include <wx/dcmemory.h>
54#include <wx/choice.h>
55
56#include "../scripting/python_scripting.h"
57
58
59/* Data to build the layer pair indicator button */
60static std::unique_ptr<wxBitmap> LayerPairBitmap;
61
62#define BM_LAYERICON_SIZE 24
64{
65 // 0 = draw pixel with white
66 // 1 = draw pixel with black
67 // 2 = draw pixel with top layer from router pair
68 // 3 = draw pixel with bottom layer from router pair
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, 2, 0, 1, 0, 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, 2, 0, 1, 0, 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, 2, 0, 1, 0, 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, 2, 0, 1, 0, 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, 2, 0, 1, 0, 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, 2, 0, 1, 0, 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, 2, 0, 1, 0, 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, 2, 0, 1, 0, 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, 2, 0, 1, 0, 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, 2, 0, 1, 0, 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, 2, 0, 1, 0, 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 { 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
93};
94
95static COLOR4D ICON_WHITE { 0.86, 0.86, 0.86, 1.0 };
96static COLOR4D ICON_BLACK { 0.28, 0.28, 0.28, 1.0 };
97
98
99void PCB_EDIT_FRAME::PrepareLayerIndicator( bool aForceRebuild )
100{
101 int ii, jj;
102 COLOR4D top_color, bottom_color, background_color;
103 bool change = aForceRebuild;
104
105 int requested_scale = Pgm().GetCommonSettings()->m_Appearance.icon_scale;
106
107 if( m_prevIconVal.previous_requested_scale != requested_scale )
108 {
109 m_prevIconVal.previous_requested_scale = requested_scale;
110 change = true;
111 }
112
113 top_color = GetColorSettings()->GetColor( GetScreen()->m_Route_Layer_TOP );
114
116 {
118 change = true;
119 }
120
121 bottom_color = GetColorSettings()->GetColor( GetScreen()->m_Route_Layer_BOTTOM );
122
124 {
126 change = true;
127 }
128
129 background_color = GetColorSettings()->GetColor( LAYER_PCB_BACKGROUND );
130
131 if( m_prevIconVal.previous_background_color != background_color )
132 {
133 m_prevIconVal.previous_background_color = background_color;
134 change = true;
135 }
136
137 if( change || !LayerPairBitmap )
138 {
139 LayerPairBitmap = std::make_unique<wxBitmap>( 24, 24 );
140
141 // Draw the icon, with colors according to the router's layer pair
142 wxMemoryDC iconDC;
143 iconDC.SelectObject( *LayerPairBitmap );
144 wxBrush brush;
145 wxPen pen;
146 int buttonColor = -1;
147
148 brush.SetStyle( wxBRUSHSTYLE_SOLID );
149 brush.SetColour( background_color.WithAlpha(1.0).ToColour() );
150 iconDC.SetBrush( brush );
151 iconDC.DrawRectangle( 0, 0, BM_LAYERICON_SIZE, BM_LAYERICON_SIZE );
152
153 for( ii = 0; ii < BM_LAYERICON_SIZE; ii++ )
154 {
155 for( jj = 0; jj < BM_LAYERICON_SIZE; jj++ )
156 {
157 if( s_BitmapLayerIcon[ii][jj] != buttonColor )
158 {
159 switch( s_BitmapLayerIcon[ii][jj] )
160 {
161 default:
162 case 0: pen.SetColour( ICON_WHITE.ToColour() ); break;
163 case 1: pen.SetColour( ICON_BLACK.ToColour() ); break;
164 case 2: pen.SetColour( top_color.ToColour() ); break;
165 case 3: pen.SetColour( bottom_color.ToColour() ); break;
166 }
167
168 buttonColor = s_BitmapLayerIcon[ii][jj];
169 iconDC.SetPen( pen );
170 }
171
172 iconDC.DrawPoint( jj, ii );
173 }
174 }
175
176 // Deselect the bitmap from the DC in order to delete the MemoryDC safely without
177 // deleting the bitmap
178 iconDC.SelectObject( wxNullBitmap );
179
180 // Scale the bitmap
181 const int scale = ( requested_scale <= 0 ) ? KiIconScale( this ) : requested_scale;
182 wxImage image = LayerPairBitmap->ConvertToImage();
183
184 // "NEAREST" causes less mixing of colors
185 image.Rescale( scale * image.GetWidth() / 4, scale * image.GetHeight() / 4,
186 wxIMAGE_QUALITY_NEAREST );
187
188 LayerPairBitmap = std::make_unique<wxBitmap>( image );
189
190 if( m_mainToolBar )
191 {
193 m_mainToolBar->Refresh();
194 }
195 }
196}
197
198
200{
201 // Note:
202 // To rebuild the aui toolbar, the more easy way is to clear ( calling m_mainToolBar.Clear() )
203 // all wxAuiToolBarItems.
204 // However the wxAuiToolBarItems are not the owners of controls managed by
205 // them and therefore do not delete them
206 // So we do not recreate them after clearing the tools.
207
208 wxWindowUpdateLocker dummy( this );
209
210 if( m_mainToolBar )
211 {
213 }
214 else
215 {
216 m_mainToolBar = new ACTION_TOOLBAR( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
217 KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT |
218 wxAUI_TB_HORIZONTAL );
220
221 // The layer indicator is special, so we register a callback directly that will
222 // regenerate the bitmap instead of using the conditions system.
223 auto layerIndicatorUpdate =
224 [this] ( wxUpdateUIEvent& )
225 {
227 };
228
229 Bind( wxEVT_UPDATE_UI, layerIndicatorUpdate, PCB_ACTIONS::selectLayerPair.GetUIId() );
230 }
231
232 // Set up toolbar
233 if( Kiface().IsSingle() )
234 {
237 }
238
240
243
248
252
255
263
273
277
279
280 if( !Kiface().IsSingle() )
282 else
284
286
288
289 if( m_SelLayerBox == nullptr )
290 {
293 }
294
295 ReCreateLayerBox( false );
296 m_mainToolBar->AddControl( m_SelLayerBox );
297
299 PrepareLayerIndicator( true ); // Force rebuild of the bitmap with the active layer colors
300
303
304 // Access to the scripting console
305 if( SCRIPTING::IsWxAvailable() )
306 {
310 }
311
312 // Go through and ensure the comboboxes are the correct size, since the strings in the
313 // box could have changed widths.
315
316 // after adding the buttons to the toolbar, must call Realize() to reflect the changes
318}
319
320
322{
323 // Note:
324 // To rebuild the aui toolbar, the more easy way is to clear ( calling m_mainToolBar.Clear() )
325 // all wxAuiToolBarItems.
326 // However the wxAuiToolBarItems are not the owners of controls managed by
327 // them and therefore do not delete them
328 // So we do not recreate them after clearing the tools.
329
330 wxWindowUpdateLocker dummy( this );
331
332 if( m_optionsToolBar )
333 {
335 }
336 else
337 {
339 wxDefaultPosition, wxDefaultSize,
340 KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
342 }
343
345
351
354
358
362
366
367 if( ADVANCED_CFG::GetCfg().m_ExtraZoneDisplayModes )
368 {
371 }
372
377
378 if( ADVANCED_CFG::GetCfg().m_DrawBoundingBoxes )
380
381 // Tools to show/hide toolbars:
384
385 if( ADVANCED_CFG::GetCfg().m_ShowPropertiesPanel )
387
389 std::unique_ptr<ACTION_MENU> gridMenu = std::make_unique<ACTION_MENU>( false, selTool );
390 gridMenu->Add( ACTIONS::gridProperties );
392
394}
395
396
398{
399 wxWindowUpdateLocker dummy( this );
400
401 if( m_drawToolBar )
402 {
404 }
405 else
406 {
407 m_drawToolBar = new ACTION_TOOLBAR( this, ID_V_TOOLBAR, wxDefaultPosition, wxDefaultSize,
408 KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
410 }
411
412 // Groups contained on this toolbar
413 static ACTION_GROUP* dimensionGroup = nullptr;
414 static ACTION_GROUP* originGroup = nullptr;
415 static ACTION_GROUP* routingGroup = nullptr;
416 static ACTION_GROUP* tuneGroup = nullptr;
417
418 if( !dimensionGroup )
419 {
420 dimensionGroup = new ACTION_GROUP( "group.pcbDimensions",
426 }
427
428 if( !originGroup )
429 {
430 originGroup = new ACTION_GROUP( "group.pcbOrigins",
433 }
434
435 if( !routingGroup )
436 {
437 routingGroup = new ACTION_GROUP( "group.pcbRouting",
440 }
441
442 if( !tuneGroup )
443 {
444 tuneGroup = new ACTION_GROUP( "group.pcbTune",
448 }
449
452
460
472
476
478
479 auto makeRouteMenu =
480 [&]()
481 {
482 std::unique_ptr<ACTION_MENU> routeMenu =
483 std::make_unique<ACTION_MENU>( false, selTool );
484
488
489 routeMenu->AppendSeparator();
490 routeMenu->Add( PCB_ACTIONS::routerSettingsDialog );
491
492 return routeMenu;
493 };
494
497
498 auto makeTuneMenu =
499 [&]()
500 {
501 std::unique_ptr<ACTION_MENU> tuneMenu = std::make_unique<ACTION_MENU>( false, selTool );
503 return tuneMenu;
504 };
505
509
510 std::unique_ptr<ACTION_MENU> zoneMenu = std::make_unique<ACTION_MENU>( false, selTool );
511 zoneMenu->Add( PCB_ACTIONS::zoneFillAll );
512 zoneMenu->Add( PCB_ACTIONS::zoneUnfillAll );
513 m_drawToolBar->AddToolContextMenu( PCB_ACTIONS::drawZone, std::move( zoneMenu ) );
514
515 std::unique_ptr<ACTION_MENU> lineMenu = std::make_unique<ACTION_MENU>( false, selTool );
516 m_drawToolBar->AddToolContextMenu( PCB_ACTIONS::drawLine, std::move( lineMenu ) );
517
519}
520
521
523{
524 wxWindowUpdateLocker dummy( this );
525
527 {
529 }
530 else
531 {
532 m_auxiliaryToolBar = new ACTION_TOOLBAR( this, ID_AUX_TOOLBAR, wxDefaultPosition,
533 wxDefaultSize,
534 KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT );
536 }
537
538 /* Set up toolbar items */
539
540 // Creates box to display and choose tracks widths:
541 if( m_SelTrackWidthBox == nullptr )
543 wxDefaultPosition, wxDefaultSize, 0, nullptr );
544
547 m_SelTrackWidthBox->SetToolTip( _( "Select the default width for new tracks. Note that this "
548 "width can be overridden by the board minimum width, or by "
549 "the width of an existing track if the 'Use Existing Track "
550 "Width' feature is enabled." ) );
551
554 _( "When routing from an existing track use its width instead "
555 "of the current width setting" ),
556 wxITEM_CHECK );
557
559
560 // Creates box to display and choose vias diameters:
561
562 if( m_SelViaSizeBox == nullptr )
564 wxDefaultPosition, wxDefaultSize, 0, nullptr );
565
567 m_auxiliaryToolBar->AddControl( m_SelViaSizeBox );
568
569 // Add the box to display and select the current grid size:
571
572 if( m_gridSelectBox == nullptr )
574 wxDefaultPosition, wxDefaultSize, 0, nullptr );
575
577
578 m_auxiliaryToolBar->AddControl( m_gridSelectBox );
579
580 // Add the box to display and select the current Zoom
582
583 if( m_zoomSelectBox == nullptr )
585 wxDefaultPosition, wxDefaultSize, 0, nullptr );
586
588 m_auxiliaryToolBar->AddControl( m_zoomSelectBox );
589
590 // Go through and ensure the comboboxes are the correct size, since the strings in the
591 // box could have changed widths.
596
597 // after adding the buttons to the toolbar, must call Realize()
599}
600
601
603{
604 if( m_mainToolBar )
605 {
606 // Update the item widths
608 }
609
611 {
612 // Update the item widths
617 }
618}
619
620
621static wxString ComboBoxUnits( EDA_UNITS aUnits, double aValue, bool aIncludeLabel = true )
622{
623 wxString text;
624 const wxChar* format;
625
626 switch( aUnits )
627 {
628 default:
629 wxASSERT_MSG( false, wxT( "Invalid unit" ) );
631 case EDA_UNITS::UNSCALED: format = wxT( "%.0f" ); break;
632 case EDA_UNITS::MILLIMETRES: format = wxT( "%.3f" ); break;
633 case EDA_UNITS::MILS: format = wxT( "%.2f" ); break;
634 case EDA_UNITS::INCHES: format = wxT( "%.5f" ); break;
635 }
636
637 text.Printf( format, EDA_UNIT_UTILS::UI::ToUserUnit( pcbIUScale, aUnits, aValue ) );
638
639 if( aIncludeLabel )
641
642 return text;
643}
644
645
646void PCB_EDIT_FRAME::UpdateTrackWidthSelectBox( wxChoice* aTrackWidthSelectBox, bool aEdit )
647{
648 if( aTrackWidthSelectBox == nullptr )
649 return;
650
651 EDA_UNITS primaryUnit;
652 EDA_UNITS secondaryUnit;
653
654 GetUnitPair( primaryUnit, secondaryUnit );
655
656 wxString msg;
657
658 aTrackWidthSelectBox->Clear();
659
660 aTrackWidthSelectBox->Append( _( "Track: use netclass width" ) );
661
662 for( unsigned ii = 1; ii < GetDesignSettings().m_TrackWidthList.size(); ii++ )
663 {
664 int size = GetDesignSettings().m_TrackWidthList[ii];
665
666 msg.Printf( _( "Track: %s (%s)" ), ComboBoxUnits( primaryUnit, size ),
667 ComboBoxUnits( secondaryUnit, size ) );
668
669 aTrackWidthSelectBox->Append( msg );
670 }
671
672 if( aEdit )
673 {
674 aTrackWidthSelectBox->Append( wxT( "---" ) );
675 aTrackWidthSelectBox->Append( _( "Edit Pre-defined Sizes..." ) );
676 }
677
678 if( GetDesignSettings().GetTrackWidthIndex() >= GetDesignSettings().m_TrackWidthList.size() )
680
681 aTrackWidthSelectBox->SetSelection( GetDesignSettings().GetTrackWidthIndex() );
682}
683
684
685void PCB_EDIT_FRAME::UpdateViaSizeSelectBox( wxChoice* aViaSizeSelectBox, bool aEdit )
686{
687 if( aViaSizeSelectBox == nullptr )
688 return;
689
690 aViaSizeSelectBox->Clear();
691
693
694 EDA_UNITS primaryUnit = GetUserUnits();
695 EDA_UNITS secondaryUnit = EDA_UNITS::MILS;
696
697 if( EDA_UNIT_UTILS::IsImperialUnit( primaryUnit ) )
698 {
699 if( cmnTool )
700 secondaryUnit = cmnTool->GetLastMetricUnits();
701 else
702 secondaryUnit = EDA_UNITS::MILLIMETRES;
703 }
704 else
705 {
706 if( cmnTool )
707 secondaryUnit = cmnTool->GetLastImperialUnits();
708 else
709 secondaryUnit = EDA_UNITS::MILS;
710 }
711
712 aViaSizeSelectBox->Append( _( "Via: use netclass sizes" ) );
713
714 for( unsigned ii = 1; ii < GetDesignSettings().m_ViasDimensionsList.size(); ii++ )
715 {
717 wxString msg, priStr, secStr;
718
719 double diam = viaDimension.m_Diameter;
720 double hole = viaDimension.m_Drill;
721
722 if( hole > 0 )
723 {
724 priStr = ComboBoxUnits( primaryUnit, diam, false ) + wxT( " / " )
725 + ComboBoxUnits( primaryUnit, hole, true );
726 secStr = ComboBoxUnits( secondaryUnit, diam, false ) + wxT( " / " )
727 + ComboBoxUnits( secondaryUnit, hole, true );
728 }
729 else
730 {
731 priStr = ComboBoxUnits( primaryUnit, diam, true );
732 secStr = ComboBoxUnits( secondaryUnit, diam, true );
733 }
734
735 msg.Printf( _( "Via: %s (%s)" ), priStr, secStr );
736
737 aViaSizeSelectBox->Append( msg );
738 }
739
740 if( aEdit )
741 {
742 aViaSizeSelectBox->Append( wxT( "---" ) );
743 aViaSizeSelectBox->Append( _( "Edit Pre-defined Sizes..." ) );
744 }
745
746 if( GetDesignSettings().GetViaSizeIndex() >= GetDesignSettings().m_ViasDimensionsList.size() )
748
749 aViaSizeSelectBox->SetSelection( GetDesignSettings().GetViaSizeIndex() );
750}
751
752
753void PCB_EDIT_FRAME::ReCreateLayerBox( bool aForceResizeToolbar )
754{
755 if( m_SelLayerBox == nullptr || m_mainToolBar == nullptr )
756 return;
757
758 m_SelLayerBox->SetToolTip( _( "+/- to switch" ) );
760
761 if( aForceResizeToolbar )
763}
764
765
767{
769 wxAuiPaneInfo& layersManager = m_auimgr.GetPane( "LayersManager" );
770 wxAuiPaneInfo& selectionFilter = m_auimgr.GetPane( "SelectionFilter" );
771
772 // show auxiliary Vertical layers and visibility manager toolbar
774
775 layersManager.Show( m_show_layer_manager_tools );
776 selectionFilter.Show( m_show_layer_manager_tools );
777
779 {
780 SetAuiPaneSize( m_auimgr, layersManager, settings->m_AuiPanels.right_panel_width, -1 );
781 }
782 else
783 {
784 settings->m_AuiPanels.right_panel_width = m_appearancePanel->GetSize().x;
785 m_auimgr.Update();
786 }
787}
788
789
791{
793
794 m_auimgr.GetPane( "PropertiesManager" ).Show( m_show_properties );
795 m_auimgr.Update();
796}
797
798
800{
802
803 m_auimgr.GetPane( SearchPaneName() ).Show( m_show_search );
804 m_auimgr.Update();
805
806 if( m_show_search )
807 {
809 }
810}
811
812
813void PCB_EDIT_FRAME::OnUpdateSelectTrackWidth( wxUpdateUIEvent& aEvent )
814{
815 if( aEvent.GetId() == ID_AUX_TOOLBAR_PCB_TRACK_WIDTH )
816 {
818 int sel;
819
820 if( bds.UseCustomTrackViaSize() )
821 sel = wxNOT_FOUND;
822 else
823 sel = bds.GetTrackWidthIndex();
824
825 if( m_SelTrackWidthBox->GetSelection() != sel )
826 m_SelTrackWidthBox->SetSelection( sel );
827 }
828}
829
830
831void PCB_EDIT_FRAME::OnUpdateSelectViaSize( wxUpdateUIEvent& aEvent )
832{
833 if( aEvent.GetId() == ID_AUX_TOOLBAR_PCB_VIA_SIZE )
834 {
836 int sel = 0;
837
838 if( bds.UseCustomTrackViaSize() )
839 sel = wxNOT_FOUND;
840 else
841 sel = bds.GetViaSizeIndex();
842
843 if( m_SelViaSizeBox->GetSelection() != sel )
844 m_SelViaSizeBox->SetSelection( sel );
845 }
846}
847
848
849void PCB_EDIT_FRAME::OnUpdateSelectAutoWidth( wxUpdateUIEvent& aEvent )
850{
852
853 aEvent.Check( bds.m_UseConnectedTrackWidth );
854}
855
856
857void PCB_EDIT_FRAME::OnUpdateLayerSelectBox( wxUpdateUIEvent& aEvent )
858{
861}
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:109
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
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
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
@ auto_track_width
static TOOL_ACTION gridProperties
Definition: actions.h:144
static TOOL_ACTION updatePcbFromSchematic
Definition: actions.h:166
static TOOL_ACTION toggleGrid
Definition: actions.h:143
static TOOL_ACTION zoomRedraw
Definition: actions.h:92
static TOOL_ACTION millimetersUnits
Definition: actions.h:149
static TOOL_ACTION zoomOutCenter
Definition: actions.h:96
static TOOL_ACTION togglePolarCoords
Definition: actions.h:152
static TOOL_ACTION milsUnits
Definition: actions.h:148
static TOOL_ACTION toggleBoundingBoxes
Definition: actions.h:107
static TOOL_ACTION plot
Definition: actions.h:58
static TOOL_ACTION open
Definition: actions.h:50
static TOOL_ACTION pageSettings
Definition: actions.h:56
static TOOL_ACTION undo
Definition: actions.h:65
static TOOL_ACTION inchesUnits
Definition: actions.h:147
static TOOL_ACTION highContrastMode
Definition: actions.h:105
static TOOL_ACTION toggleCursorStyle
Definition: actions.h:104
static TOOL_ACTION measureTool
Definition: actions.h:157
static TOOL_ACTION selectionTool
Definition: actions.h:156
static TOOL_ACTION save
Definition: actions.h:51
static TOOL_ACTION zoomFitScreen
Definition: actions.h:98
static TOOL_ACTION redo
Definition: actions.h:66
static TOOL_ACTION deleteTool
Definition: actions.h:74
static TOOL_ACTION zoomTool
Definition: actions.h:101
static TOOL_ACTION showFootprintEditor
Definition: actions.h:165
static TOOL_ACTION print
Definition: actions.h:57
static TOOL_ACTION doNew
Definition: actions.h:47
static TOOL_ACTION zoomFitObjects
Definition: actions.h:99
static TOOL_ACTION zoomInCenter
Definition: actions.h:95
static TOOL_ACTION gridSetOrigin
Definition: actions.h:140
static TOOL_ACTION showFootprintBrowser
Definition: actions.h:164
static TOOL_ACTION find
Definition: actions.h:78
A group of actions that will be displayed together on a toolbar palette.
static constexpr bool CHECK
Definition: action_menu.h:189
Define the structure of a toolbar with buttons that invoke ACTIONs.
static constexpr bool TOGGLE
static constexpr bool CANCEL
void SetAuiManager(wxAuiManager *aManager)
Set the AUI manager that this toolbar belongs to.
void UpdateControlWidth(int aID)
Update the toolbar item width of a control using its best size.
void AddToolContextMenu(const TOOL_ACTION &aAction, std::unique_ptr< ACTION_MENU > aMenu)
Add a context menu to a specific tool item on the toolbar.
void AddScaledSeparator(wxWindow *aWindow)
Add a separator that introduces space on either side to not squash the tools when scaled.
bool KiRealize()
Use this over Realize() to avoid a rendering glitch with fixed orientation toolbars.
void ClearToolbar()
Clear the toolbar and remove all associated menus.
void SetToolBitmap(const TOOL_ACTION &aAction, const wxBitmap &aBitmap)
Updates the bitmap of a particular tool.
void AddGroup(ACTION_GROUP *aGroup, bool aIsToggleEntry=false)
Add a set of actions to a toolbar as a group.
void Add(const TOOL_ACTION &aAction, bool aIsToggleEntry=false, bool aIsCancellable=false)
Add a TOOL_ACTION-based button to the toolbar.
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
Container for design settings for a BOARD object.
void UseCustomTrackViaSize(bool aEnabled)
Enables/disables custom track/via size settings.
void SetTrackWidthIndex(unsigned aIndex)
Set the current track width list index to aIndex.
void SetViaSizeIndex(unsigned aIndex)
Set the current via size list index to aIndex.
unsigned GetTrackWidthIndex() const
unsigned GetViaSizeIndex() const
std::vector< int > m_TrackWidthList
std::vector< VIA_DIMENSION > m_ViasDimensionsList
COLOR4D GetColor(int aLayer) const
Handles action that are shared between different applications.
Definition: common_tools.h:38
EDA_UNITS GetLastImperialUnits()
Definition: common_tools.h:77
EDA_UNITS GetLastMetricUnits()
Definition: common_tools.h:76
static constexpr int KICAD_AUI_TB_STYLE
< Default style flags used for wxAUI toolbars.
wxAuiManager m_auimgr
wxChoice * m_gridSelectBox
ACTION_TOOLBAR * m_optionsToolBar
void UpdateGridSelectBox()
Rebuild the grid combobox to respond to any changes in the GUI (units, user grid changes,...
void UpdateZoomSelectBox()
Rebuild the grid combobox to respond to any changes in the GUI (units, user grid changes,...
void GetUnitPair(EDA_UNITS &aPrimaryUnit, EDA_UNITS &aSecondaryUnits)
Get the pair or units in current use.
ACTION_TOOLBAR * m_mainToolBar
ACTION_TOOLBAR * m_drawToolBar
SEARCH_PANE * m_searchPane
The current canvas type.
wxChoice * m_zoomSelectBox
ACTION_TOOLBAR * m_auxiliaryToolBar
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
COLOR4D WithAlpha(double aAlpha) const
Return a color with the same color, but the given alpha.
Definition: color4d.h:321
int SetLayerSelection(int layer)
AUI_PANELS m_AuiPanels
static TOOL_ACTION toggleHV45Mode
Definition: pcb_actions.h:458
static TOOL_ACTION drawRuleArea
Definition: pcb_actions.h:181
static TOOL_ACTION placeText
Definition: pcb_actions.h:172
static TOOL_ACTION drawOrthogonalDimension
Definition: pcb_actions.h:177
static TOOL_ACTION drawRectangle
Definition: pcb_actions.h:168
static TOOL_ACTION padDisplayMode
Definition: pcb_actions.h:272
static TOOL_ACTION routerSettingsDialog
Activation of the Push and Shove settings dialogs.
Definition: pcb_actions.h:227
static TOOL_ACTION showRatsnest
Definition: pcb_actions.h:267
static TOOL_ACTION zoneFillAll
Definition: pcb_actions.h:336
static TOOL_ACTION showLayersManager
Definition: pcb_actions.h:381
static TOOL_ACTION toggleNetHighlight
Definition: pcb_actions.h:491
static TOOL_ACTION drawCircle
Definition: pcb_actions.h:169
static TOOL_ACTION mirrorH
Mirroring of selected items.
Definition: pcb_actions.h:129
static TOOL_ACTION routeDiffPair
Activation of the Push and Shove router (differential pair mode)
Definition: pcb_actions.h:207
static TOOL_ACTION placeImage
Definition: pcb_actions.h:171
static TOOL_ACTION routerTuneDiffPair
Activation of the Push and Shove router (diff pair tuning mode)
Definition: pcb_actions.h:213
static TOOL_ACTION drawTextBox
Definition: pcb_actions.h:173
static TOOL_ACTION routerHighlightMode
Actions to enable switching modes via hotkey assignments.
Definition: pcb_actions.h:232
static TOOL_ACTION routerWalkaroundMode
Definition: pcb_actions.h:234
static TOOL_ACTION routerShoveMode
Definition: pcb_actions.h:233
static TOOL_ACTION drawPolygon
Definition: pcb_actions.h:167
static TOOL_ACTION group
Definition: pcb_actions.h:466
static TOOL_ACTION zoneDisplayFilled
Definition: pcb_actions.h:274
static TOOL_ACTION drawRadialDimension
Definition: pcb_actions.h:176
static TOOL_ACTION showProperties
Definition: pcb_actions.h:382
static TOOL_ACTION routerTuneDiffPairSkew
Activation of the Push and Shove router (skew tuning mode)
Definition: pcb_actions.h:216
static TOOL_ACTION viaDisplayMode
Definition: pcb_actions.h:273
static TOOL_ACTION drawLeader
Definition: pcb_actions.h:178
static TOOL_ACTION drillOrigin
Definition: pcb_actions.h:476
static TOOL_ACTION routerTuneSingleTrace
Activation of the Push and Shove router (tune single line mode)
Definition: pcb_actions.h:210
static TOOL_ACTION trackDisplayMode
Definition: pcb_actions.h:271
static TOOL_ACTION selectLayerPair
Definition: pcb_actions.h:157
static TOOL_ACTION zoneDisplayTriangulated
Definition: pcb_actions.h:277
static TOOL_ACTION ungroup
Definition: pcb_actions.h:467
static TOOL_ACTION zoneDisplayFractured
Definition: pcb_actions.h:276
static TOOL_ACTION drawVia
Definition: pcb_actions.h:180
static TOOL_ACTION drawArc
Definition: pcb_actions.h:170
static TOOL_ACTION runDRC
Definition: pcb_actions.h:376
static TOOL_ACTION importNetlist
Definition: pcb_actions.h:363
static TOOL_ACTION boardSetup
Definition: pcb_actions.h:350
static TOOL_ACTION showEeschema
Definition: pcb_actions.h:479
static TOOL_ACTION drawCenterDimension
Definition: pcb_actions.h:175
static TOOL_ACTION zoneUnfillAll
Definition: pcb_actions.h:339
static TOOL_ACTION zoneDisplayOutline
Definition: pcb_actions.h:275
static TOOL_ACTION ratsnestLineMode
Definition: pcb_actions.h:268
static TOOL_ACTION mirrorV
Definition: pcb_actions.h:130
static TOOL_ACTION unlock
Definition: pcb_actions.h:463
static TOOL_ACTION placeFootprint
Definition: pcb_actions.h:186
static TOOL_ACTION routeSingleTrack
Activation of the Push and Shove router.
Definition: pcb_actions.h:204
static TOOL_ACTION lengthTunerSettingsDialog
Definition: pcb_actions.h:229
static TOOL_ACTION showPythonConsole
Definition: pcb_actions.h:383
static TOOL_ACTION drawLine
Definition: pcb_actions.h:166
static TOOL_ACTION localRatsnestTool
Definition: pcb_actions.h:498
static TOOL_ACTION rotateCw
Rotation of selected objects.
Definition: pcb_actions.h:122
static TOOL_ACTION rotateCcw
Definition: pcb_actions.h:123
static TOOL_ACTION drawAlignedDimension
Definition: pcb_actions.h:174
static TOOL_ACTION drawZone
Definition: pcb_actions.h:179
static TOOL_ACTION lock
Definition: pcb_actions.h:462
COLOR_SETTINGS * GetColorSettings(bool aForceRefresh=false) const override
Helper to retrieve the current color settings.
APPEARANCE_CONTROLS * m_appearancePanel
PCBNEW_SETTINGS * GetPcbNewSettings() const
virtual PCB_LAYER_ID GetActiveLayer() const
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
virtual BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Returns the BOARD_DESIGN_SETTINGS for the open project.
void UpdateTrackWidthSelectBox(wxChoice *aTrackWidthSelectBox, bool aEdit=true)
void OnUpdateSelectTrackWidth(wxUpdateUIEvent &aEvent)
void ReCreateHToolbar() override
void ReCreateVToolbar() override
void UpdateViaSizeSelectBox(wxChoice *aViaSizeSelectBox, bool aEdit=true)
LAYER_TOOLBAR_ICON_VALUES m_prevIconVal
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...
bool m_show_layer_manager_tools
void OnUpdateLayerSelectBox(wxUpdateUIEvent &aEvent)
void PrepareLayerIndicator(bool aForceRebuild=false)
void ReCreateOptToolbar() override
void ReCreateAuxiliaryToolbar() override
void OnUpdateSelectAutoWidth(wxUpdateUIEvent &aEvent)
void UpdateToolbarControlSizes() override
Update the sizes of any controls in the toolbars of the frame.
void OnUpdateSelectViaSize(wxUpdateUIEvent &aEvent)
PCB_LAYER_BOX_SELECTOR * m_SelLayerBox
wxChoice * m_SelViaSizeBox
static const wxString SearchPaneName()
wxChoice * m_SelTrackWidthBox
void AddActionPluginTools()
Append action plugin buttons to main toolbar.
Class to display a pcb layer list in a wxBitmapComboBox.
void SetBoardFrame(PCB_BASE_FRAME *aFrame)
The selection tool: currently supports:
void FocusSearch()
Definition: search_pane.cpp:88
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:170
EDA_UNITS GetUserUnits() const
#define _(s)
EDA_UNITS
Definition: eda_units.h:43
@ ID_ON_GRID_SELECT
Definition: id.h:145
@ ID_OPT_TOOLBAR
Definition: id.h:102
@ ID_V_TOOLBAR
Definition: id.h:101
@ ID_ON_ZOOM_SELECT
Definition: id.h:143
@ ID_AUX_TOOLBAR
Definition: id.h:103
@ ID_H_TOOLBAR
Definition: id.h:100
@ LAYER_PCB_BACKGROUND
PCB background color.
Definition: layer_ids.h:220
This file contains miscellaneous commonly used macros and functions.
#define KI_FALLTHROUGH
The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely fallthrough from ...
Definition: macros.h:83
double ToUserUnit(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnit, double aValue)
Function To_User_Unit convert aValue in internal units to the appropriate user units defined by aUnit...
Definition: eda_units.cpp:198
wxString GetText(EDA_UNITS aUnits, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
Get the units string for a given units type.
Definition: eda_units.cpp:102
bool IsImperialUnit(EDA_UNITS aUnit)
Definition: eda_units.cpp:29
@ ID_AUX_TOOLBAR_PCB_VIA_SIZE
Definition: pcbnew_id.h:22
@ ID_AUX_TOOLBAR_PCB_SELECT_AUTO_WIDTH
Definition: pcbnew_id.h:24
@ ID_TOOLBARH_PCB_SELECT_LAYER
Definition: pcbnew_id.h:96
@ ID_AUX_TOOLBAR_PCB_TRACK_WIDTH
Definition: pcbnew_id.h:23
see class PGM_BASE
static LIB_SYMBOL * dummy()
Used to draw a dummy shape when a LIB_SYMBOL is not found in library.
Definition: sch_symbol.cpp:74
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:111
const int scale
Container to handle a stock of specific vias each with unique diameter and drill sizes in the BOARD c...
static const char s_BitmapLayerIcon[BM_LAYERICON_SIZE][BM_LAYERICON_SIZE]
static COLOR4D ICON_WHITE
static wxString ComboBoxUnits(EDA_UNITS aUnits, double aValue, bool aIncludeLabel=true)
static std::unique_ptr< wxBitmap > LayerPairBitmap
#define BM_LAYERICON_SIZE
static COLOR4D ICON_BLACK
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.