KiCad PCB EDA Suite
cvpcb_mainframe.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, jp.charras at wanadoo.fr
5 * Copyright (C) 1992-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 _CVPCB_MAINFRAME_H_
26#define _CVPCB_MAINFRAME_H_
27
28#include <config_params.h>
29#include <kiway_player.h>
31
32#include <auto_associate.h>
33#include <cvpcb_association.h>
34#include <listboxes.h>
35
36/* Forward declarations */
37class ACTION_TOOLBAR;
38class ACTION_MENU;
39class TOOL_DISPATCHER;
40class wxAuiToolBar;
41class wxStaticText;
43
44namespace CV { struct IFACE; }
45
46// The undo/redo list is composed of vectors of associations
47typedef std::vector< CVPCB_ASSOCIATION > CVPCB_UNDO_REDO_ENTRIES;
48
49// The undo list is a vector of undo entries
50typedef std::vector< CVPCB_UNDO_REDO_ENTRIES > CVPCB_UNDO_REDO_LIST;
51
52
57{
58public:
60
61 bool OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl=0 ) override;
62
63 void KiwayMailIn( KIWAY_EXPRESS& aEvent ) override;
64
69 {
73 };
74
79 {
84 };
85
90 {
93 };
94
99 {
101 ITEM_PREV
102 };
103
109 bool IsContentModified() const override
110 {
111 return m_modified;
112 }
113
118
119 wxWindow* GetToolCanvas() const override;
120
127
134
141 void OnSelectComponent( wxListEvent& event );
142
143 /*
144 * Functions to rebuild the toolbars and menubars
145 */
146 void ReCreateHToolbar();
147 void ReCreateMenuBar() override;
148
149 void ShowChangedLanguage() override;
150
160
169
173 void UndoAssociation();
174
178 void RedoAssociation();
179
180 int GetUndoCommandCount() const override
181 {
182 return m_undoList.size();
183 }
184
185 int GetRedoCommandCount() const override
186 {
187 return m_redoList.size();
188 }
189
201 void AssociateFootprint( const CVPCB_ASSOCIATION& aAssociation, bool aNewEntry = true,
202 bool aAddUndoItem = true );
203
204 /*
205 * Functions to build the listboxes and their contents
206 */
207 void BuildSymbolsListBox();
210
216 bool SaveFootprintAssociation( bool doSaveSchematic );
217
218 void LoadSettings( APP_SETTINGS_BASE* aCfg ) override;
219
220 void SaveSettings( APP_SETTINGS_BASE* aCfg ) override;
221
233 void DisplayStatus();
234
245 bool LoadFootprintFiles();
246
256 void SendComponentSelectionToSch( bool aClearSelectionOnly = false );
257
264
271 void SetSelectedComponent( int aIndex, bool aSkipUpdate = false );
272
277 {
282 };
283
291 std::vector<unsigned int> GetComponentIndices(
293
298 wxString GetSelectedFootprint();
299
301
302 void SetStatusText( const wxString& aText, int aNumber = 0 ) override;
303
304protected:
305 CVPCB_MAINFRAME( KIWAY* aKiway, wxWindow* aParent );
306
307 void setupUIConditions() override;
308
309 bool canCloseWindow( wxCloseEvent& aCloseEvent ) override;
310 void doCloseWindow() override;
311
319 bool readNetListAndFpFiles( const std::string& aNetlist );
320
328 int readSchematicNetlist( const std::string& aNetlist );
329
330private:
331 wxString formatSymbolDesc( int idx, const wxString& aReference, const wxString& aValue,
332 const wxString& aFootprint );
333
337 void setupTools();
338
342 void setupEventHandlers();
343
344 void onTextFilterChanged( wxCommandEvent& event );
345
346 void updateFootprintViewerOnIdle( wxIdleEvent& aEvent );
347
348 void onTextFilterChangedTimer( wxTimerEvent& aEvent );
349
359 wxString* aErrorMessages = nullptr );
360
361 void refreshAfterSymbolSearch( COMPONENT* aSymbol );
362
363public:
365
366protected:
368 bool m_skipComponentSelect; // skip component selection event during
369 // automatic selection/deletion of associations
370
371 bool m_initialized; // true after creating widgets.
372 bool m_cannotClose; // true when the cvpcb frame cannot be closed
373 // (mainly during reading a netlist sent by Eeschema)
374
375private:
376 friend struct CV::IFACE;
377
384 wxTextCtrl* m_tcFilterString;
385 wxStaticText* m_statusLine1;
386 wxStaticText* m_statusLine2;
387 wxStaticText* m_statusLine3;
389
391
392 // Context menus for the list boxes
395
398
401
402};
403
404#endif //#ifndef _CVPCB_MAINFRAME_H_
boost::ptr_vector< FOOTPRINT_EQUIVALENCE > FOOTPRINT_EQUIVALENCE_LIST
Defines the structure of a menu based on ACTIONs.
Definition: action_menu.h:49
Define the structure of a toolbar with buttons that invoke ACTIONs.
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:101
Store all of the related footprint information found in a netlist.
Definition: pcb_netlist.h:85
A class to define a footprint association to be made in cvpcb.
The CvPcb application main window.
ITEM_DIR
Directions to move when selecting items.
@ ITEM_NEXT
The next item.
@ ITEM_PREV
The previous item.
bool readNetListAndFpFiles(const std::string &aNetlist)
Load the netlist file built on the fly by Eeschema and loads footprint libraries from fp lib tables.
wxTimer * m_filterTimer
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
void ShowChangedLanguage() override
void SendComponentSelectionToSch(bool aClearSelectionOnly=false)
Send a remote command to Eeschema via a socket,.
bool OpenProjectFiles(const std::vector< wxString > &aFileSet, int aCtl=0) override
Open a project or set of files given by aFileList.
void doCloseWindow() override
CVPCB_UNDO_REDO_LIST m_redoList
ACTION_MENU * m_symbolsContextMenu
wxStaticText * m_statusLine3
int GetUndoCommandCount() const override
CVPCB_MAINFRAME::CONTROL_TYPE GetFocusedControl() const
Find out which control currently has focus.
CVPCB_FILTER_ACTION
The action to apply to a footprint filter when it is modified.
@ FILTER_DISABLE
Turn off the filter.
@ FILTER_ENABLE
Turn on the filter.
@ FILTER_TOGGLE
Toggle the filter state.
void onTextFilterChangedTimer(wxTimerEvent &aEvent)
void onTextFilterChanged(wxCommandEvent &event)
LIBRARY_LISTBOX * m_librariesListBox
void setupTools()
Setup the tool system for the CVPCB main frame.
DISPLAY_FOOTPRINTS_FRAME * GetFootprintViewerFrame() const
wxButton * m_saveAndContinue
void RedoAssociation()
Redo the most recently undone association.
bool LoadFootprintFiles()
Read the list of footprint (*.mod files) and generate the list of footprints.
void SetStatusText(const wxString &aText, int aNumber=0) override
void ReCreateMenuBar() override
Recreates the menu bar.
wxString GetSelectedFootprint()
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
CVPCB_MAINFRAME(KIWAY *aKiway, wxWindow *aParent)
void SetFootprintFilter(FOOTPRINTS_LISTBOX::FP_FILTER_T aFilter, CVPCB_MAINFRAME::CVPCB_FILTER_ACTION aAction)
Set a filter criteria to either on/off or toggle the criteria.
wxStaticText * m_statusLine1
void setupEventHandlers()
Setup event handlers.
void setupUIConditions() override
Setup the UI conditions for the various actions and their controls in this frame.
void SetSelectedComponent(int aIndex, bool aSkipUpdate=false)
Set the currently selected component in the components listbox.
ACTION_MENU * m_footprintContextMenu
int GetRedoCommandCount() const override
CONTROL_TYPE
The type of the controls present in the application.
@ CONTROL_NONE
No controls have focus.
@ CONTROL_LIBRARY
Library listbox.
@ CONTROL_FOOTPRINT
Footprint listbox.
@ CONTROL_COMPONENT
Component listbox.
wxString formatSymbolDesc(int idx, const wxString &aReference, const wxString &aValue, const wxString &aFootprint)
void SetFocusedControl(CVPCB_MAINFRAME::CONTROL_TYPE aControl)
Set the focus to a specific control.
void KiwayMailIn(KIWAY_EXPRESS &aEvent) override
Receive KIWAY_EXPRESS messages from other players.
int buildEquivalenceList(FOOTPRINT_EQUIVALENCE_LIST &aList, wxString *aErrorMessages=nullptr)
Read the .equ files and populate the list of equivalents.
void OnSelectComponent(wxListEvent &event)
Called when clicking on a component in component list window:
void UndoAssociation()
Undo the most recent associations that were performed.
void DisplayStatus()
Update the information displayed on the status bar at bottom of the main frame.
ACTION_TOOLBAR * m_mainToolBar
CVPCB_UNDO_REDO_LIST m_undoList
bool canCloseWindow(wxCloseEvent &aCloseEvent) override
FOOTPRINT_LIST * m_FootprintsList
wxWindow * GetToolCanvas() const override
Canvas access.
std::vector< unsigned int > GetComponentIndices(CVPCB_MAINFRAME::CRITERIA aCriteria=CVPCB_MAINFRAME::ALL_COMPONENTS)
Get the indices for all the components meeting the specified criteria in the components listbox.
void AssociateFootprint(const CVPCB_ASSOCIATION &aAssociation, bool aNewEntry=true, bool aAddUndoItem=true)
Associate a footprint with a specific component in the list.
bool IsContentModified() const override
Get if the current associations have been modified but not saved.
void updateFootprintViewerOnIdle(wxIdleEvent &aEvent)
void refreshAfterSymbolSearch(COMPONENT *aSymbol)
wxStaticText * m_statusLine2
FOOTPRINTS_LISTBOX * m_footprintListBox
CRITERIA
Criteria to use to identify sets of components.
@ ALL_COMPONENTS
All components.
@ NA_COMPONENTS
Not associated components.
@ SEL_COMPONENTS
Selected components.
@ ASSOC_COMPONENTS
Associated components.
SYMBOLS_LISTBOX * m_symbolsListBox
TOOL_DISPATCHER * m_toolDispatcher
int readSchematicNetlist(const std::string &aNetlist)
Read the netlist (.net) file built on the fly by Eeschema.
bool SaveFootprintAssociation(bool doSaveSchematic)
Save the edits that the user has done by sending them back to Eeschema via the kiway.
wxTextCtrl * m_tcFilterString
COMPONENT * GetSelectedComponent()
Get the selected component from the component listbox.
FOCUS_DIR
Directions to rotate the focus through the listboxes is.
void AutomaticFootprintMatching()
Called by the automatic association button Read *.equ files to try to find corresponding footprint fo...
FP_FILTER_T
Filter setting constants.
Definition: listboxes.h:93
Holds a list of FOOTPRINT_INFO objects, along with a list of IO_ERRORs or PARSE_ERRORs that were thro...
Carry a payload from one KIWAY_PLAYER to another within a PROJECT.
Definition: kiway_express.h:39
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
Definition: kiway_player.h:66
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition: kiway.h:273
Store information read from a netlist along with the flags used to update the NETLIST in the BOARD.
Definition: pcb_netlist.h:213
std::vector< CVPCB_UNDO_REDO_ENTRIES > CVPCB_UNDO_REDO_LIST
std::vector< CVPCB_ASSOCIATION > CVPCB_UNDO_REDO_ENTRIES
Definition: cvpcb.cpp:38