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#include <pcb_draw_panel_gal.h>
77
78/* Data to build the layer pair indicator button */
79static wxBitmapBundle LayerPairBitmap;
80
81
82void PCB_EDIT_FRAME::PrepareLayerIndicator( bool aForceRebuild )
83{
84 COLOR4D top_color, bottom_color, background_color;
85 bool change = aForceRebuild;
86
88
89 if( m_prevIconVal.previous_icon_size != icon_size )
90 {
91 m_prevIconVal.previous_icon_size = icon_size;
92 change = true;
93 }
94
95 top_color = GetColorSettings()->GetColor( GetScreen()->m_Route_Layer_TOP );
96
97 if( m_prevIconVal.previous_Route_Layer_TOP_color != top_color )
98 {
99 m_prevIconVal.previous_Route_Layer_TOP_color = top_color;
100 change = true;
101 }
102
103 bottom_color = GetColorSettings()->GetColor( GetScreen()->m_Route_Layer_BOTTOM );
104
105 if( m_prevIconVal.previous_Route_Layer_BOTTOM_color != bottom_color )
106 {
107 m_prevIconVal.previous_Route_Layer_BOTTOM_color = bottom_color;
108 change = true;
109 }
110
111 if( change || !LayerPairBitmap.IsOk() )
112 {
113 LayerPairBitmap = LAYER_PRESENTATION::CreateLayerPairIcon( top_color, bottom_color, icon_size );
114
115 if( m_tbTopAux )
116 {
118 m_tbTopAux->Refresh();
119 }
120 }
121}
122
123
125 _( "Track width selector" ),
126 _( "Control to select the track width" ),
127 { FRAME_PCB_EDITOR } );
129 _( "Via diameter selector" ),
130 _( "Control to select the via diameter" ),
131 { FRAME_PCB_EDITOR } );
133 _( "Current variant" ),
134 _( "Control to select the current variant" ),
135 { FRAME_PCB_EDITOR } );
136
137
138std::optional<TOOLBAR_CONFIGURATION> PCB_EDIT_TOOLBAR_SETTINGS::DefaultToolbarConfig( TOOLBAR_LOC aToolbar )
139{
141
142 // clang-format off
143 switch( aToolbar )
144 {
146 config.AppendAction( ACTIONS::toggleGrid )
147 .WithContextMenu(
148 []( TOOL_MANAGER* aMgr ) -> std::unique_ptr<ACTION_MENU>
149 {
151 std::unique_ptr<ACTION_MENU> menu =
152 std::make_unique<ACTION_MENU>( false, selTool );
153
154 menu->Add( ACTIONS::gridProperties );
155 menu->Add( ACTIONS::gridOrigin );
156
157 return menu;
158 } )
159 .AppendAction( ACTIONS::toggleGridOverrides )
160 .AppendAction( PCB_ACTIONS::togglePolarCoords )
161 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Units" ) )
162 .AddAction( ACTIONS::millimetersUnits )
163 .AddAction( ACTIONS::inchesUnits )
164 .AddAction( ACTIONS::milsUnits ) )
165 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Crosshair modes" ) )
168 .AddAction( ACTIONS::cursor45Crosshairs ) );
169
170 config.AppendSeparator()
171 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Line modes" ) )
172 .AddAction( PCB_ACTIONS::lineModeFree )
173 .AddAction( PCB_ACTIONS::lineMode90 )
174 .AddAction( PCB_ACTIONS::lineMode45 ) );
175
176 config.AppendSeparator()
177 .AppendAction( PCB_ACTIONS::showRatsnest )
178 .AppendAction( PCB_ACTIONS::ratsnestLineMode );
179
180 config.AppendSeparator()
181 .AppendAction( ACTIONS::highContrastMode )
182 .AppendAction( PCB_ACTIONS::toggleNetHighlight );
183
184 config.AppendSeparator()
185 .AppendAction( PCB_ACTIONS::zoneDisplayFilled )
186 .AppendAction( PCB_ACTIONS::zoneDisplayOutline );
187
188 if( ADVANCED_CFG::GetCfg().m_ExtraZoneDisplayModes )
189 {
192 }
193
194 config.AppendSeparator()
195 .AppendAction( PCB_ACTIONS::padDisplayMode )
196 .AppendAction( PCB_ACTIONS::viaDisplayMode )
197 .AppendAction( PCB_ACTIONS::trackDisplayMode );
198
199 if( ADVANCED_CFG::GetCfg().m_DrawBoundingBoxes )
200 config.AppendAction( ACTIONS::toggleBoundingBoxes );
201
202 // Tools to show/hide toolbars:
203 config.AppendSeparator()
204 .AppendAction( PCB_ACTIONS::showLayersManager )
205 .AppendAction( ACTIONS::showProperties );
206
207 break;
208
210 config.AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Selection modes" ) )
211 .AddAction( ACTIONS::selectSetRect )
212 .AddAction( ACTIONS::selectSetLasso ) )
213 .AppendAction( PCB_ACTIONS::localRatsnestTool );
214
215 config.AppendSeparator()
216 .AppendAction( PCB_ACTIONS::placeFootprint )
217 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Track routing tools" ) )
219 .AddAction( PCB_ACTIONS::routeDiffPair )
220 .AddContextMenu(
221 []( TOOL_MANAGER* aMgr ) -> std::unique_ptr<ACTION_MENU>
222 {
224 std::unique_ptr<ACTION_MENU> menu =
225 std::make_unique<ACTION_MENU>( false, selTool );
226
230 menu->AppendSeparator();
232
233 return menu;
234 } ) )
235 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Track tuning tools" ) )
236 .AddAction( PCB_ACTIONS::tuneSingleTrack )
237 .AddAction( PCB_ACTIONS::tuneDiffPair )
238 .AddAction( PCB_ACTIONS::tuneSkew ) )
239 .AppendAction( PCB_ACTIONS::drawVia )
240 .AppendAction( PCB_ACTIONS::drawZone )
241 .WithContextMenu(
242 []( TOOL_MANAGER* aMgr ) -> std::unique_ptr<ACTION_MENU>
243 {
245 std::unique_ptr<ACTION_MENU> menu =
246 std::make_unique<ACTION_MENU>( false, selTool );
247
248 menu->Add( PCB_ACTIONS::zoneFillAll );
249 menu->Add( PCB_ACTIONS::zoneUnfillAll );
250 menu->AppendSeparator();
251 menu->Add( PCB_ACTIONS::zonesManager );
252
253 return menu;
254 } )
255 .AppendAction( PCB_ACTIONS::drawRuleArea );
256
257 config.AppendSeparator()
258 .AppendAction( PCB_ACTIONS::drawLine )
259 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Arc" ) )
260 .AddAction( PCB_ACTIONS::drawArc )
261 .AddAction( PCB_ACTIONS::drawEllipseArc )
262 .AddContextMenu(
263 []( TOOL_MANAGER* aMgr ) -> std::unique_ptr<ACTION_MENU>
264 {
266 std::unique_ptr<ACTION_MENU> menu =
267 std::make_unique<ACTION_MENU>( false, selTool );
268
272
273 return menu;
274 } ) )
275 .AppendAction( PCB_ACTIONS::drawRectangle )
276 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Circle" ) )
277 .AddAction( PCB_ACTIONS::drawCircle )
278 .AddAction( PCB_ACTIONS::drawEllipse ) )
279 .AppendAction( PCB_ACTIONS::drawPolygon )
280 .AppendAction( PCB_ACTIONS::drawBezier )
281 .AppendAction( PCB_ACTIONS::placeReferenceImage )
282 .AppendAction( PCB_ACTIONS::placeText )
283 .AppendAction( PCB_ACTIONS::drawTextBox )
284 .AppendAction( PCB_ACTIONS::drawTable )
285 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Dimension objects" ) )
290 .AddAction( PCB_ACTIONS::drawLeader ) )
291 .AppendAction( PCB_ACTIONS::placeBarcode )
292 .AppendAction( ACTIONS::deleteTool );
293
294 config.AppendSeparator()
295 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "PCB origins and points" ) )
296 .AddAction( ACTIONS::gridSetOrigin )
297 .AddAction( PCB_ACTIONS::drillOrigin ) )
298 .AppendAction( PCB_ACTIONS::placePoint )
299 .AppendAction( ACTIONS::measureTool );
300
301 break;
302
304 if( Kiface().IsSingle() )
305 {
306 config.AppendAction( ACTIONS::doNew );
307 config.AppendAction( ACTIONS::open );
308 }
309
310 config.AppendAction( ACTIONS::save );
311
312 config.AppendSeparator()
313 .AppendAction( PCB_ACTIONS::boardSetup );
314
315 config.AppendSeparator()
316 .AppendAction( ACTIONS::pageSettings )
317 .AppendAction( ACTIONS::print )
318 .AppendAction( ACTIONS::plot );
319
320 config.AppendSeparator()
321 .AppendAction( ACTIONS::undo )
322 .AppendAction( ACTIONS::redo );
323
324 config.AppendSeparator()
325 .AppendAction( ACTIONS::find );
326
327 config.AppendSeparator()
328 .AppendAction( ACTIONS::zoomRedraw )
329 .AppendAction( ACTIONS::zoomInCenter )
330 .AppendAction( ACTIONS::zoomOutCenter )
331 .AppendAction( ACTIONS::zoomFitScreen )
332 .AppendAction( ACTIONS::zoomFitObjects )
333 .AppendAction( ACTIONS::zoomTool );
334
335 config.AppendSeparator()
336 .AppendAction( PCB_ACTIONS::rotateCcw )
337 .AppendAction( PCB_ACTIONS::rotateCw )
338 .AppendAction( PCB_ACTIONS::mirrorV )
339 .AppendAction( PCB_ACTIONS::mirrorH )
340 .AppendAction( ACTIONS::group )
341 .AppendAction( ACTIONS::ungroup )
342 .AppendAction( PCB_ACTIONS::lock )
343 .AppendAction( PCB_ACTIONS::unlock );
344
345 config.AppendSeparator()
346 .AppendAction( ACTIONS::showFootprintEditor )
347 .AppendAction( ACTIONS::showFootprintBrowser )
348 .AppendAction( ACTIONS::show3DViewer );
349
350 config.AppendSeparator();
351
352 if( !Kiface().IsSingle() )
354 else
355 config.AppendAction( PCB_ACTIONS::importNetlist );
356
357 config.AppendAction( PCB_ACTIONS::runDRC );
358
359 config.AppendSeparator();
360 config.AppendAction( PCB_ACTIONS::showEeschema );
363
364 break;
365
368 .AppendAction( PCB_ACTIONS::autoTrackWidth );
369
370 config.AppendSeparator()
372
373 config.AppendSeparator()
375 .AppendAction( PCB_ACTIONS::selectLayerPair );
376
377 config.AppendSeparator()
378 .AppendControl( ACTION_TOOLBAR_CONTROLS::gridSelect );
379
380 config.AppendSeparator()
381 .AppendControl( ACTION_TOOLBAR_CONTROLS::zoomSelect );
382
383 config.AppendSeparator()
385
386 break;
387 }
388
389 // clang-format on
390 return config;
391}
392
393
395{
397
398 // Box to display and choose track widths
399 auto trackWidthSelectorFactory =
400 [this]( ACTION_TOOLBAR* aToolbar )
401 {
402 if( !m_SelTrackWidthBox )
403 {
404 m_SelTrackWidthBox = new wxChoice( aToolbar, ID_AUX_TOOLBAR_PCB_TRACK_WIDTH,
405 wxDefaultPosition, wxDefaultSize, 0, nullptr );
406 }
407
408 m_SelTrackWidthBox->SetToolTip( _( "Select the default width for new tracks. Note that this "
409 "width can be overridden by the board minimum width, or by "
410 "the width of an existing track if the 'Use Existing Track "
411 "Width' feature is enabled." ) );
412
414
415 aToolbar->Add( m_SelTrackWidthBox );
416 };
417
419
420
421 // Box to display and choose vias diameters
422 auto viaDiaSelectorFactory =
423 [this]( ACTION_TOOLBAR* aToolbar )
424 {
425 if( !m_SelViaSizeBox )
426 {
427 m_SelViaSizeBox = new wxChoice( aToolbar, ID_AUX_TOOLBAR_PCB_VIA_SIZE,
428 wxDefaultPosition, wxDefaultSize, 0, nullptr );
429 }
430
432 aToolbar->Add( m_SelViaSizeBox );
433 };
434
436
437 // Variant selection drop down control on main tool bar
438 auto variantSelectionCtrlFactory =
439 [this]( ACTION_TOOLBAR* aToolbar )
440 {
442 {
444 wxDefaultPosition, wxDefaultSize, 0, nullptr );
445 }
446
447 m_CurrentVariantCtrl->SetToolTip( _( "Select the current variant to display and edit." ) );
448
450
451 aToolbar->Add( m_CurrentVariantCtrl );
452 };
453
455
456 // IPC/Scripting plugin control
457 // TODO (ISM): Clean this up to make IPC actions just normal tool actions to get rid of this entire
458 // control
459 auto pluginControlFactory =
460 [this]( ACTION_TOOLBAR* aToolbar )
461 {
462#ifdef KICAD_IPC_API
463 bool haveApiPlugins = Pgm().GetCommonSettings()->m_Api.enable_server
464 && !Pgm().GetPluginManager().GetActionsForScope( PluginActionScope() ).empty();
465#else
466 bool haveApiPlugins = false;
467#endif
468
469 if( haveApiPlugins )
470 {
471 aToolbar->AddScaledSeparator( aToolbar->GetParent() );
472 AddApiPluginTools( aToolbar );
473 }
474 };
475
477}
478
479
481{
483
484 switch( aId )
485 {
487 case ID_AUX_TOOLBAR_PCB_VIA_SIZE: m_SelViaSizeBox = nullptr; break;
489 }
490}
491
492
494{
496 return;
497
498 if( !GetBoard() )
499 return;
500
501 wxArrayString variantNames = GetBoard()->GetVariantNamesForUI();
502
503 m_CurrentVariantCtrl->Set( variantNames );
504
505 int selectionIndex = 0;
506 wxString currentVariant = GetBoard()->GetCurrentVariant();
507
508 if( !currentVariant.IsEmpty() )
509 {
510 int foundIndex = m_CurrentVariantCtrl->FindString( currentVariant );
511
512 if( foundIndex != wxNOT_FOUND )
513 selectionIndex = foundIndex;
514 }
515
516 if( m_CurrentVariantCtrl->GetCount() > 0 )
517 m_CurrentVariantCtrl->SetSelection( selectionIndex );
518}
519
520
521void PCB_EDIT_FRAME::SetCurrentVariant( const wxString& aVariantName )
522{
523 GetBoard()->SetCurrentVariant( aVariantName );
524
525 if( PCB_DRAW_PANEL_GAL* canvas = dynamic_cast<PCB_DRAW_PANEL_GAL*>( GetCanvas() ) )
526 {
527 DS_PROXY_VIEW_ITEM* ds = canvas->GetDrawingSheet();
528
529 if( ds )
530 {
531 wxString currentVariant = GetBoard()->GetCurrentVariant();
532 wxString variantDesc = GetBoard()->GetVariantDescription( currentVariant );
533
534 ds->SetVariantName( currentVariant.ToStdString() );
535 ds->SetVariantDesc( variantDesc.ToStdString() );
536 }
537 }
538}
539
540
541void PCB_EDIT_FRAME::onVariantSelected( wxCommandEvent& aEvent )
542{
544 return;
545
546 int selection = m_CurrentVariantCtrl->GetSelection();
547
548 if( selection == wxNOT_FOUND || selection == 0 )
549 {
550 // "<Default>" selected - clear the current variant
551 SetCurrentVariant( wxEmptyString );
552 }
553 else
554 {
555 wxString selectedVariant = m_CurrentVariantCtrl->GetString( selection );
556 SetCurrentVariant( selectedVariant );
557 }
558
559 // Refresh the view and properties panel to show the new variant state
561
563 [&]( KIGFX::VIEW_ITEM* aItem ) -> int
564 {
565 if( EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aItem ) )
566 {
567 if( text->HasTextVars() )
568 {
569 text->ClearRenderCache();
570 text->ClearBoundingBoxCache();
572 }
573 }
574
575 if( PCB_FIELD* field = dynamic_cast<PCB_FIELD*>( aItem ) )
576 {
577 if( FOOTPRINT* fp = field->GetParentFootprint() )
578 {
579 if( !fp->GetVariants().empty() )
580 {
581 field->ClearRenderCache();
582 field->ClearBoundingBoxCache();
584 }
585 }
586 }
587
588 return 0;
589 } );
590
591 GetCanvas()->Refresh();
592
593 Update3DView( true, GetPcbNewSettings()->m_Display.m_Live3DRefresh );
595}
596
597
598static wxString ComboBoxUnits( EDA_UNITS aUnits, double aValue, bool aIncludeLabel = true )
599{
600 wxString text;
601 const wxChar* format;
602
603 switch( aUnits )
604 {
605 default:
606 wxASSERT_MSG( false, wxT( "Invalid unit" ) );
608 case EDA_UNITS::UNSCALED: format = wxT( "%.0f" ); break;
609 case EDA_UNITS::MM: format = wxT( "%.3f" ); break;
610 case EDA_UNITS::MILS: format = wxT( "%.2f" ); break;
611 case EDA_UNITS::INCH: format = wxT( "%.5f" ); break;
612 }
613
614 text.Printf( format, EDA_UNIT_UTILS::UI::ToUserUnit( pcbIUScale, aUnits, aValue ) );
615
616 if( aIncludeLabel )
618
619 return text;
620}
621
622
623void PCB_EDIT_FRAME::UpdateTrackWidthSelectBox( wxChoice* aTrackWidthSelectBox, bool aShowNetclass,
624 bool aShowEdit )
625{
626 if( aTrackWidthSelectBox == nullptr )
627 return;
628
629 EDA_UNITS primaryUnit;
630 EDA_UNITS secondaryUnit;
631
632 GetUnitPair( primaryUnit, secondaryUnit );
633
634 wxString msg;
635
636 aTrackWidthSelectBox->Clear();
637
638 if( aShowNetclass )
639 aTrackWidthSelectBox->Append( _( "Track: use netclass width" ) );
640
641 for( unsigned ii = 1; ii < GetDesignSettings().m_TrackWidthList.size(); ii++ )
642 {
643 int size = GetDesignSettings().m_TrackWidthList[ii];
644
645 msg.Printf( _( "Track: %s (%s)" ), ComboBoxUnits( primaryUnit, size ),
646 ComboBoxUnits( secondaryUnit, size ) );
647
648 aTrackWidthSelectBox->Append( msg );
649 }
650
651 if( aShowEdit )
652 {
653 aTrackWidthSelectBox->Append( wxT( "---" ) );
654 aTrackWidthSelectBox->Append( _( "Edit Pre-defined Sizes..." ) );
655 }
656
657 if( GetDesignSettings().GetTrackWidthIndex() >= (int) GetDesignSettings().m_TrackWidthList.size() )
659
660 // GetDesignSettings().GetTrackWidthIndex() can be < 0 if no board loaded
661 // So in this case select the first select box item available (use netclass)
662 aTrackWidthSelectBox->SetSelection( std::max( 0, GetDesignSettings().GetTrackWidthIndex() ) );
663}
664
665
666void PCB_EDIT_FRAME::UpdateViaSizeSelectBox( wxChoice* aViaSizeSelectBox, bool aShowNetclass,
667 bool aShowEdit )
668{
669 if( aViaSizeSelectBox == nullptr )
670 return;
671
672 aViaSizeSelectBox->Clear();
673
674 COMMON_TOOLS* cmnTool = m_toolManager->GetTool<COMMON_TOOLS>();
675 EDA_UNITS primaryUnit = GetUserUnits();
676 EDA_UNITS secondaryUnit = EDA_UNITS::MILS;
677
678 if( EDA_UNIT_UTILS::IsImperialUnit( primaryUnit ) )
679 secondaryUnit = cmnTool ? cmnTool->GetLastMetricUnits() : EDA_UNITS::MM;
680 else
681 secondaryUnit = cmnTool ? cmnTool->GetLastImperialUnits() : EDA_UNITS::MILS;
682
683 if( aShowNetclass )
684 aViaSizeSelectBox->Append( _( "Via: use netclass sizes" ) );
685
686 for( unsigned ii = 1; ii < GetDesignSettings().m_ViasDimensionsList.size(); ii++ )
687 {
689 wxString msg, priStr, secStr;
690
691 double diam = viaDimension.m_Diameter;
692 double hole = viaDimension.m_Drill;
693
694 if( hole > 0 )
695 {
696 priStr = ComboBoxUnits( primaryUnit, diam, false ) + wxT( " / " )
697 + ComboBoxUnits( primaryUnit, hole, true );
698 secStr = ComboBoxUnits( secondaryUnit, diam, false ) + wxT( " / " )
699 + ComboBoxUnits( secondaryUnit, hole, true );
700 }
701 else
702 {
703 priStr = ComboBoxUnits( primaryUnit, diam, true );
704 secStr = ComboBoxUnits( secondaryUnit, diam, true );
705 }
706
707 msg.Printf( _( "Via: %s (%s)" ), priStr, secStr );
708
709 aViaSizeSelectBox->Append( msg );
710 }
711
712 if( aShowEdit )
713 {
714 aViaSizeSelectBox->Append( wxT( "---" ) );
715 aViaSizeSelectBox->Append( _( "Edit Pre-defined Sizes..." ) );
716 }
717
718 if( GetDesignSettings().GetViaSizeIndex() >= (int) GetDesignSettings().m_ViasDimensionsList.size() )
720
721 // GetDesignSettings().GetViaSizeIndex() can be < 0 if no board loaded
722 // So in this case select the first select box item available (use netclass)
723 aViaSizeSelectBox->SetSelection( std::max( 0, GetDesignSettings().GetViaSizeIndex() ) );
724}
725
726
727void PCB_EDIT_FRAME::ReCreateLayerBox( bool aForceResizeToolbar )
728{
729 if( m_SelLayerBox == nullptr || m_tbTopAux == nullptr )
730 return;
731
732 m_SelLayerBox->SetToolTip( _( "+/- to switch" ) );
733 m_SelLayerBox->Resync();
734
735 if( aForceResizeToolbar )
737}
738
739
741{
743 wxAuiPaneInfo& layersManager = m_auimgr.GetPane( AppearancePanelName() );
744 wxAuiPaneInfo& selectionFilter = m_auimgr.GetPane( "SelectionFilter" );
745
746 // show auxiliary Vertical layers and visibility manager toolbar
747 m_ShowLayerManagerTools = layersManager.IsShown();
748
750
751 layersManager.Show( m_ShowLayerManagerTools );
752 selectionFilter.Show( m_ShowLayerManagerTools );
753
755 {
756 SetAuiPaneSize( m_auimgr, layersManager, settings->m_AuiPanels.right_panel_width, -1 );
757 }
758 else
759 {
760 settings->m_AuiPanels.right_panel_width = m_appearancePanel->GetSize().x;
761 m_auimgr.Update();
762 }
763}
764
765
767{
769 wxAuiPaneInfo& netInspectorPanel = m_auimgr.GetPane( NetInspectorPanelName() );
770
771 m_ShowNetInspector = netInspectorPanel.IsShown();
772
774
775 netInspectorPanel.Show( m_ShowNetInspector );
776
778 {
779 SetAuiPaneSize( m_auimgr, netInspectorPanel, settings->m_AuiPanels.net_inspector_width, -1 );
780 m_netInspectorPanel->OnShowPanel();
781 }
782 else
783 {
784 m_netInspectorPanel->SaveSettings();
785 settings->m_AuiPanels.net_inspector_width = m_netInspectorPanel->GetSize().x;
786 m_auimgr.Update();
787 }
788}
789
790
792{
794
795 // Ensure m_ShowSearch is up to date (the pane can be closed outside the menu)
796 m_ShowSearch = m_auimgr.GetPane( SearchPaneName() ).IsShown();
797
799
800 wxAuiPaneInfo& searchPaneInfo = m_auimgr.GetPane( SearchPaneName() );
801 searchPaneInfo.Show( m_ShowSearch );
802
803 if( m_ShowSearch )
804 {
805 searchPaneInfo.Direction( settings->m_AuiPanels.search_panel_dock_direction );
806
807 if( settings->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_TOP
808 || settings->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_BOTTOM )
809 {
810 SetAuiPaneSize( m_auimgr, searchPaneInfo,
811 -1, settings->m_AuiPanels.search_panel_height );
812 }
813 else if( settings->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_LEFT
814 || settings->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_RIGHT )
815 {
816 SetAuiPaneSize( m_auimgr, searchPaneInfo,
817 settings->m_AuiPanels.search_panel_width, -1 );
818 }
819 m_searchPane->FocusSearch();
820 m_searchPane->RefreshSearch();
821 }
822 else
823 {
824 settings->m_AuiPanels.search_panel_height = m_searchPane->GetSize().y;
825 settings->m_AuiPanels.search_panel_width = m_searchPane->GetSize().x;
826 settings->m_AuiPanels.search_panel_dock_direction = searchPaneInfo.dock_direction;
827 m_auimgr.Update();
828 GetCanvas()->SetFocus();
829 }
830}
831
832
833void PCB_EDIT_FRAME::OnUpdateSelectTrackWidth( wxUpdateUIEvent& aEvent )
834{
835 if( aEvent.GetId() == ID_AUX_TOOLBAR_PCB_TRACK_WIDTH )
836 {
838 int sel;
839
840 if( bds.UseCustomTrackViaSize() )
841 sel = wxNOT_FOUND;
842 else
843 // if GetTrackWidthIndex() < 0, display the "use netclass" option
844 sel = std::max( 0, bds.GetTrackWidthIndex() );
845
846 if( m_SelTrackWidthBox->GetSelection() != sel )
847 m_SelTrackWidthBox->SetSelection( sel );
848 }
849}
850
851
852void PCB_EDIT_FRAME::OnUpdateSelectViaSize( wxUpdateUIEvent& aEvent )
853{
854 if( aEvent.GetId() == ID_AUX_TOOLBAR_PCB_VIA_SIZE )
855 {
857 int sel = 0;
858
859 if( bds.UseCustomTrackViaSize() )
860 sel = wxNOT_FOUND;
861 else
862 // if GetViaSizeIndex() < 0, display the "use netclass" option
863 sel = std::max( 0, bds.GetViaSizeIndex() );
864
865 if( m_SelViaSizeBox->GetSelection() != sel )
866 m_SelViaSizeBox->SetSelection( sel );
867 }
868}
869
870
872{
874
875 wxCHECK( cfg, /* void */ );
876
877 wxAuiPaneInfo& db_library_pane = m_auimgr.GetPane( DesignBlocksPaneName() );
878
879 db_library_pane.Show( !db_library_pane.IsShown() );
880
881 if( db_library_pane.IsShown() )
882 {
883 if( db_library_pane.IsFloating() )
884 {
885 db_library_pane.FloatingSize( cfg->m_AuiPanels.design_blocks_panel_float_width,
887 m_auimgr.Update();
888 }
890 {
891 // SetAuiPaneSize also updates m_auimgr
893 }
894 }
895 else
896 {
897 if( db_library_pane.IsFloating() )
898 {
899 cfg->m_AuiPanels.design_blocks_panel_float_width = db_library_pane.floating_size.x;
900 cfg->m_AuiPanels.design_blocks_panel_float_height = db_library_pane.floating_size.y;
901 }
902 else
903 {
905 }
906
907 m_auimgr.Update();
908 }
909}
constexpr EDA_IU_SCALE pcbIUScale
Definition base_units.h:125
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:2778
wxArrayString GetVariantNamesForUI() const
Return the variant names for UI display.
Definition board.cpp:2933
wxString GetVariantDescription(const wxString &aVariantName) const
Definition board.cpp:2897
wxString GetCurrentVariant() const
Definition board.h:398
COLOR4D GetColor(int aLayer) const
APPEARANCE m_Appearance
Handles action that are shared between different applications.
EDA_UNITS GetLastImperialUnits()
EDA_UNITS GetLastMetricUnits()
void SetVariantName(const std::string &aVariant)
Set the current variant name and description to be shown on the drawing sheet.
void SetVariantDesc(const std::string &aVariantDesc)
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:93
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:1701
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 zonesManager
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 drawEllipseArc
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 drawEllipse
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 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)
void SetCurrentVariant(const wxString &aVariantName)
Set the current variant on the board and update the drawing sheet's cached variant name and descripti...
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 UpdateProperties() override
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:541
TOOL_MANAGER * m_toolManager
Master controller class:
EDA_UNITS GetUserUnits() const
#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
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.