64 auto pi = SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_KICAD );
65 std::unique_ptr<SCHEMATIC> schematic = std::make_unique<SCHEMATIC>(
nullptr );
71 schematic->SetProject( &manager.Prj() );
72 schematic->SetRoot( pi->Load( aFilename, schematic.get() ) );
73 schematic->CurrentSheet().push_back( &schematic->Root() );
77 for(
SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
78 screen->UpdateLocalLibSymbolLinks();
90 sheet.UpdateAllScreenReferences();
95 schematic->ConnectionGraph()->Recalculate( sheets,
true );
127 int aCtlBits = 0 )
override 201 void SaveFileAs(
const wxString& aProjectBasePath,
const wxString& aProjectName,
202 const wxString& aNewProjectBasePath,
const wxString& aNewProjectName,
203 const wxString& aSrcFilePath, wxString& aErrors )
override;
251 if( !fn.FileExists() )
255 fpDialog.ShowModal();
273 "An error occurred attempting to load the global symbol library table.\n" 274 "Please edit this global symbol library table in Preferences menu." 305 const wxString& aNewProjectBasePath,
const wxString& aNewProjectName,
306 const wxString& aSrcFilePath, wxString& aErrors )
308 wxFileName destFile( aSrcFilePath );
309 wxString destPath = destFile.GetPathWithSep();
310 wxUniChar pathSep = wxFileName::GetPathSeparator();
311 wxString ext = destFile.GetExt();
313 if( destPath.StartsWith( aProjectBasePath + pathSep ) )
314 destPath.Replace( aProjectBasePath, aNewProjectBasePath,
false );
316 destFile.SetPath( destPath );
323 if( destFile.GetName() == aProjectName )
324 destFile.SetName( aNewProjectName );
335 KiCopyFile( aSrcFilePath, destFile.GetFullPath(), aErrors );
340 KiCopyFile( aSrcFilePath, destFile.GetFullPath(), aErrors );
345 if( destFile.GetName() == aProjectName + wxT(
"-cache" ) )
346 destFile.SetName( aNewProjectName + wxT(
"-cache" ) );
348 KiCopyFile( aSrcFilePath, destFile.GetFullPath(), aErrors );
352 bool success =
false;
354 if( destFile.GetName() == aProjectName )
355 destFile.SetName( aNewProjectName );
364 if( node->IsList() && node->GetNumberOfChildren() > 1
365 && node->GetChild( 0 )->IsSymbol()
366 && node->GetChild( 0 )->GetSymbol() == wxT(
"source" ) )
368 auto pathNode = dynamic_cast<SEXPR::SEXPR_STRING*>( node->GetChild( 1 ) );
369 auto symNode = dynamic_cast<SEXPR::SEXPR_SYMBOL*>( node->GetChild( 1 ) );
373 path = pathNode->m_value;
375 path = symNode->m_value;
377 if(
path == aProjectName + wxT(
".sch" ) )
378 path = aNewProjectName + wxT(
".sch" );
379 else if(
path == aProjectBasePath + wxT(
"/" ) + aProjectName + wxT(
".sch" ) )
380 path = aNewProjectBasePath + wxT(
"/" ) + aNewProjectName + wxT(
".sch" );
381 else if(
path.StartsWith( aProjectBasePath ) )
382 path.Replace( aProjectBasePath, aNewProjectBasePath,
false );
385 pathNode->m_value =
path;
387 symNode->m_value =
path;
391 wxFFile destNetList( destFile.GetFullPath(), wxT(
"wb" ) );
393 if( destNetList.IsOpened() )
394 success = destNetList.Write( sexpr->AsString( 0 ) );
407 if( !aErrors.empty() )
408 aErrors += wxT(
"\n" );
410 msg.Printf(
_(
"Cannot copy file '%s'." ), destFile.GetFullPath() );
414 else if( destFile.GetName() == wxT(
"sym-lib-table" ) )
417 symbolLibTable.
Load( aSrcFilePath );
419 for(
unsigned i = 0; i < symbolLibTable.
GetCount(); i++ )
424 uri.Replace( wxT(
"/" ) + aProjectName + wxT(
"-cache.lib" ), wxT(
"/" ) + aNewProjectName + wxT(
"-cache.lib" ) );
425 uri.Replace( wxT(
"/" ) + aProjectName + wxT(
"-rescue.lib" ), wxT(
"/" ) + aNewProjectName +
426 wxT(
"-rescue.lib" ) );
427 uri.Replace( wxT(
"/" ) + aProjectName + wxT(
".lib" ), wxT(
"/" ) + aNewProjectName + wxT(
".lib" ) );
434 symbolLibTable.
Save( destFile.GetFullPath() );
440 if( !aErrors.empty() )
441 aErrors += wxT(
"\n" );
443 msg.Printf(
_(
"Cannot copy file '%s'." ), destFile.GetFullPath() );
449 wxFAIL_MSG( wxT(
"Unexpected filetype for Eeschema::SaveFileAs()" ) );
const std::string NetlistFileExtension
static void traverseSEXPR(SEXPR::SEXPR *aNode, const std::function< void(SEXPR::SEXPR *)> &aVisitor)
virtual SETTINGS_MANAGER & GetSettingsManager() const
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
static std::unique_ptr< SCHEMATIC > readSchematicFromFile(const std::string &aFilename)
static SYMBOL_LIB_TABLE & GetGlobalLibTable()
Hold a record identifying a library accessed by the appropriate plug in object in the LIB_TABLE.
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
T * RegisterSettings(T *aSettings, bool aLoadNow=true)
Takes ownership of the pointer passed in.
This file is part of the common library.
void OnKifaceEnd() override
Called just once just before the DSO is to be unloaded.
Container for data for KiCad programs.
const std::string LegacySymbolLibFileExtension
FRAME_T
The set of EDA_BASE_FRAME derivatives, typically stored in EDA_BASE_FRAME::m_Ident.
std::unique_ptr< SEXPR > ParseFromFile(const std::string &aFilename)
const std::string BackupFileSuffix
unsigned GetCount() const
Get the number of rows contained in the table.
wxWindow * CreateWindow(wxWindow *aParent, int aClassId, KIWAY *aKiway, int aCtlBits=0) override
Create a wxWindow for the current project.
void * IfaceOrAddress(int aDataId) override
Return a pointer to the requested object.
void end_common()
Common things to do for a top program module, during OnKifaceEnd();.
void InvokeSchEditSymbolLibTable(KIWAY *aKiway, wxWindow *aParent)
IFACE(const char *aName, KIWAY::FACE_T aType)
void KiCopyFile(const wxString &aSrcPath, const wxString &aDestPath, wxString &aErrors)
const std::string SchematicSymbolFileExtension
Symbol library viewer main window.
bool generateSchematicNetlist(const wxString &aFilename, wxString &aNetlist)
Schematic editor (Eeschema) main window.
void CreateServer(int service, bool local=true)
const wxString GetFullURI(bool aSubstituted=false) const
Return the full location specifying URI for the LIB, either in original UI form or in environment var...
void InitSettings(APP_SETTINGS_BASE *aSettings)
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
PGM_BASE * PgmOrNull()
similar to PGM_BASE& Pgm(), but return a reference that can be nullptr when running a shared lib from...
static bool LoadGlobalTable(SYMBOL_LIB_TABLE &aTable)
Load the global symbol library table into aTable.
#define KICAD_SCH_PORT_SERVICE_NUMBER
Scripting window listens for commands for other apps.
bool OnKifaceStart(PGM_BASE *aProgram, int aCtlBits) override
Typically start_common() is called from here.
virtual const wxString What() const
A composite of Problem() and Where()
void SaveFileAs(const wxString &aProjectBasePath, const wxString &aProjectName, const wxString &aNewProjectBasePath, const wxString &aNewProjectName, const wxString &aSrcFilePath, wxString &aErrors) override
Saving a file under a different name is delegated to the various KIFACEs because the project doesn't ...
SEXPR * GetChild(size_t aIndex) const
bool start_common(int aCtlBits)
Common things to do for a top program module, during OnKifaceStart().
const std::string LegacySymbolDocumentFileExtension
Generate the KiCad netlist format supported by Pcbnew.
SCH::IFACE KIFACE_BASE kiface("eeschema", KIWAY::FACE_SCH)
Definition of file extensions used in Kicad.
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Subclass of SIM_PLOT_FRAME_BASE, which is generated by wxFormBuilder.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
void Load(const wxString &aFileName)
Load the library table using the path defined by aFileName aFallBackTable.
void UpdateSymbolInstances(const std::vector< SYMBOL_INSTANCE_REFERENCE > &aSymbolInstances)
Update all of the symbol instance information using aSymbolInstances.
const std::string LegacySchematicFileExtension
Implementing SIM_PLOT_FRAME_BASE.
FACE_T
Known KIFACE implementations.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
bool LoadProject(const wxString &aFullPath, bool aSetActive=true)
Loads a project or sets up a new project with a specified path.
void SetFullURI(const wxString &aFullURI)
Change the full URI for the library.
TRANSFORM DefaultTransform
LIB_TABLE_ROW & At(unsigned aIndex)
Get the 'n'th LIB_TABLE_ROW object.
MY_API(KIFACE *) KIFACE_GETTER(int *aKIFACEversion
Implement a participant in the KIWAY alchemy.
const std::string KiCadSchematicFileExtension
void Save(const wxString &aFileName) const
Write this library table to aFileName in s-expression form.
static PGM_BASE * process
APP_SETTINGS_BASE * KifaceSettings() const
void AnnotatePowerSymbols()
Silently annotate the not yet annotated power symbols of the entire hierarchy of the sheet path list.
PGM_BASE & Pgm()
The global Program "get" accessor.
size_t GetNumberOfChildren() const
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
static wxString GetGlobalTableFileName()
Fetch the global symbol library table file name.
bool IsSingle() const
Is this KIFACE running under single_top?
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
const std::string KiCadSymbolLibFileExtension
The symbol library editor main window.