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-2019 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 
32 class wxSashLayoutWindow;
33 class wxListBox;
34 class FP_LIB_TABLE;
35 class BOARD_ITEM;
36 
37 namespace PCB { struct IFACE; }
38 
43 {
44  friend struct PCB::IFACE; // constructor called from here only
45 
46 protected:
47  FOOTPRINT_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType );
48 
49 
50 public:
52 
54 
57 
58  virtual COLOR4D GetGridColor() override;
59 
60  bool GetAutoZoom() const { return m_autoZoom; }
61  void SetAutoZoom( bool aEnable ) { m_autoZoom = aEnable; }
62 
69  void ReCreateLibraryList();
70 
74  void OnUpdateFootprintButton( wxUpdateUIEvent& aEvent );
75 
83  bool ShowModal( wxString* aFootprint, wxWindow* aParent ) override;
84 
85 private:
86  wxTextCtrl* m_libFilter;
87  wxListBox* m_libList; // The list of libs names
88  wxTextCtrl* m_fpFilter;
89  wxListBox* m_fpList; // The list of footprint names
90 
91  bool m_autoZoom;
92  double m_lastZoom;
93 
94  const wxString getCurNickname();
95  void setCurNickname( const wxString& aNickname );
96 
97  const wxString getCurFootprintName();
98  void setCurFootprintName( const wxString& aName );
99 
100  void OnSize( wxSizeEvent& event ) override;
101 
102  void ReCreateFootprintList();
103  void OnIterateFootprintList( wxCommandEvent& event );
104 
109  void UpdateTitle();
110 
111  void OnCloseWindow( wxCloseEvent& Event ) override;
112  void CloseFootprintViewer( wxCommandEvent& event );
113  void OnExitKiCad( wxCommandEvent& event );
114 
115  void ReCreateHToolbar() override;
116  void ReCreateVToolbar() override;
117  void ReCreateMenuBar() override;
118 
119  void OnLibFilter( wxCommandEvent& aEvent );
120  void OnFPFilter( wxCommandEvent& aEvent );
121  void OnCharHook( wxKeyEvent& aEvent ) override;
122 
123  void selectPrev( wxListBox* aListBox );
124  void selectNext( wxListBox* aListBox );
125  void ClickOnLibList( wxCommandEvent& aEvent );
126  void ClickOnFootprintList( wxCommandEvent& aEvent );
127  void DClickOnFootprintList( wxCommandEvent& aEvent );
128 
129  void InstallDisplayOptions( wxCommandEvent& aEvent );
130 
131  void LoadSettings( wxConfigBase* aCfg ) override;
132  void SaveSettings( wxConfigBase* aCfg ) override;
133  void CommonSettingsChanged( bool aEnvVarsChanged ) override;
134 
140  void OnActivate( wxActivateEvent& event );
141 
146  void AddFootprintToPCB( wxCommandEvent& aEvent );
147 
155  void SelectAndViewFootprint( int aMode );
156 
163  void Update3DView( bool aForceReload, const wxString* aTitle = nullptr ) override;
164 
165  /*
166  * Virtual functions, not used here, but needed by PCB_BASE_FRAME
167  * (virtual pure functions )
168  */
169  void SaveCopyInUndoList( BOARD_ITEM*, UNDO_REDO_T, const wxPoint& ) override {}
170  void SaveCopyInUndoList( const PICKED_ITEMS_LIST&, UNDO_REDO_T, const wxPoint &) override {}
171 
172  void updateView();
173 
174  DECLARE_EVENT_TABLE()
175 };
176 
177 #endif // FOOTPRINT_VIEWER_FRAME_H
IFACE(const char *aName, KIWAY::FACE_T aType)
Definition: pcbnew.cpp:363
void DClickOnFootprintList(wxCommandEvent &aEvent)
void OnExitKiCad(wxCommandEvent &event)
bool ShowModal(wxString *aFootprint, wxWindow *aParent) override
Function ShowModal.
void UpdateTitle()
Function UpdateTitle updates the window title with current library information.
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
void LoadSettings(wxConfigBase *aCfg) override
Load common frame parameters from a configuration file.
FRAME_T
Enum FRAME_T is the set of EDA_BASE_FRAME derivatives, typically stored in EDA_BASE_FRAME::m_Ident.
Definition: frame_type.h:34
void setCurFootprintName(const wxString &aName)
UNDO_REDO_T
Undo Redo considerations: Basically we have 3 cases New item Deleted item Modified item there is also...
void OnCloseWindow(wxCloseEvent &Event) override
Component library viewer main window.
FOOTPRINT_VIEWER_FRAME(KIWAY *aKiway, wxWindow *aParent, FRAME_T aFrameType)
void selectNext(wxListBox *aListBox)
void SetAutoZoom(bool aEnable)
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 InstallDisplayOptions(wxCommandEvent &aEvent)
Classes used in Pcbnew, CvPcb and GerbView.
void ClickOnLibList(wxCommandEvent &aEvent)
void ApplyDisplaySettingsToGAL()
Updates the GAL with display settings changes.
void SelectAndViewFootprint(int aMode)
Function SelectAndViewFootprint Select and load the next or the previous footprint if no current foot...
void OnCharHook(wxKeyEvent &aEvent) override
Capture the key event before it is sent to the GUI.
void SaveCopyInUndoList(BOARD_ITEM *, UNDO_REDO_T, const wxPoint &) override
Function SaveCopyInUndoList (virtual pure) Creates a new entry in undo list of commands.
Class KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within...
Definition: kiway.h:258
void OnActivate(wxActivateEvent &event)
Function OnActivate is called when the frame frame is activate to reload the libraries and component ...
PCB_GENERAL_SETTINGS m_configSettings
void CommonSettingsChanged(bool aEnvVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
Class PICKED_ITEMS_LIST is a holder to handle information on schematic or board items.
PCB_GENERAL_SETTINGS & GetConfigSettings()
void OnFPFilter(wxCommandEvent &aEvent)
void selectPrev(wxListBox *aListBox)
void CloseFootprintViewer(wxCommandEvent &event)
void AddFootprintToPCB(wxCommandEvent &aEvent)
Function AddFootprintToPCB exports the current footprint name and close the library browser.
void ReCreateMenuBar() override
Recreates the menu bar.
void ClickOnFootprintList(wxCommandEvent &aEvent)
void ReCreateLibraryList()
Function ReCreateLibraryList.
void OnLibFilter(wxCommandEvent &aEvent)
void OnIterateFootprintList(wxCommandEvent &event)
virtual COLOR4D GetGridColor() override
void Update3DView(bool aForceReload, const wxString *aTitle=nullptr) override
Function Update3DView must be called after a footprint selection Updates the 3D view and 3D frame tit...
class PCB_BASE_FRAME basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
void SaveCopyInUndoList(const PICKED_ITEMS_LIST &, UNDO_REDO_T, const wxPoint &) override
Function SaveCopyInUndoList (virtual pure, overloaded).
void SaveSettings(wxConfigBase *aCfg) override
Saves common frame parameters to a configuration data file.
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39