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>
33 #include <gestfich.h>
34 #include <wx/dir.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 
317 {
318  m_frame->CloseProject( true );
319  return 0;
320 }
321 
322 
323 class SAVE_AS_TRAVERSER : public wxDirTraverser
324 {
325 private:
327 
329  wxString m_projectName;
332 
333  wxFileName m_newProjectFile;
334  wxString m_errors;
335 
336 public:
338  const wxString& aSrcProjectDirPath,
339  const wxString& aSrcProjectName,
340  const wxString& aNewProjectDirPath,
341  const wxString& aNewProjectName ) :
342  m_frame( aFrame ),
343  m_projectDirPath( aSrcProjectDirPath ),
344  m_projectName( aSrcProjectName ),
345  m_newProjectDirPath( aNewProjectDirPath ),
346  m_newProjectName( aNewProjectName )
347  {
348  }
349 
350  virtual wxDirTraverseResult OnFile( const wxString& aSrcFilePath ) override
351  {
352  // Recursion guard for a Save As to a location inside the source project.
353  if( aSrcFilePath.StartsWith( m_newProjectDirPath ) )
354  return wxDIR_CONTINUE;
355 
356  wxFileName destFile( aSrcFilePath );
357  wxString ext = destFile.GetExt();
358  bool atRoot = destFile.GetPath() == m_projectDirPath;
359 
360  if( ext == "pro" )
361  {
362  wxString destPath = destFile.GetPath();
363 
364  if( destPath.StartsWith( m_projectDirPath ) )
365  {
366  destPath.Replace( m_projectDirPath, m_newProjectDirPath, false );
367  destFile.SetPath( destPath );
368  }
369 
370  if( destFile.GetName() == m_projectName )
371  {
372  destFile.SetName( m_newProjectName );
373 
374  if( atRoot )
375  m_newProjectFile = destFile;
376  }
377 
378  // Currently all paths in the settings file are relative, so we can just do a
379  // straight copy
380  KiCopyFile( aSrcFilePath, destFile.GetFullPath(), m_errors );
381  }
382  else if( ext == "kicad_sch"
383  || ext == "kicad_sch-bak"
384  || ext == "sch"
385  || ext == "sch-bak"
386  || ext == "sym"
387  || ext == "lib"
388  || ext == "dcm"
389  || ext == "kicad_sym"
390  || ext == "net"
391  || destFile.GetName() == "sym-lib-table" )
392  {
393  KIFACE* eeschema = m_frame->Kiway().KiFACE( KIWAY::FACE_SCH );
395  m_newProjectName, aSrcFilePath, m_errors );
396  }
397  else if( ext == "kicad_pcb"
398  || ext == "kicad_pcb-bak"
399  || ext == "brd"
400  || ext == "kicad_mod"
401  || ext == "mod"
402  || ext == "cmp"
403  || destFile.GetName() == "fp-lib-table" )
404  {
405  KIFACE* pcbnew = m_frame->Kiway().KiFACE( KIWAY::FACE_PCB );
407  m_newProjectName, aSrcFilePath, m_errors );
408  }
409  else if( ext == "kicad_wks" )
410  {
411  KIFACE* pleditor = m_frame->Kiway().KiFACE( KIWAY::FACE_PL_EDITOR );
413  m_newProjectName, aSrcFilePath, m_errors );
414  }
415  else if( ext == "gbr"
416  || ext == "gbrjob"
417  || ext == "drl"
418  || IsProtelExtension( ext ) )
419  {
420  KIFACE* gerbview = m_frame->Kiway().KiFACE( KIWAY::FACE_GERBVIEW );
422  m_newProjectName, aSrcFilePath, m_errors );
423  }
424  else
425  {
426  // Everything we don't recognize just gets a straight copy.
427  wxString destPath = destFile.GetPath();
428  wxString destName = destFile.GetName();
429 
430  if( destPath.StartsWith( m_projectDirPath ) )
431  {
432  destPath.Replace( m_projectDirPath, m_newProjectDirPath, false );
433  destFile.SetPath( destPath );
434  }
435 
436  if( destName == m_projectName )
437  destFile.SetName( m_newProjectName );
438 
439  KiCopyFile( aSrcFilePath, destFile.GetFullPath(), m_errors );
440  }
441 
442  return wxDIR_CONTINUE;
443  }
444 
445  virtual wxDirTraverseResult OnDir( const wxString& aSrcDirPath ) override
446  {
447  // Recursion guard for a Save As to a location inside the source project.
448  if( aSrcDirPath.StartsWith( m_newProjectDirPath ) )
449  return wxDIR_CONTINUE;
450 
451  wxFileName destDir( aSrcDirPath );
452  wxString destDirPath = destDir.GetPathWithSep();
453  wxUniChar pathSep = wxFileName::GetPathSeparator();
454 
455  if( destDirPath.StartsWith( m_projectDirPath + pathSep ) )
456  {
457  destDirPath.Replace( m_projectDirPath, m_newProjectDirPath, false );
458  destDir.SetPath( destDirPath );
459  }
460 
461  if( destDir.GetName() == m_projectName )
462  {
463  if( destDir.GetExt() == "pretty" )
464  destDir.SetName( m_newProjectName );
465 #if 0
466  // WAYNE STAMBAUGH TODO:
467  // If we end up with a symbol equivalent to ".pretty" we'll want to handle it here....
468  else if( destDir.GetExt() == "sym_lib_dir_extension" )
469  destDir.SetName( m_newProjectName );
470 #endif
471  }
472 
473  if( !wxMkdir( destDir.GetFullPath() ) )
474  {
475  wxString msg;
476 
477  if( !m_errors.empty() )
478  m_errors += "\n";
479 
480  msg.Printf( _( "Cannot copy folder \"%s\"." ), destDir.GetFullPath() );
481  m_errors += msg;
482  }
483 
484  return wxDIR_CONTINUE;
485  }
486 
487  wxString GetErrors() { return m_errors; }
488 
489  wxFileName GetNewProjectFile() { return m_newProjectFile; }
490 };
491 
492 
494 {
495  wxString msg;
496 
497  wxFileName currentProjectFile( Prj().GetProjectFullName() );
498  wxString currentProjectDirPath = currentProjectFile.GetPath();
499  wxString currentProjectName = Prj().GetProjectName();
500 
501  wxString default_dir = m_frame->GetMruPath();
502 
503  if( default_dir == currentProjectDirPath
504  || default_dir == currentProjectDirPath + wxFileName::GetPathSeparator() )
505  {
506  // Don't start within the current project
507  wxFileName default_dir_fn( default_dir );
508  default_dir_fn.RemoveLastDir();
509  default_dir = default_dir_fn.GetPath();
510  }
511 
512  wxFileDialog dlg( m_frame, _( "Save Project To" ), default_dir, wxEmptyString, wxEmptyString,
513  wxFD_SAVE );
514 
515  if( dlg.ShowModal() == wxID_CANCEL )
516  return -1;
517 
518  wxFileName newProjectDir( dlg.GetPath() );
519 
520  if( !newProjectDir.IsAbsolute() )
521  newProjectDir.MakeAbsolute();
522 
523  if( wxDirExists( newProjectDir.GetFullPath() ) )
524  {
525  msg.Printf( _( "\"%s\" already exists." ), newProjectDir.GetFullPath() );
527  return -1;
528  }
529 
530  if( !wxMkdir( newProjectDir.GetFullPath() ) )
531  {
532  msg.Printf( _( "Directory \"%s\" could not be created.\n\n"
533  "Please make sure you have write permissions and try again." ),
534  newProjectDir.GetPath() );
536  return -1;
537  }
538 
539  if( !newProjectDir.IsDirWritable() )
540  {
541  msg.Printf( _( "Cannot write to folder \"%s\"." ), newProjectDir.GetFullPath() );
542  wxMessageDialog msgDlg( m_frame, msg, _( "Error!" ), wxICON_ERROR | wxOK | wxCENTER );
543  msgDlg.SetExtendedMessage( _( "Please check your access permissions to this folder "
544  "and try again." ) );
545  msgDlg.ShowModal();
546  return -1;
547  }
548 
549  const wxString& newProjectDirPath = newProjectDir.GetFullPath();
550  const wxString& newProjectName = newProjectDir.GetName();
551  wxDir currentProjectDir( currentProjectDirPath );
552 
553  SAVE_AS_TRAVERSER traverser( m_frame, currentProjectDirPath, currentProjectName,
554  newProjectDirPath, newProjectName );
555 
556  currentProjectDir.Traverse( traverser );
557 
558  if( !traverser.GetErrors().empty() )
559  DisplayErrorMessage( m_frame, traverser.GetErrors() );
560 
561  if( traverser.GetNewProjectFile().FileExists() )
562  {
564  m_frame->LoadProject( traverser.GetNewProjectFile() );
565  }
566 
567  return 0;
568 }
569 
570 
572 {
574  return 0;
575 }
576 
577 
579 {
580  ACTION_MENU* actionMenu = aEvent.Parameter<ACTION_MENU*>();
581  CONDITIONAL_MENU* conditionalMenu = dynamic_cast<CONDITIONAL_MENU*>( actionMenu );
582  SELECTION dummySel;
583 
584  if( conditionalMenu )
585  conditionalMenu->Evaluate( dummySel );
586 
587  if( actionMenu )
588  actionMenu->UpdateAll();
589 
590  return 0;
591 }
592 
593 
595 {
596  FRAME_T playerType = aEvent.Parameter<FRAME_T>();
597  KIWAY_PLAYER* player;
598 
599  // Prevent multiple KIWAY_PLAYER loading at one time
600  const std::lock_guard<std::mutex> lock( m_loading );
601 
602  try
603  {
604  player = m_frame->Kiway().Player( playerType, true );
605  }
606  catch( const IO_ERROR& err )
607  {
608  wxMessageBox( _( "Application failed to load:\n" ) + err.What(), _( "KiCad Error" ),
609  wxOK | wxICON_ERROR, m_frame );
610  return -1;
611  }
612 
613  if ( !player )
614  {
615  wxMessageBox( _( "Application failed to load." ), _( "KiCad Error" ),
616  wxOK | wxICON_ERROR, m_frame );
617  return -1;
618  }
619 
620  if( !player->IsVisible() ) // A hidden frame might not have the document loaded.
621  {
622  wxString filepath;
623 
624  if( playerType == FRAME_SCH )
625  {
626  wxFileName kicad_schematic( m_frame->SchFileName() );
627  wxFileName legacy_schematic( m_frame->SchLegacyFileName() );
628 
629  if( !legacy_schematic.FileExists() || kicad_schematic.FileExists() )
630  filepath = kicad_schematic.GetFullPath();
631  else
632  filepath = legacy_schematic.GetFullPath();
633  }
634  else if( playerType == FRAME_PCB_EDITOR )
635  {
636  wxFileName kicad_board( m_frame->PcbFileName() );
637  wxFileName legacy_board( m_frame->PcbLegacyFileName() );
638 
639  if( !legacy_board.FileExists() || kicad_board.FileExists() )
640  filepath = kicad_board.GetFullPath();
641  else
642  filepath = legacy_board.GetFullPath();
643  }
644 
645  if( !filepath.IsEmpty() )
646  {
647  if( !player->OpenProjectFiles( std::vector<wxString>( 1, filepath ) ) )
648  return -1;
649  }
650 
651  player->Show( true );
652  }
653 
654  // Needed on Windows, other platforms do not use it, but it creates no issue
655  if( player->IsIconized() )
656  player->Iconize( false );
657 
658  player->Raise();
659 
660  // Raising the window does not set the focus on Linux. This should work on
661  // any platform.
662  if( wxWindow::FindFocus() != player )
663  player->SetFocus();
664 
665  return 0;
666 }
667 
668 
669 class TERMINATE_HANDLER : public wxProcess
670 {
671 private:
672  wxString m_appName;
673 
674 public:
675  TERMINATE_HANDLER( const wxString& appName ) :
676  m_appName( appName )
677  { }
678 
679  void OnTerminate( int pid, int status ) override
680  {
681  wxString msg = wxString::Format( _( "%s closed [pid=%d]\n" ),
682  m_appName,
683  pid );
684 
685  wxWindow* window = wxWindow::FindWindowByName( KICAD_MANAGER_FRAME_NAME );
686 
687  if( window ) // Should always happen.
688  {
689  // Be sure the kicad frame manager is found
690  // This dynamic cast is not really mandatory, but ...
691  KICAD_MANAGER_FRAME* frame = dynamic_cast<KICAD_MANAGER_FRAME*>( window );
692 
693  if( frame )
694  frame->PrintMsg( msg );
695  }
696 
697  delete this;
698  }
699 };
700 
701 
703 {
704  wxString execFile;
705  wxString params;
706 
708  execFile = GERBVIEW_EXE;
709  else if( aEvent.IsAction( &KICAD_MANAGER_ACTIONS::convertImage ) )
710  execFile = BITMAPCONVERTER_EXE;
711  else if( aEvent.IsAction( &KICAD_MANAGER_ACTIONS::showCalculator ) )
712  execFile = PCB_CALCULATOR_EXE;
713  else if( aEvent.IsAction( &KICAD_MANAGER_ACTIONS::editWorksheet ) )
714  execFile = PL_EDITOR_EXE;
715  else if( aEvent.IsAction( &KICAD_MANAGER_ACTIONS::openTextEditor ) )
716  execFile = Pgm().GetEditorName();
717  else if( aEvent.IsAction( &KICAD_MANAGER_ACTIONS::editOtherSch ) )
718  execFile = EESCHEMA_EXE;
719  else if( aEvent.IsAction( &KICAD_MANAGER_ACTIONS::editOtherPCB ) )
720  execFile = PCBNEW_EXE;
721  else
722  wxFAIL_MSG( "Execute(): unexpected request" );
723 
724  if( execFile.IsEmpty() )
725  return 0;
726 
727  if( aEvent.Parameter<wxString*>() )
728  params = *aEvent.Parameter<wxString*>();
730  params = m_frame->Prj().GetProjectPath();
731 
732  if( !params.empty() )
733  AddDelimiterString( params );
734 
735  TERMINATE_HANDLER* callback = new TERMINATE_HANDLER( execFile );
736 
737  long pid = ExecuteFile( m_frame, execFile, params, callback );
738 
739  if( pid > 0 )
740  {
741  wxString msg = wxString::Format( _( "%s %s opened [pid=%ld]\n" ),
742  execFile,
743  params,
744  pid );
745  m_frame->PrintMsg( msg );
746 
747 #ifdef __WXMAC__
748  msg.Printf( "osascript -e 'activate application \"%s\"' ", execFile );
749  system( msg.c_str() );
750 #endif
751  }
752  else
753  {
754  delete callback;
755  }
756 
757  return 0;
758 }
759 
760 
762 {
768 
771 
781 
784 }
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:61
void DoNotShowCheckbox(wxString file, int line)
Shows the 'do not show again' checkbox
Definition: confirm.cpp:54
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
const wxString PL_EDITOR_EXE
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:253
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
Defines the structure of a menu based on ACTIONs.
Definition: action_menu.h:43
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:328
static TOOL_ACTION showCalculator
const wxString SchLegacyFileName()
static TOOL_ACTION viewGerbers
void KiCopyFile(const wxString &aSrcPath, const wxString &aDestPath, wxString &aErrors)
Function CopyFile.
Definition: gestfich.cpp:363
static TOOL_ACTION newFromTemplate
void 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
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:102
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
virtual wxDirTraverseResult OnDir(const wxString &aSrcDirPath) override
static TOOL_ACTION closeProject
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:345
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:29
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:167
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:180
int NewProject(const TOOL_EVENT &aEvent)
int SaveProjectAs(const TOOL_EVENT &aEvent)
int CloseProject(const TOOL_EVENT &aEvent)
wxCheckBox * m_cbCreateDir
void CreateNewProject(const wxFileName &aProjectFileName, bool aCreateStubFiles=true)
Creates a new project by setting up and initial project, schematic, and board files.
wxString ProjectFileWildcard()
eeschema DSO
Definition: kiway.h:281
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
bool CloseProject(bool aSave)
Closes the project, and saves it if aSave is true;.
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
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:88
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:96
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
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:165
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:284
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