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 <eda_text.h>
36#include <footprint.h>
37#include <pcb_field.h>
38#include <kiface_base.h>
39#include <kiplatform/ui.h>
40#include <macros.h>
41#include <pcb_edit_frame.h>
42#include <pcb_field.h>
44#include <pcbnew_id.h>
45#include <pcbnew_settings.h>
46#include <eda_text.h>
47#include <pcb_field.h>
48#include <pgm_base.h>
51#include <router/router_tool.h>
53#include <tool/action_menu.h>
54#include <tool/action_toolbar.h>
55#include <tool/actions.h>
56#include <tool/common_tools.h>
57#include <tool/tool_manager.h>
59#include <tools/pcb_actions.h>
69#include <wx/wupdlock.h>
70#include <wx/combobox.h>
71#include <toolbars_pcb_editor.h>
73#include <eda_text.h>
74#include <tools/pcb_control.h>
75
76#include "../scripting/python_scripting.h"
77
78
79/* Data to build the layer pair indicator button */
80static wxBitmapBundle LayerPairBitmap;
81
82
83void PCB_EDIT_FRAME::PrepareLayerIndicator( bool aForceRebuild )
84{
85 COLOR4D top_color, bottom_color, background_color;
86 bool change = aForceRebuild;
87
89
90 if( m_prevIconVal.previous_icon_size != icon_size )
91 {
92 m_prevIconVal.previous_icon_size = icon_size;
93 change = true;
94 }
95
96 top_color = GetColorSettings()->GetColor( GetScreen()->m_Route_Layer_TOP );
97
98 if( m_prevIconVal.previous_Route_Layer_TOP_color != top_color )
99 {
100 m_prevIconVal.previous_Route_Layer_TOP_color = top_color;
101 change = true;
102 }
103
104 bottom_color = GetColorSettings()->GetColor( GetScreen()->m_Route_Layer_BOTTOM );
105
106 if( m_prevIconVal.previous_Route_Layer_BOTTOM_color != bottom_color )
107 {
108 m_prevIconVal.previous_Route_Layer_BOTTOM_color = bottom_color;
109 change = true;
110 }
111
112 if( change || !LayerPairBitmap.IsOk() )
113 {
114 LayerPairBitmap = LAYER_PRESENTATION::CreateLayerPairIcon( top_color, bottom_color, icon_size );
115
116 if( m_tbTopAux )
117 {
119 m_tbTopAux->Refresh();
120 }
121 }
122}
123
124
126 _( "Track width selector" ),
127 _( "Control to select the track width" ),
128 { FRAME_PCB_EDITOR } );
130 _( "Via diameter selector" ),
131 _( "Control to select the via diameter" ),
132 { FRAME_PCB_EDITOR } );
134 _( "Current variant" ),
135 _( "Control to select the current variant" ),
136 { FRAME_PCB_EDITOR } );
137
138
139std::optional<TOOLBAR_CONFIGURATION> PCB_EDIT_TOOLBAR_SETTINGS::DefaultToolbarConfig( TOOLBAR_LOC aToolbar )
140{
142
143 // clang-format off
144 switch( aToolbar )
145 {
147 config.AppendAction( ACTIONS::toggleGrid )
148 .WithContextMenu(
149 []( TOOL_MANAGER* aMgr ) -> std::unique_ptr<ACTION_MENU>
150 {
152 std::unique_ptr<ACTION_MENU> menu =
153 std::make_unique<ACTION_MENU>( false, selTool );
154
155 menu->Add( ACTIONS::gridProperties );
156 menu->Add( ACTIONS::gridOrigin );
157
158 return menu;
159 } )
160 .AppendAction( ACTIONS::toggleGridOverrides )
161 .AppendAction( PCB_ACTIONS::togglePolarCoords )
162 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Units" ) )
163 .AddAction( ACTIONS::millimetersUnits )
164 .AddAction( ACTIONS::inchesUnits )
165 .AddAction( ACTIONS::milsUnits ) )
166 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Crosshair modes" ) )
169 .AddAction( ACTIONS::cursor45Crosshairs ) );
170
171 config.AppendSeparator()
172 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Line modes" ) )
173 .AddAction( PCB_ACTIONS::lineModeFree )
174 .AddAction( PCB_ACTIONS::lineMode90 )
175 .AddAction( PCB_ACTIONS::lineMode45 ) );
176
177 config.AppendSeparator()
178 .AppendAction( PCB_ACTIONS::showRatsnest )
179 .AppendAction( PCB_ACTIONS::ratsnestLineMode );
180
181 config.AppendSeparator()
182 .AppendAction( ACTIONS::highContrastMode )
183 .AppendAction( PCB_ACTIONS::toggleNetHighlight );
184
185 config.AppendSeparator()
186 .AppendAction( PCB_ACTIONS::zoneDisplayFilled )
187 .AppendAction( PCB_ACTIONS::zoneDisplayOutline );
188
189 if( ADVANCED_CFG::GetCfg().m_ExtraZoneDisplayModes )
190 {
193 }
194
195 config.AppendSeparator()
196 .AppendAction( PCB_ACTIONS::padDisplayMode )
197 .AppendAction( PCB_ACTIONS::viaDisplayMode )
198 .AppendAction( PCB_ACTIONS::trackDisplayMode );
199
200 if( ADVANCED_CFG::GetCfg().m_DrawBoundingBoxes )
201 config.AppendAction( ACTIONS::toggleBoundingBoxes );
202
203 // Tools to show/hide toolbars:
204 config.AppendSeparator()
205 .AppendAction( PCB_ACTIONS::showLayersManager )
206 .AppendAction( ACTIONS::showProperties );
207
208 break;
209
211 config.AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Selection modes" ) )
212 .AddAction( ACTIONS::selectSetRect )
213 .AddAction( ACTIONS::selectSetLasso ) )
214 .AppendAction( PCB_ACTIONS::localRatsnestTool );
215
216 config.AppendSeparator()
217 .AppendAction( PCB_ACTIONS::placeFootprint )
218 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Track routing tools" ) )
220 .AddAction( PCB_ACTIONS::routeDiffPair )
221 .AddContextMenu(
222 []( TOOL_MANAGER* aMgr ) -> std::unique_ptr<ACTION_MENU>
223 {
225 std::unique_ptr<ACTION_MENU> menu =
226 std::make_unique<ACTION_MENU>( false, selTool );
227
231 menu->AppendSeparator();
233
234 return menu;
235 } ) )
236 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Track tuning tools" ) )
237 .AddAction( PCB_ACTIONS::tuneSingleTrack )
238 .AddAction( PCB_ACTIONS::tuneDiffPair )
239 .AddAction( PCB_ACTIONS::tuneSkew ) )
240 .AppendAction( PCB_ACTIONS::drawVia )
241 .AppendAction( PCB_ACTIONS::drawZone )
242 .WithContextMenu(
243 []( TOOL_MANAGER* aMgr ) -> std::unique_ptr<ACTION_MENU>
244 {
246 std::unique_ptr<ACTION_MENU> menu =
247 std::make_unique<ACTION_MENU>( false, selTool );
248
249 menu->Add( PCB_ACTIONS::zoneFillAll );
250 menu->Add( PCB_ACTIONS::zoneUnfillAll );
251
252 return menu;
253 } )
254 .AppendAction( PCB_ACTIONS::drawRuleArea );
255
256 config.AppendSeparator()
257 .AppendAction( PCB_ACTIONS::drawLine )
258 .AppendAction( PCB_ACTIONS::drawArc )
259 .WithContextMenu(
260 []( TOOL_MANAGER* aMgr ) -> std::unique_ptr<ACTION_MENU>
261 {
263 std::unique_ptr<ACTION_MENU> menu =
264 std::make_unique<ACTION_MENU>( false, selTool );
265
269
270 return menu;
271 } )
272 .AppendAction( PCB_ACTIONS::drawRectangle )
273 .AppendAction( PCB_ACTIONS::drawCircle )
274 .AppendAction( PCB_ACTIONS::drawPolygon )
275 .AppendAction( PCB_ACTIONS::drawBezier )
276 .AppendAction( PCB_ACTIONS::placeReferenceImage )
277 .AppendAction( PCB_ACTIONS::placeText )
278 .AppendAction( PCB_ACTIONS::drawTextBox )
279 .AppendAction( PCB_ACTIONS::drawTable )
280 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Dimension objects" ) )
285 .AddAction( PCB_ACTIONS::drawLeader ) )
286 .AppendAction( PCB_ACTIONS::placeBarcode )
287 .AppendAction( ACTIONS::deleteTool );
288
289 config.AppendSeparator()
290 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "PCB origins and points" ) )
291 .AddAction( ACTIONS::gridSetOrigin )
292 .AddAction( PCB_ACTIONS::drillOrigin ) )
293 .AppendAction( PCB_ACTIONS::placePoint )
294 .AppendAction( ACTIONS::measureTool );
295
296 break;
297
299 if( Kiface().IsSingle() )
300 {
301 config.AppendAction( ACTIONS::doNew );
302 config.AppendAction( ACTIONS::open );
303 }
304
305 config.AppendAction( ACTIONS::save );
306
307 config.AppendSeparator()
308 .AppendAction( PCB_ACTIONS::boardSetup );
309
310 config.AppendSeparator()
311 .AppendAction( ACTIONS::pageSettings )
312 .AppendAction( ACTIONS::print )
313 .AppendAction( ACTIONS::plot );
314
315 config.AppendSeparator()
316 .AppendAction( ACTIONS::undo )
317 .AppendAction( ACTIONS::redo );
318
319 config.AppendSeparator()
320 .AppendAction( ACTIONS::find );
321
322 config.AppendSeparator()
323 .AppendAction( ACTIONS::zoomRedraw )
324 .AppendAction( ACTIONS::zoomInCenter )
325 .AppendAction( ACTIONS::zoomOutCenter )
326 .AppendAction( ACTIONS::zoomFitScreen )
327 .AppendAction( ACTIONS::zoomFitObjects )
328 .AppendAction( ACTIONS::zoomTool );
329
330 config.AppendSeparator()
331 .AppendAction( PCB_ACTIONS::rotateCcw )
332 .AppendAction( PCB_ACTIONS::rotateCw )
333 .AppendAction( PCB_ACTIONS::mirrorV )
334 .AppendAction( PCB_ACTIONS::mirrorH )
335 .AppendAction( ACTIONS::group )
336 .AppendAction( ACTIONS::ungroup )
337 .AppendAction( PCB_ACTIONS::lock )
338 .AppendAction( PCB_ACTIONS::unlock );
339
340 config.AppendSeparator()
341 .AppendAction( ACTIONS::showFootprintEditor )
342 .AppendAction( ACTIONS::showFootprintBrowser )
343 .AppendAction( ACTIONS::show3DViewer );
344
345 config.AppendSeparator();
346
347 if( !Kiface().IsSingle() )
349 else
350 config.AppendAction( PCB_ACTIONS::importNetlist );
351
352 config.AppendAction( PCB_ACTIONS::runDRC );
353
354 config.AppendSeparator();
355 config.AppendAction( PCB_ACTIONS::showEeschema );
358
359 break;
360
363 .AppendAction( PCB_ACTIONS::autoTrackWidth );
364
365 config.AppendSeparator()
367
368 config.AppendSeparator()
370 .AppendAction( PCB_ACTIONS::selectLayerPair );
371
372 config.AppendSeparator()
373 .AppendControl( ACTION_TOOLBAR_CONTROLS::gridSelect );
374
375 config.AppendSeparator()
376 .AppendControl( ACTION_TOOLBAR_CONTROLS::zoomSelect );
377
378 config.AppendSeparator()
380
381 break;
382 }
383
384 // clang-format on
385 return config;
386}
387
388
390{
392
393 // Box to display and choose track widths
394 auto trackWidthSelectorFactory =
395 [this]( ACTION_TOOLBAR* aToolbar )
396 {
397 if( !m_SelTrackWidthBox )
398 {
399 m_SelTrackWidthBox = new wxChoice( aToolbar, ID_AUX_TOOLBAR_PCB_TRACK_WIDTH,
400 wxDefaultPosition, wxDefaultSize, 0, nullptr );
401 }
402
403 m_SelTrackWidthBox->SetToolTip( _( "Select the default width for new tracks. Note that this "
404 "width can be overridden by the board minimum width, or by "
405 "the width of an existing track if the 'Use Existing Track "
406 "Width' feature is enabled." ) );
407
409
410 aToolbar->Add( m_SelTrackWidthBox );
411 };
412
414
415
416 // Box to display and choose vias diameters
417 auto viaDiaSelectorFactory =
418 [this]( ACTION_TOOLBAR* aToolbar )
419 {
420 if( !m_SelViaSizeBox )
421 {
422 m_SelViaSizeBox = new wxChoice( aToolbar, ID_AUX_TOOLBAR_PCB_VIA_SIZE,
423 wxDefaultPosition, wxDefaultSize, 0, nullptr );
424 }
425
427 aToolbar->Add( m_SelViaSizeBox );
428 };
429
431
432 // Variant selection drop down control on main tool bar
433 auto variantSelectionCtrlFactory =
434 [this]( ACTION_TOOLBAR* aToolbar )
435 {
437 {
439 wxDefaultPosition, wxDefaultSize, 0, nullptr );
440 }
441
442 m_CurrentVariantCtrl->SetToolTip( _( "Select the current variant to display and edit." ) );
443
445
446 aToolbar->Add( m_CurrentVariantCtrl );
447 };
448
450
451 // IPC/Scripting plugin control
452 // TODO (ISM): Clean this up to make IPC actions just normal tool actions to get rid of this entire
453 // control
454 auto pluginControlFactory =
455 [this]( ACTION_TOOLBAR* aToolbar )
456 {
457 // Add scripting console and API plugins
458 bool scriptingAvailable = SCRIPTING::IsWxAvailable();
459
460#ifdef KICAD_IPC_API
461 bool haveApiPlugins = Pgm().GetCommonSettings()->m_Api.enable_server
462 && !Pgm().GetPluginManager().GetActionsForScope( PluginActionScope() ).empty();
463#else
464 bool haveApiPlugins = false;
465#endif
466
467 if( scriptingAvailable || haveApiPlugins )
468 {
469 aToolbar->AddScaledSeparator( aToolbar->GetParent() );
470
471 if( scriptingAvailable )
472 {
473 aToolbar->Add( PCB_ACTIONS::showPythonConsole );
474 addActionPluginTools( aToolbar );
475 }
476
477 if( haveApiPlugins )
478 AddApiPluginTools( aToolbar );
479 }
480 };
481
483}
484
485
487{
489
490 switch( aId )
491 {
493 case ID_AUX_TOOLBAR_PCB_VIA_SIZE: m_SelViaSizeBox = nullptr; break;
495 }
496}
497
498
500{
502 return;
503
504 if( !GetBoard() )
505 return;
506
507 wxArrayString variantNames = GetBoard()->GetVariantNamesForUI();
508
509 m_CurrentVariantCtrl->Set( variantNames );
510
511 int selectionIndex = 0;
512 wxString currentVariant = GetBoard()->GetCurrentVariant();
513
514 if( !currentVariant.IsEmpty() )
515 {
516 int foundIndex = m_CurrentVariantCtrl->FindString( currentVariant );
517
518 if( foundIndex != wxNOT_FOUND )
519 selectionIndex = foundIndex;
520 }
521
522 if( m_CurrentVariantCtrl->GetCount() > 0 )
523 m_CurrentVariantCtrl->SetSelection( selectionIndex );
524}
525
526
527void PCB_EDIT_FRAME::onVariantSelected( wxCommandEvent& aEvent )
528{
530 return;
531
532 int selection = m_CurrentVariantCtrl->GetSelection();
533
534 if( selection == wxNOT_FOUND || selection == 0 )
535 {
536 // "<Default>" selected - clear the current variant
537 GetBoard()->SetCurrentVariant( wxEmptyString );
538 }
539 else
540 {
541 wxString selectedVariant = m_CurrentVariantCtrl->GetString( selection );
542 GetBoard()->SetCurrentVariant( selectedVariant );
543 }
544
545 // Refresh the view and properties panel to show the new variant state
547
549 [&]( KIGFX::VIEW_ITEM* aItem ) -> int
550 {
551 if( EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aItem ) )
552 {
553 if( text->HasTextVars() )
554 {
555 text->ClearRenderCache();
556 text->ClearBoundingBoxCache();
558 }
559 }
560
561 if( PCB_FIELD* field = dynamic_cast<PCB_FIELD*>( aItem ) )
562 {
563 if( FOOTPRINT* fp = field->GetParentFootprint() )
564 {
565 if( !fp->GetVariants().empty() )
566 {
567 field->ClearRenderCache();
568 field->ClearBoundingBoxCache();
570 }
571 }
572 }
573
574 return 0;
575 } );
576
577 GetCanvas()->Refresh();
578
579 Update3DView( true, GetPcbNewSettings()->m_Display.m_Live3DRefresh );
581}
582
583
584static wxString ComboBoxUnits( EDA_UNITS aUnits, double aValue, bool aIncludeLabel = true )
585{
586 wxString text;
587 const wxChar* format;
588
589 switch( aUnits )
590 {
591 default:
592 wxASSERT_MSG( false, wxT( "Invalid unit" ) );
594 case EDA_UNITS::UNSCALED: format = wxT( "%.0f" ); break;
595 case EDA_UNITS::MM: format = wxT( "%.3f" ); break;
596 case EDA_UNITS::MILS: format = wxT( "%.2f" ); break;
597 case EDA_UNITS::INCH: format = wxT( "%.5f" ); break;
598 }
599
600 text.Printf( format, EDA_UNIT_UTILS::UI::ToUserUnit( pcbIUScale, aUnits, aValue ) );
601
602 if( aIncludeLabel )
604
605 return text;
606}
607
608
609void PCB_EDIT_FRAME::UpdateTrackWidthSelectBox( wxChoice* aTrackWidthSelectBox, bool aShowNetclass,
610 bool aShowEdit )
611{
612 if( aTrackWidthSelectBox == nullptr )
613 return;
614
615 EDA_UNITS primaryUnit;
616 EDA_UNITS secondaryUnit;
617
618 GetUnitPair( primaryUnit, secondaryUnit );
619
620 wxString msg;
621
622 aTrackWidthSelectBox->Clear();
623
624 if( aShowNetclass )
625 aTrackWidthSelectBox->Append( _( "Track: use netclass width" ) );
626
627 for( unsigned ii = 1; ii < GetDesignSettings().m_TrackWidthList.size(); ii++ )
628 {
629 int size = GetDesignSettings().m_TrackWidthList[ii];
630
631 msg.Printf( _( "Track: %s (%s)" ), ComboBoxUnits( primaryUnit, size ),
632 ComboBoxUnits( secondaryUnit, size ) );
633
634 aTrackWidthSelectBox->Append( msg );
635 }
636
637 if( aShowEdit )
638 {
639 aTrackWidthSelectBox->Append( wxT( "---" ) );
640 aTrackWidthSelectBox->Append( _( "Edit Pre-defined Sizes..." ) );
641 }
642
643 if( GetDesignSettings().GetTrackWidthIndex() >= (int) GetDesignSettings().m_TrackWidthList.size() )
645
646 // GetDesignSettings().GetTrackWidthIndex() can be < 0 if no board loaded
647 // So in this case select the first select box item available (use netclass)
648 aTrackWidthSelectBox->SetSelection( std::max( 0, GetDesignSettings().GetTrackWidthIndex() ) );
649}
650
651
652void PCB_EDIT_FRAME::UpdateViaSizeSelectBox( wxChoice* aViaSizeSelectBox, bool aShowNetclass,
653 bool aShowEdit )
654{
655 if( aViaSizeSelectBox == nullptr )
656 return;
657
658 aViaSizeSelectBox->Clear();
659
660 COMMON_TOOLS* cmnTool = m_toolManager->GetTool<COMMON_TOOLS>();
661 EDA_UNITS primaryUnit = GetUserUnits();
662 EDA_UNITS secondaryUnit = EDA_UNITS::MILS;
663
664 if( EDA_UNIT_UTILS::IsImperialUnit( primaryUnit ) )
665 secondaryUnit = cmnTool ? cmnTool->GetLastMetricUnits() : EDA_UNITS::MM;
666 else
667 secondaryUnit = cmnTool ? cmnTool->GetLastImperialUnits() : EDA_UNITS::MILS;
668
669 if( aShowNetclass )
670 aViaSizeSelectBox->Append( _( "Via: use netclass sizes" ) );
671
672 for( unsigned ii = 1; ii < GetDesignSettings().m_ViasDimensionsList.size(); ii++ )
673 {
675 wxString msg, priStr, secStr;
676
677 double diam = viaDimension.m_Diameter;
678 double hole = viaDimension.m_Drill;
679
680 if( hole > 0 )
681 {
682 priStr = ComboBoxUnits( primaryUnit, diam, false ) + wxT( " / " )
683 + ComboBoxUnits( primaryUnit, hole, true );
684 secStr = ComboBoxUnits( secondaryUnit, diam, false ) + wxT( " / " )
685 + ComboBoxUnits( secondaryUnit, hole, true );
686 }
687 else
688 {
689 priStr = ComboBoxUnits( primaryUnit, diam, true );
690 secStr = ComboBoxUnits( secondaryUnit, diam, true );
691 }
692
693 msg.Printf( _( "Via: %s (%s)" ), priStr, secStr );
694
695 aViaSizeSelectBox->Append( msg );
696 }
697
698 if( aShowEdit )
699 {
700 aViaSizeSelectBox->Append( wxT( "---" ) );
701 aViaSizeSelectBox->Append( _( "Edit Pre-defined Sizes..." ) );
702 }
703
704 if( GetDesignSettings().GetViaSizeIndex() >= (int) GetDesignSettings().m_ViasDimensionsList.size() )
706
707 // GetDesignSettings().GetViaSizeIndex() can be < 0 if no board loaded
708 // So in this case select the first select box item available (use netclass)
709 aViaSizeSelectBox->SetSelection( std::max( 0, GetDesignSettings().GetViaSizeIndex() ) );
710}
711
712
713void PCB_EDIT_FRAME::ReCreateLayerBox( bool aForceResizeToolbar )
714{
715 if( m_SelLayerBox == nullptr || m_tbTopAux == nullptr )
716 return;
717
718 m_SelLayerBox->SetToolTip( _( "+/- to switch" ) );
719 m_SelLayerBox->Resync();
720
721 if( aForceResizeToolbar )
723}
724
725
727{
729 wxAuiPaneInfo& layersManager = m_auimgr.GetPane( AppearancePanelName() );
730 wxAuiPaneInfo& selectionFilter = m_auimgr.GetPane( "SelectionFilter" );
731
732 // show auxiliary Vertical layers and visibility manager toolbar
733 m_ShowLayerManagerTools = layersManager.IsShown();
734
736
737 layersManager.Show( m_ShowLayerManagerTools );
738 selectionFilter.Show( m_ShowLayerManagerTools );
739
741 {
742 SetAuiPaneSize( m_auimgr, layersManager, settings->m_AuiPanels.right_panel_width, -1 );
743 }
744 else
745 {
746 settings->m_AuiPanels.right_panel_width = m_appearancePanel->GetSize().x;
747 m_auimgr.Update();
748 }
749}
750
751
753{
755 wxAuiPaneInfo& netInspectorPanel = m_auimgr.GetPane( NetInspectorPanelName() );
756
757 m_ShowNetInspector = netInspectorPanel.IsShown();
758
760
761 netInspectorPanel.Show( m_ShowNetInspector );
762
764 {
765 SetAuiPaneSize( m_auimgr, netInspectorPanel, settings->m_AuiPanels.net_inspector_width, -1 );
766 m_netInspectorPanel->OnShowPanel();
767 }
768 else
769 {
770 m_netInspectorPanel->SaveSettings();
771 settings->m_AuiPanels.net_inspector_width = m_netInspectorPanel->GetSize().x;
772 m_auimgr.Update();
773 }
774}
775
776
778{
780
781 // Ensure m_ShowSearch is up to date (the pane can be closed outside the menu)
782 m_ShowSearch = m_auimgr.GetPane( SearchPaneName() ).IsShown();
783
785
786 wxAuiPaneInfo& searchPaneInfo = m_auimgr.GetPane( SearchPaneName() );
787 searchPaneInfo.Show( m_ShowSearch );
788
789 if( m_ShowSearch )
790 {
791 searchPaneInfo.Direction( settings->m_AuiPanels.search_panel_dock_direction );
792
793 if( settings->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_TOP
794 || settings->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_BOTTOM )
795 {
796 SetAuiPaneSize( m_auimgr, searchPaneInfo,
797 -1, settings->m_AuiPanels.search_panel_height );
798 }
799 else if( settings->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_LEFT
800 || settings->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_RIGHT )
801 {
802 SetAuiPaneSize( m_auimgr, searchPaneInfo,
803 settings->m_AuiPanels.search_panel_width, -1 );
804 }
805 m_searchPane->FocusSearch();
806 m_searchPane->RefreshSearch();
807 }
808 else
809 {
810 settings->m_AuiPanels.search_panel_height = m_searchPane->GetSize().y;
811 settings->m_AuiPanels.search_panel_width = m_searchPane->GetSize().x;
812 settings->m_AuiPanels.search_panel_dock_direction = searchPaneInfo.dock_direction;
813 m_auimgr.Update();
814 GetCanvas()->SetFocus();
815 }
816}
817
818
819void PCB_EDIT_FRAME::OnUpdateSelectTrackWidth( wxUpdateUIEvent& aEvent )
820{
821 if( aEvent.GetId() == ID_AUX_TOOLBAR_PCB_TRACK_WIDTH )
822 {
824 int sel;
825
826 if( bds.UseCustomTrackViaSize() )
827 sel = wxNOT_FOUND;
828 else
829 // if GetTrackWidthIndex() < 0, display the "use netclass" option
830 sel = std::max( 0, bds.GetTrackWidthIndex() );
831
832 if( m_SelTrackWidthBox->GetSelection() != sel )
833 m_SelTrackWidthBox->SetSelection( sel );
834 }
835}
836
837
838void PCB_EDIT_FRAME::OnUpdateSelectViaSize( wxUpdateUIEvent& aEvent )
839{
840 if( aEvent.GetId() == ID_AUX_TOOLBAR_PCB_VIA_SIZE )
841 {
843 int sel = 0;
844
845 if( bds.UseCustomTrackViaSize() )
846 sel = wxNOT_FOUND;
847 else
848 // if GetViaSizeIndex() < 0, display the "use netclass" option
849 sel = std::max( 0, bds.GetViaSizeIndex() );
850
851 if( m_SelViaSizeBox->GetSelection() != sel )
852 m_SelViaSizeBox->SetSelection( sel );
853 }
854}
855
856
858{
860
861 wxCHECK( cfg, /* void */ );
862
863 wxAuiPaneInfo& db_library_pane = m_auimgr.GetPane( DesignBlocksPaneName() );
864
865 db_library_pane.Show( !db_library_pane.IsShown() );
866
867 if( db_library_pane.IsShown() )
868 {
869 if( db_library_pane.IsFloating() )
870 {
871 db_library_pane.FloatingSize( cfg->m_AuiPanels.design_blocks_panel_float_width,
873 m_auimgr.Update();
874 }
876 {
877 // SetAuiPaneSize also updates m_auimgr
879 }
880 }
881 else
882 {
883 if( db_library_pane.IsFloating() )
884 {
885 cfg->m_AuiPanels.design_blocks_panel_float_width = db_library_pane.floating_size.x;
886 cfg->m_AuiPanels.design_blocks_panel_float_height = db_library_pane.floating_size.y;
887 }
888 else
889 {
891 }
892
893 m_auimgr.Update();
894 }
895}
constexpr EDA_IU_SCALE pcbIUScale
Definition base_units.h:112
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
static TOOL_ACTION gridProperties
Definition actions.h:200
static TOOL_ACTION updatePcbFromSchematic
Definition actions.h:264
static TOOL_ACTION toggleGrid
Definition actions.h:198
static TOOL_ACTION zoomRedraw
Definition actions.h:132
static TOOL_ACTION millimetersUnits
Definition actions.h:206
static TOOL_ACTION show3DViewer
Definition actions.h:258
static TOOL_ACTION cursorSmallCrosshairs
Definition actions.h:152
static TOOL_ACTION zoomOutCenter
Definition actions.h:136
static TOOL_ACTION togglePolarCoords
Definition actions.h:209
static TOOL_ACTION selectSetLasso
Definition actions.h:221
static TOOL_ACTION selectSetRect
Set lasso selection mode.
Definition actions.h:220
static TOOL_ACTION group
Definition actions.h:239
static TOOL_ACTION pointEditorArcKeepCenter
Definition actions.h:273
static TOOL_ACTION milsUnits
Definition actions.h:205
static TOOL_ACTION ungroup
Definition actions.h:240
static TOOL_ACTION toggleBoundingBoxes
Definition actions.h:157
static TOOL_ACTION plot
Definition actions.h:65
static TOOL_ACTION pointEditorArcKeepRadius
Definition actions.h:275
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:204
static TOOL_ACTION highContrastMode
Definition actions.h:155
static TOOL_ACTION gridOrigin
Definition actions.h:201
static TOOL_ACTION measureTool
Definition actions.h:252
static TOOL_ACTION save
Definition actions.h:58
static TOOL_ACTION zoomFitScreen
Definition actions.h:142
static TOOL_ACTION redo
Definition actions.h:76
static TOOL_ACTION deleteTool
Definition actions.h:86
static TOOL_ACTION zoomTool
Definition actions.h:146
static TOOL_ACTION cursor45Crosshairs
Definition actions.h:154
static TOOL_ACTION showFootprintEditor
Definition actions.h:262
static TOOL_ACTION print
Definition actions.h:64
static TOOL_ACTION showProperties
Definition actions.h:266
static TOOL_ACTION doNew
Definition actions.h:54
static TOOL_ACTION zoomFitObjects
Definition actions.h:143
static TOOL_ACTION zoomInCenter
Definition actions.h:135
static TOOL_ACTION gridSetOrigin
Definition actions.h:195
static TOOL_ACTION showFootprintBrowser
Definition actions.h:261
static TOOL_ACTION toggleGridOverrides
Definition actions.h:199
static TOOL_ACTION pointEditorArcKeepEndpoint
Definition actions.h:274
static TOOL_ACTION cursorFullCrosshairs
Definition actions.h:153
static TOOL_ACTION find
Definition actions.h:117
static constexpr bool CHECK
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
FOOTPRINT * GetParentFootprint() const
void SetCurrentVariant(const wxString &aVariant)
Definition board.cpp:2515
wxArrayString GetVariantNamesForUI() const
Return the variant names for UI display.
Definition board.cpp:2661
wxString GetCurrentVariant() const
Definition board.h:404
COLOR4D GetColor(int aLayer) const
APPEARANCE m_Appearance
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()
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
void SetFocus() override
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition eda_text.h:80
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
Definition actions.h:352
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:105
An abstract base class for deriving all objects that can be added to a VIEW.
Definition view_item.h:86
void UpdateAllItemsConditionally(int aUpdateFlags, std::function< bool(VIEW_ITEM *)> aCondition)
Update items in the view according to the given flags and condition.
Definition view.cpp:1600
static wxBitmapBundle CreateLayerPairIcon(const COLOR4D &aTopColor, const COLOR4D &aBottomColor, int aDefSize=24)
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 routerSettingsDialog
Activation of the Push and Shove settings dialogs.
static TOOL_ACTION showRatsnest
static TOOL_ACTION zoneFillAll
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 routerHighlightMode
Actions to enable switching modes via hotkey assignments.
static TOOL_ACTION routerWalkaroundMode
static TOOL_ACTION routerShoveMode
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 zoneUnfillAll
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
static ACTION_TOOLBAR_CONTROL currentVariant
COLOR_SETTINGS * GetColorSettings(bool aForceRefresh=false) const override
Helper to retrieve the current color settings.
PCB_LAYER_BOX_SELECTOR * m_SelLayerBox
void configureToolbars() override
void ClearToolbarControl(int aId) 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.
BOARD * GetBoard() const
virtual BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Return the BOARD_DESIGN_SETTINGS for the open project.
virtual void Update3DView(bool aMarkDirty, bool aRefresh, const wxString *aTitle=nullptr)
Update the 3D view, if the viewer is opened by this frame.
virtual KIGFX::PCB_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
void OnUpdateSelectTrackWidth(wxUpdateUIEvent &aEvent)
void UpdateVariantSelectionCtrl()
Update the variant selection dropdown with the current board's variant names.
void UpdateTrackWidthSelectBox(wxChoice *aTrackWidthSelectBox, bool aShowNetclass, bool aShowEdit)
void UpdateViaSizeSelectBox(wxChoice *aViaSizeSelectBox, bool aShowNetclass, bool aShowEdit)
LAYER_TOOLBAR_ICON_VALUES m_prevIconVal
void ClearToolbarControl(int aId) override
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...
void PrepareLayerIndicator(bool aForceRebuild=false)
wxChoice * m_CurrentVariantCtrl
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 onVariantSelected(wxCommandEvent &aEvent)
Event handler for variant selection changes in the toolbar.
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.
The selection tool: currently supports:
virtual COMMON_SETTINGS * GetCommonSettings() const
Definition pgm_base.cpp:547
TOOL_MANAGER * m_toolManager
Master controller class:
#define _(s)
EDA_UNITS
Definition eda_units.h:48
@ FRAME_PCB_EDITOR
Definition frame_type.h:42
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
@ REPAINT
Item needs to be redrawn.
Definition view_item.h:58
@ GEOMETRY
Position or shape has changed.
Definition view_item.h:55
@ ID_AUX_TOOLBAR_PCB_VARIANT_SELECT
Definition pcbnew_id.h:19
@ 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.
see class PGM_BASE
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 wxBitmapBundle LayerPairBitmap
static wxString ComboBoxUnits(EDA_UNITS aUnits, double aValue, bool aIncludeLabel=true)
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.