KiCad PCB EDA Suite
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
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 <dick@softplc.com>
6 * Copyright (C) 2012 Wayne Stambaugh <stambaughw@gmail.com>
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_toolbar.h>
47#include <tool/actions.h>
48#include <tool/common_tools.h>
49#include <tool/tool_manager.h>
50#include <tools/pcb_actions.h>
60#include <wx/wupdlock.h>
61#include <wx/combobox.h>
62#include <toolbars_pcb_editor.h>
64
65#include "../scripting/python_scripting.h"
66
67
68/* Data to build the layer pair indicator button */
69static std::unique_ptr<wxBitmap> LayerPairBitmap;
70
71
72void PCB_EDIT_FRAME::PrepareLayerIndicator( bool aForceRebuild )
73{
74 COLOR4D top_color, bottom_color, background_color;
75 bool change = aForceRebuild;
76
77 int requested_scale = KiIconScale( this );
78
79 if( m_prevIconVal.previous_requested_scale != requested_scale )
80 {
82 change = true;
83 }
84
85 top_color = GetColorSettings()->GetColor( GetScreen()->m_Route_Layer_TOP );
86
88 {
90 change = true;
91 }
92
93 bottom_color = GetColorSettings()->GetColor( GetScreen()->m_Route_Layer_BOTTOM );
94
96 {
98 change = true;
99 }
100
101 background_color = GetColorSettings()->GetColor( LAYER_PCB_BACKGROUND );
102
103 if( m_prevIconVal.previous_background_color != background_color )
104 {
105 m_prevIconVal.previous_background_color = background_color;
106 change = true;
107 }
108
109 if( change || !LayerPairBitmap )
110 {
111 const int scale = ( requested_scale <= 0 ) ? KiIconScale( this ) : requested_scale;
112 LayerPairBitmap = LAYER_PRESENTATION::CreateLayerPairIcon( background_color, top_color,
113 bottom_color, scale );
114
115 if( m_tbTopAux )
116 {
118 m_tbTopAux->Refresh();
119 }
120 }
121}
122
123
124ACTION_TOOLBAR_CONTROL PCB_ACTION_TOOLBAR_CONTROLS::trackWidth( "control.PCBTrackWidth", _( "Track width selector" ),
125 _( "Control to select the track width" ) );
126ACTION_TOOLBAR_CONTROL PCB_ACTION_TOOLBAR_CONTROLS::viaDiameter( "control.PCBViaDia", _( "Via diameter selector" ),
127 _( "Control to select the via diameter" ) );
128
129
130std::optional<TOOLBAR_CONFIGURATION> PCB_EDIT_TOOLBAR_SETTINGS::DefaultToolbarConfig( TOOLBAR_LOC aToolbar )
131{
133
134 // clang-format off
135 switch( aToolbar )
136 {
137 case TOOLBAR_LOC::LEFT:
138 config.AppendAction( ACTIONS::toggleGrid )
139 .AppendAction( ACTIONS::toggleGridOverrides )
140 .AppendAction( PCB_ACTIONS::togglePolarCoords )
141 .AppendAction( ACTIONS::inchesUnits )
142 .AppendAction( ACTIONS::milsUnits )
143 .AppendAction( ACTIONS::millimetersUnits )
144 .AppendAction( ACTIONS::toggleCursorStyle );
145
146 config.AppendSeparator()
147 .AppendAction( PCB_ACTIONS::toggleHV45Mode );
148
149 config.AppendSeparator()
150 .AppendAction( PCB_ACTIONS::showRatsnest )
151 .AppendAction( PCB_ACTIONS::ratsnestLineMode );
152
153 config.AppendSeparator()
154 .AppendAction( ACTIONS::highContrastMode )
155 .AppendAction( PCB_ACTIONS::toggleNetHighlight );
156
157 config.AppendSeparator()
158 .AppendAction( PCB_ACTIONS::zoneDisplayFilled )
159 .AppendAction( PCB_ACTIONS::zoneDisplayOutline );
160
161 if( ADVANCED_CFG::GetCfg().m_ExtraZoneDisplayModes )
162 {
165 }
166
167 config.AppendSeparator()
168 .AppendAction( PCB_ACTIONS::padDisplayMode )
169 .AppendAction( PCB_ACTIONS::viaDisplayMode )
170 .AppendAction( PCB_ACTIONS::trackDisplayMode );
171
172 if( ADVANCED_CFG::GetCfg().m_DrawBoundingBoxes )
173 config.AppendAction( ACTIONS::toggleBoundingBoxes );
174
175 // Tools to show/hide toolbars:
176 config.AppendSeparator()
177 .AppendAction( PCB_ACTIONS::showLayersManager )
178 .AppendAction( ACTIONS::showProperties );
179
180 /* TODO (ISM): Support context menus in toolbars
181 PCB_SELECTION_TOOL* selTool = m_toolManager->GetTool<PCB_SELECTION_TOOL>();
182 std::unique_ptr<ACTION_MENU> gridMenu = std::make_unique<ACTION_MENU>( false, selTool );
183 gridMenu->Add( ACTIONS::gridProperties );
184 gridMenu->Add( ACTIONS::gridOrigin );
185 m_tbLeft->AddToolContextMenu( ACTIONS::toggleGrid, std::move( gridMenu ) );
186 */
187 break;
188
189 case TOOLBAR_LOC::RIGHT:
190 config.AppendAction( ACTIONS::selectionTool )
191 .AppendAction( PCB_ACTIONS::localRatsnestTool );
192
193 config.AppendSeparator()
194 .AppendAction( PCB_ACTIONS::placeFootprint )
195 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Track routing tools" ) )
197 .AddAction( PCB_ACTIONS::routeDiffPair ) )
198 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Track tuning tools" ) )
199 .AddAction( PCB_ACTIONS::tuneSingleTrack )
200 .AddAction( PCB_ACTIONS::tuneDiffPair )
201 .AddAction( PCB_ACTIONS::tuneSkew ) )
202 .AppendAction( PCB_ACTIONS::drawVia )
203 .AppendAction( PCB_ACTIONS::drawZone )
204 .AppendAction( PCB_ACTIONS::drawRuleArea );
205
206 config.AppendSeparator()
207 .AppendAction( PCB_ACTIONS::drawLine )
208 .AppendAction( PCB_ACTIONS::drawArc )
209 .AppendAction( PCB_ACTIONS::drawRectangle )
210 .AppendAction( PCB_ACTIONS::drawCircle )
211 .AppendAction( PCB_ACTIONS::drawPolygon )
212 .AppendAction( PCB_ACTIONS::drawBezier )
213 .AppendAction( PCB_ACTIONS::placeReferenceImage )
214 .AppendAction( PCB_ACTIONS::placeText )
215 .AppendAction( PCB_ACTIONS::drawTextBox )
216 .AppendAction( PCB_ACTIONS::drawTable )
217 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Dimension objects" ) )
222 .AddAction( PCB_ACTIONS::drawLeader ) )
223 .AppendAction( ACTIONS::deleteTool );
224
225 config.AppendSeparator()
226 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "PCB origins" ) )
227 .AddAction( ACTIONS::gridSetOrigin )
228 .AddAction( PCB_ACTIONS::drillOrigin ) )
229 .AppendAction( ACTIONS::measureTool );
230
231 /* TODO (ISM): Support context menus
232 PCB_SELECTION_TOOL* selTool = m_toolManager->GetTool<PCB_SELECTION_TOOL>();
233
234 auto makeArcMenu = [&]()
235 {
236 std::unique_ptr<ACTION_MENU> arcMenu = std::make_unique<ACTION_MENU>( false, selTool );
237
238 arcMenu->Add( PCB_ACTIONS::pointEditorArcKeepCenter, ACTION_MENU::CHECK );
239 arcMenu->Add( PCB_ACTIONS::pointEditorArcKeepEndpoint, ACTION_MENU::CHECK );
240
241 return arcMenu;
242 };
243
244 m_tbRight->AddToolContextMenu( PCB_ACTIONS::drawArc, makeArcMenu() );
245
246 auto makeRouteMenu = [&]()
247 {
248 std::unique_ptr<ACTION_MENU> routeMenu = std::make_unique<ACTION_MENU>( false, selTool );
249
250 routeMenu->Add( PCB_ACTIONS::routerHighlightMode, ACTION_MENU::CHECK );
251 routeMenu->Add( PCB_ACTIONS::routerShoveMode, ACTION_MENU::CHECK );
252 routeMenu->Add( PCB_ACTIONS::routerWalkaroundMode, ACTION_MENU::CHECK );
253
254 routeMenu->AppendSeparator();
255 routeMenu->Add( PCB_ACTIONS::routerSettingsDialog );
256
257 return routeMenu;
258 };
259
260 m_tbRight->AddToolContextMenu( PCB_ACTIONS::routeSingleTrack, makeRouteMenu() );
261 m_tbRight->AddToolContextMenu( PCB_ACTIONS::routeDiffPair, makeRouteMenu() );
262
263 std::unique_ptr<ACTION_MENU> zoneMenu = std::make_unique<ACTION_MENU>( false, selTool );
264 zoneMenu->Add( PCB_ACTIONS::zoneFillAll );
265 zoneMenu->Add( PCB_ACTIONS::zoneUnfillAll );
266 m_tbRight->AddToolContextMenu( PCB_ACTIONS::drawZone, std::move( zoneMenu ) );
267
268 std::unique_ptr<ACTION_MENU> lineMenu = std::make_unique<ACTION_MENU>( false, selTool );
269 m_tbRight->AddToolContextMenu( PCB_ACTIONS::drawLine, std::move( lineMenu ) );
270 */
271 break;
272
273 case TOOLBAR_LOC::TOP_MAIN:
274 if( Kiface().IsSingle() )
275 {
276 config.AppendAction( ACTIONS::doNew );
277 config.AppendAction( ACTIONS::open );
278 }
279
280 config.AppendAction( ACTIONS::save );
281
282 config.AppendSeparator()
283 .AppendAction( PCB_ACTIONS::boardSetup );
284
285 config.AppendSeparator()
286 .AppendAction( ACTIONS::pageSettings )
287 .AppendAction( ACTIONS::print )
288 .AppendAction( ACTIONS::plot );
289
290 config.AppendSeparator()
291 .AppendAction( ACTIONS::undo )
292 .AppendAction( ACTIONS::redo );
293
294 config.AppendSeparator()
295 .AppendAction( ACTIONS::find );
296
297 config.AppendSeparator()
298 .AppendAction( ACTIONS::zoomRedraw )
299 .AppendAction( ACTIONS::zoomInCenter )
300 .AppendAction( ACTIONS::zoomOutCenter )
301 .AppendAction( ACTIONS::zoomFitScreen )
302 .AppendAction( ACTIONS::zoomFitObjects )
303 .AppendAction( ACTIONS::zoomTool );
304
305 config.AppendSeparator()
306 .AppendAction( PCB_ACTIONS::rotateCcw )
307 .AppendAction( PCB_ACTIONS::rotateCw )
308 .AppendAction( PCB_ACTIONS::mirrorV )
309 .AppendAction( PCB_ACTIONS::mirrorH )
310 .AppendAction( PCB_ACTIONS::group )
311 .AppendAction( PCB_ACTIONS::ungroup )
312 .AppendAction( PCB_ACTIONS::lock )
313 .AppendAction( PCB_ACTIONS::unlock );
314
315 config.AppendSeparator()
316 .AppendAction( ACTIONS::showFootprintEditor )
317 .AppendAction( ACTIONS::showFootprintBrowser )
318 .AppendAction( ACTIONS::show3DViewer );
319
320 config.AppendSeparator();
321
322 if( !Kiface().IsSingle() )
324 else
325 config.AppendAction( PCB_ACTIONS::importNetlist );
326
327 config.AppendAction( PCB_ACTIONS::runDRC );
328
329 config.AppendSeparator()
330 .AppendAction( PCB_ACTIONS::showEeschema );
331
333
334 break;
335
336 case TOOLBAR_LOC::TOP_AUX:
338 .AppendAction( PCB_ACTIONS::autoTrackWidth );
339
340 config.AppendSeparator()
342
343 config.AppendSeparator()
345 .AppendAction( PCB_ACTIONS::selectLayerPair );
346
347 config.AppendSeparator()
348 .AppendControl( ACTION_TOOLBAR_CONTROLS::gridSelect );
349
350 config.AppendSeparator()
351 .AppendControl( ACTION_TOOLBAR_CONTROLS::zoomSelect );
352
353 break;
354 }
355
356 // clang-format on
357 return config;
358}
359
360
362{
364
365 // Box to display and choose track widths
366 auto trackWidthSelectorFactory =
367 [this]( ACTION_TOOLBAR* aToolbar )
368 {
369 if( !m_SelTrackWidthBox )
370 {
371 m_SelTrackWidthBox = new wxChoice( aToolbar, ID_AUX_TOOLBAR_PCB_TRACK_WIDTH,
372 wxDefaultPosition, wxDefaultSize, 0, nullptr );
373 }
374
375 m_SelTrackWidthBox->SetToolTip( _( "Select the default width for new tracks. Note that this "
376 "width can be overridden by the board minimum width, or by "
377 "the width of an existing track if the 'Use Existing Track "
378 "Width' feature is enabled." ) );
379
381
382 aToolbar->Add( m_SelTrackWidthBox );
383 };
384
386
387
388 // Box to display and choose vias diameters
389 auto viaDiaSelectorFactory =
390 [this]( ACTION_TOOLBAR* aToolbar )
391 {
392 if( !m_SelViaSizeBox )
393 {
394 m_SelViaSizeBox = new wxChoice( aToolbar, ID_AUX_TOOLBAR_PCB_VIA_SIZE,
395 wxDefaultPosition, wxDefaultSize, 0, nullptr );
396 }
397
399 aToolbar->Add( m_SelViaSizeBox );
400 };
401
403
404 // IPC/Scripting plugin control
405 // TODO (ISM): Clean this up to make IPC actions just normal tool actions to get rid of this entire
406 // control
407 auto pluginControlFactory =
408 [this]( ACTION_TOOLBAR* aToolbar )
409 {
410 // Add scripting console and API plugins
411 bool scriptingAvailable = SCRIPTING::IsWxAvailable();
412
413 #ifdef KICAD_IPC_API
414 bool haveApiPlugins = Pgm().GetCommonSettings()->m_Api.enable_server &&
415 !Pgm().GetPluginManager().GetActionsForScope( PluginActionScope() ).empty();
416 #else
417 bool haveApiPlugins = false;
418 #endif
419
420 if( scriptingAvailable || haveApiPlugins )
421 {
422 aToolbar->AddScaledSeparator( aToolbar->GetParent() );
423
424 if( scriptingAvailable )
425 {
426 aToolbar->Add( PCB_ACTIONS::showPythonConsole );
427 addActionPluginTools( aToolbar );
428 }
429
430 if( haveApiPlugins )
431 AddApiPluginTools( aToolbar );
432 }
433 };
434
436}
437
438
439static wxString ComboBoxUnits( EDA_UNITS aUnits, double aValue, bool aIncludeLabel = true )
440{
441 wxString text;
442 const wxChar* format;
443
444 switch( aUnits )
445 {
446 default:
447 wxASSERT_MSG( false, wxT( "Invalid unit" ) );
449 case EDA_UNITS::UNSCALED: format = wxT( "%.0f" ); break;
450 case EDA_UNITS::MM: format = wxT( "%.3f" ); break;
451 case EDA_UNITS::MILS: format = wxT( "%.2f" ); break;
452 case EDA_UNITS::INCH: format = wxT( "%.5f" ); break;
453 }
454
455 text.Printf( format, EDA_UNIT_UTILS::UI::ToUserUnit( pcbIUScale, aUnits, aValue ) );
456
457 if( aIncludeLabel )
459
460 return text;
461}
462
463
464void PCB_EDIT_FRAME::UpdateTrackWidthSelectBox( wxChoice* aTrackWidthSelectBox, bool aShowNetclass,
465 bool aShowEdit )
466{
467 if( aTrackWidthSelectBox == nullptr )
468 return;
469
470 EDA_UNITS primaryUnit;
471 EDA_UNITS secondaryUnit;
472
473 GetUnitPair( primaryUnit, secondaryUnit );
474
475 wxString msg;
476
477 aTrackWidthSelectBox->Clear();
478
479 if( aShowNetclass )
480 aTrackWidthSelectBox->Append( _( "Track: use netclass width" ) );
481
482 for( unsigned ii = 1; ii < GetDesignSettings().m_TrackWidthList.size(); ii++ )
483 {
484 int size = GetDesignSettings().m_TrackWidthList[ii];
485
486 msg.Printf( _( "Track: %s (%s)" ), ComboBoxUnits( primaryUnit, size ),
487 ComboBoxUnits( secondaryUnit, size ) );
488
489 aTrackWidthSelectBox->Append( msg );
490 }
491
492 if( aShowEdit )
493 {
494 aTrackWidthSelectBox->Append( wxT( "---" ) );
495 aTrackWidthSelectBox->Append( _( "Edit Pre-defined Sizes..." ) );
496 }
497
498 if( GetDesignSettings().GetTrackWidthIndex() >= GetDesignSettings().m_TrackWidthList.size() )
500
501 aTrackWidthSelectBox->SetSelection( GetDesignSettings().GetTrackWidthIndex() );
502}
503
504
505void PCB_EDIT_FRAME::UpdateViaSizeSelectBox( wxChoice* aViaSizeSelectBox, bool aShowNetclass,
506 bool aShowEdit )
507{
508 if( aViaSizeSelectBox == nullptr )
509 return;
510
511 aViaSizeSelectBox->Clear();
512
514 EDA_UNITS primaryUnit = GetUserUnits();
515 EDA_UNITS secondaryUnit = EDA_UNITS::MILS;
516
517 if( EDA_UNIT_UTILS::IsImperialUnit( primaryUnit ) )
518 secondaryUnit = cmnTool ? cmnTool->GetLastMetricUnits() : EDA_UNITS::MM;
519 else
520 secondaryUnit = cmnTool ? cmnTool->GetLastImperialUnits() : EDA_UNITS::MILS;
521
522 if( aShowNetclass )
523 aViaSizeSelectBox->Append( _( "Via: use netclass sizes" ) );
524
525 for( unsigned ii = 1; ii < GetDesignSettings().m_ViasDimensionsList.size(); ii++ )
526 {
528 wxString msg, priStr, secStr;
529
530 double diam = viaDimension.m_Diameter;
531 double hole = viaDimension.m_Drill;
532
533 if( hole > 0 )
534 {
535 priStr = ComboBoxUnits( primaryUnit, diam, false ) + wxT( " / " )
536 + ComboBoxUnits( primaryUnit, hole, true );
537 secStr = ComboBoxUnits( secondaryUnit, diam, false ) + wxT( " / " )
538 + ComboBoxUnits( secondaryUnit, hole, true );
539 }
540 else
541 {
542 priStr = ComboBoxUnits( primaryUnit, diam, true );
543 secStr = ComboBoxUnits( secondaryUnit, diam, true );
544 }
545
546 msg.Printf( _( "Via: %s (%s)" ), priStr, secStr );
547
548 aViaSizeSelectBox->Append( msg );
549 }
550
551 if( aShowEdit )
552 {
553 aViaSizeSelectBox->Append( wxT( "---" ) );
554 aViaSizeSelectBox->Append( _( "Edit Pre-defined Sizes..." ) );
555 }
556
557 if( GetDesignSettings().GetViaSizeIndex() >= GetDesignSettings().m_ViasDimensionsList.size() )
559
560 aViaSizeSelectBox->SetSelection( GetDesignSettings().GetViaSizeIndex() );
561}
562
563
564void PCB_EDIT_FRAME::ReCreateLayerBox( bool aForceResizeToolbar )
565{
566 if( m_SelLayerBox == nullptr || m_tbTopAux == nullptr )
567 return;
568
569 m_SelLayerBox->SetToolTip( _( "+/- to switch" ) );
571
572 if( aForceResizeToolbar )
574}
575
576
578{
580 wxAuiPaneInfo& layersManager = m_auimgr.GetPane( AppearancePanelName() );
581 wxAuiPaneInfo& selectionFilter = m_auimgr.GetPane( "SelectionFilter" );
582
583 // show auxiliary Vertical layers and visibility manager toolbar
584 m_show_layer_manager_tools = layersManager.IsShown();
585
587
588 layersManager.Show( m_show_layer_manager_tools );
589 selectionFilter.Show( m_show_layer_manager_tools );
590
592 {
593 SetAuiPaneSize( m_auimgr, layersManager, settings->m_AuiPanels.right_panel_width, -1 );
594 }
595 else
596 {
597 settings->m_AuiPanels.right_panel_width = m_appearancePanel->GetSize().x;
598 m_auimgr.Update();
599 }
600}
601
602
604{
606 wxAuiPaneInfo& netInspectorPanel = m_auimgr.GetPane( NetInspectorPanelName() );
607
608 m_show_net_inspector = netInspectorPanel.IsShown();
609
611
612 netInspectorPanel.Show( m_show_net_inspector );
613
615 {
616 SetAuiPaneSize( m_auimgr, netInspectorPanel, settings->m_AuiPanels.net_inspector_width,
617 -1 );
619 }
620 else
621 {
623 settings->m_AuiPanels.net_inspector_width = m_netInspectorPanel->GetSize().x;
624 m_auimgr.Update();
625 }
626}
627
628
630{
632
633 // Ensure m_show_search is up to date (the pane can be closed outside the menu)
634 m_show_search = m_auimgr.GetPane( SearchPaneName() ).IsShown();
635
637
638 wxAuiPaneInfo& searchPaneInfo = m_auimgr.GetPane( SearchPaneName() );
639 searchPaneInfo.Show( m_show_search );
640
641 if( m_show_search )
642 {
643 searchPaneInfo.Direction( settings->m_AuiPanels.search_panel_dock_direction );
644
645 if( settings->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_TOP
646 || settings->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_BOTTOM )
647 {
648 SetAuiPaneSize( m_auimgr, searchPaneInfo,
649 -1, settings->m_AuiPanels.search_panel_height );
650 }
651 else if( settings->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_LEFT
652 || settings->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_RIGHT )
653 {
654 SetAuiPaneSize( m_auimgr, searchPaneInfo,
655 settings->m_AuiPanels.search_panel_width, -1 );
656 }
659 }
660 else
661 {
662 settings->m_AuiPanels.search_panel_height = m_searchPane->GetSize().y;
663 settings->m_AuiPanels.search_panel_width = m_searchPane->GetSize().x;
664 settings->m_AuiPanels.search_panel_dock_direction = searchPaneInfo.dock_direction;
665 m_auimgr.Update();
666 GetCanvas()->SetFocus();
667 }
668}
669
670
671void PCB_EDIT_FRAME::OnUpdateSelectTrackWidth( wxUpdateUIEvent& aEvent )
672{
673 if( aEvent.GetId() == ID_AUX_TOOLBAR_PCB_TRACK_WIDTH )
674 {
676 int sel;
677
678 if( bds.UseCustomTrackViaSize() )
679 sel = wxNOT_FOUND;
680 else
681 sel = bds.GetTrackWidthIndex();
682
683 if( m_SelTrackWidthBox->GetSelection() != sel )
684 m_SelTrackWidthBox->SetSelection( sel );
685 }
686}
687
688
689void PCB_EDIT_FRAME::OnUpdateSelectViaSize( wxUpdateUIEvent& aEvent )
690{
691 if( aEvent.GetId() == ID_AUX_TOOLBAR_PCB_VIA_SIZE )
692 {
694 int sel = 0;
695
696 if( bds.UseCustomTrackViaSize() )
697 sel = wxNOT_FOUND;
698 else
699 sel = bds.GetViaSizeIndex();
700
701 if( m_SelViaSizeBox->GetSelection() != sel )
702 m_SelViaSizeBox->SetSelection( sel );
703 }
704}
705
706
708{
710
711 wxCHECK( cfg, /* void */ );
712
713 wxAuiPaneInfo& db_library_pane = m_auimgr.GetPane( DesignBlocksPaneName() );
714
715 db_library_pane.Show( !db_library_pane.IsShown() );
716
717 if( db_library_pane.IsShown() )
718 {
719 if( db_library_pane.IsFloating() )
720 {
721 db_library_pane.FloatingSize( cfg->m_AuiPanels.design_blocks_panel_float_width,
723 m_auimgr.Update();
724 }
726 {
727 // SetAuiPaneSize also updates m_auimgr
729 }
730 }
731 else
732 {
733 if( db_library_pane.IsFloating() )
734 {
735 cfg->m_AuiPanels.design_blocks_panel_float_width = db_library_pane.floating_size.x;
736 cfg->m_AuiPanels.design_blocks_panel_float_height = db_library_pane.floating_size.y;
737 }
738 else
739 {
741 }
742
743 m_auimgr.Update();
744 }
745}
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
static TOOL_ACTION updatePcbFromSchematic
Definition: actions.h:218
static TOOL_ACTION toggleGrid
Definition: actions.h:191
static TOOL_ACTION zoomRedraw
Definition: actions.h:124
static TOOL_ACTION millimetersUnits
Definition: actions.h:199
static TOOL_ACTION show3DViewer
Definition: actions.h:213
static TOOL_ACTION zoomOutCenter
Definition: actions.h:128
static TOOL_ACTION togglePolarCoords
Definition: actions.h:202
static TOOL_ACTION milsUnits
Definition: actions.h:198
static TOOL_ACTION toggleBoundingBoxes
Definition: actions.h:147
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:68
static TOOL_ACTION inchesUnits
Definition: actions.h:197
static TOOL_ACTION highContrastMode
Definition: actions.h:145
static TOOL_ACTION toggleCursorStyle
Definition: actions.h:144
static TOOL_ACTION measureTool
Definition: actions.h:207
static TOOL_ACTION selectionTool
Definition: actions.h:206
static TOOL_ACTION save
Definition: actions.h:51
static TOOL_ACTION zoomFitScreen
Definition: actions.h:134
static TOOL_ACTION redo
Definition: actions.h:69
static TOOL_ACTION deleteTool
Definition: actions.h:79
static TOOL_ACTION zoomTool
Definition: actions.h:138
static TOOL_ACTION showFootprintEditor
Definition: actions.h:217
static TOOL_ACTION print
Definition: actions.h:57
static TOOL_ACTION showProperties
Definition: actions.h:220
static TOOL_ACTION doNew
Definition: actions.h:47
static TOOL_ACTION zoomFitObjects
Definition: actions.h:135
static TOOL_ACTION zoomInCenter
Definition: actions.h:127
static TOOL_ACTION gridSetOrigin
Definition: actions.h:188
static TOOL_ACTION showFootprintBrowser
Definition: actions.h:216
static TOOL_ACTION toggleGridOverrides
Definition: actions.h:192
static TOOL_ACTION find
Definition: actions.h:109
static ACTION_TOOLBAR_CONTROL gridSelect
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.
void SetToolBitmap(const TOOL_ACTION &aAction, const wxBitmap &aBitmap)
Updates the bitmap of a particular tool.
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:79
EDA_UNITS GetLastMetricUnits()
Definition: common_tools.h:78
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()
void SetFocus() override
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
static std::unique_ptr< wxBitmap > CreateLayerPairIcon(const KIGFX::COLOR4D &aBgColor, const KIGFX::COLOR4D &aTopColor, const KIGFX::COLOR4D &aBottomColor, int aScale)
Create a layer pair "side-by-side swatch" icon.
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:544
static TOOL_ACTION drawRuleArea
Definition: pcb_actions.h:224
static TOOL_ACTION drawBezier
Definition: pcb_actions.h:207
static TOOL_ACTION placeText
Definition: pcb_actions.h:209
static TOOL_ACTION drawOrthogonalDimension
Definition: pcb_actions.h:220
static TOOL_ACTION drawRectangle
Definition: pcb_actions.h:204
static TOOL_ACTION padDisplayMode
Definition: pcb_actions.h:341
static TOOL_ACTION placeReferenceImage
Definition: pcb_actions.h:208
static TOOL_ACTION showRatsnest
Definition: pcb_actions.h:336
static TOOL_ACTION showLayersManager
Definition: pcb_actions.h:458
static TOOL_ACTION toggleNetHighlight
Definition: pcb_actions.h:580
static TOOL_ACTION drawCircle
Definition: pcb_actions.h:205
static TOOL_ACTION mirrorH
Mirroring of selected items.
Definition: pcb_actions.h:140
static TOOL_ACTION routeDiffPair
Activation of the Push and Shove router (differential pair mode)
Definition: pcb_actions.h:258
static TOOL_ACTION tuneDiffPair
Definition: pcb_actions.h:261
static TOOL_ACTION autoTrackWidth
Definition: pcb_actions.h:404
static TOOL_ACTION drawTable
Definition: pcb_actions.h:211
static TOOL_ACTION drawTextBox
Definition: pcb_actions.h:210
static TOOL_ACTION drawPolygon
Definition: pcb_actions.h:203
static TOOL_ACTION group
Definition: pcb_actions.h:552
static TOOL_ACTION zoneDisplayFilled
Definition: pcb_actions.h:343
static TOOL_ACTION drawRadialDimension
Definition: pcb_actions.h:219
static TOOL_ACTION tuneSingleTrack
Definition: pcb_actions.h:260
static TOOL_ACTION viaDisplayMode
Definition: pcb_actions.h:342
static TOOL_ACTION drawLeader
Definition: pcb_actions.h:221
static TOOL_ACTION drillOrigin
Definition: pcb_actions.h:562
static TOOL_ACTION tuneSkew
Definition: pcb_actions.h:262
static TOOL_ACTION trackDisplayMode
Definition: pcb_actions.h:340
static TOOL_ACTION selectLayerPair
Definition: pcb_actions.h:193
static TOOL_ACTION zoneDisplayTriangulated
Definition: pcb_actions.h:346
static TOOL_ACTION ungroup
Definition: pcb_actions.h:553
static TOOL_ACTION zoneDisplayFractured
Definition: pcb_actions.h:345
static TOOL_ACTION drawVia
Definition: pcb_actions.h:223
static TOOL_ACTION drawArc
Definition: pcb_actions.h:206
static TOOL_ACTION runDRC
Definition: pcb_actions.h:453
static TOOL_ACTION importNetlist
Definition: pcb_actions.h:439
static TOOL_ACTION boardSetup
Definition: pcb_actions.h:425
static TOOL_ACTION showEeschema
Definition: pcb_actions.h:566
static TOOL_ACTION drawCenterDimension
Definition: pcb_actions.h:218
static TOOL_ACTION zoneDisplayOutline
Definition: pcb_actions.h:344
static TOOL_ACTION ratsnestLineMode
Definition: pcb_actions.h:337
static TOOL_ACTION mirrorV
Definition: pcb_actions.h:141
static TOOL_ACTION unlock
Definition: pcb_actions.h:549
static TOOL_ACTION placeFootprint
Definition: pcb_actions.h:229
static TOOL_ACTION routeSingleTrack
Activation of the Push and Shove router.
Definition: pcb_actions.h:255
static TOOL_ACTION showPythonConsole
Definition: pcb_actions.h:460
static TOOL_ACTION drawLine
Definition: pcb_actions.h:202
static TOOL_ACTION localRatsnestTool
Definition: pcb_actions.h:587
static TOOL_ACTION rotateCw
Rotation of selected objects.
Definition: pcb_actions.h:133
static TOOL_ACTION rotateCcw
Definition: pcb_actions.h:134
static TOOL_ACTION drawAlignedDimension
Definition: pcb_actions.h:217
static TOOL_ACTION drawZone
Definition: pcb_actions.h:222
static TOOL_ACTION lock
Definition: pcb_actions.h:548
static ACTION_TOOLBAR_CONTROL trackWidth
static ACTION_TOOLBAR_CONTROL viaDiameter
COLOR_SETTINGS * GetColorSettings(bool aForceRefresh=false) const override
Helper to retrieve the current color settings.
PCB_LAYER_BOX_SELECTOR * m_SelLayerBox
void configureToolbars() 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.
virtual BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Return the BOARD_DESIGN_SETTINGS for the open project.
void OnUpdateSelectTrackWidth(wxUpdateUIEvent &aEvent)
void UpdateTrackWidthSelectBox(wxChoice *aTrackWidthSelectBox, bool aShowNetclass, bool aShowEdit)
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 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
void OnUpdateSelectViaSize(wxUpdateUIEvent &aEvent)
wxChoice * m_SelViaSizeBox
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.
virtual COMMON_SETTINGS * GetCommonSettings() const
Definition: pgm_base.cpp:687
void RefreshSearch()
void FocusSearch()
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:171
#define _(s)
EDA_UNITS
Definition: eda_units.h:46
@ LAYER_PCB_BACKGROUND
PCB background color.
Definition: layer_ids.h:280
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.
Definition: eda_units.cpp:261
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:127
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_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:1071
see class PGM_BASE
const int scale
Container to handle a stock of specific vias each with unique diameter and drill sizes in the BOARD c...
static wxString ComboBoxUnits(EDA_UNITS aUnits, double aValue, bool aIncludeLabel=true)
static std::unique_ptr< wxBitmap > LayerPairBitmap
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.