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 
56 #define CMP_FORMAT wxT( "%3d %8s - %16s : %s" )
57 
62 {
63 public:
65 
66  bool OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl=0 ) override;
67 
68  void KiwayMailIn( KIWAY_EXPRESS& aEvent ) override;
69 
74  {
78  };
79 
84  {
89  };
90 
94  enum FOCUS_DIR
95  {
98  };
99 
103  enum ITEM_DIR
104  {
107  };
108 
114  bool IsContentModified() const override
115  {
116  return m_modified;
117  }
118 
123 
124  wxWindow* GetToolCanvas() const override;
125 
132 
138  wxControl* GetFocusedControlObject() const;
139 
146 
153  void OnSelectComponent( wxListEvent& event );
154 
155  bool canCloseWindow( wxCloseEvent& aCloseEvent ) override;
156  void doCloseWindow() override;
157 
158  /*
159  * Functions to rebuild the toolbars and menubars
160  */
161  void ReCreateHToolbar();
162  void ReCreateMenuBar() override;
163 
164  void ShowChangedLanguage() override;
165 
175 
184 
188  void OnEnterFilteringText( wxCommandEvent& event );
189 
193  void UndoAssociation();
194 
198  void RedoAssociation();
199 
200  int GetUndoCommandCount() const override
201  {
202  return m_undoList.size();
203  }
204 
205  int GetRedoCommandCount() const override
206  {
207  return m_redoList.size();
208  }
209 
221  void AssociateFootprint( const CVPCB_ASSOCIATION& aAssociation, bool aNewEntry = true,
222  bool aAddUndoItem = true );
223 
224  /*
225  * Functions to build the listboxes and their contents
226  */
227  void BuildSymbolsListBox();
228  void BuildFootprintsListBox();
229  void BuildLibrariesListBox();
230 
236  bool SaveFootprintAssociation( bool doSaveSchematic );
237 
245  bool ReadNetListAndFpFiles( const std::string& aNetlist );
246 
254  int ReadSchematicNetlist( const std::string& aNetlist );
255 
256  void LoadSettings( APP_SETTINGS_BASE* aCfg ) override;
257 
258  void SaveSettings( APP_SETTINGS_BASE* aCfg ) override;
259 
271  void DisplayStatus();
272 
283  bool LoadFootprintFiles();
284 
294  void SendMessageToEESCHEMA( bool aClearHighligntOnly = false );
295 
302 
309  void SetSelectedComponent( int aIndex, bool aSkipUpdate = false );
310 
314  enum CRITERIA
315  {
320  };
321 
329  std::vector<unsigned int> GetComponentIndices(
331 
336  wxString GetSelectedFootprint();
337 
338  void SetStatusText( const wxString& aText, int aNumber = 0 ) override;
339 
340 protected:
341  CVPCB_MAINFRAME( KIWAY* aKiway, wxWindow* aParent );
342 
343  void setupUIConditions() override;
344 
345 private:
349  void setupTools();
350 
354  void setupEventHandlers();
355 
365  wxString* aErrorMessages = nullptr );
366 
367  void refreshAfterSymbolSearch( COMPONENT* aSymbol );
368 
369 public:
371 
372 protected:
374  bool m_skipComponentSelect; // skip component selection event during
375  // automatic selection/deletion of
376  // associations
377 
379 
380 private:
381  friend struct CV::IFACE;
382 
389  wxTextCtrl* m_tcFilterString;
390  wxStaticText* m_statusLine1;
391  wxStaticText* m_statusLine2;
392  wxStaticText* m_statusLine3;
393  wxButton* m_saveAndContinue;
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: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
COMPONENTS_LISTBOX * m_symbolsListBox
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.
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.
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.