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"
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_id.h>
53#include <pgm_base.h>
54#include <project.h>
55#include <project_pcb.h>
57#include <tool/action_toolbar.h>
58#include <tool/common_control.h>
59#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
94
95 // UI update events.
97 FOOTPRINT_EDIT_FRAME::OnUpdateLoadFootprintFromBoard )
99 FOOTPRINT_EDIT_FRAME::OnUpdateSaveFootprintToBoard )
101
102 // Drop files event
103 EVT_DROP_FILES( FOOTPRINT_EDIT_FRAME::OnDropFiles )
104
105END_EVENT_TABLE()
106
107
108FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
109 PCB_BASE_EDIT_FRAME( aKiway, aParent, FRAME_FOOTPRINT_EDITOR, wxEmptyString,
110 wxDefaultPosition, wxDefaultSize,
111 KICAD_DEFAULT_DRAWFRAME_STYLE, GetFootprintEditorFrameName() ),
112 m_show_layer_manager_tools( true )
113{
114 m_showBorderAndTitleBlock = false; // true to show the frame references
115 m_aboutTitle = _HKI( "KiCad Footprint Editor" );
116 m_selLayerBox = nullptr;
117 m_editorSettings = nullptr;
118
119 // Give an icon
120 wxIcon icon;
121 wxIconBundle icon_bundle;
122
123 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_modedit ) );
124 icon_bundle.AddIcon( icon );
125 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_modedit_32 ) );
126 icon_bundle.AddIcon( icon );
127 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_modedit_16 ) );
128 icon_bundle.AddIcon( icon );
129
130 SetIcons( icon_bundle );
131
132 // Create GAL canvas
133 m_canvasType = loadCanvasTypeSetting( GetSettings() );
134
135 PCB_DRAW_PANEL_GAL* drawPanel = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_frameSize,
136 GetGalDisplayOptions(), m_canvasType );
137 SetCanvas( drawPanel );
138
139 CreateInfoBar();
140
141 SetBoard( new BOARD() );
142
143 // This board will only be used to hold a footprint for editing
145
146 // In Footprint Editor, the default net clearance is not known (it depends on the actual
147 // board). So we do not show the default clearance, by setting it to 0. The footprint or
148 // pad specific clearance will be shown.
149 GetBoard()->GetDesignSettings().m_NetSettings->m_DefaultNetClass->SetClearance( 0 );
150
151 // Don't show the default board solder mask expansion in the footprint editor. Only the
152 // footprint or pad mask expansions settings should be shown.
154
155 // Ensure all layers and items are visible:
156 // In footprint editor, some layers have no meaning or cannot be used, but we show all of
157 // them, at least to be able to edit a bad layer
159
160 GetGalDisplayOptions().m_axesEnabled = true;
161
162 // In Footprint Editor, set the default paper size to A4 for plot/print
163 SetPageSettings( PAGE_INFO( PAGE_INFO::A4 ) );
164 SetScreen( new PCB_SCREEN( GetPageSettings().GetSizeIU( pcbIUScale.IU_PER_MILS ) ) );
165
166 // Create the manager and dispatcher & route draw panel events to the dispatcher
167 setupTools();
168 setupUIConditions();
169
170 initLibraryTree();
171 m_treePane = new FOOTPRINT_TREE_PANE( this );
172
173 // restore the last footprint from the project, if any, after the library has been init'ed
174 restoreLastFootprint();
175
176 ReCreateMenuBar();
177 ReCreateHToolbar();
178 ReCreateVToolbar();
179 ReCreateOptToolbar();
180
181 m_selectionFilterPanel = new PANEL_SELECTION_FILTER( this );
182 m_appearancePanel = new APPEARANCE_CONTROLS( this, GetCanvas(), true );
183 m_propertiesPanel = new PCB_PROPERTIES_PANEL( this, this );
184
185 // LoadSettings() *after* creating m_LayersManager, because LoadSettings() initialize
186 // parameters in m_LayersManager
187 // NOTE: KifaceSettings() will return PCBNEW_SETTINGS if we started from pcbnew
188 LoadSettings( GetSettings() );
189
190 float proportion = GetFootprintEditorSettings()->m_AuiPanels.properties_splitter;
191 m_propertiesPanel->SetSplitterProportion( proportion );
192
193 // Must be set after calling LoadSettings() to be sure these parameters are not dependent
194 // on what is read in stored settings. Enable one internal layer, because footprints
195 // support keepout areas that can be on internal layers only (therefore on the first internal
196 // layer). This is needed to handle these keepout in internal layers only.
198 GetBoard()->SetEnabledLayers( GetBoard()->GetEnabledLayers().set( In1_Cu ) );
199 GetBoard()->SetVisibleLayers( GetBoard()->GetEnabledLayers() );
200 GetBoard()->SetLayerName( In1_Cu, _( "Inner layers" ) );
201
202 SetActiveLayer( F_SilkS );
203
204 m_auimgr.SetManagedWindow( this );
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( PropertiesPaneName() )
227 .Left().Layer( 3 )
228 .Caption( _( "Properties" ) ).PaneBorder( false )
229 .MinSize( 240, 60 ).BestSize( 300, 200 ) );
230 m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" )
231 .Left().Layer( 2 ) );
232
233 m_auimgr.AddPane( m_drawToolBar, EDA_PANE().VToolbar().Name( "ToolsToolbar" )
234 .Right().Layer(2) );
235 m_auimgr.AddPane( m_appearancePanel, EDA_PANE().Name( "LayersManager" )
236 .Right().Layer( 3 )
237 .Caption( _( "Appearance" ) ).PaneBorder( false )
238 .MinSize( 180, -1 ).BestSize( 180, -1 ) );
239 m_auimgr.AddPane( m_selectionFilterPanel, EDA_PANE().Palette().Name( "SelectionFilter" )
240 .Right().Layer( 3 ).Position( 2 )
241 .Caption( _( "Selection Filter" ) ).PaneBorder( false )
242 .MinSize( 180, -1 ).BestSize( 180, -1 ) );
243
244 // Center
245 m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( "DrawFrame" )
246 .Center() );
247
248 m_auimgr.GetPane( "LayersManager" ).Show( m_show_layer_manager_tools );
249 m_auimgr.GetPane( "SelectionFilter" ).Show( m_show_layer_manager_tools );
250 m_auimgr.GetPane( PropertiesPaneName() ).Show( GetSettings()->m_AuiPanels.show_properties );
251
252 // The selection filter doesn't need to grow in the vertical direction when docked
253 m_auimgr.GetPane( "SelectionFilter" ).dock_proportion = 0;
254
255 m_acceptedExts.emplace( KiCadFootprintLibPathExtension, &ACTIONS::ddAddLibrary );
257 DragAcceptFiles( true );
258
259 ActivateGalCanvas();
260
261 FinishAUIInitialization();
262
263 // Apply saved visibility stuff at the end
264 if( FOOTPRINT_EDITOR_SETTINGS* cfg = dynamic_cast<FOOTPRINT_EDITOR_SETTINGS*>( GetSettings() ) )
265 {
266 wxAuiPaneInfo& treePane = m_auimgr.GetPane( "Footprints" );
267 wxAuiPaneInfo& layersManager = m_auimgr.GetPane( "LayersManager" );
268
269 if( cfg->m_LibWidth > 0 )
270 SetAuiPaneSize( m_auimgr, treePane, cfg->m_LibWidth, -1 );
271
272 if( cfg->m_AuiPanels.right_panel_width > 0 )
273 SetAuiPaneSize( m_auimgr, layersManager, cfg->m_AuiPanels.right_panel_width, -1 );
274
275 m_appearancePanel->SetUserLayerPresets( cfg->m_LayerPresets );
276 m_appearancePanel->ApplyLayerPreset( cfg->m_ActiveLayerPreset );
277 m_appearancePanel->SetTabIndex( cfg->m_AuiPanels.appearance_panel_tab );
278 }
279
280 GetToolManager()->PostAction( ACTIONS::zoomFitScreen );
281 UpdateTitle();
282 setupUnits( GetSettings() );
283
284 resolveCanvasType();
285
286 // Default shutdown reason until a file is loaded
287 KIPLATFORM::APP::SetShutdownBlockReason( this, _( "Footprint changes are unsaved" ) );
288
289 // Catch unhandled accelerator command characters that were no handled by the library tree
290 // panel.
291 Bind( wxEVT_CHAR, &TOOL_DISPATCHER::DispatchWxEvent, m_toolDispatcher );
292 Bind( wxEVT_CHAR_HOOK, &TOOL_DISPATCHER::DispatchWxEvent, m_toolDispatcher );
293
294 // Ensure the window is on top
295 Raise();
296 Show( true );
297
298 // Register a call to update the toolbar sizes. It can't be done immediately because
299 // it seems to require some sizes calculated that aren't yet (at least on GTK).
300 CallAfter(
301 [&]()
302 {
303 // Ensure the controls on the toolbars all are correctly sized
304 UpdateToolbarControlSizes();
305 m_treePane->FocusSearchFieldIfExists();
306 } );
307}
308
309
311{
312 // Shutdown all running tools
313 if( m_toolManager )
315
316 // save the footprint in the PROJECT
318
319 // Clear the watched file
320 setFPWatcher( nullptr );
321
323 delete m_appearancePanel;
324 delete m_treePane;
325}
326
327
329{
331
332 FOOTPRINT* fp = static_cast<FOOTPRINT*>( GetModel() );
333
334 if( fp )
335 {
336 std::vector<MSG_PANEL_ITEM> msgItems;
337 fp->GetMsgPanelInfo( this, msgItems );
338 SetMsgPanel( msgItems );
339 }
340}
341
342
344{
345 return GetScreen() && GetScreen()->IsContentModified()
347}
348
349
351{
352 return m_toolManager->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
353}
354
355
357{
358 // switches currently used canvas (Cairo / OpenGL).
359 PCB_BASE_FRAME::SwitchCanvas( aCanvasType );
360
361 GetCanvas()->GetGAL()->SetAxesEnabled( true );
362
363 // The base class method *does not reinit* the layers manager. We must update the layer
364 // widget to match board visibility states, both layers and render columns, and and some
365 // settings dependent on the canvas.
367}
368
369
371{
372 SyncLibraryTree( true );
374}
375
376
378{
379 wxAuiPaneInfo& treePane = m_auimgr.GetPane( m_treePane );
380 treePane.Show( !IsSearchTreeShown() );
381
382 if( IsSearchTreeShown() )
383 {
384 // SetAuiPaneSize also updates m_auimgr
386 }
387 else
388 {
389 m_editorSettings->m_LibWidth = m_treePane->GetSize().x;
390 m_auimgr.Update();
391 }
392}
393
394
396{
398 wxAuiPaneInfo& layersManager = m_auimgr.GetPane( "LayersManager" );
399 wxAuiPaneInfo& selectionFilter = m_auimgr.GetPane( "SelectionFilter" );
400
401 // show auxiliary Vertical layers and visibility manager toolbar
403 layersManager.Show( m_show_layer_manager_tools );
404 selectionFilter.Show( m_show_layer_manager_tools );
405
407 {
408 SetAuiPaneSize( m_auimgr, layersManager, settings->m_AuiPanels.right_panel_width, -1 );
409 }
410 else
411 {
412 settings->m_AuiPanels.right_panel_width = m_appearancePanel->GetSize().x;
413 m_auimgr.Update();
414 }
415}
416
417
419{
420 return const_cast<wxAuiManager&>( m_auimgr ).GetPane( m_treePane ).IsShown();
421}
422
423
425{
426 return GetBoard()->GetFirstFootprint();
427}
428
429
431{
433}
434
435
437{
439}
440
441
443{
444 LIB_ID id;
445
446 if( IsSearchTreeShown() )
447 id = GetTreeFPID();
448
449 if( id.GetLibNickname().empty() )
450 id = GetLoadedFPID();
451
452 return id;
453}
454
455
457{
458 FOOTPRINT* footprint = GetBoard()->GetFirstFootprint();
459
460 if( footprint )
461 return LIB_ID( footprint->GetFPID().GetLibNickname(), m_footprintNameWhenLoaded );
462 else
463 return LIB_ID();
464}
465
466
468{
469 if( GetBoard()->GetFirstFootprint() )
470 {
473 }
474
475 GetScreen()->SetContentModified( false );
476}
477
478
480{
481 // If we've already vetted closing this window, then we have no FP anymore
482 if( m_isClosing || !GetBoard() )
483 return false;
484
485 FOOTPRINT* footprint = GetBoard()->GetFirstFootprint();
486
487 return ( footprint && footprint->GetLink() != niluuid );
488}
489
490
492{
493 LIB_ID id = GetLoadedFPID();
494
495 if( id.IsValid() )
496 {
498 Prj().SetRString( PROJECT::PCB_FOOTPRINT_EDITOR_FP_NAME, id.GetLibItemName() );
499 }
500}
501
502
504{
505 const wxString& footprintName = Prj().GetRString( PROJECT::PCB_FOOTPRINT_EDITOR_FP_NAME );
506 const wxString& libNickname = Prj().GetRString( PROJECT::PCB_FOOTPRINT_EDITOR_LIB_NICKNAME );
507
508 if( libNickname.Length() && footprintName.Length() )
509 {
510 LIB_ID id;
511 id.SetLibNickname( libNickname );
512 id.SetLibItemName( footprintName );
513
514 FOOTPRINT* footprint = loadFootprint( id );
515
516 if( footprint )
517 AddFootprintToBoard( footprint );
518 }
519}
520
521
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
542 if( WX_INFOBAR* infobar = GetInfoBar() )
543 {
544 infobar->RemoveAllButtons();
545 infobar->AddCloseButton();
546 infobar->ShowMessage( msg, wxICON_INFORMATION );
547 }
548 }
549 else
550 {
551 if( WX_INFOBAR* infobar = GetInfoBar() )
552 infobar->Dismiss();
553 }
554
556}
557
558
560{
561 ReloadFootprint( aFootprint );
562
564 setFPWatcher( nullptr );
565 else
566 setFPWatcher( aFootprint );
567}
568
569
571{
573}
574
575
577{
578 return GetBoard()->GetDesignSettings();
579}
580
581
583{
584 wxFAIL_MSG( wxT( "Plotting not supported in Footprint Editor" ) );
585
587}
588
589
591{
592 wxFAIL_MSG( wxT( "Plotting not supported in Footprint Editor" ) );
593}
594
595
597{
598 if( !m_editorSettings )
599 m_editorSettings = Pgm().GetSettingsManager().GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>();
600
601 return m_editorSettings;
602}
603
604
606{
608 : Pgm().GetSettingsManager().GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>();
609}
610
611
613{
614 // Get our own settings; aCfg will be the PCBNEW_SETTINGS because we're part of the pcbnew
615 // compile unit
617
618 if( cfg )
619 {
621
623
626
629
631 }
632}
633
634
636{
637 // Load canvas type from the FOOTPRINT_EDITOR_SETTINGS:
639
640 // If we had an OpenGL failure this session, use the fallback GAL but don't update the
641 // user preference silently:
642
645}
646
647
649{
651
652 // Get our own settings; aCfg will be the PCBNEW_SETTINGS because we're part of the pcbnew
653 // compile unit
655
656 if( cfg )
657 {
659
662 cfg->m_LibWidth = m_treePane->GetSize().x;
664
666
668 {
669 cfg->m_AuiPanels.show_properties = m_propertiesPanel->IsShownOnScreen();
672 }
673
675
677 {
682 }
683 }
684}
685
686
687
689{
690 FOOTPRINT_EDITOR_SETTINGS* cfg = const_cast<FOOTPRINT_EDIT_FRAME*>( this )->GetSettings();
691
692 return cfg ? cfg->m_RotationAngle : ANGLE_90;
693}
694
695
696
698{
699 wxString currentTheme = GetFootprintEditorSettings()->m_ColorTheme;
700 return Pgm().GetSettingsManager().GetColorSettings( currentTheme );
701}
702
703
705{
706 // Get the actual frame settings for magnetic items
708 wxCHECK( cfg, nullptr );
709 return &cfg->m_MagneticItems;
710}
711
712
713const BOX2I FOOTPRINT_EDIT_FRAME::GetDocumentExtents( bool aIncludeAllVisible ) const
714{
715 FOOTPRINT* footprint = GetBoard()->GetFirstFootprint();
716
717 if( footprint )
718 {
719 bool hasGraphicalItem = footprint->Pads().size() || footprint->Zones().size();
720
721 if( !hasGraphicalItem )
722 {
723 for( const BOARD_ITEM* item : footprint->GraphicalItems() )
724 {
725 if( item->Type() == PCB_TEXT_T || item->Type() == PCB_TEXTBOX_T )
726 continue;
727
728 hasGraphicalItem = true;
729 break;
730 }
731 }
732
733 if( hasGraphicalItem )
734 {
735 return footprint->GetBoundingBox( false, false );
736 }
737 else
738 {
739 BOX2I newFootprintBB( { 0, 0 }, { 0, 0 } );
740 newFootprintBB.Inflate( pcbIUScale.mmToIU( 12 ) );
741 return newFootprintBB;
742 }
743 }
744
745 return GetBoardBoundingBox( false );
746}
747
748
750{
751 if( IsContentModified() )
752 {
753 wxString footprintName = GetBoard()->GetFirstFootprint()->GetReference();
754 wxString msg = _( "Save changes to '%s' before closing?" );
755
756 if( !HandleUnsavedChanges( this, wxString::Format( msg, footprintName ),
757 [&]() -> bool
758 {
759 return SaveFootprint( GetBoard()->GetFirstFootprint() );
760 } ) )
761 {
762 return false;
763 }
764 }
765
766 if( doClose )
767 {
768 GetInfoBar()->ShowMessageFor( wxEmptyString, 1 );
769 Clear_Pcb( false );
770 UpdateTitle();
771 }
772
773 return true;
774}
775
776
777bool FOOTPRINT_EDIT_FRAME::canCloseWindow( wxCloseEvent& aEvent )
778{
779 if( IsContentModified() )
780 {
781 // Shutdown blocks must be determined and vetoed as early as possible
783 aEvent.GetId() == wxEVT_QUERY_END_SESSION )
784 {
785 aEvent.Veto();
786 return false;
787 }
788
789 wxString footprintName = GetBoard()->GetFirstFootprint()->GetFPID().GetLibItemName();
790
792 footprintName = GetBoard()->GetFirstFootprint()->GetReference();
793
794 wxString msg = _( "Save changes to '%s' before closing?" );
795
796 if( !HandleUnsavedChanges( this, wxString::Format( msg, footprintName ),
797 [&]() -> bool
798 {
799 return SaveFootprint( GetBoard()->GetFirstFootprint() );
800 } ) )
801 {
802 aEvent.Veto();
803 return false;
804 }
805 }
806
807 // Save footprint tree column widths
808 m_adapter->SaveSettings();
809
811}
812
813
815{
816 // No more vetos
817 GetCanvas()->SetEventDispatcher( nullptr );
819
820 // Do not show the layer manager during closing to avoid flicker
821 // on some platforms (Windows) that generate useless redraw of items in
822 // the Layer Manager
823 m_auimgr.GetPane( wxT( "LayersManager" ) ).Show( false );
824 m_auimgr.GetPane( wxT( "SelectionFilter" ) ).Show( false );
825
826 Clear_Pcb( false );
827
829
830 if( mgr->IsProjectOpen() && wxFileName::IsDirWritable( Prj().GetProjectPath() ) )
831 {
832 GFootprintList.WriteCacheToFile( Prj().GetProjectPath() + wxT( "fp-info-cache" ) );
833 }
834}
835
836
837void FOOTPRINT_EDIT_FRAME::OnExitKiCad( wxCommandEvent& event )
838{
839 Kiway().OnKiCadExit();
840}
841
842
844{
845 Close();
846}
847
848
850{
852
853 aEvent.Enable( frame != nullptr );
854}
855
856
858{
860
861 FOOTPRINT* editorFootprint = GetBoard()->GetFirstFootprint();
862 bool canInsert = frame && editorFootprint && editorFootprint->GetLink() == niluuid;
863
864 // If the source was deleted, the footprint can inserted but not updated in the board.
865 if( frame && editorFootprint && editorFootprint->GetLink() != niluuid )
866 {
867 BOARD* mainpcb = frame->GetBoard();
868 canInsert = true;
869
870 // search if the source footprint was not deleted:
871 for( FOOTPRINT* candidate : mainpcb->Footprints() )
872 {
873 if( editorFootprint->GetLink() == candidate->m_Uuid )
874 {
875 canInsert = false;
876 break;
877 }
878 }
879 }
880
881 aEvent.Enable( canInsert );
882}
883
884
886{
887 // call my base class
889
890 // We have 2 panes to update.
891 // For some obscure reason, the AUI manager hides the first modified pane.
892 // So force show panes
893 wxAuiPaneInfo& tree_pane_info = m_auimgr.GetPane( m_treePane );
894 bool tree_shown = tree_pane_info.IsShown();
895 tree_pane_info.Caption( _( "Libraries" ) );
896
897 wxAuiPaneInfo& lm_pane_info = m_auimgr.GetPane( m_appearancePanel );
898 bool lm_shown = lm_pane_info.IsShown();
899 lm_pane_info.Caption( _( "Appearance" ) );
900 wxAuiPaneInfo& sf_pane_info = m_auimgr.GetPane( m_selectionFilterPanel );
901 sf_pane_info.Caption( _( "Selection Filter" ) );
902
903 // update the layer manager
907
908 // Now restore the visibility:
909 lm_pane_info.Show( lm_shown );
910 tree_pane_info.Show( tree_shown );
911 m_auimgr.Update();
912
914
915 UpdateTitle();
916}
917
918
920{
922 Update3DView( true, true );
924
925 if( !GetTitle().StartsWith( wxT( "*" ) ) )
926 UpdateTitle();
927}
928
929
931{
932 wxString title;
933 LIB_ID fpid = GetLoadedFPID();
934 FOOTPRINT* footprint = GetBoard()->GetFirstFootprint();
935 bool writable = true;
936
938 {
939 if( IsContentModified() )
940 title = wxT( "*" );
941
942 title += footprint->GetReference();
943 title += wxS( " " ) + wxString::Format( _( "[from %s]" ), Prj().GetProjectName()
944 + wxT( "." )
946 }
947 else if( fpid.IsValid() )
948 {
949 try
950 {
952 }
953 catch( const IO_ERROR& )
954 {
955 // best efforts...
956 }
957
958 // Note: don't used GetLoadedFPID(); footprint name may have been edited
959 if( IsContentModified() )
960 title = wxT( "*" );
961
962 title += From_UTF8( footprint->GetFPID().Format().c_str() );
963
964 if( !writable )
965 title += wxS( " " ) + _( "[Read Only]" );
966 }
967 else if( !fpid.GetLibItemName().empty() )
968 {
969 // Note: don't used GetLoadedFPID(); footprint name may have been edited
970 if( IsContentModified() )
971 title = wxT( "*" );
972
973 title += From_UTF8( footprint->GetFPID().GetLibItemName().c_str() );
974 title += wxS( " " ) + _( "[Unsaved]" );
975 }
976 else
977 {
978 title = _( "[no footprint loaded]" );
979 }
980
981 title += wxT( " \u2014 " ) + _( "Footprint Editor" );
982
983 SetTitle( title );
984}
985
986
988{
990}
991
992
994{
998 UpdateTitle();
999}
1000
1001
1003{
1005
1006 WX_PROGRESS_REPORTER progressReporter( this, _( "Loading Footprint Libraries" ), 2 );
1007
1008 if( GFootprintList.GetCount() == 0 )
1009 GFootprintList.ReadCacheFromFile( Prj().GetProjectPath() + wxT( "fp-info-cache" ) );
1010
1011 GFootprintList.ReadFootprintFiles( fpTable, nullptr, &progressReporter );
1012 progressReporter.Show( false );
1013
1016
1018 auto adapter = static_cast<FP_TREE_SYNCHRONIZING_ADAPTER*>( m_adapter.get() );
1019
1020 adapter->AddLibraries( this );
1021}
1022
1023
1025{
1027 auto adapter = static_cast<FP_TREE_SYNCHRONIZING_ADAPTER*>( m_adapter.get() );
1028 LIB_ID target = GetTargetFPID();
1029 bool targetSelected = ( target == m_treePane->GetLibTree()->GetSelectedLibId() );
1030
1031 // Sync FOOTPRINT_INFO list to the libraries on disk
1032 if( aProgress )
1033 {
1034 WX_PROGRESS_REPORTER progressReporter( this, _( "Updating Footprint Libraries" ), 2 );
1035 GFootprintList.ReadFootprintFiles( fpTable, nullptr, &progressReporter );
1036 progressReporter.Show( false );
1037 }
1038 else
1039 {
1040 GFootprintList.ReadFootprintFiles( fpTable, nullptr, nullptr );
1041 }
1042
1043 // Sync the LIB_TREE to the FOOTPRINT_INFO list
1044 adapter->Sync( fpTable );
1045
1047 m_treePane->GetLibTree()->Regenerate( true );
1048
1049 if( target.IsValid() )
1050 {
1051 if( adapter->FindItem( target ) )
1052 {
1053 if( targetSelected )
1054 m_treePane->GetLibTree()->SelectLibId( target );
1055 else
1056 m_treePane->GetLibTree()->CenterLibId( target );
1057 }
1058 else
1059 {
1060 // Try to focus on parent
1061 target.SetLibItemName( wxEmptyString );
1062 m_treePane->GetLibTree()->CenterLibId( target );
1063 }
1064 }
1065}
1066
1067
1069{
1070 LIB_ID target = GetTargetFPID();
1071
1072 m_treePane->GetLibTree()->Regenerate( true );
1073
1074 if( target.IsValid() )
1075 m_treePane->GetLibTree()->CenterLibId( target );
1076}
1077
1078
1080{
1082}
1083
1084
1086{
1087 m_treePane->GetLibTree()->SelectLibId( aLibID );
1088}
1089
1090
1092{
1094}
1095
1096
1098{
1099 // Create the manager and dispatcher & route draw panel events to the dispatcher
1102 GetCanvas()->GetViewControls(), config(), this );
1103 m_actions = new PCB_ACTIONS();
1105
1107
1116 m_toolManager->RegisterTool( new PCB_CONTROL ); // copy/paste
1126
1127 for( TOOL_BASE* tool : m_toolManager->Tools() )
1128 {
1129 if( PCB_TOOL_BASE* pcbTool = dynamic_cast<PCB_TOOL_BASE*>( tool ) )
1130 pcbTool->SetIsFootprintEditor( true );
1131 }
1132
1133 m_toolManager->GetTool<PCB_VIEWER_TOOLS>()->SetFootprintFrame( true );
1135
1136 m_toolManager->InvokeTool( "pcbnew.InteractiveSelection" );
1137
1138 // Load or reload wizard plugins in case they changed since the last time the frame opened
1139 // Because the board editor has also a plugin python menu,
1140 // call the PCB_EDIT_FRAME RunAction() if the board editor is running
1141 // Otherwise run the current RunAction().
1142 PCB_EDIT_FRAME* pcbframe = static_cast<PCB_EDIT_FRAME*>( Kiway().Player( FRAME_PCB_EDITOR, false ) );
1143
1144 if( pcbframe )
1146 else
1148}
1149
1150
1152{
1154
1156 PCB_EDITOR_CONDITIONS cond( this );
1157
1158 wxASSERT( mgr );
1159
1160#define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
1161#define CHECK( x ) ACTION_CONDITIONS().Check( x )
1162
1163 auto haveFootprintCond =
1164 [this]( const SELECTION& )
1165 {
1166 return GetBoard() && GetBoard()->GetFirstFootprint() != nullptr;
1167 };
1168
1169 auto footprintTargettedCond =
1170 [this]( const SELECTION& )
1171 {
1172 return !GetTargetFPID().GetLibItemName().empty();
1173 };
1174
1175 mgr->SetConditions( ACTIONS::saveAs, ENABLE( footprintTargettedCond ) );
1178
1181
1185 mgr->SetConditions( ACTIONS::millimetersUnits, CHECK( cond.Units( EDA_UNITS::MILLIMETRES ) ) );
1186 mgr->SetConditions( ACTIONS::inchesUnits, CHECK( cond.Units( EDA_UNITS::INCHES ) ) );
1187 mgr->SetConditions( ACTIONS::milsUnits, CHECK( cond.Units( EDA_UNITS::MILS ) ) );
1188
1189 mgr->SetConditions( ACTIONS::cut, ENABLE( cond.HasItems() ) );
1190 mgr->SetConditions( ACTIONS::copy, ENABLE( cond.HasItems() ) );
1197
1204
1208
1211
1212 auto constrainedDrawingModeCond =
1213 [this]( const SELECTION& )
1214 {
1215 return GetSettings()->m_Use45Limit;
1216 };
1217
1218 auto highContrastCond =
1219 [this]( const SELECTION& )
1220 {
1221 return GetDisplayOptions().m_ContrastModeDisplay != HIGH_CONTRAST_MODE::NORMAL;
1222 };
1223
1224 auto boardFlippedCond =
1225 [this]( const SELECTION& )
1226 {
1227 return GetCanvas() && GetCanvas()->GetView()->IsMirroredX();
1228 };
1229
1230 auto footprintTreeCond =
1231 [this](const SELECTION& )
1232 {
1233 return IsSearchTreeShown();
1234 };
1235
1236 auto layerManagerCond =
1237 [this]( const SELECTION& )
1238 {
1239 return m_auimgr.GetPane( "LayersManager" ).IsShown();
1240 };
1241
1242 auto propertiesCond =
1243 [this] ( const SELECTION& )
1244 {
1245 return m_auimgr.GetPane( PropertiesPaneName() ).IsShown();
1246 };
1247
1248 mgr->SetConditions( PCB_ACTIONS::toggleHV45Mode, CHECK( constrainedDrawingModeCond ) );
1249 mgr->SetConditions( ACTIONS::highContrastMode, CHECK( highContrastCond ) );
1250 mgr->SetConditions( PCB_ACTIONS::flipBoard, CHECK( boardFlippedCond ) );
1252
1253 mgr->SetConditions( PCB_ACTIONS::showFootprintTree, CHECK( footprintTreeCond ) );
1254 mgr->SetConditions( PCB_ACTIONS::showLayersManager, CHECK( layerManagerCond ) );
1255 mgr->SetConditions( PCB_ACTIONS::showProperties, CHECK( propertiesCond ) );
1256
1257 mgr->SetConditions( ACTIONS::print, ENABLE( haveFootprintCond ) );
1258 mgr->SetConditions( PCB_ACTIONS::exportFootprint, ENABLE( haveFootprintCond ) );
1259 mgr->SetConditions( PCB_ACTIONS::placeImportedGraphics, ENABLE( haveFootprintCond ) );
1260
1261 mgr->SetConditions( PCB_ACTIONS::footprintProperties, ENABLE( haveFootprintCond ) );
1262 mgr->SetConditions( PCB_ACTIONS::editTextAndGraphics, ENABLE( haveFootprintCond ) );
1263 mgr->SetConditions( PCB_ACTIONS::checkFootprint, ENABLE( haveFootprintCond ) );
1264 mgr->SetConditions( PCB_ACTIONS::repairFootprint, ENABLE( haveFootprintCond ) );
1265 mgr->SetConditions( PCB_ACTIONS::cleanupGraphics, ENABLE( haveFootprintCond ) );
1266
1267 auto isArcKeepCenterMode =
1268 [this]( const SELECTION& )
1269 {
1270 return GetSettings()->m_ArcEditMode == ARC_EDIT_MODE::KEEP_CENTER_ADJUST_ANGLE_RADIUS;
1271 };
1272
1273 auto isArcKeepEndpointMode =
1274 [this]( const SELECTION& )
1275 {
1276 return GetSettings()->m_ArcEditMode == ARC_EDIT_MODE::KEEP_ENDPOINTS_OR_START_DIRECTION;
1277 };
1278
1279 mgr->SetConditions( PCB_ACTIONS::pointEditorArcKeepCenter, CHECK( isArcKeepCenterMode ) );
1280 mgr->SetConditions( PCB_ACTIONS::pointEditorArcKeepEndpoint, CHECK( isArcKeepEndpointMode ) );
1281
1282
1283// Only enable a tool if the part is edtable
1284#define CURRENT_EDIT_TOOL( action ) \
1285 mgr->SetConditions( action, ACTION_CONDITIONS().Enable( haveFootprintCond ) \
1286 .Check( cond.CurrentTool( action ) ) )
1287
1307
1308#undef CURRENT_EDIT_TOOL
1309#undef ENABLE
1310#undef CHECK
1311}
1312
1313
1315{
1317
1318 // Be sure the axis are enabled
1319 GetCanvas()->GetGAL()->SetAxesEnabled( true );
1320
1321 UpdateView();
1322
1323 // Ensure the m_Layers settings are using the canvas type:
1325}
1326
1327
1328void FOOTPRINT_EDIT_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
1329{
1330 PCB_BASE_EDIT_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
1331
1332 auto cfg = Pgm().GetSettingsManager().GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>();
1333 GetGalDisplayOptions().ReadWindowSettings( cfg->m_Window );
1334
1335 GetBoard()->GetDesignSettings() = cfg->m_DesignSettings;
1336
1340
1342
1343 if( aEnvVarsChanged )
1344 SyncLibraryTree( true );
1345
1346 Layout();
1347 SendSizeEvent();
1348}
1349
1350
1352{
1353 LIB_ID id = GetLoadedFPID();
1354
1355 if( id.empty() )
1356 {
1357 DisplayErrorMessage( this, _( "No footprint selected." ) );
1358 return;
1359 }
1360
1361 wxFileName fn( id.GetLibItemName() );
1362 fn.SetExt( wxT( "png" ) );
1363
1364 wxString projectPath = wxPathOnly( Prj().GetProjectFullName() );
1365
1366 wxFileDialog dlg( this, _( "Export View as PNG" ), projectPath,
1367 fn.GetFullName(), PngFileWildcard(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
1368
1369 if( dlg.ShowModal() == wxID_CANCEL || dlg.GetPath().IsEmpty() )
1370 return;
1371
1372 // calling wxYield is mandatory under Linux, after closing the file selector dialog
1373 // to refresh the screen before creating the PNG or JPEG image from screen
1374 wxYield();
1375 this->SaveCanvasImageToFile( dlg.GetPath(), BITMAP_TYPE::PNG );
1376}
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:104
@ icon_modedit_32
@ icon_modedit
@ icon_modedit_16
static TOOL_ACTION toggleGrid
Definition: actions.h:148
static TOOL_ACTION paste
Definition: actions.h:69
static TOOL_ACTION millimetersUnits
Definition: actions.h:156
static TOOL_ACTION unselectAll
Definition: actions.h:72
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:155
static TOOL_ACTION toggleBoundingBoxes
Definition: actions.h:111
static TOOL_ACTION undo
Definition: actions.h:65
static TOOL_ACTION duplicate
Definition: actions.h:73
static TOOL_ACTION inchesUnits
Definition: actions.h:154
static TOOL_ACTION highContrastMode
Definition: actions.h:109
static TOOL_ACTION toggleCursorStyle
Definition: actions.h:108
static TOOL_ACTION measureTool
Definition: actions.h:164
static TOOL_ACTION doDelete
Definition: actions.h:74
static TOOL_ACTION selectionTool
Definition: actions.h:163
static TOOL_ACTION save
Definition: actions.h:51
static TOOL_ACTION zoomFitScreen
Definition: actions.h:100
static TOOL_ACTION redo
Definition: actions.h:66
static TOOL_ACTION deleteTool
Definition: actions.h:75
static TOOL_ACTION zoomTool
Definition: actions.h:103
static TOOL_ACTION print
Definition: actions.h:57
static TOOL_ACTION showProperties
Definition: actions.h:177
static TOOL_ACTION cut
Definition: actions.h:67
static TOOL_ACTION gridSetOrigin
Definition: actions.h:145
static TOOL_ACTION ddAddLibrary
Definition: actions.h:60
static TOOL_ACTION toggleGridOverrides
Definition: actions.h:149
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:92
wxString m_ColorTheme
Active color theme name.
Definition: app_settings.h:172
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:77
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:276
void SetBoardUse(BOARD_USE aUse)
Set what the board is going to be used for.
Definition: board.h:288
void SetEnabledLayers(LSET aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings.
Definition: board.cpp:669
bool SetLayerName(PCB_LAYER_ID aLayer, const wxString &aLayerName)
Changes the name of the layer given by aLayer.
Definition: board.cpp:552
FOOTPRINT * GetFirstFootprint() const
Get the first footprint on the board or nullptr.
Definition: board.h:414
FOOTPRINTS & Footprints()
Definition: board.h:318
void SetVisibleAlls()
Change the bit-mask of visible element categories and layers.
Definition: board.cpp:698
void SetVisibleLayers(LSET aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings changes the bit-mask of vis...
Definition: board.cpp:681
void SetCopperLayerCount(int aCount)
Definition: board.cpp:631
void DeleteAllFootprints()
Remove all footprints from the deque and free the memory associated with them.
Definition: board.cpp:1130
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:766
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
Definition: box2.h:507
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:55
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()
EDA_DRAW_PANEL_GAL::GAL_TYPE m_canvasType
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.
bool SaveCanvasImageToFile(const wxString &aFileName, BITMAP_TYPE aBitmapType)
Save the current view as an image file.
virtual void SwitchCanvas(EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType)
Changes the current rendering backend.
EDA_DRAW_PANEL_GAL::GAL_TYPE loadCanvasTypeSetting(APP_SETTINGS_BASE *aCfg=nullptr)
Returns the canvas type stored in the application settings.
virtual void OnSelectZoom(wxCommandEvent &event)
Set the zoom factor when selected by the zoom list box in the main tool bar.
GAL_DISPLAY_OPTIONS_IMPL & GetGalDisplayOptions()
Return a reference to the gal rendering options used by GAL for rendering.
static bool m_openGLFailureOccured
Has any failure occured when switching to OpenGL in any EDA_DRAW_FRAME?
static const wxString PropertiesPaneName()
virtual void UpdateMsgPanel()
Redraw the message panel.
PROPERTIES_PANEL * m_propertiesPanel
static constexpr GAL_TYPE GAL_FALLBACK
void StopDrawing()
Prevent the GAL canvas from further drawing until it is recreated or StartDrawing() is called.
void ForceRefresh()
Force a redraw.
@ GAL_TYPE_OPENGL
OpenGL implementation.
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.
virtual 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 GridOverrides()
Create a functor testing if the grid overrides wires is enabled in a frame.
SELECTION_CONDITION FullscreenCursor()
Create a functor testing if the cursor is full screen in a frame.
The interactive edit tool.
Definition: edit_tool.h:55
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 resolveCanvasType() override
Determines the Canvas type to load (with prompt if required) and initializes m_canvasType.
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.
bool Clear_Pcb(bool doAskAboutUnsavedChanges)
Delete all and reinitialize the current board.
Definition: initpcb.cpp:103
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
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
void ReloadFootprint(FOOTPRINT *aFootprint) override
Override from PCB_BASE_FRAME which reloads the footprint from the library without setting the footpri...
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:391
ZONES & Zones()
Definition: footprint.h:194
EDA_ITEM * Clone() const override
Invoke a function on all children.
Definition: footprint.cpp:1695
PADS & Pads()
Definition: footprint.h:188
const LIB_ID & GetFPID() const
Definition: footprint.h:230
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:1259
KIID GetLink() const
Definition: footprint.h:797
const wxString & GetReference() const
Definition: footprint.h:556
DRAWINGS & GraphicalItems()
Definition: footprint.h:191
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: footprint.cpp:981
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)
void ReadWindowSettings(WINDOW_SETTINGS &aCfg)
Read GAL config options from application-level config.
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:77
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:757
bool IsMirroredX() const
Return true if view is flipped across the X axis.
Definition: view.h:245
void MarkTargetDirty(int aTarget)
Set or clear target 'dirty' flag.
Definition: view.h:619
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition: kiway.h:279
void OnKiCadExit()
Definition: kiway.cpp:737
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:110
bool IsValid() const
Check if this LID_ID is valid.
Definition: lib_id.h:172
UTF8 Format() const
Definition: lib_id.cpp:118
const wxString GetUniStringLibItemName() const
Get strings for display messages in dialogs.
Definition: lib_id.h:112
int SetLibNickname(const UTF8 &aNickname)
Override the logical library name portion of the LIB_ID to aNickname.
Definition: lib_id.cpp:99
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:396
LIB_TREE_NODE * GetCurrentTreeNode() const
Definition: lib_tree.cpp:302
void CenterLibId(const LIB_ID &aLibId)
Ensure that an item is visible (preferably centered).
Definition: lib_tree.cpp:319
void ShowChangedLanguage()
Definition: lib_tree.cpp:261
void SelectLibId(const LIB_ID &aLibId)
Select an item in the tree widget.
Definition: lib_tree.cpp:313
LIB_TREE_MODEL_ADAPTER::SORT_MODE GetSortMode() const
Definition: lib_tree.h:137
void Unselect()
Unselect currently selected item in wxDataViewCtrl.
Definition: lib_tree.cpp:325
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:271
void Regenerate(bool aKeepState)
Regenerate the tree.
Definition: lib_tree.cpp:378
void SetSortMode(LIB_TREE_MODEL_ADAPTER::SORT_MODE aMode)
Save/restore the sorting mode.
Definition: lib_tree.h:136
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:58
static const wxChar A4[]
Definition: page_info.h:67
void SetCheckboxesFromFilter(SELECTION_FILTER_OPTIONS &aOptions)
Gather all the actions that are shared by tools.
Definition: pcb_actions.h:50
static TOOL_ACTION toggleHV45Mode
Definition: pcb_actions.h:513
static TOOL_ACTION drawRuleArea
Definition: pcb_actions.h:214
static TOOL_ACTION placeText
Definition: pcb_actions.h:201
static TOOL_ACTION pointEditorArcKeepCenter
Definition: pcb_actions.h:288
static TOOL_ACTION drawOrthogonalDimension
Definition: pcb_actions.h:210
static TOOL_ACTION drawRectangle
Definition: pcb_actions.h:197
static TOOL_ACTION setAnchor
Definition: pcb_actions.h:221
static TOOL_ACTION padDisplayMode
Definition: pcb_actions.h:323
static TOOL_ACTION placeReferenceImage
Definition: pcb_actions.h:200
static TOOL_ACTION showLayersManager
Definition: pcb_actions.h:437
static TOOL_ACTION drawCircle
Definition: pcb_actions.h:198
static TOOL_ACTION mirrorH
Mirroring of selected items.
Definition: pcb_actions.h:139
static TOOL_ACTION exportFootprint
Definition: pcb_actions.h:465
static TOOL_ACTION showFootprintTree
Definition: pcb_actions.h:442
static TOOL_ACTION drawTextBox
Definition: pcb_actions.h:202
static TOOL_ACTION drawPolygon
Definition: pcb_actions.h:196
static TOOL_ACTION placePad
Activation of the drawing tool (placing a PAD)
Definition: pcb_actions.h:473
static TOOL_ACTION group
Definition: pcb_actions.h:521
static TOOL_ACTION drawRadialDimension
Definition: pcb_actions.h:209
static TOOL_ACTION editTextAndGraphics
Definition: pcb_actions.h:406
static TOOL_ACTION drawLeader
Definition: pcb_actions.h:211
static TOOL_ACTION ddImportFootprint
Definition: pcb_actions.h:579
static TOOL_ACTION ungroup
Definition: pcb_actions.h:522
static TOOL_ACTION placeImportedGraphics
Definition: pcb_actions.h:220
static TOOL_ACTION drawArc
Definition: pcb_actions.h:199
static TOOL_ACTION graphicsOutlines
Display footprint graphics as outlines.
Definition: pcb_actions.h:485
static TOOL_ACTION pluginsReload
Scripting Actions.
Definition: pcb_actions.h:400
static TOOL_ACTION pointEditorArcKeepEndpoint
Definition: pcb_actions.h:289
static TOOL_ACTION drawCenterDimension
Definition: pcb_actions.h:208
static TOOL_ACTION footprintProperties
Definition: pcb_actions.h:467
static TOOL_ACTION flipBoard
Definition: pcb_actions.h:376
static TOOL_ACTION textOutlines
Display texts as lines.
Definition: pcb_actions.h:488
static TOOL_ACTION checkFootprint
Definition: pcb_actions.h:470
static TOOL_ACTION mirrorV
Definition: pcb_actions.h:140
static TOOL_ACTION repairFootprint
Definition: pcb_actions.h:539
static TOOL_ACTION drawLine
Definition: pcb_actions.h:195
static TOOL_ACTION cleanupGraphics
Definition: pcb_actions.h:410
static TOOL_ACTION rotateCw
Rotation of selected objects.
Definition: pcb_actions.h:132
static TOOL_ACTION rotateCcw
Definition: pcb_actions.h:133
static TOOL_ACTION drawAlignedDimension
Definition: pcb_actions.h:207
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 setFPWatcher(FOOTPRINT *aFootprint)
Creates (or removes) a watcher on the specified footprint.
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.
static FP_LIB_TABLE * PcbFootprintLibs(PROJECT *aProject)
Return the table of footprint libraries without Kiway.
Definition: project_pcb.cpp:37
@ PCB_FOOTPRINT_EDITOR_FP_NAME
Definition: project.h:192
@ PCB_FOOTPRINT_EDITOR_LIB_NICKNAME
Definition: project.h:193
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:277
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:288
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:165
TOOL_DISPATCHER * m_toolDispatcher
Definition: tools_holder.h:167
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:55
ACTIONS * m_actions
Definition: tools_holder.h:166
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:57
bool RunAction(const std::string &aActionName, T aParam)
Run the specified action immediately, pausing the current action to run the new one.
Definition: tool_manager.h:145
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:289
void ResetTools(TOOL_BASE::RESET_REASON aReason)
Reset all tools (i.e.
std::vector< TOOL_BASE * > Tools()
Definition: tool_manager.h:324
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
A modified version of the wxInfoBar class that allows us to:
Definition: wx_infobar.h:75
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
Multi-thread safe progress reporter dialog, intended for use of tasks that parallel reporting back of...
bool HandleUnsavedChanges(wxWindow *aParent, const wxString &aMessage, const std::function< bool()> &aSaveFunction)
Display a dialog with Save, Cancel and Discard Changes buttons.
Definition: confirm.cpp:240
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:305
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:439
#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:42
@ FRAME_FOOTPRINT_EDITOR
Definition: frame_type.h:43
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
PROJECT & Prj()
Definition: kicad.cpp:576
KIID niluuid(0)
KIWAY Kiway
@ F_SilkS
Definition: layer_ids.h:105
@ In1_Cu
Definition: layer_ids.h:66
This file contains miscellaneous commonly used macros and functions.
@ 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:90
bool SupportsShutdownBlockReason()
Whether or not the window supports setting a shutdown block reason.
Definition: gtk/app.cpp:79
@ 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:119
wxString From_UTF8(const char *cstring)
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:108
@ PCB_TEXTBOX_T
class PCB_TEXTBOX, wrapped text on a layer
Definition: typeinfo.h:93
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
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.