KiCad PCB EDA Suite
Loading...
Searching...
No Matches
toolbars_pcb_editor.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2012 Jean-Pierre Charras, jp.charras at wanadoo.fr
5 * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <[email protected]>
6 * Copyright (C) 2012 Wayne Stambaugh <[email protected]>
7 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, you may find one here:
21 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
22 * or you may search the http://www.gnu.org website for the version 2 license,
23 * or you may write to the Free Software Foundation, Inc.,
24 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
25 */
26
27#include <memory>
28#include <string>
29
30#include <advanced_config.h>
32#include <bitmaps.h>
33#include <board.h>
35#include <kiface_base.h>
36#include <kiplatform/ui.h>
37#include <macros.h>
38#include <pcb_edit_frame.h>
40#include <pcbnew_id.h>
41#include <pcbnew_settings.h>
42#include <pgm_base.h>
44#include <router/router_tool.h>
46#include <tool/action_toolbar.h>
47#include <tool/actions.h>
48#include <tool/common_tools.h>
49#include <tool/tool_manager.h>
50#include <tools/pcb_actions.h>
60#include <wx/wupdlock.h>
61#include <wx/combobox.h>
62#include <toolbars_pcb_editor.h>
64
65#include "../scripting/python_scripting.h"
66
67
68/* Data to build the layer pair indicator button */
69static std::unique_ptr<wxBitmap> LayerPairBitmap;
70
71
72void PCB_EDIT_FRAME::PrepareLayerIndicator( bool aForceRebuild )
73{
74 COLOR4D top_color, bottom_color, background_color;
75 bool change = aForceRebuild;
76
77 int requested_scale = KiIconScale( this );
78
79 if( m_prevIconVal.previous_requested_scale != requested_scale )
80 {
82 change = true;
83 }
84
85 top_color = GetColorSettings()->GetColor( GetScreen()->m_Route_Layer_TOP );
86
88 {
90 change = true;
91 }
92
93 bottom_color = GetColorSettings()->GetColor( GetScreen()->m_Route_Layer_BOTTOM );
94
96 {
98 change = true;
99 }
100
101 background_color = GetColorSettings()->GetColor( LAYER_PCB_BACKGROUND );
102
103 if( m_prevIconVal.previous_background_color != background_color )
104 {
105 m_prevIconVal.previous_background_color = background_color;
106 change = true;
107 }
108
109 if( change || !LayerPairBitmap )
110 {
111 const int scale = ( requested_scale <= 0 ) ? KiIconScale( this ) : requested_scale;
112 LayerPairBitmap = LAYER_PRESENTATION::CreateLayerPairIcon( background_color, top_color,
113 bottom_color, scale );
114
115 if( m_tbTopAux )
116 {
118 m_tbTopAux->Refresh();
119 }
120 }
121}
122
123
124ACTION_TOOLBAR_CONTROL PCB_ACTION_TOOLBAR_CONTROLS::trackWidth( "control.PCBTrackWidth", _( "Track width selector" ),
125 _( "Control to select the track width" ) );
126ACTION_TOOLBAR_CONTROL PCB_ACTION_TOOLBAR_CONTROLS::viaDiameter( "control.PCBViaDia", _( "Via diameter selector" ),
127 _( "Control to select the via diameter" ) );
128
129
130std::optional<TOOLBAR_CONFIGURATION> PCB_EDIT_TOOLBAR_SETTINGS::DefaultToolbarConfig( TOOLBAR_LOC aToolbar )
131{
133
134 // clang-format off
135 switch( aToolbar )
136 {
137 case TOOLBAR_LOC::LEFT:
138 config.AppendAction( ACTIONS::toggleGrid )
139 .AppendAction( ACTIONS::toggleGridOverrides )
140 .AppendAction( PCB_ACTIONS::togglePolarCoords )
141 .AppendAction( ACTIONS::inchesUnits )
142 .AppendAction( ACTIONS::milsUnits )
143 .AppendAction( ACTIONS::millimetersUnits )
144 .AppendAction( ACTIONS::toggleCursorStyle );
145
146 config.AppendSeparator()
147 .AppendAction( PCB_ACTIONS::toggleHV45Mode );
148
149 config.AppendSeparator()
150 .AppendAction( PCB_ACTIONS::showRatsnest )
151 .AppendAction( PCB_ACTIONS::ratsnestLineMode );
152
153 config.AppendSeparator()
154 .AppendAction( ACTIONS::highContrastMode )
155 .AppendAction( PCB_ACTIONS::toggleNetHighlight );
156
157 config.AppendSeparator()
158 .AppendAction( PCB_ACTIONS::zoneDisplayFilled )
159 .AppendAction( PCB_ACTIONS::zoneDisplayOutline );
160
161 if( ADVANCED_CFG::GetCfg().m_ExtraZoneDisplayModes )
162 {
165 }
166
167 config.AppendSeparator()
168 .AppendAction( PCB_ACTIONS::padDisplayMode )
169 .AppendAction( PCB_ACTIONS::viaDisplayMode )
170 .AppendAction( PCB_ACTIONS::trackDisplayMode );
171
172 if( ADVANCED_CFG::GetCfg().m_DrawBoundingBoxes )
173 config.AppendAction( ACTIONS::toggleBoundingBoxes );
174
175 // Tools to show/hide toolbars:
176 config.AppendSeparator()
177 .AppendAction( PCB_ACTIONS::showLayersManager )
178 .AppendAction( ACTIONS::showProperties );
179
180 /* TODO (ISM): Support context menus in toolbars
181 PCB_SELECTION_TOOL* selTool = m_toolManager->GetTool<PCB_SELECTION_TOOL>();
182 std::unique_ptr<ACTION_MENU> gridMenu = std::make_unique<ACTION_MENU>( false, selTool );
183 gridMenu->Add( ACTIONS::gridProperties );
184 gridMenu->Add( ACTIONS::gridOrigin );
185 m_tbLeft->AddToolContextMenu( ACTIONS::toggleGrid, std::move( gridMenu ) );
186 */
187 break;
188
189 case TOOLBAR_LOC::RIGHT:
190 config.AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Selection modes" ) )
191 .AddAction( ACTIONS::selectSetRect )
192 .AddAction( ACTIONS::selectSetLasso ) )
193 .AppendAction( PCB_ACTIONS::localRatsnestTool );
194
195 config.AppendSeparator()
196 .AppendAction( PCB_ACTIONS::placeFootprint )
197 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Track routing tools" ) )
199 .AddAction( PCB_ACTIONS::routeDiffPair ) )
200 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Track tuning tools" ) )
201 .AddAction( PCB_ACTIONS::tuneSingleTrack )
202 .AddAction( PCB_ACTIONS::tuneDiffPair )
203 .AddAction( PCB_ACTIONS::tuneSkew ) )
204 .AppendAction( PCB_ACTIONS::drawVia )
205 .AppendAction( PCB_ACTIONS::drawZone )
206 .AppendAction( PCB_ACTIONS::drawRuleArea );
207
208 config.AppendSeparator()
209 .AppendAction( PCB_ACTIONS::drawLine )
210 .AppendAction( PCB_ACTIONS::drawArc )
211 .AppendAction( PCB_ACTIONS::drawRectangle )
212 .AppendAction( PCB_ACTIONS::drawCircle )
213 .AppendAction( PCB_ACTIONS::drawPolygon )
214 .AppendAction( PCB_ACTIONS::drawBezier )
215 .AppendAction( PCB_ACTIONS::placeReferenceImage )
216 .AppendAction( PCB_ACTIONS::placeText )
217 .AppendAction( PCB_ACTIONS::drawTextBox )
218 .AppendAction( PCB_ACTIONS::drawTable )
219 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Dimension objects" ) )
224 .AddAction( PCB_ACTIONS::drawLeader ) )
225 .AppendAction( ACTIONS::deleteTool );
226
227 config.AppendSeparator()
228 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "PCB origins" ) )
229 .AddAction( ACTIONS::gridSetOrigin )
230 .AddAction( PCB_ACTIONS::drillOrigin ) )
231 .AppendAction( ACTIONS::measureTool );
232
233 /* TODO (ISM): Support context menus
234 PCB_SELECTION_TOOL* selTool = m_toolManager->GetTool<PCB_SELECTION_TOOL>();
235
236 auto makeArcMenu = [&]()
237 {
238 std::unique_ptr<ACTION_MENU> arcMenu = std::make_unique<ACTION_MENU>( false, selTool );
239
240 arcMenu->Add( ACTIONS::pointEditorArcKeepCenter, ACTION_MENU::CHECK );
241 arcMenu->Add( ACTIONS::pointEditorArcKeepEndpoint, ACTION_MENU::CHECK );
242 arcMenu->Add( ACTIONS::pointEditorArcKeepRadius, ACTION_MENU::CHECK );
243
244 return arcMenu;
245 };
246
247 m_tbRight->AddToolContextMenu( PCB_ACTIONS::drawArc, makeArcMenu() );
248
249 auto makeRouteMenu = [&]()
250 {
251 std::unique_ptr<ACTION_MENU> routeMenu = std::make_unique<ACTION_MENU>( false, selTool );
252
253 routeMenu->Add( PCB_ACTIONS::routerHighlightMode, ACTION_MENU::CHECK );
254 routeMenu->Add( PCB_ACTIONS::routerShoveMode, ACTION_MENU::CHECK );
255 routeMenu->Add( PCB_ACTIONS::routerWalkaroundMode, ACTION_MENU::CHECK );
256
257 routeMenu->AppendSeparator();
258 routeMenu->Add( PCB_ACTIONS::routerSettingsDialog );
259
260 return routeMenu;
261 };
262
263 m_tbRight->AddToolContextMenu( PCB_ACTIONS::routeSingleTrack, makeRouteMenu() );
264 m_tbRight->AddToolContextMenu( PCB_ACTIONS::routeDiffPair, makeRouteMenu() );
265
266 std::unique_ptr<ACTION_MENU> zoneMenu = std::make_unique<ACTION_MENU>( false, selTool );
267 zoneMenu->Add( PCB_ACTIONS::zoneFillAll );
268 zoneMenu->Add( PCB_ACTIONS::zoneUnfillAll );
269 m_tbRight->AddToolContextMenu( PCB_ACTIONS::drawZone, std::move( zoneMenu ) );
270
271 std::unique_ptr<ACTION_MENU> lineMenu = std::make_unique<ACTION_MENU>( false, selTool );
272 m_tbRight->AddToolContextMenu( PCB_ACTIONS::drawLine, std::move( lineMenu ) );
273 */
274 break;
275
276 case TOOLBAR_LOC::TOP_MAIN:
277 if( Kiface().IsSingle() )
278 {
279 config.AppendAction( ACTIONS::doNew );
280 config.AppendAction( ACTIONS::open );
281 }
282
283 config.AppendAction( ACTIONS::save );
284
285 config.AppendSeparator()
286 .AppendAction( PCB_ACTIONS::boardSetup );
287
288 config.AppendSeparator()
289 .AppendAction( ACTIONS::pageSettings )
290 .AppendAction( ACTIONS::print )
291 .AppendAction( ACTIONS::plot );
292
293 config.AppendSeparator()
294 .AppendAction( ACTIONS::undo )
295 .AppendAction( ACTIONS::redo );
296
297 config.AppendSeparator()
298 .AppendAction( ACTIONS::find );
299
300 config.AppendSeparator()
301 .AppendAction( ACTIONS::zoomRedraw )
302 .AppendAction( ACTIONS::zoomInCenter )
303 .AppendAction( ACTIONS::zoomOutCenter )
304 .AppendAction( ACTIONS::zoomFitScreen )
305 .AppendAction( ACTIONS::zoomFitObjects )
306 .AppendAction( ACTIONS::zoomTool );
307
308 config.AppendSeparator()
309 .AppendAction( PCB_ACTIONS::rotateCcw )
310 .AppendAction( PCB_ACTIONS::rotateCw )
311 .AppendAction( PCB_ACTIONS::mirrorV )
312 .AppendAction( PCB_ACTIONS::mirrorH )
313 .AppendAction( ACTIONS::group )
314 .AppendAction( ACTIONS::ungroup )
315 .AppendAction( PCB_ACTIONS::lock )
316 .AppendAction( PCB_ACTIONS::unlock );
317
318 config.AppendSeparator()
319 .AppendAction( ACTIONS::showFootprintEditor )
320 .AppendAction( ACTIONS::showFootprintBrowser )
321 .AppendAction( ACTIONS::show3DViewer );
322
323 config.AppendSeparator();
324
325 if( !Kiface().IsSingle() )
327 else
328 config.AppendAction( PCB_ACTIONS::importNetlist );
329
330 config.AppendAction( PCB_ACTIONS::runDRC );
331
332 config.AppendSeparator();
333 config.AppendAction( PCB_ACTIONS::showEeschema );
334
336
337 break;
338
339 case TOOLBAR_LOC::TOP_AUX:
341 .AppendAction( PCB_ACTIONS::autoTrackWidth );
342
343 config.AppendSeparator()
345
346 config.AppendSeparator()
348 .AppendAction( PCB_ACTIONS::selectLayerPair );
349
350 config.AppendSeparator()
351 .AppendControl( ACTION_TOOLBAR_CONTROLS::gridSelect );
352
353 config.AppendSeparator()
354 .AppendControl( ACTION_TOOLBAR_CONTROLS::zoomSelect );
355
356 break;
357 }
358
359 // clang-format on
360 return config;
361}
362
363
365{
367
368 // Box to display and choose track widths
369 auto trackWidthSelectorFactory =
370 [this]( ACTION_TOOLBAR* aToolbar )
371 {
372 if( !m_SelTrackWidthBox )
373 {
374 m_SelTrackWidthBox = new wxChoice( aToolbar, ID_AUX_TOOLBAR_PCB_TRACK_WIDTH,
375 wxDefaultPosition, wxDefaultSize, 0, nullptr );
376 }
377
378 m_SelTrackWidthBox->SetToolTip( _( "Select the default width for new tracks. Note that this "
379 "width can be overridden by the board minimum width, or by "
380 "the width of an existing track if the 'Use Existing Track "
381 "Width' feature is enabled." ) );
382
384
385 aToolbar->Add( m_SelTrackWidthBox );
386 };
387
389
390
391 // Box to display and choose vias diameters
392 auto viaDiaSelectorFactory =
393 [this]( ACTION_TOOLBAR* aToolbar )
394 {
395 if( !m_SelViaSizeBox )
396 {
397 m_SelViaSizeBox = new wxChoice( aToolbar, ID_AUX_TOOLBAR_PCB_VIA_SIZE,
398 wxDefaultPosition, wxDefaultSize, 0, nullptr );
399 }
400
402 aToolbar->Add( m_SelViaSizeBox );
403 };
404
406
407 // IPC/Scripting plugin control
408 // TODO (ISM): Clean this up to make IPC actions just normal tool actions to get rid of this entire
409 // control
410 auto pluginControlFactory =
411 [this]( ACTION_TOOLBAR* aToolbar )
412 {
413 // Add scripting console and API plugins
414 bool scriptingAvailable = SCRIPTING::IsWxAvailable();
415
416 #ifdef KICAD_IPC_API
417 bool haveApiPlugins = Pgm().GetCommonSettings()->m_Api.enable_server &&
418 !Pgm().GetPluginManager().GetActionsForScope( PluginActionScope() ).empty();
419 #else
420 bool haveApiPlugins = false;
421 #endif
422
423 if( scriptingAvailable || haveApiPlugins )
424 {
425 aToolbar->AddScaledSeparator( aToolbar->GetParent() );
426
427 if( scriptingAvailable )
428 {
429 aToolbar->Add( PCB_ACTIONS::showPythonConsole );
430 addActionPluginTools( aToolbar );
431 }
432
433 if( haveApiPlugins )
434 AddApiPluginTools( aToolbar );
435 }
436 };
437
439}
440
441
442static wxString ComboBoxUnits( EDA_UNITS aUnits, double aValue, bool aIncludeLabel = true )
443{
444 wxString text;
445 const wxChar* format;
446
447 switch( aUnits )
448 {
449 default:
450 wxASSERT_MSG( false, wxT( "Invalid unit" ) );
452 case EDA_UNITS::UNSCALED: format = wxT( "%.0f" ); break;
453 case EDA_UNITS::MM: format = wxT( "%.3f" ); break;
454 case EDA_UNITS::MILS: format = wxT( "%.2f" ); break;
455 case EDA_UNITS::INCH: format = wxT( "%.5f" ); break;
456 }
457
458 text.Printf( format, EDA_UNIT_UTILS::UI::ToUserUnit( pcbIUScale, aUnits, aValue ) );
459
460 if( aIncludeLabel )
462
463 return text;
464}
465
466
467void PCB_EDIT_FRAME::UpdateTrackWidthSelectBox( wxChoice* aTrackWidthSelectBox, bool aShowNetclass,
468 bool aShowEdit )
469{
470 if( aTrackWidthSelectBox == nullptr )
471 return;
472
473 EDA_UNITS primaryUnit;
474 EDA_UNITS secondaryUnit;
475
476 GetUnitPair( primaryUnit, secondaryUnit );
477
478 wxString msg;
479
480 aTrackWidthSelectBox->Clear();
481
482 if( aShowNetclass )
483 aTrackWidthSelectBox->Append( _( "Track: use netclass width" ) );
484
485 for( unsigned ii = 1; ii < GetDesignSettings().m_TrackWidthList.size(); ii++ )
486 {
487 int size = GetDesignSettings().m_TrackWidthList[ii];
488
489 msg.Printf( _( "Track: %s (%s)" ), ComboBoxUnits( primaryUnit, size ),
490 ComboBoxUnits( secondaryUnit, size ) );
491
492 aTrackWidthSelectBox->Append( msg );
493 }
494
495 if( aShowEdit )
496 {
497 aTrackWidthSelectBox->Append( wxT( "---" ) );
498 aTrackWidthSelectBox->Append( _( "Edit Pre-defined Sizes..." ) );
499 }
500
501 if( GetDesignSettings().GetTrackWidthIndex() >= GetDesignSettings().m_TrackWidthList.size() )
503
504 aTrackWidthSelectBox->SetSelection( GetDesignSettings().GetTrackWidthIndex() );
505}
506
507
508void PCB_EDIT_FRAME::UpdateViaSizeSelectBox( wxChoice* aViaSizeSelectBox, bool aShowNetclass,
509 bool aShowEdit )
510{
511 if( aViaSizeSelectBox == nullptr )
512 return;
513
514 aViaSizeSelectBox->Clear();
515
517 EDA_UNITS primaryUnit = GetUserUnits();
518 EDA_UNITS secondaryUnit = EDA_UNITS::MILS;
519
520 if( EDA_UNIT_UTILS::IsImperialUnit( primaryUnit ) )
521 secondaryUnit = cmnTool ? cmnTool->GetLastMetricUnits() : EDA_UNITS::MM;
522 else
523 secondaryUnit = cmnTool ? cmnTool->GetLastImperialUnits() : EDA_UNITS::MILS;
524
525 if( aShowNetclass )
526 aViaSizeSelectBox->Append( _( "Via: use netclass sizes" ) );
527
528 for( unsigned ii = 1; ii < GetDesignSettings().m_ViasDimensionsList.size(); ii++ )
529 {
531 wxString msg, priStr, secStr;
532
533 double diam = viaDimension.m_Diameter;
534 double hole = viaDimension.m_Drill;
535
536 if( hole > 0 )
537 {
538 priStr = ComboBoxUnits( primaryUnit, diam, false ) + wxT( " / " )
539 + ComboBoxUnits( primaryUnit, hole, true );
540 secStr = ComboBoxUnits( secondaryUnit, diam, false ) + wxT( " / " )
541 + ComboBoxUnits( secondaryUnit, hole, true );
542 }
543 else
544 {
545 priStr = ComboBoxUnits( primaryUnit, diam, true );
546 secStr = ComboBoxUnits( secondaryUnit, diam, true );
547 }
548
549 msg.Printf( _( "Via: %s (%s)" ), priStr, secStr );
550
551 aViaSizeSelectBox->Append( msg );
552 }
553
554 if( aShowEdit )
555 {
556 aViaSizeSelectBox->Append( wxT( "---" ) );
557 aViaSizeSelectBox->Append( _( "Edit Pre-defined Sizes..." ) );
558 }
559
560 if( GetDesignSettings().GetViaSizeIndex() >= GetDesignSettings().m_ViasDimensionsList.size() )
562
563 aViaSizeSelectBox->SetSelection( GetDesignSettings().GetViaSizeIndex() );
564}
565
566
567void PCB_EDIT_FRAME::ReCreateLayerBox( bool aForceResizeToolbar )
568{
569 if( m_SelLayerBox == nullptr || m_tbTopAux == nullptr )
570 return;
571
572 m_SelLayerBox->SetToolTip( _( "+/- to switch" ) );
574
575 if( aForceResizeToolbar )
577}
578
579
581{
583 wxAuiPaneInfo& layersManager = m_auimgr.GetPane( AppearancePanelName() );
584 wxAuiPaneInfo& selectionFilter = m_auimgr.GetPane( "SelectionFilter" );
585
586 // show auxiliary Vertical layers and visibility manager toolbar
587 m_show_layer_manager_tools = layersManager.IsShown();
588
590
591 layersManager.Show( m_show_layer_manager_tools );
592 selectionFilter.Show( m_show_layer_manager_tools );
593
595 {
596 SetAuiPaneSize( m_auimgr, layersManager, settings->m_AuiPanels.right_panel_width, -1 );
597 }
598 else
599 {
600 settings->m_AuiPanels.right_panel_width = m_appearancePanel->GetSize().x;
601 m_auimgr.Update();
602 }
603}
604
605
607{
609 wxAuiPaneInfo& netInspectorPanel = m_auimgr.GetPane( NetInspectorPanelName() );
610
611 m_show_net_inspector = netInspectorPanel.IsShown();
612
614
615 netInspectorPanel.Show( m_show_net_inspector );
616
618 {
619 SetAuiPaneSize( m_auimgr, netInspectorPanel, settings->m_AuiPanels.net_inspector_width,
620 -1 );
622 }
623 else
624 {
626 settings->m_AuiPanels.net_inspector_width = m_netInspectorPanel->GetSize().x;
627 m_auimgr.Update();
628 }
629}
630
631
633{
635
636 // Ensure m_show_search is up to date (the pane can be closed outside the menu)
637 m_show_search = m_auimgr.GetPane( SearchPaneName() ).IsShown();
638
640
641 wxAuiPaneInfo& searchPaneInfo = m_auimgr.GetPane( SearchPaneName() );
642 searchPaneInfo.Show( m_show_search );
643
644 if( m_show_search )
645 {
646 searchPaneInfo.Direction( settings->m_AuiPanels.search_panel_dock_direction );
647
648 if( settings->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_TOP
649 || settings->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_BOTTOM )
650 {
651 SetAuiPaneSize( m_auimgr, searchPaneInfo,
652 -1, settings->m_AuiPanels.search_panel_height );
653 }
654 else if( settings->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_LEFT
655 || settings->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_RIGHT )
656 {
657 SetAuiPaneSize( m_auimgr, searchPaneInfo,
658 settings->m_AuiPanels.search_panel_width, -1 );
659 }
662 }
663 else
664 {
665 settings->m_AuiPanels.search_panel_height = m_searchPane->GetSize().y;
666 settings->m_AuiPanels.search_panel_width = m_searchPane->GetSize().x;
667 settings->m_AuiPanels.search_panel_dock_direction = searchPaneInfo.dock_direction;
668 m_auimgr.Update();
669 GetCanvas()->SetFocus();
670 }
671}
672
673
674void PCB_EDIT_FRAME::OnUpdateSelectTrackWidth( wxUpdateUIEvent& aEvent )
675{
676 if( aEvent.GetId() == ID_AUX_TOOLBAR_PCB_TRACK_WIDTH )
677 {
679 int sel;
680
681 if( bds.UseCustomTrackViaSize() )
682 sel = wxNOT_FOUND;
683 else
684 sel = bds.GetTrackWidthIndex();
685
686 if( m_SelTrackWidthBox->GetSelection() != sel )
687 m_SelTrackWidthBox->SetSelection( sel );
688 }
689}
690
691
692void PCB_EDIT_FRAME::OnUpdateSelectViaSize( wxUpdateUIEvent& aEvent )
693{
694 if( aEvent.GetId() == ID_AUX_TOOLBAR_PCB_VIA_SIZE )
695 {
697 int sel = 0;
698
699 if( bds.UseCustomTrackViaSize() )
700 sel = wxNOT_FOUND;
701 else
702 sel = bds.GetViaSizeIndex();
703
704 if( m_SelViaSizeBox->GetSelection() != sel )
705 m_SelViaSizeBox->SetSelection( sel );
706 }
707}
708
709
711{
713
714 wxCHECK( cfg, /* void */ );
715
716 wxAuiPaneInfo& db_library_pane = m_auimgr.GetPane( DesignBlocksPaneName() );
717
718 db_library_pane.Show( !db_library_pane.IsShown() );
719
720 if( db_library_pane.IsShown() )
721 {
722 if( db_library_pane.IsFloating() )
723 {
724 db_library_pane.FloatingSize( cfg->m_AuiPanels.design_blocks_panel_float_width,
726 m_auimgr.Update();
727 }
729 {
730 // SetAuiPaneSize also updates m_auimgr
732 }
733 }
734 else
735 {
736 if( db_library_pane.IsFloating() )
737 {
738 cfg->m_AuiPanels.design_blocks_panel_float_width = db_library_pane.floating_size.x;
739 cfg->m_AuiPanels.design_blocks_panel_float_height = db_library_pane.floating_size.y;
740 }
741 else
742 {
744 }
745
746 m_auimgr.Update();
747 }
748}
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:261
static TOOL_ACTION toggleGrid
Definition: actions.h:195
static TOOL_ACTION zoomRedraw
Definition: actions.h:131
static TOOL_ACTION millimetersUnits
Definition: actions.h:203
static TOOL_ACTION show3DViewer
Definition: actions.h:255
static TOOL_ACTION zoomOutCenter
Definition: actions.h:135
static TOOL_ACTION togglePolarCoords
Definition: actions.h:206
static TOOL_ACTION selectSetLasso
Definition: actions.h:218
static TOOL_ACTION selectSetRect
Set lasso selection mode.
Definition: actions.h:217
static TOOL_ACTION group
Definition: actions.h:236
static TOOL_ACTION milsUnits
Definition: actions.h:202
static TOOL_ACTION ungroup
Definition: actions.h:237
static TOOL_ACTION toggleBoundingBoxes
Definition: actions.h:154
static TOOL_ACTION plot
Definition: actions.h:65
static TOOL_ACTION open
Definition: actions.h:57
static TOOL_ACTION pageSettings
Definition: actions.h:63
static TOOL_ACTION undo
Definition: actions.h:75
static TOOL_ACTION inchesUnits
Definition: actions.h:201
static TOOL_ACTION highContrastMode
Definition: actions.h:152
static TOOL_ACTION toggleCursorStyle
Definition: actions.h:151
static TOOL_ACTION measureTool
Definition: actions.h:249
static TOOL_ACTION save
Definition: actions.h:58
static TOOL_ACTION zoomFitScreen
Definition: actions.h:141
static TOOL_ACTION redo
Definition: actions.h:76
static TOOL_ACTION deleteTool
Definition: actions.h:86
static TOOL_ACTION zoomTool
Definition: actions.h:145
static TOOL_ACTION showFootprintEditor
Definition: actions.h:259
static TOOL_ACTION print
Definition: actions.h:64
static TOOL_ACTION showProperties
Definition: actions.h:263
static TOOL_ACTION doNew
Definition: actions.h:54
static TOOL_ACTION zoomFitObjects
Definition: actions.h:142
static TOOL_ACTION zoomInCenter
Definition: actions.h:134
static TOOL_ACTION gridSetOrigin
Definition: actions.h:192
static TOOL_ACTION showFootprintBrowser
Definition: actions.h:258
static TOOL_ACTION toggleGridOverrides
Definition: actions.h:196
static TOOL_ACTION find
Definition: actions.h:116
static ACTION_TOOLBAR_CONTROL gridSelect
static ACTION_TOOLBAR_CONTROL layerSelector
static ACTION_TOOLBAR_CONTROL zoomSelect
static ACTION_TOOLBAR_CONTROL ipcScripting
Class to hold basic information about controls that can be added to the toolbars.
Define the structure of a toolbar with buttons that invoke ACTIONs.
void SetToolBitmap(const TOOL_ACTION &aAction, const wxBitmap &aBitmap)
Updates the bitmap of a particular tool.
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
Container for design settings for a BOARD object.
void UseCustomTrackViaSize(bool aEnabled)
Enables/disables custom track/via size settings.
void SetTrackWidthIndex(unsigned aIndex)
Set the current track width list index to aIndex.
void SetViaSizeIndex(unsigned aIndex)
Set the current via size list index to aIndex.
unsigned GetTrackWidthIndex() const
unsigned GetViaSizeIndex() const
std::vector< int > m_TrackWidthList
std::vector< VIA_DIMENSION > m_ViasDimensionsList
COLOR4D GetColor(int aLayer) const
Handles action that are shared between different applications.
Definition: common_tools.h:38
EDA_UNITS GetLastImperialUnits()
Definition: common_tools.h:79
EDA_UNITS GetLastMetricUnits()
Definition: common_tools.h:78
virtual void UpdateToolbarControlSizes()
Update the sizes of any controls in the toolbars of the frame.
void RegisterCustomToolbarControlFactory(const ACTION_TOOLBAR_CONTROL &aControlDesc, const ACTION_TOOLBAR_CONTROL_FACTORY &aControlFactory)
Register a creation factory for toolbar controls that are present in this frame.
wxAuiManager m_auimgr
ACTION_TOOLBAR * m_tbTopAux
static const wxString AppearancePanelName()
NET_INSPECTOR_PANEL * m_netInspectorPanel
virtual void AddApiPluginTools(ACTION_TOOLBAR *aToolbar)
Append actions from API plugins to the given toolbar.
static const wxString NetInspectorPanelName()
void GetUnitPair(EDA_UNITS &aPrimaryUnit, EDA_UNITS &aSecondaryUnits) override
Get the pair or units in current use.
SEARCH_PANE * m_searchPane
static const wxString DesignBlocksPaneName()
void SetFocus() override
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
static std::unique_ptr< wxBitmap > CreateLayerPairIcon(const KIGFX::COLOR4D &aBgColor, const KIGFX::COLOR4D &aTopColor, const KIGFX::COLOR4D &aBottomColor, int aScale)
Create a layer pair "side-by-side swatch" icon.
virtual void SaveSettings()
Save the net inspector settings - called from EDA_EDIT_FRAME when hiding the panel.
virtual void OnShowPanel()
Prepare the panel when (re-)shown in the editor.
AUI_PANELS m_AuiPanels
static TOOL_ACTION toggleHV45Mode
Definition: pcb_actions.h:539
static TOOL_ACTION drawRuleArea
Definition: pcb_actions.h:211
static TOOL_ACTION drawBezier
Definition: pcb_actions.h:194
static TOOL_ACTION placeText
Definition: pcb_actions.h:196
static TOOL_ACTION drawOrthogonalDimension
Definition: pcb_actions.h:207
static TOOL_ACTION drawRectangle
Definition: pcb_actions.h:191
static TOOL_ACTION padDisplayMode
Definition: pcb_actions.h:319
static TOOL_ACTION placeReferenceImage
Definition: pcb_actions.h:195
static TOOL_ACTION showRatsnest
Definition: pcb_actions.h:314
static TOOL_ACTION showLayersManager
Definition: pcb_actions.h:451
static TOOL_ACTION toggleNetHighlight
Definition: pcb_actions.h:568
static TOOL_ACTION drawCircle
Definition: pcb_actions.h:192
static TOOL_ACTION mirrorH
Mirroring of selected items.
Definition: pcb_actions.h:125
static TOOL_ACTION routeDiffPair
Activation of the Push and Shove router (differential pair mode)
Definition: pcb_actions.h:245
static TOOL_ACTION tuneDiffPair
Definition: pcb_actions.h:248
static TOOL_ACTION autoTrackWidth
Definition: pcb_actions.h:384
static TOOL_ACTION drawTable
Definition: pcb_actions.h:198
static TOOL_ACTION drawTextBox
Definition: pcb_actions.h:197
static TOOL_ACTION drawPolygon
Definition: pcb_actions.h:190
static TOOL_ACTION zoneDisplayFilled
Definition: pcb_actions.h:321
static TOOL_ACTION drawRadialDimension
Definition: pcb_actions.h:206
static TOOL_ACTION tuneSingleTrack
Definition: pcb_actions.h:247
static TOOL_ACTION viaDisplayMode
Definition: pcb_actions.h:320
static TOOL_ACTION drawLeader
Definition: pcb_actions.h:208
static TOOL_ACTION drillOrigin
Definition: pcb_actions.h:550
static TOOL_ACTION tuneSkew
Definition: pcb_actions.h:249
static TOOL_ACTION trackDisplayMode
Definition: pcb_actions.h:318
static TOOL_ACTION selectLayerPair
Definition: pcb_actions.h:180
static TOOL_ACTION zoneDisplayTriangulated
Definition: pcb_actions.h:324
static TOOL_ACTION zoneDisplayFractured
Definition: pcb_actions.h:323
static TOOL_ACTION drawVia
Definition: pcb_actions.h:210
static TOOL_ACTION drawArc
Definition: pcb_actions.h:193
static TOOL_ACTION runDRC
Definition: pcb_actions.h:446
static TOOL_ACTION importNetlist
Definition: pcb_actions.h:411
static TOOL_ACTION boardSetup
Definition: pcb_actions.h:409
static TOOL_ACTION showEeschema
Definition: pcb_actions.h:553
static TOOL_ACTION drawCenterDimension
Definition: pcb_actions.h:205
static TOOL_ACTION zoneDisplayOutline
Definition: pcb_actions.h:322
static TOOL_ACTION ratsnestLineMode
Definition: pcb_actions.h:315
static TOOL_ACTION mirrorV
Definition: pcb_actions.h:126
static TOOL_ACTION unlock
Definition: pcb_actions.h:544
static TOOL_ACTION placeFootprint
Definition: pcb_actions.h:216
static TOOL_ACTION routeSingleTrack
Activation of the Push and Shove router.
Definition: pcb_actions.h:242
static TOOL_ACTION showPythonConsole
Definition: pcb_actions.h:453
static TOOL_ACTION drawLine
Definition: pcb_actions.h:189
static TOOL_ACTION localRatsnestTool
Definition: pcb_actions.h:575
static TOOL_ACTION rotateCw
Rotation of selected objects.
Definition: pcb_actions.h:118
static TOOL_ACTION rotateCcw
Definition: pcb_actions.h:119
static TOOL_ACTION drawAlignedDimension
Definition: pcb_actions.h:204
static TOOL_ACTION drawZone
Definition: pcb_actions.h:209
static TOOL_ACTION lock
Definition: pcb_actions.h:543
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:565
void RefreshSearch()
void FocusSearch()
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:171
#define _(s)
EDA_UNITS
Definition: eda_units.h:48
@ LAYER_PCB_BACKGROUND
PCB background color.
Definition: layer_ids.h:280
This file contains miscellaneous commonly used macros and functions.
#define KI_FALLTHROUGH
The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely fallthrough from ...
Definition: macros.h:83
KICOMMON_API double ToUserUnit(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnit, double aValue)
Convert aValue in internal units to the appropriate user units defined by aUnit.
Definition: eda_units.cpp:289
KICOMMON_API wxString GetText(EDA_UNITS aUnits, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
Get the units string for a given units type.
Definition: eda_units.cpp:144
KICOMMON_API bool IsImperialUnit(EDA_UNITS aUnit)
Definition: eda_units.cpp:47
@ ID_AUX_TOOLBAR_PCB_VIA_SIZE
Definition: pcbnew_id.h:17
@ ID_AUX_TOOLBAR_PCB_TRACK_WIDTH
Definition: pcbnew_id.h:18
int GetUserUnits()
Return the currently selected user unit value for the interface.
PGM_BASE & Pgm()
The global program "get" accessor.
Definition: pgm_base.cpp:902
see class PGM_BASE
const int scale
Container to handle a stock of specific vias each with unique diameter and drill sizes in the BOARD c...
static wxString ComboBoxUnits(EDA_UNITS aUnits, double aValue, bool aIncludeLabel=true)
static std::unique_ptr< wxBitmap > LayerPairBitmap
void SetAuiPaneSize(wxAuiManager &aManager, wxAuiPaneInfo &aPane, int aWidth, int aHeight)
Sets the size of an AUI pane, working around http://trac.wxwidgets.org/ticket/13180.