KiCad PCB EDA Suite
footprint_edit_frame.h
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) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
5  *
6  * This program is free software: you can redistribute it and/or modify it
7  * under the terms of the GNU General Public License as published by the
8  * Free Software Foundation, either version 3 of the License, or (at your
9  * option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef FOOTPRINT_EDIT_FRAME_H
21 #define FOOTPRINT_EDIT_FRAME_H
22 
23 #include <pcb_base_frame.h>
24 #include <pcb_base_edit_frame.h>
25 #include <io_mgr.h>
26 #include <config_params.h>
28 
30 class FP_LIB_TABLE;
34 
35 namespace PCB { struct IFACE; } // A KIFACE_I coded in pcbnew.c
36 
37 
39 {
40 public:
42 
47  static const wxChar* GetFootprintEditorFrameName();
48 
50  BOARD_ITEM_CONTAINER* GetModel() const override;
51  SELECTION& GetCurrentSelection() override;
52 
58  bool IsContentModified() const override;
59 
60  bool IsCurrentFPFromBoard() const;
61 
63 
64  APP_SETTINGS_BASE* config() const override;
65 
66  BOARD_DESIGN_SETTINGS& GetDesignSettings() const override;
67 
68  const PCB_PLOT_PARAMS& GetPlotSettings() const override;
69  void SetPlotSettings( const PCB_PLOT_PARAMS& aSettings ) override;
70 
72 
73  void LoadSettings( APP_SETTINGS_BASE* aCfg ) override;
74  void SaveSettings( APP_SETTINGS_BASE* aCfg ) override;
75 
76  COLOR_SETTINGS* GetColorSettings() const override;
77 
78  const BOX2I GetDocumentExtents( bool aIncludeAllVisible = true ) const override;
79 
80  bool canCloseWindow( wxCloseEvent& Event ) override;
81  void doCloseWindow() override;
82  void CloseFootprintEditor( wxCommandEvent& Event );
83  void OnExitKiCad( wxCommandEvent& aEvent );
84 
90  void SwitchCanvas( EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType ) override;
91 
96  void UpdateUserInterface();
97 
101  void HardRedraw() override;
102 
106  void ReCreateHToolbar() override;
107 
108  void ReCreateVToolbar() override;
109  void ReCreateOptToolbar() override;
110  void UpdateToolbarControlSizes() override;
111 
115  void ReCreateMenuBar() override;
116 
125  void ReCreateLayerBox( bool aForceResizeToolbar = true );
126 
127  void OnUpdateLayerSelectBox( wxUpdateUIEvent& aEvent );
128 
129  void SelectLayer( wxCommandEvent& event );
130 
131  // The Tool Framework initialization, for GAL mode
132  void setupTools();
133 
134  void OnSaveFootprintAsPng( wxCommandEvent& event );
135 
136  bool IsSearchTreeShown();
137  void ToggleSearchTree();
138 
146  bool SaveLibraryAs( const wxString& aLibraryPath );
147 
148  void OnUpdateLoadFootprintFromBoard( wxUpdateUIEvent& aEvent );
149  void OnUpdateSaveFootprintToBoard( wxUpdateUIEvent& aEvent );
150 
152  void OnEditItemRequest( BOARD_ITEM* aItem ) override;
153 
157  void LoadFootprintFromBoard( wxCommandEvent& event );
158 
159  void SaveFootprintToBoard( wxCommandEvent& event );
160 
161  void LoadFootprintFromLibrary( LIB_ID aFPID );
162 
166  wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER>& GetLibTreeAdapter() { return m_adapter; }
167 
174  bool SaveFootprint( FOOTPRINT* aFootprint );
175  bool SaveFootprintAs( FOOTPRINT* aFootprint );
176  bool SaveFootprintToBoard( bool aAddNew );
177  bool SaveFootprintInLibrary( FOOTPRINT* aFootprint, const wxString& aLibraryName );
178  bool RevertFootprint();
179 
186  void OnModify() override;
187 
193  bool Clear_Pcb( bool aQuery );
194 
196  LIB_ID GetTreeFPID() const;
197 
199 
201  LIB_ID GetLoadedFPID() const;
202 
205  LIB_ID GetTargetFPID() const;
206 
207  void ClearModify();
208 
212  void ExportFootprint( FOOTPRINT* aFootprint );
213 
220  FOOTPRINT* ImportFootprint( const wxString& aName = wxT( "" ) );
221 
229  bool LoadFootprintFromBoard( FOOTPRINT* aFootprint );
230 
237 
241  bool DeleteFootprintFromLibrary( const LIB_ID& aFPID, bool aConfirm );
242 
246  COLOR4D GetGridColor() override;
247 
249  void SetActiveLayer( PCB_LAYER_ID aLayer ) override;
250 
251  void OnDisplayOptionsChanged() override;
252 
254  void ActivateGalCanvas() override;
255 
265  bool OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl = 0 ) override;
266 
271  void AddFootprintToBoard( FOOTPRINT* aFootprint ) override;
272 
276  void InstallPreferences( PAGED_DIALOG* aParent, PANEL_HOTKEYS_EDITOR* aHotkeysPanel ) override;
277 
281  void ShowChangedLanguage() override;
282 
286  void CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged ) override;
287 
292  void SyncLibraryTree( bool aProgress );
293 
298  void RegenerateLibraryTree();
299 
303  void RefreshLibraryTree();
304 
306  void UpdateView();
307 
308  void UpdateTitle();
309 
310  void FocusOnLibID( const LIB_ID& aLibID );
311 
312  void KiwayMailIn( KIWAY_EXPRESS& mail ) override;
313 
314  DECLARE_EVENT_TABLE()
315 
316 protected:
318  FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent, EDA_DRAW_PANEL_GAL::GAL_TYPE aBackend );
319 
320  PCB_LAYER_BOX_SELECTOR* m_selLayerBox; // a combo box to display and select active layer
321 
323 
328  void initLibraryTree();
329 
330  void restoreLastFootprint();
331  void retainLastFootprint();
332 
336  void editFootprintProperties( FOOTPRINT* aFootprint );
337 
338  void setupUIConditions() override;
339 
340 private:
341  friend struct PCB::IFACE;
342 
344 
346 
350 };
351 
352 #endif // FOOTPRINT_EDIT_FRAME_H
std::map< KIID, KIID > m_boardFootprintUuids
Carry a payload from one KIWAY_PLAYER to another within a PROJECT.
Definition: kiway_express.h:38
void OnEditItemRequest(BOARD_ITEM *aItem) override
Install the corresponding dialog editor for the given item.
void LoadFootprintFromLibrary(LIB_ID aFPID)
wxObjectDataPtr< LIB_TREE_MODEL_ADAPTER > & GetLibTreeAdapter()
Return the adapter object that provides the stored data.
void SelectLayer(wxCommandEvent &event)
void OnExitKiCad(wxCommandEvent &aEvent)
void ReCreateHToolbar() override
Create the main horizontal toolbar for the footprint editor.
void editFootprintProperties(FOOTPRINT *aFootprint)
Run the Footprint Properties dialog and handle changes made in it.
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 SetActiveLayer(PCB_LAYER_ID aLayer) override
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Called after the preferences dialog is run.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:80
COLOR4D GetGridColor() override
void initLibraryTree()
Make sure the footprint info list is loaded (with a progress dialog) and then initialize the footprin...
bool OpenProjectFiles(const std::vector< wxString > &aFileSet, int aCtl=0) override
Load a KiCad board (.kicad_pcb) from aFileName.
void ActivateGalCanvas() override
Use to start up the GAL drawing canvas.
Definition: bitmap.cpp:64
void UpdateUserInterface()
Update the layer manager and other widgets from the board setup (layer and items visibility,...
void SaveFootprintToBoard(wxCommandEvent &event)
Class to display a pcb layer list in a wxBitmapComboBox.
bool DeleteFootprintFromLibrary(const LIB_ID &aFPID, bool aConfirm)
Delete the given footprint from its library.
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
SELECTION & GetCurrentSelection() override
Get the current selection from the canvas area.
FOOTPRINT * SelectFootprintFromBoard(BOARD *aPcb)
Display the list of footprints currently existing on the BOARD.
void OnDisplayOptionsChanged() override
Classes used in Pcbnew, CvPcb and GerbView.
const BOX2I GetDocumentExtents(bool aIncludeAllVisible=true) const override
Returns bbox of document with option to not include some items.
void ReCreateMenuBar() override
(Re)Create the menubar for the Footprint Editor frame
void ExportFootprint(FOOTPRINT *aFootprint)
Create a file containing only one footprint.
void SyncLibraryTree(bool aProgress)
Synchronize the footprint library tree to the current state of the footprint library table.
Definition: kiid.h:44
void RegenerateLibraryTree()
Filter, sort, and redisplay the library tree.
PCB_LAYER_ID
A quick note on layer IDs:
bool Clear_Pcb(bool aQuery)
Delete all and reinitialize the current board.
Definition: initpcb.cpp:97
void HardRedraw() override
Refresh the library tree and redraw the window.
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:99
bool SaveLibraryAs(const wxString &aLibraryPath)
Save a library to a new name and/or library type.
void OnModify() override
Must be called after a footprint change in order to set the "modify" flag of the current screen and p...
void OnUpdateSaveFootprintToBoard(wxUpdateUIEvent &aEvent)
Install the corresponding dialog editor for the given item.
void FocusOnLibID(const LIB_ID &aLibID)
Class to handle modifications to the symbol libraries.
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...
bool SaveFootprintInLibrary(FOOTPRINT *aFootprint, const wxString &aLibraryName)
wxObjectDataPtr< LIB_TREE_MODEL_ADAPTER > m_adapter
FOOTPRINT_EDITOR_SETTINGS * m_settings
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition: kiway.h:258
void UpdateToolbarControlSizes() override
Update the sizes of any controls in the toolbars of the frame.
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
Footprint Editor pane with footprint library tree.
Model class in the component selector Model-View-Adapter (mediated MVC) architecture.
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
Parameters and options when plotting/printing a board.
std::unique_ptr< FOOTPRINT > m_revertModule
COLOR_SETTINGS * GetColorSettings() const override
Helper to retrieve the current color settings.
PCB_LAYER_BOX_SELECTOR * m_selLayerBox
LIB_TREE_NODE * GetCurrentTreeNode() const
const PCB_PLOT_PARAMS & GetPlotSettings() const override
Return the PCB_PLOT_PARAMS for the BOARD owned by this frame.
void SwitchCanvas(EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType) override
Switch the currently used canvas (Cairo / OpenGL).
void InstallPreferences(PAGED_DIALOG *aParent, PANEL_HOTKEYS_EDITOR *aHotkeysPanel) override
Allow footprint editor to install its preferences panel into the preferences dialog.
void LoadFootprintFromBoard(wxCommandEvent &event)
Called from the main toolbar to load a footprint from board mainly to edit it.
void SetPlotSettings(const PCB_PLOT_PARAMS &aSettings) override
Common, abstract interface for edit frames.
void CloseFootprintEditor(wxCommandEvent &Event)
LIB_ID GetLoadedFPID() const
Return the LIB_ID of the part being edited.
bool canCloseWindow(wxCloseEvent &Event) override
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:190
BOARD_ITEM_CONTAINER * GetModel() const override
bool SaveFootprintAs(FOOTPRINT *aFootprint)
FOOTPRINT_TREE_PANE * m_treePane
MAGNETIC_SETTINGS * GetMagneticItemsSettings() override
void ShowChangedLanguage() override
Update visible items after a language change.
Color settings are a bit different than most of the settings objects in that there can be more than o...
void OnUpdateLoadFootprintFromBoard(wxUpdateUIEvent &aEvent)
FOOTPRINT_EDITOR_SETTINGS * GetSettings()
APP_SETTINGS_BASE * config() const override
Returns the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
void AddFootprintToBoard(FOOTPRINT *aFootprint) override
Override from PCB_BASE_EDIT_FRAME which adds a footprint to the editor's dummy board,...
void RefreshLibraryTree()
Redisplay the library tree.
Abstract interface for BOARD_ITEMs capable of storing other items inside.
bool IsContentModified() const override
Get if any footprints or libraries have been modified but not saved.
bool SaveFootprint(FOOTPRINT *aFootprint)
Save in an existing library a given footprint.
void OnUpdateLayerSelectBox(wxUpdateUIEvent &aEvent)
void KiwayMailIn(KIWAY_EXPRESS &mail) override
Receive KIWAY_EXPRESS messages from other players.
LIB_ID GetTreeFPID() const
Return the LIB_ID of the part or library selected in the footprint tree.
static const wxChar * GetFootprintEditorFrameName()
void ReCreateLayerBox(bool aForceResizeToolbar=true)
Re create the layer Box by clearing the old list, and building a new one from the new layers names an...
void OnSaveFootprintAsPng(wxCommandEvent &event)
FOOTPRINT * ImportFootprint(const wxString &aName=wxT(""))
Read a file containing only one footprint.
Container for design settings for a BOARD object.
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103