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 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Units" ) )
141 .AddAction( ACTIONS::millimetersUnits )
142 .AddAction( ACTIONS::inchesUnits )
143 .AddAction( ACTIONS::milsUnits ) )
144 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Crosshair modes" ) )
147 .AddAction( ACTIONS::cursor45Crosshairs ) );
148
149 config.AppendSeparator()
150 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Line modes" ) )
151 .AddAction( PCB_ACTIONS::lineModeFree )
152 .AddAction( PCB_ACTIONS::lineMode90 )
153 .AddAction( PCB_ACTIONS::lineMode45 ) );
154
155 config.AppendSeparator()
156 .AppendAction( PCB_ACTIONS::showRatsnest )
157 .AppendAction( PCB_ACTIONS::ratsnestLineMode );
158
159 config.AppendSeparator()
160 .AppendAction( ACTIONS::highContrastMode )
161 .AppendAction( PCB_ACTIONS::toggleNetHighlight );
162
163 config.AppendSeparator()
164 .AppendAction( PCB_ACTIONS::zoneDisplayFilled )
165 .AppendAction( PCB_ACTIONS::zoneDisplayOutline );
166
167 if( ADVANCED_CFG::GetCfg().m_ExtraZoneDisplayModes )
168 {
171 }
172
173 config.AppendSeparator()
174 .AppendAction( PCB_ACTIONS::padDisplayMode )
175 .AppendAction( PCB_ACTIONS::viaDisplayMode )
176 .AppendAction( PCB_ACTIONS::trackDisplayMode );
177
178 if( ADVANCED_CFG::GetCfg().m_DrawBoundingBoxes )
179 config.AppendAction( ACTIONS::toggleBoundingBoxes );
180
181 // Tools to show/hide toolbars:
182 config.AppendSeparator()
183 .AppendAction( PCB_ACTIONS::showLayersManager )
184 .AppendAction( ACTIONS::showProperties );
185
186 /* TODO (ISM): Support context menus in toolbars
187 PCB_SELECTION_TOOL* selTool = m_toolManager->GetTool<PCB_SELECTION_TOOL>();
188 std::unique_ptr<ACTION_MENU> gridMenu = std::make_unique<ACTION_MENU>( false, selTool );
189 gridMenu->Add( ACTIONS::gridProperties );
190 gridMenu->Add( ACTIONS::gridOrigin );
191 m_tbLeft->AddToolContextMenu( ACTIONS::toggleGrid, std::move( gridMenu ) );
192 */
193 break;
194
196 config.AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Selection modes" ) )
197 .AddAction( ACTIONS::selectSetRect )
198 .AddAction( ACTIONS::selectSetLasso ) )
199 .AppendAction( PCB_ACTIONS::localRatsnestTool );
200
201 config.AppendSeparator()
202 .AppendAction( PCB_ACTIONS::placeFootprint )
203 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Track routing tools" ) )
205 .AddAction( PCB_ACTIONS::routeDiffPair ) )
206 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Track tuning tools" ) )
207 .AddAction( PCB_ACTIONS::tuneSingleTrack )
208 .AddAction( PCB_ACTIONS::tuneDiffPair )
209 .AddAction( PCB_ACTIONS::tuneSkew ) )
210 .AppendAction( PCB_ACTIONS::drawVia )
211 .AppendAction( PCB_ACTIONS::drawZone )
212 .AppendAction( PCB_ACTIONS::drawRuleArea );
213
214 config.AppendSeparator()
215 .AppendAction( PCB_ACTIONS::drawLine )
216 .AppendAction( PCB_ACTIONS::drawArc )
217 .AppendAction( PCB_ACTIONS::drawRectangle )
218 .AppendAction( PCB_ACTIONS::drawCircle )
219 .AppendAction( PCB_ACTIONS::drawPolygon )
220 .AppendAction( PCB_ACTIONS::drawBezier )
221 .AppendAction( PCB_ACTIONS::placeReferenceImage )
222 .AppendAction( PCB_ACTIONS::placeText )
223 .AppendAction( PCB_ACTIONS::drawTextBox )
224 .AppendAction( PCB_ACTIONS::drawTable )
225 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Dimension objects" ) )
230 .AddAction( PCB_ACTIONS::drawLeader ) )
231 .AppendAction( PCB_ACTIONS::placeBarcode )
232 .AppendAction( ACTIONS::deleteTool );
233
234 config.AppendSeparator()
235 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "PCB origins and points" ) )
236 .AddAction( ACTIONS::gridSetOrigin )
237 .AddAction( PCB_ACTIONS::drillOrigin ) )
238 .AppendAction( PCB_ACTIONS::placePoint )
239 .AppendAction( ACTIONS::measureTool );
240
241 /* TODO (ISM): Support context menus
242 PCB_SELECTION_TOOL* selTool = m_toolManager->GetTool<PCB_SELECTION_TOOL>();
243
244 auto makeArcMenu =
245 [&]()
246 {
247 std::unique_ptr<ACTION_MENU> arcMenu = std::make_unique<ACTION_MENU>( false, selTool );
248
249 arcMenu->Add( ACTIONS::pointEditorArcKeepCenter, ACTION_MENU::CHECK );
250 arcMenu->Add( ACTIONS::pointEditorArcKeepEndpoint, ACTION_MENU::CHECK );
251 arcMenu->Add( ACTIONS::pointEditorArcKeepRadius, ACTION_MENU::CHECK );
252
253 return arcMenu;
254 };
255
256 m_tbRight->AddToolContextMenu( PCB_ACTIONS::drawArc, makeArcMenu() );
257
258 auto makeRouteMenu =
259 [&]()
260 {
261 std::unique_ptr<ACTION_MENU> routeMenu = std::make_unique<ACTION_MENU>( false, selTool );
262
263 routeMenu->Add( PCB_ACTIONS::routerHighlightMode, ACTION_MENU::CHECK );
264 routeMenu->Add( PCB_ACTIONS::routerShoveMode, ACTION_MENU::CHECK );
265 routeMenu->Add( PCB_ACTIONS::routerWalkaroundMode, ACTION_MENU::CHECK );
266
267 routeMenu->AppendSeparator();
268 routeMenu->Add( PCB_ACTIONS::routerSettingsDialog );
269
270 return routeMenu;
271 };
272
273 m_tbRight->AddToolContextMenu( PCB_ACTIONS::routeSingleTrack, makeRouteMenu() );
274 m_tbRight->AddToolContextMenu( PCB_ACTIONS::routeDiffPair, makeRouteMenu() );
275
276 std::unique_ptr<ACTION_MENU> zoneMenu = std::make_unique<ACTION_MENU>( false, selTool );
277 zoneMenu->Add( PCB_ACTIONS::zoneFillAll );
278 zoneMenu->Add( PCB_ACTIONS::zoneUnfillAll );
279 m_tbRight->AddToolContextMenu( PCB_ACTIONS::drawZone, std::move( zoneMenu ) );
280
281 std::unique_ptr<ACTION_MENU> lineMenu = std::make_unique<ACTION_MENU>( false, selTool );
282 m_tbRight->AddToolContextMenu( PCB_ACTIONS::drawLine, std::move( lineMenu ) );
283 */
284 break;
285
287 if( Kiface().IsSingle() )
288 {
289 config.AppendAction( ACTIONS::doNew );
290 config.AppendAction( ACTIONS::open );
291 }
292
293 config.AppendAction( ACTIONS::save );
294
295 config.AppendSeparator()
296 .AppendAction( PCB_ACTIONS::boardSetup );
297
298 config.AppendSeparator()
299 .AppendAction( ACTIONS::pageSettings )
300 .AppendAction( ACTIONS::print )
301 .AppendAction( ACTIONS::plot );
302
303 config.AppendSeparator()
304 .AppendAction( ACTIONS::undo )
305 .AppendAction( ACTIONS::redo );
306
307 config.AppendSeparator()
308 .AppendAction( ACTIONS::find );
309
310 config.AppendSeparator()
311 .AppendAction( ACTIONS::zoomRedraw )
312 .AppendAction( ACTIONS::zoomInCenter )
313 .AppendAction( ACTIONS::zoomOutCenter )
314 .AppendAction( ACTIONS::zoomFitScreen )
315 .AppendAction( ACTIONS::zoomFitObjects )
316 .AppendAction( ACTIONS::zoomTool );
317
318 config.AppendSeparator()
319 .AppendAction( PCB_ACTIONS::rotateCcw )
320 .AppendAction( PCB_ACTIONS::rotateCw )
321 .AppendAction( PCB_ACTIONS::mirrorV )
322 .AppendAction( PCB_ACTIONS::mirrorH )
323 .AppendAction( ACTIONS::group )
324 .AppendAction( ACTIONS::ungroup )
325 .AppendAction( PCB_ACTIONS::lock )
326 .AppendAction( PCB_ACTIONS::unlock );
327
328 config.AppendSeparator()
329 .AppendAction( ACTIONS::showFootprintEditor )
330 .AppendAction( ACTIONS::showFootprintBrowser )
331 .AppendAction( ACTIONS::show3DViewer );
332
333 config.AppendSeparator();
334
335 if( !Kiface().IsSingle() )
337 else
338 config.AppendAction( PCB_ACTIONS::importNetlist );
339
340 config.AppendAction( PCB_ACTIONS::runDRC );
341
342 config.AppendSeparator();
343 config.AppendAction( PCB_ACTIONS::showEeschema );
344
346
347 break;
348
351 .AppendAction( PCB_ACTIONS::autoTrackWidth );
352
353 config.AppendSeparator()
355
356 config.AppendSeparator()
358 .AppendAction( PCB_ACTIONS::selectLayerPair );
359
360 config.AppendSeparator()
361 .AppendControl( ACTION_TOOLBAR_CONTROLS::gridSelect );
362
363 config.AppendSeparator()
364 .AppendControl( ACTION_TOOLBAR_CONTROLS::zoomSelect );
365
366 config.AppendSeparator()
368
369 break;
370 }
371
372 // clang-format on
373 return config;
374}
375
376
378{
380
381 // Box to display and choose track widths
382 auto trackWidthSelectorFactory =
383 [this]( ACTION_TOOLBAR* aToolbar )
384 {
385 if( !m_SelTrackWidthBox )
386 {
387 m_SelTrackWidthBox = new wxChoice( aToolbar, ID_AUX_TOOLBAR_PCB_TRACK_WIDTH,
388 wxDefaultPosition, wxDefaultSize, 0, nullptr );
389 }
390
391 m_SelTrackWidthBox->SetToolTip( _( "Select the default width for new tracks. Note that this "
392 "width can be overridden by the board minimum width, or by "
393 "the width of an existing track if the 'Use Existing Track "
394 "Width' feature is enabled." ) );
395
397
398 aToolbar->Add( m_SelTrackWidthBox );
399 };
400
402
403
404 // Box to display and choose vias diameters
405 auto viaDiaSelectorFactory =
406 [this]( ACTION_TOOLBAR* aToolbar )
407 {
408 if( !m_SelViaSizeBox )
409 {
410 m_SelViaSizeBox = new wxChoice( aToolbar, ID_AUX_TOOLBAR_PCB_VIA_SIZE,
411 wxDefaultPosition, wxDefaultSize, 0, nullptr );
412 }
413
415 aToolbar->Add( m_SelViaSizeBox );
416 };
417
419
420 // IPC/Scripting plugin control
421 // TODO (ISM): Clean this up to make IPC actions just normal tool actions to get rid of this entire
422 // control
423 auto pluginControlFactory =
424 [this]( ACTION_TOOLBAR* aToolbar )
425 {
426 // Add scripting console and API plugins
427 bool scriptingAvailable = SCRIPTING::IsWxAvailable();
428
429 #ifdef KICAD_IPC_API
430 bool haveApiPlugins = Pgm().GetCommonSettings()->m_Api.enable_server &&
431 !Pgm().GetPluginManager().GetActionsForScope( PluginActionScope() ).empty();
432 #else
433 bool haveApiPlugins = false;
434 #endif
435
436 if( scriptingAvailable || haveApiPlugins )
437 {
438 aToolbar->AddScaledSeparator( aToolbar->GetParent() );
439
440 if( scriptingAvailable )
441 {
442 aToolbar->Add( PCB_ACTIONS::showPythonConsole );
443 addActionPluginTools( aToolbar );
444 }
445
446 if( haveApiPlugins )
447 AddApiPluginTools( aToolbar );
448 }
449 };
450
452}
453
454
455static wxString ComboBoxUnits( EDA_UNITS aUnits, double aValue, bool aIncludeLabel = true )
456{
457 wxString text;
458 const wxChar* format;
459
460 switch( aUnits )
461 {
462 default:
463 wxASSERT_MSG( false, wxT( "Invalid unit" ) );
465 case EDA_UNITS::UNSCALED: format = wxT( "%.0f" ); break;
466 case EDA_UNITS::MM: format = wxT( "%.3f" ); break;
467 case EDA_UNITS::MILS: format = wxT( "%.2f" ); break;
468 case EDA_UNITS::INCH: format = wxT( "%.5f" ); break;
469 }
470
471 text.Printf( format, EDA_UNIT_UTILS::UI::ToUserUnit( pcbIUScale, aUnits, aValue ) );
472
473 if( aIncludeLabel )
475
476 return text;
477}
478
479
480void PCB_EDIT_FRAME::UpdateTrackWidthSelectBox( wxChoice* aTrackWidthSelectBox, bool aShowNetclass,
481 bool aShowEdit )
482{
483 if( aTrackWidthSelectBox == nullptr )
484 return;
485
486 EDA_UNITS primaryUnit;
487 EDA_UNITS secondaryUnit;
488
489 GetUnitPair( primaryUnit, secondaryUnit );
490
491 wxString msg;
492
493 aTrackWidthSelectBox->Clear();
494
495 if( aShowNetclass )
496 aTrackWidthSelectBox->Append( _( "Track: use netclass width" ) );
497
498 for( unsigned ii = 1; ii < GetDesignSettings().m_TrackWidthList.size(); ii++ )
499 {
500 int size = GetDesignSettings().m_TrackWidthList[ii];
501
502 msg.Printf( _( "Track: %s (%s)" ), ComboBoxUnits( primaryUnit, size ),
503 ComboBoxUnits( secondaryUnit, size ) );
504
505 aTrackWidthSelectBox->Append( msg );
506 }
507
508 if( aShowEdit )
509 {
510 aTrackWidthSelectBox->Append( wxT( "---" ) );
511 aTrackWidthSelectBox->Append( _( "Edit Pre-defined Sizes..." ) );
512 }
513
514 if( GetDesignSettings().GetTrackWidthIndex() >= (int) GetDesignSettings().m_TrackWidthList.size() )
516
517 // GetDesignSettings().GetTrackWidthIndex() can be < 0 if no board loaded
518 // So in this case select the first select box item available (use netclass)
519 aTrackWidthSelectBox->SetSelection( std::max( 0, GetDesignSettings().GetTrackWidthIndex() ) );
520}
521
522
523void PCB_EDIT_FRAME::UpdateViaSizeSelectBox( wxChoice* aViaSizeSelectBox, bool aShowNetclass,
524 bool aShowEdit )
525{
526 if( aViaSizeSelectBox == nullptr )
527 return;
528
529 aViaSizeSelectBox->Clear();
530
531 COMMON_TOOLS* cmnTool = m_toolManager->GetTool<COMMON_TOOLS>();
532 EDA_UNITS primaryUnit = GetUserUnits();
533 EDA_UNITS secondaryUnit = EDA_UNITS::MILS;
534
535 if( EDA_UNIT_UTILS::IsImperialUnit( primaryUnit ) )
536 secondaryUnit = cmnTool ? cmnTool->GetLastMetricUnits() : EDA_UNITS::MM;
537 else
538 secondaryUnit = cmnTool ? cmnTool->GetLastImperialUnits() : EDA_UNITS::MILS;
539
540 if( aShowNetclass )
541 aViaSizeSelectBox->Append( _( "Via: use netclass sizes" ) );
542
543 for( unsigned ii = 1; ii < GetDesignSettings().m_ViasDimensionsList.size(); ii++ )
544 {
546 wxString msg, priStr, secStr;
547
548 double diam = viaDimension.m_Diameter;
549 double hole = viaDimension.m_Drill;
550
551 if( hole > 0 )
552 {
553 priStr = ComboBoxUnits( primaryUnit, diam, false ) + wxT( " / " )
554 + ComboBoxUnits( primaryUnit, hole, true );
555 secStr = ComboBoxUnits( secondaryUnit, diam, false ) + wxT( " / " )
556 + ComboBoxUnits( secondaryUnit, hole, true );
557 }
558 else
559 {
560 priStr = ComboBoxUnits( primaryUnit, diam, true );
561 secStr = ComboBoxUnits( secondaryUnit, diam, true );
562 }
563
564 msg.Printf( _( "Via: %s (%s)" ), priStr, secStr );
565
566 aViaSizeSelectBox->Append( msg );
567 }
568
569 if( aShowEdit )
570 {
571 aViaSizeSelectBox->Append( wxT( "---" ) );
572 aViaSizeSelectBox->Append( _( "Edit Pre-defined Sizes..." ) );
573 }
574
575 if( GetDesignSettings().GetViaSizeIndex() >= (int) GetDesignSettings().m_ViasDimensionsList.size() )
577
578 // GetDesignSettings().GetViaSizeIndex() can be < 0 if no board loaded
579 // So in this case select the first select box item available (use netclass)
580 aViaSizeSelectBox->SetSelection( std::max( 0, GetDesignSettings().GetViaSizeIndex() ) );
581}
582
583
584void PCB_EDIT_FRAME::ReCreateLayerBox( bool aForceResizeToolbar )
585{
586 if( m_SelLayerBox == nullptr || m_tbTopAux == nullptr )
587 return;
588
589 m_SelLayerBox->SetToolTip( _( "+/- to switch" ) );
590 m_SelLayerBox->Resync();
591
592 if( aForceResizeToolbar )
594}
595
596
598{
600 wxAuiPaneInfo& layersManager = m_auimgr.GetPane( AppearancePanelName() );
601 wxAuiPaneInfo& selectionFilter = m_auimgr.GetPane( "SelectionFilter" );
602
603 // show auxiliary Vertical layers and visibility manager toolbar
604 m_show_layer_manager_tools = layersManager.IsShown();
605
607
608 layersManager.Show( m_show_layer_manager_tools );
609 selectionFilter.Show( m_show_layer_manager_tools );
610
612 {
613 SetAuiPaneSize( m_auimgr, layersManager, settings->m_AuiPanels.right_panel_width, -1 );
614 }
615 else
616 {
617 settings->m_AuiPanels.right_panel_width = m_appearancePanel->GetSize().x;
618 m_auimgr.Update();
619 }
620}
621
622
624{
626 wxAuiPaneInfo& netInspectorPanel = m_auimgr.GetPane( NetInspectorPanelName() );
627
628 m_show_net_inspector = netInspectorPanel.IsShown();
629
631
632 netInspectorPanel.Show( m_show_net_inspector );
633
635 {
636 SetAuiPaneSize( m_auimgr, netInspectorPanel, settings->m_AuiPanels.net_inspector_width, -1 );
637 m_netInspectorPanel->OnShowPanel();
638 }
639 else
640 {
641 m_netInspectorPanel->SaveSettings();
642 settings->m_AuiPanels.net_inspector_width = m_netInspectorPanel->GetSize().x;
643 m_auimgr.Update();
644 }
645}
646
647
649{
651
652 // Ensure m_show_search is up to date (the pane can be closed outside the menu)
653 m_show_search = m_auimgr.GetPane( SearchPaneName() ).IsShown();
654
656
657 wxAuiPaneInfo& searchPaneInfo = m_auimgr.GetPane( SearchPaneName() );
658 searchPaneInfo.Show( m_show_search );
659
660 if( m_show_search )
661 {
662 searchPaneInfo.Direction( settings->m_AuiPanels.search_panel_dock_direction );
663
664 if( settings->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_TOP
665 || settings->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_BOTTOM )
666 {
667 SetAuiPaneSize( m_auimgr, searchPaneInfo,
668 -1, settings->m_AuiPanels.search_panel_height );
669 }
670 else if( settings->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_LEFT
671 || settings->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_RIGHT )
672 {
673 SetAuiPaneSize( m_auimgr, searchPaneInfo,
674 settings->m_AuiPanels.search_panel_width, -1 );
675 }
676 m_searchPane->FocusSearch();
677 m_searchPane->RefreshSearch();
678 }
679 else
680 {
681 settings->m_AuiPanels.search_panel_height = m_searchPane->GetSize().y;
682 settings->m_AuiPanels.search_panel_width = m_searchPane->GetSize().x;
683 settings->m_AuiPanels.search_panel_dock_direction = searchPaneInfo.dock_direction;
684 m_auimgr.Update();
685 GetCanvas()->SetFocus();
686 }
687}
688
689
690void PCB_EDIT_FRAME::OnUpdateSelectTrackWidth( wxUpdateUIEvent& aEvent )
691{
692 if( aEvent.GetId() == ID_AUX_TOOLBAR_PCB_TRACK_WIDTH )
693 {
695 int sel;
696
697 if( bds.UseCustomTrackViaSize() )
698 sel = wxNOT_FOUND;
699 else
700 // if GetTrackWidthIndex() < 0, display the "use netclass" option
701 sel = std::max( 0, bds.GetTrackWidthIndex() );
702
703 if( m_SelTrackWidthBox->GetSelection() != sel )
704 m_SelTrackWidthBox->SetSelection( sel );
705 }
706}
707
708
709void PCB_EDIT_FRAME::OnUpdateSelectViaSize( wxUpdateUIEvent& aEvent )
710{
711 if( aEvent.GetId() == ID_AUX_TOOLBAR_PCB_VIA_SIZE )
712 {
714 int sel = 0;
715
716 if( bds.UseCustomTrackViaSize() )
717 sel = wxNOT_FOUND;
718 else
719 // if GetViaSizeIndex() < 0, display the "use netclass" option
720 sel = std::max( 0, bds.GetViaSizeIndex() );
721
722 if( m_SelViaSizeBox->GetSelection() != sel )
723 m_SelViaSizeBox->SetSelection( sel );
724 }
725}
726
727
729{
731
732 wxCHECK( cfg, /* void */ );
733
734 wxAuiPaneInfo& db_library_pane = m_auimgr.GetPane( DesignBlocksPaneName() );
735
736 db_library_pane.Show( !db_library_pane.IsShown() );
737
738 if( db_library_pane.IsShown() )
739 {
740 if( db_library_pane.IsFloating() )
741 {
742 db_library_pane.FloatingSize( cfg->m_AuiPanels.design_blocks_panel_float_width,
744 m_auimgr.Update();
745 }
747 {
748 // SetAuiPaneSize also updates m_auimgr
750 }
751 }
752 else
753 {
754 if( db_library_pane.IsFloating() )
755 {
756 cfg->m_AuiPanels.design_blocks_panel_float_width = db_library_pane.floating_size.x;
757 cfg->m_AuiPanels.design_blocks_panel_float_height = db_library_pane.floating_size.y;
758 }
759 else
760 {
762 }
763
764 m_auimgr.Update();
765 }
766}
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 lineModeFree
Unconstrained angle mode (icon lines_any)
static TOOL_ACTION drawRuleArea
static TOOL_ACTION drawBezier
static TOOL_ACTION placeText
static TOOL_ACTION drawOrthogonalDimension
static TOOL_ACTION drawRectangle
static TOOL_ACTION padDisplayMode
static TOOL_ACTION placeReferenceImage
static TOOL_ACTION 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 lineMode45
45-degree-or-orthogonal mode (icon hv45mode)
static TOOL_ACTION drillOrigin
static TOOL_ACTION tuneSkew
static TOOL_ACTION trackDisplayMode
static TOOL_ACTION selectLayerPair
static TOOL_ACTION zoneDisplayTriangulated
static TOOL_ACTION zoneDisplayFractured
static TOOL_ACTION drawVia
static TOOL_ACTION drawArc
static TOOL_ACTION runDRC
static TOOL_ACTION importNetlist
static TOOL_ACTION boardSetup
static TOOL_ACTION showEeschema
static TOOL_ACTION drawCenterDimension
static TOOL_ACTION lineMode90
90-degree-only mode (icon lines90)
static TOOL_ACTION zoneDisplayOutline
static TOOL_ACTION ratsnestLineMode
static TOOL_ACTION placeBarcode
static TOOL_ACTION placePoint
static TOOL_ACTION mirrorV
static TOOL_ACTION unlock
static TOOL_ACTION placeFootprint
static TOOL_ACTION routeSingleTrack
Activation of the Push and Shove router.
static TOOL_ACTION showPythonConsole
static TOOL_ACTION drawLine
static TOOL_ACTION localRatsnestTool
static TOOL_ACTION rotateCw
Rotation of selected objects.
static TOOL_ACTION rotateCcw
static TOOL_ACTION drawAlignedDimension
static TOOL_ACTION drawZone
static TOOL_ACTION lock
static ACTION_TOOLBAR_CONTROL trackWidth
static ACTION_TOOLBAR_CONTROL viaDiameter
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:537
TOOL_MANAGER * m_toolManager
#define _(s)
EDA_UNITS
Definition eda_units.h:48
@ LAYER_PCB_BACKGROUND
PCB background color.
Definition layer_ids.h:281
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:946
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.