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-2018 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;
42 
43 namespace CV { struct IFACE; }
44 
45 // The undo/redo list is composed of vectors of associations
46 typedef std::vector< CVPCB_ASSOCIATION > CVPCB_UNDO_REDO_ENTRIES;
47 
48 // The undo list is a vector of undo entries
49 typedef std::vector< CVPCB_UNDO_REDO_ENTRIES > CVPCB_UNDO_REDO_LIST;
50 
55 #define CMP_FORMAT wxT( "%3d %8s - %16s : %s" )
56 
61 {
62  friend struct CV::IFACE;
63 
71  wxTextCtrl* m_tcFilterString;
72  wxStaticText* m_statusLine1;
73  wxStaticText* m_statusLine2;
74  wxStaticText* m_statusLine3;
75  wxButton* m_saveAndContinue;
76 
77 public:
78  wxArrayString m_ModuleLibNames;
79  wxArrayString m_EquFilesNames;
80 
82 
83 protected:
84  bool m_modified;
85  bool m_skipComponentSelect; // skip component selection event during
86  // automatic selection/deletion of
87  // associations
88  std::vector<PARAM_CFG*> m_projectFileParams;
89 
91 
92  CVPCB_MAINFRAME( KIWAY* aKiway, wxWindow* aParent );
93 
94 public:
96 
97  bool OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl=0 ) override;
98 
99  void KiwayMailIn( KIWAY_EXPRESS& aEvent ) override;
100 
105  {
109  };
110 
115  {
120  };
121 
126  {
129  };
130 
134  enum ITEM_DIR
135  {
138  };
139 
145  bool IsContentModified() override
146  {
147  return m_modified;
148  }
149 
154 
161 
167  wxControl* GetFocusedControlObject();
168 
175 
183  void OnSelectComponent( wxListEvent& event );
184 
190  void OnCloseWindow( wxCloseEvent& Event );
191 
192  /*
193  * Functions to rebuild the toolbars and menubars
194  */
195  void ReCreateHToolbar();
196  void ReCreateMenuBar() override;
197 
198  void ShowChangedLanguage() override;
199 
209 
217  void SetFootprintFilter(
219 
224  void OnEnterFilteringText( wxCommandEvent& event );
225 
226 
230  void UndoAssociation();
231 
235  void RedoAssociation();
236 
248  void AssociateFootprint( const CVPCB_ASSOCIATION& aAssociation, bool aNewEntry = true,
249  bool aAddUndoItem = true );
250 
251  /*
252  * Functions to build the listboxes and their contents
253  */
254  void BuildCmpListBox();
256  void BuildLIBRARY_LISTBOX();
257 
264  bool SaveFootprintAssociation( bool doSaveSchematic );
265 
273  bool ReadNetListAndFpFiles( const std::string& aNetlist );
274 
282  int ReadSchematicNetlist( const std::string& aNetlist );
283 
288  void LoadProjectFile();
289 
294  void SaveProjectFile();
295 
296  void LoadSettings( wxConfigBase* aCfg ) override;
297 
298  void SaveSettings( wxConfigBase* aCfg ) override;
299 
312  void DisplayStatus();
313 
325  bool LoadFootprintFiles();
326 
340  std::vector<PARAM_CFG*>& GetProjectFileParameters( void );
341 
350  void SendMessageToEESCHEMA( bool aClearHighligntOnly = false );
351 
358 
365  void SetSelectedComponent( int aIndex, bool aSkipUpdate = false );
366 
370  enum CRITERIA
371  {
376  };
377 
385  std::vector<unsigned int> GetComponentIndices(
387 
392  wxString GetSelectedFootprint();
393 
394  void SetStatusText( const wxString& aText, int aNumber = 0 ) override;
395 
399  void SyncToolbars() override;
400 
401 private:
405  void setupTools();
406 
410  void setupEventHandlers();
411 
419  int buildEquivalenceList( FOOTPRINT_EQUIVALENCE_LIST& aList, wxString * aErrorMessages = NULL );
420 
421  void refreshAfterComponentSearch (COMPONENT* component);
422 
423  // Tool dispatcher
425 
426  // Context menus for the list boxes
429 
430  // Undo/Redo item lists
433 };
434 
435 #endif //#ifndef _CVPCB_MAINFRAME_H_
void AutomaticFootprintMatching()
Called by the automatic association button Read *.equ files to try to find corresponding footprint fo...
ACTION_TOOLBAR.
KIWAY_PLAYER is a wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of ...
Definition: kiway_player.h:59
KIWAY_EXPRESS carries a payload from one KIWAY_PLAYER to another within a PROJECT.
Definition: kiway_express.h:39
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
wxControl * GetFocusedControlObject()
Get a pointer to the currently focused control.
wxArrayString m_EquFilesNames
ACTION_MENU.
Definition: action_menu.h:43
COMPONENTS_LISTBOX * m_compListBox
void SendMessageToEESCHEMA(bool aClearHighligntOnly=false)
Function SendMessageToEESCHEMA Send a remote command to Eeschema via a socket, Commands are $PART: "r...
void UndoAssociation()
Undo the most recent associations that were performed.
wxString m_currentSearchPattern
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.
The common library.
int ReadSchematicNetlist(const std::string &aNetlist)
Function ReadSchematicNetlist 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.
wxStaticText * m_statusLine3
std::vector< PARAM_CFG * > & GetProjectFileParameters(void)
Function GetProjectFileParameters return project file parameter list for CvPcb.
Definition: cfg.cpp:36
void SyncToolbars() override
Syncronize the toolbar state with the current tool state.
bool LoadFootprintFiles()
Function LoadFootprintFiles reads the list of footprint (*.mod files) and generate the list of footpr...
DISPLAY_FOOTPRINTS_FRAME is used to display footprints.
void LoadSettings(wxConfigBase *aCfg) override
Load common frame parameters from a configuration file.
bool IsContentModified() override
Get if the current associations have been modified but not saved.
void ShowChangedLanguage() override
Redraw the menus and what not in current language.
wxTextCtrl * m_tcFilterString
void OnSelectComponent(wxListEvent &event)
Function OnSelectComponent Called when clicking on a component in component list window.
void refreshAfterComponentSearch(COMPONENT *component)
void SaveSettings(wxConfigBase *aCfg) override
Saves common frame parameters to a configuration data file.
FP_FILTER_T
Filter setting constants.
Definition: listboxes.h:94
NETLIST stores all of information read from a netlist along with the flags used to update the NETLIST...
Definition: pcb_netlist.h:217
#define NULL
bool OpenProjectFiles(const std::vector< wxString > &aFileSet, int aCtl=0) override
Function OpenProjectFiles is abstract, and opens 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
wxArrayString m_ModuleLibNames
void KiwayMailIn(KIWAY_EXPRESS &aEvent) override
Function KiwayMailIn receives KIWAY_EXPRESS messages from other players.
std::vector< PARAM_CFG * > m_projectFileParams
No controls have focus.
ACTION_MENU * m_componentContextMenu
KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the s...
Definition: kiway.h:274
void SetStatusText(const wxString &aText, int aNumber=0) override
CRITERIA
Criteria to use to identify sets of components.
void ReCreateMenuBar() override
Recreates the menu bar.
void BuildFOOTPRINTS_LISTBOX()
CVPCB_UNDO_REDO_LIST m_undoList
TOOL_DISPATCHER * m_toolDispatcher
LIBRARY_LISTBOX * m_libListBox
TOOL_DISPATCHER.
FOCUS_DIR
Directions to rotate the focus through the listboxes is.
COMPONENT is used to store components and all of their related information found in a netlist.
Definition: pcb_netlist.h:85
int buildEquivalenceList(FOOTPRINT_EQUIVALENCE_LIST &aList, wxString *aErrorMessages=NULL)
read the .equ files and populate the list of equvalents
wxStaticText * m_statusLine2
void OnCloseWindow(wxCloseEvent &Event)
OnCloseWindow.
wxString GetSelectedFootprint()
DISPLAY_FOOTPRINTS_FRAME * GetFootprintViewerFrame()
Holds a list of FOOTPRINT_INFO objects, along with a list of IO_ERRORs or PARSE_ERRORs that were thro...
void SaveProjectFile()
Function SaveProjectFile Saves the CvPcb configuration parameter from the project (....
Definition: cfg.cpp:61
bool ReadNetListAndFpFiles(const std::string &aNetlist)
Function ReadNetListAndFpFiles loads the netlist file built on the fly by Eeschema and loads footprin...
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.
CVPCB_MAINFRAME::CONTROL_TYPE GetFocusedControl()
Find out which control currently has focus.
void SetFootprintFilter(FOOTPRINTS_LISTBOX::FP_FILTER_T aFilter, CVPCB_MAINFRAME::CVPCB_FILTER_ACTION aAction)
Function SetFootprintFilter 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)
Function OnEnterFilteringText Is called each time the text of m_tcFilterString is changed.
Not associated components.
void DisplayStatus()
Function DisplayStatus updates the information displayed on the status bar at bottom of the main fram...
void LoadProjectFile()
Function LoadProjectFile reads the CvPcb configuration parameter from the project (....
Definition: cfg.cpp:50
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)
Function SaveFootprintAssociation saves the edits that the user has done by sending them back to eesc...