KiCad PCB EDA Suite
kicad_manager_control.cpp
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) 2019 CERN
5  * Copyright (C) 2019-2020 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * This program is free software: you can redistribute it and/or modify it
8  * under the terms of the GNU General Public License as published by the
9  * Free Software Foundation, either version 3 of the License, or (at your
10  * option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
22 #include <executable_names.h>
23 #include <pgm_base.h>
24 #include <kiway.h>
25 #include <kicad_manager_frame.h>
26 #include <confirm.h>
27 #include <bitmaps.h>
28 #include <tool/selection.h>
29 #include <tool/tool_event.h>
30 #include <tool/tool_manager.h>
34 #include <gestfich.h>
35 
37 class DIR_CHECKBOX : public wxPanel
38 {
39 public:
40  DIR_CHECKBOX( wxWindow* aParent )
41  : wxPanel( aParent )
42  {
43  m_cbCreateDir = new wxCheckBox( this, wxID_ANY,
44  _( "Create a new directory for the project" ) );
45  m_cbCreateDir->SetValue( true );
46 
47  wxBoxSizer* sizer = new wxBoxSizer( wxHORIZONTAL );
48  sizer->Add( m_cbCreateDir, 0, wxALL, 8 );
49 
50  SetSizerAndFit( sizer );
51  }
52 
53  bool CreateNewDir() const
54  {
55  return m_cbCreateDir->GetValue();
56  }
57 
58  static wxWindow* Create( wxWindow* aParent )
59  {
60  return new DIR_CHECKBOX( aParent );
61  }
62 
63 protected:
64  wxCheckBox* m_cbCreateDir;
65 };
66 
67 
69  TOOL_INTERACTIVE( "kicad.Control" ),
70  m_frame( nullptr )
71 {
72 }
73 
74 
76 {
77  m_frame = getEditFrame<KICAD_MANAGER_FRAME>();
78 }
79 
80 
82 {
83  wxString default_dir = m_frame->GetMruPath();
84  wxFileDialog dlg( m_frame, _( "Create New Project" ), default_dir, wxEmptyString,
85  ProjectFileWildcard(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
86 
87  // Add a "Create a new directory" checkbox
88  dlg.SetExtraControlCreator( &DIR_CHECKBOX::Create );
89 
90  if( dlg.ShowModal() == wxID_CANCEL )
91  return -1;
92 
93  wxFileName pro( dlg.GetPath() );
94 
95  // wxFileName automatically extracts an extension. But if it isn't
96  // a .pro extension, we should keep it as part of the filename
97  if( !pro.GetExt().IsEmpty()
98  && pro.GetExt().ToStdString() != ProjectFileExtension )
99  pro.SetName( pro.GetName() + wxT( "." ) + pro.GetExt() );
100 
101  pro.SetExt( ProjectFileExtension ); // enforce extension
102 
103  if( !pro.IsAbsolute() )
104  pro.MakeAbsolute();
105 
106  // Append a new directory with the same name of the project file.
107  if( static_cast<DIR_CHECKBOX*>( dlg.GetExtraControl() )->CreateNewDir() )
108  pro.AppendDir( pro.GetName() );
109 
110  // Check if the project directory is empty if it already exists.
111  wxDir directory( pro.GetPath() );
112 
113  if( !pro.DirExists() )
114  {
115  if( !pro.Mkdir() )
116  {
117  wxString msg;
118  msg.Printf( _( "Directory \"%s\" could not be created.\n\n"
119  "Please make sure you have write permissions and try again." ),
120  pro.GetPath() );
122  return -1;
123  }
124  }
125  else if( directory.HasFiles() )
126  {
127  wxString msg = _( "The selected directory is not empty. It is recommended that you "
128  "create projects in their own empty directory.\n\nDo you "
129  "want to continue?" );
130 
131  if( !IsOK( m_frame, msg ) )
132  return -1;
133  }
134 
135  m_frame->CreateNewProject( pro );
136  m_frame->LoadProject( pro );
137 
138  return 0;
139 }
140 
141 
143 {
145 
146  wxFileName templatePath;
147  wxString envStr;
148 
149  // KiCad system template path.
150  ENV_VAR_MAP_CITER it = Pgm().GetLocalEnvVariables().find( "KICAD_TEMPLATE_DIR" );
151 
152  if( it != Pgm().GetLocalEnvVariables().end() && it->second.GetValue() != wxEmptyString )
153  {
154  templatePath.AssignDir( it->second.GetValue() );
155  ps->AddTemplatesPage( _( "System Templates" ), templatePath );
156  }
157 
158  // User template path.
159  it = Pgm().GetLocalEnvVariables().find( "KICAD_USER_TEMPLATE_DIR" );
160 
161  if( it != Pgm().GetLocalEnvVariables().end() && it->second.GetValue() != wxEmptyString )
162  {
163  templatePath.AssignDir( it->second.GetValue() );
164  ps->AddTemplatesPage( _( "User Templates" ), templatePath );
165  }
166 
167  // Show the project template selector dialog
168  if( ps->ShowModal() != wxID_OK )
169  return -1;
170 
171  if( !ps->GetSelectedTemplate() )
172  {
173  wxMessageBox( _( "No project template was selected. Cannot generate new project." ),
174  _( "Error" ), wxOK | wxICON_ERROR, m_frame );
175 
176  return -1;
177  }
178 
179  // Get project destination folder and project file name.
180  wxString default_dir = wxFileName( Prj().GetProjectFullName() ).GetPathWithSep();
181  wxString title = _( "New Project Folder" );
182  wxFileDialog dlg( m_frame, title, default_dir, wxEmptyString, ProjectFileWildcard(),
183  wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
184 
185  // Add a "Create a new directory" checkbox
186  dlg.SetExtraControlCreator( &DIR_CHECKBOX::Create );
187 
188  if( dlg.ShowModal() == wxID_CANCEL )
189  return -1;
190 
191  wxFileName fn( dlg.GetPath() );
192 
193  // wxFileName automatically extracts an extension. But if it isn't
194  // a .pro extension, we should keep it as part of the filename
195  if( !fn.GetExt().IsEmpty() && fn.GetExt().ToStdString() != ProjectFileExtension )
196  fn.SetName( fn.GetName() + wxT( "." ) + fn.GetExt() );
197 
198  fn.SetExt( ProjectFileExtension );
199 
200  if( !fn.IsAbsolute() )
201  fn.MakeAbsolute();
202 
203  // Append a new directory with the same name of the project file.
204  if( static_cast<DIR_CHECKBOX*>( dlg.GetExtraControl() )->CreateNewDir() )
205  fn.AppendDir( fn.GetName() );
206 
207  // Check if the project directory is empty if it already exists.
208  wxDir directory( fn.GetPath() );
209 
210  if( !fn.DirExists() )
211  {
212  if( !fn.Mkdir() )
213  {
214  wxString msg;
215  msg.Printf( _( "Directory \"%s\" could not be created.\n\n"
216  "Please make sure you have write permissions and try again." ),
217  fn.GetPath() );
219  return -1;
220  }
221  }
222 
223  if( !fn.IsDirWritable() )
224  {
225  wxString msg;
226 
227  msg.Printf( _( "Cannot write to folder \"%s\"." ), fn.GetPath() );
228  wxMessageDialog msgDlg( m_frame, msg, _( "Error!" ), wxICON_ERROR | wxOK | wxCENTER );
229  msgDlg.SetExtendedMessage( _( "Please check your access permissions to this folder "
230  "and try again." ) );
231  msgDlg.ShowModal();
232  return -1;
233  }
234 
235  m_frame->ClearMsg();
236 
237  // Make sure we are not overwriting anything in the destination folder.
238  std::vector< wxFileName > destFiles;
239 
240  if( ps->GetSelectedTemplate()->GetDestinationFiles( fn, destFiles ) )
241  {
242  std::vector< wxFileName > overwrittenFiles;
243 
244  for( const auto& file : destFiles )
245  {
246  if( file.FileExists() )
247  overwrittenFiles.push_back( file );
248  }
249 
250  if( !overwrittenFiles.empty() )
251  {
252  wxString extendedMsg = _( "Overwriting files:" ) + "\n";
253 
254  for( const auto& file : overwrittenFiles )
255  extendedMsg += "\n" + file.GetFullName();
256 
257  KIDIALOG msgDlg( m_frame, _( "Similar files already exist in the destination folder." ),
258  _( "Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING );
259  msgDlg.SetExtendedMessage( extendedMsg );
260  msgDlg.SetOKLabel( _( "Overwrite" ) );
261  msgDlg.DoNotShowCheckbox( __FILE__, __LINE__ );
262 
263  if( msgDlg.ShowModal() == wxID_CANCEL )
264  return -1;
265  }
266  }
267 
268  wxString errorMsg;
269 
270  // The selected template widget contains the template we're attempting to use to
271  // create a project
272  if( !ps->GetSelectedTemplate()->CreateProject( fn, &errorMsg ) )
273  {
274  wxMessageDialog createDlg( m_frame,
275  _( "A problem occurred creating new project from template!" ),
276  _( "Template Error" ),
277  wxOK | wxICON_ERROR );
278 
279  if( !errorMsg.empty() )
280  createDlg.SetExtendedMessage( errorMsg );
281 
282  createDlg.ShowModal();
283  return -1;
284  }
285 
286  m_frame->CreateNewProject( fn.GetFullPath() );
287  m_frame->LoadProject( fn );
288  return 0;
289 }
290 
291 
293 {
294  wxString wildcard = AllProjectFilesWildcard() + "|" + ProjectFileWildcard() + "|"
296 
297  wxString default_dir = m_frame->GetMruPath();
298  wxFileDialog dlg( m_frame, _( "Open Existing Project" ), default_dir, wxEmptyString,
299  wildcard, wxFD_OPEN | wxFD_FILE_MUST_EXIST );
300 
301  if( dlg.ShowModal() == wxID_CANCEL )
302  return -1;
303 
304  wxFileName pro( dlg.GetPath() );
305 
306  if( !pro.IsAbsolute() )
307  pro.MakeAbsolute();
308 
309  if( !pro.FileExists() )
310  return -1;
311 
312  m_frame->LoadProject( pro );
313  return 0;
314 }
315 
316 
317 class SAVE_AS_TRAVERSER : public wxDirTraverser
318 {
319 private:
321 
323  wxString m_projectName;
326 
327  wxFileName m_newProjectFile;
328  wxString m_errors;
329 
330 public:
332  const wxString& aSrcProjectDirPath,
333  const wxString& aSrcProjectName,
334  const wxString& aNewProjectDirPath,
335  const wxString& aNewProjectName ) :
336  m_frame( aFrame ),
337  m_projectDirPath( aSrcProjectDirPath ),
338  m_projectName( aSrcProjectName ),
339  m_newProjectDirPath( aNewProjectDirPath ),
340  m_newProjectName( aNewProjectName )
341  {
342  }
343 
344  virtual wxDirTraverseResult OnFile( const wxString& aSrcFilePath ) override
345  {
346  wxFileName destFile( aSrcFilePath );
347  wxString ext = destFile.GetExt();
348  bool atRoot = destFile.GetPath() == m_projectDirPath;
349 
350  if( ext == "pro" )
351  {
352  wxString destPath = destFile.GetPath();
353 
354  if( destPath.StartsWith( m_projectDirPath ) )
355  {
356  destPath.Replace( m_projectDirPath, m_newProjectDirPath, false );
357  destFile.SetPath( destPath );
358  }
359 
360  if( destFile.GetName() == m_projectName )
361  {
362  destFile.SetName( m_newProjectName );
363 
364  if( atRoot )
365  m_newProjectFile = destFile;
366  }
367 
368  // Currently all paths in the settings file are relative, so we can just do a
369  // straight copy
370  CopyFile( aSrcFilePath, destFile.GetFullPath(), m_errors );
371  }
372  else if( ext == "kicad_sch"
373  || ext == "kicad_sch-bak"
374  || ext == "sch"
375  || ext == "sch-bak"
376  || ext == "sym"
377  || ext == "lib"
378  || ext == "dcm"
379  || ext == "kicad_sym"
380  || ext == "net"
381  || destFile.GetName() == "sym-lib-table" )
382  {
383  KIFACE* eeschema = m_frame->Kiway().KiFACE( KIWAY::FACE_SCH );
385  m_newProjectName, aSrcFilePath, m_errors );
386  }
387  else if( ext == "kicad_pcb"
388  || ext == "kicad_pcb-bak"
389  || ext == "brd"
390  || ext == "kicad_mod"
391  || ext == "mod"
392  || ext == "cmp"
393  || destFile.GetName() == "fp-lib-table" )
394  {
395  KIFACE* pcbnew = m_frame->Kiway().KiFACE( KIWAY::FACE_PCB );
397  m_newProjectName, aSrcFilePath, m_errors );
398  }
399  else if( ext == "kicad_wks" )
400  {
401  KIFACE* pleditor = m_frame->Kiway().KiFACE( KIWAY::FACE_PL_EDITOR );
403  m_newProjectName, aSrcFilePath, m_errors );
404  }
405  else if( ext == "gbr"
406  || ext == "gbrjob"
407  || ext == "drl"
408  || IsProtelExtension( ext ) )
409  {
410  KIFACE* gerbview = m_frame->Kiway().KiFACE( KIWAY::FACE_GERBVIEW );
412  m_newProjectName, aSrcFilePath, m_errors );
413  }
414  else
415  {
416  // Everything we don't recognize just gets a straight copy.
417  wxString destPath = destFile.GetPath();
418  wxString destName = destFile.GetName();
419 
420  if( destPath.StartsWith( m_projectDirPath ) )
421  {
422  destPath.Replace( m_projectDirPath, m_newProjectDirPath, false );
423  destFile.SetPath( destPath );
424  }
425 
426  if( destName == m_projectName )
427  destFile.SetName( m_newProjectName );
428 
429  CopyFile( aSrcFilePath, destFile.GetFullPath(), m_errors );
430  }
431 
432  return wxDIR_CONTINUE;
433  }
434 
435  virtual wxDirTraverseResult OnDir( const wxString& dirPath ) override
436  {
437  wxFileName destDir( dirPath );
438  wxString destDirPath = destDir.GetPathWithSep();
439  wxUniChar pathSep = wxFileName::GetPathSeparator();
440 
441  if( destDirPath.StartsWith( m_projectDirPath + pathSep ) )
442  {
443  destDirPath.Replace( m_projectDirPath, m_newProjectDirPath, false );
444  destDir.SetPath( destDirPath );
445  }
446 
447  if( destDir.GetName() == m_projectName )
448  {
449  if( destDir.GetExt() == "pretty" )
450  destDir.SetName( m_newProjectName );
451 #if 0
452  // WAYNE STAMBAUGH TODO:
453  // If we end up with a symbol equivalent to ".pretty" we'll want to handle it here....
454  else if( destDir.GetExt() == "sym_lib_dir_extension" )
455  destDir.SetName( m_newProjectName );
456 #endif
457  }
458 
459  if( !wxMkdir( destDir.GetFullPath() ) )
460  {
461  wxString msg;
462 
463  if( !m_errors.empty() )
464  m_errors += "\n";
465 
466  msg.Printf( _( "Cannot copy folder \"%s\"." ), destDir.GetFullPath() );
467  m_errors += msg;
468  }
469 
470  return wxDIR_CONTINUE;
471  }
472 
473  wxString GetErrors() { return m_errors; }
474 
475  wxFileName GetNewProjectFile() { return m_newProjectFile; }
476 };
477 
478 
480 {
481  wxString msg;
482 
483  wxFileName currentProjectFile( Prj().GetProjectFullName() );
484  wxString currentProjectDirPath = currentProjectFile.GetPath();
485  wxString currentProjectName = Prj().GetProjectName();
486 
487  wxString default_dir = m_frame->GetMruPath();
488 
489  if( default_dir == currentProjectDirPath
490  || default_dir == currentProjectDirPath + wxFileName::GetPathSeparator() )
491  {
492  // Don't start within the current project
493  wxFileName default_dir_fn( default_dir );
494  default_dir_fn.RemoveLastDir();
495  default_dir = default_dir_fn.GetPath();
496  }
497 
498  wxFileDialog dlg( m_frame, _( "Save Project To" ), default_dir, wxEmptyString, wxEmptyString,
499  wxFD_SAVE );
500 
501  if( dlg.ShowModal() == wxID_CANCEL )
502  return -1;
503 
504  wxFileName newProjectDir( dlg.GetPath() );
505 
506  if( !newProjectDir.IsAbsolute() )
507  newProjectDir.MakeAbsolute();
508 
509  if( wxDirExists( newProjectDir.GetFullPath() ) )
510  {
511  msg.Printf( _( "\"%s\" already exists." ), newProjectDir.GetFullPath() );
513  return -1;
514  }
515 
516  if( !wxMkdir( newProjectDir.GetFullPath() ) )
517  {
518  msg.Printf( _( "Directory \"%s\" could not be created.\n\n"
519  "Please make sure you have write permissions and try again." ),
520  newProjectDir.GetPath() );
522  return -1;
523  }
524 
525  if( !newProjectDir.IsDirWritable() )
526  {
527  msg.Printf( _( "Cannot write to folder \"%s\"." ), newProjectDir.GetFullPath() );
528  wxMessageDialog msgDlg( m_frame, msg, _( "Error!" ), wxICON_ERROR | wxOK | wxCENTER );
529  msgDlg.SetExtendedMessage( _( "Please check your access permissions to this folder "
530  "and try again." ) );
531  msgDlg.ShowModal();
532  return -1;
533  }
534 
535  const wxString& newProjectDirPath = newProjectDir.GetFullPath();
536  const wxString& newProjectName = newProjectDir.GetName();
537  wxDir currentProjectDir( currentProjectDirPath );
538 
539  SAVE_AS_TRAVERSER traverser( m_frame,
540  currentProjectDirPath, currentProjectName,
541  newProjectDirPath, newProjectName );
542 
543  currentProjectDir.Traverse( traverser );
544 
545  if( !traverser.GetErrors().empty() )
546  DisplayErrorMessage( m_frame, traverser.GetErrors() );
547 
548  if( traverser.GetNewProjectFile().FileExists() )
549  {
551  m_frame->LoadProject( traverser.GetNewProjectFile() );
552  }
553 
554  return 0;
555 }
556 
557 
559 {
561  return 0;
562 }
563 
564 
566 {
567  ACTION_MENU* actionMenu = aEvent.Parameter<ACTION_MENU*>();
568  CONDITIONAL_MENU* conditionalMenu = dynamic_cast<CONDITIONAL_MENU*>( actionMenu );
569  SELECTION dummySel;
570 
571  if( conditionalMenu )
572  conditionalMenu->Evaluate( dummySel );
573 
574  if( actionMenu )
575  actionMenu->UpdateAll();
576 
577  return 0;
578 }
579 
580 
582 {
583  FRAME_T playerType = aEvent.Parameter<FRAME_T>();
584  KIWAY_PLAYER* player;
585 
586  // Prevent multiple KIWAY_PLAYER loading at one time
587  const std::lock_guard<std::mutex> lock( m_loading );
588 
589  try
590  {
591  player = m_frame->Kiway().Player( playerType, true );
592  }
593  catch( const IO_ERROR& err )
594  {
595  wxMessageBox( _( "Application failed to load:\n" ) + err.What(), _( "KiCad Error" ),
596  wxOK | wxICON_ERROR, m_frame );
597  return -1;
598  }
599 
600  if( !player->IsVisible() ) // A hidden frame might not have the document loaded.
601  {
602  wxString filepath;
603 
604  if( playerType == FRAME_SCH )
605  {
606  wxFileName kicad_schematic( m_frame->SchFileName() );
607  wxFileName legacy_schematic( m_frame->SchLegacyFileName() );
608 
609  if( !legacy_schematic.FileExists() || kicad_schematic.FileExists() )
610  filepath = kicad_schematic.GetFullPath();
611  else
612  filepath = legacy_schematic.GetFullPath();
613  }
614  else if( playerType == FRAME_PCB_EDITOR )
615  {
616  wxFileName kicad_board( m_frame->PcbFileName() );
617  wxFileName legacy_board( m_frame->PcbLegacyFileName() );
618 
619  if( !legacy_board.FileExists() || kicad_board.FileExists() )
620  filepath = kicad_board.GetFullPath();
621  else
622  filepath = legacy_board.GetFullPath();
623  }
624 
625  if( !filepath.IsEmpty() )
626  {
627  if( !player->OpenProjectFiles( std::vector<wxString>( 1, filepath ) ) )
628  return -1;
629  }
630 
631  player->Show( true );
632  }
633 
634  // Needed on Windows, other platforms do not use it, but it creates no issue
635  if( player->IsIconized() )
636  player->Iconize( false );
637 
638  player->Raise();
639 
640  // Raising the window does not set the focus on Linux. This should work on
641  // any platform.
642  if( wxWindow::FindFocus() != player )
643  player->SetFocus();
644 
645  return 0;
646 }
647 
648 
649 class TERMINATE_HANDLER : public wxProcess
650 {
651 private:
652  wxString m_appName;
653 
654 public:
655  TERMINATE_HANDLER( const wxString& appName ) :
656  m_appName( appName )
657  { }
658 
659  void OnTerminate( int pid, int status ) override
660  {
661  wxString msg = wxString::Format( _( "%s closed [pid=%d]\n" ),
662  m_appName,
663  pid );
664 
665  wxWindow* window = wxWindow::FindWindowByName( KICAD_MANAGER_FRAME_NAME );
666 
667  if( window ) // Should always happen.
668  {
669  // Be sure the kicad frame manager is found
670  // This dynamic cast is not really mandatory, but ...
671  KICAD_MANAGER_FRAME* frame = dynamic_cast<KICAD_MANAGER_FRAME*>( window );
672 
673  if( frame )
674  frame->PrintMsg( msg );
675  }
676 
677  delete this;
678  }
679 };
680 
681 
683 {
684  wxString execFile;
685  wxString params;
686 
688  execFile = GERBVIEW_EXE;
689  else if( aEvent.IsAction( &KICAD_MANAGER_ACTIONS::convertImage ) )
690  execFile = BITMAPCONVERTER_EXE;
691  else if( aEvent.IsAction( &KICAD_MANAGER_ACTIONS::showCalculator ) )
692  execFile = PCB_CALCULATOR_EXE;
693  else if( aEvent.IsAction( &KICAD_MANAGER_ACTIONS::editWorksheet ) )
694  execFile = PL_EDITOR_EXE;
695  else if( aEvent.IsAction( &KICAD_MANAGER_ACTIONS::openTextEditor ) )
696  execFile = Pgm().GetEditorName();
697  else if( aEvent.IsAction( &KICAD_MANAGER_ACTIONS::editOtherSch ) )
698  execFile = EESCHEMA_EXE;
699  else if( aEvent.IsAction( &KICAD_MANAGER_ACTIONS::editOtherPCB ) )
700  execFile = PCBNEW_EXE;
701  else
702  wxFAIL_MSG( "Execute(): unexpected request" );
703 
704  if( execFile.IsEmpty() )
705  return 0;
706 
707  if( aEvent.Parameter<wxString*>() )
708  params = *aEvent.Parameter<wxString*>();
709  else if( aEvent.IsAction( &KICAD_MANAGER_ACTIONS::viewGerbers ) )
710  params = m_frame->Prj().GetProjectPath();
711 
712  if( !params.empty() )
713  AddDelimiterString( params );
714 
715  TERMINATE_HANDLER* callback = new TERMINATE_HANDLER( execFile );
716 
717  long pid = ExecuteFile( m_frame, execFile, params, callback );
718 
719  if( pid > 0 )
720  {
721  wxString msg = wxString::Format( _( "%s %s opened [pid=%ld]\n" ),
722  execFile,
723  params,
724  pid );
725  m_frame->PrintMsg( msg );
726 
727 #ifdef __WXMAC__
728  msg.Printf( "osascript -e 'activate application \"%s\"' ", execFile );
729  system( msg.c_str() );
730 #endif
731  }
732  else
733  {
734  delete callback;
735  }
736 
737  return 0;
738 }
739 
740 
742 {
747 
750 
760 
763 }
wxString AllProjectFilesWildcard()
static TOOL_ACTION newProject
KiCad executable names.
KIWAY_PLAYER is a wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of ...
Definition: kiway_player.h:59
void DoNotShowCheckbox(wxString file, int line)
Shows the 'do not show again' checkbox
Definition: confirm.cpp:53
int ShowPlayer(const TOOL_EVENT &aEvent)
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_holder.h:56
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:104
const wxString PL_EDITOR_EXE
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:252
This file is part of the common library TODO brief description.
wxString LegacyProjectFileWildcard()
Helper class to create more flexible dialogs, including 'do not show again' checkbox handling.
Definition: confirm.h:44
ACTION_MENU.
Definition: action_menu.h:44
This file is part of the common library.
Helper widget to select whether a new directory should be created for a project
const wxString PCBNEW_EXE
const std::string ProjectFileExtension
PROJECT_TEMPLATE * GetSelectedTemplate()
FRAME_T
Enum FRAME_T is the set of EDA_BASE_FRAME derivatives, typically stored in EDA_BASE_FRAME::m_Ident.
Definition: frame_type.h:34
PROJECT & Prj()
Definition: kicad.cpp:317
static TOOL_ACTION showCalculator
void CopyFile(const wxString &aSrcPath, const wxString &aDestPath, wxString &aErrors)
Function CopyFile.
Definition: gestfich.cpp:363
const wxString SchLegacyFileName()
static TOOL_ACTION viewGerbers
static TOOL_ACTION newFromTemplate
void UpdateAll()
Function UpdateAll() Runs update handlers for the menu and its submenus.
void OnTerminate(int pid, int status) override
VTBL_ENTRY void SaveFileAs(const wxString &srcProjectBasePath, const wxString &srcProjectName, const wxString &newProjectBasePath, const wxString &newProjectName, const wxString &srcFilePath, wxString &aErrors)
Function SaveFileAs Saving a file under a different name is delegated to the various KIFACEs because ...
Definition: kiway.h:219
VTBL_ENTRY const wxString GetProjectPath() const
Function GetProjectPath returns the full path of the project.
Definition: project.cpp:122
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Function Go()
void setTransitions() override
Sets up handlers for various events.
bool IsProtelExtension(const wxString &ext)
const wxString GERBVIEW_EXE
static TOOL_ACTION convertImage
bool IsAction(const TOOL_ACTION *aAction) const
Function IsAction() Tests if the event contains an action issued upon activation of the given TOOL_AC...
Definition: tool_event.cpp:67
int Refresh(const TOOL_EVENT &aEvent)
static TOOL_ACTION editOtherPCB
SAVE_AS_TRAVERSER(KICAD_MANAGER_FRAME *aFrame, const wxString &aSrcProjectDirPath, const wxString &aSrcProjectName, const wxString &aNewProjectDirPath, const wxString &aNewProjectName)
wxString GetMruPath() const
const wxString SchFileName()
const wxString EESCHEMA_EXE
static TOOL_ACTION editSchematic
VTBL_ENTRY KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=NULL)
Function Player returns the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:342
int OpenProject(const TOOL_EVENT &aEvent)
void PrintMsg(const wxString &aText)
Displays aText in the text panel.
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:33
TERMINATE_HANDLER(const wxString &appName)
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
KICAD_MANAGER_FRAME * m_frame
Pointer to the currently used edit/draw frame.
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:435
std::map< wxString, ENV_VAR_ITEM >::const_iterator ENV_VAR_MAP_CITER
Definition: pgm_base.h:119
TOOL_EVENT.
Definition: tool_event.h:171
DIR_CHECKBOX(wxWindow *aParent)
Definition of file extensions used in Kicad.
const wxString PCB_CALCULATOR_EXE
static TOOL_ACTION editFootprints
pcbnew DSO
Definition: kiway.h:282
void AddDelimiterString(wxString &string)
Function AddDelimiterString Add un " to the start and the end of string (if not already done).
Definition: gestfich.cpp:42
static TOOL_ACTION updateMenu
Definition: actions.h:163
static TOOL_ACTION editWorksheet
VTBL_ENTRY KIFACE * KiFACE(FACE_T aFaceId, bool doLoad=true)
Function KiFACE returns the KIFACE* given a FACE_T.
Definition: kiway.cpp:178
int NewProject(const TOOL_EVENT &aEvent)
int SaveProjectAs(const TOOL_EVENT &aEvent)
wxCheckBox * m_cbCreateDir
wxString ProjectFileWildcard()
eeschema DSO
Definition: kiway.h:281
void Reset(RESET_REASON aReason) override
Function Reset() Brings the tool to a known, initial state.
static TOOL_ACTION editOtherSch
KICAD_MANAGER_FRAME * m_frame
size_t GetDestinationFiles(const wxFileName &aNewProjectPath, std::vector< wxFileName > &aDestFiles)
Fetch the list of destination files to be copied when the new project is created.
static TOOL_ACTION editPCB
int UpdateMenu(const TOOL_EVENT &aEvent)
see class PGM_BASE
bool CreateProject(wxFileName &aNewProjectPath, wxString *aErrorMsg=nullptr)
Copies and renames all template files to create a new project.
const wxString PcbLegacyFileName()
static TOOL_ACTION openProject
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
static TOOL_ACTION saveAs
Definition: actions.h:55
#define KICAD_MANAGER_FRAME_NAME
#define _(s)
Definition: 3d_actions.cpp:33
static TOOL_ACTION zoomRedraw
Definition: actions.h:87
static wxWindow * Create(wxWindow *aParent)
const wxString PcbFileName()
KIFACE is used by a participant in the KIWAY alchemy.
Definition: kiway.h:150
int NewFromTemplate(const TOOL_EVENT &aEvent)
void AddTemplatesPage(const wxString &aTitle, wxFileName &aPath)
Add a new page with aTitle, populated with templates from aPath.
RESET_REASON
Determines the reason of reset for a tool
Definition: tool_base.h:79
int ShowModal() override
Definition: confirm.cpp:95
VTBL_ENTRY const wxString GetProjectName() const
Function GetProjectName returns the short name of the project.
Definition: project.cpp:128
void LoadProject(const wxFileName &aProjectFileName)
const wxString BITMAPCONVERTER_EXE
void CreateNewProject(const wxFileName &aProjectFileName)
Creates a new project by setting up and initial project, schematic, and board files.
static TOOL_ACTION editSymbols
int ExecuteFile(wxWindow *frame, const wxString &ExecFile, const wxString &param, wxProcess *callback)
Function ExecuteFile calls the executable file ExecFile with the command line parameters param.
Definition: gestfich.cpp:174
void ClearMsg()
Erase the text panel.
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h:76
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Display a yes/no dialog with aMessage and returns the user response.
Definition: confirm.cpp:283
virtual wxDirTraverseResult OnDir(const wxString &dirPath) override
The main KiCad project manager frame.
int Execute(const TOOL_EVENT &aEvent)
static TOOL_ACTION openTextEditor
bool CreateNewDir() const
virtual wxDirTraverseResult OnFile(const wxString &aSrcFilePath) override