KiCad PCB EDA Suite
eeschema/files-io.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) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 2013 Wayne Stambaugh <stambaughw@gmail.com>
6  * Copyright (C) 2013 CERN (www.cern.ch)
7  * Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; either version 2
12  * of the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, you may find one here:
21  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
22  * or you may search the http://www.gnu.org website for the version 2 license,
23  * or you may write to the Free Software Foundation, Inc.,
24  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
25  */
26 
27 #include <advanced_config.h>
28 #include <class_library.h>
29 #include <confirm.h>
30 #include <connection_graph.h>
31 #include <dialog_migrate_buses.h>
32 #include <dialog_symbol_remap.h>
33 #include <eeschema_settings.h>
34 #include <gestfich.h>
35 #include <id.h>
36 #include <kiface_i.h>
37 #include <kiplatform/app.h>
38 #include <pgm_base.h>
39 #include <profile.h>
40 #include <project/project_file.h>
41 #include <project_rescue.h>
42 #include <reporter.h>
43 #include <richio.h>
44 #include <sch_component.h>
45 #include <sch_edit_frame.h>
47 #include <sch_sheet.h>
48 #include <sch_sheet_path.h>
49 #include <schematic.h>
52 #include <symbol_lib_table.h>
53 #include <tool/actions.h>
54 #include <tool/tool_manager.h>
56 #include <trace_helpers.h>
57 #include <widgets/infobar.h>
60 #include <wx/stdpaths.h>
62 
63 bool SCH_EDIT_FRAME::SaveEEFile( SCH_SHEET* aSheet, bool aSaveUnderNewName )
64 {
65  wxString msg;
66  wxFileName schematicFileName;
67  bool success;
68 
69  if( aSheet == NULL )
70  aSheet = GetCurrentSheet().Last();
71 
72  SCH_SCREEN* screen = aSheet->GetScreen();
73 
74  wxCHECK( screen, false );
75 
76  // If no name exists in the window yet - save as new.
77  if( screen->GetFileName().IsEmpty() )
78  aSaveUnderNewName = true;
79 
80  // Construct the name of the file to be saved
81  schematicFileName = Prj().AbsolutePath( screen->GetFileName() );
82 
83  if( aSaveUnderNewName )
84  {
85  wxFileName savePath( Prj().GetProjectFullName() );
86 
87  if( !savePath.IsOk() || !savePath.IsDirWritable() )
88  {
89  savePath = GetMruPath();
90 
91  if( !savePath.IsOk() || !savePath.IsDirWritable() )
92  savePath = wxStandardPaths::Get().GetDocumentsDir();
93  }
94 
95  wxFileDialog dlg( this, _( "Schematic Files" ), savePath.GetPath(),
96  schematicFileName.GetFullName(), KiCadSchematicFileWildcard(),
97  wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
98 
99  if( dlg.ShowModal() == wxID_CANCEL )
100  return false;
101 
102  schematicFileName = dlg.GetPath();
103 
104  if( schematicFileName.GetExt().IsEmpty() )
105  schematicFileName.SetExt( KiCadSchematicFileExtension );
106  }
107 
108  if( !IsWritable( schematicFileName ) )
109  return false;
110 
111  wxFileName tempFile( schematicFileName );
112  tempFile.SetName( wxT( "." ) + tempFile.GetName() );
113  tempFile.SetExt( tempFile.GetExt() + wxT( "$" ) );
114 
115  // Save
116  wxLogTrace( traceAutoSave,
117  wxT( "Saving file <" ) + schematicFileName.GetFullPath() + wxT( ">" ) );
118 
119  SCH_IO_MGR::SCH_FILE_T pluginType = SCH_IO_MGR::GuessPluginTypeFromSchPath(
120  schematicFileName.GetFullPath() );
121  SCH_PLUGIN::SCH_PLUGIN_RELEASER pi( SCH_IO_MGR::FindPlugin( pluginType ) );
122 
123  try
124  {
125  pi->Save( tempFile.GetFullPath(), aSheet, &Schematic() );
126  success = true;
127  }
128  catch( const IO_ERROR& ioe )
129  {
130  msg.Printf( _( "Error saving schematic file \"%s\".\n%s" ),
131  schematicFileName.GetFullPath(), ioe.What() );
132  DisplayError( this, msg );
133 
134  msg.Printf( _( "Failed to create temporary file \"%s\"" ), tempFile.GetFullPath() );
135  AppendMsgPanel( wxEmptyString, msg, CYAN );
136 
137  // In case we started a file but didn't fully write it, clean up
138  wxRemoveFile( tempFile.GetFullPath() );
139 
140  success = false;
141  }
142 
143  if( success )
144  {
145  // Replace the original with the temporary file we just wrote
146  success = wxRenameFile( tempFile.GetFullPath(), schematicFileName.GetFullPath() );
147 
148  if( !success )
149  {
150  msg.Printf( _( "Error saving schematic file \"%s\".\n"
151  "Failed to rename temporary file %s" ),
152  schematicFileName.GetFullPath(), tempFile.GetFullPath() );
153  DisplayError( this, msg );
154 
155  msg.Printf( _( "Failed to rename temporary file \"%s\"" ), tempFile.GetFullPath() );
156  AppendMsgPanel( wxEmptyString, msg, CYAN );
157  }
158  }
159 
160  if( success )
161  {
162  // Delete auto save file.
163  wxFileName autoSaveFileName = schematicFileName;
164  autoSaveFileName.SetName( GetAutoSaveFilePrefix() + schematicFileName.GetName() );
165 
166  if( autoSaveFileName.FileExists() )
167  {
168  wxLogTrace( traceAutoSave,
169  wxT( "Removing auto save file <" ) + autoSaveFileName.GetFullPath() +
170  wxT( ">" ) );
171 
172  wxRemoveFile( autoSaveFileName.GetFullPath() );
173  }
174 
175  // Update the screen and frame info and reset the lock file.
176  if( aSaveUnderNewName )
177  {
178  screen->SetFileName( schematicFileName.GetFullPath() );
179  LockFile( schematicFileName.GetFullPath() );
180  }
181 
182  screen->ClrSave();
183  screen->ClrModify();
184 
185  msg.Printf( _( "File %s saved" ), screen->GetFileName() );
186  SetStatusText( msg, 0 );
187  }
188  else
189  {
190  DisplayError( this, _( "File write operation failed." ) );
191  }
192 
193  return success;
194 }
195 
196 
197 void SCH_EDIT_FRAME::Save_File( bool doSaveAs )
198 {
199  if( doSaveAs )
200  {
201  if( SaveEEFile( NULL, true ) )
202  {
203  SCH_SCREEN* screen = GetScreen();
204 
205  wxCHECK( screen, /* void */ );
206 
207  wxFileName fn = screen->GetFileName();
208 
209  if( fn.GetExt() == LegacySchematicFileExtension )
211 
212  // If we are saving under a new name, and don't have a real project yet, create one
213  fn.SetExt( ProjectFileExtension );
214 
215  if( fn.IsDirWritable() && !fn.FileExists() )
216  {
217  Prj().SetReadOnly( false );
218  GetSettingsManager()->SaveProjectAs( fn.GetFullPath() );
219  }
220  }
221  }
222  else
223  {
224  SaveEEFile( NULL );
225  }
226 
227  UpdateTitle();
228 }
229 
230 
231 bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl )
232 {
233  // implement the pseudo code from KIWAY_PLAYER.h:
234  wxString msg;
235 
236  auto cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
237 
238  // This is for python:
239  if( aFileSet.size() != 1 )
240  {
241  msg.Printf( "Eeschema:%s() takes only a single filename.", __WXFUNCTION__ );
242  DisplayError( this, msg );
243  return false;
244  }
245 
246  wxString fullFileName( aFileSet[0] );
247 
248  // We insist on caller sending us an absolute path, if it does not, we say it's a bug.
249  wxASSERT_MSG( wxFileName( fullFileName ).IsAbsolute(), wxT( "Path is not absolute!" ) );
250 
251  if( !LockFile( fullFileName ) )
252  {
253  msg.Printf( _( "Schematic file \"%s\" is already open." ), fullFileName );
254  DisplayError( this, msg );
255  return false;
256  }
257 
258  if( !AskToSaveChanges() )
259  return false;
260 
261  PROF_COUNTER openFiles( "OpenProjectFile" );
262 
263  wxFileName pro = fullFileName;
264  pro.SetExt( ProjectFileExtension );
265 
266  bool is_new = !wxFileName::IsFileReadable( fullFileName );
267 
268  // If its a non-existent schematic and caller thinks it exists
269  if( is_new && !( aCtl & KICTL_CREATE ) )
270  {
271  // notify user that fullFileName does not exist, ask if user wants to create it.
272  msg.Printf( _( "Schematic \"%s\" does not exist. Do you wish to create it?" ),
273  fullFileName );
274 
275  if( !IsOK( this, msg ) )
276  return false;
277  }
278 
279  // unload current project file before loading new
280  {
281  SetScreen( nullptr );
283  CreateScreens();
284  }
285 
286  SetStatusText( wxEmptyString );
287  ClearMsgPanel();
288 
289  SCH_IO_MGR::SCH_FILE_T schFileType = SCH_IO_MGR::GuessPluginTypeFromSchPath( fullFileName );
290 
291  // PROJECT::SetProjectFullName() is an impactful function. It should only be
292  // called under carefully considered circumstances.
293 
294  // The calling code should know not to ask me here to change projects unless
295  // it knows what consequences that will have on other KIFACEs running and using
296  // this same PROJECT. It can be very harmful if that calling code is stupid.
297 
298  // NOTE: The calling code should never call this in hosted (non-standalone) mode with a
299  // different project than what has been loaded by the manager frame. This will crash.
300 
301  bool differentProject = pro.GetFullPath() != Prj().GetProjectFullName();
302 
303  if( differentProject )
304  {
305  if( !Prj().IsNullProject() )
307 
308  Schematic().SetProject( nullptr );
310 
311  GetSettingsManager()->LoadProject( pro.GetFullPath() );
312 
313  // Do not allow saving a project if one doesn't exist. This normally happens if we are
314  // standalone and opening a schematic that has been moved from its project folder.
315  if( !pro.Exists() && !( aCtl & KICTL_CREATE ) )
316  Prj().SetReadOnly();
317 
318  CreateScreens();
319  }
320 
321  if( schFileType == SCH_IO_MGR::SCH_LEGACY )
322  {
323  // Don't reload the symbol libraries if we are just launching Eeschema from KiCad again.
324  // They are already saved in the kiface project object.
325  if( differentProject || !Prj().GetElem( PROJECT::ELEM_SCH_PART_LIBS ) )
326  {
327  // load the libraries here, not in SCH_SCREEN::Draw() which is a context
328  // that will not tolerate DisplayError() dialog since we're already in an
329  // event handler in there.
330  // And when a schematic file is loaded, we need these libs to initialize
331  // some parameters (links to PART LIB, dangling ends ...)
333  Prj().SchLibs();
334  }
335  }
336  else
337  {
338  // No legacy symbol libraries including the cache are loaded with the new file format.
340  }
341 
342  // Load the symbol library table, this will be used forever more.
344  Prj().SchSymbolLibTable();
345 
346  // Load project settings after schematic has been set up with the project link, since this will
347  // update some of the needed schematic settings such as drawing defaults
349 
350  wxFileName rfn( GetCurrentFileName() );
351  rfn.MakeRelativeTo( Prj().GetProjectPath() );
352  LoadWindowState( rfn.GetFullPath() );
353 
354  KIPLATFORM::APP::SetShutdownBlockReason( this, _( "Schematic file changes are unsaved" ) );
355 
356  if( Kiface().IsSingle() )
357  {
359  }
360 
361  if( is_new )
362  {
363  // mark new, unsaved file as modified.
364  GetScreen()->SetModify();
365  GetScreen()->SetFileName( fullFileName );
366  }
367  else
368  {
369  // This will rename the file if there is an autosave and the user want to recover.
370  CheckForAutoSaveFile( fullFileName );
371 
372  SetScreen( nullptr );
373 
374  SCH_PLUGIN* plugin = SCH_IO_MGR::FindPlugin( schFileType );
375  SCH_PLUGIN::SCH_PLUGIN_RELEASER pi( plugin );
376 
377  try
378  {
379  Schematic().SetRoot( pi->Load( fullFileName, &Schematic() ) );
380 
381  if( !pi->GetError().IsEmpty() )
382  {
383  DisplayErrorMessage( this,
384  _( "The entire schematic could not be loaded. Errors "
385  "occurred attempting to load \nhierarchical sheet "
386  "schematics." ),
387  pi->GetError() );
388  }
389  }
390  catch( const IO_ERROR& ioe )
391  {
392  // Do not leave g_RootSheet == NULL because it is expected to be
393  // a valid sheet. Therefore create a dummy empty root sheet and screen.
394  CreateScreens();
396 
397  msg.Printf( _( "Error loading schematic file \"%s\".\n%s" ),
398  fullFileName, ioe.What() );
399  DisplayError( this, msg );
400 
401  msg.Printf( _( "Failed to load \"%s\"" ), fullFileName );
402  AppendMsgPanel( wxEmptyString, msg, CYAN );
403 
404  return false;
405  }
406 
407  // It's possible the schematic parser fixed errors due to bugs so warn the user
408  // that the schematic has been fixed (modified).
409  SCH_SHEET_LIST sheetList = Schematic().GetSheets();
410 
411  if( sheetList.IsModified() )
412  {
413  DisplayInfoMessage( this,
414  _( "An error was found when loading the schematic that has "
415  "been automatically fixed. Please save the schematic to "
416  "repair the broken file or it may not be usable with other "
417  "versions of KiCad." ) );
418  }
419 
420  if( sheetList.AllSheetPageNumbersEmpty() )
421  sheetList.SetInitialPageNumbers();
422 
423  UpdateFileHistory( fullFileName );
424 
425  SCH_SCREENS schematic( Schematic().Root() );
426 
427  // LIB_ID checks and symbol rescue only apply to the legacy file formats.
428  if( schFileType == SCH_IO_MGR::SCH_LEGACY )
429  {
430  // Convert old projects over to use symbol library table.
431  if( schematic.HasNoFullyDefinedLibIds() )
432  {
433  DIALOG_SYMBOL_REMAP dlgRemap( this );
434 
435  dlgRemap.ShowQuasiModal();
436  }
437  else
438  {
439  // Double check to ensure no legacy library list entries have been
440  // added to the projec file symbol library list.
441  wxString paths;
442  wxArrayString libNames;
443 
444  PART_LIBS::LibNamesAndPaths( &Prj(), false, &paths, &libNames );
445 
446  if( !libNames.IsEmpty() )
447  {
449  {
450  wxRichMessageDialog invalidLibDlg(
451  this,
452  _( "Illegal entry found in project file symbol library list." ),
453  _( "Project Load Warning" ),
454  wxOK | wxCENTER | wxICON_EXCLAMATION );
455  invalidLibDlg.ShowDetailedText(
456  _( "Symbol libraries defined in the project file symbol library "
457  "list are no longer supported and will be removed.\n\nThis may "
458  "cause broken symbol library links under certain conditions." ) );
459  invalidLibDlg.ShowCheckBox( _( "Do not show this dialog again." ) );
460  invalidLibDlg.ShowModal();
462  !invalidLibDlg.IsCheckBoxChecked();
463  }
464 
465  libNames.Clear();
466  paths.Clear();
467  PART_LIBS::LibNamesAndPaths( &Prj(), true, &paths, &libNames );
468  }
469 
470  if( !cfg || !cfg->m_RescueNeverShow )
471  {
473  editor->RescueSymbolLibTableProject( false );
474  }
475  }
476 
477  // Update all symbol library links for all sheets.
478  schematic.UpdateSymbolLinks();
479 
480  if( !cfg || cfg->m_Appearance.show_sexpr_file_convert_warning )
481  {
482  wxRichMessageDialog newFileFormatDlg(
483  this,
484  _( "The schematic file will be converted to the new file format on save." ),
485  _( "Project Load Warning" ),
486  wxOK | wxCENTER | wxICON_EXCLAMATION );
487  newFileFormatDlg.ShowDetailedText(
488  _( "This schematic was saved in the legacy file format which is no "
489  "longer supported and will be saved using the new file format.\n\nThe "
490  "new file format cannot be opened with previous versions of KiCad." ) );
491  newFileFormatDlg.ShowCheckBox( _( "Do not show this dialog again." ) );
492  newFileFormatDlg.ShowModal();
493 
494  if( cfg )
495  cfg->m_Appearance.show_sexpr_file_convert_warning =
496  !newFileFormatDlg.IsCheckBoxChecked();
497  }
498 
499  // Legacy schematic can have duplicate time stamps so fix that before converting
500  // to the s-expression format.
501  schematic.ReplaceDuplicateTimeStamps();
502 
503  // Allow the schematic to be saved to new file format without making any edits.
504  OnModify();
505  }
506  else // S-expression schematic.
507  {
508  for( SCH_SCREEN* screen = schematic.GetFirst(); screen; screen = schematic.GetNext() )
509  screen->UpdateLocalLibSymbolLinks();
510 
511  // Restore all of the loaded symbol and sheet instances from the root sheet.
512  sheetList.UpdateSymbolInstances( Schematic().RootScreen()->GetSymbolInstances() );
513  sheetList.UpdateSheetInstances( Schematic().RootScreen()->GetSheetInstances() );
514  }
515 
517 
518  SetScreen( GetCurrentSheet().LastScreen() );
519 
520  // Migrate conflicting bus definitions
521  // TODO(JE) This should only run once based on schematic file version
522  if( Schematic().ConnectionGraph()->GetBusesNeedingMigration().size() > 0 )
523  {
524  DIALOG_MIGRATE_BUSES dlg( this );
525  dlg.ShowQuasiModal();
527  OnModify();
528  }
529 
530  GetScreen()->TestDanglingEnds(); // Only perform the dangling end test on root sheet.
533  GetScreen()->m_Initialized = true;
534  }
535 
536  // Load any exclusions from the project file
538 
541 
543 
544  // re-create junctions if needed. Eeschema optimizes wires by merging
545  // colinear segments. If a schematic is saved without a valid
546  // cache library or missing installed libraries, this can cause connectivity errors
547  // unless junctions are added.
548  FixupJunctions();
549 
550  SyncView();
552 
553  UpdateTitle();
554 
555  wxFileName fn = Prj().AbsolutePath( GetScreen()->GetFileName() );
556  m_infoBar->Dismiss();
557 
558  if( fn.FileExists() && !fn.IsFileWritable() )
559  {
562  m_infoBar->ShowMessage( "Schematic file is read only.", wxICON_WARNING );
563  }
564 
565 #ifdef PROFILE
566  openFiles.Show();
567 #endif
568 
569  return true;
570 }
571 
572 
574 {
575  wxString fullFileName;
576  SCH_SCREEN* screen = GetScreen();
577 
578  if( !screen )
579  {
580  wxLogError( wxT( "Document not ready, cannot import" ) );
581  return false;
582  }
583 
584  // open file chooser dialog
585  wxString path = wxPathOnly( Prj().GetProjectFullName() );
586 
587  wxFileDialog dlg( this, _( "Append Schematic" ), path, wxEmptyString,
588  KiCadSchematicFileWildcard(), wxFD_OPEN | wxFD_FILE_MUST_EXIST );
589 
590  if( dlg.ShowModal() == wxID_CANCEL )
591  return false;
592 
593  fullFileName = dlg.GetPath();
594 
595  if( !LoadSheetFromFile( GetCurrentSheet().Last(), &GetCurrentSheet(), fullFileName ) )
596  return false;
597 
598  SCH_SCREENS screens( GetCurrentSheet().Last() );
599  screens.TestDanglingEnds();
600 
603 
604  SyncView();
605  HardRedraw(); // Full reinit of the current screen and the display.
606  OnModify();
607 
608  return true;
609 }
610 
611 
612 void SCH_EDIT_FRAME::OnAppendProject( wxCommandEvent& event )
613 {
614  if( GetScreen() && GetScreen()->IsModified() )
615  {
616  wxString msg = _( "This operation cannot be undone.\n\n"
617  "Do you want to save the current document before proceeding?" );
618 
619  if( IsOK( this, msg ) )
620  SaveProject();
621  }
622 
623  AppendSchematic();
624 }
625 
626 
627 void SCH_EDIT_FRAME::OnImportProject( wxCommandEvent& aEvent )
628 {
629  if( !AskToSaveChanges() )
630  return;
631 
632  // Set the project location if none is set
633  bool setProject = Prj().GetProjectFullName().IsEmpty();
634  wxString path = wxPathOnly( Prj().GetProjectFullName() );
635 
636  // clang-format off
637  std::list<std::pair<const wxString, const SCH_IO_MGR::SCH_FILE_T>> loaders;
638 
639  if( ADVANCED_CFG::GetCfg().m_PluginAltiumSch )
640  loaders.emplace_back( AltiumSchematicFileWildcard(), SCH_IO_MGR::SCH_ALTIUM ); // Import Altium schematic files
641 
642  loaders.emplace_back( CadstarSchematicArchiveFileWildcard(), SCH_IO_MGR::SCH_CADSTAR_ARCHIVE ); //Import CADSTAR Schematic Archive files
643  loaders.emplace_back( EagleSchematicFileWildcard(), SCH_IO_MGR::SCH_EAGLE ); // Import Eagle schematic files
644  // clang-format on
645 
646  wxString fileFilters;
647  wxString allWildcards;
648 
649  for( auto& loader : loaders )
650  {
651  if( !fileFilters.IsEmpty() )
652  fileFilters += wxChar( '|' );
653 
654  fileFilters += wxGetTranslation( loader.first );
655 
656  SCH_PLUGIN::SCH_PLUGIN_RELEASER plugin( SCH_IO_MGR::FindPlugin( loader.second ) );
657  wxCHECK( plugin, /*void*/ );
658  allWildcards += "*." + formatWildcardExt( plugin->GetFileExtension() ) + ";";
659  }
660 
661  fileFilters = _( "All supported formats|" ) + allWildcards + "|" + fileFilters;
662 
663  wxFileDialog dlg( this, _( "Import Schematic" ), path, wxEmptyString, fileFilters,
664  wxFD_OPEN | wxFD_FILE_MUST_EXIST ); // TODO
665 
666  if( dlg.ShowModal() == wxID_CANCEL )
667  return;
668 
669  if( setProject )
670  {
671  if( !Prj().IsNullProject() )
673 
674  Schematic().SetProject( nullptr );
676 
677  Schematic().Reset();
678 
679  wxFileName projectFn( dlg.GetPath() );
680  projectFn.SetExt( ProjectFileExtension );
681  GetSettingsManager()->LoadProject( projectFn.GetFullPath() );
682 
683  Schematic().SetProject( &Prj() );
684  }
685 
686  wxFileName fn = dlg.GetPath();
687 
688  SCH_IO_MGR::SCH_FILE_T pluginType = SCH_IO_MGR::SCH_FILE_T::SCH_FILE_UNKNOWN;
689 
690  for( auto& loader : loaders )
691  {
692  if( fn.GetExt().CmpNoCase( SCH_IO_MGR::GetFileExtension( loader.second ) ) == 0 )
693  {
694  pluginType = loader.second;
695  break;
696  }
697  }
698 
699  if( pluginType == SCH_IO_MGR::SCH_FILE_T::SCH_FILE_UNKNOWN )
700  {
701  wxLogError( wxString::Format( "unexpected file extension: %s", fn.GetExt() ) );
702  return;
703  }
704 
705  importFile( dlg.GetPath(), pluginType );
706 }
707 
708 
710 {
711  wxString msg;
712  SCH_SCREEN* screen;
713  SCH_SCREENS screens( Schematic().Root() );
714  bool success = true;
715  bool updateFileType = false;
716 
717  // I want to see it in the debugger, show me the string! Can't do that with wxFileName.
718  wxString fileName = Prj().AbsolutePath( Schematic().Root().GetFileName() );
719  wxFileName fn = fileName;
720 
721  if( fn.IsOk() && !fn.IsDirWritable() )
722  {
723  msg = wxString::Format( _( "Directory \"%s\" is not writable." ), fn.GetPath() );
724  DisplayError( this, msg );
725  return false;
726  }
727 
728  // Warn user on potential file overwrite. This can happen on shared sheets.
729  wxArrayString overwrittenFiles;
730 
731  for( size_t i = 0; i < screens.GetCount(); i++ )
732  {
733  screen = screens.GetScreen( i );
734 
735  wxCHECK2( screen, continue );
736 
737  // Convert legacy schematics file name extensions for the new format.
738  wxFileName tmpFn = screen->GetFileName();
739 
740  if( !tmpFn.IsOk() )
741  continue;
742 
743  if( tmpFn.GetExt() == KiCadSchematicFileExtension )
744  continue;
745 
746  tmpFn.SetExt( KiCadSchematicFileExtension );
747 
748  if( tmpFn.FileExists() )
749  overwrittenFiles.Add( tmpFn.GetFullPath() );
750  }
751 
752  if( !overwrittenFiles.IsEmpty() )
753  {
754  for( auto overwrittenFile : overwrittenFiles )
755  {
756  if( msg.IsEmpty() )
757  msg = overwrittenFile;
758  else
759  msg += "\n" + overwrittenFile;
760  }
761 
762  wxRichMessageDialog dlg(
763  this,
764  _( "Saving the project to the new file format will overwrite existing files." ),
765  _( "Project Save Warning" ),
766  wxOK | wxCANCEL | wxCANCEL_DEFAULT | wxCENTER | wxICON_EXCLAMATION );
767  dlg.ShowDetailedText( wxString::Format(
768  _( "The following files will be overwritten:\n\n%s" ), msg ) );
769  dlg.SetOKCancelLabels( wxMessageDialog::ButtonLabel( _( "Overwrite Files" ) ),
770  wxMessageDialog::ButtonLabel( _( "Abort Project Save" ) ) );
771 
772  if( dlg.ShowModal() == wxID_CANCEL )
773  return false;
774  }
775 
776  screens.BuildClientSheetPathList();
777 
778  for( size_t i = 0; i < screens.GetCount(); i++ )
779  {
780  screen = screens.GetScreen( i );
781 
782  wxCHECK2( screen, continue );
783 
784  // Convert legacy schematics file name extensions for the new format.
785  wxFileName tmpFn = screen->GetFileName();
786 
787  if( tmpFn.IsOk() && tmpFn.GetExt() != KiCadSchematicFileExtension )
788  {
789  updateFileType = true;
790  tmpFn.SetExt( KiCadSchematicFileExtension );
791 
792  for( auto item : screen->Items().OfType( SCH_SHEET_T ) )
793  {
794  SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item );
795  wxFileName sheetFileName = sheet->GetFileName();
796 
797  if( !sheetFileName.IsOk() || sheetFileName.GetExt() == KiCadSchematicFileExtension )
798  continue;
799 
800  sheetFileName.SetExt( KiCadSchematicFileExtension );
801  sheet->SetFileName( sheetFileName.GetFullPath() );
802  UpdateItem( sheet );
803  }
804 
805  screen->SetFileName( tmpFn.GetFullPath() );
806  }
807 
808  std::vector<SCH_SHEET_PATH>& sheets = screen->GetClientSheetPaths();
809 
810  if( sheets.size() == 1 )
811  screen->SetVirtualPageNumber( 1 );
812  else
813  screen->SetVirtualPageNumber( 0 ); // multiple uses; no way to store the real sheet #
814 
815  success &= SaveEEFile( screens.GetSheet( i ) );
816  }
817 
818  if( updateFileType )
819  UpdateFileHistory( Schematic().RootScreen()->GetFileName() );
820 
821  // Save the sheet name map to the project file
822  std::vector<FILE_INFO_PAIR>& sheets = Prj().GetProjectFile().GetSheets();
823  sheets.clear();
824 
825  for( SCH_SHEET_PATH& sheetPath : Schematic().GetSheets() )
826  {
827  SCH_SHEET* sheet = sheetPath.Last();
828  sheets.emplace_back( std::make_pair( sheet->m_Uuid, sheet->GetName() ) );
829  }
830 
831  if( !Prj().IsNullProject() )
832  Pgm().GetSettingsManager().SaveProject();
833 
834  if( !Kiface().IsSingle() )
835  {
836  WX_STRING_REPORTER backupReporter( &msg );
837 
838  if( !GetSettingsManager()->TriggerBackupIfNeeded( backupReporter ) )
839  SetStatusText( msg, 0 );
840  }
841 
842  UpdateTitle();
843 
844  return success;
845 }
846 
847 
849 {
850  wxFileName tmpFileName = Schematic().Root().GetFileName();
851  wxFileName fn = tmpFileName;
852  wxFileName tmp;
853  SCH_SCREENS screens( Schematic().Root() );
854 
855  bool autoSaveOk = true;
856 
857  tmp.AssignDir( fn.GetPath() );
858 
859  if( !tmp.IsOk() )
860  return false;
861 
862  if( !IsWritable( tmp ) )
863  return false;
864 
865  for( size_t i = 0; i < screens.GetCount(); i++ )
866  {
867  // Only create auto save files for the schematics that have been modified.
868  if( !screens.GetScreen( i )->IsSave() )
869  continue;
870 
871  tmpFileName = fn = screens.GetScreen( i )->GetFileName();
872 
873  // Auto save file name is the normal file name prefixed with GetAutoSavePrefix().
874  fn.SetName( GetAutoSaveFilePrefix() + fn.GetName() );
875 
876  screens.GetScreen( i )->SetFileName( fn.GetFullPath() );
877 
878  if( SaveEEFile( screens.GetSheet( i ), false ) )
879  screens.GetScreen( i )->SetModify();
880  else
881  autoSaveOk = false;
882 
883  screens.GetScreen( i )->SetFileName( tmpFileName.GetFullPath() );
884  }
885 
886  if( autoSaveOk )
887  {
888  m_autoSaveState = false;
889 
890  if( !Kiface().IsSingle() &&
892  {
894  }
895  }
896 
897  return autoSaveOk;
898 }
899 
900 
901 bool SCH_EDIT_FRAME::importFile( const wxString& aFileName, int aFileType )
902 {
903  wxFileName newfilename;
904  SCH_SHEET_LIST sheetList = Schematic().GetSheets();
905 
906  switch( (SCH_IO_MGR::SCH_FILE_T) aFileType )
907  {
908  case SCH_IO_MGR::SCH_ALTIUM:
909  case SCH_IO_MGR::SCH_CADSTAR_ARCHIVE:
910  case SCH_IO_MGR::SCH_EAGLE:
911  // We insist on caller sending us an absolute path, if it does not, we say it's a bug.
912  wxASSERT_MSG( wxFileName( aFileName ).IsAbsolute(),
913  wxT( "Import eagle schematic caller didn't send full filename" ) );
914 
915  if( !LockFile( aFileName ) )
916  {
917  wxString msg = wxString::Format( _( "Schematic file \"%s\" is already open." ),
918  aFileName );
919  DisplayError( this, msg );
920  return false;
921  }
922 
923  try
924  {
926  SCH_IO_MGR::FindPlugin( (SCH_IO_MGR::SCH_FILE_T) aFileType ) );
927  Schematic().SetRoot( pi->Load( aFileName, &Schematic() ) );
928 
929  // Eagle sheets do not use a worksheet frame by default, so set it to an empty one
931  pglayout.SetEmptyLayout();
932 
933  BASE_SCREEN::m_PageLayoutDescrFileName = "empty.kicad_wks";
934  wxFileName layoutfn( Prj().GetProjectPath(), BASE_SCREEN::m_PageLayoutDescrFileName );
935  wxFile layoutfile;
936 
937  if( layoutfile.Create( layoutfn.GetFullPath() ) )
938  {
939  layoutfile.Write( WS_DATA_MODEL::EmptyLayout() );
940  layoutfile.Close();
941  }
942 
943  newfilename.SetPath( Prj().GetProjectPath() );
944  newfilename.SetName( Prj().GetProjectName() );
945  newfilename.SetExt( LegacySchematicFileExtension );
946 
947  SetScreen( GetCurrentSheet().LastScreen() );
948 
949  Schematic().Root().SetFileName( newfilename.GetFullPath() );
950  GetScreen()->SetFileName( newfilename.GetFullPath() );
951  GetScreen()->SetModify();
952 
954 
955  UpdateFileHistory( aFileName );
956  SCH_SCREENS schematic( Schematic().Root() );
957  schematic.UpdateSymbolLinks(); // Update all symbol library links for all sheets.
958 
959  GetScreen()->m_Initialized = true;
960 
961  for( SCH_SCREEN* screen = schematic.GetFirst(); screen; screen = schematic.GetNext() )
962  {
963  for( auto item : screen->Items().OfType( SCH_COMPONENT_T ) )
964  {
965  std::vector<wxPoint> pts;
966  SCH_COMPONENT* cmp = static_cast<SCH_COMPONENT*>( item );
967 
968  // Update footprint LIB_ID to point to the imported Eagle library
969  SCH_FIELD* fpField = cmp->GetField( FOOTPRINT_FIELD );
970 
971  if( !fpField->GetText().IsEmpty() )
972  {
973  LIB_ID fpId;
974  fpId.Parse( fpField->GetText(), LIB_ID::ID_SCH, true );
975  fpId.SetLibNickname( newfilename.GetName() );
976  fpField->SetText( fpId.Format() );
977  }
978  }
979  }
980 
981  // Only perform the dangling end test on root sheet.
983 
985 
988  SyncView();
989  UpdateTitle();
990  }
991  catch( const IO_ERROR& ioe )
992  {
993  // Do not leave g_RootSheet == NULL because it is expected to be
994  // a valid sheet. Therefore create a dummy empty root sheet and screen.
995  CreateScreens();
997 
998  wxString msg;
999  msg.Printf( _( "Error loading schematic \"%s\".\n%s" ), aFileName, ioe.What() );
1000  DisplayError( this, msg );
1001 
1002  msg.Printf( _( "Failed to load \"%s\"" ), aFileName );
1003  AppendMsgPanel( wxEmptyString, msg, CYAN );
1004 
1005  return false;
1006  }
1007 
1008  return true;
1009 
1010  default:
1011  return false;
1012  }
1013 }
1014 
1015 
1017 {
1018  SCH_SCREENS screenList( Schematic().Root() );
1019 
1020  // Save any currently open and modified project files.
1021  for( SCH_SCREEN* screen = screenList.GetFirst(); screen; screen = screenList.GetNext() )
1022  {
1023  if( screen->IsModify() )
1024  {
1025  if( !HandleUnsavedChanges( this, _( "The current schematic has been modified. "
1026  "Save changes?" ),
1027  [&]()->bool { return SaveProject(); } ) )
1028  {
1029  return false;
1030  }
1031  }
1032  }
1033 
1034  return true;
1035 }
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:240
WS_DATA_MODEL handles the graphic items list to draw/plot the frame and title block.
Definition: ws_data_model.h:38
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
void ShowMessage(const wxString &aMessage, int aFlags=wxICON_INFORMATION) override
Show the info bar with the provided message and icon.
Definition: infobar.cpp:120
SCH_FIELD instances are attached to a component and provide a place for the component's value,...
Definition: sch_field.h:51
void Save_File(bool doSaveAs=false)
bool HandleUnsavedChanges(wxWindow *aParent, const wxString &aMessage, const std::function< bool()> &aSaveFunction)
Display a dialog with Save, Cancel and Discard Changes buttons.
Definition: confirm.cpp:202
bool IsModified()
Check the entire hierarchy for any modifications.
const wxString & GetFileName() const
Definition: sch_screen.h:186
SCH_SCREEN * GetNext()
void UpdateItem(EDA_ITEM *aItem, bool isAddOrDelete=false)
Mark an item for refresh.
bool OpenProjectFiles(const std::vector< wxString > &aFileSet, int aCtl=0) override
Function OpenProjectFiles is abstract, and opens a project or set of files given by aFileList.
static void LibNamesAndPaths(PROJECT *aProject, bool doSave, wxString *aPaths, wxArrayString *aNames=NULL)
Save or load the names of the currently configured part libraries (without paths).
void SetVirtualPageNumber(int aPageNumber)
Definition: base_screen.h:141
SCH_SHEET_LIST GetSheets() const
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:97
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.
SETTINGS_MANAGER * GetSettingsManager() const
const wxChar *const traceAutoSave
Flag to enable auto save feature debug tracing.
void RecalculateConnections(SCH_CLEANUP_FLAGS aCleanupFlags)
Generates the connection data for the entire schematic hierarchy.
void SaveProjectSettings() override
Save changes to the project settings to the project (.pro) file.
Model changes (required full reload)
Definition: tool_base.h:82
CONNECTION_GRAPH * ConnectionGraph() const
Definition: schematic.h:137
SCH_SHEET * Last() const
Return a pointer to the last SCH_SHEET of the list.
This file is part of the common library.
void SaveProjectAs(const wxString &aFullPath)
Sets the currently loaded project path and saves it (pointers remain valid)
const std::string ProjectFileExtension
void SetScreen(BASE_SCREEN *aScreen) override
#define KICTL_CREATE
caller thinks requested project files may not exist
Definition: kiway_player.h:81
EE_TYPE OfType(KICAD_T aType)
Definition: sch_rtree.h:219
bool AskToSaveChanges()
Checks if any of the screens has unsaved changes and asks the user whether to save or drop them.
wxString KiCadSchematicFileWildcard()
AUTO_BACKUP m_Backup
void ResolveERCExclusions()
Update markers to match recorded exclusions.
static TOOL_ACTION zoomFitScreen
Definition: actions.h:94
void UpdateTitle()
Set the main window title bar text.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:141
void OnAppendProject(wxCommandEvent &event)
static wxString EmptyLayout()
Returns a string containing the empty layout shape.
bool IsWritable(const wxFileName &aFileName)
Checks if aFileName can be written.
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:284
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:102
The class PROF_COUNTER is a small class to help profiling.
Definition: profile.h:44
bool importFile(const wxString &aFileName, int aFileType)
Load the given filename but sets the path to the current project path.
bool SaveEEFile(SCH_SHEET *aSheet, bool aSaveUnderNewName=false)
Save aSheet to a schematic file.
void LoadWindowState(const wxString &aFileName)
void UpdateFileHistory(const wxString &FullFileName, FILE_HISTORY *aFileHistory=nullptr)
Update the list of recently opened files.
void UpdateSheetInstances(const std::vector< SCH_SHEET_INSTANCE > &aSheetInstances)
Update all of the sheet instance information using aSheetInstances.
VTBL_ENTRY const wxString AbsolutePath(const wxString &aFileName) const
Function AbsolutePath fixes up aFileName if it is relative to the project's directory to be an absolu...
Definition: project.cpp:270
static WS_DATA_MODEL & GetTheInstance()
static function: returns the instance of WS_DATA_MODEL used in the application
void OnImportProject(wxCommandEvent &event)
VTBL_ENTRY void SetElem(ELEM_T aIndex, _ELEM *aElem)
Definition: project.cpp:258
static wxString m_PageLayoutDescrFileName
the name of the page layout descr file, or emty to used the default pagelayout
Definition: base_screen.h:84
EESCHEMA_SETTINGS * eeconfig() const
void SetShutdownBlockReason(wxWindow *aWindow, const wxString &aReason)
Sets the block reason why the window/application is preventing OS shutdown.
Definition: gtk/app.cpp:51
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
void SetRoot(SCH_SHEET *aRootSheet)
Initializes the schematic with a new root sheet.
Definition: schematic.cpp:100
bool RescueSymbolLibTableProject(bool aRunningOnDemand)
SCH_EDITOR_CONTROL.
static SCH_FILE_T GuessPluginTypeFromSchPath(const wxString &aSchematicPath)
Return a plugin type given a schematic using the file extension of aSchematicPath.
Definition: sch_io_mgr.cpp:187
wxString GetMruPath() const
wxString CadstarSchematicArchiveFileWildcard()
void Dismiss() override
Dismisses the infobar and updates the containing layout and AUI manager (if one is provided).
Definition: infobar.cpp:140
Base class that schematic file and library loading and saving plugins should derive from.
Definition: sch_io_mgr.h:153
void SetFileName(wxString aFilename)
Definition: sch_sheet.h:504
bool LoadSheetFromFile(SCH_SHEET *aSheet, SCH_SHEET_PATH *aHierarchy, const wxString &aFileName)
Load a the KiCad schematic file aFileName into the sheet aSheet.
Definition: sheet.cpp:101
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:121
void CheckForAutoSaveFile(const wxFileName &aFileName)
Check if an auto save file exists for aFileName and takes the appropriate action depending on the use...
wxString GetName() const
Definition: sch_sheet.h:282
#define NULL
bool IsSingle() const
Function IsSingle is this KIFACE_I running under single_top?
Definition: kiface_i.h:117
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:29
int RecomputeIntersheetsRefs()
void HardRedraw() override
Rebuild the GAL and redraw the screen.
void SyncView()
Mark all items for refresh.
bool TriggerBackupIfNeeded(REPORTER &aReporter) const
Calls BackupProject if a new backup is needed according to the current backup policy.
bool m_Initialized
Definition: base_screen.h:101
static const wxString GetFileExtension(SCH_FILE_T aFileType)
Return the schematic file extension for aFileType.
Definition: sch_io_mgr.cpp:139
int ShowQuasiModal()
VTBL_ENTRY PROJECT_FILE & GetProjectFile() const
Definition: project.h:143
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
COMMON_SETTINGS * GetCommonSettings() const
Retrieves the common settings shared by all applications.
SCHEMATIC & Schematic() const
void BuildClientSheetPathList()
built the list of sheet paths sharing a screen for each screen in use
Definition of file extensions used in Kicad.
bool AppendSchematic()
Import a KiCad schematic into the current sheet.
bool CreateArchiveLibraryCacheFile(bool aUseCurrentSheetFilename=false)
Create a symbol library file with the name of the root document plus the '-cache' suffix,...
Definition: libarch.cpp:42
wxString formatWildcardExt(const wxString &aWildcard)
Format wildcard extension to support case sensitive file dialogs.
Definition: color4d.h:59
wxLogTrace helper definitions.
size_t GetCount() const
Definition: sch_screen.h:532
bool HasNoFullyDefinedLibIds()
Test all of the schematic symbols to see if all LIB_ID objects library nickname is not set.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
VTBL_ENTRY const wxString GetProjectFullName() const
Function GetProjectFullName returns the full path and name of the project.
Definition: project.cpp:116
wxString GetFileName() const
Return the filename corresponding to this sheet.
Definition: sch_sheet.h:498
void SetProject(PROJECT *aPrj)
Definition: schematic.cpp:73
virtual void ClearMsgPanel()
Clear all messages from the message panel.
VTBL_ENTRY bool IsNullProject() const
Checks if this project is a null project (i.e.
Definition: project.cpp:134
void UpdateSymbolInstances(const std::vector< SYMBOL_INSTANCE_REFERENCE > &aSymbolInstances)
Update all of the symbol instance information using aSymbolInstances.
const std::string LegacySchematicFileExtension
void RemoveAllButtons()
Remove all the buttons that have been added by the user.
Definition: infobar.cpp:226
UTF8 Format() const
Definition: lib_id.cpp:237
bool LoadProjectSettings()
Loads the KiCad project file (*.pro) settings specific to Eeschema.
WX_STRING_REPORTER is a wrapper for reporting to a wxString object.
Definition: reporter.h:161
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:219
Field Name Module PCB, i.e. "16DIP300".
bool doAutoSave() override
Save the schematic files that have been modified and not yet saved.
const KIID m_Uuid
Definition: eda_item.h:151
int SetLibNickname(const UTF8 &aNickname)
Override the logical library name portion of the LIB_ID to aNickname.
Definition: lib_id.cpp:193
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
static wxString GetAutoSaveFilePrefix()
Helper object to release a SCH_PLUGIN in the context of a potential thrown exception through its dest...
Definition: sch_io_mgr.h:470
bool LoadProject(const wxString &aFullPath, bool aSetActive=true)
Loads a project or sets up a new project with a specified path.
void Reset()
Initializes this schematic to a blank one, unloading anything existing.
Definition: schematic.cpp:50
std::vector< FILE_INFO_PAIR > & GetSheets()
Definition: project_file.h:82
bool AllSheetPageNumbersEmpty() const
Check all of the sheet instance for empty page numbers.
SCH_SHEET & Root() const
Definition: schematic.h:102
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:48
see class PGM_BASE
bool IsSave() const
Definition: base_screen.h:125
void TestDanglingEnds()
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
wxString EagleSchematicFileWildcard()
WX_INFOBAR * m_infoBar
#define _(s)
Definition: 3d_actions.cpp:33
bool UnloadProject(PROJECT *aProject, bool aSave=true)
Saves, unloads and unregisters the given PROJECT.
EE_RTREE & Items()
Definition: sch_screen.h:159
bool SaveProject(const wxString &aFullPath=wxEmptyString)
Saves a loaded project.
SCH_SHEET * GetSheet(unsigned int aIndex) const
const std::string KiCadSchematicFileExtension
void ClrModify()
Definition: base_screen.h:121
Schematic symbol object.
Definition: sch_component.h:79
wxString GetCurrentFileName() const override
Get the full filename + path of the currently opened file in the frame.
bool backup_on_autosave
Trigger a backup on autosave.
SCH_SHEET_PATH & GetCurrentSheet() const
int ReplaceDuplicateTimeStamps()
Test all sheet and component objects in the schematic for duplicate time stamps and replaces them as ...
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
std::vector< SCH_SHEET_PATH > & GetClientSheetPaths()
Definition: sch_screen.h:206
SCH_SCREEN * GetFirst()
void Show(std::ostream &aStream=std::cerr)
Print the elapsed time (in a suitable unit) to a stream.
Definition: profile.h:99
SCH_SCREEN * GetScreen(unsigned int aIndex) const
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current screen and u...
void ClearDrawingState()
Clear the state flags of all the items in the screen.
Definition: sch_screen.cpp:832
void SetFileName(const wxString &aFileName)
Definition: sch_screen.h:184
static REPORTER & GetInstance()
Definition: reporter.cpp:105
Definition for part library class.
void SetModify()
Definition: base_screen.h:120
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
int Parse(const UTF8 &aId, LIB_ID_TYPE aType, bool aFix=false)
Parse LIB_ID with the information from aId.
Definition: lib_id.cpp:122
void UpdateSymbolLinks(REPORTER *aReporter=nullptr)
Initialize the LIB_PART reference for each SCH_COMPONENT found in the full schematic.
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition: confirm.cpp:268
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
virtual void ClearUndoRedoList()
Function ClearUndoRedoList clear undo and redo list, using ClearUndoORRedoList() picked items are del...
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:133
wxString AltiumSchematicFileWildcard()
void ClrSave()
Definition: base_screen.h:123
void SetInitialPageNumbers()
Set initial sheet page numbers.
VTBL_ENTRY void SetReadOnly(bool aReadOnly=true)
Definition: project.h:124
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:521
bool LockFile(const wxString &aFileName)
Mark a schematic file as being in use.
bool TestDanglingEnds(const SCH_SHEET_PATH *aPath=nullptr)
Test all of the connectable objects in the schematic for unused connection points.
bool RegisterApplicationRestart(const wxString &aCommandLine)
Registers the application for restart with the OS with the given command line string to pass as args.
Definition: gtk/app.cpp:26
void AddCloseButton(const wxString &aTooltip=_("Hide this message."))
Add the default close button to the infobar on the right side.
Definition: infobar.cpp:216
void AppendMsgPanel(const wxString &aTextUpper, const wxString &aTextLower, int aPadding=6)
Append a message to the message panel.