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 std::unique_ptr<ACTION_MENU> arcMenu = std::make_unique<ACTION_MENU>( false, selTool );
247
248 arcMenu->Add( ACTIONS::pointEditorArcKeepCenter, ACTION_MENU::CHECK );
249 arcMenu->Add( ACTIONS::pointEditorArcKeepEndpoint, ACTION_MENU::CHECK );
250 arcMenu->Add( ACTIONS::pointEditorArcKeepRadius, ACTION_MENU::CHECK );
251
252 return arcMenu;
253 };
254
255 m_tbRight->AddToolContextMenu( PCB_ACTIONS::drawArc, makeArcMenu() );
256
257 auto makeRouteMenu = [&]()
258 {
259 std::unique_ptr<ACTION_MENU> routeMenu = std::make_unique<ACTION_MENU>( false, selTool );
260
261 routeMenu->Add( PCB_ACTIONS::routerHighlightMode, ACTION_MENU::CHECK );
262 routeMenu->Add( PCB_ACTIONS::routerShoveMode, ACTION_MENU::CHECK );
263 routeMenu->Add( PCB_ACTIONS::routerWalkaroundMode, ACTION_MENU::CHECK );
264
265 routeMenu->AppendSeparator();
266 routeMenu->Add( PCB_ACTIONS::routerSettingsDialog );
267
268 return routeMenu;
269 };
270
271 m_tbRight->AddToolContextMenu( PCB_ACTIONS::routeSingleTrack, makeRouteMenu() );
272 m_tbRight->AddToolContextMenu( PCB_ACTIONS::routeDiffPair, makeRouteMenu() );
273
274 std::unique_ptr<ACTION_MENU> zoneMenu = std::make_unique<ACTION_MENU>( false, selTool );
275 zoneMenu->Add( PCB_ACTIONS::zoneFillAll );
276 zoneMenu->Add( PCB_ACTIONS::zoneUnfillAll );
277 m_tbRight->AddToolContextMenu( PCB_ACTIONS::drawZone, std::move( zoneMenu ) );
278
279 std::unique_ptr<ACTION_MENU> lineMenu = std::make_unique<ACTION_MENU>( false, selTool );
280 m_tbRight->AddToolContextMenu( PCB_ACTIONS::drawLine, std::move( lineMenu ) );
281 */
282 break;
283
285 if( Kiface().IsSingle() )
286 {
287 config.AppendAction( ACTIONS::doNew );
288 config.AppendAction( ACTIONS::open );
289 }
290
291 config.AppendAction( ACTIONS::save );
292
293 config.AppendSeparator()
294 .AppendAction( PCB_ACTIONS::boardSetup );
295
296 config.AppendSeparator()
297 .AppendAction( ACTIONS::pageSettings )
298 .AppendAction( ACTIONS::print )
299 .AppendAction( ACTIONS::plot );
300
301 config.AppendSeparator()
302 .AppendAction( ACTIONS::undo )
303 .AppendAction( ACTIONS::redo );
304
305 config.AppendSeparator()
306 .AppendAction( ACTIONS::find );
307
308 config.AppendSeparator()
309 .AppendAction( ACTIONS::zoomRedraw )
310 .AppendAction( ACTIONS::zoomInCenter )
311 .AppendAction( ACTIONS::zoomOutCenter )
312 .AppendAction( ACTIONS::zoomFitScreen )
313 .AppendAction( ACTIONS::zoomFitObjects )
314 .AppendAction( ACTIONS::zoomTool );
315
316 config.AppendSeparator()
317 .AppendAction( PCB_ACTIONS::rotateCcw )
318 .AppendAction( PCB_ACTIONS::rotateCw )
319 .AppendAction( PCB_ACTIONS::mirrorV )
320 .AppendAction( PCB_ACTIONS::mirrorH )
321 .AppendAction( ACTIONS::group )
322 .AppendAction( ACTIONS::ungroup )
323 .AppendAction( PCB_ACTIONS::lock )
324 .AppendAction( PCB_ACTIONS::unlock );
325
326 config.AppendSeparator()
327 .AppendAction( ACTIONS::showFootprintEditor )
328 .AppendAction( ACTIONS::showFootprintBrowser )
329 .AppendAction( ACTIONS::show3DViewer );
330
331 config.AppendSeparator();
332
333 if( !Kiface().IsSingle() )
335 else
336 config.AppendAction( PCB_ACTIONS::importNetlist );
337
338 config.AppendAction( PCB_ACTIONS::runDRC );
339
340 config.AppendSeparator();
341 config.AppendAction( PCB_ACTIONS::showEeschema );
342
344
345 break;
346
349 .AppendAction( PCB_ACTIONS::autoTrackWidth );
350
351 config.AppendSeparator()
353
354 config.AppendSeparator()
356 .AppendAction( PCB_ACTIONS::selectLayerPair );
357
358 config.AppendSeparator()
359 .AppendControl( ACTION_TOOLBAR_CONTROLS::gridSelect );
360
361 config.AppendSeparator()
362 .AppendControl( ACTION_TOOLBAR_CONTROLS::zoomSelect );
363
364 config.AppendSeparator()
366
367 break;
368 }
369
370 // clang-format on
371 return config;
372}
373
374
376{
378
379 // Box to display and choose track widths
380 auto trackWidthSelectorFactory =
381 [this]( ACTION_TOOLBAR* aToolbar )
382 {
383 if( !m_SelTrackWidthBox )
384 {
385 m_SelTrackWidthBox = new wxChoice( aToolbar, ID_AUX_TOOLBAR_PCB_TRACK_WIDTH,
386 wxDefaultPosition, wxDefaultSize, 0, nullptr );
387 }
388
389 m_SelTrackWidthBox->SetToolTip( _( "Select the default width for new tracks. Note that this "
390 "width can be overridden by the board minimum width, or by "
391 "the width of an existing track if the 'Use Existing Track "
392 "Width' feature is enabled." ) );
393
395
396 aToolbar->Add( m_SelTrackWidthBox );
397 };
398
400
401
402 // Box to display and choose vias diameters
403 auto viaDiaSelectorFactory =
404 [this]( ACTION_TOOLBAR* aToolbar )
405 {
406 if( !m_SelViaSizeBox )
407 {
408 m_SelViaSizeBox = new wxChoice( aToolbar, ID_AUX_TOOLBAR_PCB_VIA_SIZE,
409 wxDefaultPosition, wxDefaultSize, 0, nullptr );
410 }
411
413 aToolbar->Add( m_SelViaSizeBox );
414 };
415
417
418 // IPC/Scripting plugin control
419 // TODO (ISM): Clean this up to make IPC actions just normal tool actions to get rid of this entire
420 // control
421 auto pluginControlFactory =
422 [this]( ACTION_TOOLBAR* aToolbar )
423 {
424 // Add scripting console and API plugins
425 bool scriptingAvailable = SCRIPTING::IsWxAvailable();
426
427 #ifdef KICAD_IPC_API
428 bool haveApiPlugins = Pgm().GetCommonSettings()->m_Api.enable_server &&
429 !Pgm().GetPluginManager().GetActionsForScope( PluginActionScope() ).empty();
430 #else
431 bool haveApiPlugins = false;
432 #endif
433
434 if( scriptingAvailable || haveApiPlugins )
435 {
436 aToolbar->AddScaledSeparator( aToolbar->GetParent() );
437
438 if( scriptingAvailable )
439 {
440 aToolbar->Add( PCB_ACTIONS::showPythonConsole );
441 addActionPluginTools( aToolbar );
442 }
443
444 if( haveApiPlugins )
445 AddApiPluginTools( aToolbar );
446 }
447 };
448
450}
451
452
453static wxString ComboBoxUnits( EDA_UNITS aUnits, double aValue, bool aIncludeLabel = true )
454{
455 wxString text;
456 const wxChar* format;
457
458 switch( aUnits )
459 {
460 default:
461 wxASSERT_MSG( false, wxT( "Invalid unit" ) );
463 case EDA_UNITS::UNSCALED: format = wxT( "%.0f" ); break;
464 case EDA_UNITS::MM: format = wxT( "%.3f" ); break;
465 case EDA_UNITS::MILS: format = wxT( "%.2f" ); break;
466 case EDA_UNITS::INCH: format = wxT( "%.5f" ); break;
467 }
468
469 text.Printf( format, EDA_UNIT_UTILS::UI::ToUserUnit( pcbIUScale, aUnits, aValue ) );
470
471 if( aIncludeLabel )
473
474 return text;
475}
476
477
478void PCB_EDIT_FRAME::UpdateTrackWidthSelectBox( wxChoice* aTrackWidthSelectBox, bool aShowNetclass,
479 bool aShowEdit )
480{
481 if( aTrackWidthSelectBox == nullptr )
482 return;
483
484 EDA_UNITS primaryUnit;
485 EDA_UNITS secondaryUnit;
486
487 GetUnitPair( primaryUnit, secondaryUnit );
488
489 wxString msg;
490
491 aTrackWidthSelectBox->Clear();
492
493 if( aShowNetclass )
494 aTrackWidthSelectBox->Append( _( "Track: use netclass width" ) );
495
496 for( unsigned ii = 1; ii < GetDesignSettings().m_TrackWidthList.size(); ii++ )
497 {
498 int size = GetDesignSettings().m_TrackWidthList[ii];
499
500 msg.Printf( _( "Track: %s (%s)" ), ComboBoxUnits( primaryUnit, size ),
501 ComboBoxUnits( secondaryUnit, size ) );
502
503 aTrackWidthSelectBox->Append( msg );
504 }
505
506 if( aShowEdit )
507 {
508 aTrackWidthSelectBox->Append( wxT( "---" ) );
509 aTrackWidthSelectBox->Append( _( "Edit Pre-defined Sizes..." ) );
510 }
511
512 if( GetDesignSettings().GetTrackWidthIndex() >= (int) GetDesignSettings().m_TrackWidthList.size() )
514
515 aTrackWidthSelectBox->SetSelection( GetDesignSettings().GetTrackWidthIndex() );
516}
517
518
519void PCB_EDIT_FRAME::UpdateViaSizeSelectBox( wxChoice* aViaSizeSelectBox, bool aShowNetclass,
520 bool aShowEdit )
521{
522 if( aViaSizeSelectBox == nullptr )
523 return;
524
525 aViaSizeSelectBox->Clear();
526
527 COMMON_TOOLS* cmnTool = m_toolManager->GetTool<COMMON_TOOLS>();
528 EDA_UNITS primaryUnit = GetUserUnits();
529 EDA_UNITS secondaryUnit = EDA_UNITS::MILS;
530
531 if( EDA_UNIT_UTILS::IsImperialUnit( primaryUnit ) )
532 secondaryUnit = cmnTool ? cmnTool->GetLastMetricUnits() : EDA_UNITS::MM;
533 else
534 secondaryUnit = cmnTool ? cmnTool->GetLastImperialUnits() : EDA_UNITS::MILS;
535
536 if( aShowNetclass )
537 aViaSizeSelectBox->Append( _( "Via: use netclass sizes" ) );
538
539 for( unsigned ii = 1; ii < GetDesignSettings().m_ViasDimensionsList.size(); ii++ )
540 {
542 wxString msg, priStr, secStr;
543
544 double diam = viaDimension.m_Diameter;
545 double hole = viaDimension.m_Drill;
546
547 if( hole > 0 )
548 {
549 priStr = ComboBoxUnits( primaryUnit, diam, false ) + wxT( " / " )
550 + ComboBoxUnits( primaryUnit, hole, true );
551 secStr = ComboBoxUnits( secondaryUnit, diam, false ) + wxT( " / " )
552 + ComboBoxUnits( secondaryUnit, hole, true );
553 }
554 else
555 {
556 priStr = ComboBoxUnits( primaryUnit, diam, true );
557 secStr = ComboBoxUnits( secondaryUnit, diam, true );
558 }
559
560 msg.Printf( _( "Via: %s (%s)" ), priStr, secStr );
561
562 aViaSizeSelectBox->Append( msg );
563 }
564
565 if( aShowEdit )
566 {
567 aViaSizeSelectBox->Append( wxT( "---" ) );
568 aViaSizeSelectBox->Append( _( "Edit Pre-defined Sizes..." ) );
569 }
570
571 if( GetDesignSettings().GetViaSizeIndex() >= (int) GetDesignSettings().m_ViasDimensionsList.size() )
573
574 aViaSizeSelectBox->SetSelection( GetDesignSettings().GetViaSizeIndex() );
575}
576
577
578void PCB_EDIT_FRAME::ReCreateLayerBox( bool aForceResizeToolbar )
579{
580 if( m_SelLayerBox == nullptr || m_tbTopAux == nullptr )
581 return;
582
583 m_SelLayerBox->SetToolTip( _( "+/- to switch" ) );
584 m_SelLayerBox->Resync();
585
586 if( aForceResizeToolbar )
588}
589
590
592{
594 wxAuiPaneInfo& layersManager = m_auimgr.GetPane( AppearancePanelName() );
595 wxAuiPaneInfo& selectionFilter = m_auimgr.GetPane( "SelectionFilter" );
596
597 // show auxiliary Vertical layers and visibility manager toolbar
598 m_show_layer_manager_tools = layersManager.IsShown();
599
601
602 layersManager.Show( m_show_layer_manager_tools );
603 selectionFilter.Show( m_show_layer_manager_tools );
604
606 {
607 SetAuiPaneSize( m_auimgr, layersManager, settings->m_AuiPanels.right_panel_width, -1 );
608 }
609 else
610 {
611 settings->m_AuiPanels.right_panel_width = m_appearancePanel->GetSize().x;
612 m_auimgr.Update();
613 }
614}
615
616
618{
620 wxAuiPaneInfo& netInspectorPanel = m_auimgr.GetPane( NetInspectorPanelName() );
621
622 m_show_net_inspector = netInspectorPanel.IsShown();
623
625
626 netInspectorPanel.Show( m_show_net_inspector );
627
629 {
630 SetAuiPaneSize( m_auimgr, netInspectorPanel, settings->m_AuiPanels.net_inspector_width, -1 );
631 m_netInspectorPanel->OnShowPanel();
632 }
633 else
634 {
635 m_netInspectorPanel->SaveSettings();
636 settings->m_AuiPanels.net_inspector_width = m_netInspectorPanel->GetSize().x;
637 m_auimgr.Update();
638 }
639}
640
641
643{
645
646 // Ensure m_show_search is up to date (the pane can be closed outside the menu)
647 m_show_search = m_auimgr.GetPane( SearchPaneName() ).IsShown();
648
650
651 wxAuiPaneInfo& searchPaneInfo = m_auimgr.GetPane( SearchPaneName() );
652 searchPaneInfo.Show( m_show_search );
653
654 if( m_show_search )
655 {
656 searchPaneInfo.Direction( settings->m_AuiPanels.search_panel_dock_direction );
657
658 if( settings->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_TOP
659 || settings->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_BOTTOM )
660 {
661 SetAuiPaneSize( m_auimgr, searchPaneInfo,
662 -1, settings->m_AuiPanels.search_panel_height );
663 }
664 else if( settings->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_LEFT
665 || settings->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_RIGHT )
666 {
667 SetAuiPaneSize( m_auimgr, searchPaneInfo,
668 settings->m_AuiPanels.search_panel_width, -1 );
669 }
670 m_searchPane->FocusSearch();
671 m_searchPane->RefreshSearch();
672 }
673 else
674 {
675 settings->m_AuiPanels.search_panel_height = m_searchPane->GetSize().y;
676 settings->m_AuiPanels.search_panel_width = m_searchPane->GetSize().x;
677 settings->m_AuiPanels.search_panel_dock_direction = searchPaneInfo.dock_direction;
678 m_auimgr.Update();
679 GetCanvas()->SetFocus();
680 }
681}
682
683
684void PCB_EDIT_FRAME::OnUpdateSelectTrackWidth( wxUpdateUIEvent& aEvent )
685{
686 if( aEvent.GetId() == ID_AUX_TOOLBAR_PCB_TRACK_WIDTH )
687 {
689 int sel;
690
691 if( bds.UseCustomTrackViaSize() )
692 sel = wxNOT_FOUND;
693 else
694 sel = bds.GetTrackWidthIndex();
695
696 if( m_SelTrackWidthBox->GetSelection() != sel )
697 m_SelTrackWidthBox->SetSelection( sel );
698 }
699}
700
701
702void PCB_EDIT_FRAME::OnUpdateSelectViaSize( wxUpdateUIEvent& aEvent )
703{
704 if( aEvent.GetId() == ID_AUX_TOOLBAR_PCB_VIA_SIZE )
705 {
707 int sel = 0;
708
709 if( bds.UseCustomTrackViaSize() )
710 sel = wxNOT_FOUND;
711 else
712 sel = bds.GetViaSizeIndex();
713
714 if( m_SelViaSizeBox->GetSelection() != sel )
715 m_SelViaSizeBox->SetSelection( sel );
716 }
717}
718
719
721{
723
724 wxCHECK( cfg, /* void */ );
725
726 wxAuiPaneInfo& db_library_pane = m_auimgr.GetPane( DesignBlocksPaneName() );
727
728 db_library_pane.Show( !db_library_pane.IsShown() );
729
730 if( db_library_pane.IsShown() )
731 {
732 if( db_library_pane.IsFloating() )
733 {
734 db_library_pane.FloatingSize( cfg->m_AuiPanels.design_blocks_panel_float_width,
736 m_auimgr.Update();
737 }
739 {
740 // SetAuiPaneSize also updates m_auimgr
742 }
743 }
744 else
745 {
746 if( db_library_pane.IsFloating() )
747 {
748 cfg->m_AuiPanels.design_blocks_panel_float_width = db_library_pane.floating_size.x;
749 cfg->m_AuiPanels.design_blocks_panel_float_height = db_library_pane.floating_size.y;
750 }
751 else
752 {
754 }
755
756 m_auimgr.Update();
757 }
758}
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:576
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: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.