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 
70  wxTextCtrl* m_tcFilterString;
71  wxStaticText* m_statusLine1;
72  wxStaticText* m_statusLine2;
73  wxStaticText* m_statusLine3;
74  wxButton* m_saveAndContinue;
75 
76 public:
78 
79 protected:
80  bool m_modified;
81  bool m_skipComponentSelect; // skip component selection event during
82  // automatic selection/deletion of
83  // associations
84 
86 
87  CVPCB_MAINFRAME( KIWAY* aKiway, wxWindow* aParent );
88 
89  void setupUIConditions() override;
90 
91 public:
93 
94  bool OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl=0 ) override;
95 
96  void KiwayMailIn( KIWAY_EXPRESS& aEvent ) override;
97 
102  {
106  };
107 
112  {
117  };
118 
123  {
126  };
127 
131  enum ITEM_DIR
132  {
135  };
136 
142  bool IsContentModified() override
143  {
144  return m_modified;
145  }
146 
151 
152  wxWindow* GetToolCanvas() const override;
153 
160 
166  wxControl* GetFocusedControlObject() const;
167 
174 
182  void OnSelectComponent( wxListEvent& event );
183 
184  bool canCloseWindow( wxCloseEvent& aCloseEvent ) override;
185  void doCloseWindow() override;
186 
187  /*
188  * Functions to rebuild the toolbars and menubars
189  */
190  void ReCreateHToolbar();
191  void ReCreateMenuBar() override;
192 
193  void ShowChangedLanguage() override;
194 
204 
212  void SetFootprintFilter(
214 
219  void OnEnterFilteringText( wxCommandEvent& event );
220 
221 
225  void UndoAssociation();
226 
230  void RedoAssociation();
231 
232  int GetUndoCommandCount() const override
233  {
234  return m_undoList.size();
235  }
236 
237  int GetRedoCommandCount() const override
238  {
239  return m_redoList.size();
240  }
241 
253  void AssociateFootprint( const CVPCB_ASSOCIATION& aAssociation, bool aNewEntry = true,
254  bool aAddUndoItem = true );
255 
256  /*
257  * Functions to build the listboxes and their contents
258  */
259  void BuildSymbolsListBox();
260  void BuildFootprintsListBox();
261  void BuildLibrariesListBox();
262 
269  bool SaveFootprintAssociation( bool doSaveSchematic );
270 
278  bool ReadNetListAndFpFiles( const std::string& aNetlist );
279 
287  int ReadSchematicNetlist( const std::string& aNetlist );
288 
289  void LoadSettings( APP_SETTINGS_BASE* aCfg ) override;
290 
291  void SaveSettings( APP_SETTINGS_BASE* aCfg ) override;
292 
305  void DisplayStatus();
306 
317  bool LoadFootprintFiles();
318 
327  void SendMessageToEESCHEMA( bool aClearHighligntOnly = false );
328 
335 
342  void SetSelectedComponent( int aIndex, bool aSkipUpdate = false );
343 
347  enum CRITERIA
348  {
353  };
354 
362  std::vector<unsigned int> GetComponentIndices(
364 
369  wxString GetSelectedFootprint();
370 
371  void SetStatusText( const wxString& aText, int aNumber = 0 ) override;
372 
373 private:
377  void setupTools();
378 
382  void setupEventHandlers();
383 
391  int buildEquivalenceList( FOOTPRINT_EQUIVALENCE_LIST& aList, wxString * aErrorMessages = NULL );
392 
393  void refreshAfterSymbolSearch( COMPONENT* aSymbol );
394 
395  // Tool dispatcher
397 
398  // Context menus for the list boxes
401 
402  // Undo/Redo item lists
405 };
406 
407 #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:61
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:47
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.
Definition: cvpcb.cpp:41
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
Save common frame parameters to a configuration data file.
wxStaticText * m_statusLine3
COMPONENTS_LISTBOX * m_symbolsListBox
bool LoadFootprintFiles()
Function LoadFootprintFiles reads the list of footprint (*.mod files) and generate the list of footpr...
ACTION_MENU * m_symbolsContextMenu
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.
void refreshAfterSymbolSearch(COMPONENT *aSymbol)
wxTextCtrl * m_tcFilterString
void OnSelectComponent(wxListEvent &event)
Function OnSelectComponent Called when clicking on a component in component list window.
FP_FILTER_T
Filter setting constants.
Definition: listboxes.h:94
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:205
#define NULL
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.
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:83
int buildEquivalenceList(FOOTPRINT_EQUIVALENCE_LIST &aList, wxString *aErrorMessages=NULL)
read the .equ files and populate the list of equvalents
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)
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.
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.
LIBRARY_LISTBOX * m_librariesListBox
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...