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 <kiface_base.h>
36#include <kiplatform/ui.h>
37#include <macros.h>
38#include <pcb_edit_frame.h>
40#include <pcbnew_id.h>
41#include <pcbnew_settings.h>
42#include <pgm_base.h>
44#include <router/router_tool.h>
46#include <tool/action_menu.h>
47#include <tool/action_toolbar.h>
48#include <tool/actions.h>
49#include <tool/common_tools.h>
50#include <tool/tool_manager.h>
52#include <tools/pcb_actions.h>
62#include <wx/wupdlock.h>
63#include <wx/combobox.h>
64#include <toolbars_pcb_editor.h>
66
67#include "../scripting/python_scripting.h"
68
69
70/* Data to build the layer pair indicator button */
71static wxBitmapBundle LayerPairBitmap;
72
73
74void PCB_EDIT_FRAME::PrepareLayerIndicator( bool aForceRebuild )
75{
76 COLOR4D top_color, bottom_color, background_color;
77 bool change = aForceRebuild;
78
80
81 if( m_prevIconVal.previous_icon_size != icon_size )
82 {
83 m_prevIconVal.previous_icon_size = icon_size;
84 change = true;
85 }
86
87 top_color = GetColorSettings()->GetColor( GetScreen()->m_Route_Layer_TOP );
88
89 if( m_prevIconVal.previous_Route_Layer_TOP_color != top_color )
90 {
91 m_prevIconVal.previous_Route_Layer_TOP_color = top_color;
92 change = true;
93 }
94
95 bottom_color = GetColorSettings()->GetColor( GetScreen()->m_Route_Layer_BOTTOM );
96
97 if( m_prevIconVal.previous_Route_Layer_BOTTOM_color != bottom_color )
98 {
99 m_prevIconVal.previous_Route_Layer_BOTTOM_color = bottom_color;
100 change = true;
101 }
102
103 if( change || !LayerPairBitmap.IsOk() )
104 {
105 LayerPairBitmap = LAYER_PRESENTATION::CreateLayerPairIcon( top_color, bottom_color, icon_size );
106
107 if( m_tbTopAux )
108 {
110 m_tbTopAux->Refresh();
111 }
112 }
113}
114
115
117 _( "Track width selector" ),
118 _( "Control to select the track width" ),
119 { FRAME_PCB_EDITOR } );
121 _( "Via diameter selector" ),
122 _( "Control to select the via diameter" ),
123 { FRAME_PCB_EDITOR } );
125 _( "Current variant" ),
126 _( "Control to select the current variant" ),
127 { FRAME_PCB_EDITOR } );
128
129
130std::optional<TOOLBAR_CONFIGURATION> PCB_EDIT_TOOLBAR_SETTINGS::DefaultToolbarConfig( TOOLBAR_LOC aToolbar )
131{
133
134 // clang-format off
135 switch( aToolbar )
136 {
138 config.AppendAction( ACTIONS::toggleGrid )
139 .WithContextMenu(
140 []( TOOL_MANAGER* aMgr ) -> std::unique_ptr<ACTION_MENU>
141 {
143 std::unique_ptr<ACTION_MENU> menu =
144 std::make_unique<ACTION_MENU>( false, selTool );
145
146 menu->Add( ACTIONS::gridProperties );
147 menu->Add( ACTIONS::gridOrigin );
148
149 return menu;
150 } )
151 .AppendAction( ACTIONS::toggleGridOverrides )
152 .AppendAction( PCB_ACTIONS::togglePolarCoords )
153 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Units" ) )
154 .AddAction( ACTIONS::millimetersUnits )
155 .AddAction( ACTIONS::inchesUnits )
156 .AddAction( ACTIONS::milsUnits ) )
157 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Crosshair modes" ) )
160 .AddAction( ACTIONS::cursor45Crosshairs ) );
161
162 config.AppendSeparator()
163 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Line modes" ) )
164 .AddAction( PCB_ACTIONS::lineModeFree )
165 .AddAction( PCB_ACTIONS::lineMode90 )
166 .AddAction( PCB_ACTIONS::lineMode45 ) );
167
168 config.AppendSeparator()
169 .AppendAction( PCB_ACTIONS::showRatsnest )
170 .AppendAction( PCB_ACTIONS::ratsnestLineMode );
171
172 config.AppendSeparator()
173 .AppendAction( ACTIONS::highContrastMode )
174 .AppendAction( PCB_ACTIONS::toggleNetHighlight );
175
176 config.AppendSeparator()
177 .AppendAction( PCB_ACTIONS::zoneDisplayFilled )
178 .AppendAction( PCB_ACTIONS::zoneDisplayOutline );
179
180 if( ADVANCED_CFG::GetCfg().m_ExtraZoneDisplayModes )
181 {
184 }
185
186 config.AppendSeparator()
187 .AppendAction( PCB_ACTIONS::padDisplayMode )
188 .AppendAction( PCB_ACTIONS::viaDisplayMode )
189 .AppendAction( PCB_ACTIONS::trackDisplayMode );
190
191 if( ADVANCED_CFG::GetCfg().m_DrawBoundingBoxes )
192 config.AppendAction( ACTIONS::toggleBoundingBoxes );
193
194 // Tools to show/hide toolbars:
195 config.AppendSeparator()
196 .AppendAction( PCB_ACTIONS::showLayersManager )
197 .AppendAction( ACTIONS::showProperties );
198
199 break;
200
202 config.AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Selection modes" ) )
203 .AddAction( ACTIONS::selectSetRect )
204 .AddAction( ACTIONS::selectSetLasso ) )
205 .AppendAction( PCB_ACTIONS::localRatsnestTool );
206
207 config.AppendSeparator()
208 .AppendAction( PCB_ACTIONS::placeFootprint )
209 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Track routing tools" ) )
211 .AddAction( PCB_ACTIONS::routeDiffPair )
212 .AddContextMenu(
213 []( TOOL_MANAGER* aMgr ) -> std::unique_ptr<ACTION_MENU>
214 {
216 std::unique_ptr<ACTION_MENU> menu =
217 std::make_unique<ACTION_MENU>( false, selTool );
218
222 menu->AppendSeparator();
224
225 return menu;
226 } ) )
227 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Track tuning tools" ) )
228 .AddAction( PCB_ACTIONS::tuneSingleTrack )
229 .AddAction( PCB_ACTIONS::tuneDiffPair )
230 .AddAction( PCB_ACTIONS::tuneSkew ) )
231 .AppendAction( PCB_ACTIONS::drawVia )
232 .AppendAction( PCB_ACTIONS::drawZone )
233 .WithContextMenu(
234 []( TOOL_MANAGER* aMgr ) -> std::unique_ptr<ACTION_MENU>
235 {
237 std::unique_ptr<ACTION_MENU> menu =
238 std::make_unique<ACTION_MENU>( false, selTool );
239
240 menu->Add( PCB_ACTIONS::zoneFillAll );
241 menu->Add( PCB_ACTIONS::zoneUnfillAll );
242
243 return menu;
244 } )
245 .AppendAction( PCB_ACTIONS::drawRuleArea );
246
247 config.AppendSeparator()
248 .AppendAction( PCB_ACTIONS::drawLine )
249 .AppendAction( PCB_ACTIONS::drawArc )
250 .WithContextMenu(
251 []( TOOL_MANAGER* aMgr ) -> std::unique_ptr<ACTION_MENU>
252 {
254 std::unique_ptr<ACTION_MENU> menu =
255 std::make_unique<ACTION_MENU>( false, selTool );
256
260
261 return menu;
262 } )
263 .AppendAction( PCB_ACTIONS::drawRectangle )
264 .AppendAction( PCB_ACTIONS::drawCircle )
265 .AppendAction( PCB_ACTIONS::drawPolygon )
266 .AppendAction( PCB_ACTIONS::drawBezier )
267 .AppendAction( PCB_ACTIONS::placeReferenceImage )
268 .AppendAction( PCB_ACTIONS::placeText )
269 .AppendAction( PCB_ACTIONS::drawTextBox )
270 .AppendAction( PCB_ACTIONS::drawTable )
271 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Dimension objects" ) )
276 .AddAction( PCB_ACTIONS::drawLeader ) )
277 .AppendAction( PCB_ACTIONS::placeBarcode )
278 .AppendAction( ACTIONS::deleteTool );
279
280 config.AppendSeparator()
281 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "PCB origins and points" ) )
282 .AddAction( ACTIONS::gridSetOrigin )
283 .AddAction( PCB_ACTIONS::drillOrigin ) )
284 .AppendAction( PCB_ACTIONS::placePoint )
285 .AppendAction( ACTIONS::measureTool );
286
287 break;
288
290 if( Kiface().IsSingle() )
291 {
292 config.AppendAction( ACTIONS::doNew );
293 config.AppendAction( ACTIONS::open );
294 }
295
296 config.AppendAction( ACTIONS::save );
297
298 config.AppendSeparator()
299 .AppendAction( PCB_ACTIONS::boardSetup );
300
301 config.AppendSeparator()
302 .AppendAction( ACTIONS::pageSettings )
303 .AppendAction( ACTIONS::print )
304 .AppendAction( ACTIONS::plot );
305
306 config.AppendSeparator()
307 .AppendAction( ACTIONS::undo )
308 .AppendAction( ACTIONS::redo );
309
310 config.AppendSeparator()
311 .AppendAction( ACTIONS::find );
312
313 config.AppendSeparator()
314 .AppendAction( ACTIONS::zoomRedraw )
315 .AppendAction( ACTIONS::zoomInCenter )
316 .AppendAction( ACTIONS::zoomOutCenter )
317 .AppendAction( ACTIONS::zoomFitScreen )
318 .AppendAction( ACTIONS::zoomFitObjects )
319 .AppendAction( ACTIONS::zoomTool );
320
321 config.AppendSeparator()
322 .AppendAction( PCB_ACTIONS::rotateCcw )
323 .AppendAction( PCB_ACTIONS::rotateCw )
324 .AppendAction( PCB_ACTIONS::mirrorV )
325 .AppendAction( PCB_ACTIONS::mirrorH )
326 .AppendAction( ACTIONS::group )
327 .AppendAction( ACTIONS::ungroup )
328 .AppendAction( PCB_ACTIONS::lock )
329 .AppendAction( PCB_ACTIONS::unlock );
330
331 config.AppendSeparator()
332 .AppendAction( ACTIONS::showFootprintEditor )
333 .AppendAction( ACTIONS::showFootprintBrowser )
334 .AppendAction( ACTIONS::show3DViewer );
335
336 config.AppendSeparator();
337
338 if( !Kiface().IsSingle() )
340 else
341 config.AppendAction( PCB_ACTIONS::importNetlist );
342
343 config.AppendAction( PCB_ACTIONS::runDRC );
344
345 config.AppendSeparator();
346 config.AppendAction( PCB_ACTIONS::showEeschema );
349
350 break;
351
354 .AppendAction( PCB_ACTIONS::autoTrackWidth );
355
356 config.AppendSeparator()
358
359 config.AppendSeparator()
361 .AppendAction( PCB_ACTIONS::selectLayerPair );
362
363 config.AppendSeparator()
364 .AppendControl( ACTION_TOOLBAR_CONTROLS::gridSelect );
365
366 config.AppendSeparator()
367 .AppendControl( ACTION_TOOLBAR_CONTROLS::zoomSelect );
368
369 config.AppendSeparator()
371
372 break;
373 }
374
375 // clang-format on
376 return config;
377}
378
379
381{
383
384 // Box to display and choose track widths
385 auto trackWidthSelectorFactory =
386 [this]( ACTION_TOOLBAR* aToolbar )
387 {
388 if( !m_SelTrackWidthBox )
389 {
390 m_SelTrackWidthBox = new wxChoice( aToolbar, ID_AUX_TOOLBAR_PCB_TRACK_WIDTH,
391 wxDefaultPosition, wxDefaultSize, 0, nullptr );
392 }
393
394 m_SelTrackWidthBox->SetToolTip( _( "Select the default width for new tracks. Note that this "
395 "width can be overridden by the board minimum width, or by "
396 "the width of an existing track if the 'Use Existing Track "
397 "Width' feature is enabled." ) );
398
400
401 aToolbar->Add( m_SelTrackWidthBox );
402 };
403
405
406
407 // Box to display and choose vias diameters
408 auto viaDiaSelectorFactory =
409 [this]( ACTION_TOOLBAR* aToolbar )
410 {
411 if( !m_SelViaSizeBox )
412 {
413 m_SelViaSizeBox = new wxChoice( aToolbar, ID_AUX_TOOLBAR_PCB_VIA_SIZE,
414 wxDefaultPosition, wxDefaultSize, 0, nullptr );
415 }
416
418 aToolbar->Add( m_SelViaSizeBox );
419 };
420
422
423 // Variant selection drop down control on main tool bar
424 auto variantSelectionCtrlFactory =
425 [this]( ACTION_TOOLBAR* aToolbar )
426 {
428 {
430 wxDefaultPosition, wxDefaultSize, 0, nullptr );
431 }
432
433 m_currentVariantCtrl->SetToolTip( _( "Select the current variant to display and edit." ) );
434
436
437 aToolbar->Add( m_currentVariantCtrl );
438 };
439
441
442 // IPC/Scripting plugin control
443 // TODO (ISM): Clean this up to make IPC actions just normal tool actions to get rid of this entire
444 // control
445 auto pluginControlFactory =
446 [this]( ACTION_TOOLBAR* aToolbar )
447 {
448 // Add scripting console and API plugins
449 bool scriptingAvailable = SCRIPTING::IsWxAvailable();
450
451#ifdef KICAD_IPC_API
452 bool haveApiPlugins = Pgm().GetCommonSettings()->m_Api.enable_server
453 && !Pgm().GetPluginManager().GetActionsForScope( PluginActionScope() ).empty();
454#else
455 bool haveApiPlugins = false;
456#endif
457
458 if( scriptingAvailable || haveApiPlugins )
459 {
460 aToolbar->AddScaledSeparator( aToolbar->GetParent() );
461
462 if( scriptingAvailable )
463 {
464 aToolbar->Add( PCB_ACTIONS::showPythonConsole );
465 addActionPluginTools( aToolbar );
466 }
467
468 if( haveApiPlugins )
469 AddApiPluginTools( aToolbar );
470 }
471 };
472
474}
475
476
478{
480
481 switch( aId )
482 {
484 case ID_AUX_TOOLBAR_PCB_VIA_SIZE: m_SelViaSizeBox = nullptr; break;
486 }
487}
488
489
491{
493 return;
494
495 if( !GetBoard() )
496 return;
497
498 wxArrayString variantNames = GetBoard()->GetVariantNamesForUI();
499
500 m_currentVariantCtrl->Set( variantNames );
501
502 int selectionIndex = 0;
503 wxString currentVariant = GetBoard()->GetCurrentVariant();
504
505 if( !currentVariant.IsEmpty() )
506 {
507 int foundIndex = m_currentVariantCtrl->FindString( currentVariant );
508
509 if( foundIndex != wxNOT_FOUND )
510 selectionIndex = foundIndex;
511 }
512
513 if( m_currentVariantCtrl->GetCount() > 0 )
514 m_currentVariantCtrl->SetSelection( selectionIndex );
515}
516
517
518void PCB_EDIT_FRAME::onVariantSelected( wxCommandEvent& aEvent )
519{
521 return;
522
523 int selection = m_currentVariantCtrl->GetSelection();
524
525 if( selection == wxNOT_FOUND || selection == 0 )
526 {
527 // "<Default>" selected - clear the current variant
528 GetBoard()->SetCurrentVariant( wxEmptyString );
529 }
530 else
531 {
532 wxString selectedVariant = m_currentVariantCtrl->GetString( selection );
533 GetBoard()->SetCurrentVariant( selectedVariant );
534 }
535
536 // Refresh the view and properties panel to show the new variant state
538 GetCanvas()->Refresh();
539}
540
541
542static wxString ComboBoxUnits( EDA_UNITS aUnits, double aValue, bool aIncludeLabel = true )
543{
544 wxString text;
545 const wxChar* format;
546
547 switch( aUnits )
548 {
549 default:
550 wxASSERT_MSG( false, wxT( "Invalid unit" ) );
552 case EDA_UNITS::UNSCALED: format = wxT( "%.0f" ); break;
553 case EDA_UNITS::MM: format = wxT( "%.3f" ); break;
554 case EDA_UNITS::MILS: format = wxT( "%.2f" ); break;
555 case EDA_UNITS::INCH: format = wxT( "%.5f" ); break;
556 }
557
558 text.Printf( format, EDA_UNIT_UTILS::UI::ToUserUnit( pcbIUScale, aUnits, aValue ) );
559
560 if( aIncludeLabel )
562
563 return text;
564}
565
566
567void PCB_EDIT_FRAME::UpdateTrackWidthSelectBox( wxChoice* aTrackWidthSelectBox, bool aShowNetclass,
568 bool aShowEdit )
569{
570 if( aTrackWidthSelectBox == nullptr )
571 return;
572
573 EDA_UNITS primaryUnit;
574 EDA_UNITS secondaryUnit;
575
576 GetUnitPair( primaryUnit, secondaryUnit );
577
578 wxString msg;
579
580 aTrackWidthSelectBox->Clear();
581
582 if( aShowNetclass )
583 aTrackWidthSelectBox->Append( _( "Track: use netclass width" ) );
584
585 for( unsigned ii = 1; ii < GetDesignSettings().m_TrackWidthList.size(); ii++ )
586 {
587 int size = GetDesignSettings().m_TrackWidthList[ii];
588
589 msg.Printf( _( "Track: %s (%s)" ), ComboBoxUnits( primaryUnit, size ),
590 ComboBoxUnits( secondaryUnit, size ) );
591
592 aTrackWidthSelectBox->Append( msg );
593 }
594
595 if( aShowEdit )
596 {
597 aTrackWidthSelectBox->Append( wxT( "---" ) );
598 aTrackWidthSelectBox->Append( _( "Edit Pre-defined Sizes..." ) );
599 }
600
601 if( GetDesignSettings().GetTrackWidthIndex() >= (int) GetDesignSettings().m_TrackWidthList.size() )
603
604 // GetDesignSettings().GetTrackWidthIndex() can be < 0 if no board loaded
605 // So in this case select the first select box item available (use netclass)
606 aTrackWidthSelectBox->SetSelection( std::max( 0, GetDesignSettings().GetTrackWidthIndex() ) );
607}
608
609
610void PCB_EDIT_FRAME::UpdateViaSizeSelectBox( wxChoice* aViaSizeSelectBox, bool aShowNetclass,
611 bool aShowEdit )
612{
613 if( aViaSizeSelectBox == nullptr )
614 return;
615
616 aViaSizeSelectBox->Clear();
617
618 COMMON_TOOLS* cmnTool = m_toolManager->GetTool<COMMON_TOOLS>();
619 EDA_UNITS primaryUnit = GetUserUnits();
620 EDA_UNITS secondaryUnit = EDA_UNITS::MILS;
621
622 if( EDA_UNIT_UTILS::IsImperialUnit( primaryUnit ) )
623 secondaryUnit = cmnTool ? cmnTool->GetLastMetricUnits() : EDA_UNITS::MM;
624 else
625 secondaryUnit = cmnTool ? cmnTool->GetLastImperialUnits() : EDA_UNITS::MILS;
626
627 if( aShowNetclass )
628 aViaSizeSelectBox->Append( _( "Via: use netclass sizes" ) );
629
630 for( unsigned ii = 1; ii < GetDesignSettings().m_ViasDimensionsList.size(); ii++ )
631 {
633 wxString msg, priStr, secStr;
634
635 double diam = viaDimension.m_Diameter;
636 double hole = viaDimension.m_Drill;
637
638 if( hole > 0 )
639 {
640 priStr = ComboBoxUnits( primaryUnit, diam, false ) + wxT( " / " )
641 + ComboBoxUnits( primaryUnit, hole, true );
642 secStr = ComboBoxUnits( secondaryUnit, diam, false ) + wxT( " / " )
643 + ComboBoxUnits( secondaryUnit, hole, true );
644 }
645 else
646 {
647 priStr = ComboBoxUnits( primaryUnit, diam, true );
648 secStr = ComboBoxUnits( secondaryUnit, diam, true );
649 }
650
651 msg.Printf( _( "Via: %s (%s)" ), priStr, secStr );
652
653 aViaSizeSelectBox->Append( msg );
654 }
655
656 if( aShowEdit )
657 {
658 aViaSizeSelectBox->Append( wxT( "---" ) );
659 aViaSizeSelectBox->Append( _( "Edit Pre-defined Sizes..." ) );
660 }
661
662 if( GetDesignSettings().GetViaSizeIndex() >= (int) GetDesignSettings().m_ViasDimensionsList.size() )
664
665 // GetDesignSettings().GetViaSizeIndex() can be < 0 if no board loaded
666 // So in this case select the first select box item available (use netclass)
667 aViaSizeSelectBox->SetSelection( std::max( 0, GetDesignSettings().GetViaSizeIndex() ) );
668}
669
670
671void PCB_EDIT_FRAME::ReCreateLayerBox( bool aForceResizeToolbar )
672{
673 if( m_SelLayerBox == nullptr || m_tbTopAux == nullptr )
674 return;
675
676 m_SelLayerBox->SetToolTip( _( "+/- to switch" ) );
677 m_SelLayerBox->Resync();
678
679 if( aForceResizeToolbar )
681}
682
683
685{
687 wxAuiPaneInfo& layersManager = m_auimgr.GetPane( AppearancePanelName() );
688 wxAuiPaneInfo& selectionFilter = m_auimgr.GetPane( "SelectionFilter" );
689
690 // show auxiliary Vertical layers and visibility manager toolbar
691 m_show_layer_manager_tools = layersManager.IsShown();
692
694
695 layersManager.Show( m_show_layer_manager_tools );
696 selectionFilter.Show( m_show_layer_manager_tools );
697
699 {
700 SetAuiPaneSize( m_auimgr, layersManager, settings->m_AuiPanels.right_panel_width, -1 );
701 }
702 else
703 {
704 settings->m_AuiPanels.right_panel_width = m_appearancePanel->GetSize().x;
705 m_auimgr.Update();
706 }
707}
708
709
711{
713 wxAuiPaneInfo& netInspectorPanel = m_auimgr.GetPane( NetInspectorPanelName() );
714
715 m_show_net_inspector = netInspectorPanel.IsShown();
716
718
719 netInspectorPanel.Show( m_show_net_inspector );
720
722 {
723 SetAuiPaneSize( m_auimgr, netInspectorPanel, settings->m_AuiPanels.net_inspector_width, -1 );
724 m_netInspectorPanel->OnShowPanel();
725 }
726 else
727 {
728 m_netInspectorPanel->SaveSettings();
729 settings->m_AuiPanels.net_inspector_width = m_netInspectorPanel->GetSize().x;
730 m_auimgr.Update();
731 }
732}
733
734
736{
738
739 // Ensure m_show_search is up to date (the pane can be closed outside the menu)
740 m_show_search = m_auimgr.GetPane( SearchPaneName() ).IsShown();
741
743
744 wxAuiPaneInfo& searchPaneInfo = m_auimgr.GetPane( SearchPaneName() );
745 searchPaneInfo.Show( m_show_search );
746
747 if( m_show_search )
748 {
749 searchPaneInfo.Direction( settings->m_AuiPanels.search_panel_dock_direction );
750
751 if( settings->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_TOP
752 || settings->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_BOTTOM )
753 {
754 SetAuiPaneSize( m_auimgr, searchPaneInfo,
755 -1, settings->m_AuiPanels.search_panel_height );
756 }
757 else if( settings->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_LEFT
758 || settings->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_RIGHT )
759 {
760 SetAuiPaneSize( m_auimgr, searchPaneInfo,
761 settings->m_AuiPanels.search_panel_width, -1 );
762 }
763 m_searchPane->FocusSearch();
764 m_searchPane->RefreshSearch();
765 }
766 else
767 {
768 settings->m_AuiPanels.search_panel_height = m_searchPane->GetSize().y;
769 settings->m_AuiPanels.search_panel_width = m_searchPane->GetSize().x;
770 settings->m_AuiPanels.search_panel_dock_direction = searchPaneInfo.dock_direction;
771 m_auimgr.Update();
772 GetCanvas()->SetFocus();
773 }
774}
775
776
777void PCB_EDIT_FRAME::OnUpdateSelectTrackWidth( wxUpdateUIEvent& aEvent )
778{
779 if( aEvent.GetId() == ID_AUX_TOOLBAR_PCB_TRACK_WIDTH )
780 {
782 int sel;
783
784 if( bds.UseCustomTrackViaSize() )
785 sel = wxNOT_FOUND;
786 else
787 // if GetTrackWidthIndex() < 0, display the "use netclass" option
788 sel = std::max( 0, bds.GetTrackWidthIndex() );
789
790 if( m_SelTrackWidthBox->GetSelection() != sel )
791 m_SelTrackWidthBox->SetSelection( sel );
792 }
793}
794
795
796void PCB_EDIT_FRAME::OnUpdateSelectViaSize( wxUpdateUIEvent& aEvent )
797{
798 if( aEvent.GetId() == ID_AUX_TOOLBAR_PCB_VIA_SIZE )
799 {
801 int sel = 0;
802
803 if( bds.UseCustomTrackViaSize() )
804 sel = wxNOT_FOUND;
805 else
806 // if GetViaSizeIndex() < 0, display the "use netclass" option
807 sel = std::max( 0, bds.GetViaSizeIndex() );
808
809 if( m_SelViaSizeBox->GetSelection() != sel )
810 m_SelViaSizeBox->SetSelection( sel );
811 }
812}
813
814
816{
818
819 wxCHECK( cfg, /* void */ );
820
821 wxAuiPaneInfo& db_library_pane = m_auimgr.GetPane( DesignBlocksPaneName() );
822
823 db_library_pane.Show( !db_library_pane.IsShown() );
824
825 if( db_library_pane.IsShown() )
826 {
827 if( db_library_pane.IsFloating() )
828 {
829 db_library_pane.FloatingSize( cfg->m_AuiPanels.design_blocks_panel_float_width,
831 m_auimgr.Update();
832 }
834 {
835 // SetAuiPaneSize also updates m_auimgr
837 }
838 }
839 else
840 {
841 if( db_library_pane.IsFloating() )
842 {
843 cfg->m_AuiPanels.design_blocks_panel_float_width = db_library_pane.floating_size.x;
844 cfg->m_AuiPanels.design_blocks_panel_float_height = db_library_pane.floating_size.y;
845 }
846 else
847 {
849 }
850
851 m_auimgr.Update();
852 }
853}
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
void SetCurrentVariant(const wxString &aVariant)
Definition board.cpp:2502
wxArrayString GetVariantNamesForUI() const
Return the variant names for UI display.
Definition board.cpp:2648
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 color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:105
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.
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...
bool m_show_layer_manager_tools
void PrepareLayerIndicator(bool aForceRebuild=false)
void addActionPluginTools(ACTION_TOOLBAR *aToolbar)
Append action plugin buttons to given toolbar.
PLUGIN_ACTION_SCOPE PluginActionScope() const override
void ToggleLibraryTree() override
wxChoice * m_currentVariantCtrl
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:535
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
@ 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.