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 
78  const PCB_PLOT_PARAMS& GetPlotSettings() const override;
79  void SetPlotSettings( const PCB_PLOT_PARAMS& aSettings ) override;
80 
82 
83  void LoadSettings( APP_SETTINGS_BASE* aCfg ) override;
84  void SaveSettings( APP_SETTINGS_BASE* aCfg ) override;
85 
86  COLOR_SETTINGS* GetColorSettings() override;
87 
88  const BOX2I GetDocumentExtents() const override;
89 
90  void OnCloseWindow( wxCloseEvent& Event ) override;
91  void CloseModuleEditor( wxCommandEvent& Event );
92  void OnExitKiCad( wxCommandEvent& aEvent );
93 
98  void SwitchCanvas( EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType ) override;
99 
104  void UpdateUserInterface();
105 
106  void Process_Special_Functions( wxCommandEvent& event );
107 
111  void HardRedraw() override;
112 
116  void ReCreateHToolbar() override;
117 
118  void ReCreateVToolbar() override;
119  void ReCreateOptToolbar() override;
120 
124  void ReCreateMenuBar() override;
125 
133  void ReCreateLayerBox( bool aForceResizeToolbar = true );
134 
135  void OnUpdateLayerSelectBox( wxUpdateUIEvent& aEvent );
136 
137  // The Tool Framework initalization, for GAL mode
138  void setupTools();
139 
140  void OnSaveFootprintAsPng( wxCommandEvent& event );
141 
142  bool IsSearchTreeShown();
143  void ToggleSearchTree();
144 
151  bool SaveLibraryAs( const wxString& aLibraryPath );
152 
153  void OnUpdateModuleSelected( wxUpdateUIEvent& aEvent );
154  void OnUpdateLoadModuleFromBoard( wxUpdateUIEvent& aEvent );
155  void OnUpdateInsertModuleInBoard( wxUpdateUIEvent& aEvent );
156 
158  void OnEditItemRequest( BOARD_ITEM* aItem ) override;
159 
163  void LoadModuleFromBoard( wxCommandEvent& event );
164 
165  void LoadModuleFromLibrary( LIB_ID aFPID );
166 
171 
178  bool SaveFootprint( MODULE* aModule );
179  bool SaveFootprintAs( MODULE* aModule );
180  bool SaveFootprintToBoard( bool aAddNew );
181  bool SaveFootprintInLibrary( MODULE* aModule, const wxString& aLibraryName );
182  bool RevertFootprint();
183 
190  void OnModify() override;
191 
192  // BOARD handling
193 
199  bool Clear_Pcb( bool aQuery );
200 
202  LIB_ID GetTreeFPID() const;
203 
205 
207  LIB_ID GetLoadedFPID() const;
208 
211  LIB_ID GetTargetFPID() const;
212 
213  // importing / exporting Footprint
224  void Export_Module( MODULE* aModule );
225 
235  MODULE* Import_Module( const wxString& aName = wxT("") );
236 
243  bool Load_Module_From_BOARD( MODULE* Module );
244 
252 
253  // functions to edit footprint edges
254 
258  bool DeleteModuleFromLibrary( const LIB_ID& aFPID, bool aConfirm );
259 
267  bool IsElementVisible( GAL_LAYER_ID aElement ) const;
268 
276  void SetElementVisibility( GAL_LAYER_ID aElement, bool aNewState );
277 
281  COLOR4D GetGridColor() override;
282 
284  void SetActiveLayer( PCB_LAYER_ID aLayer ) override;
285 
287  void OnUpdateLayerAlpha( wxUpdateUIEvent& aEvent ) override;
288 
290  void ActivateGalCanvas() override;
291 
301  bool OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl = 0 ) override;
302 
307  void AddModuleToBoard( MODULE* module ) override;
308 
312  void InstallPreferences( PAGED_DIALOG* aParent, PANEL_HOTKEYS_EDITOR* aHotkeysPanel ) override;
313 
314  void ReFillLayerWidget();
315 
319  void ShowChangedLanguage() override;
320 
324  void CommonSettingsChanged( bool aEnvVarsChanged ) override;
325 
331  void SyncLibraryTree( bool aProgress );
332 
337  void RegenerateLibraryTree();
338 
339  void FocusOnLibID( const LIB_ID& aLibID );
340 
341  void KiwayMailIn( KIWAY_EXPRESS& mail ) override;
342 
343  void SyncToolbars() override;
344 
345  DECLARE_EVENT_TABLE()
346 
347 protected:
349  FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent, EDA_DRAW_PANEL_GAL::GAL_TYPE aBackend );
350 
351  PCB_LAYER_BOX_SELECTOR* m_selLayerBox; // a combo box to display and select active layer
352 
354 
359  void initLibraryTree();
360 
364  void updateTitle();
365 
367  void updateView();
368 
369  void restoreLastFootprint();
370  void retainLastFootprint();
371 
375  void editFootprintProperties( MODULE* aFootprint );
376 };
377 
378 #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 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: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:91
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.
BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:180
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.