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;
34 
35 namespace PCB { struct IFACE; } // A KIFACE_I coded in pcbnew.c
36 
37 
39 {
40  friend struct PCB::IFACE;
41 
44 
45  std::unique_ptr<MODULE> m_revertModule;
47 
49 
50 public:
51 
53 
59  static const wxChar* GetFootprintEditorFrameName();
60 
62  BOARD_ITEM_CONTAINER* GetModel() const override;
63 
69  bool IsContentModified() override;
70 
71  bool IsCurrentFPFromBoard() const;
72 
73  BOARD_DESIGN_SETTINGS& GetDesignSettings() const override;
74  void SetDesignSettings( const BOARD_DESIGN_SETTINGS& aSettings ) override;
75 
76  const PCB_PLOT_PARAMS& GetPlotSettings() const override;
77  void SetPlotSettings( const PCB_PLOT_PARAMS& aSettings ) override;
78 
79  void LoadSettings( wxConfigBase* aCfg ) override;
80  void SaveSettings( wxConfigBase* aCfg ) override;
81 
82  const BOX2I GetDocumentExtents() const override;
83 
95  std::vector<PARAM_CFG*>& GetConfigurationSettings();
96 
97  void OnCloseWindow( wxCloseEvent& Event ) override;
98  void CloseModuleEditor( wxCommandEvent& Event );
99  void OnExitKiCad( wxCommandEvent& aEvent );
100 
105  void SwitchCanvas( EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType ) override;
106 
111  void UpdateUserInterface();
112 
113  void Process_Special_Functions( wxCommandEvent& event );
114 
118  void HardRedraw() override;
119 
123  void ReCreateHToolbar() override;
124 
125  void ReCreateVToolbar() override;
126  void ReCreateOptToolbar() override;
127 
131  void ReCreateMenuBar() override;
132 
140  void ReCreateLayerBox( bool aForceResizeToolbar = true );
141 
142  void OnUpdateLayerSelectBox( wxUpdateUIEvent& aEvent );
143 
144  // The Tool Framework initalization, for GAL mode
145  void setupTools();
146 
147  void OnSaveFootprintAsPng( wxCommandEvent& event );
148 
149  bool IsSearchTreeShown();
150  void ToggleSearchTree();
151 
158  bool SaveLibraryAs( const wxString& aLibraryPath );
159 
160  void OnUpdateModuleSelected( wxUpdateUIEvent& aEvent );
161  void OnUpdateLoadModuleFromBoard( wxUpdateUIEvent& aEvent );
162  void OnUpdateInsertModuleInBoard( wxUpdateUIEvent& aEvent );
163 
165  void OnEditItemRequest( BOARD_ITEM* aItem ) override;
166 
170  void LoadModuleFromBoard( wxCommandEvent& event );
171 
172  void LoadModuleFromLibrary( LIB_ID aFPID );
173 
178 
185  bool SaveFootprint( MODULE* aModule );
186  bool SaveFootprintAs( MODULE* aModule );
187  bool SaveFootprintToBoard( bool aAddNew );
188  bool SaveFootprintInLibrary( MODULE* aModule, const wxString& aLibraryName );
189  bool RevertFootprint();
190 
197  void OnModify() override;
198 
199  // BOARD handling
200 
206  bool Clear_Pcb( bool aQuery );
207 
209  LIB_ID GetTreeFPID() const;
210 
212  LIB_ID GetLoadedFPID() const;
213 
216  LIB_ID GetTargetFPID() const;
217 
221  void Transform( MODULE* module, int transform );
222 
223  // importing / exporting Footprint
234  void Export_Module( MODULE* aModule );
235 
245  MODULE* Import_Module( const wxString& aName = wxT("") );
246 
253  bool Load_Module_From_BOARD( MODULE* Module );
254 
262 
263  // functions to edit footprint edges
264 
268  bool DeleteModuleFromLibrary( const LIB_ID& aFPID, bool aConfirm );
269 
277  bool IsElementVisible( GAL_LAYER_ID aElement ) const;
278 
286  void SetElementVisibility( GAL_LAYER_ID aElement, bool aNewState );
287 
291  COLOR4D GetGridColor() override;
292 
294  void SetActiveLayer( PCB_LAYER_ID aLayer ) override;
295 
297  void OnUpdateLayerAlpha( wxUpdateUIEvent& aEvent ) override;
298 
300  void ActivateGalCanvas() override;
301 
311  bool OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl = 0 ) override;
312 
317  void AddModuleToBoard( MODULE* module ) override;
318 
322  void InstallPreferences( PAGED_DIALOG* aParent, PANEL_HOTKEYS_EDITOR* aHotkeysPanel ) override;
323 
324  void ReFillLayerWidget();
325 
329  void ShowChangedLanguage() override;
330 
334  void CommonSettingsChanged( bool aEnvVarsChanged ) override;
335 
341  void SyncLibraryTree( bool aProgress );
342  void FocusOnLibID( const LIB_ID& aLibID );
343 
344  void KiwayMailIn( KIWAY_EXPRESS& mail ) override;
345 
346  void SyncToolbars() override;
347 
348  DECLARE_EVENT_TABLE()
349 
350 protected:
352  FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent, EDA_DRAW_PANEL_GAL::GAL_TYPE aBackend );
353 
354  PCB_LAYER_BOX_SELECTOR* m_selLayerBox; // a combo box to display and select active layer
355  std::vector<PARAM_CFG*> m_configParams; // List of footprint editor configuration parameters.
356 
361  void initLibraryTree();
362 
366  void updateTitle();
367 
369  void updateView();
370 
371  void restoreLastFootprint();
372  void retainLastFootprint();
373 
377  void editFootprintProperties( MODULE* aFootprint );
378 };
379 
380 #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
The common library.
Template specialization to enable wxStrings for certain containers (e.g. unordered_map)
Definition: bitmap.cpp:55
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.
std::vector< PARAM_CFG * > m_configParams
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.
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.
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 LoadSettings(wxConfigBase *aCfg) override
Load common frame parameters from a configuration file.
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.
KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the s...
Definition: kiway.h:274
bool Load_Module_From_BOARD(MODULE *Module)
Load in Modedit a footprint from the main board.
Footprint Editor pane with footprint library tree.
PCB_PLOT_PARAMS handles plot parameters and options when plotting/printing a board.
PCB_LAYER_BOX_SELECTOR * m_selLayerBox
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:98
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().
void SaveSettings(wxConfigBase *aCfg) override
Saves common frame parameters to a configuration data file.
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:160
PARAM_CFG is a base class which establishes the interface functions ReadParam and SaveParam,...
Definition: config_params.h:99
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.
std::vector< PARAM_CFG * > & GetConfigurationSettings()
Return the footprint editor settings list.
FOOTPRINT_TREE_PANE * m_treePane
void ShowChangedLanguage() override
Update visible items after a language change.
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 Transform(MODULE *module, int transform)
Perform a geometric transform on the current footprint.
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:39
bool IsElementVisible(GAL_LAYER_ID aElement) const
Test whether a given element category is visible.