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:
79 
80 protected:
81  bool m_modified;
82  bool m_skipComponentSelect; // skip component selection event during
83  // automatic selection/deletion of
84  // associations
85 
87 
88  CVPCB_MAINFRAME( KIWAY* aKiway, wxWindow* aParent );
89 
90 public:
92 
93  bool OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl=0 ) override;
94 
95  void KiwayMailIn( KIWAY_EXPRESS& aEvent ) override;
96 
101  {
105  };
106 
111  {
116  };
117 
122  {
125  };
126 
130  enum ITEM_DIR
131  {
134  };
135 
141  bool IsContentModified() override
142  {
143  return m_modified;
144  }
145 
150 
151  wxWindow* GetToolCanvas() const override;
152 
159 
165  wxControl* GetFocusedControlObject();
166 
173 
181  void OnSelectComponent( wxListEvent& event );
182 
188  void OnCloseWindow( wxCloseEvent& Event );
189 
190  /*
191  * Functions to rebuild the toolbars and menubars
192  */
193  void ReCreateHToolbar();
194  void ReCreateMenuBar() override;
195 
196  void ShowChangedLanguage() override;
197 
207 
215  void SetFootprintFilter(
217 
222  void OnEnterFilteringText( wxCommandEvent& event );
223 
224 
228  void UndoAssociation();
229 
233  void RedoAssociation();
234 
246  void AssociateFootprint( const CVPCB_ASSOCIATION& aAssociation, bool aNewEntry = true,
247  bool aAddUndoItem = true );
248 
249  /*
250  * Functions to build the listboxes and their contents
251  */
252  void BuildCmpListBox();
254  void BuildLIBRARY_LISTBOX();
255 
262  bool SaveFootprintAssociation( bool doSaveSchematic );
263 
271  bool ReadNetListAndFpFiles( const std::string& aNetlist );
272 
280  int ReadSchematicNetlist( const std::string& aNetlist );
281 
282  void LoadSettings( APP_SETTINGS_BASE* aCfg ) override;
283 
284  void SaveSettings( APP_SETTINGS_BASE* aCfg ) override;
285 
298  void DisplayStatus();
299 
311  bool LoadFootprintFiles();
312 
321  void SendMessageToEESCHEMA( bool aClearHighligntOnly = false );
322 
329 
336  void SetSelectedComponent( int aIndex, bool aSkipUpdate = false );
337 
341  enum CRITERIA
342  {
347  };
348 
356  std::vector<unsigned int> GetComponentIndices(
358 
363  wxString GetSelectedFootprint();
364 
365  void SetStatusText( const wxString& aText, int aNumber = 0 ) override;
366 
370  void SyncToolbars() override;
371 
372 private:
376  void setupTools();
377 
381  void setupEventHandlers();
382 
390  int buildEquivalenceList( FOOTPRINT_EQUIVALENCE_LIST& aList, wxString * aErrorMessages = NULL );
391 
392  void refreshAfterComponentSearch (COMPONENT* component);
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...
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.
ACTION_MENU.
Definition: action_menu.h:44
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.
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.
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Saves common frame parameters to a configuration data file.
wxStaticText * m_statusLine3
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.
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)
FP_FILTER_T
Filter setting constants.
Definition: listboxes.h:94
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:91
NETLIST stores all of information read from a netlist along with the flags used to update the NETLIST...
Definition: pcb_netlist.h:212
#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
void KiwayMailIn(KIWAY_EXPRESS &aEvent) override
Function KiwayMailIn receives 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.
ACTION_MENU * m_componentContextMenu
KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the s...
Definition: kiway.h:273
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:80
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()
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)
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.
wxWindow * GetToolCanvas() const override
Canvas access.
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.
DISPLAY_FOOTPRINTS_FRAME * GetFootprintViewerFrame() const
void DisplayStatus()
Function DisplayStatus updates the information displayed on the status bar at bottom of the main fram...
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...