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 
68  void UpdateMsgPanel() override;
69 
76  void ReCreateLibraryList();
77 
81  void OnUpdateFootprintButton( wxUpdateUIEvent& aEvent );
82 
90  bool ShowModal( wxString* aFootprint, wxWindow* aParent ) override;
91 
92 private:
93 
94  wxListBox* m_libList; // The list of libs names
95  wxListBox* m_footprintList; // The list of footprint names
96 
97  bool m_autoZoom;
98  double m_lastZoom;
99 
100  const wxString getCurNickname();
101  void setCurNickname( const wxString& aNickname );
102 
103  const wxString getCurFootprintName();
104  void setCurFootprintName( const wxString& aName );
105 
106  void OnSize( wxSizeEvent& event ) override;
107 
108  void ReCreateFootprintList();
109  void OnIterateFootprintList( wxCommandEvent& event );
110 
115  void UpdateTitle();
116 
122  void RedrawActiveWindow( wxDC* DC, bool EraseBg ) override;
123 
124  void OnCloseWindow( wxCloseEvent& Event ) override;
125  void CloseFootprintViewer( wxCommandEvent& event );
126 
127  void ReCreateHToolbar() override;
128  void ReCreateVToolbar() override;
129  void ReCreateMenuBar() override;
130 
131  void OnLeftClick( wxDC* DC, const wxPoint& MousePos ) override;
132  void ClickOnLibList( wxCommandEvent& event );
133  void ClickOnFootprintList( wxCommandEvent& event );
134  void DClickOnFootprintList( wxCommandEvent& event );
135  void OnSetRelativeOffset( wxCommandEvent& event );
136 
137  void InstallDisplayOptions( wxCommandEvent& event );
138 
139  bool GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KEY aHotKey = 0 ) override;
140 
142  EDA_HOTKEY* GetHotKeyDescription( int aCommand ) const override;
143 
152  bool OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, EDA_ITEM* aItem = NULL ) override;
153 
154  void LoadSettings( wxConfigBase* aCfg ) override;
155  void SaveSettings( wxConfigBase* aCfg ) override;
156 
162  virtual void OnActivate( wxActivateEvent& event ) override;
163 
168  void SelectCurrentFootprint( wxCommandEvent& event );
169 
174  void AddFootprintToPCB( wxCommandEvent& event );
175 
183  void SelectAndViewFootprint( int aMode );
184 
185  bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu ) override;
186 
191  void Show3D_Frame( wxCommandEvent& event ) override;
192 
200  void Update3D_Frame( bool aForceReloadFootprint = true );
201 
202  /*
203  * Virtual functions, not used here, but needed by PCB_BASE_FRAME
204  * (virtual pure functions )
205  */
206  void OnLeftDClick( wxDC*, const wxPoint& ) override {}
207  void SaveCopyInUndoList( BOARD_ITEM*, UNDO_REDO_T, const wxPoint& ) override {}
208  void SaveCopyInUndoList( const PICKED_ITEMS_LIST&, UNDO_REDO_T, const wxPoint &) override {}
209 
210  void updateView();
211 
212  DECLARE_EVENT_TABLE()
213 };
214 
215 #endif // FOOTPRINT_VIEWER_FRAME_H
IFACE(const char *aName, KIWAY::FACE_T aType)
Definition: pcbnew.cpp:390
void ClickOnLibList(wxCommandEvent &event)
bool OnRightClick(const wxPoint &MousePos, wxMenu *PopMenu) override
bool ShowModal(wxString *aFootprint, wxWindow *aParent) override
Function ShowModal.
void UpdateTitle()
Function UpdateTitle updates the window title with current library information.
bool OnHotKey(wxDC *aDC, int aHotKey, const wxPoint &aPosition, EDA_ITEM *aItem=NULL) override
Function OnHotKey handle hot key events.
void ClickOnFootprintList(wxCommandEvent &event)
void Update3D_Frame(bool aForceReloadFootprint=true)
Function Update3D_Frame must be called after a footprint selection Updates the 3D view and 3D frame t...
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.
void DClickOnFootprintList(wxCommandEvent &event)
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 SetAutoZoom(bool aEnable)
void RedrawActiveWindow(wxDC *DC, bool EraseBg) override
Function RedrawActiveWindow Display the current selected component.
void Show3D_Frame(wxCommandEvent &event) override
Function Show3D_Frame (virtual) displays 3D view of the footprint (module) being edited.
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.
Classes used in Pcbnew, CvPcb and GerbView.
void ApplyDisplaySettingsToGAL()
Updates the GAL with display settings changes.
void UpdateMsgPanel() override
redraws the message panel.
void SelectAndViewFootprint(int aMode)
Function SelectAndViewFootprint Select and load the next or the previous footprint if no current foot...
void SaveCopyInUndoList(BOARD_ITEM *, UNDO_REDO_T, const wxPoint &) override
Function SaveCopyInUndoList (virtual pure) Creates a new entry in undo list of commands.
bool GeneralControl(wxDC *aDC, const wxPoint &aPosition, EDA_KEY aHotKey=0) override
Perform application specific control using aDC at aPosition in logical units.
Class KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within...
Definition: kiway.h:258
void OnLeftClick(wxDC *DC, const wxPoint &MousePos) override
uint32_t EDA_KEY
Definition: common.h:71
void OnLeftDClick(wxDC *, const wxPoint &) override
PCB_GENERAL_SETTINGS m_configSettings
Class PICKED_ITEMS_LIST is a holder to handle information on schematic or board items.
PCB_GENERAL_SETTINGS & GetConfigSettings()
void SelectCurrentFootprint(wxCommandEvent &event)
Function SelectCurrentFootprint Selects the current footprint name and display it.
EDA_HOTKEY * GetHotKeyDescription(int aCommand) const override
void OnSetRelativeOffset(wxCommandEvent &event)
class EDA_HOTKEY is a class to handle hot key commands.
Definition: hotkeys_basic.h:59
void CloseFootprintViewer(wxCommandEvent &event)
void ReCreateMenuBar() override
Recreates the menu bar.
void ReCreateLibraryList()
Function ReCreateLibraryList.
void InstallDisplayOptions(wxCommandEvent &event)
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:157
virtual void OnActivate(wxActivateEvent &event) override
Function OnActivate is called when the frame frame is activate to reload the libraries and component ...
void OnIterateFootprintList(wxCommandEvent &event)
void AddFootprintToPCB(wxCommandEvent &event)
Function AddFootprintToPCB exports the current footprint name and close the library browser.
virtual COLOR4D GetGridColor() override
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