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_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( ACTIONS::pointEditorArcKeepCenter, ACTION_MENU::CHECK );
239 arcMenu->Add( ACTIONS::pointEditorArcKeepEndpoint, ACTION_MENU::CHECK );
240 arcMenu->Add( ACTIONS::pointEditorArcKeepRadius, ACTION_MENU::CHECK );
241
242 return arcMenu;
243 };
244
245 m_tbRight->AddToolContextMenu( PCB_ACTIONS::drawArc, makeArcMenu() );
246
247 auto makeRouteMenu = [&]()
248 {
249 std::unique_ptr<ACTION_MENU> routeMenu = std::make_unique<ACTION_MENU>( false, selTool );
250
251 routeMenu->Add( PCB_ACTIONS::routerHighlightMode, ACTION_MENU::CHECK );
252 routeMenu->Add( PCB_ACTIONS::routerShoveMode, ACTION_MENU::CHECK );
253 routeMenu->Add( PCB_ACTIONS::routerWalkaroundMode, ACTION_MENU::CHECK );
254
255 routeMenu->AppendSeparator();
256 routeMenu->Add( PCB_ACTIONS::routerSettingsDialog );
257
258 return routeMenu;
259 };
260
261 m_tbRight->AddToolContextMenu( PCB_ACTIONS::routeSingleTrack, makeRouteMenu() );
262 m_tbRight->AddToolContextMenu( PCB_ACTIONS::routeDiffPair, makeRouteMenu() );
263
264 std::unique_ptr<ACTION_MENU> zoneMenu = std::make_unique<ACTION_MENU>( false, selTool );
265 zoneMenu->Add( PCB_ACTIONS::zoneFillAll );
266 zoneMenu->Add( PCB_ACTIONS::zoneUnfillAll );
267 m_tbRight->AddToolContextMenu( PCB_ACTIONS::drawZone, std::move( zoneMenu ) );
268
269 std::unique_ptr<ACTION_MENU> lineMenu = std::make_unique<ACTION_MENU>( false, selTool );
270 m_tbRight->AddToolContextMenu( PCB_ACTIONS::drawLine, std::move( lineMenu ) );
271 */
272 break;
273
274 case TOOLBAR_LOC::TOP_MAIN:
275 if( Kiface().IsSingle() )
276 {
277 config.AppendAction( ACTIONS::doNew );
278 config.AppendAction( ACTIONS::open );
279 }
280
281 config.AppendAction( ACTIONS::save );
282
283 config.AppendSeparator()
284 .AppendAction( PCB_ACTIONS::boardSetup );
285
286 config.AppendSeparator()
287 .AppendAction( ACTIONS::pageSettings )
288 .AppendAction( ACTIONS::print )
289 .AppendAction( ACTIONS::plot );
290
291 config.AppendSeparator()
292 .AppendAction( ACTIONS::undo )
293 .AppendAction( ACTIONS::redo );
294
295 config.AppendSeparator()
296 .AppendAction( ACTIONS::find );
297
298 config.AppendSeparator()
299 .AppendAction( ACTIONS::zoomRedraw )
300 .AppendAction( ACTIONS::zoomInCenter )
301 .AppendAction( ACTIONS::zoomOutCenter )
302 .AppendAction( ACTIONS::zoomFitScreen )
303 .AppendAction( ACTIONS::zoomFitObjects )
304 .AppendAction( ACTIONS::zoomTool );
305
306 config.AppendSeparator()
307 .AppendAction( PCB_ACTIONS::rotateCcw )
308 .AppendAction( PCB_ACTIONS::rotateCw )
309 .AppendAction( PCB_ACTIONS::mirrorV )
310 .AppendAction( PCB_ACTIONS::mirrorH )
311 .AppendAction( ACTIONS::group )
312 .AppendAction( ACTIONS::ungroup )
313 .AppendAction( PCB_ACTIONS::lock )
314 .AppendAction( PCB_ACTIONS::unlock );
315
316 config.AppendSeparator()
317 .AppendAction( ACTIONS::showFootprintEditor )
318 .AppendAction( ACTIONS::showFootprintBrowser )
319 .AppendAction( ACTIONS::show3DViewer );
320
321 config.AppendSeparator();
322
323 if( !Kiface().IsSingle() )
325 else
326 config.AppendAction( PCB_ACTIONS::importNetlist );
327
328 config.AppendAction( PCB_ACTIONS::runDRC );
329
330 config.AppendSeparator();
331 config.AppendAction( PCB_ACTIONS::showEeschema );
332
334
335 break;
336
337 case TOOLBAR_LOC::TOP_AUX:
339 .AppendAction( PCB_ACTIONS::autoTrackWidth );
340
341 config.AppendSeparator()
343
344 config.AppendSeparator()
346 .AppendAction( PCB_ACTIONS::selectLayerPair );
347
348 config.AppendSeparator()
349 .AppendControl( ACTION_TOOLBAR_CONTROLS::gridSelect );
350
351 config.AppendSeparator()
352 .AppendControl( ACTION_TOOLBAR_CONTROLS::zoomSelect );
353
354 break;
355 }
356
357 // clang-format on
358 return config;
359}
360
361
363{
365
366 // Box to display and choose track widths
367 auto trackWidthSelectorFactory =
368 [this]( ACTION_TOOLBAR* aToolbar )
369 {
370 if( !m_SelTrackWidthBox )
371 {
372 m_SelTrackWidthBox = new wxChoice( aToolbar, ID_AUX_TOOLBAR_PCB_TRACK_WIDTH,
373 wxDefaultPosition, wxDefaultSize, 0, nullptr );
374 }
375
376 m_SelTrackWidthBox->SetToolTip( _( "Select the default width for new tracks. Note that this "
377 "width can be overridden by the board minimum width, or by "
378 "the width of an existing track if the 'Use Existing Track "
379 "Width' feature is enabled." ) );
380
382
383 aToolbar->Add( m_SelTrackWidthBox );
384 };
385
387
388
389 // Box to display and choose vias diameters
390 auto viaDiaSelectorFactory =
391 [this]( ACTION_TOOLBAR* aToolbar )
392 {
393 if( !m_SelViaSizeBox )
394 {
395 m_SelViaSizeBox = new wxChoice( aToolbar, ID_AUX_TOOLBAR_PCB_VIA_SIZE,
396 wxDefaultPosition, wxDefaultSize, 0, nullptr );
397 }
398
400 aToolbar->Add( m_SelViaSizeBox );
401 };
402
404
405 // IPC/Scripting plugin control
406 // TODO (ISM): Clean this up to make IPC actions just normal tool actions to get rid of this entire
407 // control
408 auto pluginControlFactory =
409 [this]( ACTION_TOOLBAR* aToolbar )
410 {
411 // Add scripting console and API plugins
412 bool scriptingAvailable = SCRIPTING::IsWxAvailable();
413
414 #ifdef KICAD_IPC_API
415 bool haveApiPlugins = Pgm().GetCommonSettings()->m_Api.enable_server &&
416 !Pgm().GetPluginManager().GetActionsForScope( PluginActionScope() ).empty();
417 #else
418 bool haveApiPlugins = false;
419 #endif
420
421 if( scriptingAvailable || haveApiPlugins )
422 {
423 aToolbar->AddScaledSeparator( aToolbar->GetParent() );
424
425 if( scriptingAvailable )
426 {
427 aToolbar->Add( PCB_ACTIONS::showPythonConsole );
428 addActionPluginTools( aToolbar );
429 }
430
431 if( haveApiPlugins )
432 AddApiPluginTools( aToolbar );
433 }
434 };
435
437}
438
439
440static wxString ComboBoxUnits( EDA_UNITS aUnits, double aValue, bool aIncludeLabel = true )
441{
442 wxString text;
443 const wxChar* format;
444
445 switch( aUnits )
446 {
447 default:
448 wxASSERT_MSG( false, wxT( "Invalid unit" ) );
450 case EDA_UNITS::UNSCALED: format = wxT( "%.0f" ); break;
451 case EDA_UNITS::MM: format = wxT( "%.3f" ); break;
452 case EDA_UNITS::MILS: format = wxT( "%.2f" ); break;
453 case EDA_UNITS::INCH: format = wxT( "%.5f" ); break;
454 }
455
456 text.Printf( format, EDA_UNIT_UTILS::UI::ToUserUnit( pcbIUScale, aUnits, aValue ) );
457
458 if( aIncludeLabel )
460
461 return text;
462}
463
464
465void PCB_EDIT_FRAME::UpdateTrackWidthSelectBox( wxChoice* aTrackWidthSelectBox, bool aShowNetclass,
466 bool aShowEdit )
467{
468 if( aTrackWidthSelectBox == nullptr )
469 return;
470
471 EDA_UNITS primaryUnit;
472 EDA_UNITS secondaryUnit;
473
474 GetUnitPair( primaryUnit, secondaryUnit );
475
476 wxString msg;
477
478 aTrackWidthSelectBox->Clear();
479
480 if( aShowNetclass )
481 aTrackWidthSelectBox->Append( _( "Track: use netclass width" ) );
482
483 for( unsigned ii = 1; ii < GetDesignSettings().m_TrackWidthList.size(); ii++ )
484 {
485 int size = GetDesignSettings().m_TrackWidthList[ii];
486
487 msg.Printf( _( "Track: %s (%s)" ), ComboBoxUnits( primaryUnit, size ),
488 ComboBoxUnits( secondaryUnit, size ) );
489
490 aTrackWidthSelectBox->Append( msg );
491 }
492
493 if( aShowEdit )
494 {
495 aTrackWidthSelectBox->Append( wxT( "---" ) );
496 aTrackWidthSelectBox->Append( _( "Edit Pre-defined Sizes..." ) );
497 }
498
499 if( GetDesignSettings().GetTrackWidthIndex() >= GetDesignSettings().m_TrackWidthList.size() )
501
502 aTrackWidthSelectBox->SetSelection( GetDesignSettings().GetTrackWidthIndex() );
503}
504
505
506void PCB_EDIT_FRAME::UpdateViaSizeSelectBox( wxChoice* aViaSizeSelectBox, bool aShowNetclass,
507 bool aShowEdit )
508{
509 if( aViaSizeSelectBox == nullptr )
510 return;
511
512 aViaSizeSelectBox->Clear();
513
515 EDA_UNITS primaryUnit = GetUserUnits();
516 EDA_UNITS secondaryUnit = EDA_UNITS::MILS;
517
518 if( EDA_UNIT_UTILS::IsImperialUnit( primaryUnit ) )
519 secondaryUnit = cmnTool ? cmnTool->GetLastMetricUnits() : EDA_UNITS::MM;
520 else
521 secondaryUnit = cmnTool ? cmnTool->GetLastImperialUnits() : EDA_UNITS::MILS;
522
523 if( aShowNetclass )
524 aViaSizeSelectBox->Append( _( "Via: use netclass sizes" ) );
525
526 for( unsigned ii = 1; ii < GetDesignSettings().m_ViasDimensionsList.size(); ii++ )
527 {
529 wxString msg, priStr, secStr;
530
531 double diam = viaDimension.m_Diameter;
532 double hole = viaDimension.m_Drill;
533
534 if( hole > 0 )
535 {
536 priStr = ComboBoxUnits( primaryUnit, diam, false ) + wxT( " / " )
537 + ComboBoxUnits( primaryUnit, hole, true );
538 secStr = ComboBoxUnits( secondaryUnit, diam, false ) + wxT( " / " )
539 + ComboBoxUnits( secondaryUnit, hole, true );
540 }
541 else
542 {
543 priStr = ComboBoxUnits( primaryUnit, diam, true );
544 secStr = ComboBoxUnits( secondaryUnit, diam, true );
545 }
546
547 msg.Printf( _( "Via: %s (%s)" ), priStr, secStr );
548
549 aViaSizeSelectBox->Append( msg );
550 }
551
552 if( aShowEdit )
553 {
554 aViaSizeSelectBox->Append( wxT( "---" ) );
555 aViaSizeSelectBox->Append( _( "Edit Pre-defined Sizes..." ) );
556 }
557
558 if( GetDesignSettings().GetViaSizeIndex() >= GetDesignSettings().m_ViasDimensionsList.size() )
560
561 aViaSizeSelectBox->SetSelection( GetDesignSettings().GetViaSizeIndex() );
562}
563
564
565void PCB_EDIT_FRAME::ReCreateLayerBox( bool aForceResizeToolbar )
566{
567 if( m_SelLayerBox == nullptr || m_tbTopAux == nullptr )
568 return;
569
570 m_SelLayerBox->SetToolTip( _( "+/- to switch" ) );
572
573 if( aForceResizeToolbar )
575}
576
577
579{
581 wxAuiPaneInfo& layersManager = m_auimgr.GetPane( AppearancePanelName() );
582 wxAuiPaneInfo& selectionFilter = m_auimgr.GetPane( "SelectionFilter" );
583
584 // show auxiliary Vertical layers and visibility manager toolbar
585 m_show_layer_manager_tools = layersManager.IsShown();
586
588
589 layersManager.Show( m_show_layer_manager_tools );
590 selectionFilter.Show( m_show_layer_manager_tools );
591
593 {
594 SetAuiPaneSize( m_auimgr, layersManager, settings->m_AuiPanels.right_panel_width, -1 );
595 }
596 else
597 {
598 settings->m_AuiPanels.right_panel_width = m_appearancePanel->GetSize().x;
599 m_auimgr.Update();
600 }
601}
602
603
605{
607 wxAuiPaneInfo& netInspectorPanel = m_auimgr.GetPane( NetInspectorPanelName() );
608
609 m_show_net_inspector = netInspectorPanel.IsShown();
610
612
613 netInspectorPanel.Show( m_show_net_inspector );
614
616 {
617 SetAuiPaneSize( m_auimgr, netInspectorPanel, settings->m_AuiPanels.net_inspector_width,
618 -1 );
620 }
621 else
622 {
624 settings->m_AuiPanels.net_inspector_width = m_netInspectorPanel->GetSize().x;
625 m_auimgr.Update();
626 }
627}
628
629
631{
633
634 // Ensure m_show_search is up to date (the pane can be closed outside the menu)
635 m_show_search = m_auimgr.GetPane( SearchPaneName() ).IsShown();
636
638
639 wxAuiPaneInfo& searchPaneInfo = m_auimgr.GetPane( SearchPaneName() );
640 searchPaneInfo.Show( m_show_search );
641
642 if( m_show_search )
643 {
644 searchPaneInfo.Direction( settings->m_AuiPanels.search_panel_dock_direction );
645
646 if( settings->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_TOP
647 || settings->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_BOTTOM )
648 {
649 SetAuiPaneSize( m_auimgr, searchPaneInfo,
650 -1, settings->m_AuiPanels.search_panel_height );
651 }
652 else if( settings->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_LEFT
653 || settings->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_RIGHT )
654 {
655 SetAuiPaneSize( m_auimgr, searchPaneInfo,
656 settings->m_AuiPanels.search_panel_width, -1 );
657 }
660 }
661 else
662 {
663 settings->m_AuiPanels.search_panel_height = m_searchPane->GetSize().y;
664 settings->m_AuiPanels.search_panel_width = m_searchPane->GetSize().x;
665 settings->m_AuiPanels.search_panel_dock_direction = searchPaneInfo.dock_direction;
666 m_auimgr.Update();
667 GetCanvas()->SetFocus();
668 }
669}
670
671
672void PCB_EDIT_FRAME::OnUpdateSelectTrackWidth( wxUpdateUIEvent& aEvent )
673{
674 if( aEvent.GetId() == ID_AUX_TOOLBAR_PCB_TRACK_WIDTH )
675 {
677 int sel;
678
679 if( bds.UseCustomTrackViaSize() )
680 sel = wxNOT_FOUND;
681 else
682 sel = bds.GetTrackWidthIndex();
683
684 if( m_SelTrackWidthBox->GetSelection() != sel )
685 m_SelTrackWidthBox->SetSelection( sel );
686 }
687}
688
689
690void PCB_EDIT_FRAME::OnUpdateSelectViaSize( wxUpdateUIEvent& aEvent )
691{
692 if( aEvent.GetId() == ID_AUX_TOOLBAR_PCB_VIA_SIZE )
693 {
695 int sel = 0;
696
697 if( bds.UseCustomTrackViaSize() )
698 sel = wxNOT_FOUND;
699 else
700 sel = bds.GetViaSizeIndex();
701
702 if( m_SelViaSizeBox->GetSelection() != sel )
703 m_SelViaSizeBox->SetSelection( sel );
704 }
705}
706
707
709{
711
712 wxCHECK( cfg, /* void */ );
713
714 wxAuiPaneInfo& db_library_pane = m_auimgr.GetPane( DesignBlocksPaneName() );
715
716 db_library_pane.Show( !db_library_pane.IsShown() );
717
718 if( db_library_pane.IsShown() )
719 {
720 if( db_library_pane.IsFloating() )
721 {
722 db_library_pane.FloatingSize( cfg->m_AuiPanels.design_blocks_panel_float_width,
724 m_auimgr.Update();
725 }
727 {
728 // SetAuiPaneSize also updates m_auimgr
730 }
731 }
732 else
733 {
734 if( db_library_pane.IsFloating() )
735 {
736 cfg->m_AuiPanels.design_blocks_panel_float_width = db_library_pane.floating_size.x;
737 cfg->m_AuiPanels.design_blocks_panel_float_height = db_library_pane.floating_size.y;
738 }
739 else
740 {
742 }
743
744 m_auimgr.Update();
745 }
746}
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:112
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:257
static TOOL_ACTION toggleGrid
Definition: actions.h:195
static TOOL_ACTION zoomRedraw
Definition: actions.h:131
static TOOL_ACTION millimetersUnits
Definition: actions.h:203
static TOOL_ACTION show3DViewer
Definition: actions.h:251
static TOOL_ACTION zoomOutCenter
Definition: actions.h:135
static TOOL_ACTION togglePolarCoords
Definition: actions.h:206
static TOOL_ACTION group
Definition: actions.h:232
static TOOL_ACTION milsUnits
Definition: actions.h:202
static TOOL_ACTION ungroup
Definition: actions.h:233
static TOOL_ACTION toggleBoundingBoxes
Definition: actions.h:154
static TOOL_ACTION plot
Definition: actions.h:65
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:201
static TOOL_ACTION highContrastMode
Definition: actions.h:152
static TOOL_ACTION toggleCursorStyle
Definition: actions.h:151
static TOOL_ACTION measureTool
Definition: actions.h:245
static TOOL_ACTION selectionTool
Definition: actions.h:244
static TOOL_ACTION save
Definition: actions.h:58
static TOOL_ACTION zoomFitScreen
Definition: actions.h:141
static TOOL_ACTION redo
Definition: actions.h:76
static TOOL_ACTION deleteTool
Definition: actions.h:86
static TOOL_ACTION zoomTool
Definition: actions.h:145
static TOOL_ACTION showFootprintEditor
Definition: actions.h:255
static TOOL_ACTION print
Definition: actions.h:64
static TOOL_ACTION showProperties
Definition: actions.h:259
static TOOL_ACTION doNew
Definition: actions.h:54
static TOOL_ACTION zoomFitObjects
Definition: actions.h:142
static TOOL_ACTION zoomInCenter
Definition: actions.h:134
static TOOL_ACTION gridSetOrigin
Definition: actions.h:192
static TOOL_ACTION showFootprintBrowser
Definition: actions.h:254
static TOOL_ACTION toggleGridOverrides
Definition: actions.h:196
static TOOL_ACTION find
Definition: actions.h:116
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:540
static TOOL_ACTION drawRuleArea
Definition: pcb_actions.h:211
static TOOL_ACTION drawBezier
Definition: pcb_actions.h:194
static TOOL_ACTION placeText
Definition: pcb_actions.h:196
static TOOL_ACTION drawOrthogonalDimension
Definition: pcb_actions.h:207
static TOOL_ACTION drawRectangle
Definition: pcb_actions.h:191
static TOOL_ACTION padDisplayMode
Definition: pcb_actions.h:319
static TOOL_ACTION placeReferenceImage
Definition: pcb_actions.h:195
static TOOL_ACTION showRatsnest
Definition: pcb_actions.h:314
static TOOL_ACTION showLayersManager
Definition: pcb_actions.h:452
static TOOL_ACTION toggleNetHighlight
Definition: pcb_actions.h:568
static TOOL_ACTION drawCircle
Definition: pcb_actions.h:192
static TOOL_ACTION mirrorH
Mirroring of selected items.
Definition: pcb_actions.h:125
static TOOL_ACTION routeDiffPair
Activation of the Push and Shove router (differential pair mode)
Definition: pcb_actions.h:245
static TOOL_ACTION tuneDiffPair
Definition: pcb_actions.h:248
static TOOL_ACTION autoTrackWidth
Definition: pcb_actions.h:384
static TOOL_ACTION drawTable
Definition: pcb_actions.h:198
static TOOL_ACTION drawTextBox
Definition: pcb_actions.h:197
static TOOL_ACTION drawPolygon
Definition: pcb_actions.h:190
static TOOL_ACTION zoneDisplayFilled
Definition: pcb_actions.h:321
static TOOL_ACTION drawRadialDimension
Definition: pcb_actions.h:206
static TOOL_ACTION tuneSingleTrack
Definition: pcb_actions.h:247
static TOOL_ACTION viaDisplayMode
Definition: pcb_actions.h:320
static TOOL_ACTION drawLeader
Definition: pcb_actions.h:208
static TOOL_ACTION drillOrigin
Definition: pcb_actions.h:551
static TOOL_ACTION tuneSkew
Definition: pcb_actions.h:249
static TOOL_ACTION trackDisplayMode
Definition: pcb_actions.h:318
static TOOL_ACTION selectLayerPair
Definition: pcb_actions.h:180
static TOOL_ACTION zoneDisplayTriangulated
Definition: pcb_actions.h:324
static TOOL_ACTION zoneDisplayFractured
Definition: pcb_actions.h:323
static TOOL_ACTION drawVia
Definition: pcb_actions.h:210
static TOOL_ACTION drawArc
Definition: pcb_actions.h:193
static TOOL_ACTION runDRC
Definition: pcb_actions.h:447
static TOOL_ACTION importNetlist
Definition: pcb_actions.h:412
static TOOL_ACTION boardSetup
Definition: pcb_actions.h:410
static TOOL_ACTION showEeschema
Definition: pcb_actions.h:554
static TOOL_ACTION drawCenterDimension
Definition: pcb_actions.h:205
static TOOL_ACTION zoneDisplayOutline
Definition: pcb_actions.h:322
static TOOL_ACTION ratsnestLineMode
Definition: pcb_actions.h:315
static TOOL_ACTION mirrorV
Definition: pcb_actions.h:126
static TOOL_ACTION unlock
Definition: pcb_actions.h:545
static TOOL_ACTION placeFootprint
Definition: pcb_actions.h:216
static TOOL_ACTION routeSingleTrack
Activation of the Push and Shove router.
Definition: pcb_actions.h:242
static TOOL_ACTION showPythonConsole
Definition: pcb_actions.h:454
static TOOL_ACTION drawLine
Definition: pcb_actions.h:189
static TOOL_ACTION localRatsnestTool
Definition: pcb_actions.h:575
static TOOL_ACTION rotateCw
Rotation of selected objects.
Definition: pcb_actions.h:118
static TOOL_ACTION rotateCcw
Definition: pcb_actions.h:119
static TOOL_ACTION drawAlignedDimension
Definition: pcb_actions.h:204
static TOOL_ACTION drawZone
Definition: pcb_actions.h:209
static TOOL_ACTION lock
Definition: pcb_actions.h:544
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:556
void RefreshSearch()
void FocusSearch()
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:171
#define _(s)
EDA_UNITS
Definition: eda_units.h:48
@ 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:289
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:144
KICOMMON_API bool IsImperialUnit(EDA_UNITS aUnit)
Definition: eda_units.cpp:47
@ 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.
Definition: pgm_base.cpp:893
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.