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