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