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 */
37 class ACTION_TOOLBAR;
38 class ACTION_MENU;
39 class TOOL_DISPATCHER;
40 class wxAuiToolBar;
41 class wxStaticText;
43 
44 namespace CV { struct IFACE; }
45 
46 // The undo/redo list is composed of vectors of associations
47 typedef std::vector< CVPCB_ASSOCIATION > CVPCB_UNDO_REDO_ENTRIES;
48 
49 // The undo list is a vector of undo entries
50 typedef std::vector< CVPCB_UNDO_REDO_ENTRIES > CVPCB_UNDO_REDO_LIST;
51 
52 
57 {
58 public:
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 
89  enum FOCUS_DIR
90  {
93  };
94 
98  enum ITEM_DIR
99  {
102  };
103 
109  bool IsContentModified() const override
110  {
111  return m_modified;
112  }
113 
118 
119  wxWindow* GetToolCanvas() const override;
120 
127 
133  wxControl* GetFocusedControlObject() const;
134 
141 
148  void OnSelectComponent( wxListEvent& event );
149 
150  bool canCloseWindow( wxCloseEvent& aCloseEvent ) override;
151  void doCloseWindow() override;
152 
153  /*
154  * Functions to rebuild the toolbars and menubars
155  */
156  void ReCreateHToolbar();
157  void ReCreateMenuBar() override;
158 
159  void ShowChangedLanguage() override;
160 
170 
179 
183  void OnEnterFilteringText( wxCommandEvent& event );
184 
188  void UndoAssociation();
189 
193  void RedoAssociation();
194 
195  int GetUndoCommandCount() const override
196  {
197  return m_undoList.size();
198  }
199 
200  int GetRedoCommandCount() const override
201  {
202  return m_redoList.size();
203  }
204 
216  void AssociateFootprint( const CVPCB_ASSOCIATION& aAssociation, bool aNewEntry = true,
217  bool aAddUndoItem = true );
218 
219  /*
220  * Functions to build the listboxes and their contents
221  */
222  void BuildSymbolsListBox();
223  void BuildFootprintsListBox();
224  void BuildLibrariesListBox();
225 
231  bool SaveFootprintAssociation( bool doSaveSchematic );
232 
240  bool ReadNetListAndFpFiles( const std::string& aNetlist );
241 
249  int ReadSchematicNetlist( const std::string& aNetlist );
250 
251  void LoadSettings( APP_SETTINGS_BASE* aCfg ) override;
252 
253  void SaveSettings( APP_SETTINGS_BASE* aCfg ) override;
254 
266  void DisplayStatus();
267 
278  bool LoadFootprintFiles();
279 
289  void SendMessageToEESCHEMA( bool aClearHighligntOnly = false );
290 
297 
304  void SetSelectedComponent( int aIndex, bool aSkipUpdate = false );
305 
309  enum CRITERIA
310  {
315  };
316 
324  std::vector<unsigned int> GetComponentIndices(
326 
331  wxString GetSelectedFootprint();
332 
333  void SetStatusText( const wxString& aText, int aNumber = 0 ) override;
334 
335 protected:
336  CVPCB_MAINFRAME( KIWAY* aKiway, wxWindow* aParent );
337 
338  void setupUIConditions() override;
339 
340 private:
341  wxString formatSymbolDesc( int idx, const wxString& aReference, const wxString& aValue,
342  const wxString& aFootprint );
343 
347  void setupTools();
348 
352  void setupEventHandlers();
353 
363  wxString* aErrorMessages = nullptr );
364 
365  void refreshAfterSymbolSearch( COMPONENT* aSymbol );
366 
367 public:
369 
370 protected:
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 
379 private:
380  friend struct CV::IFACE;
381 
388  wxTextCtrl* m_tcFilterString;
389  wxStaticText* m_statusLine1;
390  wxStaticText* m_statusLine2;
391  wxStaticText* m_statusLine3;
392  wxButton* m_saveAndContinue;
393 
394  // Tool dispatcher
396 
397  // Context menus for the list boxes
400 
401  // Undo/Redo item lists
404 };
405 
406 #endif //#ifndef _CVPCB_MAINFRAME_H_
void AutomaticFootprintMatching()
Called by the automatic association button Read *.equ files to try to find corresponding footprint fo...
Define the structure of a toolbar with buttons that invoke ACTIONs.
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
Definition: kiway_player.h:64
bool canCloseWindow(wxCloseEvent &aCloseEvent) override
Carry a payload from one KIWAY_PLAYER to another within a PROJECT.
Definition: kiway_express.h:38
CONTROL_TYPE
The type of the controls present in the application.
FOOTPRINT_LIST * m_FootprintsList
CVPCB_FILTER_ACTION
The action to apply to a footprint filter when it is modified.
ACTION_MENU * m_footprintContextMenu
Defines the structure of a menu based on ACTIONs.
Definition: action_menu.h:48
void SendMessageToEESCHEMA(bool aClearHighligntOnly=false)
Send a remote command to Eeschema via a socket,.
void UndoAssociation()
Undo the most recent associations that were performed.
Definition: cvpcb.cpp:38
void AssociateFootprint(const CVPCB_ASSOCIATION &aAssociation, bool aNewEntry=true, bool aAddUndoItem=true)
Associate a footprint with a specific component in the list.
void setupEventHandlers()
Setup event handlers.
void RedoAssociation()
Redo the most recently undone association.
int ReadSchematicNetlist(const std::string &aNetlist)
Read the netlist (.net) file built on the fly by Eeschema.
void SetFocusedControl(CVPCB_MAINFRAME::CONTROL_TYPE aControl)
Set the focus to a specific control.
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
wxStaticText * m_statusLine3
bool LoadFootprintFiles()
Read the list of footprint (*.mod files) and generate the list of footprints.
bool IsContentModified() const override
Get if the current associations have been modified but not saved.
ACTION_MENU * m_symbolsContextMenu
void ShowChangedLanguage() override
void refreshAfterSymbolSearch(COMPONENT *aSymbol)
wxTextCtrl * m_tcFilterString
void OnSelectComponent(wxListEvent &event)
Called when clicking on a component in component list window:
FP_FILTER_T
Filter setting constants.
Definition: listboxes.h:91
CVPCB_MAINFRAME::CONTROL_TYPE GetFocusedControl() const
Find out which control currently has focus.
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:99
Store information read from a netlist along with the flags used to update the NETLIST in the BOARD.
Definition: pcb_netlist.h:206
bool OpenProjectFiles(const std::vector< wxString > &aFileSet, int aCtl=0) override
Open a project or set of files given by aFileList.
void SetSelectedComponent(int aIndex, bool aSkipUpdate=false)
Set the currently selected component in the components listbox.
boost::ptr_vector< FOOTPRINT_EQUIVALENCE > FOOTPRINT_EQUIVALENCE_LIST
ACTION_TOOLBAR * m_mainToolBar
int GetUndoCommandCount() const override
void KiwayMailIn(KIWAY_EXPRESS &aEvent) override
Receive KIWAY_EXPRESS messages from other players.
No controls have focus.
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
SYMBOLS_LISTBOX * m_symbolsListBox
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition: kiway.h:260
void SetStatusText(const wxString &aText, int aNumber=0) override
CRITERIA
Criteria to use to identify sets of components.
int GetRedoCommandCount() const override
void ReCreateMenuBar() override
Recreates the menu bar.
CVPCB_UNDO_REDO_LIST m_undoList
wxControl * GetFocusedControlObject() const
Get a pointer to the currently focused control.
TOOL_DISPATCHER * m_toolDispatcher
FOCUS_DIR
Directions to rotate the focus through the listboxes is.
Store all of the related footprint information found in a netlist.
Definition: pcb_netlist.h:84
wxStaticText * m_statusLine2
void setupUIConditions() override
Setup the UI conditions for the various actions and their controls in this frame.
wxString GetSelectedFootprint()
void doCloseWindow() override
Holds a list of FOOTPRINT_INFO objects, along with a list of IO_ERRORs or PARSE_ERRORs that were thro...
bool ReadNetListAndFpFiles(const std::string &aNetlist)
Load the netlist file built on the fly by Eeschema and loads footprint libraries from fp lib tables.
CVPCB_MAINFRAME(KIWAY *aKiway, wxWindow *aParent)
std::vector< CVPCB_UNDO_REDO_ENTRIES > CVPCB_UNDO_REDO_LIST
CVPCB_UNDO_REDO_LIST m_redoList
ITEM_DIR
Directions to move when selecting items.
COMPONENT * GetSelectedComponent()
Get the selected component from the component listbox.
Toggle the filter state.
FOOTPRINTS_LISTBOX * m_footprintListBox
A class to define a footprint association to be made in cvpcb.
wxString formatSymbolDesc(int idx, const wxString &aReference, const wxString &aValue, const wxString &aFootprint)
wxWindow * GetToolCanvas() const override
Canvas access.
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.
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 OnEnterFilteringText(wxCommandEvent &event)
Called each time the text of m_tcFilterString is changed.
Not associated components.
LIBRARY_LISTBOX * m_librariesListBox
DISPLAY_FOOTPRINTS_FRAME * GetFootprintViewerFrame() const
void DisplayStatus()
Update the information displayed on the status bar at bottom of the main frame.
int buildEquivalenceList(FOOTPRINT_EQUIVALENCE_LIST &aList, wxString *aErrorMessages=nullptr)
Read the .equ files and populate the list of equivalents.
wxButton * m_saveAndContinue
void setupTools()
Setup the tool system for the CVPCB main frame.
The CvPcb application main window.
wxStaticText * m_statusLine1
std::vector< CVPCB_ASSOCIATION > CVPCB_UNDO_REDO_ENTRIES
bool SaveFootprintAssociation(bool doSaveSchematic)
Save the edits that the user has done by sending them back to Eeschema via the kiway.