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 The 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#include <string>
29
30#include <advanced_config.h>
32#include <bitmaps.h>
33#include <board.h>
35#include <footprint.h>
36#include <kiface_base.h>
37#include <kiplatform/ui.h>
38#include <macros.h>
39#include <pcb_edit_frame.h>
40#include <pcb_field.h>
42#include <pcbnew_id.h>
43#include <pcbnew_settings.h>
44#include <eda_text.h>
45#include <pcb_field.h>
46#include <pgm_base.h>
49#include <router/router_tool.h>
51#include <tool/action_menu.h>
52#include <tool/action_toolbar.h>
53#include <tool/actions.h>
54#include <tool/common_tools.h>
55#include <tool/tool_manager.h>
57#include <tools/pcb_actions.h>
67#include <wx/wupdlock.h>
68#include <wx/combobox.h>
69#include <toolbars_pcb_editor.h>
71
72#include "../scripting/python_scripting.h"
73
74
75/* Data to build the layer pair indicator button */
76static wxBitmapBundle LayerPairBitmap;
77
78
79void PCB_EDIT_FRAME::PrepareLayerIndicator( bool aForceRebuild )
80{
81 COLOR4D top_color, bottom_color, background_color;
82 bool change = aForceRebuild;
83
85
86 if( m_prevIconVal.previous_icon_size != icon_size )
87 {
88 m_prevIconVal.previous_icon_size = icon_size;
89 change = true;
90 }
91
92 top_color = GetColorSettings()->GetColor( GetScreen()->m_Route_Layer_TOP );
93
94 if( m_prevIconVal.previous_Route_Layer_TOP_color != top_color )
95 {
96 m_prevIconVal.previous_Route_Layer_TOP_color = top_color;
97 change = true;
98 }
99
100 bottom_color = GetColorSettings()->GetColor( GetScreen()->m_Route_Layer_BOTTOM );
101
102 if( m_prevIconVal.previous_Route_Layer_BOTTOM_color != bottom_color )
103 {
104 m_prevIconVal.previous_Route_Layer_BOTTOM_color = bottom_color;
105 change = true;
106 }
107
108 if( change || !LayerPairBitmap.IsOk() )
109 {
110 LayerPairBitmap = LAYER_PRESENTATION::CreateLayerPairIcon( top_color, bottom_color, icon_size );
111
112 if( m_tbTopAux )
113 {
115 m_tbTopAux->Refresh();
116 }
117 }
118}
119
120
122 _( "Track width selector" ),
123 _( "Control to select the track width" ),
124 { FRAME_PCB_EDITOR } );
126 _( "Via diameter selector" ),
127 _( "Control to select the via diameter" ),
128 { FRAME_PCB_EDITOR } );
130 _( "Current variant" ),
131 _( "Control to select the current variant" ),
132 { FRAME_PCB_EDITOR } );
133
134
135std::optional<TOOLBAR_CONFIGURATION> PCB_EDIT_TOOLBAR_SETTINGS::DefaultToolbarConfig( TOOLBAR_LOC aToolbar )
136{
138
139 // clang-format off
140 switch( aToolbar )
141 {
143 config.AppendAction( ACTIONS::toggleGrid )
144 .WithContextMenu(
145 []( TOOL_MANAGER* aMgr ) -> std::unique_ptr<ACTION_MENU>
146 {
148 std::unique_ptr<ACTION_MENU> menu =
149 std::make_unique<ACTION_MENU>( false, selTool );
150
151 menu->Add( ACTIONS::gridProperties );
152 menu->Add( ACTIONS::gridOrigin );
153
154 return menu;
155 } )
156 .AppendAction( ACTIONS::toggleGridOverrides )
157 .AppendAction( PCB_ACTIONS::togglePolarCoords )
158 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Units" ) )
159 .AddAction( ACTIONS::millimetersUnits )
160 .AddAction( ACTIONS::inchesUnits )
161 .AddAction( ACTIONS::milsUnits ) )
162 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Crosshair modes" ) )
165 .AddAction( ACTIONS::cursor45Crosshairs ) );
166
167 config.AppendSeparator()
168 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Line modes" ) )
169 .AddAction( PCB_ACTIONS::lineModeFree )
170 .AddAction( PCB_ACTIONS::lineMode90 )
171 .AddAction( PCB_ACTIONS::lineMode45 ) );
172
173 config.AppendSeparator()
174 .AppendAction( PCB_ACTIONS::showRatsnest )
175 .AppendAction( PCB_ACTIONS::ratsnestLineMode );
176
177 config.AppendSeparator()
178 .AppendAction( ACTIONS::highContrastMode )
179 .AppendAction( PCB_ACTIONS::toggleNetHighlight );
180
181 config.AppendSeparator()
182 .AppendAction( PCB_ACTIONS::zoneDisplayFilled )
183 .AppendAction( PCB_ACTIONS::zoneDisplayOutline );
184
185 if( ADVANCED_CFG::GetCfg().m_ExtraZoneDisplayModes )
186 {
189 }
190
191 config.AppendSeparator()
192 .AppendAction( PCB_ACTIONS::padDisplayMode )
193 .AppendAction( PCB_ACTIONS::viaDisplayMode )
194 .AppendAction( PCB_ACTIONS::trackDisplayMode );
195
196 if( ADVANCED_CFG::GetCfg().m_DrawBoundingBoxes )
197 config.AppendAction( ACTIONS::toggleBoundingBoxes );
198
199 // Tools to show/hide toolbars:
200 config.AppendSeparator()
201 .AppendAction( PCB_ACTIONS::showLayersManager )
202 .AppendAction( ACTIONS::showProperties );
203
204 break;
205
207 config.AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Selection modes" ) )
208 .AddAction( ACTIONS::selectSetRect )
209 .AddAction( ACTIONS::selectSetLasso ) )
210 .AppendAction( PCB_ACTIONS::localRatsnestTool );
211
212 config.AppendSeparator()
213 .AppendAction( PCB_ACTIONS::placeFootprint )
214 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Track routing tools" ) )
216 .AddAction( PCB_ACTIONS::routeDiffPair )
217 .AddContextMenu(
218 []( TOOL_MANAGER* aMgr ) -> std::unique_ptr<ACTION_MENU>
219 {
221 std::unique_ptr<ACTION_MENU> menu =
222 std::make_unique<ACTION_MENU>( false, selTool );
223
227 menu->AppendSeparator();
229
230 return menu;
231 } ) )
232 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Track tuning tools" ) )
233 .AddAction( PCB_ACTIONS::tuneSingleTrack )
234 .AddAction( PCB_ACTIONS::tuneDiffPair )
235 .AddAction( PCB_ACTIONS::tuneSkew ) )
236 .AppendAction( PCB_ACTIONS::drawVia )
237 .AppendAction( PCB_ACTIONS::drawZone )
238 .WithContextMenu(
239 []( TOOL_MANAGER* aMgr ) -> std::unique_ptr<ACTION_MENU>
240 {
242 std::unique_ptr<ACTION_MENU> menu =
243 std::make_unique<ACTION_MENU>( false, selTool );
244
245 menu->Add( PCB_ACTIONS::zoneFillAll );
246 menu->Add( PCB_ACTIONS::zoneUnfillAll );
247
248 return menu;
249 } )
250 .AppendAction( PCB_ACTIONS::drawRuleArea );
251
252 config.AppendSeparator()
253 .AppendAction( PCB_ACTIONS::drawLine )
254 .AppendAction( PCB_ACTIONS::drawArc )
255 .WithContextMenu(
256 []( TOOL_MANAGER* aMgr ) -> std::unique_ptr<ACTION_MENU>
257 {
259 std::unique_ptr<ACTION_MENU> menu =
260 std::make_unique<ACTION_MENU>( false, selTool );
261
265
266 return menu;
267 } )
268 .AppendAction( PCB_ACTIONS::drawRectangle )
269 .AppendAction( PCB_ACTIONS::drawCircle )
270 .AppendAction( PCB_ACTIONS::drawPolygon )
271 .AppendAction( PCB_ACTIONS::drawBezier )
272 .AppendAction( PCB_ACTIONS::placeReferenceImage )
273 .AppendAction( PCB_ACTIONS::placeText )
274 .AppendAction( PCB_ACTIONS::drawTextBox )
275 .AppendAction( PCB_ACTIONS::drawTable )
276 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Dimension objects" ) )
281 .AddAction( PCB_ACTIONS::drawLeader ) )
282 .AppendAction( PCB_ACTIONS::placeBarcode )
283 .AppendAction( ACTIONS::deleteTool );
284
285 config.AppendSeparator()
286 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "PCB origins and points" ) )
287 .AddAction( ACTIONS::gridSetOrigin )
288 .AddAction( PCB_ACTIONS::drillOrigin ) )
289 .AppendAction( PCB_ACTIONS::placePoint )
290 .AppendAction( ACTIONS::measureTool );
291
292 break;
293
295 if( Kiface().IsSingle() )
296 {
297 config.AppendAction( ACTIONS::doNew );
298 config.AppendAction( ACTIONS::open );
299 }
300
301 config.AppendAction( ACTIONS::save );
302
303 config.AppendSeparator()
304 .AppendAction( PCB_ACTIONS::boardSetup );
305
306 config.AppendSeparator()
307 .AppendAction( ACTIONS::pageSettings )
308 .AppendAction( ACTIONS::print )
309 .AppendAction( ACTIONS::plot );
310
311 config.AppendSeparator()
312 .AppendAction( ACTIONS::undo )
313 .AppendAction( ACTIONS::redo );
314
315 config.AppendSeparator()
316 .AppendAction( ACTIONS::find );
317
318 config.AppendSeparator()
319 .AppendAction( ACTIONS::zoomRedraw )
320 .AppendAction( ACTIONS::zoomInCenter )
321 .AppendAction( ACTIONS::zoomOutCenter )
322 .AppendAction( ACTIONS::zoomFitScreen )
323 .AppendAction( ACTIONS::zoomFitObjects )
324 .AppendAction( ACTIONS::zoomTool );
325
326 config.AppendSeparator()
327 .AppendAction( PCB_ACTIONS::rotateCcw )
328 .AppendAction( PCB_ACTIONS::rotateCw )
329 .AppendAction( PCB_ACTIONS::mirrorV )
330 .AppendAction( PCB_ACTIONS::mirrorH )
331 .AppendAction( ACTIONS::group )
332 .AppendAction( ACTIONS::ungroup )
333 .AppendAction( PCB_ACTIONS::lock )
334 .AppendAction( PCB_ACTIONS::unlock );
335
336 config.AppendSeparator()
337 .AppendAction( ACTIONS::showFootprintEditor )
338 .AppendAction( ACTIONS::showFootprintBrowser )
339 .AppendAction( ACTIONS::show3DViewer );
340
341 config.AppendSeparator();
342
343 if( !Kiface().IsSingle() )
345 else
346 config.AppendAction( PCB_ACTIONS::importNetlist );
347
348 config.AppendAction( PCB_ACTIONS::runDRC );
349
350 config.AppendSeparator();
351 config.AppendAction( PCB_ACTIONS::showEeschema );
354
355 break;
356
359 .AppendAction( PCB_ACTIONS::autoTrackWidth );
360
361 config.AppendSeparator()
363
364 config.AppendSeparator()
366 .AppendAction( PCB_ACTIONS::selectLayerPair );
367
368 config.AppendSeparator()
369 .AppendControl( ACTION_TOOLBAR_CONTROLS::gridSelect );
370
371 config.AppendSeparator()
372 .AppendControl( ACTION_TOOLBAR_CONTROLS::zoomSelect );
373
374 config.AppendSeparator()
376
377 break;
378 }
379
380 // clang-format on
381 return config;
382}
383
384
386{
388
389 // Box to display and choose track widths
390 auto trackWidthSelectorFactory =
391 [this]( ACTION_TOOLBAR* aToolbar )
392 {
393 if( !m_SelTrackWidthBox )
394 {
395 m_SelTrackWidthBox = new wxChoice( aToolbar, ID_AUX_TOOLBAR_PCB_TRACK_WIDTH,
396 wxDefaultPosition, wxDefaultSize, 0, nullptr );
397 }
398
399 m_SelTrackWidthBox->SetToolTip( _( "Select the default width for new tracks. Note that this "
400 "width can be overridden by the board minimum width, or by "
401 "the width of an existing track if the 'Use Existing Track "
402 "Width' feature is enabled." ) );
403
405
406 aToolbar->Add( m_SelTrackWidthBox );
407 };
408
410
411
412 // Box to display and choose vias diameters
413 auto viaDiaSelectorFactory =
414 [this]( ACTION_TOOLBAR* aToolbar )
415 {
416 if( !m_SelViaSizeBox )
417 {
418 m_SelViaSizeBox = new wxChoice( aToolbar, ID_AUX_TOOLBAR_PCB_VIA_SIZE,
419 wxDefaultPosition, wxDefaultSize, 0, nullptr );
420 }
421
423 aToolbar->Add( m_SelViaSizeBox );
424 };
425
427
428 // Variant selection drop down control on main tool bar
429 auto variantSelectionCtrlFactory =
430 [this]( ACTION_TOOLBAR* aToolbar )
431 {
433 {
435 wxDefaultPosition, wxDefaultSize, 0, nullptr );
436 }
437
438 m_CurrentVariantCtrl->SetToolTip( _( "Select the current variant to display and edit." ) );
439
441
442 aToolbar->Add( m_CurrentVariantCtrl );
443 };
444
446
447 // IPC/Scripting plugin control
448 // TODO (ISM): Clean this up to make IPC actions just normal tool actions to get rid of this entire
449 // control
450 auto pluginControlFactory =
451 [this]( ACTION_TOOLBAR* aToolbar )
452 {
453 // Add scripting console and API plugins
454 bool scriptingAvailable = SCRIPTING::IsWxAvailable();
455
456#ifdef KICAD_IPC_API
457 bool haveApiPlugins = Pgm().GetCommonSettings()->m_Api.enable_server
458 && !Pgm().GetPluginManager().GetActionsForScope( PluginActionScope() ).empty();
459#else
460 bool haveApiPlugins = false;
461#endif
462
463 if( scriptingAvailable || haveApiPlugins )
464 {
465 aToolbar->AddScaledSeparator( aToolbar->GetParent() );
466
467 if( scriptingAvailable )
468 {
469 aToolbar->Add( PCB_ACTIONS::showPythonConsole );
470 addActionPluginTools( aToolbar );
471 }
472
473 if( haveApiPlugins )
474 AddApiPluginTools( aToolbar );
475 }
476 };
477
479}
480
481
483{
485
486 switch( aId )
487 {
489 case ID_AUX_TOOLBAR_PCB_VIA_SIZE: m_SelViaSizeBox = nullptr; break;
491 }
492}
493
494
496{
498 return;
499
500 if( !GetBoard() )
501 return;
502
503 wxArrayString variantNames = GetBoard()->GetVariantNamesForUI();
504
505 m_CurrentVariantCtrl->Set( variantNames );
506
507 int selectionIndex = 0;
508 wxString currentVariant = GetBoard()->GetCurrentVariant();
509
510 if( !currentVariant.IsEmpty() )
511 {
512 int foundIndex = m_CurrentVariantCtrl->FindString( currentVariant );
513
514 if( foundIndex != wxNOT_FOUND )
515 selectionIndex = foundIndex;
516 }
517
518 if( m_CurrentVariantCtrl->GetCount() > 0 )
519 m_CurrentVariantCtrl->SetSelection( selectionIndex );
520}
521
522
523void PCB_EDIT_FRAME::onVariantSelected( wxCommandEvent& aEvent )
524{
526 return;
527
528 int selection = m_CurrentVariantCtrl->GetSelection();
529
530 if( selection == wxNOT_FOUND || selection == 0 )
531 {
532 // "<Default>" selected - clear the current variant
533 GetBoard()->SetCurrentVariant( wxEmptyString );
534 }
535 else
536 {
537 wxString selectedVariant = m_CurrentVariantCtrl->GetString( selection );
538 GetBoard()->SetCurrentVariant( selectedVariant );
539 }
540
541 // Refresh the view and properties panel to show the new variant state
543
545 [&]( KIGFX::VIEW_ITEM* aItem ) -> int
546 {
547 if( EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aItem ) )
548 {
549 if( text->HasTextVars() )
550 {
551 text->ClearRenderCache();
552 text->ClearBoundingBoxCache();
554 }
555 }
556
557 if( PCB_FIELD* field = dynamic_cast<PCB_FIELD*>( aItem ) )
558 {
559 if( FOOTPRINT* fp = field->GetParentFootprint() )
560 {
561 if( !fp->GetVariants().empty() )
562 {
563 field->ClearRenderCache();
564 field->ClearBoundingBoxCache();
566 }
567 }
568 }
569
570 return 0;
571 } );
572
573 GetCanvas()->Refresh();
574
575 Update3DView( true, GetPcbNewSettings()->m_Display.m_Live3DRefresh );
576}
577
578
579static wxString ComboBoxUnits( EDA_UNITS aUnits, double aValue, bool aIncludeLabel = true )
580{
581 wxString text;
582 const wxChar* format;
583
584 switch( aUnits )
585 {
586 default:
587 wxASSERT_MSG( false, wxT( "Invalid unit" ) );
589 case EDA_UNITS::UNSCALED: format = wxT( "%.0f" ); break;
590 case EDA_UNITS::MM: format = wxT( "%.3f" ); break;
591 case EDA_UNITS::MILS: format = wxT( "%.2f" ); break;
592 case EDA_UNITS::INCH: format = wxT( "%.5f" ); break;
593 }
594
595 text.Printf( format, EDA_UNIT_UTILS::UI::ToUserUnit( pcbIUScale, aUnits, aValue ) );
596
597 if( aIncludeLabel )
599
600 return text;
601}
602
603
604void PCB_EDIT_FRAME::UpdateTrackWidthSelectBox( wxChoice* aTrackWidthSelectBox, bool aShowNetclass,
605 bool aShowEdit )
606{
607 if( aTrackWidthSelectBox == nullptr )
608 return;
609
610 EDA_UNITS primaryUnit;
611 EDA_UNITS secondaryUnit;
612
613 GetUnitPair( primaryUnit, secondaryUnit );
614
615 wxString msg;
616
617 aTrackWidthSelectBox->Clear();
618
619 if( aShowNetclass )
620 aTrackWidthSelectBox->Append( _( "Track: use netclass width" ) );
621
622 for( unsigned ii = 1; ii < GetDesignSettings().m_TrackWidthList.size(); ii++ )
623 {
624 int size = GetDesignSettings().m_TrackWidthList[ii];
625
626 msg.Printf( _( "Track: %s (%s)" ), ComboBoxUnits( primaryUnit, size ),
627 ComboBoxUnits( secondaryUnit, size ) );
628
629 aTrackWidthSelectBox->Append( msg );
630 }
631
632 if( aShowEdit )
633 {
634 aTrackWidthSelectBox->Append( wxT( "---" ) );
635 aTrackWidthSelectBox->Append( _( "Edit Pre-defined Sizes..." ) );
636 }
637
638 if( GetDesignSettings().GetTrackWidthIndex() >= (int) GetDesignSettings().m_TrackWidthList.size() )
640
641 // GetDesignSettings().GetTrackWidthIndex() can be < 0 if no board loaded
642 // So in this case select the first select box item available (use netclass)
643 aTrackWidthSelectBox->SetSelection( std::max( 0, GetDesignSettings().GetTrackWidthIndex() ) );
644}
645
646
647void PCB_EDIT_FRAME::UpdateViaSizeSelectBox( wxChoice* aViaSizeSelectBox, bool aShowNetclass,
648 bool aShowEdit )
649{
650 if( aViaSizeSelectBox == nullptr )
651 return;
652
653 aViaSizeSelectBox->Clear();
654
655 COMMON_TOOLS* cmnTool = m_toolManager->GetTool<COMMON_TOOLS>();
656 EDA_UNITS primaryUnit = GetUserUnits();
657 EDA_UNITS secondaryUnit = EDA_UNITS::MILS;
658
659 if( EDA_UNIT_UTILS::IsImperialUnit( primaryUnit ) )
660 secondaryUnit = cmnTool ? cmnTool->GetLastMetricUnits() : EDA_UNITS::MM;
661 else
662 secondaryUnit = cmnTool ? cmnTool->GetLastImperialUnits() : EDA_UNITS::MILS;
663
664 if( aShowNetclass )
665 aViaSizeSelectBox->Append( _( "Via: use netclass sizes" ) );
666
667 for( unsigned ii = 1; ii < GetDesignSettings().m_ViasDimensionsList.size(); ii++ )
668 {
670 wxString msg, priStr, secStr;
671
672 double diam = viaDimension.m_Diameter;
673 double hole = viaDimension.m_Drill;
674
675 if( hole > 0 )
676 {
677 priStr = ComboBoxUnits( primaryUnit, diam, false ) + wxT( " / " )
678 + ComboBoxUnits( primaryUnit, hole, true );
679 secStr = ComboBoxUnits( secondaryUnit, diam, false ) + wxT( " / " )
680 + ComboBoxUnits( secondaryUnit, hole, true );
681 }
682 else
683 {
684 priStr = ComboBoxUnits( primaryUnit, diam, true );
685 secStr = ComboBoxUnits( secondaryUnit, diam, true );
686 }
687
688 msg.Printf( _( "Via: %s (%s)" ), priStr, secStr );
689
690 aViaSizeSelectBox->Append( msg );
691 }
692
693 if( aShowEdit )
694 {
695 aViaSizeSelectBox->Append( wxT( "---" ) );
696 aViaSizeSelectBox->Append( _( "Edit Pre-defined Sizes..." ) );
697 }
698
699 if( GetDesignSettings().GetViaSizeIndex() >= (int) GetDesignSettings().m_ViasDimensionsList.size() )
701
702 // GetDesignSettings().GetViaSizeIndex() can be < 0 if no board loaded
703 // So in this case select the first select box item available (use netclass)
704 aViaSizeSelectBox->SetSelection( std::max( 0, GetDesignSettings().GetViaSizeIndex() ) );
705}
706
707
708void PCB_EDIT_FRAME::ReCreateLayerBox( bool aForceResizeToolbar )
709{
710 if( m_SelLayerBox == nullptr || m_tbTopAux == nullptr )
711 return;
712
713 m_SelLayerBox->SetToolTip( _( "+/- to switch" ) );
714 m_SelLayerBox->Resync();
715
716 if( aForceResizeToolbar )
718}
719
720
722{
724 wxAuiPaneInfo& layersManager = m_auimgr.GetPane( AppearancePanelName() );
725 wxAuiPaneInfo& selectionFilter = m_auimgr.GetPane( "SelectionFilter" );
726
727 // show auxiliary Vertical layers and visibility manager toolbar
728 m_ShowLayerManagerTools = layersManager.IsShown();
729
731
732 layersManager.Show( m_ShowLayerManagerTools );
733 selectionFilter.Show( m_ShowLayerManagerTools );
734
736 {
737 SetAuiPaneSize( m_auimgr, layersManager, settings->m_AuiPanels.right_panel_width, -1 );
738 }
739 else
740 {
741 settings->m_AuiPanels.right_panel_width = m_appearancePanel->GetSize().x;
742 m_auimgr.Update();
743 }
744}
745
746
748{
750 wxAuiPaneInfo& netInspectorPanel = m_auimgr.GetPane( NetInspectorPanelName() );
751
752 m_ShowNetInspector = netInspectorPanel.IsShown();
753
755
756 netInspectorPanel.Show( m_ShowNetInspector );
757
759 {
760 SetAuiPaneSize( m_auimgr, netInspectorPanel, settings->m_AuiPanels.net_inspector_width, -1 );
761 m_netInspectorPanel->OnShowPanel();
762 }
763 else
764 {
765 m_netInspectorPanel->SaveSettings();
766 settings->m_AuiPanels.net_inspector_width = m_netInspectorPanel->GetSize().x;
767 m_auimgr.Update();
768 }
769}
770
771
773{
775
776 // Ensure m_ShowSearch is up to date (the pane can be closed outside the menu)
777 m_ShowSearch = m_auimgr.GetPane( SearchPaneName() ).IsShown();
778
780
781 wxAuiPaneInfo& searchPaneInfo = m_auimgr.GetPane( SearchPaneName() );
782 searchPaneInfo.Show( m_ShowSearch );
783
784 if( m_ShowSearch )
785 {
786 searchPaneInfo.Direction( settings->m_AuiPanels.search_panel_dock_direction );
787
788 if( settings->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_TOP
789 || settings->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_BOTTOM )
790 {
791 SetAuiPaneSize( m_auimgr, searchPaneInfo,
792 -1, settings->m_AuiPanels.search_panel_height );
793 }
794 else if( settings->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_LEFT
795 || settings->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_RIGHT )
796 {
797 SetAuiPaneSize( m_auimgr, searchPaneInfo,
798 settings->m_AuiPanels.search_panel_width, -1 );
799 }
800 m_searchPane->FocusSearch();
801 m_searchPane->RefreshSearch();
802 }
803 else
804 {
805 settings->m_AuiPanels.search_panel_height = m_searchPane->GetSize().y;
806 settings->m_AuiPanels.search_panel_width = m_searchPane->GetSize().x;
807 settings->m_AuiPanels.search_panel_dock_direction = searchPaneInfo.dock_direction;
808 m_auimgr.Update();
809 GetCanvas()->SetFocus();
810 }
811}
812
813
814void PCB_EDIT_FRAME::OnUpdateSelectTrackWidth( wxUpdateUIEvent& aEvent )
815{
816 if( aEvent.GetId() == ID_AUX_TOOLBAR_PCB_TRACK_WIDTH )
817 {
819 int sel;
820
821 if( bds.UseCustomTrackViaSize() )
822 sel = wxNOT_FOUND;
823 else
824 // if GetTrackWidthIndex() < 0, display the "use netclass" option
825 sel = std::max( 0, bds.GetTrackWidthIndex() );
826
827 if( m_SelTrackWidthBox->GetSelection() != sel )
828 m_SelTrackWidthBox->SetSelection( sel );
829 }
830}
831
832
833void PCB_EDIT_FRAME::OnUpdateSelectViaSize( wxUpdateUIEvent& aEvent )
834{
835 if( aEvent.GetId() == ID_AUX_TOOLBAR_PCB_VIA_SIZE )
836 {
838 int sel = 0;
839
840 if( bds.UseCustomTrackViaSize() )
841 sel = wxNOT_FOUND;
842 else
843 // if GetViaSizeIndex() < 0, display the "use netclass" option
844 sel = std::max( 0, bds.GetViaSizeIndex() );
845
846 if( m_SelViaSizeBox->GetSelection() != sel )
847 m_SelViaSizeBox->SetSelection( sel );
848 }
849}
850
851
853{
855
856 wxCHECK( cfg, /* void */ );
857
858 wxAuiPaneInfo& db_library_pane = m_auimgr.GetPane( DesignBlocksPaneName() );
859
860 db_library_pane.Show( !db_library_pane.IsShown() );
861
862 if( db_library_pane.IsShown() )
863 {
864 if( db_library_pane.IsFloating() )
865 {
866 db_library_pane.FloatingSize( cfg->m_AuiPanels.design_blocks_panel_float_width,
868 m_auimgr.Update();
869 }
871 {
872 // SetAuiPaneSize also updates m_auimgr
874 }
875 }
876 else
877 {
878 if( db_library_pane.IsFloating() )
879 {
880 cfg->m_AuiPanels.design_blocks_panel_float_width = db_library_pane.floating_size.x;
881 cfg->m_AuiPanels.design_blocks_panel_float_height = db_library_pane.floating_size.y;
882 }
883 else
884 {
886 }
887
888 m_auimgr.Update();
889 }
890}
constexpr EDA_IU_SCALE pcbIUScale
Definition base_units.h:112
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
static TOOL_ACTION gridProperties
Definition actions.h:200
static TOOL_ACTION updatePcbFromSchematic
Definition actions.h:264
static TOOL_ACTION toggleGrid
Definition actions.h:198
static TOOL_ACTION zoomRedraw
Definition actions.h:132
static TOOL_ACTION millimetersUnits
Definition actions.h:206
static TOOL_ACTION show3DViewer
Definition actions.h:258
static TOOL_ACTION cursorSmallCrosshairs
Definition actions.h:152
static TOOL_ACTION zoomOutCenter
Definition actions.h:136
static TOOL_ACTION togglePolarCoords
Definition actions.h:209
static TOOL_ACTION selectSetLasso
Definition actions.h:221
static TOOL_ACTION selectSetRect
Set lasso selection mode.
Definition actions.h:220
static TOOL_ACTION group
Definition actions.h:239
static TOOL_ACTION pointEditorArcKeepCenter
Definition actions.h:273
static TOOL_ACTION milsUnits
Definition actions.h:205
static TOOL_ACTION ungroup
Definition actions.h:240
static TOOL_ACTION toggleBoundingBoxes
Definition actions.h:157
static TOOL_ACTION plot
Definition actions.h:65
static TOOL_ACTION pointEditorArcKeepRadius
Definition actions.h:275
static TOOL_ACTION open
Definition actions.h:57
static TOOL_ACTION pageSettings
Definition actions.h:63
static TOOL_ACTION undo
Definition actions.h:75
static TOOL_ACTION inchesUnits
Definition actions.h:204
static TOOL_ACTION highContrastMode
Definition actions.h:155
static TOOL_ACTION gridOrigin
Definition actions.h:201
static TOOL_ACTION measureTool
Definition actions.h:252
static TOOL_ACTION save
Definition actions.h:58
static TOOL_ACTION zoomFitScreen
Definition actions.h:142
static TOOL_ACTION redo
Definition actions.h:76
static TOOL_ACTION deleteTool
Definition actions.h:86
static TOOL_ACTION zoomTool
Definition actions.h:146
static TOOL_ACTION cursor45Crosshairs
Definition actions.h:154
static TOOL_ACTION showFootprintEditor
Definition actions.h:262
static TOOL_ACTION print
Definition actions.h:64
static TOOL_ACTION showProperties
Definition actions.h:266
static TOOL_ACTION doNew
Definition actions.h:54
static TOOL_ACTION zoomFitObjects
Definition actions.h:143
static TOOL_ACTION zoomInCenter
Definition actions.h:135
static TOOL_ACTION gridSetOrigin
Definition actions.h:195
static TOOL_ACTION showFootprintBrowser
Definition actions.h:261
static TOOL_ACTION toggleGridOverrides
Definition actions.h:199
static TOOL_ACTION pointEditorArcKeepEndpoint
Definition actions.h:274
static TOOL_ACTION cursorFullCrosshairs
Definition actions.h:153
static TOOL_ACTION find
Definition actions.h:117
static constexpr bool CHECK
static ACTION_TOOLBAR_CONTROL gridSelect
static ACTION_TOOLBAR_CONTROL overrideLocks
static ACTION_TOOLBAR_CONTROL layerSelector
static ACTION_TOOLBAR_CONTROL zoomSelect
static ACTION_TOOLBAR_CONTROL ipcScripting
Class to hold basic information about controls that can be added to the toolbars.
Define the structure of a toolbar with buttons that invoke ACTIONs.
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 SetViaSizeIndex(int aIndex)
Set the current via size list index to aIndex.
void SetTrackWidthIndex(int aIndex)
Set the current track width list index to aIndex.
std::vector< int > m_TrackWidthList
std::vector< VIA_DIMENSION > m_ViasDimensionsList
FOOTPRINT * GetParentFootprint() const
void SetCurrentVariant(const wxString &aVariant)
Definition board.cpp:2511
wxArrayString GetVariantNamesForUI() const
Return the variant names for UI display.
Definition board.cpp:2657
wxString GetCurrentVariant() const
Definition board.h:404
COLOR4D GetColor(int aLayer) const
APPEARANCE m_Appearance
Handles action that are shared between different applications.
EDA_UNITS GetLastImperialUnits()
EDA_UNITS GetLastMetricUnits()
virtual void UpdateToolbarControlSizes()
Update the sizes of any controls in the toolbars of the frame.
void RegisterCustomToolbarControlFactory(const ACTION_TOOLBAR_CONTROL &aControlDesc, const ACTION_TOOLBAR_CONTROL_FACTORY &aControlFactory)
Register a creation factory for toolbar controls that are present in this frame.
wxAuiManager m_auimgr
ACTION_TOOLBAR * m_tbTopAux
static const wxString AppearancePanelName()
NET_INSPECTOR_PANEL * m_netInspectorPanel
virtual void AddApiPluginTools(ACTION_TOOLBAR *aToolbar)
Append actions from API plugins to the given toolbar.
static const wxString NetInspectorPanelName()
void GetUnitPair(EDA_UNITS &aPrimaryUnit, EDA_UNITS &aSecondaryUnits) override
Get the pair or units in current use.
SEARCH_PANE * m_searchPane
static const wxString DesignBlocksPaneName()
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
void SetFocus() override
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition eda_text.h:80
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:105
An abstract base class for deriving all objects that can be added to a VIEW.
Definition view_item.h:86
void UpdateAllItemsConditionally(int aUpdateFlags, std::function< bool(VIEW_ITEM *)> aCondition)
Update items in the view according to the given flags and condition.
Definition view.cpp:1586
static wxBitmapBundle CreateLayerPairIcon(const COLOR4D &aTopColor, const COLOR4D &aBottomColor, int aDefSize=24)
Create a layer pair "side-by-side swatch" icon.
AUI_PANELS m_AuiPanels
static TOOL_ACTION lineModeFree
Unconstrained angle mode (icon lines_any)
static TOOL_ACTION drawRuleArea
static TOOL_ACTION drawBezier
static TOOL_ACTION placeText
static TOOL_ACTION drawOrthogonalDimension
static TOOL_ACTION drawRectangle
static TOOL_ACTION padDisplayMode
static TOOL_ACTION placeReferenceImage
static TOOL_ACTION routerSettingsDialog
Activation of the Push and Shove settings dialogs.
static TOOL_ACTION showRatsnest
static TOOL_ACTION zoneFillAll
static TOOL_ACTION showLayersManager
static TOOL_ACTION toggleNetHighlight
static TOOL_ACTION drawCircle
static TOOL_ACTION mirrorH
Mirroring of selected items.
static TOOL_ACTION routeDiffPair
Activation of the Push and Shove router (differential pair mode)
static TOOL_ACTION tuneDiffPair
static TOOL_ACTION autoTrackWidth
static TOOL_ACTION drawTable
static TOOL_ACTION drawTextBox
static TOOL_ACTION routerHighlightMode
Actions to enable switching modes via hotkey assignments.
static TOOL_ACTION routerWalkaroundMode
static TOOL_ACTION routerShoveMode
static TOOL_ACTION drawPolygon
static TOOL_ACTION zoneDisplayFilled
static TOOL_ACTION drawRadialDimension
static TOOL_ACTION tuneSingleTrack
static TOOL_ACTION viaDisplayMode
static TOOL_ACTION drawLeader
static TOOL_ACTION lineMode45
45-degree-or-orthogonal mode (icon hv45mode)
static TOOL_ACTION drillOrigin
static TOOL_ACTION tuneSkew
static TOOL_ACTION trackDisplayMode
static TOOL_ACTION selectLayerPair
static TOOL_ACTION zoneDisplayTriangulated
static TOOL_ACTION zoneDisplayFractured
static TOOL_ACTION drawVia
static TOOL_ACTION drawArc
static TOOL_ACTION runDRC
static TOOL_ACTION importNetlist
static TOOL_ACTION boardSetup
static TOOL_ACTION showEeschema
static TOOL_ACTION drawCenterDimension
static TOOL_ACTION zoneUnfillAll
static TOOL_ACTION lineMode90
90-degree-only mode (icon lines90)
static TOOL_ACTION zoneDisplayOutline
static TOOL_ACTION ratsnestLineMode
static TOOL_ACTION placeBarcode
static TOOL_ACTION placePoint
static TOOL_ACTION mirrorV
static TOOL_ACTION unlock
static TOOL_ACTION placeFootprint
static TOOL_ACTION routeSingleTrack
Activation of the Push and Shove router.
static TOOL_ACTION showPythonConsole
static TOOL_ACTION drawLine
static TOOL_ACTION localRatsnestTool
static TOOL_ACTION rotateCw
Rotation of selected objects.
static TOOL_ACTION rotateCcw
static TOOL_ACTION drawAlignedDimension
static TOOL_ACTION drawZone
static TOOL_ACTION lock
static ACTION_TOOLBAR_CONTROL trackWidth
static ACTION_TOOLBAR_CONTROL viaDiameter
static ACTION_TOOLBAR_CONTROL currentVariant
COLOR_SETTINGS * GetColorSettings(bool aForceRefresh=false) const override
Helper to retrieve the current color settings.
PCB_LAYER_BOX_SELECTOR * m_SelLayerBox
void configureToolbars() override
void ClearToolbarControl(int aId) override
APPEARANCE_CONTROLS * m_appearancePanel
PCBNEW_SETTINGS * GetPcbNewSettings() const
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
BOARD * GetBoard() const
virtual BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Return the BOARD_DESIGN_SETTINGS for the open project.
virtual void Update3DView(bool aMarkDirty, bool aRefresh, const wxString *aTitle=nullptr)
Update the 3D view, if the viewer is opened by this frame.
virtual KIGFX::PCB_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
void OnUpdateSelectTrackWidth(wxUpdateUIEvent &aEvent)
void UpdateVariantSelectionCtrl()
Update the variant selection dropdown with the current board's variant names.
void UpdateTrackWidthSelectBox(wxChoice *aTrackWidthSelectBox, bool aShowNetclass, bool aShowEdit)
void UpdateViaSizeSelectBox(wxChoice *aViaSizeSelectBox, bool aShowNetclass, bool aShowEdit)
LAYER_TOOLBAR_ICON_VALUES m_prevIconVal
void ClearToolbarControl(int aId) override
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...
void PrepareLayerIndicator(bool aForceRebuild=false)
wxChoice * m_CurrentVariantCtrl
void addActionPluginTools(ACTION_TOOLBAR *aToolbar)
Append action plugin buttons to given toolbar.
PLUGIN_ACTION_SCOPE PluginActionScope() const override
void ToggleLibraryTree() override
void OnUpdateSelectViaSize(wxUpdateUIEvent &aEvent)
wxChoice * m_SelViaSizeBox
void onVariantSelected(wxCommandEvent &aEvent)
Event handler for variant selection changes in the toolbar.
void configureToolbars() override
PCB_DESIGN_BLOCK_PANE * m_designBlocksPane
static const wxString SearchPaneName()
wxChoice * m_SelTrackWidthBox
std::optional< TOOLBAR_CONFIGURATION > DefaultToolbarConfig(TOOLBAR_LOC aToolbar) override
Get the default tools to show on the specified canvas toolbar.
The selection tool: currently supports:
virtual COMMON_SETTINGS * GetCommonSettings() const
Definition pgm_base.cpp:541
TOOL_MANAGER * m_toolManager
Master controller class:
#define _(s)
EDA_UNITS
Definition eda_units.h:48
@ FRAME_PCB_EDITOR
Definition frame_type.h:42
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)
Convert aValue in internal units to the appropriate user units defined by aUnit.
KICOMMON_API wxString GetText(EDA_UNITS aUnits, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
Get the units string for a given units type.
KICOMMON_API bool IsImperialUnit(EDA_UNITS aUnit)
Definition eda_units.cpp:47
@ REPAINT
Item needs to be redrawn.
Definition view_item.h:58
@ GEOMETRY
Position or shape has changed.
Definition view_item.h:55
@ ID_AUX_TOOLBAR_PCB_VARIANT_SELECT
Definition pcbnew_id.h:19
@ ID_AUX_TOOLBAR_PCB_VIA_SIZE
Definition pcbnew_id.h:17
@ ID_AUX_TOOLBAR_PCB_TRACK_WIDTH
Definition pcbnew_id.h:18
int GetUserUnits()
Return the currently selected user unit value for the interface.
PGM_BASE & Pgm()
The global program "get" accessor.
see class PGM_BASE
Container to handle a stock of specific vias each with unique diameter and drill sizes in the BOARD c...
@ RIGHT
Toolbar on the right side of the canvas.
@ LEFT
Toolbar on the left side of the canvas.
@ TOP_AUX
Toolbar on the top of the canvas.
@ TOP_MAIN
Toolbar on the top of the canvas.
static wxBitmapBundle LayerPairBitmap
static wxString ComboBoxUnits(EDA_UNITS aUnits, double aValue, bool aIncludeLabel=true)
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.