KiCad PCB EDA Suite
footprint_viewer_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) 2018 Jean-Pierre Charras, jap.charras at wanadoo.fr
5  * Copyright (C) 2004-2021 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
25 #ifndef FOOTPRINT_VIEWER_FRAME_H
26 #define FOOTPRINT_VIEWER_FRAME_H
27 
28 
29 #include <wx/gdicmn.h>
30 #include <pcb_base_frame.h>
31 #include <pcbnew_settings.h>
32 
33 class wxSashLayoutWindow;
34 class wxListBox;
35 class wxSearchCtrl;
36 class FP_LIB_TABLE;
37 class BOARD_ITEM;
38 class SELECTION;
39 
40 namespace PCB { struct IFACE; }
41 
46 {
47 public:
49 
51  BOARD_ITEM_CONTAINER* GetModel() const override;
52 
53  SELECTION& GetCurrentSelection() override;
54 
55  virtual COLOR4D GetGridColor() override;
56 
58  {
59  return &m_magneticItems;
60  }
61 
67  void ReCreateLibraryList();
68 
72  void OnUpdateFootprintButton( wxUpdateUIEvent& aEvent );
73 
80  bool ShowModal( wxString* aFootprint, wxWindow* aParent ) override;
81 
82  COLOR_SETTINGS* GetColorSettings() const override;
83 
84 protected:
85  FOOTPRINT_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType );
86 
88 
89  void setupUIConditions() override;
90 
91 private:
92  const wxString getCurNickname();
93  void setCurNickname( const wxString& aNickname );
94 
95  const wxString getCurFootprintName();
96  void setCurFootprintName( const wxString& aName );
97 
98  void OnSize( wxSizeEvent& event ) override;
99 
100  void ReCreateFootprintList();
101  void OnIterateFootprintList( wxCommandEvent& event );
102 
106  void UpdateTitle();
107 
108  void doCloseWindow() override;
109  void CloseFootprintViewer( wxCommandEvent& event );
110  void OnExitKiCad( wxCommandEvent& event );
111 
112  void ReCreateHToolbar() override;
113  void ReCreateVToolbar() override;
114  void ReCreateOptToolbar() override;
115  void ReCreateMenuBar() override;
116 
117  void OnLibFilter( wxCommandEvent& aEvent );
118  void OnFPFilter( wxCommandEvent& aEvent );
119  void OnCharHook( wxKeyEvent& aEvent ) override;
120 
121  void selectPrev( wxListBox* aListBox );
122  void selectNext( wxListBox* aListBox );
123  void ClickOnLibList( wxCommandEvent& aEvent );
124  void ClickOnFootprintList( wxCommandEvent& aEvent );
125  void DClickOnFootprintList( wxCommandEvent& aEvent );
126 
127  void LoadSettings( APP_SETTINGS_BASE* aCfg ) override;
128  void SaveSettings( APP_SETTINGS_BASE* aCfg ) override;
129 
131 
132  void CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged ) override;
133 
138  void OnActivate( wxActivateEvent& event );
139 
143  void AddFootprintToPCB( wxCommandEvent& aEvent );
144 
153  void SelectAndViewFootprint( int aMode );
154 
156  void Update3DView( bool aMarkDirty, bool aRefresh, const wxString* aTitle = nullptr ) override;
157 
158  void SaveCopyInUndoList( EDA_ITEM*, UNDO_REDO ) override {}
159  void SaveCopyInUndoList( const PICKED_ITEMS_LIST&, UNDO_REDO ) override {}
160 
161  void updateView();
162 
163  DECLARE_EVENT_TABLE()
164 
165  friend struct PCB::IFACE; // constructor called from here only
166 
167  wxSearchCtrl* m_libFilter;
168  wxListBox* m_libList; // The list of library names.
169  wxSearchCtrl* m_fpFilter;
170  wxListBox* m_fpList; // The list of footprint names.
171 
173  double m_lastZoom;
174 };
175 
176 #endif // FOOTPRINT_VIEWER_FRAME_H
void DClickOnFootprintList(wxCommandEvent &aEvent)
void OnExitKiCad(wxCommandEvent &event)
bool ShowModal(wxString *aFootprint, wxWindow *aParent) override
Run the footprint viewer as a modal dialog.
void UpdateTitle()
Update the window title with current library information.
WINDOW_SETTINGS * GetWindowSettings(APP_SETTINGS_BASE *aCfg) override
Return a pointer to the window settings for this frame.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
MAGNETIC_SETTINGS * GetMagneticItemsSettings() override
FRAME_T
The set of EDA_BASE_FRAME derivatives, typically stored in EDA_BASE_FRAME::m_Ident.
Definition: frame_type.h:32
void setCurFootprintName(const wxString &aName)
Component library viewer main window.
FOOTPRINT_VIEWER_FRAME(KIWAY *aKiway, wxWindow *aParent, FRAME_T aFrameType)
void selectNext(wxListBox *aListBox)
void setupUIConditions() override
Setup the UI conditions for the various actions and their controls in this frame.
void OnSize(wxSizeEvent &event) override
Recalculate the size of toolbars and display panel when the frame size changes.
void setCurNickname(const wxString &aNickname)
void OnUpdateFootprintButton(wxUpdateUIEvent &aEvent)
Update the ID_ADD_FOOTPRINT_TO_BOARD tool state in main toolbar.
void Update3DView(bool aMarkDirty, bool aRefresh, const wxString *aTitle=nullptr) override
Update the 3D view, if the viewer is opened by this frame.
UNDO_REDO
Undo Redo considerations: Basically we have 3 cases New item Deleted item Modified item there is also...
SELECTION & GetCurrentSelection() override
Get the current selection from the canvas area.
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
void SaveCopyInUndoList(EDA_ITEM *, UNDO_REDO) override
Create a new entry in undo list of commands.
Classes used in Pcbnew, CvPcb and GerbView.
void ClickOnLibList(wxCommandEvent &aEvent)
Stores the common settings that are saved and loaded for each window / frame.
Definition: app_settings.h:81
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
void SelectAndViewFootprint(int aMode)
Select and load the next or the previous footprint.
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:99
void OnCharHook(wxKeyEvent &aEvent) override
Capture the key event before it is sent to the GUI.
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition: kiway.h:260
void OnActivate(wxActivateEvent &event)
Called when the frame frame is activate to reload the libraries and component lists that can be chang...
A holder to handle information on schematic or board items.
void OnFPFilter(wxCommandEvent &aEvent)
void selectPrev(wxListBox *aListBox)
COLOR_SETTINGS * GetColorSettings() const override
Helper to retrieve the current color settings.
void SaveCopyInUndoList(const PICKED_ITEMS_LIST &, UNDO_REDO) override
Creates a new entry in undo list of commands.
void CloseFootprintViewer(wxCommandEvent &event)
void AddFootprintToPCB(wxCommandEvent &aEvent)
Export the current footprint name and close the library browser.
void ReCreateMenuBar() override
Recreates the menu bar.
void ClickOnFootprintList(wxCommandEvent &aEvent)
void ReCreateLibraryList()
Create or recreate the list of current loaded libraries.
void OnLibFilter(wxCommandEvent &aEvent)
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:100
MAGNETIC_SETTINGS m_magneticItems
Color settings are a bit different than most of the settings objects in that there can be more than o...
BOARD_ITEM_CONTAINER * GetModel() const override
void OnIterateFootprintList(wxCommandEvent &event)
Abstract interface for BOARD_ITEMs capable of storing other items inside.
virtual COLOR4D GetGridColor() override
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103