43 return wxT(
"CADSTAR Schematic Archive" );
58 wxCHECK( !aFileName.IsEmpty() && aSchematic,
nullptr );
65 wxCHECK_MSG( aSchematic->
IsValid(),
nullptr,
"Can't append to a schematic with no root!" );
66 rootSheet = &aSchematic->
Root();
72 aSchematic->
SetRoot( rootSheet );
83 csaLoader.
Load( aSchematic, rootSheet );
88 wxCHECK_MSG( libTable,
nullptr,
"Could not load symbol lib table." );
93 if( libName.IsEmpty() )
96 libName = fn.GetName();
99 if( libName.IsEmpty() )
108 sch_plugin.
set( SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_KICAD ) );
114 wxString libTableUri =
"${KIPRJMOD}/" + libFileName.GetFullName();
127 libTable->
Format( &formatter, 0 );
132 aSchematic->
Prj().SchSymbolLibTable();
140 sch_plugin->
SaveSymbol( libFileName.GetFullPath(), symbol, &properties );
142 sch_plugin->
SaveLibrary( libFileName.GetFullPath() );
168 const wxString& aLibraryPath,
173 for(
auto& [libnameStr, libSymbol] :
m_libCache )
174 aSymbolNameList.Add( libSymbol->GetName() );
179 const wxString& aLibraryPath,
184 for(
auto& [libnameStr, libSymbol] :
m_libCache )
185 aSymbolList.push_back( libSymbol.get() );
190 const wxString& aAliasName,
204 std::set<wxString> fieldNames;
206 for(
auto& [libnameStr, libSymbol] :
m_libCache )
208 std::vector<LIB_FIELD*> fields;
209 libSymbol->GetFields( fields );
213 if( field->IsMandatory() )
216 fieldNames.insert( field->GetName() );
220 std::copy( fieldNames.begin(), fieldNames.end(), std::back_inserter( aNames ) );
226 ( *aListToAppendTo )[
"csa"] =
227 UTF8(
_(
"Path to the CADSTAR schematic archive (*.csa) file related to this CADSTAR "
228 "parts library. If none specified it is assumed to be 'symbol.csa' in the "
231 ( *aListToAppendTo )[
"fplib"] =
232 UTF8(
_(
"Name of the footprint library related to the symbols in this library. You "
233 "should create a separate entry for the CADSTAR PCB Archive (*.cpa) file in "
234 "the footprint library tables. If none specified, 'cadstarpcblib' is assumed." ) );
242 wxString fplibname =
"cadstarpcblib";
244 if( aProperties && aProperties->count(
"csa" ) )
246 csafn = wxFileName( aProperties->at(
"csa" ) );
248 if( !csafn.IsAbsolute() )
250 wxFileName libDir( aLibraryPath );
252 libDir.SetName(
"" );
261 csafn = wxFileName( aLibraryPath );
262 csafn.SetName(
"symbol" );
263 csafn.SetExt(
"csa" );
266 if( aProperties && aProperties->count(
"fplib" ) )
268 fplibname = aProperties->at(
"fplib" ).wx_str();
272 long long timestamp = 0;
273 wxFileName fn( aLibraryPath );
275 if( fn.IsFileReadable() )
276 timestamp = fn.GetModificationTime().GetValue().GetValue();
279 if( fn.IsFileReadable()
294 std::vector<LIB_SYMBOL*> symbols = csaLoader.
LoadPartsLib( aLibraryPath );
298 m_libCache.insert( { sym->GetName(), std::unique_ptr<LIB_SYMBOL>( sym ) } );
Loads a csa file into a KiCad SCHEMATIC object.
const std::vector< LIB_SYMBOL * > & GetLoadedSymbols() const
void Load(SCHEMATIC *aSchematic, SCH_SHEET *aRootSheet)
Loads a CADSTAR Schematic Archive file into the KiCad SCHEMATIC object given.
std::vector< LIB_SYMBOL * > LoadPartsLib(const wxString &aFilename)
void SetFpLibName(const wxString &aLibName)
NAME_TO_SYMBOL_MAP m_libCache
PROGRESS_REPORTER * m_progressReporter
void ensureLoadedLibrary(const wxString &aLibraryPath, const STRING_UTF8_MAP *aProperties)
long long m_cacheTimestamp
LIB_SYMBOL * LoadSymbol(const wxString &aLibraryPath, const wxString &aAliasName, const STRING_UTF8_MAP *aProperties=nullptr) override
Load a LIB_SYMBOL object having aPartName from the aLibraryPath containing a library format that this...
void EnumerateSymbolLib(wxArrayString &aSymbolNameList, const wxString &aLibraryPath, const STRING_UTF8_MAP *aProperties=nullptr) override
Populate a list of LIB_SYMBOL alias names contained within the library aLibraryPath.
const wxString GetName() const override
Return a brief hard coded name for this SCH_PLUGIN.
void GetAvailableSymbolFields(std::vector< wxString > &aNames) override
Retrieves a list of (custom) field names that are present on symbols in this library.
int GetModifyHash() const override
Return the modification hash from the library cache.
wxString m_cachefplibname
SCH_SHEET * LoadSchematicFile(const wxString &aFileName, SCHEMATIC *aSchematic, SCH_SHEET *aAppendToMe=nullptr, const STRING_UTF8_MAP *aProperties=nullptr) override
Load information from some input file format that this SCH_PLUGIN implementation knows about,...
void SymbolLibOptions(STRING_UTF8_MAP *aListToAppendTo) const override
Append supported SCH_PLUGIN options to aListToAppenTo along with internationalized descriptions.
Field object used in symbol libraries.
A logical library item identifier and consists of various portions much like a URI.
int SetLibNickname(const UTF8 &aNickname)
Override the logical library name portion of the LIB_ID to aNickname.
static UTF8 FixIllegalChars(const UTF8 &aLibItemName, bool aLib)
Replace illegal LIB_ID item name characters with underscores '_'.
Define a library symbol object.
bool HasLibrary(const wxString &aNickname, bool aCheckEnabled=false) const
Test for the existence of aNickname in the library table.
bool InsertRow(LIB_TABLE_ROW *aRow, bool doReplace=false)
Adds aRow if it does not already exist or if doReplace is true.
virtual const wxString GetProjectPath() const
Return the full path of the project.
virtual const wxString GetProjectName() const
Return the short name of the project.
virtual void SetElem(ELEM_T aIndex, _ELEM *aElem)
Holds all the data relating to one schematic.
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.
bool IsValid() const
A simple test if the schematic is loaded, not a complete one.
PROJECT & Prj() const override
Return a reference to the project this schematic is part of.
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...
void set(SCH_PLUGIN *aPlugin)
virtual void SaveSymbol(const wxString &aLibraryPath, const LIB_SYMBOL *aSymbol, const STRING_UTF8_MAP *aProperties=nullptr)
Write aSymbol to an existing library located at aLibraryPath.
virtual void SaveLibrary(const wxString &aFileName, const STRING_UTF8_MAP *aProperties=nullptr)
virtual void CreateSymbolLib(const wxString &aLibraryPath, const STRING_UTF8_MAP *aProperties=nullptr)
Create a new empty symbol library at aLibraryPath.
void SetFileName(const wxString &aFileName)
Set the file name for this screen to aFileName.
static const char * PropBuffering
The property used internally by the plugin to enable cache buffering which prevents the library file ...
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.
void SetFileName(const wxString &aFilename)
wxString GetFileName() const
Return the filename corresponding to this sheet.
SCH_SCREEN * GetScreen() const
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
void SetLibId(const LIB_ID &aName)
const LIB_ID & GetLibId() const
A name/value tuple with unique names and optional values.
Hold a record identifying a symbol library accessed by the appropriate symbol library SCH_PLUGIN obje...
static const wxString & GetSymbolLibTableFileName()
virtual void Format(OUTPUTFORMATTER *aOutput, int aIndentLevel) const override
Generate the table in s-expression format to aOutput with an indentation level of aIndentLevel.
An 8 bit string that is assuredly encoded in UTF8, and supplies special conversion support to and fro...
const std::string KiCadSymbolLibFileExtension
Definition of file extensions used in Kicad.
#define FN_NORMALIZE_FLAGS
Default flags to pass to wxFileName::Normalize().