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-2019 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 class PCBNEW_SELECTION;
35 
36 namespace PCB { struct IFACE; } // A KIFACE_I coded in pcbnew.c
37 
38 
40 {
41  friend struct PCB::IFACE;
42 
44 
45  wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER> m_adapter;
46 
47  std::unique_ptr<FOOTPRINT> m_revertModule;
49 
51 
52 public:
53 
55 
61  static const wxChar* GetFootprintEditorFrameName();
62 
64  BOARD_ITEM_CONTAINER* GetModel() const override;
65  SELECTION& GetCurrentSelection() override;
66 
72  bool IsContentModified() override;
73 
74  bool IsCurrentFPFromBoard() const;
75 
77 
78  BOARD_DESIGN_SETTINGS& GetDesignSettings() const override;
79 
80  const PCB_PLOT_PARAMS& GetPlotSettings() const override;
81  void SetPlotSettings( const PCB_PLOT_PARAMS& aSettings ) override;
82 
84 
85  void LoadSettings( APP_SETTINGS_BASE* aCfg ) override;
86  void SaveSettings( APP_SETTINGS_BASE* aCfg ) override;
87 
88  COLOR_SETTINGS* GetColorSettings() override;
89 
90  const BOX2I GetDocumentExtents( bool aIncludeAllVisible = true ) const override;
91 
92  bool canCloseWindow( wxCloseEvent& Event ) override;
93  void doCloseWindow() override;
94  void CloseFootprintEditor( wxCommandEvent& Event );
95  void OnExitKiCad( wxCommandEvent& aEvent );
96 
101  void SwitchCanvas( EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType ) override;
102 
107  void UpdateUserInterface();
108 
112  void HardRedraw() override;
113 
117  void ReCreateHToolbar() override;
118 
119  void ReCreateVToolbar() override;
120  void ReCreateOptToolbar() override;
121 
125  void ReCreateMenuBar() override;
126 
134  void ReCreateLayerBox( bool aForceResizeToolbar = true );
135 
136  void OnUpdateLayerSelectBox( wxUpdateUIEvent& aEvent );
137 
138  void SelectLayer( wxCommandEvent& event );
139 
140  // The Tool Framework initalization, for GAL mode
141  void setupTools();
142 
143  void OnSaveFootprintAsPng( wxCommandEvent& event );
144 
145  bool IsSearchTreeShown();
146  void ToggleSearchTree();
147 
154  bool SaveLibraryAs( const wxString& aLibraryPath );
155 
156  void OnUpdateModuleSelected( wxUpdateUIEvent& aEvent );
157  void OnUpdateLoadFootprintFromBoard( wxUpdateUIEvent& aEvent );
158  void OnUpdateSaveFootprintToBoard( wxUpdateUIEvent& aEvent );
159 
161  void OnEditItemRequest( BOARD_ITEM* aItem ) override;
162 
166  void LoadFootprintFromBoard( wxCommandEvent& event );
167 
168  void SaveFootprintToBoard( wxCommandEvent& event );
169 
170  void LoadFootprintFromLibrary( LIB_ID aFPID );
171 
175  wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER>& GetLibTreeAdapter() { return m_adapter; }
176 
183  bool SaveFootprint( FOOTPRINT* aFootprint );
184  bool SaveFootprintAs( FOOTPRINT* aFootprint );
185  bool SaveFootprintToBoard( bool aAddNew );
186  bool SaveFootprintInLibrary( FOOTPRINT* aFootprint, const wxString& aLibraryName );
187  bool RevertFootprint();
188 
195  void OnModify() override;
196 
197  // BOARD handling
198 
204  bool Clear_Pcb( bool aQuery );
205 
207  LIB_ID GetTreeFPID() const;
208 
210 
212  LIB_ID GetLoadedFPID() const;
213 
216  LIB_ID GetTargetFPID() const;
217 
218  void ClearModify();
219 
220  // importing / exporting Footprint
224  void ExportFootprint( FOOTPRINT* aFootprint );
225 
232  FOOTPRINT* ImportFootprint( const wxString& aName = wxT( "") );
233 
241  bool LoadFootprintFromBoard( FOOTPRINT* aFootprint );
242 
249 
253  bool DeleteFootprintFromLibrary( const LIB_ID& aFPID, bool aConfirm );
254 
258  COLOR4D GetGridColor() override;
259 
261  void SetActiveLayer( PCB_LAYER_ID aLayer ) override;
262 
264  void OnUpdateLayerAlpha( wxUpdateUIEvent& aEvent ) override;
265 
267  void ActivateGalCanvas() override;
268 
278  bool OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl = 0 ) override;
279 
284  void AddFootprintToBoard( FOOTPRINT* aFootprint ) override;
285 
289  void InstallPreferences( PAGED_DIALOG* aParent, PANEL_HOTKEYS_EDITOR* aHotkeysPanel ) override;
290 
294  void ShowChangedLanguage() override;
295 
299  void CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged ) override;
300 
306  void SyncLibraryTree( bool aProgress );
307 
312  void RegenerateLibraryTree();
313 
314  void RefreshLibraryTree();
315 
317  void UpdateView();
318 
319  void FocusOnLibID( const LIB_ID& aLibID );
320 
321  void KiwayMailIn( KIWAY_EXPRESS& mail ) override;
322 
323  DECLARE_EVENT_TABLE()
324 
325 protected:
327  FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent, EDA_DRAW_PANEL_GAL::GAL_TYPE aBackend );
328 
329  PCB_LAYER_BOX_SELECTOR* m_selLayerBox; // a combo box to display and select active layer
330 
332 
337  void initLibraryTree();
338 
342  void updateTitle();
343 
344  void restoreLastFootprint();
345  void retainLastFootprint();
346 
350  void editFootprintProperties( FOOTPRINT* aFootprint );
351 
352  void setupUIConditions() override;
353 };
354 
355 #endif // FOOTPRINT_EDIT_FRAME_H
KIWAY_EXPRESS carries a payload from one KIWAY_PLAYER to another within a PROJECT.
Definition: kiway_express.h:39
void OnEditItemRequest(BOARD_ITEM *aItem) override
void LoadFootprintFromLibrary(LIB_ID aFPID)
wxObjectDataPtr< LIB_TREE_MODEL_ADAPTER > & GetLibTreeAdapter()
Returns 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.
void OnUpdateLayerAlpha(wxUpdateUIEvent &aEvent) override
BOARD_DESIGN_SETTINGS & GetDesignSettings() const override
Returns the BOARD_DESIGN_SETTINGS for the open project Overloaded in FOOTPRINT_EDIT_FRAME.
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.
BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
Definition: board_item.h:86
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 UpdateView()
Reloads displayed items and sets view.
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.
bool IsContentModified() override
Get if any footprints or libraries have been modified but not saved.
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.
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:94
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)
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
KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the s...
Definition: kiway.h:273
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Saves 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.
PCB_PLOT_PARAMS handles plot parameters and options when plotting/printing a board.
std::unique_ptr< FOOTPRINT > m_revertModule
PCB_LAYER_BOX_SELECTOR * m_selLayerBox
LIB_TREE_NODE * GetCurrentTreeNode() const
const PCB_PLOT_PARAMS & GetPlotSettings() const override
Function GetPlotSettings returns the PCB_PLOT_PARAMS for the BOARD owned by this frame.
void SwitchCanvas(EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType) override
switches currently used canvas (Cairo / OpenGL).
void InstallPreferences(PAGED_DIALOG *aParent, PANEL_HOTKEYS_EDITOR *aHotkeysPanel) override
Allows 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 updateTitle()
Updates window title according to getLibNickName().
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:186
COLOR_SETTINGS * GetColorSettings() override
Helper to retrieve the current color settings.
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()
void AddFootprintToBoard(FOOTPRINT *aFootprint) override
Override from PCB_BASE_EDIT_FRAME which adds a footprint to the editor's dummy board,...
Abstract interface for BOARD_ITEMs capable of storing other items inside.
void OnUpdateModuleSelected(wxUpdateUIEvent &aEvent)
bool SaveFootprint(FOOTPRINT *aFootprint)
Save in an existing library a given footprint.
void OnUpdateLayerSelectBox(wxUpdateUIEvent &aEvent)
void KiwayMailIn(KIWAY_EXPRESS &mail) override
Function KiwayMailIn receives 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()
Function GetFootprintEditorFrameName (static)
void ReCreateLayerBox(bool aForceResizeToolbar=true)
Re create the layer Box by clearing the old list, and building le new one, from the new layers names ...
void OnSaveFootprintAsPng(wxCommandEvent &event)
FOOTPRINT * ImportFootprint(const wxString &aName=wxT(""))
Read a file containing only one footprint.
BOARD_DESIGN_SETTINGS contains design settings for a BOARD object.
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:100