86 SCH_IO* pi = SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_KICAD );
87 std::unique_ptr<SCHEMATIC> schematic = std::make_unique<SCHEMATIC>(
nullptr );
96 schematic->SetProject( &manager.
Prj() );
98 schematic->CurrentSheet().push_back( &schematic->Root() );
103 screen->UpdateLocalLibSymbolLinks();
110 if( schematic->RootScreen()->GetFileFormatVersionAtLoad() < 20230221 )
113 screen->FixLegacyPowerSymbolMismatches();
117 screen->MigrateSimModels();
123 sheet.UpdateAllScreenReferences();
131 schematic->ConnectionGraph()->Recalculate( sheets,
true );
162 void Reset()
override;
208 bool cancelled =
false;
235 APP_SETTINGS_BASE* cfg = GetAppSettings<SYMBOL_EDITOR_SETTINGS>(
"symbol_editor" );
268 APP_SETTINGS_BASE* cfg = GetAppSettings<SYMBOL_EDITOR_SETTINGS>(
"symbol_editor" );
269 TOOLBAR_SETTINGS* tb = GetToolbarSettings<SYMBOL_EDIT_TOOLBAR_SETTINGS>(
"symbol_editor-toolbars" );
271 std::vector<TOOL_ACTION*> actions;
272 std::vector<ACTION_TOOLBAR_CONTROL*> controls;
275 actions.push_back( action );
278 controls.push_back( control );
328 TOOLBAR_SETTINGS* tb = GetToolbarSettings<SCH_EDIT_TOOLBAR_SETTINGS>(
"eeschema-toolbars" );
330 std::vector<TOOL_ACTION*> actions;
331 std::vector<ACTION_TOOLBAR_CONTROL*> controls;
334 actions.push_back( action );
337 controls.push_back( control );
382 void SaveFileAs(
const wxString& aProjectBasePath,
const wxString& aProjectName,
383 const wxString& aNewProjectBasePath,
const wxString& aNewProjectName,
384 const wxString& aSrcFilePath, wxString& aErrors )
override;
442 m_jobHandler = std::make_unique<EESCHEMA_JOBS_HANDLER>( aKiway );
464 if( !fn.FileExists() )
493 _(
"An error occurred attempting to load the global symbol library table.\n"
494 "Please edit this global symbol library table in Preferences menu." );
510 if( !fn.FileExists() )
513 emptyTable.
Save( fn.GetFullPath() );
529 _(
"An error occurred attempting to load the global design block library table.\n"
530 "Please edit this global design block library table in Preferences menu." );
559 const wxString& aNewProjectBasePath,
const wxString& aNewProjectName,
560 const wxString& aSrcFilePath, wxString& aErrors )
562 wxFileName destFile( aSrcFilePath );
563 wxString destPath = destFile.GetPathWithSep();
564 wxUniChar pathSep = wxFileName::GetPathSeparator();
565 wxString ext = destFile.GetExt();
567 if( destPath.StartsWith( aProjectBasePath + pathSep ) )
568 destPath.Replace( aProjectBasePath, aNewProjectBasePath,
false );
570 destFile.SetPath( destPath );
577 if( destFile.GetName() == aProjectName )
579 destFile.SetName( aNewProjectName );
581 else if( destFile.GetName() == aNewProjectName )
585 if( !aErrors.empty() )
586 aErrors += wxS(
"\n" );
588 msg.Printf(
_(
"Cannot copy file '%s' as it will be overwritten by the new root "
589 "sheet file." ), destFile.GetFullPath() );
603 KiCopyFile( aSrcFilePath, destFile.GetFullPath(), aErrors );
608 KiCopyFile( aSrcFilePath, destFile.GetFullPath(), aErrors );
614 if( destFile.GetName() == aProjectName + wxS(
"-cache" ) )
615 destFile.SetName( aNewProjectName + wxS(
"-cache" ) );
617 if( destFile.GetName() == aProjectName + wxS(
"-rescue" ) )
618 destFile.SetName( aNewProjectName + wxS(
"-rescue" ) );
620 KiCopyFile( aSrcFilePath, destFile.GetFullPath(), aErrors );
624 bool success =
false;
626 if( destFile.GetName() == aProjectName )
627 destFile.SetName( aNewProjectName );
636 if( node->IsList() && node->GetNumberOfChildren() > 1
637 && node->GetChild( 0 )->IsSymbol()
638 && node->GetChild( 0 )->GetSymbol() ==
"source" )
640 auto pathNode = dynamic_cast<SEXPR::SEXPR_STRING*>( node->GetChild( 1 ) );
641 auto symNode = dynamic_cast<SEXPR::SEXPR_SYMBOL*>( node->GetChild( 1 ) );
645 path = pathNode->m_value;
647 path = symNode->m_value;
649 if( path == aProjectName + wxS(
".sch" ) )
650 path = aNewProjectName + wxS(
".sch" );
651 else if( path == aProjectBasePath +
"/" + aProjectName + wxS(
".sch" ) )
652 path = aNewProjectBasePath +
"/" + aNewProjectName + wxS(
".sch" );
653 else if( path.StartsWith( aProjectBasePath ) )
654 path.Replace( aProjectBasePath, aNewProjectBasePath, false );
657 pathNode->m_value = path;
659 symNode->m_value = path;
663 wxFFile destNetList( destFile.GetFullPath(),
"wb" );
665 if( destNetList.IsOpened() )
666 success = destNetList.Write( sexpr->AsString( 0 ) );
679 if( !aErrors.empty() )
680 aErrors += wxS(
"\n" );
682 msg.Printf(
_(
"Cannot copy file '%s'." ), destFile.GetFullPath() );
689 symbolLibTable.
Load( aSrcFilePath );
691 for(
unsigned i = 0; i < symbolLibTable.
GetCount(); i++ )
696 uri.Replace( wxS(
"/" ) + aProjectName + wxS(
"-cache.lib" ),
697 wxS(
"/" ) + aNewProjectName + wxS(
"-cache.lib" ) );
698 uri.Replace( wxS(
"/" ) + aProjectName + wxS(
"-rescue.lib" ),
699 wxS(
"/" ) + aNewProjectName + wxS(
"-rescue.lib" ) );
700 uri.Replace( wxS(
"/" ) + aProjectName + wxS(
".lib" ),
701 wxS(
"/" ) + aNewProjectName + wxS(
".lib" ) );
708 symbolLibTable.
Save( destFile.GetFullPath() );
714 if( !aErrors.empty() )
717 msg.Printf(
_(
"Cannot copy file '%s'." ), destFile.GetFullPath() );
723 wxFAIL_MSG( wxS(
"Unexpected filetype for Eeschema::SaveFileAs()" ) );
730 return m_jobHandler->RunJob( aJob, aReporter, aProgressReporter );
constexpr EDA_IU_SCALE schIUScale
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
static std::list< TOOL_ACTION * > & GetActionList()
Return list of TOOL_ACTIONs.
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
static PROGRESS_REPORTER & GetInstance()
static REPORTER & GetInstance()
static wxString GetGlobalTableFileName()
static bool LoadGlobalTable(DESIGN_BLOCK_LIB_TABLE &aTable)
Load the global design block library table into aTable.
static DESIGN_BLOCK_LIB_TABLE & GetGlobalLibTable()
The base frame for deriving all KiCad main window classes.
static void SetSchEditFrame(SCH_EDIT_FRAME *aSchEditFrame)
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()
An simple container class that lets us dispatch output jobs to kifaces.
void InitSettings(APP_SETTINGS_BASE *aSettings)
void end_common()
Common things to do for a top program module, during OnKifaceEnd();.
APP_SETTINGS_BASE * KifaceSettings() const
bool start_common(int aCtlBits)
Common things to do for a top program module, during OnKifaceStart().
int m_start_flags
flags provided in OnKifaceStart()
bool IsSingle() const
Is this KIFACE running under single_top?
void CreateServer(int service, bool local=true)
bool Destroy() override
Our version of Destroy() which is virtual from wxWidgets.
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
FACE_T
Known KIFACE implementations.
Hold a record identifying a library accessed by the appropriate plug in object in the LIB_TABLE.
void SetFullURI(const wxString &aFullURI)
Change the full URI for the library.
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...
LIB_TABLE_ROW & At(unsigned aIndex)
Get the 'n'th LIB_TABLE_ROW object.
void Load(const wxString &aFileName)
Load the library table using the path defined by aFileName aFallBackTable.
unsigned GetCount() const
Get the number of rows contained in the table.
void Save(const wxString &aFileName) const
Write this library table to aFileName in s-expression form.
Generate the KiCad netlist format supported by Pcbnew.
void Format(OUTPUTFORMATTER *aOutputFormatter, int aCtl)
Output this s-expression netlist into aOutputFormatter.
Container for data for KiCad programs.
virtual SETTINGS_MANAGER & GetSettingsManager() const
A progress reporter interface for use in multi-threaded environments.
A pure virtual class used to derive REPORTER objects from.
Schematic editor (Eeschema) main window.
Base class that schematic file and library loading and saving plugins should derive from.
virtual SCH_SHEET * LoadSchematicFile(const wxString &aFileName, SCHEMATIC *aSchematic, SCH_SHEET *aAppendToMe=nullptr, const std::map< std::string, UTF8 > *aProperties=nullptr)
Load information from some input file format that this SCH_IO implementation knows about,...
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
void AnnotatePowerSymbols()
Silently annotate the not yet annotated power symbols of the entire hierarchy of the sheet path list.
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...
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
T * RegisterSettings(T *aSettings, bool aLoadNow=true)
Take ownership of the pointer passed in.
bool LoadProject(const wxString &aFullPath, bool aSetActive=true)
Load a project or sets up a new project with a specified path.
PROJECT & Prj() const
A helper while we are not MDI-capable – return the one and only project.
void FlushAndRelease(JSON_SETTINGS *aSettings, bool aSave=true)
If the given settings object is registered, save it to disk and unregister it.
std::unique_ptr< SEXPR > ParseFromFile(const std::string &aFilename)
size_t GetNumberOfChildren() const
SEXPR * GetChild(size_t aIndex) const
The SIMULATOR_FRAME holds the main user-interface for running simulations.
Simple error container for failure to init the simulation engine and ultimately abort the frame const...
Symbol library viewer main window.
The symbol library editor main window.
static SYMBOL_LIB_TABLE & GetGlobalLibTable()
static wxString GetGlobalTableFileName()
Fetch the global symbol library table file name.
static bool LoadGlobalTable(SYMBOL_LIB_TABLE &aTable)
Load the global symbol library table into aTable.
Symbol library viewer main window.
EDA_UNITS GetUserUnits() const
void SetUserUnits(EDA_UNITS aUnits)
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
This file is part of the common library.
#define KICAD_SCH_PORT_SERVICE_NUMBER
Eeschema listens on this port for commands from Pcbnew.
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
static void traverseSEXPR(SEXPR::SEXPR *aNode, const std::function< void(SEXPR::SEXPR *)> &aVisitor)
@ FRAME_SCH_SYMBOL_EDITOR
@ PANEL_SCH_FIELD_NAME_TEMPLATES
@ DIALOG_SCH_LIBRARY_TABLE
@ DIALOG_DESIGN_BLOCK_LIBRARY_TABLE
void KiCopyFile(const wxString &aSrcPath, const wxString &aDestPath, wxString &aErrors)
static const std::string LegacySchematicFileExtension
static const std::string NetlistFileExtension
static const std::string SymbolLibraryTableFileName
static const std::string SchematicSymbolFileExtension
static const std::string KiCadSchematicFileExtension
static const std::string LegacySymbolLibFileExtension
static const std::string KiCadSymbolLibFileExtension
static const std::string BackupFileSuffix
static const std::string LegacySymbolDocumentFileExtension
@ KIFACE_NETLIST_SCHEMATIC
#define KFCTL_CLI
Running as CLI app.
static std::unique_ptr< SCHEMATIC > readSchematicFromFile(const std::string &aFilename)
SCH::IFACE KIFACE_BASE, UNITS_PROVIDER kiface("eeschema", KIWAY::FACE_SCH)
bool generateSchematicNetlist(const wxString &aFilename, std::string &aNetlist)
void InvokeEditDesignBlockLibTable(KIWAY *aKiway, wxWindow *aParent)
void InvokeSchEditSymbolLibTable(KIWAY *aKiway, wxWindow *aParent)
PGM_BASE & Pgm()
The global program "get" accessor.
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
bool OnKifaceStart(PGM_BASE *aProgram, int aCtlBits, KIWAY *aKiway) override
Typically start_common() is called from here.
Implement a participant in the KIWAY alchemy.
bool OnKifaceStart(PGM_BASE *aProgram, int aCtlBits, KIWAY *aKiway) override
Typically start_common() is called from here.
bool loadGlobalDesignBlockLibTable()
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 ...
wxWindow * CreateKiWindow(wxWindow *aParent, int aClassId, KIWAY *aKiway, int aCtlBits=0) override
Create a wxWindow for the current project.
IFACE(const char *aName, KIWAY::FACE_T aType)
void Reset() override
Reloads global state.
void * IfaceOrAddress(int aDataId) override
Return a pointer to the requested object.
int HandleJob(JOB *aJob, REPORTER *aReporter, PROGRESS_REPORTER *aProgressReporter) override
std::unique_ptr< EESCHEMA_JOBS_HANDLER > m_jobHandler
bool loadGlobalLibTable()
bool HandleJobConfig(JOB *aJob, wxWindow *aParent) override
void OnKifaceEnd() override
Called just once just before the DSO is to be unloaded.
Definition of file extensions used in Kicad.