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 FP_LIB_TABLE;
36 class BOARD_ITEM;
37 class SELECTION;
38 
39 namespace PCB { struct IFACE; }
40 
45 {
46 public:
48 
50  BOARD_ITEM_CONTAINER* GetModel() const override;
51 
52  SELECTION& GetCurrentSelection() override;
53 
54  virtual COLOR4D GetGridColor() override;
55 
56  bool GetAutoZoom() override;
57  void SetAutoZoom( bool aAutoZoom ) override;
58 
60  {
61  return &m_magneticItems;
62  }
63 
69  void ReCreateLibraryList();
70 
74  void OnUpdateFootprintButton( wxUpdateUIEvent& aEvent );
75 
82  bool ShowModal( wxString* aFootprint, wxWindow* aParent ) override;
83 
84  COLOR_SETTINGS* GetColorSettings() const override;
85 
86 protected:
87  FOOTPRINT_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType );
88 
90 
91  void setupUIConditions() override;
92 
93 private:
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 
108  void UpdateTitle();
109 
110  void doCloseWindow() override;
111  void CloseFootprintViewer( wxCommandEvent& event );
112  void OnExitKiCad( wxCommandEvent& event );
113 
114  void ReCreateHToolbar() override;
115  void ReCreateVToolbar() override;
116  void ReCreateOptToolbar() 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 LoadSettings( APP_SETTINGS_BASE* aCfg ) override;
130  void SaveSettings( APP_SETTINGS_BASE* aCfg ) override;
131 
133 
134  void CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged ) override;
135 
140  void OnActivate( wxActivateEvent& event );
141 
145  void AddFootprintToPCB( wxCommandEvent& aEvent );
146 
155  void SelectAndViewFootprint( int aMode );
156 
158  void Update3DView( bool aMarkDirty, bool aRefresh, const wxString* aTitle = nullptr ) override;
159 
160  void SaveCopyInUndoList( EDA_ITEM*, UNDO_REDO ) override {}
161  void SaveCopyInUndoList( const PICKED_ITEMS_LIST&, UNDO_REDO ) override {}
162 
163  void updateView();
164 
165  DECLARE_EVENT_TABLE()
166 
167  friend struct PCB::IFACE; // constructor called from here only
168 
169  wxTextCtrl* m_libFilter;
170  wxListBox* m_libList; // The list of library names.
171  wxTextCtrl* m_fpFilter;
172  wxListBox* m_fpList; // The list of footprint names.
173 
175  double m_lastZoom;
176 };
177 
178 #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:80
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.
bool GetAutoZoom() override
Always returns false.
FOOTPRINT_VIEWER_FRAME(KIWAY *aKiway, wxWindow *aParent, FRAME_T aFrameType)
void selectNext(wxListBox *aListBox)
void SetAutoZoom(bool aAutoZoom) override
Does nothing.
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:258
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