KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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-2023 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 <pcb_io/pcb_io_mgr.h>
26#include <widgets/lib_tree.h>
27#include <footprint_tree_pane.h>
29
31class FP_LIB_TABLE;
35class EDA_LIST_DIALOG;
36
37namespace PCB { struct IFACE; } // A KIFACE coded in pcbnew.cpp
38
39
41{
42public:
44
49 static const wxChar* GetFootprintEditorFrameName();
50
52 BOARD_ITEM_CONTAINER* GetModel() const override;
54
60 bool IsContentModified() const override;
61
62 bool IsCurrentFPFromBoard() const;
63
64 bool CanCloseFPFromBoard( bool doClose );
65
67
71 EDA_ANGLE GetRotationAngle() const override;
72
73 APP_SETTINGS_BASE* config() const override;
74
76
77 const PCB_PLOT_PARAMS& GetPlotSettings() const override;
78 void SetPlotSettings( const PCB_PLOT_PARAMS& aSettings ) override;
79
81
82 void LoadSettings( APP_SETTINGS_BASE* aCfg ) override;
83 void SaveSettings( APP_SETTINGS_BASE* aCfg ) override;
84
85 COLOR_SETTINGS* GetColorSettings( bool aForceRefresh = false ) const override;
86
87 std::unique_ptr<GRID_HELPER> MakeGridHelper() override;
88
89 const BOX2I GetDocumentExtents( bool aIncludeAllVisible = true ) const override;
90
91 bool canCloseWindow( wxCloseEvent& Event ) override;
92 void doCloseWindow() override;
93 void CloseFootprintEditor( wxCommandEvent& Event );
94 void OnExitKiCad( wxCommandEvent& aEvent );
95
101 void SwitchCanvas( EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType ) override;
102
107 void UpdateUserInterface();
108
110 void UpdateMsgPanel() override;
111
115 void HardRedraw() override;
116
120 void ReCreateHToolbar() override;
121
122 void ReCreateVToolbar() override;
123 void ReCreateOptToolbar() override;
124 void UpdateToolbarControlSizes() override;
125
134 void ReCreateLayerBox( bool aForceResizeToolbar = true );
135
136 void OnUpdateLayerSelectBox( wxUpdateUIEvent& aEvent );
137
138 void SelectLayer( wxCommandEvent& event );
139
140 // The Tool Framework initialization, for GAL mode
141 void setupTools();
142
143 void OnSaveFootprintAsPng( wxCommandEvent& event );
144
145 bool IsLibraryTreeShown() const override;
146 void ToggleLibraryTree() override;
147 void FocusLibraryTreeInput() override;
148
149 void ToggleLayersManager();
150
158 bool SaveLibraryAs( const wxString& aLibraryPath );
159
160 void OnUpdateLoadFootprintFromBoard( wxUpdateUIEvent& aEvent );
161 void OnUpdateSaveFootprintToBoard( wxUpdateUIEvent& aEvent );
162
164 void OnEditItemRequest( BOARD_ITEM* aItem ) override;
165
169 void OnLoadFootprintFromBoard( wxCommandEvent& event );
170
171 void OnSaveFootprintToBoard( wxCommandEvent& event );
172
173 void LoadFootprintFromLibrary( LIB_ID aFPID );
174
178 wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER>& GetLibTreeAdapter() { return m_adapter; }
179
186 bool SaveFootprint( FOOTPRINT* aFootprint );
187 bool DuplicateFootprint( FOOTPRINT* aFootprint );
188 bool SaveFootprintAs( FOOTPRINT* aFootprint );
189 bool SaveFootprintToBoard( bool aAddNew );
190 bool SaveFootprintInLibrary( FOOTPRINT* aFootprint, const wxString& aLibraryName );
191 bool RevertFootprint();
192
199 void OnModify() override;
200
207 bool Clear_Pcb( bool doAskAboutUnsavedChanges );
208
210 LIB_ID GetLoadedFPID() const;
211
214 LIB_ID GetTargetFPID() const;
215
216 void ClearModify();
217
221 void ExportFootprint( FOOTPRINT* aFootprint );
222
229 FOOTPRINT* ImportFootprint( const wxString& aName = wxT( "" ) );
230
238 bool LoadFootprintFromBoard( FOOTPRINT* aFootprint );
239
246
250 bool DeleteFootprintFromLibrary( const LIB_ID& aFPID, bool aConfirm );
251
255 COLOR4D GetGridColor() override;
256
258 void SetActiveLayer( PCB_LAYER_ID aLayer ) override;
259
260 void OnDisplayOptionsChanged() override;
261
263 void ActivateGalCanvas() override;
264
274 bool OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl = 0 ) override;
275
280 void AddFootprintToBoard( FOOTPRINT* aFootprint ) override;
281
286 void ReloadFootprint( FOOTPRINT* aFootprint ) override;
287
291 void ShowChangedLanguage() override;
292
296 void CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged ) override;
297
298 LIB_TREE* GetLibTree() const override
299 {
300 return m_treePane->GetLibTree();
301 }
302
307 void SyncLibraryTree( bool aProgress );
308
312 void RefreshLibraryTree();
313
317 void UpdateLibraryTree( const wxDataViewItem& treeItem, FOOTPRINT* aFootprint );
318
320 void UpdateView();
321
322 void UpdateTitle();
323
324 void FocusOnLibID( const LIB_ID& aLibID );
325
326 void KiwayMailIn( KIWAY_EXPRESS& mail ) override;
327
328 DECLARE_EVENT_TABLE()
329
330protected:
332 FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent );
333
337 void resolveCanvasType() override;
338
343 void initLibraryTree();
344
346 void retainLastFootprint();
347
351 void doReCreateMenuBar() override;
352
356 void editFootprintProperties( FOOTPRINT* aFootprint );
357
358 void setupUIConditions() override;
359
360 void centerItemIdleHandler( wxIdleEvent& aEvent );
361
362protected:
363 PCB_LAYER_BOX_SELECTOR* m_selLayerBox; // a combo box to display and select active layer
365
366private:
367 friend struct PCB::IFACE;
368
371
373
375
379};
380
381#endif // FOOTPRINT_EDIT_FRAME_H
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:92
Container for design settings for a BOARD object.
Abstract interface for BOARD_ITEMs capable of storing other items inside.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:79
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:290
Color settings are a bit different than most of the settings objects in that there can be more than o...
A dialog which shows:
void CloseFootprintEditor(wxCommandEvent &Event)
BOARD_DESIGN_SETTINGS & GetDesignSettings() const override
Returns the BOARD_DESIGN_SETTINGS for the open project.
void setupUIConditions() override
Setup the UI conditions for the various actions and their controls in this frame.
void ActivateGalCanvas() override
Use to start up the GAL drawing canvas.
void editFootprintProperties(FOOTPRINT *aFootprint)
Run the Footprint Properties dialog and handle changes made in it.
void HardRedraw() override
Refresh the library tree and redraw the window.
void UpdateLibraryTree(const wxDataViewItem &treeItem, FOOTPRINT *aFootprint)
Update a single node in the library tree.
static const wxChar * GetFootprintEditorFrameName()
void SyncLibraryTree(bool aProgress)
Synchronize the footprint library tree to the current state of the footprint library table.
bool SaveFootprintInLibrary(FOOTPRINT *aFootprint, const wxString &aLibraryName)
bool SaveLibraryAs(const wxString &aLibraryPath)
Save a library to a new name and/or library type.
void OnSaveFootprintAsPng(wxCommandEvent &event)
bool SaveFootprintAs(FOOTPRINT *aFootprint)
bool DuplicateFootprint(FOOTPRINT *aFootprint)
void FocusLibraryTreeInput() override
void ToggleLibraryTree() override
BOARD_ITEM_CONTAINER * GetModel() const override
void ReCreateLayerBox(bool aForceResizeToolbar=true)
Re create the layer Box by clearing the old list, and building a new one from the new layers names an...
void OnUpdateLayerSelectBox(wxUpdateUIEvent &aEvent)
LIB_TREE * GetLibTree() const override
bool canCloseWindow(wxCloseEvent &Event) override
void UpdateMsgPanel() override
Redraw the message panel.
void ExportFootprint(FOOTPRINT *aFootprint)
Create a file containing only one footprint.
void KiwayMailIn(KIWAY_EXPRESS &mail) override
Receive KIWAY_EXPRESS messages from other players.
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...
LIB_ID GetLoadedFPID() const
Return the LIB_ID of the part being edited.
APP_SETTINGS_BASE * config() const override
Returns the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
void SelectLayer(wxCommandEvent &event)
bool SaveFootprintToBoard(bool aAddNew)
void SetPlotSettings(const PCB_PLOT_PARAMS &aSettings) override
bool SaveFootprint(FOOTPRINT *aFootprint)
Save in an existing library a given footprint.
void initLibraryTree()
Make sure the footprint info list is loaded (with a progress dialog) and then initialize the footprin...
void LoadFootprintFromLibrary(LIB_ID aFPID)
void OnLoadFootprintFromBoard(wxCommandEvent &event)
Called from the main toolbar to load a footprint from board mainly to edit it.
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Called after the preferences dialog is run.
wxObjectDataPtr< LIB_TREE_MODEL_ADAPTER > & GetLibTreeAdapter()
Return the adapter object that provides the stored data.
void UpdateToolbarControlSizes() override
Update the sizes of any controls in the toolbars of the frame.
FOOTPRINT * ImportFootprint(const wxString &aName=wxT(""))
Read a file containing only one footprint.
std::map< KIID, KIID > m_boardFootprintUuids
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
FOOTPRINT * SelectFootprintFromBoard(BOARD *aPcb)
Display the list of footprints currently existing on the BOARD.
void ReCreateHToolbar() override
Create the main horizontal toolbar for the footprint editor.
void ShowChangedLanguage() override
Update visible items after a language change.
void resolveCanvasType() override
Determines the Canvas type to load (with prompt if required) and initializes m_canvasType.
void OnSaveFootprintToBoard(wxCommandEvent &event)
bool IsContentModified() const override
Get if any footprints or libraries have been modified but not saved.
void UpdateUserInterface()
Update the layer manager and other widgets from the board setup (layer and items visibility,...
wxObjectDataPtr< LIB_TREE_MODEL_ADAPTER > m_adapter
bool IsLibraryTreeShown() const override
FOOTPRINT_EDITOR_SETTINGS * m_editorSettings
void centerItemIdleHandler(wxIdleEvent &aEvent)
const BOX2I GetDocumentExtents(bool aIncludeAllVisible=true) const override
Returns bbox of document with option to not include some items.
bool Clear_Pcb(bool doAskAboutUnsavedChanges)
Delete all and reinitialize the current board.
Definition: initpcb.cpp:105
void OnUpdateLoadFootprintFromBoard(wxUpdateUIEvent &aEvent)
void OnUpdateSaveFootprintToBoard(wxUpdateUIEvent &aEvent)
Install the corresponding dialog editor for the given item.
void OnEditItemRequest(BOARD_ITEM *aItem) override
Install the corresponding dialog editor for the given item.
SELECTION & GetCurrentSelection() override
Get the current selection from the canvas area.
bool CanCloseFPFromBoard(bool doClose)
void SetActiveLayer(PCB_LAYER_ID aLayer) override
void AddFootprintToBoard(FOOTPRINT *aFootprint) override
Override from PCB_BASE_EDIT_FRAME which adds a footprint to the editor's dummy board,...
bool DeleteFootprintFromLibrary(const LIB_ID &aFPID, bool aConfirm)
Delete the given footprint from its library.
void OnModify() override
Must be called after a footprint change in order to set the "modify" flag of the current screen and p...
FOOTPRINT_TREE_PANE * m_treePane
std::unique_ptr< GRID_HELPER > MakeGridHelper() override
COLOR4D GetGridColor() override
void OnDisplayOptionsChanged() override
void doReCreateMenuBar() override
(Re)Create the menubar for the Footprint Editor frame
void FocusOnLibID(const LIB_ID &aLibID)
const PCB_PLOT_PARAMS & GetPlotSettings() const override
Return the PCB_PLOT_PARAMS for the BOARD owned by this frame.
PCB_LAYER_BOX_SELECTOR * m_selLayerBox
std::unique_ptr< FOOTPRINT > m_originalFootprintCopy
void ReloadFootprint(FOOTPRINT *aFootprint) override
Override from PCB_BASE_FRAME which reloads the footprint from the library without setting the footpri...
EDA_ANGLE GetRotationAngle() const override
Return the angle used for rotate operations.
void RefreshLibraryTree()
Redisplay the library tree.
void OnExitKiCad(wxCommandEvent &aEvent)
bool OpenProjectFiles(const std::vector< wxString > &aFileSet, int aCtl=0) override
Load a KiCad board (.kicad_pcb) from aFileName.
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
MAGNETIC_SETTINGS * GetMagneticItemsSettings() override
FOOTPRINT_EDITOR_SETTINGS * GetSettings()
void SwitchCanvas(EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType) override
Switch the currently used canvas (Cairo / OpenGL).
bool LoadFootprintFromBoard(FOOTPRINT *aFootprint)
Load a footprint from the main board into the Footprint Editor.
COLOR_SETTINGS * GetColorSettings(bool aForceRefresh=false) const override
Helper to retrieve the current color settings.
Footprint Editor pane with footprint library tree.
LIB_TREE * GetLibTree() const
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
Definition: kiid.h:49
Carry a payload from one KIWAY_PLAYER to another within a PROJECT.
Definition: kiway_express.h:40
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition: kiway.h:285
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:49
Widget displaying a tree of symbols with optional search text control and description panel....
Definition: lib_tree.h:49
Common, abstract interface for edit frames.
Class to display a pcb layer list in a wxBitmapComboBox.
Parameters and options when plotting/printing a board.
Class to handle modifications to the symbol libraries.
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:60
STL namespace.