KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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"
37#include <bitmaps.h>
38#include <board.h>
39#include <footprint.h>
40#include <confirm.h>
43#include <footprint_info_impl.h>
44#include <footprint_tree_pane.h>
45#include <fp_lib_table.h>
47#include <kiface_base.h>
48#include <kiplatform/app.h>
49#include <kiway.h>
50#include <macros.h>
51#include <pcb_draw_panel_gal.h>
52#include <pcb_edit_frame.h>
53#include <pcbnew.h>
54#include <pcbnew_id.h>
55#include <pgm_base.h>
56#include <project.h>
58#include <tool/action_toolbar.h>
59#include <tool/common_control.h>
60#include <tool/common_tools.h>
61#include <tool/selection.h>
63#include <tool/tool_manager.h>
64#include <tool/zoom_tool.h>
67#include <tools/group_tool.h>
70#include <widgets/lib_tree.h>
75#include <wx/filedlg.h>
77
78BEGIN_EVENT_TABLE( FOOTPRINT_EDIT_FRAME, PCB_BASE_FRAME )
79 EVT_MENU( wxID_CLOSE, FOOTPRINT_EDIT_FRAME::CloseFootprintEditor )
80 EVT_MENU( wxID_EXIT, FOOTPRINT_EDIT_FRAME::OnExitKiCad )
81
83
86
88
91
92 // Horizontal toolbar
95
96 // UI update events.
98 FOOTPRINT_EDIT_FRAME::OnUpdateLoadFootprintFromBoard )
100 FOOTPRINT_EDIT_FRAME::OnUpdateSaveFootprintToBoard )
102
103 // Drop files event
104 EVT_DROP_FILES( FOOTPRINT_EDIT_FRAME::OnDropFiles )
105
106END_EVENT_TABLE()
107
108
109FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
110 PCB_BASE_EDIT_FRAME( aKiway, aParent, FRAME_FOOTPRINT_EDITOR, wxEmptyString,
111 wxDefaultPosition, wxDefaultSize,
112 KICAD_DEFAULT_DRAWFRAME_STYLE, GetFootprintEditorFrameName() ),
113 m_show_layer_manager_tools( true )
114{
115 m_showBorderAndTitleBlock = false; // true to show the frame references
116 m_aboutTitle = _HKI( "KiCad Footprint Editor" );
117 m_selLayerBox = nullptr;
118 m_editorSettings = nullptr;
119
120 // Give an icon
121 wxIcon icon;
122 wxIconBundle icon_bundle;
123
124 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_modedit ) );
125 icon_bundle.AddIcon( icon );
126 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_modedit_32 ) );
127 icon_bundle.AddIcon( icon );
128 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_modedit_16 ) );
129 icon_bundle.AddIcon( icon );
130
131 SetIcons( icon_bundle );
132
133 // Create GAL canvas
134 m_canvasType = loadCanvasTypeSetting();
135
136 PCB_DRAW_PANEL_GAL* drawPanel = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_frameSize,
137 GetGalDisplayOptions(), m_canvasType );
138 SetCanvas( drawPanel );
139 SetBoard( new BOARD() );
140
141 // This board will only be used to hold a footprint for editing
143
144 // In Footprint Editor, the default net clearance is not known (it depends on the actual
145 // board). So we do not show the default clearance, by setting it to 0. The footprint or
146 // pad specific clearance will be shown.
147 GetBoard()->GetDesignSettings().m_NetSettings->m_DefaultNetClass->SetClearance( 0 );
148
149 // Don't show the default board solder mask expansion in the footprint editor. Only the
150 // footprint or pad mask expansions settings should be shown.
152
153 // restore the last footprint from the project, if any
154 restoreLastFootprint();
155
156 // Ensure all layers and items are visible:
157 // In footprint editor, some layers have no meaning or cannot be used, but we show all of
158 // them, at least to be able to edit a bad layer
160
161 GetGalDisplayOptions().m_axesEnabled = true;
162
163 // In Footprint Editor, set the default paper size to A4 for plot/print
164 SetPageSettings( PAGE_INFO( PAGE_INFO::A4 ) );
165 SetScreen( new PCB_SCREEN( GetPageSettings().GetSizeIU( pcbIUScale.IU_PER_MILS ) ) );
166
167 // Create the manager and dispatcher & route draw panel events to the dispatcher
168 setupTools();
169 setupUIConditions();
170
171 initLibraryTree();
172 m_treePane = new FOOTPRINT_TREE_PANE( this );
173
174 ReCreateMenuBar();
175 ReCreateHToolbar();
176 ReCreateVToolbar();
177 ReCreateOptToolbar();
178
179 m_selectionFilterPanel = new PANEL_SELECTION_FILTER( this );
180 m_appearancePanel = new APPEARANCE_CONTROLS( this, GetCanvas(), true );
181 m_propertiesPanel = new PCB_PROPERTIES_PANEL( this, this );
182
183 // LoadSettings() *after* creating m_LayersManager, because LoadSettings() initialize
184 // parameters in m_LayersManager
185 // NOTE: KifaceSettings() will return PCBNEW_SETTINGS if we started from pcbnew
186 LoadSettings( GetSettings() );
187
188 float proportion = GetFootprintEditorSettings()->m_AuiPanels.properties_splitter_proportion;
189 m_propertiesPanel->SetSplitterProportion( proportion );
190
191 // Must be set after calling LoadSettings() to be sure these parameters are not dependent
192 // on what is read in stored settings. Enable one internal layer, because footprints
193 // support keepout areas that can be on internal layers only (therefore on the first internal
194 // layer). This is needed to handle these keepout in internal layers only.
196 GetBoard()->SetEnabledLayers( GetBoard()->GetEnabledLayers().set( In1_Cu ) );
197 GetBoard()->SetVisibleLayers( GetBoard()->GetEnabledLayers() );
198 GetBoard()->SetLayerName( In1_Cu, _( "Inner layers" ) );
199
200 SetActiveLayer( F_SilkS );
201
202 m_auimgr.SetManagedWindow( this );
203
204 CreateInfoBar();
205
206 unsigned int auiFlags = wxAUI_MGR_DEFAULT;
207#if !defined( _WIN32 )
208 // Windows cannot redraw the UI fast enough during a live resize and may lead to all kinds
209 // of graphical glitches
210 auiFlags |= wxAUI_MGR_LIVE_RESIZE;
211#endif
212 m_auimgr.SetFlags( auiFlags );
213
214 // Rows; layers 4 - 6
215 m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" )
216 .Top().Layer( 6 ) );
217
218 m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" )
219 .Bottom().Layer( 6 ) );
220
221 // Columns; layers 1 - 3
222 m_auimgr.AddPane( m_treePane, EDA_PANE().Palette().Name( "Footprints" )
223 .Left().Layer( 4 )
224 .Caption( _( "Libraries" ) )
225 .MinSize( 250, -1 ).BestSize( 250, -1 ) );
226 m_auimgr.AddPane( m_propertiesPanel, EDA_PANE().Name( wxS( "PropertiesManager" ) )
227 .Left().Layer( 3 ).Caption( _( "Properties" ) )
228 .PaneBorder( false ).MinSize( 240, -1 ).BestSize( 300, -1 ) );
229 m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" )
230 .Left().Layer( 2 ) );
231
232 m_auimgr.AddPane( m_drawToolBar, EDA_PANE().VToolbar().Name( "ToolsToolbar" )
233 .Right().Layer(2) );
234 m_auimgr.AddPane( m_appearancePanel, EDA_PANE().Name( "LayersManager" )
235 .Right().Layer( 3 )
236 .Caption( _( "Appearance" ) ).PaneBorder( false )
237 .MinSize( 180, -1 ).BestSize( 180, -1 ) );
238 m_auimgr.AddPane( m_selectionFilterPanel, EDA_PANE().Palette().Name( "SelectionFilter" )
239 .Right().Layer( 3 ).Position( 2 )
240 .Caption( _( "Selection Filter" ) ).PaneBorder( false )
241 .MinSize( 160, -1 ).BestSize( m_selectionFilterPanel->GetBestSize() ) );
242
243 // Center
244 m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( "DrawFrame" )
245 .Center() );
246
247 m_auimgr.GetPane( "LayersManager" ).Show( m_show_layer_manager_tools );
248 m_auimgr.GetPane( "SelectionFilter" ).Show( m_show_layer_manager_tools );
249 m_auimgr.GetPane( "PropertiesManager" ).Show( m_show_properties );
250
251 // The selection filter doesn't need to grow in the vertical direction when docked
252 m_auimgr.GetPane( "SelectionFilter" ).dock_proportion = 0;
253
254 m_acceptedExts.emplace( KiCadFootprintLibPathExtension, &ACTIONS::ddAddLibrary );
256 DragAcceptFiles( true );
257
258 ActivateGalCanvas();
259
260 FinishAUIInitialization();
261
262 // Apply saved visibility stuff at the end
263 FOOTPRINT_EDITOR_SETTINGS* cfg = GetSettings();
264 wxAuiPaneInfo& treePane = m_auimgr.GetPane( "Footprints" );
265 wxAuiPaneInfo& layersManager = m_auimgr.GetPane( "LayersManager" );
266
267 // wxAUI hack: force widths by setting MinSize() and then Fixed()
268 // thanks to ZenJu http://trac.wxwidgets.org/ticket/13180
269
270 if( cfg->m_LibWidth > 0 )
271 {
272 SetAuiPaneSize( m_auimgr, treePane, cfg->m_LibWidth, -1 );
273
274 treePane.MinSize( cfg->m_LibWidth, -1 );
275 treePane.Fixed();
276 }
277
278 if( cfg->m_AuiPanels.right_panel_width > 0 )
279 {
280 SetAuiPaneSize( m_auimgr, layersManager, cfg->m_AuiPanels.right_panel_width, -1 );
281
282 layersManager.MinSize( cfg->m_LibWidth, -1 );
283 layersManager.Fixed();
284 }
285
286 // Apply fixed sizes
287 m_auimgr.Update();
288
289 // Now make them resizable again
290 treePane.Resizable();
291 m_auimgr.Update();
292
293 // Note: DO NOT call m_auimgr.Update() anywhere after this; it will nuke the sizes
294 // back to minimum.
295 treePane.MinSize( 250, -1 );
296 layersManager.MinSize( 250, -1 );
297
298 m_appearancePanel->SetUserLayerPresets( cfg->m_LayerPresets );
299 m_appearancePanel->ApplyLayerPreset( cfg->m_ActiveLayerPreset );
300 m_appearancePanel->SetTabIndex( cfg->m_AuiPanels.appearance_panel_tab );
301
302 GetToolManager()->RunAction( ACTIONS::zoomFitScreen, false );
303 UpdateTitle();
304 setupUnits( GetSettings() );
305
306 resolveCanvasType();
307
308 // Default shutdown reason until a file is loaded
309 KIPLATFORM::APP::SetShutdownBlockReason( this, _( "Footprint changes are unsaved" ) );
310
311 // Catch unhandled accelerator command characters that were no handled by the library tree
312 // panel.
313 Bind( wxEVT_CHAR, &TOOL_DISPATCHER::DispatchWxEvent, m_toolDispatcher );
314 Bind( wxEVT_CHAR_HOOK, &TOOL_DISPATCHER::DispatchWxEvent, m_toolDispatcher );
315
316 // Ensure the window is on top
317 Raise();
318 Show( true );
319
320 // Register a call to update the toolbar sizes. It can't be done immediately because
321 // it seems to require some sizes calculated that aren't yet (at least on GTK).
322 CallAfter(
323 [&]()
324 {
325 // Ensure the controls on the toolbars all are correctly sized
326 UpdateToolbarControlSizes();
327 m_treePane->FocusSearchFieldIfExists();
328 } );
329}
330
331
333{
334 // Shutdown all running tools
335 if( m_toolManager )
337
338 // save the footprint in the PROJECT
340
342 delete m_appearancePanel;
343 delete m_treePane;
344}
345
346
348{
350
351 FOOTPRINT* fp = static_cast<FOOTPRINT*>( GetModel() );
352
353 if( fp )
354 {
355 std::vector<MSG_PANEL_ITEM> msgItems;
356 fp->GetMsgPanelInfo( this, msgItems );
357 SetMsgPanel( msgItems );
358 }
359}
360
361
363{
364 return GetScreen() && GetScreen()->IsContentModified()
366}
367
368
370{
371 return m_toolManager->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
372}
373
374
376{
377 // switches currently used canvas (Cairo / OpenGL).
378 PCB_BASE_FRAME::SwitchCanvas( aCanvasType );
379
380 GetCanvas()->GetGAL()->SetAxesEnabled( true );
381
382 // The base class method *does not reinit* the layers manager. We must update the layer
383 // widget to match board visibility states, both layers and render columns, and and some
384 // settings dependent on the canvas.
386}
387
388
390{
391 SyncLibraryTree( true );
393}
394
395
397{
398 wxAuiPaneInfo& treePane = m_auimgr.GetPane( m_treePane );
399 treePane.Show( !IsSearchTreeShown() );
400
401 if( IsSearchTreeShown() )
402 {
403 // SetAuiPaneSize also updates m_auimgr
405 }
406 else
407 {
408 m_editorSettings->m_LibWidth = m_treePane->GetSize().x;
409 m_auimgr.Update();
410 }
411}
412
413
415{
417 wxAuiPaneInfo& layersManager = m_auimgr.GetPane( "LayersManager" );
418 wxAuiPaneInfo& selectionFilter = m_auimgr.GetPane( "SelectionFilter" );
419
420 // show auxiliary Vertical layers and visibility manager toolbar
422 layersManager.Show( m_show_layer_manager_tools );
423 selectionFilter.Show( m_show_layer_manager_tools );
424
426 {
427 SetAuiPaneSize( m_auimgr, layersManager, settings->m_AuiPanels.right_panel_width, -1 );
428 }
429 else
430 {
431 settings->m_AuiPanels.right_panel_width = m_appearancePanel->GetSize().x;
432 m_auimgr.Update();
433 }
434}
435
436
438{
439 return const_cast<wxAuiManager&>( m_auimgr ).GetPane( m_treePane ).IsShown();
440}
441
442
444{
445 return GetBoard()->GetFirstFootprint();
446}
447
448
450{
452}
453
454
456{
458}
459
460
462{
463 LIB_ID id;
464
465 if( IsSearchTreeShown() )
466 id = GetTreeFPID();
467
468 if( id.GetLibNickname().empty() )
469 id = GetLoadedFPID();
470
471 return id;
472}
473
474
476{
477 FOOTPRINT* footprint = GetBoard()->GetFirstFootprint();
478
479 if( footprint )
480 return LIB_ID( footprint->GetFPID().GetLibNickname(), m_footprintNameWhenLoaded );
481 else
482 return LIB_ID();
483}
484
485
487{
488 if( GetBoard()->GetFirstFootprint() )
490
491 GetScreen()->SetContentModified( false );
492}
493
494
496{
497 // If we've already vetted closing this window, then we have no FP anymore
498 if( m_isClosing )
499 return false;
500
501 FOOTPRINT* footprint = GetBoard()->GetFirstFootprint();
502
503 return ( footprint && footprint->GetLink() != niluuid );
504}
505
506
508{
509 LIB_ID id = GetLoadedFPID();
510
511 if( id.IsValid() )
512 {
514 Prj().SetRString( PROJECT::PCB_FOOTPRINT_EDITOR_FP_NAME, id.GetLibItemName() );
515 }
516}
517
518
520{
521 const wxString& footprintName = Prj().GetRString( PROJECT::PCB_FOOTPRINT_EDITOR_FP_NAME );
522 const wxString& libNickname = Prj().GetRString( PROJECT::PCB_FOOTPRINT_EDITOR_LIB_NICKNAME );
523
524 if( libNickname.Length() && footprintName.Length() )
525 {
526 LIB_ID id;
527 id.SetLibNickname( libNickname );
528 id.SetLibItemName( footprintName );
529
530 FOOTPRINT* footprint = loadFootprint( id );
531
532 if( footprint )
533 AddFootprintToBoard( footprint );
534 }
535}
536
537
539{
540 m_originalFootprintCopy.reset( static_cast<FOOTPRINT*>( aFootprint->Clone() ) );
541 m_originalFootprintCopy->SetParent( nullptr );
542
544
546 // Ensure item UUIDs are valid
547 // ("old" footprints can have null uuids that create issues in fp editor)
548 aFootprint->FixUuids();
549
551 {
552 wxString msg;
553 msg.Printf( _( "Editing %s from board. Saving will update the board only." ),
554 aFootprint->GetReference() );
555
558 GetInfoBar()->ShowMessage( msg, wxICON_INFORMATION );
559 }
560 else
561 {
562 GetInfoBar()->Dismiss();
563 }
564
566}
567
568
570{
572}
573
574
576{
577 return GetBoard()->GetDesignSettings();
578}
579
580
582{
583 wxFAIL_MSG( wxT( "Plotting not supported in Footprint Editor" ) );
584
586}
587
588
590{
591 wxFAIL_MSG( wxT( "Plotting not supported in Footprint Editor" ) );
592}
593
594
596{
597 if( !m_editorSettings )
598 m_editorSettings = Pgm().GetSettingsManager().GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>();
599
600 return m_editorSettings;
601}
602
603
605{
607 : Pgm().GetSettingsManager().GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>();
608}
609
610
612{
613 // Get our own settings; aCfg will be the PCBNEW_SETTINGS because we're part of the pcbnew
614 // compile unit
616
617 if( cfg )
618 {
620
622
626
629
631 }
632}
633
634
636{
638
639 // Get our own settings; aCfg will be the PCBNEW_SETTINGS because we're part of the pcbnew
640 // compile unit
642
643 if( cfg )
644 {
646
649 cfg->m_LibWidth = m_treePane->GetSize().x;
653
657
660
663
665 }
666}
667
668
669
671{
672 FOOTPRINT_EDITOR_SETTINGS* cfg = const_cast<FOOTPRINT_EDIT_FRAME*>( this )->GetSettings();
673
674 return cfg ? cfg->m_RotationAngle : ANGLE_90;
675}
676
677
678
680{
681 wxString currentTheme = GetFootprintEditorSettings()->m_ColorTheme;
682 return Pgm().GetSettingsManager().GetColorSettings( currentTheme );
683}
684
685
687{
688 // Get the actual frame settings for magnetic items
690 wxCHECK( cfg, nullptr );
691 return &cfg->m_MagneticItems;
692}
693
694
695const BOX2I FOOTPRINT_EDIT_FRAME::GetDocumentExtents( bool aIncludeAllVisible ) const
696{
697 FOOTPRINT* footprint = GetBoard()->GetFirstFootprint();
698
699 if( footprint )
700 {
701 bool hasGraphicalItem = footprint->Pads().size() || footprint->Zones().size();
702
703 if( !hasGraphicalItem )
704 {
705 for( const BOARD_ITEM* item : footprint->GraphicalItems() )
706 {
707 if( item->Type() == PCB_TEXT_T )
708 continue;
709
710 hasGraphicalItem = true;
711 break;
712 }
713 }
714
715 if( hasGraphicalItem )
716 {
717 return footprint->GetBoundingBox( false, false );
718 }
719 else
720 {
721 BOX2I newFootprintBB( { 0, 0 }, { 0, 0 } );
722 newFootprintBB.Inflate( pcbIUScale.mmToIU( 12 ) );
723 return newFootprintBB;
724 }
725 }
726
727 return GetBoardBoundingBox( false );
728}
729
730
732{
733 if( IsContentModified() )
734 {
735 wxString footprintName = GetBoard()->GetFirstFootprint()->GetReference();
736 wxString msg = _( "Save changes to '%s' before closing?" );
737
738 if( !HandleUnsavedChanges( this, wxString::Format( msg, footprintName ),
739 [&]() -> bool
740 {
741 return SaveFootprint( GetBoard()->GetFirstFootprint() );
742 } ) )
743 {
744 return false;
745 }
746 }
747
748 if( doClose )
749 {
750 GetInfoBar()->ShowMessageFor( wxEmptyString, 1 );
751 Clear_Pcb( false );
752 UpdateTitle();
753 }
754
755 return true;
756}
757
758
759bool FOOTPRINT_EDIT_FRAME::canCloseWindow( wxCloseEvent& aEvent )
760{
761 if( IsContentModified() )
762 {
763 // Shutdown blocks must be determined and vetoed as early as possible
765 aEvent.GetId() == wxEVT_QUERY_END_SESSION )
766 {
767 aEvent.Veto();
768 return false;
769 }
770
771 wxString footprintName = GetBoard()->GetFirstFootprint()->GetFPID().GetLibItemName();
772
774 footprintName = GetBoard()->GetFirstFootprint()->GetReference();
775
776 wxString msg = _( "Save changes to '%s' before closing?" );
777
778 if( !HandleUnsavedChanges( this, wxString::Format( msg, footprintName ),
779 [&]() -> bool
780 {
781 return SaveFootprint( GetBoard()->GetFirstFootprint() );
782 } ) )
783 {
784 aEvent.Veto();
785 return false;
786 }
787 }
788
789 // Save footprint tree column widths
790 m_adapter->SaveSettings();
791
793}
794
795
797{
798 // No more vetos
799 GetCanvas()->SetEventDispatcher( nullptr );
801
802 // Do not show the layer manager during closing to avoid flicker
803 // on some platforms (Windows) that generate useless redraw of items in
804 // the Layer Manager
805 m_auimgr.GetPane( wxT( "LayersManager" ) ).Show( false );
806 m_auimgr.GetPane( wxT( "SelectionFilter" ) ).Show( false );
807
808 Clear_Pcb( false );
809
811
812 if( mgr->IsProjectOpen() && wxFileName::IsDirWritable( Prj().GetProjectPath() ) )
813 {
814 GFootprintList.WriteCacheToFile( Prj().GetProjectPath() + wxT( "fp-info-cache" ) );
815 }
816}
817
818
819void FOOTPRINT_EDIT_FRAME::OnExitKiCad( wxCommandEvent& event )
820{
821 Kiway().OnKiCadExit();
822}
823
824
826{
827 Close();
828}
829
830
832{
834
835 aEvent.Enable( frame && frame->GetBoard()->GetFirstFootprint() != nullptr );
836}
837
838
840{
842
843 FOOTPRINT* editorFootprint = GetBoard()->GetFirstFootprint();
844 bool canInsert = frame && editorFootprint && editorFootprint->GetLink() == niluuid;
845
846 // If the source was deleted, the footprint can inserted but not updated in the board.
847 if( frame && editorFootprint && editorFootprint->GetLink() != niluuid )
848 {
849 BOARD* mainpcb = frame->GetBoard();
850 canInsert = true;
851
852 // search if the source footprint was not deleted:
853 for( FOOTPRINT* candidate : mainpcb->Footprints() )
854 {
855 if( editorFootprint->GetLink() == candidate->m_Uuid )
856 {
857 canInsert = false;
858 break;
859 }
860 }
861 }
862
863 aEvent.Enable( canInsert );
864}
865
866
868{
869 // call my base class
871
872 // We have 2 panes to update.
873 // For some obscure reason, the AUI manager hides the first modified pane.
874 // So force show panes
875 wxAuiPaneInfo& tree_pane_info = m_auimgr.GetPane( m_treePane );
876 bool tree_shown = tree_pane_info.IsShown();
877 tree_pane_info.Caption( _( "Libraries" ) );
878
879 wxAuiPaneInfo& lm_pane_info = m_auimgr.GetPane( m_appearancePanel );
880 bool lm_shown = lm_pane_info.IsShown();
881 lm_pane_info.Caption( _( "Appearance" ) );
882 wxAuiPaneInfo& sf_pane_info = m_auimgr.GetPane( m_selectionFilterPanel );
883 sf_pane_info.Caption( _( "Selection Filter" ) );
884
885 // update the layer manager
889
890 // Now restore the visibility:
891 lm_pane_info.Show( lm_shown );
892 tree_pane_info.Show( tree_shown );
893 m_auimgr.Update();
894
896
897 UpdateTitle();
898}
899
900
902{
904 Update3DView( true, true );
906
907 if( !GetTitle().StartsWith( wxT( "*" ) ) )
908 UpdateTitle();
909}
910
911
913{
914 wxString title;
915 LIB_ID fpid = GetLoadedFPID();
916 FOOTPRINT* footprint = GetBoard()->GetFirstFootprint();
917 bool writable = true;
918
920 {
921 if( IsContentModified() )
922 title = wxT( "*" );
923
924 title += footprint->GetReference();
925 title += wxS( " " ) + wxString::Format( _( "[from %s]" ), Prj().GetProjectName()
926 + wxT( "." )
928 }
929 else if( fpid.IsValid() )
930 {
931 try
932 {
934 }
935 catch( const IO_ERROR& )
936 {
937 // best efforts...
938 }
939
940 // Note: don't used GetLoadedFPID(); footprint name may have been edited
941 if( IsContentModified() )
942 title = wxT( "*" );
943
944 title += FROM_UTF8( footprint->GetFPID().Format().c_str() );
945
946 if( !writable )
947 title += wxS( " " ) + _( "[Read Only]" );
948 }
949 else if( !fpid.GetLibItemName().empty() )
950 {
951 // Note: don't used GetLoadedFPID(); footprint name may have been edited
952 if( IsContentModified() )
953 title = wxT( "*" );
954
955 title += FROM_UTF8( footprint->GetFPID().GetLibItemName().c_str() );
956 title += wxS( " " ) + _( "[Unsaved]" );
957 }
958 else
959 {
960 title = _( "[no footprint loaded]" );
961 }
962
963 title += wxT( " \u2014 " ) + _( "Footprint Editor" );
964
965 SetTitle( title );
966}
967
968
970{
972}
973
974
976{
980 UpdateTitle();
981}
982
983
985{
986 FP_LIB_TABLE* fpTable = Prj().PcbFootprintLibs();
987
988 WX_PROGRESS_REPORTER progressReporter( this, _( "Loading Footprint Libraries" ), 2 );
989
990 if( GFootprintList.GetCount() == 0 )
991 GFootprintList.ReadCacheFromFile( Prj().GetProjectPath() + wxT( "fp-info-cache" ) );
992
993 GFootprintList.ReadFootprintFiles( fpTable, nullptr, &progressReporter );
994 progressReporter.Show( false );
995
998
1000 auto adapter = static_cast<FP_TREE_SYNCHRONIZING_ADAPTER*>( m_adapter.get() );
1001
1002 adapter->AddLibraries( this );
1003}
1004
1005
1007{
1008 FP_LIB_TABLE* fpTable = Prj().PcbFootprintLibs();
1009 auto adapter = static_cast<FP_TREE_SYNCHRONIZING_ADAPTER*>( m_adapter.get() );
1010 LIB_ID target = GetTargetFPID();
1011 bool targetSelected = ( target == m_treePane->GetLibTree()->GetSelectedLibId() );
1012
1013 // Sync FOOTPRINT_INFO list to the libraries on disk
1014 if( aProgress )
1015 {
1016 WX_PROGRESS_REPORTER progressReporter( this, _( "Updating Footprint Libraries" ), 2 );
1017 GFootprintList.ReadFootprintFiles( fpTable, nullptr, &progressReporter );
1018 progressReporter.Show( false );
1019 }
1020 else
1021 {
1022 GFootprintList.ReadFootprintFiles( fpTable, nullptr, nullptr );
1023 }
1024
1025 // Sync the LIB_TREE to the FOOTPRINT_INFO list
1026 adapter->Sync( fpTable );
1027
1029 m_treePane->GetLibTree()->Regenerate( true );
1030
1031 if( target.IsValid() )
1032 {
1033 if( adapter->FindItem( target ) )
1034 {
1035 if( targetSelected )
1036 m_treePane->GetLibTree()->SelectLibId( target );
1037 else
1038 m_treePane->GetLibTree()->CenterLibId( target );
1039 }
1040 else
1041 {
1042 // Try to focus on parent
1043 target.SetLibItemName( wxEmptyString );
1044 m_treePane->GetLibTree()->CenterLibId( target );
1045 }
1046 }
1047}
1048
1049
1051{
1052 LIB_ID target = GetTargetFPID();
1053
1054 m_treePane->GetLibTree()->Regenerate( true );
1055
1056 if( target.IsValid() )
1057 m_treePane->GetLibTree()->CenterLibId( target );
1058}
1059
1060
1062{
1064}
1065
1066
1068{
1069 m_treePane->GetLibTree()->SelectLibId( aLibID );
1070}
1071
1072
1074{
1076}
1077
1078
1080{
1081 // Create the manager and dispatcher & route draw panel events to the dispatcher
1084 GetCanvas()->GetViewControls(), config(), this );
1085 m_actions = new PCB_ACTIONS();
1087
1089
1098 m_toolManager->RegisterTool( new PCB_CONTROL ); // copy/paste
1108
1109 for( TOOL_BASE* tool : m_toolManager->Tools() )
1110 {
1111 if( PCB_TOOL_BASE* pcbTool = dynamic_cast<PCB_TOOL_BASE*>( tool ) )
1112 pcbTool->SetIsFootprintEditor( true );
1113 }
1114
1115 m_toolManager->GetTool<PCB_VIEWER_TOOLS>()->SetFootprintFrame( true );
1117
1118 m_toolManager->InvokeTool( "pcbnew.InteractiveSelection" );
1119
1120 // Load or reload wizard plugins in case they changed since the last time the frame opened
1121 // Because the board editor has also a plugin python menu,
1122 // call the PCB_EDIT_FRAME RunAction() if the board editor is running
1123 // Otherwise run the current RunAction().
1124 PCB_EDIT_FRAME* pcbframe = static_cast<PCB_EDIT_FRAME*>( Kiway().Player( FRAME_PCB_EDITOR, false ) );
1125
1126 if( pcbframe )
1128 else
1130}
1131
1132
1134{
1136
1138 PCB_EDITOR_CONDITIONS cond( this );
1139
1140 wxASSERT( mgr );
1141
1142#define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
1143#define CHECK( x ) ACTION_CONDITIONS().Check( x )
1144
1145 auto haveFootprintCond =
1146 [this]( const SELECTION& )
1147 {
1148 return GetBoard()->GetFirstFootprint() != nullptr;
1149 };
1150
1151 auto footprintTargettedCond =
1152 [this]( const SELECTION& )
1153 {
1154 return !GetTargetFPID().GetLibItemName().empty();
1155 };
1156
1157 mgr->SetConditions( ACTIONS::saveAs, ENABLE( footprintTargettedCond ) );
1160
1163
1166 mgr->SetConditions( ACTIONS::millimetersUnits, CHECK( cond.Units( EDA_UNITS::MILLIMETRES ) ) );
1167 mgr->SetConditions( ACTIONS::inchesUnits, CHECK( cond.Units( EDA_UNITS::INCHES ) ) );
1168 mgr->SetConditions( ACTIONS::milsUnits, CHECK( cond.Units( EDA_UNITS::MILS ) ) );
1169
1170 mgr->SetConditions( ACTIONS::cut, ENABLE( cond.HasItems() ) );
1171 mgr->SetConditions( ACTIONS::copy, ENABLE( cond.HasItems() ) );
1177
1184
1188
1191
1192 auto constrainedDrawingModeCond =
1193 [this]( const SELECTION& )
1194 {
1195 return GetSettings()->m_Use45Limit;
1196 };
1197
1198 auto highContrastCond =
1199 [this]( const SELECTION& )
1200 {
1201 return GetDisplayOptions().m_ContrastModeDisplay != HIGH_CONTRAST_MODE::NORMAL;
1202 };
1203
1204 auto boardFlippedCond =
1205 [this]( const SELECTION& )
1206 {
1207 return GetCanvas()->GetView()->IsMirroredX();
1208 };
1209
1210 auto footprintTreeCond =
1211 [this](const SELECTION& )
1212 {
1213 return IsSearchTreeShown();
1214 };
1215
1216 auto layerManagerCond =
1217 [this]( const SELECTION& )
1218 {
1219 return m_auimgr.GetPane( "LayersManager" ).IsShown();
1220 };
1221
1222 auto propertiesCond =
1223 [this] ( const SELECTION& )
1224 {
1225 return m_auimgr.GetPane( "PropertiesManager" ).IsShown();
1226 };
1227
1228 mgr->SetConditions( PCB_ACTIONS::toggleHV45Mode, CHECK( constrainedDrawingModeCond ) );
1229 mgr->SetConditions( ACTIONS::highContrastMode, CHECK( highContrastCond ) );
1230 mgr->SetConditions( PCB_ACTIONS::flipBoard, CHECK( boardFlippedCond ) );
1232
1233 mgr->SetConditions( PCB_ACTIONS::showFootprintTree, CHECK( footprintTreeCond ) );
1234 mgr->SetConditions( PCB_ACTIONS::showLayersManager, CHECK( layerManagerCond ) );
1235 mgr->SetConditions( PCB_ACTIONS::showProperties, CHECK( propertiesCond ) );
1236
1237 mgr->SetConditions( ACTIONS::print, ENABLE( haveFootprintCond ) );
1238 mgr->SetConditions( PCB_ACTIONS::exportFootprint, ENABLE( haveFootprintCond ) );
1239 mgr->SetConditions( PCB_ACTIONS::placeImportedGraphics, ENABLE( haveFootprintCond ) );
1240
1241 mgr->SetConditions( PCB_ACTIONS::footprintProperties, ENABLE( haveFootprintCond ) );
1242 mgr->SetConditions( PCB_ACTIONS::editTextAndGraphics, ENABLE( haveFootprintCond ) );
1243 mgr->SetConditions( PCB_ACTIONS::checkFootprint, ENABLE( haveFootprintCond ) );
1244 mgr->SetConditions( PCB_ACTIONS::repairFootprint, ENABLE( haveFootprintCond ) );
1245 mgr->SetConditions( PCB_ACTIONS::cleanupGraphics, ENABLE( haveFootprintCond ) );
1246
1247 auto isArcKeepCenterMode = [this]( const SELECTION& )
1248 {
1249 return GetSettings()->m_ArcEditMode == ARC_EDIT_MODE::KEEP_CENTER_ADJUST_ANGLE_RADIUS;
1250 };
1251
1252 auto isArcKeepEndpointMode = [this]( const SELECTION& )
1253 {
1254 return GetSettings()->m_ArcEditMode == ARC_EDIT_MODE::KEEP_ENDPOINTS_OR_START_DIRECTION;
1255 };
1256
1257 mgr->SetConditions( PCB_ACTIONS::pointEditorArcKeepCenter, CHECK( isArcKeepCenterMode ) );
1258 mgr->SetConditions( PCB_ACTIONS::pointEditorArcKeepEndpoint, CHECK( isArcKeepEndpointMode ) );
1259
1260
1261// Only enable a tool if the part is edtable
1262#define CURRENT_EDIT_TOOL( action ) mgr->SetConditions( action, \
1263 ACTION_CONDITIONS().Enable( haveFootprintCond ).Check( cond.CurrentTool( action ) ) )
1264
1284
1285#undef CURRENT_EDIT_TOOL
1286#undef ENABLE
1287#undef CHECK
1288}
1289
1290
1292{
1294
1295 // Be sure the axis are enabled
1296 GetCanvas()->GetGAL()->SetAxesEnabled( true );
1297
1298 UpdateView();
1299
1300 // Ensure the m_Layers settings are using the canvas type:
1302}
1303
1304
1305void FOOTPRINT_EDIT_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
1306{
1307 PCB_BASE_EDIT_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
1308
1309 auto cfg = Pgm().GetSettingsManager().GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>();
1310 GetGalDisplayOptions().ReadWindowSettings( cfg->m_Window );
1311
1312 GetBoard()->GetDesignSettings() = cfg->m_DesignSettings;
1313
1317
1319
1320 if( aEnvVarsChanged )
1321 SyncLibraryTree( true );
1322
1323 Layout();
1324 SendSizeEvent();
1325}
1326
1327
1329{
1330 LIB_ID id = GetLoadedFPID();
1331
1332 if( id.empty() )
1333 {
1334 DisplayErrorMessage( this, _( "No footprint selected." ) );
1335 return;
1336 }
1337
1338 wxFileName fn( id.GetLibItemName() );
1339 fn.SetExt( wxT( "png" ) );
1340
1341 wxString projectPath = wxPathOnly( Prj().GetProjectFullName() );
1342
1343 wxFileDialog dlg( this, _( "Footprint Image File Name" ), projectPath,
1344 fn.GetFullName(), PngFileWildcard(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
1345
1346 if( dlg.ShowModal() == wxID_CANCEL || dlg.GetPath().IsEmpty() )
1347 return;
1348
1349 // calling wxYield is mandatory under Linux, after closing the file selector dialog
1350 // to refresh the screen before creating the PNG or JPEG image from screen
1351 wxYield();
1352 SaveCanvasImageToFile( this, dlg.GetPath() );
1353}
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:106
bool SaveCanvasImageToFile(EDA_DRAW_FRAME *aFrame, const wxString &aFileName, BITMAP_TYPE aBitmapType)
Save the current view as an image file.
Definition: bitmap.cpp:216
@ icon_modedit_32
@ icon_modedit
@ icon_modedit_16
static TOOL_ACTION toggleGrid
Definition: actions.h:144
static TOOL_ACTION paste
Definition: actions.h:69
static TOOL_ACTION millimetersUnits
Definition: actions.h:150
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:149
static TOOL_ACTION toggleBoundingBoxes
Definition: actions.h:108
static TOOL_ACTION undo
Definition: actions.h:65
static TOOL_ACTION duplicate
Definition: actions.h:72
static TOOL_ACTION inchesUnits
Definition: actions.h:148
static TOOL_ACTION highContrastMode
Definition: actions.h:106
static TOOL_ACTION toggleCursorStyle
Definition: actions.h:105
static TOOL_ACTION measureTool
Definition: actions.h:158
static TOOL_ACTION doDelete
Definition: actions.h:73
static TOOL_ACTION selectionTool
Definition: actions.h:157
static TOOL_ACTION save
Definition: actions.h:51
static TOOL_ACTION zoomFitScreen
Definition: actions.h:99
static TOOL_ACTION redo
Definition: actions.h:66
static TOOL_ACTION deleteTool
Definition: actions.h:74
static TOOL_ACTION zoomTool
Definition: actions.h:102
static TOOL_ACTION print
Definition: actions.h:57
static TOOL_ACTION cut
Definition: actions.h:67
static TOOL_ACTION gridSetOrigin
Definition: actions.h:141
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:71
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:270
void SetBoardUse(BOARD_USE aUse)
Set what the board is going to be used for.
Definition: board.h:282
void SetEnabledLayers(LSET aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings.
Definition: board.cpp:631
bool SetLayerName(PCB_LAYER_ID aLayer, const wxString &aLayerName)
Changes the name of the layer given by aLayer.
Definition: board.cpp:514
FOOTPRINT * GetFirstFootprint() const
Get the first footprint on the board or nullptr.
Definition: board.h:405
FOOTPRINTS & Footprints()
Definition: board.h:312
void SetVisibleAlls()
Change the bit-mask of visible element categories and layers.
Definition: board.cpp:660
void SetVisibleLayers(LSET aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings changes the bit-mask of vis...
Definition: board.cpp:643
void SetCopperLayerCount(int aCount)
Definition: board.cpp:593
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:728
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
void ShowChangedLanguage() override
Redraw the menus and what not in current language.
virtual void setupUIConditions()
Setup the UI conditions for the various actions and their controls in this frame.
wxAuiManager m_auimgr
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
virtual void OnSize(wxSizeEvent &aEvent)
virtual bool canCloseWindow(wxCloseEvent &aCloseEvent)
bool m_isClosing
Set by NonUserClose() to indicate that the user did not request the current close.
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 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:239
ZONES & Zones()
Definition: footprint.h:178
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: footprint.cpp:1386
PADS & Pads()
Definition: footprint.h:172
const LIB_ID & GetFPID() const
Definition: footprint.h:214
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:1023
KIID GetLink() const
Definition: footprint.h:691
const wxString & GetReference() const
Definition: footprint.h:521
DRAWINGS & GraphicalItems()
Definition: footprint.h:175
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: footprint.cpp:806
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
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition: kiway.h:279
void OnKiCadExit()
Definition: kiway.cpp:733
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:432
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:361
LIB_TREE_NODE * GetCurrentTreeNode() const
Definition: lib_tree.cpp:267
void CenterLibId(const LIB_ID &aLibId)
Ensure that an item is visible (preferably centered).
Definition: lib_tree.cpp:284
void ShowChangedLanguage()
Definition: lib_tree.cpp:226
void SelectLibId(const LIB_ID &aLibId)
Select an item in the tree widget.
Definition: lib_tree.cpp:278
LIB_TREE_MODEL_ADAPTER::SORT_MODE GetSortMode() const
Definition: lib_tree.h:135
void Unselect()
Unselect currently selected item in wxDataViewCtrl.
Definition: lib_tree.cpp:290
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:236
void Regenerate(bool aKeepState)
Regenerate the tree.
Definition: lib_tree.cpp:343
void SetSortMode(LIB_TREE_MODEL_ADAPTER::SORT_MODE aMode)
Save/restore the sorting mode.
Definition: lib_tree.h:134
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:467
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:390
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:419
static TOOL_ACTION showFootprintTree
Definition: pcb_actions.h:396
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:427
static TOOL_ACTION group
Definition: pcb_actions.h:475
static TOOL_ACTION drawRadialDimension
Definition: pcb_actions.h:180
static TOOL_ACTION showProperties
Definition: pcb_actions.h:391
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:531
static TOOL_ACTION ungroup
Definition: pcb_actions.h:476
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:439
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:421
static TOOL_ACTION flipBoard
Definition: pcb_actions.h:330
static TOOL_ACTION textOutlines
Display texts as lines.
Definition: pcb_actions.h:442
static TOOL_ACTION checkFootprint
Definition: pcb_actions.h:424
static TOOL_ACTION mirrorV
Definition: pcb_actions.h:130
static TOOL_ACTION repairFootprint
Definition: pcb_actions.h:492
static TOOL_ACTION drawLine
Definition: pcb_actions.h:170
static TOOL_ACTION cleanupGraphics
Definition: pcb_actions.h:364
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
PROPERTIES_PANEL * m_propertiesPanel
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.
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 AddFootprintToBoard(FOOTPRINT *aFootprint)
Add the given footprint to the board.
PCB_DISPLAY_OPTIONS m_displayOptions
FOOTPRINT_EDITOR_SETTINGS * GetFootprintEditorSettings() const
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
float SplitterProportion() const
Action handler for the Properties panel.
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...
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 (the sheet for a schematic)
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:301
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:140
void Dismiss() override
Dismisses the infobar and updates the containing layout and AUI manager (if one is provided).
Definition: wx_infobar.cpp:187
void AddCloseButton(const wxString &aTooltip=_("Hide this message."))
Add the default close button to the infobar on the right side.
Definition: wx_infobar.cpp:291
void ShowMessage(const wxString &aMessage, int aFlags=wxICON_INFORMATION) override
Show the info bar with the provided message and icon.
Definition: wx_infobar.cpp:154
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:243
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:308
This file is part of the common library.
#define CHECK(x)
#define ENABLE(x)
#define _HKI(x)
static bool empty(const wxTextEntryBase *aCtrl)
#define _(s)
Declaration of the eda_3d_viewer class.
static constexpr EDA_ANGLE & ANGLE_90
Definition: eda_angle.h:431
#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 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
PROJECT & Prj()
Definition: kicad.cpp:554
KIID niluuid(0)
KIWAY Kiway
@ 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
@ 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
SETTINGS_MANAGER * GetSettingsManager()
BOARD * GetBoard()
see class PGM_BASE
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:115
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:106
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
Definition: typeinfo.h:90
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.