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 class PCBNEW_SELECTION;
36 
37 namespace PCB { struct IFACE; } // A KIFACE_I coded in pcbnew.c
38 
39 
41 {
42  friend struct PCB::IFACE;
43 
46 
47  std::unique_ptr<MODULE> 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() const override;
91 
92  bool canCloseWindow( wxCloseEvent& Event ) override;
93  void doCloseWindow() override;
94  void CloseModuleEditor( wxCommandEvent& Event );
95  void OnExitKiCad( wxCommandEvent& aEvent );
96 
101  void SwitchCanvas( EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType ) override;
102 
107  void UpdateUserInterface();
108 
109  void Process_Special_Functions( wxCommandEvent& event );
110 
114  void HardRedraw() override;
115 
119  void ReCreateHToolbar() override;
120 
121  void ReCreateVToolbar() override;
122  void ReCreateOptToolbar() override;
123 
127  void ReCreateMenuBar() override;
128 
136  void ReCreateLayerBox( bool aForceResizeToolbar = true );
137 
138  void OnUpdateLayerSelectBox( wxUpdateUIEvent& aEvent );
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 OnUpdateLoadModuleFromBoard( wxUpdateUIEvent& aEvent );
158  void OnUpdateInsertModuleInBoard( wxUpdateUIEvent& aEvent );
159 
161  void OnEditItemRequest( BOARD_ITEM* aItem ) override;
162 
166  void LoadModuleFromBoard( wxCommandEvent& event );
167 
168  void LoadModuleFromLibrary( LIB_ID aFPID );
169 
174 
181  bool SaveFootprint( MODULE* aModule );
182  bool SaveFootprintAs( MODULE* aModule );
183  bool SaveFootprintToBoard( bool aAddNew );
184  bool SaveFootprintInLibrary( MODULE* aModule, const wxString& aLibraryName );
185  bool RevertFootprint();
186 
193  void OnModify() override;
194 
195  // BOARD handling
196 
202  bool Clear_Pcb( bool aQuery );
203 
205  LIB_ID GetTreeFPID() const;
206 
208 
210  LIB_ID GetLoadedFPID() const;
211 
214  LIB_ID GetTargetFPID() const;
215 
216  // importing / exporting Footprint
227  void Export_Module( MODULE* aModule );
228 
238  MODULE* Import_Module( const wxString& aName = wxT("") );
239 
246  bool Load_Module_From_BOARD( MODULE* Module );
247 
255 
256  // functions to edit footprint edges
257 
261  bool DeleteModuleFromLibrary( const LIB_ID& aFPID, bool aConfirm );
262 
270  bool IsElementVisible( GAL_LAYER_ID aElement ) const;
271 
279  void SetElementVisibility( GAL_LAYER_ID aElement, bool aNewState );
280 
284  COLOR4D GetGridColor() override;
285 
287  void SetActiveLayer( PCB_LAYER_ID aLayer ) override;
288 
290  void OnUpdateLayerAlpha( wxUpdateUIEvent& aEvent ) override;
291 
293  void ActivateGalCanvas() override;
294 
304  bool OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl = 0 ) override;
305 
310  void AddModuleToBoard( MODULE* module ) override;
311 
315  void InstallPreferences( PAGED_DIALOG* aParent, PANEL_HOTKEYS_EDITOR* aHotkeysPanel ) override;
316 
317  void ReFillLayerWidget();
318 
322  void ShowChangedLanguage() override;
323 
327  void CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged ) override;
328 
334  void SyncLibraryTree( bool aProgress );
335 
340  void RegenerateLibraryTree();
341 
342  void FocusOnLibID( const LIB_ID& aLibID );
343 
344  void KiwayMailIn( KIWAY_EXPRESS& mail ) override;
345 
346  DECLARE_EVENT_TABLE()
347 
348 protected:
350  FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent, EDA_DRAW_PANEL_GAL::GAL_TYPE aBackend );
351 
352  PCB_LAYER_BOX_SELECTOR* m_selLayerBox; // a combo box to display and select active layer
353 
355 
360  void initLibraryTree();
361 
365  void updateTitle();
366 
368  void updateView();
369 
370  void restoreLastFootprint();
371  void retainLastFootprint();
372 
376  void editFootprintProperties( MODULE* aFootprint );
377 
378  void setupUIConditions() override;
379 };
380 
381 #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
Returns the BOARD_DESIGN_SETTINGS for the open project Overloaded in FOOTPRINT_EDIT_FRAME.
const BOX2I GetDocumentExtents() const override
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.
bool SaveFootprintToBoard(bool aAddNew)
BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
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 LoadModuleFromLibrary(LIB_ID aFPID)
GAL_LAYER_ID
GAL layers are "virtual" layers, i.e.
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.
SELECTION & GetCurrentSelection() override
Get the current selection from the canvas area.
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:95
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 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 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.
bool canCloseWindow(wxCloseEvent &Event) override
Information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:176
COLOR_SETTINGS * GetColorSettings() override
Helper to retrieve the current color settings.
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
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...
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:99
bool IsElementVisible(GAL_LAYER_ID aElement) const
Test whether a given element category is visible.