KiCad PCB EDA Suite
footprint_edit_frame.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) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
5 * Copyright (C) 2015 SoftPLC Corporation, Dick Hollenbeck <[email protected]>
6 * Copyright (C) 2015-2016 Wayne Stambaugh <[email protected]>
7 * Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
8 *
9 * This program is free software: you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation, either version 3 of the License, or (at your
12 * option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program. If not, see <http://www.gnu.org/licenses/>.
21 */
22
23#include "tools/convert_tool.h"
24#include "tools/drawing_tool.h"
25#include "tools/edit_tool.h"
27#include "tools/pad_tool.h"
28#include "tools/pcb_actions.h"
29#include "tools/pcb_control.h"
36#include <bitmaps.h>
37#include <board.h>
38#include <footprint.h>
39#include <confirm.h>
42#include <footprint_info_impl.h>
43#include <footprint_tree_pane.h>
44#include <fp_lib_table.h>
46#include <kiface_base.h>
47#include <kiplatform/app.h>
48#include <kiway.h>
49#include <macros.h>
50#include <pcb_draw_panel_gal.h>
51#include <pcb_edit_frame.h>
52#include <pcbnew.h>
53#include <pcbnew_id.h>
54#include <pgm_base.h>
55#include <project.h>
57#include <tool/action_toolbar.h>
58#include <tool/common_control.h>
59#include <tool/common_tools.h>
60#include <tool/selection.h>
62#include <tool/tool_manager.h>
63#include <tool/zoom_tool.h>
66#include <tools/group_tool.h>
69#include <widgets/lib_tree.h>
73#include <wx/filedlg.h>
75
76BEGIN_EVENT_TABLE( FOOTPRINT_EDIT_FRAME, PCB_BASE_FRAME )
77 EVT_MENU( wxID_CLOSE, FOOTPRINT_EDIT_FRAME::CloseFootprintEditor )
78 EVT_MENU( wxID_EXIT, FOOTPRINT_EDIT_FRAME::OnExitKiCad )
79
81
84
86
89
90 // Horizontal toolbar
93
94 // UI update events.
96 FOOTPRINT_EDIT_FRAME::OnUpdateLoadFootprintFromBoard )
98 FOOTPRINT_EDIT_FRAME::OnUpdateSaveFootprintToBoard )
100
101 // Drop files event
102 EVT_DROP_FILES( FOOTPRINT_EDIT_FRAME::OnDropFiles )
103
104END_EVENT_TABLE()
105
106
107FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
108 PCB_BASE_EDIT_FRAME( aKiway, aParent, FRAME_FOOTPRINT_EDITOR, wxEmptyString,
109 wxDefaultPosition, wxDefaultSize,
110 KICAD_DEFAULT_DRAWFRAME_STYLE, GetFootprintEditorFrameName() ),
111 m_show_layer_manager_tools( true )
112{
113 m_showBorderAndTitleBlock = false; // true to show the frame references
114 m_aboutTitle = _( "KiCad Footprint Editor" );
115 m_selLayerBox = nullptr;
116 m_editorSettings = nullptr;
117
118 // Give an icon
119 wxIcon icon;
120 wxIconBundle icon_bundle;
121
122 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_modedit ) );
123 icon_bundle.AddIcon( icon );
124 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_modedit_32 ) );
125 icon_bundle.AddIcon( icon );
126 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_modedit_16 ) );
127 icon_bundle.AddIcon( icon );
128
129 SetIcons( icon_bundle );
130
131 // Create GAL canvas
132 m_canvasType = loadCanvasTypeSetting();
133
134 PCB_DRAW_PANEL_GAL* drawPanel = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_frameSize,
135 GetGalDisplayOptions(), m_canvasType );
136 SetCanvas( drawPanel );
137 SetBoard( new BOARD() );
138
139 // This board will only be used to hold a footprint for editing
141
142 // In Footprint Editor, the default net clearance is not known (it depends on the actual
143 // board). So we do not show the default clearance, by setting it to 0. The footprint or
144 // pad specific clearance will be shown.
145 GetBoard()->GetDesignSettings().m_NetSettings->m_DefaultNetClass->SetClearance( 0 );
146
147 // Don't show the default board solder mask expansion in the footprint editor. Only the
148 // footprint or pad mask expansions settings should be shown.
150
151 // restore the last footprint from the project, if any
152 restoreLastFootprint();
153
154 // Ensure all layers and items are visible:
155 // In footprint editor, some layers have no meaning or cannot be used, but we show all of
156 // them, at least to be able to edit a bad layer
158
159 GetGalDisplayOptions().m_axesEnabled = true;
160
161 // In Footprint Editor, set the default paper size to A4 for plot/print
162 SetPageSettings( PAGE_INFO( PAGE_INFO::A4 ) );
163 SetScreen( new PCB_SCREEN( GetPageSettings().GetSizeIU( pcbIUScale.IU_PER_MILS ) ) );
164
165 // Create the manager and dispatcher & route draw panel events to the dispatcher
166 setupTools();
167 setupUIConditions();
168
169 initLibraryTree();
170 m_treePane = new FOOTPRINT_TREE_PANE( this );
171
172 ReCreateMenuBar();
173 ReCreateHToolbar();
174 ReCreateVToolbar();
175 ReCreateOptToolbar();
176
177 m_selectionFilterPanel = new PANEL_SELECTION_FILTER( this );
178 m_appearancePanel = new APPEARANCE_CONTROLS( this, GetCanvas(), true );
179
180 // LoadSettings() *after* creating m_LayersManager, because LoadSettings() initialize
181 // parameters in m_LayersManager
182 // NOTE: KifaceSettings() will return PCBNEW_SETTINGS if we started from pcbnew
183 LoadSettings( GetSettings() );
184
185 // Must be set after calling LoadSettings() to be sure these parameters are not dependent
186 // on what is read in stored settings. Enable one internal layer, because footprints
187 // support keepout areas that can be on internal layers only (therefore on the first internal
188 // layer). This is needed to handle these keepout in internal layers only.
190 GetBoard()->SetEnabledLayers( GetBoard()->GetEnabledLayers().set( In1_Cu ) );
191 GetBoard()->SetVisibleLayers( GetBoard()->GetEnabledLayers() );
192 GetBoard()->SetLayerName( In1_Cu, _( "Inner layers" ) );
193
194 SetActiveLayer( F_SilkS );
195
196 m_auimgr.SetManagedWindow( this );
197
198 CreateInfoBar();
199
200 unsigned int auiFlags = wxAUI_MGR_DEFAULT;
201#if !defined( _WIN32 )
202 // Windows cannot redraw the UI fast enough during a live resize and may lead to all kinds
203 // of graphical glitches
204 auiFlags |= wxAUI_MGR_LIVE_RESIZE;
205#endif
206 m_auimgr.SetFlags( auiFlags );
207
208 // Rows; layers 4 - 6
209 m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" )
210 .Top().Layer( 6 ) );
211
212 m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" )
213 .Bottom().Layer( 6 ) );
214
215 // Columns; layers 1 - 3
216 m_auimgr.AddPane( m_treePane, EDA_PANE().Palette().Name( "Footprints" )
217 .Left().Layer( 3 )
218 .Caption( _( "Libraries" ) )
219 .MinSize( 250, -1 ).BestSize( 250, -1 ) );
220 m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" )
221 .Left().Layer( 2 ) );
222
223 m_auimgr.AddPane( m_drawToolBar, EDA_PANE().VToolbar().Name( "ToolsToolbar" )
224 .Right().Layer(2) );
225 m_auimgr.AddPane( m_appearancePanel, EDA_PANE().Name( "LayersManager" )
226 .Right().Layer( 3 )
227 .Caption( _( "Appearance" ) ).PaneBorder( false )
228 .MinSize( 180, -1 ).BestSize( 180, -1 ) );
229 m_auimgr.AddPane( m_selectionFilterPanel, EDA_PANE().Palette().Name( "SelectionFilter" )
230 .Right().Layer( 3 ).Position( 2 )
231 .Caption( _( "Selection Filter" ) ).PaneBorder( false )
232 .MinSize( 160, -1 ).BestSize( m_selectionFilterPanel->GetBestSize() ) );
233
234 // Center
235 m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( "DrawFrame" )
236 .Center() );
237
238 m_auimgr.GetPane( "LayersManager" ).Show( m_show_layer_manager_tools );
239 m_auimgr.GetPane( "SelectionFilter" ).Show( m_show_layer_manager_tools );
240
241 // The selection filter doesn't need to grow in the vertical direction when docked
242 m_auimgr.GetPane( "SelectionFilter" ).dock_proportion = 0;
243
244 m_acceptedExts.emplace( KiCadFootprintLibPathExtension, &ACTIONS::ddAddLibrary );
246 DragAcceptFiles( true );
247
248 ActivateGalCanvas();
249
250 FinishAUIInitialization();
251
252 // Apply saved visibility stuff at the end
253 FOOTPRINT_EDITOR_SETTINGS* cfg = GetSettings();
254 wxAuiPaneInfo& treePane = m_auimgr.GetPane( "Footprints" );
255 wxAuiPaneInfo& layersManager = m_auimgr.GetPane( "LayersManager" );
256
257 // wxAUI hack: force widths by setting MinSize() and then Fixed()
258 // thanks to ZenJu http://trac.wxwidgets.org/ticket/13180
259
260 if( cfg->m_LibWidth > 0 )
261 {
262 SetAuiPaneSize( m_auimgr, treePane, cfg->m_LibWidth, -1 );
263
264 treePane.MinSize( cfg->m_LibWidth, -1 );
265 treePane.Fixed();
266 }
267
268 if( cfg->m_AuiPanels.right_panel_width > 0 )
269 {
270 SetAuiPaneSize( m_auimgr, layersManager, cfg->m_AuiPanels.right_panel_width, -1 );
271
272 layersManager.MinSize( cfg->m_LibWidth, -1 );
273 layersManager.Fixed();
274 }
275
276 // Apply fixed sizes
277 m_auimgr.Update();
278
279 // Now make them resizable again
280 treePane.Resizable();
281 m_auimgr.Update();
282
283 // Note: DO NOT call m_auimgr.Update() anywhere after this; it will nuke the sizes
284 // back to minimum.
285 treePane.MinSize( 250, -1 );
286 layersManager.MinSize( 250, -1 );
287
288 m_appearancePanel->SetUserLayerPresets( cfg->m_LayerPresets );
289 m_appearancePanel->ApplyLayerPreset( cfg->m_ActiveLayerPreset );
290 m_appearancePanel->SetTabIndex( cfg->m_AuiPanels.appearance_panel_tab );
291
292 GetToolManager()->RunAction( ACTIONS::zoomFitScreen, false );
293 UpdateTitle();
294 setupUnits( GetSettings() );
295
296 resolveCanvasType();
297
298 // Default shutdown reason until a file is loaded
299 KIPLATFORM::APP::SetShutdownBlockReason( this, _( "Footprint changes are unsaved" ) );
300
301 // Catch unhandled accelerator command characters that were no handled by the library tree
302 // panel.
303 Bind( wxEVT_CHAR, &TOOL_DISPATCHER::DispatchWxEvent, m_toolDispatcher );
304 Bind( wxEVT_CHAR_HOOK, &TOOL_DISPATCHER::DispatchWxEvent, m_toolDispatcher );
305
306 // Ensure the window is on top
307 Raise();
308 Show( true );
309
310 // Register a call to update the toolbar sizes. It can't be done immediately because
311 // it seems to require some sizes calculated that aren't yet (at least on GTK).
312 CallAfter( [&]()
313 {
314 // Ensure the controls on the toolbars all are correctly sized
315 UpdateToolbarControlSizes();
316 } );
317}
318
319
321{
322 // Shutdown all running tools
323 if( m_toolManager )
325
326 // save the footprint in the PROJECT
328
330 delete m_appearancePanel;
331 delete m_treePane;
332}
333
334
336{
338}
339
340
342{
343 return m_toolManager->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
344}
345
346
348{
349 // switches currently used canvas (Cairo / OpenGL).
350 PCB_BASE_FRAME::SwitchCanvas( aCanvasType );
351
352 GetCanvas()->GetGAL()->SetAxesEnabled( true );
353
354 // The base class method *does not reinit* the layers manager. We must update the layer
355 // widget to match board visibility states, both layers and render columns, and and some
356 // settings dependent on the canvas.
358}
359
360
362{
363 SyncLibraryTree( true );
365}
366
367
369{
370 wxAuiPaneInfo& treePane = m_auimgr.GetPane( m_treePane );
371 treePane.Show( !IsSearchTreeShown() );
372
373 if( IsSearchTreeShown() )
374 {
375 // SetAuiPaneSize also updates m_auimgr
377 }
378 else
379 {
380 m_editorSettings->m_LibWidth = m_treePane->GetSize().x;
381 m_auimgr.Update();
382 }
383}
384
385
387{
389 wxAuiPaneInfo& layersManager = m_auimgr.GetPane( "LayersManager" );
390 wxAuiPaneInfo& selectionFilter = m_auimgr.GetPane( "SelectionFilter" );
391
392 // show auxiliary Vertical layers and visibility manager toolbar
394 layersManager.Show( m_show_layer_manager_tools );
395 selectionFilter.Show( m_show_layer_manager_tools );
396
398 {
399 SetAuiPaneSize( m_auimgr, layersManager, settings->m_AuiPanels.right_panel_width, -1 );
400 }
401 else
402 {
403 settings->m_AuiPanels.right_panel_width = m_appearancePanel->GetSize().x;
404 m_auimgr.Update();
405 }
406}
407
408
410{
411 return const_cast<wxAuiManager&>( m_auimgr ).GetPane( m_treePane ).IsShown();
412}
413
414
416{
417 return GetBoard()->GetFirstFootprint();
418}
419
420
422{
424}
425
426
428{
430}
431
432
434{
435 LIB_ID id;
436
437 if( IsSearchTreeShown() )
438 id = GetTreeFPID();
439
440 if( id.GetLibNickname().empty() )
441 id = GetLoadedFPID();
442
443 return id;
444}
445
446
448{
449 FOOTPRINT* footprint = GetBoard()->GetFirstFootprint();
450
451 if( footprint )
452 return LIB_ID( footprint->GetFPID().GetLibNickname(), m_footprintNameWhenLoaded );
453 else
454 return LIB_ID();
455}
456
457
459{
460 if( GetBoard()->GetFirstFootprint() )
462
463 GetScreen()->SetContentModified( false );
464}
465
466
468{
469 FOOTPRINT* footprint = GetBoard()->GetFirstFootprint();
470
471 return ( footprint && footprint->GetLink() != niluuid );
472}
473
474
476{
477 LIB_ID id = GetLoadedFPID();
478
479 if( id.IsValid() )
480 {
482 Prj().SetRString( PROJECT::PCB_FOOTPRINT_EDITOR_FP_NAME, id.GetLibItemName() );
483 }
484}
485
486
488{
489 const wxString& footprintName = Prj().GetRString( PROJECT::PCB_FOOTPRINT_EDITOR_FP_NAME );
490 const wxString& libNickname = Prj().GetRString( PROJECT::PCB_FOOTPRINT_EDITOR_LIB_NICKNAME );
491
492 if( libNickname.Length() && footprintName.Length() )
493 {
494 LIB_ID id;
495 id.SetLibNickname( libNickname );
496 id.SetLibItemName( footprintName );
497
498 FOOTPRINT* footprint = loadFootprint( id );
499
500 if( footprint )
501 AddFootprintToBoard( footprint );
502 }
503}
504
505
507{
508 m_revertModule.reset( (FOOTPRINT*) aFootprint->Clone() );
509
511
513 // Ensure item UUIDs are valid
514 // ("old" footprints can have null uuids that create issues in fp editor)
515 aFootprint->FixUuids();
516
518 {
519 wxString msg;
520 msg.Printf( _( "Editing %s from board. Saving will update the board only." ),
521 aFootprint->GetReference() );
522
525 GetInfoBar()->ShowMessage( msg, wxICON_INFORMATION );
526 }
527
529}
530
531
533{
535}
536
537
539{
540 return GetBoard()->GetDesignSettings();
541}
542
543
545{
546 wxFAIL_MSG( wxT( "Plotting not supported in Footprint Editor" ) );
547
549}
550
551
553{
554 wxFAIL_MSG( wxT( "Plotting not supported in Footprint Editor" ) );
555}
556
557
559{
560 if( !m_editorSettings )
561 m_editorSettings = Pgm().GetSettingsManager().GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>();
562
563 return m_editorSettings;
564}
565
566
568{
570 : Pgm().GetSettingsManager().GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>();
571}
572
573
575{
576 // aCfg will be the PCBNEW_SETTINGS
578
580
582
585
588}
589
590
592{
594
595 // aCfg will be the PCBNEW_SETTINGS
597
599
602 cfg->m_LibWidth = m_treePane->GetSize().x;
606
610}
611
612
613
615{
616 FOOTPRINT_EDITOR_SETTINGS* cfg = const_cast<FOOTPRINT_EDIT_FRAME*>( this )->GetSettings();
617
618 return cfg ? cfg->m_RotationAngle : ANGLE_90;
619}
620
621
622
624{
625 wxString currentTheme = GetFootprintEditorSettings()->m_ColorTheme;
626 return Pgm().GetSettingsManager().GetColorSettings( currentTheme );
627}
628
629
631{
632 // Get the actual frame settings for magnetic items
634 wxCHECK( cfg, nullptr );
635 return &cfg->m_MagneticItems;
636}
637
638
639const BOX2I FOOTPRINT_EDIT_FRAME::GetDocumentExtents( bool aIncludeAllVisible ) const
640{
641 FOOTPRINT* footprint = GetBoard()->GetFirstFootprint();
642
643 if( footprint )
644 {
645 bool hasGraphicalItem = footprint->Pads().size() || footprint->Zones().size();
646
647 if( !hasGraphicalItem )
648 {
649 for( const BOARD_ITEM* item : footprint->GraphicalItems() )
650 {
651 if( item->Type() == PCB_FP_TEXT_T )
652 continue;
653
654 hasGraphicalItem = true;
655 break;
656 }
657 }
658
659 if( hasGraphicalItem )
660 {
661 return footprint->GetBoundingBox( false, false );
662 }
663 else
664 {
665 BOX2I newFootprintBB( { 0, 0 }, { 0, 0 } );
666 newFootprintBB.Inflate( pcbIUScale.mmToIU( 12 ) );
667 return newFootprintBB;
668 }
669 }
670
671 return GetBoardBoundingBox( false );
672}
673
674
676{
677 if( IsContentModified() )
678 {
679 wxString footprintName = GetBoard()->GetFirstFootprint()->GetReference();
680 wxString msg = _( "Save changes to '%s' before closing?" );
681
682 if( !HandleUnsavedChanges( this, wxString::Format( msg, footprintName ),
683 [&]() -> bool
684 {
685 return SaveFootprint( GetBoard()->GetFirstFootprint() );
686 } ) )
687 {
688 return false;
689 }
690 }
691
692 if( doClose )
693 {
694 GetInfoBar()->ShowMessageFor( wxEmptyString, 1 );
695 Clear_Pcb( false );
696 UpdateTitle();
697 }
698
699 return true;
700}
701
702
703bool FOOTPRINT_EDIT_FRAME::canCloseWindow( wxCloseEvent& aEvent )
704{
705 if( IsContentModified() )
706 {
707 // Shutdown blocks must be determined and vetoed as early as possible
709 aEvent.GetId() == wxEVT_QUERY_END_SESSION )
710 {
711 aEvent.Veto();
712 return false;
713 }
714
715 wxString footprintName = GetBoard()->GetFirstFootprint()->GetFPID().GetLibItemName();
716
718 footprintName = GetBoard()->GetFirstFootprint()->GetReference();
719
720 wxString msg = _( "Save changes to '%s' before closing?" );
721
722 if( !HandleUnsavedChanges( this, wxString::Format( msg, footprintName ),
723 [&]() -> bool
724 {
725 return SaveFootprint( GetBoard()->GetFirstFootprint() );
726 } ) )
727 {
728 aEvent.Veto();
729 return false;
730 }
731 }
732
734}
735
736
738{
739 // No more vetos
740 GetCanvas()->SetEventDispatcher( nullptr );
742
743 // Do not show the layer manager during closing to avoid flicker
744 // on some platforms (Windows) that generate useless redraw of items in
745 // the Layer Manager
746 m_auimgr.GetPane( wxT( "LayersManager" ) ).Show( false );
747 m_auimgr.GetPane( wxT( "SelectionFilter" ) ).Show( false );
748
749 Clear_Pcb( false );
750
752
753 if( mgr->IsProjectOpen() && wxFileName::IsDirWritable( Prj().GetProjectPath() ) )
754 {
755 GFootprintList.WriteCacheToFile( Prj().GetProjectPath() + wxT( "fp-info-cache" ) );
756 }
757
759}
760
761
762void FOOTPRINT_EDIT_FRAME::OnExitKiCad( wxCommandEvent& event )
763{
764 Kiway().OnKiCadExit();
765}
766
767
769{
770 Close();
771}
772
773
775{
777
778 aEvent.Enable( frame && frame->GetBoard()->GetFirstFootprint() != nullptr );
779}
780
781
783{
785
786 FOOTPRINT* editorFootprint = GetBoard()->GetFirstFootprint();
787 bool canInsert = frame && editorFootprint && editorFootprint->GetLink() == niluuid;
788
789 // If the source was deleted, the footprint can inserted but not updated in the board.
790 if( frame && editorFootprint && editorFootprint->GetLink() != niluuid )
791 {
792 BOARD* mainpcb = frame->GetBoard();
793 canInsert = true;
794
795 // search if the source footprint was not deleted:
796 for( FOOTPRINT* candidate : mainpcb->Footprints() )
797 {
798 if( editorFootprint->GetLink() == candidate->m_Uuid )
799 {
800 canInsert = false;
801 break;
802 }
803 }
804 }
805
806 aEvent.Enable( canInsert );
807}
808
809
811{
812 // call my base class
814
815 // We have 2 panes to update.
816 // For some obscure reason, the AUI manager hides the first modified pane.
817 // So force show panes
818 wxAuiPaneInfo& tree_pane_info = m_auimgr.GetPane( m_treePane );
819 bool tree_shown = tree_pane_info.IsShown();
820 tree_pane_info.Caption( _( "Libraries" ) );
821
822 wxAuiPaneInfo& lm_pane_info = m_auimgr.GetPane( m_appearancePanel );
823 bool lm_shown = lm_pane_info.IsShown();
824 lm_pane_info.Caption( _( "Appearance" ) );
825 wxAuiPaneInfo& sf_pane_info = m_auimgr.GetPane( m_selectionFilterPanel );
826 sf_pane_info.Caption( _( "Selection Filter" ) );
827
828 // update the layer manager
832
833 // Now restore the visibility:
834 lm_pane_info.Show( lm_shown );
835 tree_pane_info.Show( tree_shown );
836 m_auimgr.Update();
837
838 UpdateTitle();
839}
840
841
843{
845 Update3DView( true, true );
847
848 if( !GetTitle().StartsWith( wxT( "*" ) ) )
849 UpdateTitle();
850}
851
852
854{
855 wxString title;
856 LIB_ID fpid = GetLoadedFPID();
857 FOOTPRINT* footprint = GetBoard()->GetFirstFootprint();
858 bool writable = true;
859
861 {
862 if( IsContentModified() )
863 title = wxT( "*" );
864
865 title += footprint->GetReference();
866 title += wxS( " " ) + wxString::Format( _( "[from %s]" ), Prj().GetProjectName()
867 + wxT( "." )
869 }
870 else if( fpid.IsValid() )
871 {
872 try
873 {
875 }
876 catch( const IO_ERROR& )
877 {
878 // best efforts...
879 }
880
881 // Note: don't used GetLoadedFPID(); footprint name may have been edited
882 if( IsContentModified() )
883 title = wxT( "*" );
884
885 title += FROM_UTF8( footprint->GetFPID().Format().c_str() );
886
887 if( !writable )
888 title += wxS( " " ) + _( "[Read Only]" );
889 }
890 else if( !fpid.GetLibItemName().empty() )
891 {
892 // Note: don't used GetLoadedFPID(); footprint name may have been edited
893 if( IsContentModified() )
894 title = wxT( "*" );
895
896 title += FROM_UTF8( footprint->GetFPID().GetLibItemName().c_str() );
897 title += wxS( " " ) + _( "[Unsaved]" );
898 }
899 else
900 {
901 title = _( "[no footprint loaded]" );
902 }
903
904 title += wxT( " \u2014 " ) + _( "Footprint Editor" );
905
906 SetTitle( title );
907}
908
909
911{
913}
914
915
917{
921 UpdateTitle();
922}
923
924
926{
927 FP_LIB_TABLE* fpTable = Prj().PcbFootprintLibs();
928
929 WX_PROGRESS_REPORTER progressReporter( this, _( "Loading Footprint Libraries" ), 2 );
930
931 if( GFootprintList.GetCount() == 0 )
932 GFootprintList.ReadCacheFromFile( Prj().GetProjectPath() + wxT( "fp-info-cache" ) );
933
934 GFootprintList.ReadFootprintFiles( fpTable, nullptr, &progressReporter );
935 progressReporter.Show( false );
936
939
941 auto adapter = static_cast<FP_TREE_SYNCHRONIZING_ADAPTER*>( m_adapter.get() );
942
943 adapter->AddLibraries( this );
944}
945
946
948{
949 FP_LIB_TABLE* fpTable = Prj().PcbFootprintLibs();
950 auto adapter = static_cast<FP_TREE_SYNCHRONIZING_ADAPTER*>( m_adapter.get() );
951 LIB_ID target = GetTargetFPID();
952 bool targetSelected = ( target == m_treePane->GetLibTree()->GetSelectedLibId() );
953
954 // Sync FOOTPRINT_INFO list to the libraries on disk
955 if( aProgress )
956 {
957 WX_PROGRESS_REPORTER progressReporter( this, _( "Updating Footprint Libraries" ), 2 );
958 GFootprintList.ReadFootprintFiles( fpTable, nullptr, &progressReporter );
959 progressReporter.Show( false );
960 }
961 else
962 {
963 GFootprintList.ReadFootprintFiles( fpTable, nullptr, nullptr );
964 }
965
966 // Sync the LIB_TREE to the FOOTPRINT_INFO list
967 adapter->Sync();
968
970 m_treePane->GetLibTree()->Regenerate( true );
971
972 if( target.IsValid() )
973 {
974 if( adapter->FindItem( target ) )
975 {
976 if( targetSelected )
977 m_treePane->GetLibTree()->SelectLibId( target );
978 else
979 m_treePane->GetLibTree()->CenterLibId( target );
980 }
981 else
982 {
983 // Try to focus on parent
984 target.SetLibItemName( wxEmptyString );
985 m_treePane->GetLibTree()->CenterLibId( target );
986 }
987 }
988}
989
990
992{
993 LIB_ID target = GetTargetFPID();
994
995 m_treePane->GetLibTree()->Regenerate( true );
996
997 if( target.IsValid() )
998 m_treePane->GetLibTree()->CenterLibId( target );
999}
1000
1001
1003{
1005}
1006
1007
1009{
1010 m_treePane->GetLibTree()->SelectLibId( aLibID );
1011}
1012
1013
1015{
1017}
1018
1019
1021{
1022 // Create the manager and dispatcher & route draw panel events to the dispatcher
1025 GetCanvas()->GetViewControls(), config(), this );
1026 m_actions = new PCB_ACTIONS();
1028
1030
1039 m_toolManager->RegisterTool( new PCB_CONTROL ); // copy/paste
1048
1049 for( TOOL_BASE* tool : m_toolManager->Tools() )
1050 {
1051 if( PCB_TOOL_BASE* pcbTool = dynamic_cast<PCB_TOOL_BASE*>( tool ) )
1052 pcbTool->SetIsFootprintEditor( true );
1053 }
1054
1055 m_toolManager->GetTool<PCB_VIEWER_TOOLS>()->SetFootprintFrame( true );
1057
1058 m_toolManager->InvokeTool( "pcbnew.InteractiveSelection" );
1059}
1060
1061
1063{
1065
1067 PCB_EDITOR_CONDITIONS cond( this );
1068
1069 wxASSERT( mgr );
1070
1071#define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
1072#define CHECK( x ) ACTION_CONDITIONS().Check( x )
1073
1074 auto haveFootprintCond =
1075 [this]( const SELECTION& )
1076 {
1077 return GetBoard()->GetFirstFootprint() != nullptr;
1078 };
1079
1080 auto footprintTargettedCond =
1081 [this]( const SELECTION& )
1082 {
1083 return !GetTargetFPID().GetLibItemName().empty();
1084 };
1085
1086 mgr->SetConditions( ACTIONS::saveAs, ENABLE( footprintTargettedCond ) );
1089
1092
1098
1099 mgr->SetConditions( ACTIONS::cut, ENABLE( cond.HasItems() ) );
1100 mgr->SetConditions( ACTIONS::copy, ENABLE( cond.HasItems() ) );
1106
1107 auto haveAtLeastOneGroupCond =
1108 []( const SELECTION& aSel )
1109 {
1110 for( EDA_ITEM* item : aSel )
1111 {
1112 if( item->Type() == PCB_GROUP_T )
1113 return true;
1114 }
1115
1116 return false;
1117 };
1118
1124 mgr->SetConditions( PCB_ACTIONS::ungroup, ENABLE( haveAtLeastOneGroupCond ) );
1125
1129
1132
1133 auto constrainedDrawingModeCond =
1134 [this]( const SELECTION& )
1135 {
1136 return GetSettings()->m_Use45Limit;
1137 };
1138
1139 auto highContrastCond =
1140 [this]( const SELECTION& )
1141 {
1143 };
1144
1145 auto boardFlippedCond =
1146 [this]( const SELECTION& )
1147 {
1148 return GetCanvas()->GetView()->IsMirroredX();
1149 };
1150
1151 auto footprintTreeCond =
1152 [this](const SELECTION& )
1153 {
1154 return IsSearchTreeShown();
1155 };
1156
1157 auto layerManagerCond =
1158 [this]( const SELECTION& )
1159 {
1160 return m_auimgr.GetPane( "LayersManager" ).IsShown();
1161 };
1162
1163 mgr->SetConditions( PCB_ACTIONS::toggleHV45Mode, CHECK( constrainedDrawingModeCond ) );
1164 mgr->SetConditions( ACTIONS::highContrastMode, CHECK( highContrastCond ) );
1165 mgr->SetConditions( PCB_ACTIONS::flipBoard, CHECK( boardFlippedCond ) );
1167
1168 mgr->SetConditions( PCB_ACTIONS::showFootprintTree, CHECK( footprintTreeCond ) );
1169 mgr->SetConditions( PCB_ACTIONS::showLayersManager, CHECK( layerManagerCond ) );
1170
1171 mgr->SetConditions( ACTIONS::print, ENABLE( haveFootprintCond ) );
1172 mgr->SetConditions( PCB_ACTIONS::exportFootprint, ENABLE( haveFootprintCond ) );
1173 mgr->SetConditions( PCB_ACTIONS::placeImportedGraphics, ENABLE( haveFootprintCond ) );
1174
1175 mgr->SetConditions( PCB_ACTIONS::footprintProperties, ENABLE( haveFootprintCond ) );
1176 mgr->SetConditions( PCB_ACTIONS::editTextAndGraphics, ENABLE( haveFootprintCond ) );
1177 mgr->SetConditions( PCB_ACTIONS::checkFootprint, ENABLE( haveFootprintCond ) );
1178 mgr->SetConditions( PCB_ACTIONS::repairFootprint, ENABLE( haveFootprintCond ) );
1179 mgr->SetConditions( PCB_ACTIONS::cleanupGraphics, ENABLE( haveFootprintCond ) );
1180
1181
1182// Only enable a tool if the part is edtable
1183#define CURRENT_EDIT_TOOL( action ) mgr->SetConditions( action, \
1184 ACTION_CONDITIONS().Enable( haveFootprintCond ).Check( cond.CurrentTool( action ) ) )
1185
1205
1206#undef CURRENT_EDIT_TOOL
1207#undef ENABLE
1208#undef CHECK
1209}
1210
1211
1213{
1215
1216 // Be sure the axis are enabled
1217 GetCanvas()->GetGAL()->SetAxesEnabled( true );
1218
1219 UpdateView();
1220
1221 // Ensure the m_Layers settings are using the canvas type:
1223}
1224
1225
1226void FOOTPRINT_EDIT_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
1227{
1228 PCB_BASE_EDIT_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
1229
1230 auto cfg = Pgm().GetSettingsManager().GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>();
1231 GetGalDisplayOptions().ReadWindowSettings( cfg->m_Window );
1232
1236
1238
1239 if( aEnvVarsChanged )
1240 SyncLibraryTree( true );
1241
1242 Layout();
1243 SendSizeEvent();
1244}
1245
1246
1248{
1249 LIB_ID id = GetLoadedFPID();
1250
1251 if( id.empty() )
1252 {
1253 wxMessageBox( _( "No footprint selected." ) );
1254 return;
1255 }
1256
1257 wxFileName fn( id.GetLibItemName() );
1258 fn.SetExt( wxT( "png" ) );
1259
1260 wxString projectPath = wxPathOnly( Prj().GetProjectFullName() );
1261
1262 wxFileDialog dlg( this, _( "Footprint Image File Name" ), projectPath,
1263 fn.GetFullName(), PngFileWildcard(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
1264
1265 if( dlg.ShowModal() == wxID_CANCEL || dlg.GetPath().IsEmpty() )
1266 return;
1267
1268 // calling wxYield is mandatory under Linux, after closing the file selector dialog
1269 // to refresh the screen before creating the PNG or JPEG image from screen
1270 wxYield();
1271 SaveCanvasImageToFile( this, dlg.GetPath() );
1272}
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:109
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Definition: bitmap.cpp:105
bool SaveCanvasImageToFile(EDA_DRAW_FRAME *aFrame, const wxString &aFileName, BITMAP_TYPE aBitmapType)
Save the current view as an image file.
Definition: bitmap.cpp:207
@ icon_modedit_32
@ icon_modedit
@ icon_modedit_16
@ NORMAL
Inactive layers are shown normally (no high-contrast mode)
static TOOL_ACTION toggleGrid
Definition: actions.h:143
static TOOL_ACTION paste
Definition: actions.h:69
static TOOL_ACTION millimetersUnits
Definition: actions.h:149
static TOOL_ACTION revert
Definition: actions.h:55
static TOOL_ACTION saveAs
Definition: actions.h:52
static TOOL_ACTION copy
Definition: actions.h:68
static TOOL_ACTION pasteSpecial
Definition: actions.h:70
static TOOL_ACTION milsUnits
Definition: actions.h:148
static TOOL_ACTION toggleBoundingBoxes
Definition: actions.h:107
static TOOL_ACTION undo
Definition: actions.h:65
static TOOL_ACTION duplicate
Definition: actions.h:72
static TOOL_ACTION inchesUnits
Definition: actions.h:147
static TOOL_ACTION highContrastMode
Definition: actions.h:105
static TOOL_ACTION toggleCursorStyle
Definition: actions.h:104
static TOOL_ACTION measureTool
Definition: actions.h:157
static TOOL_ACTION doDelete
Definition: actions.h:73
static TOOL_ACTION selectionTool
Definition: actions.h:156
static TOOL_ACTION save
Definition: actions.h:51
static TOOL_ACTION zoomFitScreen
Definition: actions.h:98
static TOOL_ACTION redo
Definition: actions.h:66
static TOOL_ACTION deleteTool
Definition: actions.h:74
static TOOL_ACTION zoomTool
Definition: actions.h:101
static TOOL_ACTION print
Definition: actions.h:57
static TOOL_ACTION cut
Definition: actions.h:67
static TOOL_ACTION gridSetOrigin
Definition: actions.h:140
static TOOL_ACTION ddAddLibrary
Definition: actions.h:60
static TOOL_ACTION selectAll
Definition: actions.h:71
Manage TOOL_ACTION objects.
void SetConditions(const TOOL_ACTION &aAction, const ACTION_CONDITIONS &aConditions)
Set the conditions the UI elements for activating a specific tool action should use for determining t...
std::vector< LAYER_PRESET > GetUserLayerPresets() const
Update the current layer presets from those saved in the project file.
int GetTabIndex() const
Set the current notebook tab.
void UpdateDisplayOptions()
Return a list of the layer presets created by the user.
wxString GetActiveLayerPreset() const
void OnLanguageChanged()
Update the panel contents from the application and board models.
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:101
wxString m_ColorTheme
Active color theme name.
Definition: app_settings.h:187
bool IsContentModified() const
Definition: base_screen.h:60
void SetContentModified(bool aModified=true)
Definition: base_screen.h:59
Container for design settings for a BOARD object.
std::shared_ptr< NET_SETTINGS > m_NetSettings
Abstract interface for BOARD_ITEMs capable of storing other items inside.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:50
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:265
void SetBoardUse(BOARD_USE aUse)
Set what the board is going to be used for.
Definition: board.h:277
void SetEnabledLayers(LSET aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings.
Definition: board.cpp:520
bool SetLayerName(PCB_LAYER_ID aLayer, const wxString &aLayerName)
Changes the name of the layer given by aLayer.
Definition: board.cpp:415
FOOTPRINT * GetFirstFootprint() const
Get the first footprint on the board or nullptr.
Definition: board.h:397
FOOTPRINTS & Footprints()
Definition: board.h:307
void SetVisibleAlls()
Change the bit-mask of visible element categories and layers.
Definition: board.cpp:549
void SetVisibleLayers(LSET aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings changes the bit-mask of vis...
Definition: board.cpp:532
void SetCopperLayerCount(int aCount)
Definition: board.cpp:494
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:617
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
Definition: box2.h:506
Color settings are a bit different than most of the settings objects in that there can be more than o...
Handle actions that are shared between different applications.
Handles action that are shared between different applications.
Definition: common_tools.h:38
Tool responsible for drawing graphical elements like lines, arcs, circles, etc.
Definition: drawing_tool.h:51
virtual void setupUIConditions()
Setup the UI conditions for the various actions and their controls in this frame.
SETTINGS_MANAGER * GetSettingsManager() const
wxAuiManager m_auimgr
WX_INFOBAR * GetInfoBar()
void OnSelectGrid(wxCommandEvent &event)
Command event handler for selecting grid sizes.
KIGFX::GAL_DISPLAY_OPTIONS & GetGalDisplayOptions()
Return a reference to the gal rendering options used by GAL for rendering.
virtual void SwitchCanvas(EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType)
Changes the current rendering backend.
virtual void OnSize(wxSizeEvent &event) override
Recalculate the size of toolbars and display panel when the frame size changes.
virtual void OnSelectZoom(wxCommandEvent &event)
Set the zoom factor when selected by the zoom list box in the main tool bar.
virtual void UpdateMsgPanel()
Redraw the message panel.
void OnGridSettings(wxCommandEvent &event)
void StopDrawing()
Prevent the GAL canvas from further drawing until it is recreated or StartDrawing() is called.
void ForceRefresh()
Force a redraw.
KIGFX::GAL * GetGAL() const
Return a pointer to the GAL instance used in the panel.
void SetEventDispatcher(TOOL_DISPATCHER *aEventDispatcher)
Set a dispatcher that processes events and forwards them to tools.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:85
Specialization of the wxAuiPaneInfo class for KiCad panels.
SELECTION_CONDITION NoActiveTool()
Create a functor testing if there are no tools active in the frame.
SELECTION_CONDITION BoundingBoxes()
SELECTION_CONDITION RedoAvailable()
Create a functor that tests if there are any items in the redo queue.
SELECTION_CONDITION CurrentTool(const TOOL_ACTION &aTool)
Create a functor testing if the specified tool is the current active tool in the frame.
SELECTION_CONDITION UndoAvailable()
Create a functor that tests if there are any items in the undo queue.
SELECTION_CONDITION Units(EDA_UNITS aUnit)
Create a functor that tests if the frame has the specified units.
SELECTION_CONDITION GridVisible()
Create a functor testing if the grid is visible in a frame.
SELECTION_CONDITION ContentModified()
Create a functor that tests if the content of the frame is modified.
SELECTION_CONDITION FullscreenCursor()
Create a functor testing if the cursor is full screen in a frame.
The interactive edit tool.
Definition: edit_tool.h:65
Module editor specific tools.
BOARD_DESIGN_SETTINGS m_DesignSettings
Only some of these settings are actually used for footprint editing.
std::vector< LAYER_PRESET > m_LayerPresets
SELECTION_FILTER_OPTIONS m_SelectionFilter
void CloseFootprintEditor(wxCommandEvent &Event)
BOARD_DESIGN_SETTINGS & GetDesignSettings() const override
Returns the BOARD_DESIGN_SETTINGS for the open project.
void setupUIConditions() override
Setup the UI conditions for the various actions and their controls in this frame.
void ActivateGalCanvas() override
Use to start up the GAL drawing canvas.
void HardRedraw() override
Refresh the library tree and redraw the window.
static const wxChar * GetFootprintEditorFrameName()
void SyncLibraryTree(bool aProgress)
Synchronize the footprint library tree to the current state of the footprint library table.
void OnSaveFootprintAsPng(wxCommandEvent &event)
BOARD_ITEM_CONTAINER * GetModel() const override
bool canCloseWindow(wxCloseEvent &Event) override
LIB_ID GetTargetFPID() const
Return the LIB_ID of the part selected in the footprint tree, or the loaded part if there is no selec...
LIB_ID GetLoadedFPID() const
Return the LIB_ID of the part being edited.
APP_SETTINGS_BASE * config() const override
Returns the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
void SelectLayer(wxCommandEvent &event)
LIB_TREE_NODE * GetCurrentTreeNode() const
void SetPlotSettings(const PCB_PLOT_PARAMS &aSettings) override
bool SaveFootprint(FOOTPRINT *aFootprint)
Save in an existing library a given footprint.
LIB_ID GetTreeFPID() const
Return the LIB_ID of the part or library selected in the footprint tree.
void initLibraryTree()
Make sure the footprint info list is loaded (with a progress dialog) and then initialize the footprin...
void OnLoadFootprintFromBoard(wxCommandEvent &event)
Called from the main toolbar to load a footprint from board mainly to edit it.
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Called after the preferences dialog is run.
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
void ShowChangedLanguage() override
Update visible items after a language change.
void OnSaveFootprintToBoard(wxCommandEvent &event)
bool IsContentModified() const override
Get if any footprints or libraries have been modified but not saved.
void UpdateUserInterface()
Update the layer manager and other widgets from the board setup (layer and items visibility,...
std::unique_ptr< FOOTPRINT > m_revertModule
wxObjectDataPtr< LIB_TREE_MODEL_ADAPTER > m_adapter
FOOTPRINT_EDITOR_SETTINGS * m_editorSettings
const BOX2I GetDocumentExtents(bool aIncludeAllVisible=true) const override
Returns bbox of document with option to not include some items.
void OnUpdateLoadFootprintFromBoard(wxUpdateUIEvent &aEvent)
void OnUpdateSaveFootprintToBoard(wxUpdateUIEvent &aEvent)
Install the corresponding dialog editor for the given item.
SELECTION & GetCurrentSelection() override
Get the current selection from the canvas area.
bool CanCloseFPFromBoard(bool doClose)
void RegenerateLibraryTree()
Filter, sort, and redisplay the library tree.
void AddFootprintToBoard(FOOTPRINT *aFootprint) override
Override from PCB_BASE_EDIT_FRAME which adds a footprint to the editor's dummy board,...
void OnModify() override
Must be called after a footprint change in order to set the "modify" flag of the current screen and p...
FOOTPRINT_TREE_PANE * m_treePane
bool Clear_Pcb(bool aQuery)
Delete all and reinitialize the current board.
Definition: initpcb.cpp:97
void OnDisplayOptionsChanged() override
void FocusOnLibID(const LIB_ID &aLibID)
const PCB_PLOT_PARAMS & GetPlotSettings() const override
Return the PCB_PLOT_PARAMS for the BOARD owned by this frame.
EDA_ANGLE GetRotationAngle() const override
Return the angle used for rotate operations.
void RefreshLibraryTree()
Redisplay the library tree.
void OnExitKiCad(wxCommandEvent &aEvent)
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
MAGNETIC_SETTINGS * GetMagneticItemsSettings() override
FOOTPRINT_EDITOR_SETTINGS * GetSettings()
void SwitchCanvas(EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType) override
Switch the currently used canvas (Cairo / OpenGL).
COLOR_SETTINGS * GetColorSettings(bool aForceRefresh=false) const override
Helper to retrieve the current color settings.
bool ReadFootprintFiles(FP_LIB_TABLE *aTable, const wxString *aNickname=nullptr, PROGRESS_REPORTER *aProgressReporter=nullptr) override
Read all the footprints provided by the combination of aTable and aNickname.
void WriteCacheToFile(const wxString &aFilePath) override
void ReadCacheFromFile(const wxString &aFilePath) override
void DisplayErrors(wxTopLevelWindow *aCaller=nullptr)
unsigned GetErrorCount() const
unsigned GetCount() const
Footprint Editor pane with footprint library tree.
LIB_TREE * GetLibTree() const
bool FixUuids()
Old footprints do not always have a valid UUID (some can be set to null uuid) However null UUIDs,...
Definition: footprint.cpp:226
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: footprint.cpp:1350
PADS & Pads()
Definition: footprint.h:174
const LIB_ID & GetFPID() const
Definition: footprint.h:207
KIID GetLink() const
Definition: footprint.h:629
const wxString & GetReference() const
Definition: footprint.h:519
FP_ZONES & Zones()
Definition: footprint.h:180
DRAWINGS & GraphicalItems()
Definition: footprint.h:177
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: footprint.cpp:782
bool IsFootprintLibWritable(const wxString &aNickname)
Return true if the library given by aNickname is writable.
void AddLibraries(EDA_BASE_FRAME *aParent)
static wxObjectDataPtr< LIB_TREE_MODEL_ADAPTER > Create(FOOTPRINT_EDIT_FRAME *aFrame, FP_LIB_TABLE *aLibs)
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:76
void ReadWindowSettings(WINDOW_SETTINGS &aCfg)
Read GAL config options from application-level config.
bool m_axesEnabled
Fullscreen crosshair or small cross.
void SetAxesEnabled(bool aAxesEnabled)
Enable drawing the axes.
void UpdateAllLayersColor()
Apply the new coloring scheme to all layers.
Definition: view.cpp:758
bool IsMirroredX() const
Return true if view is flipped across the X axis.
Definition: view.h:243
void MarkTargetDirty(int aTarget)
Set or clear target 'dirty' flag.
Definition: view.h:617
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
Definition: kiway_holder.h:53
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition: kiway.h:267
void OnKiCadExit()
Definition: kiway.cpp:657
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:394
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:49
int SetLibItemName(const UTF8 &aLibItemName)
Override the library item name portion of the LIB_ID to aLibItemName.
Definition: lib_id.cpp:109
bool IsValid() const
Check if this LID_ID is valid.
Definition: lib_id.h:165
UTF8 Format() const
Definition: lib_id.cpp:117
int SetLibNickname(const UTF8 &aNickname)
Override the logical library name portion of the LIB_ID to aNickname.
Definition: lib_id.cpp:98
const UTF8 & GetLibItemName() const
Definition: lib_id.h:101
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:87
Model class in the component selector Model-View-Adapter (mediated MVC) architecture.
void RefreshLibTree()
Refreshes the tree (mainly to update highlighting and asterisking)
Definition: lib_tree.cpp:307
LIB_TREE_NODE * GetCurrentTreeNode() const
Definition: lib_tree.cpp:213
void CenterLibId(const LIB_ID &aLibId)
Ensure that an item is visible (preferably centered).
Definition: lib_tree.cpp:230
void SelectLibId(const LIB_ID &aLibId)
Select an item in the tree widget.
Definition: lib_tree.cpp:224
void Unselect()
Unselect currently selected item in wxDataViewCtrl.
Definition: lib_tree.cpp:236
LIB_ID GetSelectedLibId(int *aUnit=nullptr) const
For multi-unit symbols, if the user selects the symbol itself rather than picking an individual unit,...
Definition: lib_tree.cpp:182
void Regenerate(bool aKeepState)
Regenerate the tree.
Definition: lib_tree.cpp:289
Tool relating to pads and pad settings.
Definition: pad_tool.h:37
Describe the page size and margins of a paper page on which to eventually print or plot.
Definition: page_info.h:54
static const wxChar A4[]
Definition: page_info.h:63
void SetCheckboxesFromFilter(SELECTION_FILTER_OPTIONS &aOptions)
Gather all the actions that are shared by tools.
Definition: pcb_actions.h:49
static TOOL_ACTION toggleHV45Mode
Definition: pcb_actions.h:458
static TOOL_ACTION drawRuleArea
Definition: pcb_actions.h:181
static TOOL_ACTION placeText
Definition: pcb_actions.h:172
static TOOL_ACTION drawOrthogonalDimension
Definition: pcb_actions.h:177
static TOOL_ACTION drawRectangle
Definition: pcb_actions.h:168
static TOOL_ACTION setAnchor
Definition: pcb_actions.h:188
static TOOL_ACTION padDisplayMode
Definition: pcb_actions.h:272
static TOOL_ACTION showLayersManager
Definition: pcb_actions.h:381
static TOOL_ACTION drawCircle
Definition: pcb_actions.h:169
static TOOL_ACTION mirrorH
Mirroring of selected items.
Definition: pcb_actions.h:129
static TOOL_ACTION placeImage
Definition: pcb_actions.h:171
static TOOL_ACTION exportFootprint
Definition: pcb_actions.h:410
static TOOL_ACTION showFootprintTree
Definition: pcb_actions.h:387
static TOOL_ACTION drawTextBox
Definition: pcb_actions.h:173
static TOOL_ACTION drawPolygon
Definition: pcb_actions.h:167
static TOOL_ACTION placePad
Activation of the drawing tool (placing a PAD)
Definition: pcb_actions.h:418
static TOOL_ACTION group
Definition: pcb_actions.h:466
static TOOL_ACTION drawRadialDimension
Definition: pcb_actions.h:176
static TOOL_ACTION editTextAndGraphics
Definition: pcb_actions.h:352
static TOOL_ACTION drawLeader
Definition: pcb_actions.h:178
static TOOL_ACTION ddImportFootprint
Definition: pcb_actions.h:521
static TOOL_ACTION ungroup
Definition: pcb_actions.h:467
static TOOL_ACTION placeImportedGraphics
Definition: pcb_actions.h:187
static TOOL_ACTION drawArc
Definition: pcb_actions.h:170
static TOOL_ACTION graphicsOutlines
Display footprint graphics as outlines.
Definition: pcb_actions.h:430
static TOOL_ACTION drawCenterDimension
Definition: pcb_actions.h:175
static TOOL_ACTION footprintProperties
Definition: pcb_actions.h:412
static TOOL_ACTION flipBoard
Definition: pcb_actions.h:322
static TOOL_ACTION textOutlines
Display texts as lines.
Definition: pcb_actions.h:433
static TOOL_ACTION checkFootprint
Definition: pcb_actions.h:415
static TOOL_ACTION mirrorV
Definition: pcb_actions.h:130
static TOOL_ACTION repairFootprint
Definition: pcb_actions.h:483
static TOOL_ACTION drawLine
Definition: pcb_actions.h:166
static TOOL_ACTION cleanupGraphics
Definition: pcb_actions.h:355
static TOOL_ACTION rotateCw
Rotation of selected objects.
Definition: pcb_actions.h:122
static TOOL_ACTION rotateCcw
Definition: pcb_actions.h:123
static TOOL_ACTION drawAlignedDimension
Definition: pcb_actions.h:174
Common, abstract interface for edit frames.
APPEARANCE_CONTROLS * m_appearancePanel
PANEL_SELECTION_FILTER * m_selectionFilterPanel
void ActivateGalCanvas() override
Set the #m_Pcb member in such as way as to ensure deleting any previous BOARD.
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
virtual const PCB_PLOT_PARAMS & GetPlotSettings() const
Return the PCB_PLOT_PARAMS for the BOARD owned by this frame.
const PCB_DISPLAY_OPTIONS & GetDisplayOptions() const
Display options control the way tracks, vias, outlines and other things are shown (for instance solid...
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
virtual void OnModify()
Must be called after a change in order to set the "modify" flag of the current screen and update the ...
FOOTPRINT * loadFootprint(const LIB_ID &aFootprintId)
Attempts to load aFootprintId from the footprint library table.
bool canCloseWindow(wxCloseEvent &aCloseEvent) override
BOX2I GetBoardBoundingBox(bool aBoardEdgesOnly=false) const
Calculate the bounding box containing all board items (or board edge segments).
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
BOARD * GetBoard() const
virtual void ShowChangedLanguage() override
Redraw the menus and what not in current language.
virtual void AddFootprintToBoard(FOOTPRINT *aFootprint)
Add the given footprint to the board.
PCB_DISPLAY_OPTIONS m_displayOptions
FOOTPRINT_EDITOR_SETTINGS * GetFootprintEditorSettings() const
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
virtual void Update3DView(bool aMarkDirty, bool aRefresh, const wxString *aTitle=nullptr)
Update the 3D view, if the viewer is opened by this frame.
Handle actions that are shared between different frames in PcbNew.
Definition: pcb_control.h:47
HIGH_CONTRAST_MODE m_ContrastModeDisplay
How inactive layers are displayed.
void UpdateColors()
Update the color settings in the painter and GAL.
virtual KIGFX::PCB_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
void DisplayBoard(BOARD *aBoard, PROGRESS_REPORTER *aReporter=nullptr)
Add all items from the current board to the VIEW, so they can be displayed by GAL.
Group generic conditions for PCB editor states.
SELECTION_CONDITION PadFillDisplay()
Create a functor that tests if the frame fills the pads.
SELECTION_CONDITION HasItems()
Create a functor that tests if there are items in the board.
SELECTION_CONDITION GraphicsFillDisplay()
Create a functor that tests if the frame fills graphics items.
SELECTION_CONDITION TextFillDisplay()
Create a functor that tests if the frame fills text items.
The main frame for Pcbnew.
Generic tool for picking an item.
Parameters and options when plotting/printing a board.
Tool that displays edit points allowing to modify items by dragging the points.
The selection tool: currently supports:
Tool useful for viewing footprints.
The interactive edit tool.
@ PCB_FOOTPRINT_EDITOR_FP_NAME
Definition: project.h:174
@ PCB_FOOTPRINT_EDITOR_LIB_NICKNAME
Definition: project.h:175
virtual FP_LIB_TABLE * PcbFootprintLibs(KIWAY &aKiway)
Return the table of footprint libraries.
Definition: project.cpp:318
virtual void SetRString(RSTRING_T aStringId, const wxString &aString)
Store a "retained string", which is any session and project specific string identified in enum RSTRIN...
Definition: project.cpp:253
virtual const wxString & GetRString(RSTRING_T aStringId)
Return a "retained string", which is any session and project specific string identified in enum RSTRI...
Definition: project.cpp:264
Tool relating to pads and pad settings.
static SELECTION_CONDITION MoreThan(int aNumber)
Create a functor that tests if the number of selected items is greater than the value given as parame...
static bool Idle(const SELECTION &aSelection)
Test if there no items selected or being edited.
static bool ShowAlways(const SELECTION &aSelection)
The default condition function (always returns true).
bool IsProjectOpen() const
Helper for checking if we have a project open TODO: This should be deprecated along with Prj() once w...
void FlushAndRelease(JSON_SETTINGS *aSettings, bool aSave=true)
If the given settings object is registered, save it to disk and unregister it.
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:170
TOOL_DISPATCHER * m_toolDispatcher
Definition: tools_holder.h:172
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:54
ACTIONS * m_actions
Definition: tools_holder.h:171
Base abstract interface for all kinds of tools.
Definition: tool_base.h:66
@ MODEL_RELOAD
Model changes (required full reload)
Definition: tool_base.h:80
virtual void DispatchWxEvent(wxEvent &aEvent)
Process wxEvents (mostly UI events), translate them to TOOL_EVENTs, and make tools handle those.
Master controller class:
Definition: tool_manager.h:55
bool InvokeTool(TOOL_ID aToolId)
Call a tool by sending a tool activation event to tool of given ID.
ACTION_MANAGER * GetActionManager() const
Definition: tool_manager.h:196
void ResetTools(TOOL_BASE::RESET_REASON aReason)
Reset all tools (i.e.
std::vector< TOOL_BASE * > Tools()
Definition: tool_manager.h:231
void RegisterTool(TOOL_BASE *aTool)
Add a tool to the manager set and sets it up.
void SetEnvironment(EDA_ITEM *aModel, KIGFX::VIEW *aView, KIGFX::VIEW_CONTROLS *aViewControls, APP_SETTINGS_BASE *aSettings, TOOLS_HOLDER *aFrame)
Set the work environment (model, view, view controls and the parent window).
void InitTools()
Initializes all registered tools.
void ShutdownAllTools()
Shutdown all tools with a currently registered event loop in this tool manager by waking them up with...
bool empty() const
Definition: utf8.h:103
const char * c_str() const
Definition: utf8.h:102
void RemoveAllButtons()
Remove all the buttons that have been added by the user.
Definition: infobar.cpp:286
void ShowMessageFor(const wxString &aMessage, int aTime, int aFlags=wxICON_INFORMATION, MESSAGE_TYPE aType=WX_INFOBAR::MESSAGE_TYPE::GENERIC)
Show the infobar with the provided message and icon for a specific period of time.
Definition: infobar.cpp:128
void AddCloseButton(const wxString &aTooltip=_("Hide this message."))
Add the default close button to the infobar on the right side.
Definition: infobar.cpp:276
void ShowMessage(const wxString &aMessage, int aFlags=wxICON_INFORMATION) override
Show the info bar with the provided message and icon.
Definition: infobar.cpp:142
Multi-thread safe progress reporter dialog, intended for use of tasks that parallel reporting back of...
bool HandleUnsavedChanges(wxWindow *aParent, const wxString &aMessage, const std::function< bool()> &aSaveFunction)
Display a dialog with Save, Cancel and Discard Changes buttons.
Definition: confirm.cpp:240
This file is part of the common library.
static bool empty(const wxTextEntryBase *aCtrl)
#define _(s)
static constexpr EDA_ANGLE & ANGLE_90
Definition: eda_angle.h:414
#define KICAD_DEFAULT_DRAWFRAME_STYLE
#define FOOTPRINT_EDIT_FRAME_NAME
GERBVIEW_FRAME::OnZipFileHistory GERBVIEW_FRAME::OnSelectDisplayMode EVT_CHOICE(ID_GBR_AUX_TOOLBAR_PCB_APERATTRIBUTES_CHOICE, GERBVIEW_FRAME::OnSelectHighlightChoice) EVT_UPDATE_UI(ID_TOOLBARH_GERBVIEW_SELECT_ACTIVE_LAYER
EVT_UPDATE_UI(ID_LOAD_FOOTPRINT_FROM_BOARD, FOOTPRINT_EDIT_FRAME::OnUpdateLoadFootprintFromBoard) EVT_UPDATE_UI(ID_ADD_FOOTPRINT_TO_BOARD
#define CHECK(x)
#define ENABLE(x)
#define CURRENT_EDIT_TOOL(action)
FOOTPRINT_LIST_IMPL GFootprintList
The global footprint info table.
Definition: cvpcb.cpp:140
@ FRAME_PCB_EDITOR
Definition: frame_type.h:40
@ FRAME_FOOTPRINT_EDITOR
Definition: frame_type.h:41
const std::string KiCadFootprintLibPathExtension
const std::string KiCadFootprintFileExtension
#define PcbFileExtension
wxString PngFileWildcard()
@ ID_ON_GRID_SELECT
Definition: id.h:145
@ ID_ON_ZOOM_SELECT
Definition: id.h:143
@ ID_GRID_SETTINGS
Definition: id.h:146
KIID niluuid(0)
@ F_SilkS
Definition: layer_ids.h:104
@ In1_Cu
Definition: layer_ids.h:65
This file contains miscellaneous commonly used macros and functions.
static wxString FROM_UTF8(const char *cstring)
Convert a UTF8 encoded C string to a wxString for all wxWidgets build modes.
Definition: macros.h:110
@ TARGET_NONCACHED
Auxiliary rendering target (noncached)
Definition: definitions.h:49
void SetShutdownBlockReason(wxWindow *aWindow, const wxString &aReason)
Sets the block reason why the window/application is preventing OS shutdown.
Definition: gtk/app.cpp:83
bool SupportsShutdownBlockReason()
Whether or not the window supports setting a shutdown block reason.
Definition: gtk/app.cpp:72
bool IsValid(const std::string &aString, SIM_VALUE::TYPE aValueType=SIM_VALUE::TYPE_FLOAT, NOTATION aNotation=NOTATION::SI)
Definition: sim_value.cpp:127
@ ID_FPEDIT_SAVE_PNG
Definition: pcbnew_id.h:98
@ ID_ADD_FOOTPRINT_TO_BOARD
Definition: pcbnew_id.h:116
@ ID_LOAD_FOOTPRINT_FROM_BOARD
Definition: pcbnew_id.h:117
@ ID_TOOLBARH_PCB_SELECT_LAYER
Definition: pcbnew_id.h:96
BOARD * GetBoard()
see class PGM_BASE
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:111
const double IU_PER_MILS
Definition: base_units.h:78
constexpr int mmToIU(double mm) const
Definition: base_units.h:89
@ PCB_GROUP_T
class PCB_GROUP, a set of BOARD_ITEMs
Definition: typeinfo.h:115
@ PCB_FP_TEXT_T
class FP_TEXT, text in a footprint
Definition: typeinfo.h:92
Definition of file extensions used in Kicad.
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.