66#include <wx/filedlg.h>
68#include <wx/stdpaths.h>
77#include "widgets/filedlg_hook_save_project.h"
90 if( aFileSet.size() != 1 )
92 msg.Printf(
"Eeschema:%s() takes only a single filename.", __WXFUNCTION__ );
97 wxString fullFileName( aFileSet[0] );
98 wxFileName wx_filename( fullFileName );
101 wxASSERT_MSG( wx_filename.IsAbsolute(), wxT(
"Path is not absolute!" ) );
105 msg.Printf(
_(
"Schematic '%s' is already open by '%s' at '%s'." ), fullFileName,
121 wxFileName pro = fullFileName;
124 bool is_new = !wxFileName::IsFileReadable( fullFileName );
130 msg.Printf(
_(
"Schematic '%s' does not exist. Do you wish to create it?" ),
133 if( !
IsOK(
this, msg ) )
145 SetStatusText( wxEmptyString );
149 :
_(
"Loading Schematic" ), 1 );
153 if( differentProject )
155 if( !
Prj().IsNullProject() )
163 wxFileName legacyPro( pro );
168 if( !pro.Exists() && !legacyPro.Exists() && !( aCtl &
KICTL_CREATE ) )
176 if( schFileType == SCH_IO_MGR::SCH_LEGACY )
199 Prj().SchSymbolLibTable();
206 rfn.MakeRelativeTo(
Prj().GetProjectPath() );
224 wxFileName autoSaveFn = fullFileName;
227 autoSaveFn.ClearExt();
233 SCH_PLUGIN* plugin = SCH_IO_MGR::FindPlugin( schFileType );
238 bool failedLoad =
false;
250 "occurred attempting to load hierarchical sheets." ),
256 msg.Printf(
_(
"Error loading schematic '%s'." ), fullFileName);
257 progressReporter.Hide();
264 msg.Printf(
_(
"Error loading schematic '%s'." ), fullFileName);
265 progressReporter.Hide();
270 catch(
const std::bad_alloc& )
272 msg.Printf(
_(
"Memory exhausted loading schematic '%s'." ), fullFileName );
273 progressReporter.Hide();
291 msg.Printf(
_(
"Failed to load '%s'." ), fullFileName );
304 _(
"An error was found when loading the schematic that has "
305 "been automatically fixed. Please save the schematic to "
306 "repair the broken file or it may not be usable with other "
307 "versions of KiCad." ) );
318 if( schFileType == SCH_IO_MGR::SCH_LEGACY )
323 std::vector<SCH_ITEM*> deleted;
325 for(
SCH_ITEM* item : screen->Items() )
330 std::unique_ptr<SCH_LINE> wire = std::make_unique<SCH_LINE>();
334 wire->SetEndPoint( entry->
GetEnd() );
336 screen->Append( wire.release() );
337 deleted.push_back( item );
342 screen->Remove( item );
358 wxArrayString libNames;
362 if( !libNames.IsEmpty() )
364 if(
eeconfig()->m_Appearance.show_illegal_symbol_lib_dialog )
366 wxRichMessageDialog invalidLibDlg(
368 _(
"Illegal entry found in project file symbol library list." ),
369 _(
"Project Load Warning" ),
370 wxOK | wxCENTER | wxICON_EXCLAMATION );
371 invalidLibDlg.ShowDetailedText(
372 _(
"Symbol libraries defined in the project file symbol library "
373 "list are no longer supported and will be removed.\n\n"
374 "This may cause broken symbol library links under certain "
376 invalidLibDlg.ShowCheckBox(
_(
"Do not show this dialog again." ) );
377 invalidLibDlg.ShowModal();
379 !invalidLibDlg.IsCheckBoxChecked();
390 editor->RescueSymbolLibTableProject(
false );
400 wxFileName cacheFn = pro;
402 cacheFn.SetName( cacheFn.GetName() +
"-cache" );
405 msg.Printf(
_(
"The project symbol library cache file '%s' was not found." ),
406 cacheFn.GetFullName() );
407 extMsg =
_(
"This can result in a broken schematic under certain conditions. "
408 "If the schematic does not have any missing symbols upon opening, "
409 "save it immediately before making any changes to prevent data "
410 "loss. If there are missing symbols, either manual recovery of "
411 "the schematic or recovery of the symbol cache library file and "
412 "reloading the schematic is required." );
414 wxMessageDialog dlgMissingCache(
this, msg,
_(
"Warning" ),
415 wxOK | wxCANCEL | wxICON_EXCLAMATION | wxCENTER );
416 dlgMissingCache.SetExtendedMessage( extMsg );
417 dlgMissingCache.SetOKCancelLabels(
418 wxMessageDialog::ButtonLabel(
_(
"Load Without Cache File" ) ),
419 wxMessageDialog::ButtonLabel(
_(
"Abort" ) ) );
421 if( dlgMissingCache.ShowModal() == wxID_CANCEL )
435 "It will be converted to the new format when saved." ),
443 screen->FixLegacyPowerSymbolMismatches();
455 "It will be converted to the new format when saved." ),
460 screen->UpdateLocalLibSymbolLinks();
463 if(
Schematic().RootScreen()->GetFileFormatVersionAtLoad() < 20221002 )
466 if(
Schematic().RootScreen()->GetFileFormatVersionAtLoad() < 20221110 )
469 if(
Schematic().RootScreen()->GetFileFormatVersionAtLoad() < 20230221 )
471 screen->FixLegacyPowerSymbolMismatches();
474 screen->MigrateSimModels();
483 if(
Schematic().ConnectionGraph()->GetBusesNeedingMigration().size() > 0 )
512 if( schFileType == SCH_IO_MGR::SCH_LEGACY )
522 wxCommandEvent e( EDA_EVT_SCHEMATIC_CHANGED );
523 ProcessEventLocally( e );
527 wxCHECK2( listener,
continue );
531 wxWindow* win =
dynamic_cast<wxWindow*
>( listener );
534 win->HandleWindowEvent( e );
536 listener->SafelyProcessEvent( e );
544 if( fn.FileExists() && !fn.IsFileWritable() )
566 wxLogError( wxT(
"Document not ready, cannot import" ) );
571 wxString
path = wxPathOnly(
Prj().GetProjectFullName() );
573 wxFileDialog dlg(
this,
_(
"Insert Schematic" ),
path, wxEmptyString,
576 if( dlg.ShowModal() == wxID_CANCEL )
605 wxString msg =
_(
"This operation cannot be undone.\n\n"
606 "Do you want to save the current document before proceeding?" );
608 if(
IsOK(
this, msg ) )
623 wxString msg =
_(
"This operation replaces the contents of the current project.\n\n"
624 "Do you want to proceed?" );
626 if( !
IsOK(
this, msg ) )
632 wxString
path = wxPathOnly(
Prj().GetProjectFullName() );
634 wxString fileFiltersStr;
635 wxString allWildcardsStr;
637 for(
const SCH_IO_MGR::SCH_FILE_T&
fileType : SCH_IO_MGR::SCH_FILE_T_vector )
639 if(
fileType == SCH_IO_MGR::SCH_KICAD ||
fileType == SCH_IO_MGR::SCH_LEGACY )
652 if( !fileFiltersStr.IsEmpty() )
653 fileFiltersStr += wxChar(
'|' );
661 fileFiltersStr =
_(
"All supported formats" ) + wxT(
"|" ) + allWildcardsStr + wxT(
"|" )
664 wxFileDialog dlg(
this,
_(
"Import Schematic" ),
path, wxEmptyString, fileFiltersStr,
665 wxFD_OPEN | wxFD_FILE_MUST_EXIST );
667 if( dlg.ShowModal() == wxID_CANCEL )
684 wxFileName projectFn( dlg.GetPath() );
691 wxFileName fn = dlg.GetPath();
693 SCH_IO_MGR::SCH_FILE_T pluginType = SCH_IO_MGR::SCH_FILE_T::SCH_FILE_UNKNOWN;
695 for(
const SCH_IO_MGR::SCH_FILE_T&
fileType : SCH_IO_MGR::SCH_FILE_T_vector )
709 if( pluginType == SCH_IO_MGR::SCH_FILE_T::SCH_FILE_UNKNOWN )
711 wxLogError(
_(
"No loader can read the specified file: '%s'." ), fn.GetFullPath() );
724 wxFileName schematicFileName;
725 wxFileName oldFileName;
730 wxCHECK( screen,
false );
733 wxCHECK( !aSavePath.IsEmpty(),
false );
737 oldFileName = schematicFileName;
745 wxFileName projectFile( schematicFileName );
749 if( projectFile.FileExists() )
756 wxString tempFile = wxFileName::CreateTempFileName( wxS(
"eeschema" ) );
759 wxLogTrace(
traceAutoSave, wxS(
"Saving file " ) + schematicFileName.GetFullPath() );
765 schematicFileName.GetFullPath() );
767 if( pluginType == SCH_IO_MGR::SCH_FILE_UNKNOWN )
768 pluginType = SCH_IO_MGR::SCH_KICAD;
779 msg.Printf(
_(
"Error saving schematic file '%s'.\n%s" ),
780 schematicFileName.GetFullPath(),
784 msg.Printf(
_(
"Failed to create temporary file '%s'." ),
789 wxRemoveFile( tempFile );
799 success = wxRenameFile( tempFile, schematicFileName.GetFullPath() );
803 msg.Printf(
_(
"Error saving schematic file '%s'.\n"
804 "Failed to rename temporary file '%s'." ),
805 schematicFileName.GetFullPath(),
809 msg.Printf(
_(
"Failed to rename temporary file '%s'." ),
818 wxFileName autoSaveFileName = schematicFileName;
821 if( autoSaveFileName.FileExists() )
824 wxT(
"Removing auto save file <" ) + autoSaveFileName.GetFullPath() +
827 wxRemoveFile( autoSaveFileName.GetFullPath() );
832 msg.Printf(
_(
"File '%s' saved." ), screen->
GetFileName() );
833 SetStatusText( msg, 0 );
851 bool updateFileHistory =
false;
852 bool createNewProject =
false;
856 wxFileName fn = fileName;
860 std::unordered_map<SCH_SCREEN*, wxString> filenameMap;
863 if(
Prj().IsNullProject() || aSaveAs )
866 wxCHECK(
Kiface().IsSingle() || aSaveAs,
false );
868 wxFileName newFileName;
869 wxFileName savePath(
Prj().GetProjectFullName() );
871 if( !savePath.IsOk() || !savePath.IsDirWritable() )
875 if( !savePath.IsOk() || !savePath.IsDirWritable() )
879 if( savePath.HasExt() )
882 savePath.SetName( wxEmptyString );
884 wxFileDialog dlg(
this,
_(
"Schematic Files" ), savePath.GetPath(),
886 wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
891 if(
Kiface().IsSingle() || aSaveAs )
893 dlg.SetCustomizeHook( newProjectHook );
896 if( dlg.ShowModal() == wxID_CANCEL )
901 if( ( !newFileName.DirExists() && !newFileName.Mkdir() ) ||
902 !newFileName.IsDirWritable() )
904 msg.Printf(
_(
"Folder '%s' could not be created.\n\n"
905 "Make sure you have write permissions and try again." ),
906 newFileName.GetPath() );
908 wxMessageDialog dlgBadPath(
this, msg,
_(
"Error" ),
909 wxOK | wxICON_EXCLAMATION | wxCENTER );
911 dlgBadPath.ShowModal();
922 updateFileHistory =
true;
930 for(
size_t i = 0; i < screens.
GetCount(); i++ )
934 wxCHECK2( screen,
continue );
945 if( tmp.FileExists() )
948 if( tmp.GetPath().IsEmpty() )
950 tmp.SetPath( newFileName.GetPath() );
952 else if( tmp.GetPath() == fn.GetPath() )
954 tmp.SetPath( newFileName.GetPath() );
956 else if( tmp.GetPath().StartsWith( fn.GetPath() ) )
960 wxString newPath = newFileName.GetPath();
961 newPath += tmp.GetPath().Right( fn.GetPath().Length() );
962 tmp.SetPath( newPath );
966 wxT(
"Moving schematic from '%s' to '%s'." ),
970 if( !tmp.DirExists() && !tmp.Mkdir() )
972 msg.Printf(
_(
"Folder '%s' could not be created.\n\n"
973 "Make sure you have write permissions and try again." ),
974 newFileName.GetPath() );
976 wxMessageDialog dlgBadFilePath(
this, msg,
_(
"Error" ),
977 wxOK | wxICON_EXCLAMATION | wxCENTER );
979 dlgBadFilePath.ShowModal();
984 filenameMap[screen] = tmp.GetFullPath();
994 if( sheet.Last()->IsRootSheet() )
997 sheet.MakeFilePathRelativeToParentSheet();
1000 else if( !fn.FileExists() )
1003 updateFileHistory =
true;
1006 if( filenameMap.empty() || !saveCopy )
1008 for(
size_t i = 0; i < screens.
GetCount(); i++ )
1013 wxArrayString overwrittenFiles;
1015 for(
size_t i = 0; i < screens.
GetCount(); i++ )
1019 wxCHECK2( screen,
continue );
1022 wxFileName tmpFn = filenameMap[screen];
1032 if( tmpFn.FileExists() )
1033 overwrittenFiles.Add( tmpFn.GetFullPath() );
1036 if( !overwrittenFiles.IsEmpty() )
1038 for(
const wxString& overwrittenFile : overwrittenFiles )
1041 msg = overwrittenFile;
1043 msg +=
"\n" + overwrittenFile;
1046 wxRichMessageDialog dlg(
this,
_(
"Saving will overwrite existing files." ),
1047 _(
"Save Warning" ),
1048 wxOK | wxCANCEL | wxCANCEL_DEFAULT | wxCENTER |
1049 wxICON_EXCLAMATION );
1050 dlg.ShowDetailedText(
_(
"The following files will be overwritten:\n\n" ) + msg );
1051 dlg.SetOKCancelLabels( wxMessageDialog::ButtonLabel(
_(
"Overwrite Files" ) ),
1052 wxMessageDialog::ButtonLabel(
_(
"Abort Project Save" ) ) );
1054 if( dlg.ShowModal() == wxID_CANCEL )
1060 for(
size_t i = 0; i < screens.
GetCount(); i++ )
1064 wxCHECK2( screen,
continue );
1067 wxFileName tmpFn = filenameMap[screen];
1071 updateFileHistory =
true;
1083 sheet->
SetFileName( sheetFileName.GetFullPath() );
1087 filenameMap[screen] = tmpFn.GetFullPath();
1099 if( sheets.size() == 1 )
1105 if( !saveCopy && tmpFn.GetFullPath() != screen->
GetFileName() )
1115 if( !aSaveAs && !success )
1118 if( aSaveAs && success )
1121 if( updateFileHistory )
1132 wxCHECK2( sheet,
continue );
1139 wxCHECK2( screen,
continue );
1141 sheets.emplace_back( std::make_pair( screen->
GetUuid(), sheet->
GetName() ) );
1145 sheets.emplace_back( std::make_pair( sheet->
m_Uuid, sheet->
GetName() ) );
1149 wxASSERT( filenameMap.count(
Schematic().RootScreen() ) );
1150 wxFileName projectPath( filenameMap.at(
Schematic().RootScreen() ) );
1153 if(
Prj().IsNullProject() || ( aSaveAs && !saveCopy ) )
1158 else if( saveCopy && createNewProject )
1167 if( !
Kiface().IsSingle() )
1172 SetStatusText( msg, 0 );
1187 wxFileName fn = tmpFileName;
1195 bool autoSaveOk =
true;
1197 if( fn.GetPath().IsEmpty() )
1198 tmp.AssignDir(
Prj().GetProjectPath() );
1200 tmp.AssignDir( fn.GetPath() );
1208 wxString title = GetTitle();
1210 for(
size_t i = 0; i < screens.
GetCount(); i++ )
1252 wxFileName filename( aFileName );
1253 wxFileName newfilename;
1255 SCH_IO_MGR::SCH_FILE_T
fileType = (SCH_IO_MGR::SCH_FILE_T) aFileType;
1259 case SCH_IO_MGR::SCH_ALTIUM:
1260 case SCH_IO_MGR::SCH_CADSTAR_ARCHIVE:
1261 case SCH_IO_MGR::SCH_EAGLE:
1262 case SCH_IO_MGR::SCH_LTSPICE:
1263 case SCH_IO_MGR::SCH_EASYEDA:
1264 case SCH_IO_MGR::SCH_EASYEDAPRO:
1267 wxCHECK_MSG( filename.IsAbsolute(), ,
1268 wxT(
"Import schematic: path is not absolute!" ) );
1283 errorReporter.ShowModal();
1292 newfilename.SetPath(
Prj().GetProjectPath() );
1293 newfilename.SetName(
Prj().GetProjectName() );
1314 wxString msg = wxString::Format(
_(
"Error loading schematic '%s'." ), aFileName );
1317 msg.Printf(
_(
"Failed to load '%s'." ), aFileName );
1320 catch(
const std::exception& exc )
1325 wxString msg = wxString::Format(
_(
"Unhandled exception occurred loading schematic "
1326 "'%s'." ), aFileName );
1329 msg.Printf(
_(
"Failed to load '%s'." ), aFileName );
1341 wxCommandEvent e( EDA_EVT_SCHEMATIC_CHANGED );
1342 ProcessEventLocally( e );
1346 wxCHECK2( listener,
continue );
1350 wxWindow* win =
dynamic_cast<wxWindow*
>( listener );
1353 win->HandleWindowEvent( e );
1355 listener->SafelyProcessEvent( e );
1380 if( simFrame && !simFrame->Close() )
1383 if( screen->IsContentModified() )
1406 wxLogTrace(
traceAutoSave,
"Creating auto save file %s", autoSaveFileName.GetFullPath() );
1408 wxCHECK( autoSaveFileName.IsDirWritable(),
false );
1412 std::vector< wxString > autoSavedFiles;
1414 for(
size_t i = 0; i < screens.
GetCount(); i++ )
1424 autoSavedFiles.emplace_back( fn.GetFullPath() );
1427 wxTextFile autoSaveFile( autoSaveFileName.GetFullPath() );
1429 if( autoSaveFileName.FileExists() && !wxRemoveFile( autoSaveFileName.GetFullPath() ) )
1431 wxLogTrace(
traceAutoSave,
"Error removing auto save file %s",
1432 autoSaveFileName.GetFullPath() );
1438 if( autoSavedFiles.empty() )
1441 if( !autoSaveFile.Create() )
1444 for(
const wxString& fileName : autoSavedFiles )
1446 wxLogTrace(
traceAutoSave,
"Adding auto save file %s to %s",
1447 fileName, autoSaveFileName.GetName() );
1448 autoSaveFile.AddLine( fileName );
1451 if( !autoSaveFile.Write() )
1454 wxLogTrace(
traceAutoSave,
"Auto save file '%s' written", autoSaveFileName.GetFullName() );
1462 if( !
Pgm().IsGUI() )
1465 wxCHECK_RET( aFileName.IsOk(), wxT(
"Invalid file name!" ) );
1468 wxT(
"Checking for auto save file " ) + aFileName.GetFullPath() );
1470 if( !aFileName.FileExists() )
1474 "Well this is potentially embarrassing!\n"
1475 "It appears that the last time you were editing one or more of the schematic files\n"
1476 "were not saved properly. Do you wish to restore the last saved edits you made?" );
1478 int response = wxMessageBox( msg,
Pgm().App().GetAppDisplayName(), wxYES_NO | wxICON_QUESTION,
1481 wxTextFile autoSaveFile( aFileName.GetFullPath() );
1483 if( !autoSaveFile.Open() )
1485 msg.Printf(
_(
"The file '%s` could not be opened.\n"
1486 "Manual recovery of automatically saved files is required." ),
1487 aFileName.GetFullPath() );
1489 wxMessageBox( msg,
Pgm().App().GetAppDisplayName(), wxOK | wxICON_EXCLAMATION,
this );
1493 if( response == wxYES )
1495 wxArrayString unrecoveredFiles;
1497 for( wxString fn = autoSaveFile.GetFirstLine(); !autoSaveFile.Eof();
1498 fn = autoSaveFile.GetNextLine() )
1500 wxFileName recoveredFn = fn;
1501 wxString tmp = recoveredFn.GetName();
1505 recoveredFn.SetName( tmp );
1507 wxFileName backupFn = recoveredFn;
1511 wxLogTrace(
traceAutoSave, wxT(
"Recovering auto save file:\n"
1512 " Original file: '%s'\n"
1513 " Backup file: '%s'\n"
1514 " Auto save file: '%s'" ),
1515 recoveredFn.GetFullPath(), backupFn.GetFullPath(), fn );
1517 if( !wxFileExists( fn ) )
1519 unrecoveredFiles.Add( recoveredFn.GetFullPath() );
1523 else if( !wxCopyFile( recoveredFn.GetFullPath(), backupFn.GetFullPath() ) )
1525 unrecoveredFiles.Add( recoveredFn.GetFullPath() );
1528 else if( !wxRenameFile( fn, recoveredFn.GetFullPath() ) )
1530 unrecoveredFiles.Add( recoveredFn.GetFullPath() );
1534 if( !unrecoveredFiles.IsEmpty() )
1536 msg =
_(
"The following automatically saved file(s) could not be restored\n" );
1538 for(
size_t i = 0; i < unrecoveredFiles.GetCount(); i++ )
1539 msg += unrecoveredFiles[i] + wxT(
"\n" );
1541 msg +=
_(
"Manual recovery will be required to restore the file(s) above." );
1542 wxMessageBox( msg,
Pgm().App().GetAppDisplayName(), wxOK | wxICON_EXCLAMATION,
1548 wxArrayString unremovedFiles;
1550 for( wxString fn = autoSaveFile.GetFirstLine(); !autoSaveFile.Eof();
1551 fn = autoSaveFile.GetNextLine() )
1553 wxLogTrace(
traceAutoSave, wxT(
"Removing auto save file " ) + fn );
1555 if( wxFileExists( fn ) && !wxRemoveFile( fn ) )
1556 unremovedFiles.Add( fn );
1559 if( !unremovedFiles.IsEmpty() )
1561 msg =
_(
"The following automatically saved file(s) could not be removed\n" );
1563 for(
size_t i = 0; i < unremovedFiles.GetCount(); i++ )
1564 msg += unremovedFiles[i] + wxT(
"\n" );
1566 msg +=
_(
"Manual removal will be required for the file(s) above." );
1567 wxMessageBox( msg,
Pgm().App().GetAppDisplayName(), wxOK | wxICON_EXCLAMATION,
1573 wxLogTrace(
traceAutoSave, wxT(
"Removing auto save file '%s'" ), aFileName.GetFullPath() );
1575 if( !wxRemoveFile( aFileName.GetFullPath() ) )
1577 msg.Printf(
_(
"The automatic save master file\n"
1579 "could not be deleted." ), aFileName.GetFullPath() );
1581 wxMessageDialog dlg(
this, msg,
Pgm().App().GetAppDisplayName(),
1582 wxOK | wxICON_EXCLAMATION | wxCENTER );
1584 dlg.SetExtendedMessage(
1585 _(
"This file must be manually removed or the auto save feature will be\n"
1586 "shown every time the schematic editor is launched." ) );
1595 static wxString autoSaveFileName( wxT(
"#auto_saved_files#" ) );
1597 return autoSaveFileName;
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
static TOOL_ACTION zoomFitScreen
bool IsContentModified() const
void SetVirtualPageNumber(int aPageNumber)
static wxString m_DrawingSheetFileName
the name of the drawing sheet file, or empty to use the default drawing sheet
void SetContentModified(bool aModified=true)
Class DIALOG_HTML_REPORTER.
WX_HTML_REPORT_BOX * m_Reporter
Handle the graphic items list to draw/plot the frame and title block.
static DS_DATA_MODEL & GetTheInstance()
static function: returns the instance of DS_DATA_MODEL used in the application
void LoadWindowState(const wxString &aFileName)
virtual void ClearUndoRedoList()
Clear the undo and redo list using ClearUndoORRedoList()
SETTINGS_MANAGER * GetSettingsManager() const
void UpdateFileHistory(const wxString &FullFileName, FILE_HISTORY *aFileHistory=nullptr)
Update the list of recently opened files.
wxString GetMruPath() const
bool IsWritable(const wxFileName &aFileName, bool aVerbose=true)
Checks if aFileName can be written.
static wxString GetAutoSaveFilePrefix()
std::unique_ptr< LOCKFILE > m_file_checker
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
void RefreshCanvas() override
bool LockFile(const wxString &aFileName)
Mark a schematic file as being in use.
A base class for most all the KiCad significant classes used in schematics and boards.
EE_TYPE OfType(KICAD_T aType) const
bool GetCreateNewProject() const
Gets if this hook has attached controls to a dialog box.
bool IsAttachedToDialog() const
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
virtual const wxString What() const
A composite of Problem() and Where()
virtual const wxString Problem() const
what was the problem?
APP_SETTINGS_BASE * KifaceSettings() const
bool IsSingle() const
Is this KIFACE running under single_top?
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
static REPORTER & GetInstance()
static wxString GetDefaultUserProjectsPath()
Gets the default path we point users to create projects.
A small class to help profiling.
void Show(std::ostream &aStream=std::cerr)
Print the elapsed time (in a suitable unit) to a stream.
std::vector< FILE_INFO_PAIR > & GetSheets()
virtual void SetReadOnly(bool aReadOnly=true)
virtual const wxString GetProjectFullName() const
Return the full path and name of the project.
virtual PROJECT_FILE & GetProjectFile() const
virtual void SetElem(ELEM_T aIndex, _ELEM *aElem)
virtual const wxString AbsolutePath(const wxString &aFileName) const
Fix up aFileName if it is relative to the project's directory to be an absolute path and filename.
void Reset()
Initialize this schematic to a blank one, unloading anything existing.
void ResolveERCExclusionsPostUpdate()
Update markers to match recorded exclusions.
CONNECTION_GRAPH * ConnectionGraph() const override
void FixupJunctions()
Add junctions to this schematic where required.
SCH_SHEET_LIST GetSheets() const override
Builds and returns an updated schematic hierarchy TODO: can this be cached?
void SetRoot(SCH_SHEET *aRootSheet)
Initialize the schematic with a new root sheet.
void SetProject(PROJECT *aPrj)
SCH_SCREEN * RootScreen() const
Helper to retrieve the screen of the root sheet.
PROJECT & Prj() const override
Return a reference to the project this schematic is part of.
void SyncView()
Mark all items for refresh.
EESCHEMA_SETTINGS * eeconfig() const
Class for a bus to bus entry.
VECTOR2I GetPosition() const override
Handle actions specific to the schematic editor.
bool IsContentModified() const override
Get if the current schematic has been modified but not saved.
void importFile(const wxString &aFileName, int aFileType)
Load the given filename but sets the path to the current project path.
const wxString & getAutoSaveFileName() const
bool LoadSheetFromFile(SCH_SHEET *aSheet, SCH_SHEET_PATH *aHierarchy, const wxString &aFileName)
Load a the KiCad schematic file aFileName into the sheet aSheet.
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag and update other data struc...
bool OpenProjectFiles(const std::vector< wxString > &aFileSet, int aCtl=0) override
Open a project or set of files given by aFileList.
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
void SetScreen(BASE_SCREEN *aScreen) override
bool AskToSaveChanges()
Check if any of the screens has unsaved changes and asks the user whether to save or drop them.
bool doAutoSave() override
Save the schematic files that have been modified and not yet saved.
std::vector< wxEvtHandler * > m_schematicChangeListeners
void HardRedraw() override
Rebuild the GAL and redraw the screen.
void OnAppendProject(wxCommandEvent &event)
SCH_SHEET_PATH & GetCurrentSheet() const
SCHEMATIC & Schematic() const
void updateTitle()
Set the main window title bar text.
bool saveSchematicFile(SCH_SHEET *aSheet, const wxString &aSavePath)
Save aSheet to a schematic file.
bool LoadProjectSettings()
Load the KiCad project file (*.pro) settings specific to Eeschema.
void RecomputeIntersheetRefs()
Update the schematic's page reference map for all global labels, and refresh the labels so that they ...
bool updateAutoSaveFile()
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
bool AddSheetAndUpdateDisplay(const wxString aFullFileName)
Add a sheet file into the current sheet and updates display.
void RecalculateConnections(SCH_COMMIT *aCommit, SCH_CLEANUP_FLAGS aCleanupFlags)
Generate the connection data for the entire schematic hierarchy.
void initScreenZoom()
Initialize the zoom value of the current screen and mark the screen as zoom-initialized.
void OnImportProject(wxCommandEvent &event)
bool AppendSchematic()
Import a KiCad schematic into the current sheet.
virtual void CheckForAutoSaveFile(const wxFileName &aFileName) override
This overloaded version checks if the auto save master file "#auto_saved_files#" exists and recovers ...
void UpdateItem(EDA_ITEM *aItem, bool isAddOrDelete=false, bool aUpdateRtree=false) override
Mark an item for refresh.
void UpdateHierarchyNavigator()
Update the hierarchy navigation tree and history.
wxString GetCurrentFileName() const override
Get the full filename + path of the currently opened file in the frame.
void TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
bool SaveProject(bool aSaveAs=false)
Save the currently-open schematic (including its hierarchy) and associated project.
void saveProjectSettings() override
Saves any design-related project settings associated with this frame.
static SCH_FILE_T GuessPluginTypeFromSchPath(const wxString &aSchematicPath, int aCtl=0)
Return a plugin type given a schematic using the file extension of aSchematicPath.
Base class for any item which can be embedded within the SCHEMATIC container class,...
Helper object to release a SCH_PLUGIN in the context of a potential thrown exception through its dest...
Base class that schematic file and library loading and saving plugins should derive from.
virtual bool CanReadSchematicFile(const wxString &aFileName) const
Checks if this SCH_PLUGIN can read the specified schematic file.
virtual const wxString & GetError() const
Return an error string to the caller.
virtual SCH_SHEET * LoadSchematicFile(const wxString &aFileName, SCHEMATIC *aSchematic, SCH_SHEET *aAppendToMe=nullptr, const STRING_UTF8_MAP *aProperties=nullptr)
Load information from some input file format that this SCH_PLUGIN implementation knows about,...
virtual void SaveSchematicFile(const wxString &aFileName, SCH_SHEET *aSheet, SCHEMATIC *aSchematic, const STRING_UTF8_MAP *aProperties=nullptr)
Write aSchematic to a storage file in a format that this SCH_PLUGIN implementation knows about,...
virtual const PLUGIN_FILE_DESC GetSchematicFileDesc() const
Returns schematic file description for the SCH_PLUGIN.
virtual void SetReporter(REPORTER *aReporter)
Set an optional reporter for warnings/errors.
virtual void SetProgressReporter(PROGRESS_REPORTER *aReporter)
Set an optional progress reporter.
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
SCH_SCREEN * GetScreen(unsigned int aIndex) const
void UpdateSymbolLinks(REPORTER *aReporter=nullptr)
Initialize the LIB_SYMBOL reference for each SCH_SYMBOL found in the full schematic.
void BuildClientSheetPathList()
built the list of sheet paths sharing a screen for each screen in use
bool HasNoFullyDefinedLibIds()
Test all of the schematic symbols to see if all LIB_ID objects library nickname is not set.
SCH_SHEET * GetSheet(unsigned int aIndex) const
int ReplaceDuplicateTimeStamps()
Test all sheet and symbol objects in the schematic for duplicate time stamps and replaces them as nec...
void ClearDrawingState()
Clear the state flags of all the items in the screen.
std::vector< SCH_SHEET_PATH > & GetClientSheetPaths()
Return the number of times this screen is used.
void TestDanglingEnds(const SCH_SHEET_PATH *aPath=nullptr, std::function< void(SCH_ITEM *)> *aChangedHandler=nullptr) const
Test all of the connectable objects in the schematic for unused connection points.
EE_RTREE & Items()
Gets the full RTree, usually for iterating.
const wxString & GetFileName() const
const KIID & GetUuid() const
void SetFileName(const wxString &aFileName)
Set the file name for this screen to aFileName.
int GetFileFormatVersionAtLoad() const
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
void UpdateSheetInstanceData(const std::vector< SCH_SHEET_INSTANCE > &aSheetInstances)
Update all of the sheet instance information using aSheetInstances.
void SetInitialPageNumbers()
Set initial sheet page numbers.
bool AllSheetPageNumbersEmpty() const
Check all of the sheet instance for empty page numbers.
bool IsModified() const
Check the entire hierarchy for any modifications.
void UpdateSymbolInstanceData(const std::vector< SCH_SYMBOL_INSTANCE > &aSymbolInstances)
Update all of the symbol instance information using aSymbolInstances.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
void UpdateAllScreenReferences() const
Update all the symbol references for this sheet path.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
void SetFileName(const wxString &aFilename)
wxString GetFileName() const
Return the filename corresponding to this sheet.
SCH_SCREEN * GetScreen() const
void SaveProjectAs(const wxString &aFullPath, PROJECT *aProject=nullptr)
Sets the currently loaded project path and saves it (pointers remain valid) Note that this will not m...
void SaveProjectCopy(const wxString &aFullPath, PROJECT *aProject=nullptr)
Saves a copy of the current project under the given path.
bool SaveProject(const wxString &aFullPath=wxEmptyString, PROJECT *aProject=nullptr)
Saves a loaded project.
bool LoadProject(const wxString &aFullPath, bool aSetActive=true)
Loads a project or sets up a new project with a specified path.
bool UnloadProject(PROJECT *aProject, bool aSave=true)
Saves, unloads and unregisters the given PROJECT.
bool TriggerBackupIfNeeded(REPORTER &aReporter) const
Calls BackupProject if a new backup is needed according to the current backup policy.
The SIMULATOR_FRAME holds the main user-interface for running simulations.
A collection of SYMBOL_LIB objects.
static void SetLibNamesAndPaths(PROJECT *aProject, const wxString &aPaths, const wxArrayString &aNames)
static void GetLibNamesAndPaths(PROJECT *aProject, wxString *aPaths, wxArrayString *aNames=nullptr)
static void ResolvePossibleSymlinks(wxFileName &aFilename)
void Flush()
Build the HTML messages page.
bool HasMessage() const override
Returns true if the reporter client is non-empty.
void RemoveAllButtons()
Remove all the buttons that have been added by the user.
@ OUTDATED_SAVE
OUTDATED_SAVE Messages that should be cleared on save.
void Dismiss() override
Dismisses the infobar and updates the containing layout and AUI manager (if one is provided).
void AddCloseButton(const wxString &aTooltip=_("Hide this message."))
Add the default close button to the infobar on the right side.
MESSAGE_TYPE GetMessageType() const
void ShowMessage(const wxString &aMessage, int aFlags=wxICON_INFORMATION) override
Show the info bar with the provided message and icon.
Multi-thread safe progress reporter dialog, intended for use of tasks that parallel reporting back of...
A wrapper for reporting to a wxString object.
wxString EnsureFileExtension(const wxString &aFilename, const wxString &aExtension)
It's annoying to throw up nag dialogs when the extension isn't right.
bool AskOverrideLock(wxWindow *aParent, const wxString &aMessage)
Display a dialog indicating the file is already open, with an option to reset the lock.
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Display a yes/no dialog with aMessage and returns the user response.
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
bool HandleUnsavedChanges(wxWindow *aParent, const wxString &aMessage, const std::function< bool()> &aSaveFunction)
Display a dialog with Save, Cancel and Discard Changes buttons.
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
This file is part of the common library.
static bool empty(const wxTextEntryBase *aCtrl)
const std::string BackupFileSuffix
wxString formatWildcardExt(const wxString &aWildcard)
Format wildcard extension to support case sensitive file dialogs.
const std::string LegacyProjectFileExtension
const std::string ProjectFileExtension
const std::string KiCadSchematicFileExtension
const std::string LegacySymbolLibFileExtension
wxString KiCadSchematicFileWildcard()
const wxChar *const traceAutoSave
Flag to enable auto save feature debug tracing.
const wxChar *const tracePathsAndFiles
Flag to enable path and file name debug output.
#define KICTL_CREATE
caller thinks requested project files may not exist.
#define SEXPR_SCHEMATIC_FILE_VERSION
Schematic file version.
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
std::vector< FAB_LAYER_COLOR > dummy
MODEL3D_FORMAT_TYPE fileType(const char *aFileName)
bool show_illegal_symbol_lib_dialog
Container that describes file type info.
wxString FileFilter() const
std::vector< std::string > m_FileExtensions
Filter used for file pickers if m_IsFile is true.
Definition for symbol library class.
wxLogTrace helper definitions.
Definition of file extensions used in Kicad.