KiCad PCB EDA Suite
kicad.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) 2013 CERN (www.cern.ch)
5  * Copyright (C) 2017 KiCad Developers, see CHANGELOG.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 
30 #ifndef KICAD_H
31 #define KICAD_H
32 
33 
34 #include <wx/process.h>
35 
36 #include <id.h>
37 #include <eda_base_frame.h>
38 #include <kiway_player.h>
39 
40 #define KICAD_MANAGER_FRAME_NAME wxT( "KicadFrame" )
41 
42 class LAUNCHER_PANEL;
43 class TREEPROJECTFILES;
44 class TREE_PROJECT_FRAME;
45 
46 // Identify the type of files handled by Kicad manager
47 //
48 // When changing this enum please verify (and perhaps update)
49 // TREE_PROJECT_FRAME::GetFileExt(),
50 // s_AllowedExtensionsToList[]
51 
54  TREE_SCHEMA, // Schematic file (.sch)
55  TREE_LEGACY_PCB, // board file (.brd) legacy format
56  TREE_SEXP_PCB, // board file (.kicad_brd) new s expression format
57  TREE_GERBER, // Gerber file (.pho, .g*)
58  TREE_HTML, // HTML file (.htm, *.html)
59  TREE_PDF, // PDF file (.pdf)
60  TREE_TXT, // ascii text file (.txt)
61  TREE_NET, // netlist file (.net)
64  TREE_CMP_LINK, // cmp/footprint link file (.cmp)
65  TREE_REPORT, // report file (.rpt)
66  TREE_FP_PLACE, // fooprints position (place) file (.pos)
67  TREE_DRILL, // Excellon drill file (.drl)
68  TREE_SVG, // SVG file (.svg)
69  TREE_PAGE_LAYOUT_DESCR, // Page layout and title block descr file (.kicad_wks)
70  TREE_FOOTPRINT_FILE, // footprint file (.kicad_mod)
71  TREE_SCHEMATIC_LIBFILE, // schematic library file (.lib)
73 };
74 
75 
107 
117 
125 
126  // Please, verify: the number of items in this list should be
127  // less than ROOM_FOR_KICADMANAGER (see id.h)
129 };
130 
131 
136 {
137 public:
138  KICAD_MANAGER_FRAME( wxWindow* parent, const wxString& title,
139  const wxPoint& pos, const wxSize& size );
140 
142 
143  void OnCloseWindow( wxCloseEvent& Event );
144  void OnSize( wxSizeEvent& event );
145 
149  void OnLoadProject( wxCommandEvent& event );
150 
155  void OnCreateProjectFromTemplate( wxCommandEvent& event );
156 
157  void OnNewProject( wxCommandEvent& aEvent );
158 
162  void OnSaveProject( wxCommandEvent& event );
163 
164  void OnArchiveFiles( wxCommandEvent& event );
165  void OnUnarchiveFiles( wxCommandEvent& event );
166 
167  void OnRunEeschema( wxCommandEvent& event );
168  void OnRunSchLibEditor( wxCommandEvent& event );
169  void OnRunPcbNew( wxCommandEvent& event );
170  void OnRunPcbFpEditor( wxCommandEvent& event );
171  void OnRunGerbview( wxCommandEvent& event );
172  void OnRunBitmapConverter( wxCommandEvent& event );
173  void OnRunPcbCalculator( wxCommandEvent& event );
174  void OnRunPageLayoutEditor( wxCommandEvent& event );
175 
176  void OnConfigurePaths( wxCommandEvent& aEvent );
177  void OnEditSymLibTable( wxCommandEvent& aEvent );
178  void OnEditFpLibTable( wxCommandEvent& aEvent );
179  void OnPreferences( wxCommandEvent& aEvent );
180  void OnOpenTextEditor( wxCommandEvent& event );
181  void OnOpenFileInTextEditor( wxCommandEvent& event );
182  void OnBrowseInFileExplorer( wxCommandEvent& event );
183  void OnShowHotkeys( wxCommandEvent& event );
184 
185  void OnFileHistory( wxCommandEvent& event );
186  void OnExit( wxCommandEvent& event );
187 
188  void ReCreateMenuBar() override;
189  void RecreateBaseHToolbar();
190 
194  void OnImportEagleFiles( wxCommandEvent& event );
195 
201  void PrintMsg( const wxString& aText );
202 
206  void PrintPrjInfo();
207 
211  void ClearMsg();
212 
213  void OnRefresh( wxCommandEvent& event );
214  void OnUpdateRequiresProject( wxUpdateUIEvent& event );
215 
226  void CreateNewProject( const wxFileName& aProjectFileName );
227  void LoadProject( const wxFileName& aProjectFileName );
228 
229 
230  void LoadSettings( wxConfigBase* aCfg ) override;
231 
232  void SaveSettings( wxConfigBase* aCfg ) override;
233 
234  void CommonSettingsChanged() override;
235 
243  void Execute( wxWindow* frame, const wxString& execFile,
244  wxString param = wxEmptyString );
245 
246  class TERMINATE_HANDLER : public wxProcess
247  {
248  private:
249  wxString m_appName;
250 
251  public:
252  TERMINATE_HANDLER( const wxString& appName ) :
253  m_appName( appName )
254  {
255  }
256 
257  void OnTerminate( int pid, int status ) override;
258  };
259 
264  void OnChangeWatchedPaths( wxCommandEvent& aEvent );
265 
266 
267  void SetProjectFileName( const wxString& aFullProjectProFileName );
268  const wxString GetProjectFileName();
269 
270  // read only accessors
271  const wxString SchFileName();
272  const wxString PcbFileName();
273  const wxString PcbLegacyFileName();
274 
275  void ReCreateTreePrj();
276 
279  void RunPcbNew( const wxString& aProjectBoardFileName );
280 
283  void RunEeschema( const wxString& aProjectSchematicFileName );
284 
285  DECLARE_EVENT_TABLE()
286 
287 private:
288  wxConfigBase* config() override;
289 
290  const SEARCH_STACK& sys_search() override;
291 
292  wxString help_name() override;
293 
296  wxTextCtrl* m_MessagesBox;
297  wxAuiToolBar* m_VToolBar; // Vertical toolbar (not used)
298 
301 
302  void language_change( wxCommandEvent& event );
303 
305 };
306 
307 
310 class LAUNCHER_PANEL : public wxPanel
311 {
312 private:
313  wxBoxSizer* m_buttonSizer;
314 
315  int m_height = 0;
316  int m_width = 0;
317 
318 public: LAUNCHER_PANEL( wxWindow* parent );
320 
321  int GetPanelHeight() const;
322  int GetPanelWidth() const;
323 
324 private:
325 
330  void CreateCommandToolbar( void );
331 
332  void AddButton( wxWindowID aId, const wxBitmap& aBitmap, const wxString& aToolTip );
333 };
334 
335 // The C++ project manager includes a single PROJECT in its link image.
336 class PROJECT;
337 extern PROJECT& Prj();
338 
339 #endif
void OnRunPcbCalculator(wxCommandEvent &event)
Definition: mainframe.cpp:436
void OnBrowseInFileExplorer(wxCommandEvent &event)
Definition: mainframe.cpp:487
Definition: kicad.h:59
Class KIWAY_HOLDER is a mix in class which holds the location of a wxWindow&#39;s KIWAY.
Definition: kiway_player.h:48
void OnEditFpLibTable(wxCommandEvent &aEvent)
Definition: mainframe.cpp:568
void OnNewProject(wxCommandEvent &aEvent)
Definition: prjconfig.cpp:219
void OnRunPageLayoutEditor(wxCommandEvent &event)
Definition: mainframe.cpp:442
Structure EDA_HOTKEY_CONFIG contains the information required to save hot key information to a config...
Definition: hotkeys_basic.h:94
TreeFileType
Definition: kicad.h:52
void language_change(wxCommandEvent &event)
Definition: mainframe.cpp:505
Class PROJECT holds project specific data.
Definition: project.h:57
class LAUNCHER_PANEL
Definition: kicad.h:310
void LoadSettings(wxConfigBase *aCfg) override
Function LoadSettings loads common frame parameters from a configuration file.
Definition: mainframe.cpp:526
void OnRefresh(wxCommandEvent &event)
Definition: mainframe.cpp:499
void OnRunPcbFpEditor(wxCommandEvent &event)
Definition: mainframe.cpp:404
void OnRunEeschema(wxCommandEvent &event)
Definition: mainframe.cpp:329
Class TREEPROJECTFILES This is the class to show (as a tree) the files in the project directory...
void OnImportEagleFiles(wxCommandEvent &event)
Open dialog to import Eagle schematic and board files.
void OnOpenFileInTextEditor(wxCommandEvent &event)
Definition: mainframe.cpp:467
void OnRunSchLibEditor(wxCommandEvent &event)
Definition: mainframe.cpp:337
Class SEARCH_STACK looks for files in a number of places.
Definition: search_stack.h:41
wxAuiToolBar * m_VToolBar
Definition: kicad.h:297
void OnEditSymLibTable(wxCommandEvent &aEvent)
Definition: mainframe.cpp:561
void OnConfigurePaths(wxCommandEvent &aEvent)
Definition: mainframe.cpp:554
void OnLoadProject(wxCommandEvent &event)
Load an exiting project (.pro) file.
Definition: prjconfig.cpp:165
void OnRunBitmapConverter(wxCommandEvent &event)
Definition: mainframe.cpp:430
void OnOpenTextEditor(wxCommandEvent &event)
Definition: mainframe.cpp:458
Definition: kicad.h:61
LAUNCHER_PANEL * m_Launcher
Definition: kicad.h:295
void RunEeschema(const wxString &aProjectSchematicFileName)
Call this only for a SCH associated with the current project.
Definition: mainframe.cpp:294
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
void OnFileHistory(wxCommandEvent &event)
const wxString SchFileName()
Definition: mainframe.cpp:146
void Execute(wxWindow *frame, const wxString &execFile, wxString param=wxEmptyString)
Open another KiCad application and logs a message.
Definition: mainframe.cpp:265
Definition: kicad.h:68
void OnUpdateRequiresProject(wxUpdateUIEvent &event)
Definition: prjconfig.cpp:407
void PrintMsg(const wxString &aText)
Displays aText in the text panel.
Definition: mainframe.cpp:194
~LAUNCHER_PANEL()
Definition: kicad.h:319
class TREE_PROJECT_FRAME Window to display the tree files
EDA_HOTKEY_CONFIG * m_manager_Hokeys_Descr
Definition: kicad.h:300
wxString help_name() override
Definition: mainframe.cpp:188
Base window classes and related definitions.
void OnChangeWatchedPaths(wxCommandEvent &aEvent)
Called by sending a event with id = ID_INIT_WATCHED_PATHS rebuild the list of wahtched paths...
void OnCreateProjectFromTemplate(wxCommandEvent &event)
Creates a new project folder, copy a template into this new folder.
Definition: prjconfig.cpp:271
void RecreateBaseHToolbar()
(Re)Create the horizontal toolbar
Definition: kicad.h:72
void OnShowHotkeys(wxCommandEvent &event)
Definition: mainframe.cpp:548
void OnRunGerbview(wxCommandEvent &event)
Definition: mainframe.cpp:449
void OnArchiveFiles(wxCommandEvent &event)
void CommonSettingsChanged() override
Function CommonSettingsChanged Notification event that some of the common (suite-wide) settings have ...
Definition: mainframe.cpp:512
TERMINATE_HANDLER(const wxString &appName)
Definition: kicad.h:252
wxBoxSizer * m_buttonSizer
Definition: kicad.h:313
const wxString GetProjectFileName()
Definition: mainframe.cpp:140
void SetProjectFileName(const wxString &aFullProjectProFileName)
Definition: mainframe.cpp:128
KICAD_MANAGER_FRAME(wxWindow *parent, const wxString &title, const wxPoint &pos, const wxSize &size)
Definition: mainframe.cpp:56
void OnCloseWindow(wxCloseEvent &Event)
Definition: mainframe.cpp:209
void OnRunPcbNew(wxCommandEvent &event)
Definition: mainframe.cpp:392
const wxString PcbLegacyFileName()
Definition: mainframe.cpp:166
void ReCreateMenuBar() override
(Re)Create the menubar
void OnSize(wxSizeEvent &event)
Definition: mainframe.cpp:200
wxTextCtrl * m_MessagesBox
Definition: kicad.h:296
void SaveSettings(wxConfigBase *aCfg) override
Function SaveSettings saves common frame parameters to a configuration data file. ...
Definition: mainframe.cpp:533
void OnPreferences(wxCommandEvent &aEvent)
Definition: mainframe.cpp:575
TREE_PROJECT_FRAME * m_LeftWin
Definition: kicad.h:294
Class EDA_BASE_FRAME is the base frame for deriving all KiCad main window classes.
const wxString PcbFileName()
Definition: mainframe.cpp:156
Definition: kicad.h:60
void LoadProject(const wxFileName &aProjectFileName)
Definition: prjconfig.cpp:61
wxConfigBase * config() override
Function config returns the wxConfigBase used in SaveSettings(), and is overloaded in KICAD_MANAGER_F...
Definition: mainframe.cpp:120
bool m_active_project
Definition: kicad.h:304
void OnUnarchiveFiles(wxCommandEvent &event)
void CreateNewProject(const wxFileName &aProjectFileName)
Creates a new project by setting up and initial project, schematic, and board files.
Definition: prjconfig.cpp:108
void OnExit(wxCommandEvent &event)
Definition: mainframe.cpp:238
const SEARCH_STACK & sys_search() override
Function sys_search returns a SEARCH_STACK pertaining to entire program, and is overloaded in KICAD_M...
Definition: mainframe.cpp:182
void ClearMsg()
Erase the text panel.
Definition: mainframe.cpp:520
void PrintPrjInfo()
Prints the current working directory name and the projet name on the text panel.
Definition: mainframe.cpp:540
void OnTerminate(int pid, int status) override
Definition: mainframe.cpp:244
id_kicad_frm
Command IDs for KiCad.
Definition: kicad.h:97
The main KiCad project manager frame.
Definition: kicad.h:135
void RunPcbNew(const wxString &aProjectBoardFileName)
Call this only for a PCB associated with the current project.
Definition: mainframe.cpp:363
void OnSaveProject(wxCommandEvent &event)
Save the project (.pro) file containing the top level configuration parameters.
Definition: prjconfig.cpp:398