KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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, jp.charras at wanadoo.fr
5 * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <[email protected]>
6 * Copyright (C) 2012 Wayne Stambaugh <[email protected]>
7 * Copyright (C) 1992-2023 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>
31#include <bitmaps.h>
32#include <board.h>
34#include <kiface_base.h>
35#include <kiplatform/ui.h>
36#include <macros.h>
37#include <pcb_edit_frame.h>
39#include <pcbnew_id.h>
40#include <pcbnew_settings.h>
41#include <pgm_base.h>
43#include <router/router_tool.h>
45#include <tool/action_toolbar.h>
46#include <tool/actions.h>
47#include <tool/common_tools.h>
48#include <tool/tool_manager.h>
49#include <tools/pcb_actions.h>
56#include <wx/wupdlock.h>
57#include <wx/dcmemory.h>
58#include <wx/combobox.h>
59
60#include "../scripting/python_scripting.h"
61
62
63/* Data to build the layer pair indicator button */
64static std::unique_ptr<wxBitmap> LayerPairBitmap;
65
66#define BM_LAYERICON_SIZE 24
68{
69 // 0 = draw pixel with white
70 // 1 = draw pixel with black
71 // 2 = draw pixel with top layer from router pair
72 // 3 = draw pixel with bottom layer from router pair
73 { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3 },
74 { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3 },
75 { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3, 3 },
76 { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3, 3 },
77 { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3, 3, 3 },
78 { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3, 3, 3 },
79 { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3, 3, 3, 3 },
80 { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3, 3, 3, 3 },
81 { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
82 { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
83 { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
84 { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
85 { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
86 { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
87 { 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
88 { 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
89 { 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
90 { 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
91 { 2, 2, 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
92 { 2, 2, 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
93 { 2, 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
94 { 2, 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
95 { 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
96 { 2, 2, 2, 2, 2, 0, 1, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
97};
98
99static COLOR4D ICON_WHITE { 0.86, 0.86, 0.86, 1.0 };
100static COLOR4D ICON_BLACK { 0.28, 0.28, 0.28, 1.0 };
101
102
104{
105 int ii, jj;
106 COLOR4D top_color, bottom_color, background_color;
107 bool change = aForceRebuild;
108
109 int requested_scale = KiIconScale( this );
110
111 if( m_prevIconVal.previous_requested_scale != requested_scale )
112 {
113 m_prevIconVal.previous_requested_scale = requested_scale;
114 change = true;
115 }
116
117 top_color = GetColorSettings()->GetColor( GetScreen()->m_Route_Layer_TOP );
118
120 {
122 change = true;
123 }
124
125 bottom_color = GetColorSettings()->GetColor( GetScreen()->m_Route_Layer_BOTTOM );
126
128 {
130 change = true;
131 }
132
133 background_color = GetColorSettings()->GetColor( LAYER_PCB_BACKGROUND );
134
135 if( m_prevIconVal.previous_background_color != background_color )
136 {
137 m_prevIconVal.previous_background_color = background_color;
138 change = true;
139 }
140
141 if( change || !LayerPairBitmap )
142 {
143 LayerPairBitmap = std::make_unique<wxBitmap>( 24, 24 );
144
145 // Draw the icon, with colors according to the router's layer pair
146 wxMemoryDC iconDC;
147 iconDC.SelectObject( *LayerPairBitmap );
148 wxBrush brush;
149 wxPen pen;
150 int buttonColor = -1;
151
152 brush.SetStyle( wxBRUSHSTYLE_SOLID );
153 brush.SetColour( background_color.WithAlpha(1.0).ToColour() );
154 iconDC.SetBrush( brush );
155 iconDC.DrawRectangle( 0, 0, BM_LAYERICON_SIZE, BM_LAYERICON_SIZE );
156
157 for( ii = 0; ii < BM_LAYERICON_SIZE; ii++ )
158 {
159 for( jj = 0; jj < BM_LAYERICON_SIZE; jj++ )
160 {
161 if( s_BitmapLayerIcon[ii][jj] != buttonColor )
162 {
163 switch( s_BitmapLayerIcon[ii][jj] )
164 {
165 default:
166 case 0: pen.SetColour( ICON_WHITE.ToColour() ); break;
167 case 1: pen.SetColour( ICON_BLACK.ToColour() ); break;
168 case 2: pen.SetColour( top_color.ToColour() ); break;
169 case 3: pen.SetColour( bottom_color.ToColour() ); break;
170 }
171
172 buttonColor = s_BitmapLayerIcon[ii][jj];
173 iconDC.SetPen( pen );
174 }
175
176 iconDC.DrawPoint( jj, ii );
177 }
178 }
179
180 // Deselect the bitmap from the DC in order to delete the MemoryDC safely without
181 // deleting the bitmap
182 iconDC.SelectObject( wxNullBitmap );
183
184 // Scale the bitmap
185 const int scale = ( requested_scale <= 0 ) ? KiIconScale( this ) : requested_scale;
186 wxImage image = LayerPairBitmap->ConvertToImage();
187
188 // "NEAREST" causes less mixing of colors
189 image.Rescale( scale * image.GetWidth() / 4, scale * image.GetHeight() / 4,
190 wxIMAGE_QUALITY_NEAREST );
191
192 LayerPairBitmap = std::make_unique<wxBitmap>( image );
193
195 {
197 m_auxiliaryToolBar->Refresh();
198 }
199 }
200}
201
202
204{
205 // Note:
206 // To rebuild the aui toolbar, the more easy way is to clear ( calling m_mainToolBar.Clear() )
207 // all wxAuiToolBarItems.
208 // However the wxAuiToolBarItems are not the owners of controls managed by
209 // them and therefore do not delete them
210 // So we do not recreate them after clearing the tools.
211
212 wxWindowUpdateLocker dummy( this );
213
214 if( m_mainToolBar )
215 {
217 }
218 else
219 {
220 m_mainToolBar = new ACTION_TOOLBAR( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
221 KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT |
222 wxAUI_TB_HORIZONTAL );
224 }
225
226 // Set up toolbar
227 if( Kiface().IsSingle() )
228 {
231 }
232
234
237
242
246
249
257
267
272
274
275 if( !Kiface().IsSingle() )
277 else
279
281
284
285 // Add SWIG and API plugins
286 bool scriptingAvailable = SCRIPTING::IsWxAvailable();
287#ifdef KICAD_IPC_API
288 bool haveApiPlugins = Pgm().GetCommonSettings()->m_Api.enable_server &&
289 !Pgm().GetPluginManager().GetActionsForScope( PLUGIN_ACTION_SCOPE::PCB ).empty();
290#else
291 bool haveApiPlugins = false;
292#endif
293
294 if( scriptingAvailable || haveApiPlugins )
295 {
297
298 if( scriptingAvailable )
299 {
302 }
303
304 if( haveApiPlugins )
306 }
307
308 // after adding the buttons to the toolbar, must call Realize() to reflect the changes
310}
311
312
314{
315 // Note:
316 // To rebuild the aui toolbar, the more easy way is to clear ( calling m_mainToolBar.Clear() )
317 // all wxAuiToolBarItems.
318 // However the wxAuiToolBarItems are not the owners of controls managed by
319 // them and therefore do not delete them
320 // So we do not recreate them after clearing the tools.
321
322 wxWindowUpdateLocker dummy( this );
323
324 if( m_optionsToolBar )
325 {
327 }
328 else
329 {
331 wxDefaultPosition, wxDefaultSize,
332 KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
334 }
335
338
344
347
351
355
359
360 if( ADVANCED_CFG::GetCfg().m_ExtraZoneDisplayModes )
361 {
364 }
365
370
371 if( ADVANCED_CFG::GetCfg().m_DrawBoundingBoxes )
373
374 // Tools to show/hide toolbars:
378
380 std::unique_ptr<ACTION_MENU> gridMenu = std::make_unique<ACTION_MENU>( false, selTool );
381 gridMenu->Add( ACTIONS::gridProperties );
382 gridMenu->Add( ACTIONS::gridOrigin );
384
386}
387
388
390{
391 wxWindowUpdateLocker dummy( this );
392
393 if( m_drawToolBar )
394 {
396 }
397 else
398 {
399 m_drawToolBar = new ACTION_TOOLBAR( this, ID_V_TOOLBAR, wxDefaultPosition, wxDefaultSize,
400 KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
402 }
403
404 // Groups contained on this toolbar
405 static ACTION_GROUP* dimensionGroup = nullptr;
406 static ACTION_GROUP* originGroup = nullptr;
407 static ACTION_GROUP* routingGroup = nullptr;
408 static ACTION_GROUP* tuneGroup = nullptr;
409
410 if( !dimensionGroup )
411 {
412 dimensionGroup = new ACTION_GROUP( "group.pcbDimensions",
418 }
419
420 if( !originGroup )
421 {
422 originGroup = new ACTION_GROUP( "group.pcbOrigins",
425 }
426
427 if( !routingGroup )
428 {
429 routingGroup = new ACTION_GROUP( "group.pcbRouting",
432 }
433
434 if( !tuneGroup )
435 {
436 tuneGroup = new ACTION_GROUP( "group.pcbTune",
440 }
441
444
452
465
469
471
472 auto makeArcMenu = [&]()
473 {
474 std::unique_ptr<ACTION_MENU> arcMenu = std::make_unique<ACTION_MENU>( false, selTool );
475
478
479 return arcMenu;
480 };
481
483
484 auto makeRouteMenu = [&]()
485 {
486 std::unique_ptr<ACTION_MENU> routeMenu = std::make_unique<ACTION_MENU>( false, selTool );
487
491
492 routeMenu->AppendSeparator();
493 routeMenu->Add( PCB_ACTIONS::routerSettingsDialog );
494
495 return routeMenu;
496 };
497
500
501 std::unique_ptr<ACTION_MENU> zoneMenu = std::make_unique<ACTION_MENU>( false, selTool );
502 zoneMenu->Add( PCB_ACTIONS::zoneFillAll );
503 zoneMenu->Add( PCB_ACTIONS::zoneUnfillAll );
504 m_drawToolBar->AddToolContextMenu( PCB_ACTIONS::drawZone, std::move( zoneMenu ) );
505
506 std::unique_ptr<ACTION_MENU> lineMenu = std::make_unique<ACTION_MENU>( false, selTool );
507 m_drawToolBar->AddToolContextMenu( PCB_ACTIONS::drawLine, std::move( lineMenu ) );
508
510}
511
512
514{
515 wxWindowUpdateLocker dummy( this );
516
518 {
520 }
521 else
522 {
523 m_auxiliaryToolBar = new ACTION_TOOLBAR( this, ID_AUX_TOOLBAR, wxDefaultPosition,
524 wxDefaultSize,
525 KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT );
526
527 // The layer indicator is special, so we register a callback directly that will
528 // regenerate the bitmap instead of using the conditions system.
529 auto layerIndicatorUpdate =
530 [this] ( wxUpdateUIEvent& )
531 {
533 };
534
535 Bind( wxEVT_UPDATE_UI, layerIndicatorUpdate, PCB_ACTIONS::selectLayerPair.GetUIId() );
536
538 }
539
540 /* Set up toolbar items */
541
542 // Creates box to display and choose tracks widths:
543 if( m_SelTrackWidthBox == nullptr )
545 wxDefaultPosition, wxDefaultSize, 0, nullptr );
546
549 m_SelTrackWidthBox->SetToolTip( _( "Select the default width for new tracks. Note that this "
550 "width can be overridden by the board minimum width, or by "
551 "the width of an existing track if the 'Use Existing Track "
552 "Width' feature is enabled." ) );
553
555 KiScaledBitmap( BITMAPS::auto_track_width, this ),
556 _( "When routing from an existing track use its width instead "
557 "of the current width setting" ),
558 wxITEM_CHECK );
559
561
562 // Creates box to display and choose vias diameters:
563
564 if( m_SelViaSizeBox == nullptr )
566 wxDefaultPosition, wxDefaultSize, 0, nullptr );
567
569 m_auxiliaryToolBar->AddControl( m_SelViaSizeBox );
570
572
573 if( m_SelLayerBox == nullptr )
574 {
577 }
578
579 ReCreateLayerBox( false );
580 m_auxiliaryToolBar->AddControl( m_SelLayerBox );
581
583 PrepareLayerIndicator( true ); // Force rebuild of the bitmap with the active layer colors
584
585 // Add the box to display and select the current grid size:
587
588 if( m_gridSelectBox == nullptr )
590 wxDefaultPosition, wxDefaultSize, 0, nullptr );
591
593
594 m_auxiliaryToolBar->AddControl( m_gridSelectBox );
595
596 // Add the box to display and select the current Zoom
598
599 if( m_zoomSelectBox == nullptr )
601 wxDefaultPosition, wxDefaultSize, 0, nullptr );
602
604 m_auxiliaryToolBar->AddControl( m_zoomSelectBox );
605
606 // Go through and ensure the comboboxes are the correct size, since the strings in the
607 // box could have changed widths.
613
614 // after adding the buttons to the toolbar, must call Realize()
616}
617
618
620{
621 if( m_mainToolBar )
622 {
623 // Update the item widths
624 }
625
627 {
628 // Update the item widths
634 }
635}
636
637
638static wxString ComboBoxUnits( EDA_UNITS aUnits, double aValue, bool aIncludeLabel = true )
639{
640 wxString text;
641 const wxChar* format;
642
643 switch( aUnits )
644 {
645 default:
646 wxASSERT_MSG( false, wxT( "Invalid unit" ) );
648 case EDA_UNITS::UNSCALED: format = wxT( "%.0f" ); break;
649 case EDA_UNITS::MILLIMETRES: format = wxT( "%.3f" ); break;
650 case EDA_UNITS::MILS: format = wxT( "%.2f" ); break;
651 case EDA_UNITS::INCHES: format = wxT( "%.5f" ); break;
652 }
653
654 text.Printf( format, EDA_UNIT_UTILS::UI::ToUserUnit( pcbIUScale, aUnits, aValue ) );
655
656 if( aIncludeLabel )
658
659 return text;
660}
661
662
663void PCB_EDIT_FRAME::UpdateTrackWidthSelectBox( wxChoice* aTrackWidthSelectBox, bool aShowNetclass,
664 bool aShowEdit )
665{
666 if( aTrackWidthSelectBox == nullptr )
667 return;
668
669 EDA_UNITS primaryUnit;
670 EDA_UNITS secondaryUnit;
671
672 GetUnitPair( primaryUnit, secondaryUnit );
673
674 wxString msg;
675
676 aTrackWidthSelectBox->Clear();
677
678 if( aShowNetclass )
679 aTrackWidthSelectBox->Append( _( "Track: use netclass width" ) );
680
681 for( unsigned ii = 1; ii < GetDesignSettings().m_TrackWidthList.size(); ii++ )
682 {
683 int size = GetDesignSettings().m_TrackWidthList[ii];
684
685 msg.Printf( _( "Track: %s (%s)" ), ComboBoxUnits( primaryUnit, size ),
686 ComboBoxUnits( secondaryUnit, size ) );
687
688 aTrackWidthSelectBox->Append( msg );
689 }
690
691 if( aShowEdit )
692 {
693 aTrackWidthSelectBox->Append( wxT( "---" ) );
694 aTrackWidthSelectBox->Append( _( "Edit Pre-defined Sizes..." ) );
695 }
696
697 if( GetDesignSettings().GetTrackWidthIndex() >= GetDesignSettings().m_TrackWidthList.size() )
699
700 aTrackWidthSelectBox->SetSelection( GetDesignSettings().GetTrackWidthIndex() );
701}
702
703
704void PCB_EDIT_FRAME::UpdateViaSizeSelectBox( wxChoice* aViaSizeSelectBox, bool aShowNetclass,
705 bool aShowEdit )
706{
707 if( aViaSizeSelectBox == nullptr )
708 return;
709
710 aViaSizeSelectBox->Clear();
711
713
714 EDA_UNITS primaryUnit = GetUserUnits();
715 EDA_UNITS secondaryUnit = EDA_UNITS::MILS;
716
717 if( EDA_UNIT_UTILS::IsImperialUnit( primaryUnit ) )
718 {
719 if( cmnTool )
720 secondaryUnit = cmnTool->GetLastMetricUnits();
721 else
722 secondaryUnit = EDA_UNITS::MILLIMETRES;
723 }
724 else
725 {
726 if( cmnTool )
727 secondaryUnit = cmnTool->GetLastImperialUnits();
728 else
729 secondaryUnit = EDA_UNITS::MILS;
730 }
731
732 if( aShowNetclass )
733 aViaSizeSelectBox->Append( _( "Via: use netclass sizes" ) );
734
735 for( unsigned ii = 1; ii < GetDesignSettings().m_ViasDimensionsList.size(); ii++ )
736 {
738 wxString msg, priStr, secStr;
739
740 double diam = viaDimension.m_Diameter;
741 double hole = viaDimension.m_Drill;
742
743 if( hole > 0 )
744 {
745 priStr = ComboBoxUnits( primaryUnit, diam, false ) + wxT( " / " )
746 + ComboBoxUnits( primaryUnit, hole, true );
747 secStr = ComboBoxUnits( secondaryUnit, diam, false ) + wxT( " / " )
748 + ComboBoxUnits( secondaryUnit, hole, true );
749 }
750 else
751 {
752 priStr = ComboBoxUnits( primaryUnit, diam, true );
753 secStr = ComboBoxUnits( secondaryUnit, diam, true );
754 }
755
756 msg.Printf( _( "Via: %s (%s)" ), priStr, secStr );
757
758 aViaSizeSelectBox->Append( msg );
759 }
760
761 if( aShowEdit )
762 {
763 aViaSizeSelectBox->Append( wxT( "---" ) );
764 aViaSizeSelectBox->Append( _( "Edit Pre-defined Sizes..." ) );
765 }
766
767 if( GetDesignSettings().GetViaSizeIndex() >= GetDesignSettings().m_ViasDimensionsList.size() )
769
770 aViaSizeSelectBox->SetSelection( GetDesignSettings().GetViaSizeIndex() );
771}
772
773
774void PCB_EDIT_FRAME::ReCreateLayerBox( bool aForceResizeToolbar )
775{
776 if( m_SelLayerBox == nullptr || m_auxiliaryToolBar == nullptr )
777 return;
778
779 m_SelLayerBox->SetToolTip( _( "+/- to switch" ) );
781
782 if( aForceResizeToolbar )
784}
785
786
788{
790 wxAuiPaneInfo& layersManager = m_auimgr.GetPane( "LayersManager" );
791 wxAuiPaneInfo& selectionFilter = m_auimgr.GetPane( "SelectionFilter" );
792
793 // show auxiliary Vertical layers and visibility manager toolbar
795
796 layersManager.Show( m_show_layer_manager_tools );
797 selectionFilter.Show( m_show_layer_manager_tools );
798
800 {
801 SetAuiPaneSize( m_auimgr, layersManager, settings->m_AuiPanels.right_panel_width, -1 );
802 }
803 else
804 {
805 settings->m_AuiPanels.right_panel_width = m_appearancePanel->GetSize().x;
806 m_auimgr.Update();
807 }
808}
809
810
812{
814 wxAuiPaneInfo& netInspectorPanel = m_auimgr.GetPane( NetInspectorPanelName() );
815
817
818 netInspectorPanel.Show( m_show_net_inspector );
819
821 {
822 SetAuiPaneSize( m_auimgr, netInspectorPanel, settings->m_AuiPanels.net_inspector_width,
823 -1 );
825 }
826 else
827 {
829 settings->m_AuiPanels.net_inspector_width = m_netInspectorPanel->GetSize().x;
830 m_auimgr.Update();
831 }
832}
833
834
836{
838
839 // Ensure m_show_search is up to date (the pane can be closed outside the menu)
840 m_show_search = m_auimgr.GetPane( SearchPaneName() ).IsShown();
841
843
844 wxAuiPaneInfo& searchPaneInfo = m_auimgr.GetPane( SearchPaneName() );
845 searchPaneInfo.Show( m_show_search );
846
847 if( m_show_search )
848 {
849 searchPaneInfo.Direction( settings->m_AuiPanels.search_panel_dock_direction );
850
851 if( settings->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_TOP
852 || settings->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_BOTTOM )
853 {
854 SetAuiPaneSize( m_auimgr, searchPaneInfo,
855 -1, settings->m_AuiPanels.search_panel_height );
856 }
857 else if( settings->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_LEFT
858 || settings->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_RIGHT )
859 {
860 SetAuiPaneSize( m_auimgr, searchPaneInfo,
861 settings->m_AuiPanels.search_panel_width, -1 );
862 }
864 }
865 else
866 {
867 settings->m_AuiPanels.search_panel_height = m_searchPane->GetSize().y;
868 settings->m_AuiPanels.search_panel_width = m_searchPane->GetSize().x;
869 settings->m_AuiPanels.search_panel_dock_direction = searchPaneInfo.dock_direction;
870 m_auimgr.Update();
871 }
872}
873
874
875void PCB_EDIT_FRAME::OnUpdateSelectTrackWidth( wxUpdateUIEvent& aEvent )
876{
877 if( aEvent.GetId() == ID_AUX_TOOLBAR_PCB_TRACK_WIDTH )
878 {
880 int sel;
881
882 if( bds.UseCustomTrackViaSize() )
883 sel = wxNOT_FOUND;
884 else
885 sel = bds.GetTrackWidthIndex();
886
887 if( m_SelTrackWidthBox->GetSelection() != sel )
888 m_SelTrackWidthBox->SetSelection( sel );
889 }
890}
891
892
893void PCB_EDIT_FRAME::OnUpdateSelectViaSize( wxUpdateUIEvent& aEvent )
894{
895 if( aEvent.GetId() == ID_AUX_TOOLBAR_PCB_VIA_SIZE )
896 {
898 int sel = 0;
899
900 if( bds.UseCustomTrackViaSize() )
901 sel = wxNOT_FOUND;
902 else
903 sel = bds.GetViaSizeIndex();
904
905 if( m_SelViaSizeBox->GetSelection() != sel )
906 m_SelViaSizeBox->SetSelection( sel );
907 }
908}
909
910
911void PCB_EDIT_FRAME::OnUpdateSelectAutoWidth( wxUpdateUIEvent& aEvent )
912{
914
915 aEvent.Check( bds.m_UseConnectedTrackWidth );
916}
917
918
919void PCB_EDIT_FRAME::OnUpdateLayerSelectBox( wxUpdateUIEvent& aEvent )
920{
923}
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:108
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:147
static TOOL_ACTION gridProperties
Definition: actions.h:174
static TOOL_ACTION updatePcbFromSchematic
Definition: actions.h:199
static TOOL_ACTION toggleGrid
Definition: actions.h:172
static TOOL_ACTION zoomRedraw
Definition: actions.h:114
static TOOL_ACTION millimetersUnits
Definition: actions.h:180
static TOOL_ACTION show3DViewer
Definition: actions.h:194
static TOOL_ACTION zoomOutCenter
Definition: actions.h:118
static TOOL_ACTION togglePolarCoords
Definition: actions.h:183
static TOOL_ACTION milsUnits
Definition: actions.h:179
static TOOL_ACTION toggleBoundingBoxes
Definition: actions.h:135
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:66
static TOOL_ACTION inchesUnits
Definition: actions.h:178
static TOOL_ACTION highContrastMode
Definition: actions.h:133
static TOOL_ACTION toggleCursorStyle
Definition: actions.h:132
static TOOL_ACTION gridOrigin
Definition: actions.h:175
static TOOL_ACTION measureTool
Definition: actions.h:188
static TOOL_ACTION selectionTool
Definition: actions.h:187
static TOOL_ACTION save
Definition: actions.h:51
static TOOL_ACTION zoomFitScreen
Definition: actions.h:124
static TOOL_ACTION redo
Definition: actions.h:67
static TOOL_ACTION deleteTool
Definition: actions.h:76
static TOOL_ACTION zoomTool
Definition: actions.h:127
static TOOL_ACTION showFootprintEditor
Definition: actions.h:198
static TOOL_ACTION print
Definition: actions.h:57
static TOOL_ACTION showProperties
Definition: actions.h:201
static TOOL_ACTION doNew
Definition: actions.h:47
static TOOL_ACTION zoomFitObjects
Definition: actions.h:125
static TOOL_ACTION zoomInCenter
Definition: actions.h:117
static TOOL_ACTION gridSetOrigin
Definition: actions.h:169
static TOOL_ACTION showFootprintBrowser
Definition: actions.h:197
static TOOL_ACTION toggleGridOverrides
Definition: actions.h:173
static TOOL_ACTION find
Definition: actions.h:99
A group of actions that will be displayed together on a toolbar palette.
static constexpr bool CHECK
Definition: action_menu.h:201
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,...
ACTION_TOOLBAR * m_mainToolBar
NET_INSPECTOR_PANEL * m_netInspectorPanel
static const wxString NetInspectorPanelName()
void GetUnitPair(EDA_UNITS &aPrimaryUnit, EDA_UNITS &aSecondaryUnits) override
Get the pair or units in current use.
ACTION_TOOLBAR * m_drawToolBar
SEARCH_PANE * m_searchPane
wxChoice * m_zoomSelectBox
virtual void addApiPluginTools()
Append actions from API plugins to the main toolbar.
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:311
wxColour ToColour() const
Definition: color4d.cpp:220
int SetLayerSelection(int layer)
virtual void SaveSettings()
Save the net inspector settings - called from EDA_EDIT_FRAME when hiding the panel.
virtual void OnShowPanel()
Prepare the panel when (re-)shown in the editor.
AUI_PANELS m_AuiPanels
static TOOL_ACTION toggleHV45Mode
Definition: pcb_actions.h:511
static TOOL_ACTION drawRuleArea
Definition: pcb_actions.h:215
static TOOL_ACTION placeText
Definition: pcb_actions.h:201
static TOOL_ACTION pointEditorArcKeepCenter
Definition: pcb_actions.h:290
static TOOL_ACTION drawOrthogonalDimension
Definition: pcb_actions.h:211
static TOOL_ACTION drawRectangle
Definition: pcb_actions.h:197
static TOOL_ACTION padDisplayMode
Definition: pcb_actions.h:325
static TOOL_ACTION placeReferenceImage
Definition: pcb_actions.h:200
static TOOL_ACTION routerSettingsDialog
Activation of the Push and Shove settings dialogs.
Definition: pcb_actions.h:261
static TOOL_ACTION showRatsnest
Definition: pcb_actions.h:320
static TOOL_ACTION zoneFillAll
Definition: pcb_actions.h:392
static TOOL_ACTION showLayersManager
Definition: pcb_actions.h:437
static TOOL_ACTION toggleNetHighlight
Definition: pcb_actions.h:547
static TOOL_ACTION drawCircle
Definition: pcb_actions.h:198
static TOOL_ACTION mirrorH
Mirroring of selected items.
Definition: pcb_actions.h:139
static TOOL_ACTION routeDiffPair
Activation of the Push and Shove router (differential pair mode)
Definition: pcb_actions.h:246
static TOOL_ACTION tuneDiffPair
Definition: pcb_actions.h:249
static TOOL_ACTION drawTable
Definition: pcb_actions.h:203
static TOOL_ACTION drawTextBox
Definition: pcb_actions.h:202
static TOOL_ACTION routerHighlightMode
Actions to enable switching modes via hotkey assignments.
Definition: pcb_actions.h:265
static TOOL_ACTION routerWalkaroundMode
Definition: pcb_actions.h:267
static TOOL_ACTION routerShoveMode
Definition: pcb_actions.h:266
static TOOL_ACTION drawPolygon
Definition: pcb_actions.h:196
static TOOL_ACTION group
Definition: pcb_actions.h:519
static TOOL_ACTION zoneDisplayFilled
Definition: pcb_actions.h:327
static TOOL_ACTION drawRadialDimension
Definition: pcb_actions.h:210
static TOOL_ACTION tuneSingleTrack
Definition: pcb_actions.h:248
static TOOL_ACTION viaDisplayMode
Definition: pcb_actions.h:326
static TOOL_ACTION drawLeader
Definition: pcb_actions.h:212
static TOOL_ACTION drillOrigin
Definition: pcb_actions.h:529
static TOOL_ACTION tuneSkew
Definition: pcb_actions.h:250
static TOOL_ACTION trackDisplayMode
Definition: pcb_actions.h:324
static TOOL_ACTION selectLayerPair
Definition: pcb_actions.h:186
static TOOL_ACTION zoneDisplayTriangulated
Definition: pcb_actions.h:330
static TOOL_ACTION ungroup
Definition: pcb_actions.h:520
static TOOL_ACTION zoneDisplayFractured
Definition: pcb_actions.h:329
static TOOL_ACTION drawVia
Definition: pcb_actions.h:214
static TOOL_ACTION drawArc
Definition: pcb_actions.h:199
static TOOL_ACTION runDRC
Definition: pcb_actions.h:432
static TOOL_ACTION importNetlist
Definition: pcb_actions.h:419
static TOOL_ACTION pointEditorArcKeepEndpoint
Definition: pcb_actions.h:291
static TOOL_ACTION boardSetup
Definition: pcb_actions.h:405
static TOOL_ACTION showEeschema
Definition: pcb_actions.h:533
static TOOL_ACTION drawCenterDimension
Definition: pcb_actions.h:209
static TOOL_ACTION zoneUnfillAll
Definition: pcb_actions.h:395
static TOOL_ACTION zoneDisplayOutline
Definition: pcb_actions.h:328
static TOOL_ACTION ratsnestLineMode
Definition: pcb_actions.h:321
static TOOL_ACTION mirrorV
Definition: pcb_actions.h:140
static TOOL_ACTION unlock
Definition: pcb_actions.h:516
static TOOL_ACTION placeFootprint
Definition: pcb_actions.h:220
static TOOL_ACTION routeSingleTrack
Activation of the Push and Shove router.
Definition: pcb_actions.h:243
static TOOL_ACTION showPythonConsole
Definition: pcb_actions.h:439
static TOOL_ACTION drawLine
Definition: pcb_actions.h:195
static TOOL_ACTION localRatsnestTool
Definition: pcb_actions.h:554
static TOOL_ACTION rotateCw
Rotation of selected objects.
Definition: pcb_actions.h:132
static TOOL_ACTION rotateCcw
Definition: pcb_actions.h:133
static TOOL_ACTION drawAlignedDimension
Definition: pcb_actions.h:208
static TOOL_ACTION drawZone
Definition: pcb_actions.h:213
static TOOL_ACTION lock
Definition: pcb_actions.h:515
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 OnUpdateSelectTrackWidth(wxUpdateUIEvent &aEvent)
void ReCreateHToolbar() override
void UpdateTrackWidthSelectBox(wxChoice *aTrackWidthSelectBox, bool aShowNetclass, bool aShowEdit)
void ReCreateVToolbar() override
void UpdateViaSizeSelectBox(wxChoice *aViaSizeSelectBox, bool aShowNetclass, bool aShowEdit)
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:
virtual COMMON_SETTINGS * GetCommonSettings() const
Definition: pgm_base.cpp:678
void FocusSearch()
Definition: search_pane.cpp:96
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:167
#define _(s)
EDA_UNITS
Definition: eda_units.h:46
@ 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:224
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
KICOMMON_API 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:259
KICOMMON_API 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:126
KICOMMON_API bool IsImperialUnit(EDA_UNITS aUnit)
Definition: eda_units.cpp:47
@ 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
int GetUserUnits()
Return the currently selected user unit value for the interface.
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: pgm_base.cpp:1059
see class PGM_BASE
const int scale
std::vector< FAB_LAYER_COLOR > dummy
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.