KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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-2023 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 <kiway_player.h>
30
31#include <auto_associate.h>
32#include <cvpcb_association.h>
33#include <listboxes.h>
34
35/* Forward declarations */
36class ACTION_TOOLBAR;
37class ACTION_MENU;
38class TOOL_DISPATCHER;
39class wxAuiToolBar;
40class wxStaticText;
42
43namespace CV { struct IFACE; }
44
45// The undo/redo list is composed of vectors of associations
46typedef std::vector< CVPCB_ASSOCIATION > CVPCB_UNDO_REDO_ENTRIES;
47
48// The undo list is a vector of undo entries
49typedef std::vector< CVPCB_UNDO_REDO_ENTRIES > CVPCB_UNDO_REDO_LIST;
50
51
56{
57public:
59
60 bool OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl=0 ) override;
61
62 void KiwayMailIn( KIWAY_EXPRESS& aEvent ) override;
63
68 {
72 };
73
78 {
83 };
84
89 {
92 };
93
98 {
100 ITEM_PREV
101 };
102
108 bool IsContentModified() const override
109 {
110 return m_modified;
111 }
112
117
118 wxWindow* GetToolCanvas() const override;
119
126
133
140 void OnSelectComponent( wxListEvent& event );
141
142 /*
143 * Functions to rebuild the toolbars and menubars
144 */
145 void ReCreateHToolbar();
146
147 void ShowChangedLanguage() override;
148
158
167
171 void UndoAssociation();
172
176 void RedoAssociation();
177
178 int GetUndoCommandCount() const override
179 {
180 return m_undoList.size();
181 }
182
183 int GetRedoCommandCount() const override
184 {
185 return m_redoList.size();
186 }
187
188 // Cvpcb does not handle a undo/redo description (it does not use a UNDO_REDO_CONTAINER,
189 // but a CVPCB_UNDO_REDO_LIST to store the undo/redo commands)
190 wxString GetUndoActionDescription() const override
191 {
192 return wxEmptyString;
193 }
194
195 wxString GetRedoActionDescription() const override
196 {
197 return wxEmptyString;
198 }
199
211 void AssociateFootprint( const CVPCB_ASSOCIATION& aAssociation, bool aNewEntry = true,
212 bool aAddUndoItem = true );
213
214 /*
215 * Functions to build the listbox contents
216 */
217 void BuildFootprintsList();
218 void BuildLibrariesList();
219
225 bool SaveFootprintAssociation( bool doSaveSchematic );
226
227 void LoadSettings( APP_SETTINGS_BASE* aCfg ) override;
228
229 void SaveSettings( APP_SETTINGS_BASE* aCfg ) override;
230
242 void DisplayStatus();
243
254 bool LoadFootprintFiles();
255
265 void SendComponentSelectionToSch( bool aClearSelectionOnly = false );
266
273
280 void SetSelectedComponent( int aIndex, bool aSkipUpdate = false );
281
286 {
291 };
292
300 std::vector<unsigned int> GetComponentIndices(
302
307 wxString GetSelectedFootprint();
308
310
311 void SetStatusText( const wxString& aText, int aNumber = 0 ) override;
312
313protected:
314 CVPCB_MAINFRAME( KIWAY* aKiway, wxWindow* aParent );
315
316 void doReCreateMenuBar() override;
317
318 void setupUIConditions() override;
319
320 bool canCloseWindow( wxCloseEvent& aCloseEvent ) override;
321 void doCloseWindow() override;
322
330 bool readNetListAndFpFiles( const std::string& aNetlist );
331
339 int readSchematicNetlist( const std::string& aNetlist );
340
341private:
342 wxString formatSymbolDesc( int idx, const wxString& aReference, const wxString& aValue,
343 const wxString& aFootprint );
344
348 void setupTools();
349
353 void setupEventHandlers();
354
355 void onTextFilterChanged( wxCommandEvent& event );
356
357 void updateFootprintViewerOnIdle( wxIdleEvent& aEvent );
358
359 void onTextFilterChangedTimer( wxTimerEvent& aEvent );
360
370 wxString* aErrorMessages = nullptr );
371
372 void refreshAfterSymbolSearch( COMPONENT* aSymbol );
373
374public:
376
377protected:
379 bool m_skipComponentSelect; // skip component selection event during
380 // automatic selection/deletion of associations
381
382 bool m_initialized; // true after creating widgets.
383 bool m_cannotClose; // true when the cvpcb frame cannot be closed
384 // (mainly during reading a netlist sent by Eeschema)
385
386private:
387 friend struct CV::IFACE;
388
395 wxTextCtrl* m_tcFilterString;
396 wxStaticText* m_statusLine1;
397 wxStaticText* m_statusLine2;
398 wxStaticText* m_statusLine3;
400
402
403 // Context menus for the list boxes
406
409
412
413};
414
415#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:92
Store all of the related footprint information found in a netlist.
Definition: pcb_netlist.h:88
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
wxString GetUndoActionDescription() const override
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.
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.
wxString GetRedoActionDescription() const override
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:40
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
Definition: kiway_player.h:65
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition: kiway.h:284
Store information read from a netlist along with the flags used to update the NETLIST in the BOARD.
Definition: pcb_netlist.h:241
std::vector< CVPCB_UNDO_REDO_ENTRIES > CVPCB_UNDO_REDO_LIST
std::vector< CVPCB_ASSOCIATION > CVPCB_UNDO_REDO_ENTRIES
Definition: cvpcb.cpp:39