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-2023 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 = _HKI( "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 {
315 // Ensure the controls on the toolbars all are correctly sized
316 UpdateToolbarControlSizes();
317 m_treePane->FocusSearchFieldIfExists();
318 } );
319}
320
321
323{
324 // Shutdown all running tools
325 if( m_toolManager )
327
328 // save the footprint in the PROJECT
330
332 delete m_appearancePanel;
333 delete m_treePane;
334}
335
336
338{
340
341 FOOTPRINT* fp = static_cast<FOOTPRINT*>( GetModel() );
342
343 if( fp )
344 {
345 std::vector<MSG_PANEL_ITEM> msgItems;
346 fp->GetMsgPanelInfo( this, msgItems );
347 SetMsgPanel( msgItems );
348 }
349}
350
351
353{
354 return GetScreen() && GetScreen()->IsContentModified()
356}
357
358
360{
361 return m_toolManager->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
362}
363
364
366{
367 // switches currently used canvas (Cairo / OpenGL).
368 PCB_BASE_FRAME::SwitchCanvas( aCanvasType );
369
370 GetCanvas()->GetGAL()->SetAxesEnabled( true );
371
372 // The base class method *does not reinit* the layers manager. We must update the layer
373 // widget to match board visibility states, both layers and render columns, and and some
374 // settings dependent on the canvas.
376}
377
378
380{
381 SyncLibraryTree( true );
383}
384
385
387{
388 wxAuiPaneInfo& treePane = m_auimgr.GetPane( m_treePane );
389 treePane.Show( !IsSearchTreeShown() );
390
391 if( IsSearchTreeShown() )
392 {
393 // SetAuiPaneSize also updates m_auimgr
395 }
396 else
397 {
398 m_editorSettings->m_LibWidth = m_treePane->GetSize().x;
399 m_auimgr.Update();
400 }
401}
402
403
405{
407 wxAuiPaneInfo& layersManager = m_auimgr.GetPane( "LayersManager" );
408 wxAuiPaneInfo& selectionFilter = m_auimgr.GetPane( "SelectionFilter" );
409
410 // show auxiliary Vertical layers and visibility manager toolbar
412 layersManager.Show( m_show_layer_manager_tools );
413 selectionFilter.Show( m_show_layer_manager_tools );
414
416 {
417 SetAuiPaneSize( m_auimgr, layersManager, settings->m_AuiPanels.right_panel_width, -1 );
418 }
419 else
420 {
421 settings->m_AuiPanels.right_panel_width = m_appearancePanel->GetSize().x;
422 m_auimgr.Update();
423 }
424}
425
426
428{
429 return const_cast<wxAuiManager&>( m_auimgr ).GetPane( m_treePane ).IsShown();
430}
431
432
434{
435 return GetBoard()->GetFirstFootprint();
436}
437
438
440{
442}
443
444
446{
448}
449
450
452{
453 LIB_ID id;
454
455 if( IsSearchTreeShown() )
456 id = GetTreeFPID();
457
458 if( id.GetLibNickname().empty() )
459 id = GetLoadedFPID();
460
461 return id;
462}
463
464
466{
467 FOOTPRINT* footprint = GetBoard()->GetFirstFootprint();
468
469 if( footprint )
470 return LIB_ID( footprint->GetFPID().GetLibNickname(), m_footprintNameWhenLoaded );
471 else
472 return LIB_ID();
473}
474
475
477{
478 if( GetBoard()->GetFirstFootprint() )
480
481 GetScreen()->SetContentModified( false );
482}
483
484
486{
487 FOOTPRINT* footprint = GetBoard()->GetFirstFootprint();
488
489 return ( footprint && footprint->GetLink() != niluuid );
490}
491
492
494{
495 LIB_ID id = GetLoadedFPID();
496
497 if( id.IsValid() )
498 {
500 Prj().SetRString( PROJECT::PCB_FOOTPRINT_EDITOR_FP_NAME, id.GetLibItemName() );
501 }
502}
503
504
506{
507 const wxString& footprintName = Prj().GetRString( PROJECT::PCB_FOOTPRINT_EDITOR_FP_NAME );
508 const wxString& libNickname = Prj().GetRString( PROJECT::PCB_FOOTPRINT_EDITOR_LIB_NICKNAME );
509
510 if( libNickname.Length() && footprintName.Length() )
511 {
512 LIB_ID id;
513 id.SetLibNickname( libNickname );
514 id.SetLibItemName( footprintName );
515
516 FOOTPRINT* footprint = loadFootprint( id );
517
518 if( footprint )
519 AddFootprintToBoard( footprint );
520 }
521}
522
523
525{
526 m_originalFootprintCopy.reset( static_cast<FOOTPRINT*>( aFootprint->Clone() ) );
527 m_originalFootprintCopy->SetParent( nullptr );
528
530
532 // Ensure item UUIDs are valid
533 // ("old" footprints can have null uuids that create issues in fp editor)
534 aFootprint->FixUuids();
535
537 {
538 wxString msg;
539 msg.Printf( _( "Editing %s from board. Saving will update the board only." ),
540 aFootprint->GetReference() );
541
544 GetInfoBar()->ShowMessage( msg, wxICON_INFORMATION );
545 }
546 else
547 {
548 GetInfoBar()->Dismiss();
549 }
550
552}
553
554
556{
558}
559
560
562{
563 return GetBoard()->GetDesignSettings();
564}
565
566
568{
569 wxFAIL_MSG( wxT( "Plotting not supported in Footprint Editor" ) );
570
572}
573
574
576{
577 wxFAIL_MSG( wxT( "Plotting not supported in Footprint Editor" ) );
578}
579
580
582{
583 if( !m_editorSettings )
584 m_editorSettings = Pgm().GetSettingsManager().GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>();
585
586 return m_editorSettings;
587}
588
589
591{
593 : Pgm().GetSettingsManager().GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>();
594}
595
596
598{
599 // aCfg will be the PCBNEW_SETTINGS
601
603
605
608
611}
612
613
615{
617
618 // aCfg will be the PCBNEW_SETTINGS
620
622
625 cfg->m_LibWidth = m_treePane->GetSize().x;
629
633}
634
635
636
638{
639 FOOTPRINT_EDITOR_SETTINGS* cfg = const_cast<FOOTPRINT_EDIT_FRAME*>( this )->GetSettings();
640
641 return cfg ? cfg->m_RotationAngle : ANGLE_90;
642}
643
644
645
647{
648 wxString currentTheme = GetFootprintEditorSettings()->m_ColorTheme;
649 return Pgm().GetSettingsManager().GetColorSettings( currentTheme );
650}
651
652
654{
655 // Get the actual frame settings for magnetic items
657 wxCHECK( cfg, nullptr );
658 return &cfg->m_MagneticItems;
659}
660
661
662const BOX2I FOOTPRINT_EDIT_FRAME::GetDocumentExtents( bool aIncludeAllVisible ) const
663{
664 FOOTPRINT* footprint = GetBoard()->GetFirstFootprint();
665
666 if( footprint )
667 {
668 bool hasGraphicalItem = footprint->Pads().size() || footprint->Zones().size();
669
670 if( !hasGraphicalItem )
671 {
672 for( const BOARD_ITEM* item : footprint->GraphicalItems() )
673 {
674 if( item->Type() == PCB_FP_TEXT_T )
675 continue;
676
677 hasGraphicalItem = true;
678 break;
679 }
680 }
681
682 if( hasGraphicalItem )
683 {
684 return footprint->GetBoundingBox( false, false );
685 }
686 else
687 {
688 BOX2I newFootprintBB( { 0, 0 }, { 0, 0 } );
689 newFootprintBB.Inflate( pcbIUScale.mmToIU( 12 ) );
690 return newFootprintBB;
691 }
692 }
693
694 return GetBoardBoundingBox( false );
695}
696
697
699{
700 if( IsContentModified() )
701 {
702 wxString footprintName = GetBoard()->GetFirstFootprint()->GetReference();
703 wxString msg = _( "Save changes to '%s' before closing?" );
704
705 if( !HandleUnsavedChanges( this, wxString::Format( msg, footprintName ),
706 [&]() -> bool
707 {
708 return SaveFootprint( GetBoard()->GetFirstFootprint() );
709 } ) )
710 {
711 return false;
712 }
713 }
714
715 if( doClose )
716 {
717 GetInfoBar()->ShowMessageFor( wxEmptyString, 1 );
718 Clear_Pcb( false );
719 UpdateTitle();
720 }
721
722 return true;
723}
724
725
726bool FOOTPRINT_EDIT_FRAME::canCloseWindow( wxCloseEvent& aEvent )
727{
728 if( IsContentModified() )
729 {
730 // Shutdown blocks must be determined and vetoed as early as possible
732 aEvent.GetId() == wxEVT_QUERY_END_SESSION )
733 {
734 aEvent.Veto();
735 return false;
736 }
737
738 wxString footprintName = GetBoard()->GetFirstFootprint()->GetFPID().GetLibItemName();
739
741 footprintName = GetBoard()->GetFirstFootprint()->GetReference();
742
743 wxString msg = _( "Save changes to '%s' before closing?" );
744
745 if( !HandleUnsavedChanges( this, wxString::Format( msg, footprintName ),
746 [&]() -> bool
747 {
748 return SaveFootprint( GetBoard()->GetFirstFootprint() );
749 } ) )
750 {
751 aEvent.Veto();
752 return false;
753 }
754 }
755
756 // Save footprint tree column widths
757 m_adapter->SaveSettings();
758
760}
761
762
764{
765 // No more vetos
766 GetCanvas()->SetEventDispatcher( nullptr );
768
769 // Do not show the layer manager during closing to avoid flicker
770 // on some platforms (Windows) that generate useless redraw of items in
771 // the Layer Manager
772 m_auimgr.GetPane( wxT( "LayersManager" ) ).Show( false );
773 m_auimgr.GetPane( wxT( "SelectionFilter" ) ).Show( false );
774
775 Clear_Pcb( false );
776
778
779 if( mgr->IsProjectOpen() && wxFileName::IsDirWritable( Prj().GetProjectPath() ) )
780 {
781 GFootprintList.WriteCacheToFile( Prj().GetProjectPath() + wxT( "fp-info-cache" ) );
782 }
783
785}
786
787
788void FOOTPRINT_EDIT_FRAME::OnExitKiCad( wxCommandEvent& event )
789{
790 Kiway().OnKiCadExit();
791}
792
793
795{
796 Close();
797}
798
799
801{
803
804 aEvent.Enable( frame && frame->GetBoard()->GetFirstFootprint() != nullptr );
805}
806
807
809{
811
812 FOOTPRINT* editorFootprint = GetBoard()->GetFirstFootprint();
813 bool canInsert = frame && editorFootprint && editorFootprint->GetLink() == niluuid;
814
815 // If the source was deleted, the footprint can inserted but not updated in the board.
816 if( frame && editorFootprint && editorFootprint->GetLink() != niluuid )
817 {
818 BOARD* mainpcb = frame->GetBoard();
819 canInsert = true;
820
821 // search if the source footprint was not deleted:
822 for( FOOTPRINT* candidate : mainpcb->Footprints() )
823 {
824 if( editorFootprint->GetLink() == candidate->m_Uuid )
825 {
826 canInsert = false;
827 break;
828 }
829 }
830 }
831
832 aEvent.Enable( canInsert );
833}
834
835
837{
838 // call my base class
840
841 // We have 2 panes to update.
842 // For some obscure reason, the AUI manager hides the first modified pane.
843 // So force show panes
844 wxAuiPaneInfo& tree_pane_info = m_auimgr.GetPane( m_treePane );
845 bool tree_shown = tree_pane_info.IsShown();
846 tree_pane_info.Caption( _( "Libraries" ) );
847
848 wxAuiPaneInfo& lm_pane_info = m_auimgr.GetPane( m_appearancePanel );
849 bool lm_shown = lm_pane_info.IsShown();
850 lm_pane_info.Caption( _( "Appearance" ) );
851 wxAuiPaneInfo& sf_pane_info = m_auimgr.GetPane( m_selectionFilterPanel );
852 sf_pane_info.Caption( _( "Selection Filter" ) );
853
854 // update the layer manager
858
859 // Now restore the visibility:
860 lm_pane_info.Show( lm_shown );
861 tree_pane_info.Show( tree_shown );
862 m_auimgr.Update();
863
864 UpdateTitle();
865}
866
867
869{
871 Update3DView( true, true );
873
874 if( !GetTitle().StartsWith( wxT( "*" ) ) )
875 UpdateTitle();
876}
877
878
880{
881 wxString title;
882 LIB_ID fpid = GetLoadedFPID();
883 FOOTPRINT* footprint = GetBoard()->GetFirstFootprint();
884 bool writable = true;
885
887 {
888 if( IsContentModified() )
889 title = wxT( "*" );
890
891 title += footprint->GetReference();
892 title += wxS( " " ) + wxString::Format( _( "[from %s]" ), Prj().GetProjectName()
893 + wxT( "." )
895 }
896 else if( fpid.IsValid() )
897 {
898 try
899 {
901 }
902 catch( const IO_ERROR& )
903 {
904 // best efforts...
905 }
906
907 // Note: don't used GetLoadedFPID(); footprint name may have been edited
908 if( IsContentModified() )
909 title = wxT( "*" );
910
911 title += FROM_UTF8( footprint->GetFPID().Format().c_str() );
912
913 if( !writable )
914 title += wxS( " " ) + _( "[Read Only]" );
915 }
916 else if( !fpid.GetLibItemName().empty() )
917 {
918 // Note: don't used GetLoadedFPID(); footprint name may have been edited
919 if( IsContentModified() )
920 title = wxT( "*" );
921
922 title += FROM_UTF8( footprint->GetFPID().GetLibItemName().c_str() );
923 title += wxS( " " ) + _( "[Unsaved]" );
924 }
925 else
926 {
927 title = _( "[no footprint loaded]" );
928 }
929
930 title += wxT( " \u2014 " ) + _( "Footprint Editor" );
931
932 SetTitle( title );
933}
934
935
937{
939}
940
941
943{
947 UpdateTitle();
948}
949
950
952{
953 FP_LIB_TABLE* fpTable = Prj().PcbFootprintLibs();
954
955 WX_PROGRESS_REPORTER progressReporter( this, _( "Loading Footprint Libraries" ), 2 );
956
957 if( GFootprintList.GetCount() == 0 )
958 GFootprintList.ReadCacheFromFile( Prj().GetProjectPath() + wxT( "fp-info-cache" ) );
959
960 GFootprintList.ReadFootprintFiles( fpTable, nullptr, &progressReporter );
961 progressReporter.Show( false );
962
965
967 auto adapter = static_cast<FP_TREE_SYNCHRONIZING_ADAPTER*>( m_adapter.get() );
968
969 adapter->AddLibraries( this );
970}
971
972
974{
975 FP_LIB_TABLE* fpTable = Prj().PcbFootprintLibs();
976 auto adapter = static_cast<FP_TREE_SYNCHRONIZING_ADAPTER*>( m_adapter.get() );
977 LIB_ID target = GetTargetFPID();
978 bool targetSelected = ( target == m_treePane->GetLibTree()->GetSelectedLibId() );
979
980 // Sync FOOTPRINT_INFO list to the libraries on disk
981 if( aProgress )
982 {
983 WX_PROGRESS_REPORTER progressReporter( this, _( "Updating Footprint Libraries" ), 2 );
984 GFootprintList.ReadFootprintFiles( fpTable, nullptr, &progressReporter );
985 progressReporter.Show( false );
986 }
987 else
988 {
989 GFootprintList.ReadFootprintFiles( fpTable, nullptr, nullptr );
990 }
991
992 // Sync the LIB_TREE to the FOOTPRINT_INFO list
993 adapter->Sync();
994
996 m_treePane->GetLibTree()->Regenerate( true );
997
998 if( target.IsValid() )
999 {
1000 if( adapter->FindItem( target ) )
1001 {
1002 if( targetSelected )
1003 m_treePane->GetLibTree()->SelectLibId( target );
1004 else
1005 m_treePane->GetLibTree()->CenterLibId( target );
1006 }
1007 else
1008 {
1009 // Try to focus on parent
1010 target.SetLibItemName( wxEmptyString );
1011 m_treePane->GetLibTree()->CenterLibId( target );
1012 }
1013 }
1014}
1015
1016
1018{
1019 LIB_ID target = GetTargetFPID();
1020
1021 m_treePane->GetLibTree()->Regenerate( true );
1022
1023 if( target.IsValid() )
1024 m_treePane->GetLibTree()->CenterLibId( target );
1025}
1026
1027
1029{
1031}
1032
1033
1035{
1036 m_treePane->GetLibTree()->SelectLibId( aLibID );
1037}
1038
1039
1041{
1043}
1044
1045
1047{
1048 // Create the manager and dispatcher & route draw panel events to the dispatcher
1051 GetCanvas()->GetViewControls(), config(), this );
1052 m_actions = new PCB_ACTIONS();
1054
1056
1065 m_toolManager->RegisterTool( new PCB_CONTROL ); // copy/paste
1074
1075 for( TOOL_BASE* tool : m_toolManager->Tools() )
1076 {
1077 if( PCB_TOOL_BASE* pcbTool = dynamic_cast<PCB_TOOL_BASE*>( tool ) )
1078 pcbTool->SetIsFootprintEditor( true );
1079 }
1080
1081 m_toolManager->GetTool<PCB_VIEWER_TOOLS>()->SetFootprintFrame( true );
1083
1084 m_toolManager->InvokeTool( "pcbnew.InteractiveSelection" );
1085
1086 // Load or reload wizard plugins in case they changed since the last time the frame opened
1088}
1089
1090
1092{
1094
1096 PCB_EDITOR_CONDITIONS cond( this );
1097
1098 wxASSERT( mgr );
1099
1100#define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
1101#define CHECK( x ) ACTION_CONDITIONS().Check( x )
1102
1103 auto haveFootprintCond =
1104 [this]( const SELECTION& )
1105 {
1106 return GetBoard()->GetFirstFootprint() != nullptr;
1107 };
1108
1109 auto footprintTargettedCond =
1110 [this]( const SELECTION& )
1111 {
1112 return !GetTargetFPID().GetLibItemName().empty();
1113 };
1114
1115 mgr->SetConditions( ACTIONS::saveAs, ENABLE( footprintTargettedCond ) );
1118
1121
1127
1128 mgr->SetConditions( ACTIONS::cut, ENABLE( cond.HasItems() ) );
1129 mgr->SetConditions( ACTIONS::copy, ENABLE( cond.HasItems() ) );
1135
1142
1146
1149
1150 auto constrainedDrawingModeCond =
1151 [this]( const SELECTION& )
1152 {
1153 return GetSettings()->m_Use45Limit;
1154 };
1155
1156 auto highContrastCond =
1157 [this]( const SELECTION& )
1158 {
1160 };
1161
1162 auto boardFlippedCond =
1163 [this]( const SELECTION& )
1164 {
1165 return GetCanvas()->GetView()->IsMirroredX();
1166 };
1167
1168 auto footprintTreeCond =
1169 [this](const SELECTION& )
1170 {
1171 return IsSearchTreeShown();
1172 };
1173
1174 auto layerManagerCond =
1175 [this]( const SELECTION& )
1176 {
1177 return m_auimgr.GetPane( "LayersManager" ).IsShown();
1178 };
1179
1180 mgr->SetConditions( PCB_ACTIONS::toggleHV45Mode, CHECK( constrainedDrawingModeCond ) );
1181 mgr->SetConditions( ACTIONS::highContrastMode, CHECK( highContrastCond ) );
1182 mgr->SetConditions( PCB_ACTIONS::flipBoard, CHECK( boardFlippedCond ) );
1184
1185 mgr->SetConditions( PCB_ACTIONS::showFootprintTree, CHECK( footprintTreeCond ) );
1186 mgr->SetConditions( PCB_ACTIONS::showLayersManager, CHECK( layerManagerCond ) );
1187
1188 mgr->SetConditions( ACTIONS::print, ENABLE( haveFootprintCond ) );
1189 mgr->SetConditions( PCB_ACTIONS::exportFootprint, ENABLE( haveFootprintCond ) );
1190 mgr->SetConditions( PCB_ACTIONS::placeImportedGraphics, ENABLE( haveFootprintCond ) );
1191
1192 mgr->SetConditions( PCB_ACTIONS::footprintProperties, ENABLE( haveFootprintCond ) );
1193 mgr->SetConditions( PCB_ACTIONS::editTextAndGraphics, ENABLE( haveFootprintCond ) );
1194 mgr->SetConditions( PCB_ACTIONS::checkFootprint, ENABLE( haveFootprintCond ) );
1195 mgr->SetConditions( PCB_ACTIONS::repairFootprint, ENABLE( haveFootprintCond ) );
1196 mgr->SetConditions( PCB_ACTIONS::cleanupGraphics, ENABLE( haveFootprintCond ) );
1197
1198 auto isArcKeepCenterMode = [this]( const SELECTION& )
1199 {
1201 };
1202
1203 auto isArcKeepEndpointMode = [this]( const SELECTION& )
1204 {
1206 };
1207
1208 mgr->SetConditions( PCB_ACTIONS::pointEditorArcKeepCenter, CHECK( isArcKeepCenterMode ) );
1209 mgr->SetConditions( PCB_ACTIONS::pointEditorArcKeepEndpoint, CHECK( isArcKeepEndpointMode ) );
1210
1211
1212// Only enable a tool if the part is edtable
1213#define CURRENT_EDIT_TOOL( action ) mgr->SetConditions( action, \
1214 ACTION_CONDITIONS().Enable( haveFootprintCond ).Check( cond.CurrentTool( action ) ) )
1215
1235
1236#undef CURRENT_EDIT_TOOL
1237#undef ENABLE
1238#undef CHECK
1239}
1240
1241
1243{
1245
1246 // Be sure the axis are enabled
1247 GetCanvas()->GetGAL()->SetAxesEnabled( true );
1248
1249 UpdateView();
1250
1251 // Ensure the m_Layers settings are using the canvas type:
1253}
1254
1255
1256void FOOTPRINT_EDIT_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
1257{
1258 PCB_BASE_EDIT_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
1259
1260 auto cfg = Pgm().GetSettingsManager().GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>();
1261 GetGalDisplayOptions().ReadWindowSettings( cfg->m_Window );
1262
1263 GetBoard()->GetDesignSettings() = cfg->m_DesignSettings;
1264
1268
1270
1271 if( aEnvVarsChanged )
1272 SyncLibraryTree( true );
1273
1274 Layout();
1275 SendSizeEvent();
1276}
1277
1278
1280{
1281 LIB_ID id = GetLoadedFPID();
1282
1283 if( id.empty() )
1284 {
1285 DisplayErrorMessage( this, _( "No footprint selected." ) );
1286 return;
1287 }
1288
1289 wxFileName fn( id.GetLibItemName() );
1290 fn.SetExt( wxT( "png" ) );
1291
1292 wxString projectPath = wxPathOnly( Prj().GetProjectFullName() );
1293
1294 wxFileDialog dlg( this, _( "Footprint Image File Name" ), projectPath,
1295 fn.GetFullName(), PngFileWildcard(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
1296
1297 if( dlg.ShowModal() == wxID_CANCEL || dlg.GetPath().IsEmpty() )
1298 return;
1299
1300 // calling wxYield is mandatory under Linux, after closing the file selector dialog
1301 // to refresh the screen before creating the PNG or JPEG image from screen
1302 wxYield();
1303 SaveCanvasImageToFile( this, dlg.GetPath() );
1304}
@ KEEP_ENDPOINTS_OR_START_DIRECTION
@ KEEP_CENTER_ADJUST_ANGLE_RADIUS
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:215
@ 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:110
wxString m_ColorTheme
Active color theme name.
Definition: app_settings.h:190
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:58
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:589
bool SetLayerName(PCB_LAYER_ID aLayer, const wxString &aLayerName)
Changes the name of the layer given by aLayer.
Definition: board.cpp:472
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:618
void SetVisibleLayers(LSET aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings changes the bit-mask of vis...
Definition: board.cpp:601
void SetCopperLayerCount(int aCount)
Definition: board.cpp:551
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:686
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.
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
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.
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
void UpdateMsgPanel() override
Redraw the message panel.
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,...
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.
std::unique_ptr< FOOTPRINT > m_originalFootprintCopy
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:238
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: footprint.cpp:1374
PADS & Pads()
Definition: footprint.h:170
const LIB_ID & GetFPID() const
Definition: footprint.h:212
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Populate aList of MSG_PANEL_ITEM objects with it's internal state for display purposes.
Definition: footprint.cpp:1018
KIID GetLink() const
Definition: footprint.h:680
const wxString & GetReference() const
Definition: footprint.h:519
FP_ZONES & Zones()
Definition: footprint.h:176
DRAWINGS & GraphicalItems()
Definition: footprint.h:173
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: footprint.cpp:805
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:761
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:274
void OnKiCadExit()
Definition: kiway.cpp:668
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:172
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:102
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:313
LIB_TREE_NODE * GetCurrentTreeNode() const
Definition: lib_tree.cpp:219
void CenterLibId(const LIB_ID &aLibId)
Ensure that an item is visible (preferably centered).
Definition: lib_tree.cpp:236
void SelectLibId(const LIB_ID &aLibId)
Select an item in the tree widget.
Definition: lib_tree.cpp:230
void Unselect()
Unselect currently selected item in wxDataViewCtrl.
Definition: lib_tree.cpp:242
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:188
void Regenerate(bool aKeepState)
Regenerate the tree.
Definition: lib_tree.cpp:295
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:466
static TOOL_ACTION drawRuleArea
Definition: pcb_actions.h:185
static TOOL_ACTION placeText
Definition: pcb_actions.h:176
static TOOL_ACTION pointEditorArcKeepCenter
Definition: pcb_actions.h:248
static TOOL_ACTION drawOrthogonalDimension
Definition: pcb_actions.h:181
static TOOL_ACTION drawRectangle
Definition: pcb_actions.h:172
static TOOL_ACTION setAnchor
Definition: pcb_actions.h:192
static TOOL_ACTION padDisplayMode
Definition: pcb_actions.h:280
static TOOL_ACTION showLayersManager
Definition: pcb_actions.h:389
static TOOL_ACTION drawCircle
Definition: pcb_actions.h:173
static TOOL_ACTION mirrorH
Mirroring of selected items.
Definition: pcb_actions.h:129
static TOOL_ACTION placeImage
Definition: pcb_actions.h:175
static TOOL_ACTION exportFootprint
Definition: pcb_actions.h:418
static TOOL_ACTION showFootprintTree
Definition: pcb_actions.h:395
static TOOL_ACTION drawTextBox
Definition: pcb_actions.h:177
static TOOL_ACTION drawPolygon
Definition: pcb_actions.h:171
static TOOL_ACTION placePad
Activation of the drawing tool (placing a PAD)
Definition: pcb_actions.h:426
static TOOL_ACTION group
Definition: pcb_actions.h:474
static TOOL_ACTION drawRadialDimension
Definition: pcb_actions.h:180
static TOOL_ACTION editTextAndGraphics
Definition: pcb_actions.h:360
static TOOL_ACTION drawLeader
Definition: pcb_actions.h:182
static TOOL_ACTION ddImportFootprint
Definition: pcb_actions.h:529
static TOOL_ACTION ungroup
Definition: pcb_actions.h:475
static TOOL_ACTION placeImportedGraphics
Definition: pcb_actions.h:191
static TOOL_ACTION drawArc
Definition: pcb_actions.h:174
static TOOL_ACTION graphicsOutlines
Display footprint graphics as outlines.
Definition: pcb_actions.h:438
static TOOL_ACTION pluginsReload
Scripting Actions.
Definition: pcb_actions.h:354
static TOOL_ACTION pointEditorArcKeepEndpoint
Definition: pcb_actions.h:249
static TOOL_ACTION drawCenterDimension
Definition: pcb_actions.h:179
static TOOL_ACTION footprintProperties
Definition: pcb_actions.h:420
static TOOL_ACTION flipBoard
Definition: pcb_actions.h:330
static TOOL_ACTION textOutlines
Display texts as lines.
Definition: pcb_actions.h:441
static TOOL_ACTION checkFootprint
Definition: pcb_actions.h:423
static TOOL_ACTION mirrorV
Definition: pcb_actions.h:130
static TOOL_ACTION repairFootprint
Definition: pcb_actions.h:491
static TOOL_ACTION drawLine
Definition: pcb_actions.h:170
static TOOL_ACTION cleanupGraphics
Definition: pcb_actions.h:363
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:178
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.
void OnModify() override
Must be called after a change in order to set the "modify" flag and update other data structures and ...
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:175
@ PCB_FOOTPRINT_EDITOR_LIB_NICKNAME
Definition: project.h:176
virtual FP_LIB_TABLE * PcbFootprintLibs(KIWAY &aKiway)
Return the table of footprint libraries.
Definition: project.cpp:324
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:254
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:265
Tool relating to pads and pad settings.
static SELECTION_CONDITION HasType(KICAD_T aType)
Create a functor that tests if among the selected items there is at least one of a given type.
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 RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:142
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: wx_infobar.cpp:289
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: wx_infobar.cpp:128
void Dismiss() override
Dismisses the infobar and updates the containing layout and AUI manager (if one is provided).
Definition: wx_infobar.cpp:175
void AddCloseButton(const wxString &aTooltip=_("Hide this message."))
Add the default close button to the infobar on the right side.
Definition: wx_infobar.cpp:279
void ShowMessage(const wxString &aMessage, int aFlags=wxICON_INFORMATION) override
Show the info bar with the provided message and icon.
Definition: wx_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:260
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:325
This file is part of the common library.
#define _HKI(x)
static bool empty(const wxTextEntryBase *aCtrl)
#define _(s)
static constexpr EDA_ANGLE & ANGLE_90
Definition: eda_angle.h:425
#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.