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 The 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, see <https://www.gnu.org/licenses/>.
19 */
20
21#ifndef _CVPCB_MAINFRAME_H_
22#define _CVPCB_MAINFRAME_H_
23
24#include <kiway_player.h>
26
27#include <auto_associate.h>
28#include <cvpcb_association.h>
29#include <listboxes.h>
30
31/* Forward declarations */
32class ACTION_TOOLBAR;
33class ACTION_MENU;
34class TOOL_DISPATCHER;
35class wxAuiToolBar;
36class wxStaticText;
38
39namespace CV { struct IFACE; }
40
41// The undo/redo list is composed of vectors of associations
42typedef std::vector< CVPCB_ASSOCIATION > CVPCB_UNDO_REDO_ENTRIES;
43
44// The undo list is a vector of undo entries
45typedef std::vector< CVPCB_UNDO_REDO_ENTRIES > CVPCB_UNDO_REDO_LIST;
46
47
52{
53public:
55
56 bool OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl=0 ) override;
57
58 void KiwayMailIn( KIWAY_MAIL_EVENT& aEvent ) override;
59
69
80
89
98
104 bool IsContentModified() const override
105 {
106 return m_modified;
107 }
108
113
114 wxWindow* GetToolCanvas() const override;
115
122
129
136 void OnSelectComponent( wxListEvent& event );
137
138 void ShowChangedLanguage() override;
139
149
158
162 void UndoAssociation();
163
167 void RedoAssociation();
168
169 int GetUndoCommandCount() const override
170 {
171 return m_undoList.size();
172 }
173
174 int GetRedoCommandCount() const override
175 {
176 return m_redoList.size();
177 }
178
179 // Cvpcb does not handle a undo/redo description (it does not use a UNDO_REDO_CONTAINER,
180 // but a CVPCB_UNDO_REDO_LIST to store the undo/redo commands)
181 wxString GetUndoActionDescription() const override
182 {
183 return wxEmptyString;
184 }
185
186 wxString GetRedoActionDescription() const override
187 {
188 return wxEmptyString;
189 }
190
202 void AssociateFootprint( const CVPCB_ASSOCIATION& aAssociation, bool aNewEntry = true,
203 bool aAddUndoItem = true );
204
205 /*
206 * Functions to build the listbox contents
207 */
208 void BuildFootprintsList();
209 void BuildLibrariesList();
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
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 configureToolbars() override;
308
309 void doReCreateMenuBar() override;
310
311 void setupUIConditions() override;
312
313 bool canCloseWindow( wxCloseEvent& aCloseEvent ) override;
314 void doCloseWindow() override;
315
323 bool readNetListAndFpFiles( const std::string& aNetlist );
324
332 int readSchematicNetlist( const std::string& aNetlist );
333
334private:
335 wxString formatSymbolDesc( int idx, const wxString& aReference, const wxString& aValue,
336 const wxString& aFootprint );
337
341 void setupTools();
342
346 void setupEventHandlers();
347
348 void onTextFilterChanged( wxCommandEvent& event );
349
350 void updateFootprintViewerOnIdle( wxIdleEvent& aEvent );
351
352 void onTextFilterChangedTimer( wxTimerEvent& aEvent );
353
363 wxString* aErrorMessages = nullptr );
364
365 void refreshAfterSymbolSearch( COMPONENT* aSymbol );
366
367public:
369
370protected:
372 bool m_skipComponentSelect; // skip component selection event during
373 // automatic selection/deletion of associations
374
375 bool m_initialized; // true after creating widgets.
376 bool m_cannotClose; // true when the cvpcb frame cannot be closed
377 // (mainly during reading a netlist sent by Eeschema)
378
379private:
380 friend struct CV::IFACE;
381
387 wxTextCtrl* m_tcFilterString;
388 wxStaticText* m_statusLine1;
389 wxStaticText* m_statusLine2;
390 wxStaticText* m_statusLine3;
392
394
395 // Context menus for the list boxes
398
401
404
405};
406
407#endif //#ifndef _CVPCB_MAINFRAME_H_
boost::ptr_vector< FOOTPRINT_EQUIVALENCE > FOOTPRINT_EQUIVALENCE_LIST
Define the structure of a menu based on ACTIONs.
Definition action_menu.h:43
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.
Store all of the related component information found in a netlist.
A class to define a footprint association to be made in cvpcb.
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.
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.
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.
void KiwayMailIn(KIWAY_MAIL_EVENT &aEvent) override
Receive #KIWAY_ROUTED_EVENT messages from other players.
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.
void configureToolbars() override
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:95
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_mail.h:34
KIWAY_PLAYER(KIWAY *aKiway, wxWindow *aParent, FRAME_T aFrameType, const wxString &aTitle, const wxPoint &aPos, const wxSize &aSize, long aStyle, const wxString &aFrameName, const EDA_IU_SCALE &aIuScale)
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition kiway.h:311
Store information read from a netlist along with the flags used to update the NETLIST in the BOARD.
std::vector< CVPCB_UNDO_REDO_ENTRIES > CVPCB_UNDO_REDO_LIST
std::vector< CVPCB_ASSOCIATION > CVPCB_UNDO_REDO_ENTRIES
Definition cvpcb.cpp:34