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
148 void ShowChangedLanguage() override;
149
159
168
172 void UndoAssociation();
173
177 void RedoAssociation();
178
179 int GetUndoCommandCount() const override
180 {
181 return m_undoList.size();
182 }
183
184 int GetRedoCommandCount() const override
185 {
186 return m_redoList.size();
187 }
188
200 void AssociateFootprint( const CVPCB_ASSOCIATION& aAssociation, bool aNewEntry = true,
201 bool aAddUndoItem = true );
202
203 /*
204 * Functions to build the listboxes and their contents
205 */
206 void BuildSymbolsListBox();
209
215 bool SaveFootprintAssociation( bool doSaveSchematic );
216
217 void LoadSettings( APP_SETTINGS_BASE* aCfg ) override;
218
219 void SaveSettings( APP_SETTINGS_BASE* aCfg ) override;
220
232 void DisplayStatus();
233
244 bool LoadFootprintFiles();
245
255 void SendComponentSelectionToSch( bool aClearSelectionOnly = false );
256
263
270 void SetSelectedComponent( int aIndex, bool aSkipUpdate = false );
271
276 {
281 };
282
290 std::vector<unsigned int> GetComponentIndices(
292
297 wxString GetSelectedFootprint();
298
300
301 void SetStatusText( const wxString& aText, int aNumber = 0 ) override;
302
303protected:
304 CVPCB_MAINFRAME( KIWAY* aKiway, wxWindow* aParent );
305
306 void doReCreateMenuBar() override;
307
308 void setupUIConditions() override;
309
310 bool canCloseWindow( wxCloseEvent& aCloseEvent ) override;
311 void doCloseWindow() override;
312
320 bool readNetListAndFpFiles( const std::string& aNetlist );
321
329 int readSchematicNetlist( const std::string& aNetlist );
330
331private:
332 wxString formatSymbolDesc( int idx, const wxString& aReference, const wxString& aValue,
333 const wxString& aFootprint );
334
338 void setupTools();
339
343 void setupEventHandlers();
344
345 void onTextFilterChanged( wxCommandEvent& event );
346
347 void updateFootprintViewerOnIdle( wxIdleEvent& aEvent );
348
349 void onTextFilterChangedTimer( wxTimerEvent& aEvent );
350
360 wxString* aErrorMessages = nullptr );
361
362 void refreshAfterSymbolSearch( COMPONENT* aSymbol );
363
364public:
366
367protected:
369 bool m_skipComponentSelect; // skip component selection event during
370 // automatic selection/deletion of associations
371
372 bool m_initialized; // true after creating widgets.
373 bool m_cannotClose; // true when the cvpcb frame cannot be closed
374 // (mainly during reading a netlist sent by Eeschema)
375
376private:
377 friend struct CV::IFACE;
378
385 wxTextCtrl* m_tcFilterString;
386 wxStaticText* m_statusLine1;
387 wxStaticText* m_statusLine2;
388 wxStaticText* m_statusLine3;
390
392
393 // Context menus for the list boxes
396
399
402
403};
404
405#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:110
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
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
void doReCreateMenuBar() override
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:279
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