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;
31 class EDGE_MODULE;
33 class LIB_MANAGER;
35 
36 namespace PCB { struct IFACE; } // A KIFACE_I coded in pcbnew.c
37 
38 
40 {
41  friend struct PCB::IFACE;
42 
45 
46  std::unique_ptr<MODULE> m_revertModule;
48 
50 
51 public:
52 
54 
60  static const wxChar* GetFootprintEditorFrameName();
61 
63  BOARD_ITEM_CONTAINER* GetModel() const override;
64 
70  bool IsContentModified() override;
71 
72  bool IsCurrentFPFromBoard() const;
73 
75 
76  BOARD_DESIGN_SETTINGS& GetDesignSettings() const override;
77  void SetDesignSettings( const BOARD_DESIGN_SETTINGS& aSettings ) override;
78 
79  const PCB_PLOT_PARAMS& GetPlotSettings() const override;
80  void SetPlotSettings( const PCB_PLOT_PARAMS& aSettings ) override;
81 
82  void LoadSettings( APP_SETTINGS_BASE* aCfg ) override;
83  void SaveSettings( APP_SETTINGS_BASE* aCfg ) override;
84 
85  const BOX2I GetDocumentExtents() const override;
86 
87  void OnCloseWindow( wxCloseEvent& Event ) override;
88  void CloseModuleEditor( wxCommandEvent& Event );
89  void OnExitKiCad( wxCommandEvent& aEvent );
90 
95  void SwitchCanvas( EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType ) override;
96 
101  void UpdateUserInterface();
102 
103  void Process_Special_Functions( wxCommandEvent& event );
104 
108  void HardRedraw() override;
109 
113  void ReCreateHToolbar() override;
114 
115  void ReCreateVToolbar() override;
116  void ReCreateOptToolbar() override;
117 
121  void ReCreateMenuBar() override;
122 
130  void ReCreateLayerBox( bool aForceResizeToolbar = true );
131 
132  void OnUpdateLayerSelectBox( wxUpdateUIEvent& aEvent );
133 
134  // The Tool Framework initalization, for GAL mode
135  void setupTools();
136 
137  void OnSaveFootprintAsPng( wxCommandEvent& event );
138 
139  bool IsSearchTreeShown();
140  void ToggleSearchTree();
141 
148  bool SaveLibraryAs( const wxString& aLibraryPath );
149 
150  void OnUpdateModuleSelected( wxUpdateUIEvent& aEvent );
151  void OnUpdateLoadModuleFromBoard( wxUpdateUIEvent& aEvent );
152  void OnUpdateInsertModuleInBoard( wxUpdateUIEvent& aEvent );
153 
155  void OnEditItemRequest( BOARD_ITEM* aItem ) override;
156 
160  void LoadModuleFromBoard( wxCommandEvent& event );
161 
162  void LoadModuleFromLibrary( LIB_ID aFPID );
163 
168 
175  bool SaveFootprint( MODULE* aModule );
176  bool SaveFootprintAs( MODULE* aModule );
177  bool SaveFootprintToBoard( bool aAddNew );
178  bool SaveFootprintInLibrary( MODULE* aModule, const wxString& aLibraryName );
179  bool RevertFootprint();
180 
187  void OnModify() override;
188 
189  // BOARD handling
190 
196  bool Clear_Pcb( bool aQuery );
197 
199  LIB_ID GetTreeFPID() const;
200 
202 
204  LIB_ID GetLoadedFPID() const;
205 
208  LIB_ID GetTargetFPID() const;
209 
210  // importing / exporting Footprint
221  void Export_Module( MODULE* aModule );
222 
232  MODULE* Import_Module( const wxString& aName = wxT("") );
233 
240  bool Load_Module_From_BOARD( MODULE* Module );
241 
249 
250  // functions to edit footprint edges
251 
255  bool DeleteModuleFromLibrary( const LIB_ID& aFPID, bool aConfirm );
256 
264  bool IsElementVisible( GAL_LAYER_ID aElement ) const;
265 
273  void SetElementVisibility( GAL_LAYER_ID aElement, bool aNewState );
274 
278  COLOR4D GetGridColor() override;
279 
281  void SetActiveLayer( PCB_LAYER_ID aLayer ) override;
282 
284  void OnUpdateLayerAlpha( wxUpdateUIEvent& aEvent ) override;
285 
287  void ActivateGalCanvas() override;
288 
298  bool OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl = 0 ) override;
299 
304  void AddModuleToBoard( MODULE* module ) override;
305 
309  void InstallPreferences( PAGED_DIALOG* aParent, PANEL_HOTKEYS_EDITOR* aHotkeysPanel ) override;
310 
311  void ReFillLayerWidget();
312 
316  void ShowChangedLanguage() override;
317 
321  void CommonSettingsChanged( bool aEnvVarsChanged ) override;
322 
328  void SyncLibraryTree( bool aProgress );
329 
334  void RegenerateLibraryTree();
335 
336  void FocusOnLibID( const LIB_ID& aLibID );
337 
338  void KiwayMailIn( KIWAY_EXPRESS& mail ) override;
339 
340  void SyncToolbars() override;
341 
342  DECLARE_EVENT_TABLE()
343 
344 protected:
346  FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent, EDA_DRAW_PANEL_GAL::GAL_TYPE aBackend );
347 
348  PCB_LAYER_BOX_SELECTOR* m_selLayerBox; // a combo box to display and select active layer
349 
351 
356  void initLibraryTree();
357 
361  void updateTitle();
362 
364  void updateView();
365 
366  void restoreLastFootprint();
367  void retainLastFootprint();
368 
372  void editFootprintProperties( MODULE* aFootprint );
373 };
374 
375 #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
LIB_TREE_MODEL_ADAPTER::PTR & GetLibTreeAdapter()
Returns the adapter object that provides the stored data.
void OnExitKiCad(wxCommandEvent &aEvent)
void ReCreateHToolbar() override
Create the main horizontal toolbar for the footprint editor.
void OnUpdateLayerAlpha(wxUpdateUIEvent &aEvent) override
BOARD_DESIGN_SETTINGS & GetDesignSettings() const override
Function GetDesignSettings returns the BOARD_DESIGN_SETTINGS for the BOARD owned by this frame.
const BOX2I GetDocumentExtents() const override
void SetActiveLayer(PCB_LAYER_ID aLayer) override
bool SaveFootprintToBoard(bool aAddNew)
BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
void SyncToolbars() override
Update the toolbars (mostly settings/check buttons/checkboxes) with the current controller state.
COLOR4D GetGridColor() override
void CommonSettingsChanged(bool aEnvVarsChanged) override
Called after the preferences dialog is run.
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 LoadModuleFromLibrary(LIB_ID aFPID)
void OnCloseWindow(wxCloseEvent &Event) override
GAL_LAYER_ID
GAL layers are "virtual" layers, i.e.
void ActivateGalCanvas() override
void UpdateUserInterface()
Update the layer manager and other widgets from the board setup (layer and items visibility,...
Class to display a pcb layer list in a wxBitmapComboBox.
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
void OnUpdateLoadModuleFromBoard(wxUpdateUIEvent &aEvent)
bool DeleteModuleFromLibrary(const LIB_ID &aFPID, bool aConfirm)
Delete the given module from its library.
bool IsContentModified() override
Get if any footprints or libraries have been modified but not saved.
Classes used in Pcbnew, CvPcb and GerbView.
MODULE * SelectFootprintFromBoard(BOARD *aPcb)
Display the list of modules currently existing on the BOARD.
void ReCreateMenuBar() override
(Re)Create the menubar for the module editor frame
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.
std::unique_ptr< MODULE > m_revertModule
PCB_LAYER_ID
A quick note on layer IDs:
bool Clear_Pcb(bool aQuery)
Delete all and reinitialize the current board.
Definition: initpcb.cpp:98
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:75
bool SaveLibraryAs(const wxString &aLibraryPath)
Save a library to a new name and/or library type.
void editFootprintProperties(MODULE *aFootprint)
Run the Footprint Properties dialog and handle changes made in it.
void OnModify() override
Must be called after a footprint change in order to set the "modify" flag of the current screen and p...
void FocusOnLibID(const LIB_ID &aLibID)
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...
void SetElementVisibility(GAL_LAYER_ID aElement, bool aNewState)
Function SetElementVisibility changes the visibility of an element category.
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
bool Load_Module_From_BOARD(MODULE *Module)
Load in Modedit a footprint from the main board.
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.
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 Export_Module(MODULE *aModule)
Create a file containing only one footprint.
bool SaveFootprintInLibrary(MODULE *aModule, const wxString &aLibraryName)
Class to handle modifications to the symbol libraries.
Definition: lib_manager.h:99
void InstallPreferences(PAGED_DIALOG *aParent, PANEL_HOTKEYS_EDITOR *aHotkeysPanel) override
Allows Modedit to install its preferences panel into the preferences dialog.
bool SaveFootprintAs(MODULE *aModule)
void Process_Special_Functions(wxCommandEvent &event)
void SetDesignSettings(const BOARD_DESIGN_SETTINGS &aSettings) override
void updateTitle()
Updates window title according to getLibNickName().
LIB_TREE_MODEL_ADAPTER::PTR m_adapter
void SetPlotSettings(const PCB_PLOT_PARAMS &aSettings) override
void LoadModuleFromBoard(wxCommandEvent &event)
Called from the main toolbar to load a footprint from board mainly to edit it.
Common, abstract interface for edit frames.
LIB_ID GetLoadedFPID() const
Return the LIB_ID of the part being edited.
BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:163
void OnUpdateInsertModuleInBoard(wxUpdateUIEvent &aEvent)
BOARD_ITEM_CONTAINER * GetModel() const override
void updateView()
Reloads displayed items and sets view.
bool SaveFootprint(MODULE *aModule)
Save in an existing library a given footprint.
FOOTPRINT_TREE_PANE * m_treePane
void ShowChangedLanguage() override
Update visible items after a language change.
FOOTPRINT_EDITOR_SETTINGS * GetSettings()
wxObjectDataPtr< LIB_TREE_MODEL_ADAPTER > PTR
Reference-counting container for a pointer to CMP_TREE_MODEL_ADAPTER_BASE.
void AddModuleToBoard(MODULE *module) override
Override from PCB_BASE_EDIT_FRAME which adds a module to the editor's dummy board,...
void CloseModuleEditor(wxCommandEvent &Event)
Abstract interface for BOARD_ITEMs capable of storing other items inside.
void OnUpdateModuleSelected(wxUpdateUIEvent &aEvent)
MODULE * Import_Module(const wxString &aName=wxT(""))
Read a file containing only one 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)
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:40
bool IsElementVisible(GAL_LAYER_ID aElement) const
Test whether a given element category is visible.