30#include <wx/mstream.h>
41#include <schematic_lexer.h>
67using namespace TSCHEMATIC_T;
70#define SCH_PARSE_ERROR( text, reader, pos ) \
71 THROW_PARSE_ERROR( text, reader.GetSource(), reader.Line(), \
72 reader.LineNumber(), pos - reader.Line() )
101 const std::map<std::string, UTF8>* aProperties )
103 wxASSERT( !aFileName || aSchematic !=
nullptr );
108 wxFileName fn = aFileName;
116 wxASSERT( fn.IsAbsolute() );
126 if( !normedFn.IsAbsolute() )
128 if( aFileName.Right( normedFn.GetFullPath().Length() ) == normedFn.GetFullPath() )
129 m_path = aFileName.Left( aFileName.Length() - normedFn.GetFullPath().Length() );
143 init( aSchematic, aProperties );
145 if( aAppendToMe ==
nullptr )
148 std::unique_ptr<SCH_SHEET> newSheet = std::make_unique<SCH_SHEET>( aSchematic );
150 wxFileName relPath( aFileName );
156 newSheet->SetFileName( relPath.GetFullPath() );
161 sheet = newSheet.release();
166 wxCHECK_MSG( aSchematic->
IsValid(),
nullptr,
"Can't append to a schematic with no root!" );
195 if( !fileName.IsAbsolute() )
204 wxLogTrace(
traceSchPlugin,
"Loading '%s'", fileName.GetFullPath() );
208 while( !ancestorSheetPath.
empty() )
215 m_error += wxString::Format(
_(
"Could not load sheet '%s' because it already "
216 "appears as a direct ancestor in the schematic "
218 fileName.GetFullPath() );
220 fileName = wxEmptyString;
228 if( ancestorSheetPath.
empty() )
249 loadFile( fileName.GetFullPath(), aSheet );
264 if( fileName.FileExists() )
302 size_t lineCount = 0;
337 const std::map<std::string, UTF8>* aProperties )
339 wxCHECK_RET( aSheet !=
nullptr,
"NULL SCH_SHEET object." );
340 wxCHECK_RET( !aFileName.IsEmpty(),
"No schematic file name defined." );
344 init( aSchematic, aProperties );
346 wxFileName fn = aFileName;
350 wxASSERT( fn.IsAbsolute() );
365 wxCHECK_RET( aSheet !=
nullptr,
"NULL SCH_SHEET* object." );
366 wxCHECK_RET(
m_schematic !=
nullptr,
"NULL SCHEMATIC* object." );
381 m_out->
Print(
"(kicad_sch (version %d) (generator \"eeschema\") (generator_version %s)",
393 for(
const auto& [ libItemName, libSymbol ] : screen->
GetLibSymbols() )
398 for(
const std::shared_ptr<BUS_ALIAS>& alias : screen->
GetBusAliases() )
405 if( a->
Type() != b->Type() )
406 return a->
Type() < b->Type();
408 return a->
m_Uuid < b->m_Uuid;
411 std::multiset<
SCH_ITEM*,
decltype( cmp )> save_map( cmp );
417 save_map.insert( item );
422 switch( item->Type() )
478 wxASSERT(
"Unexpected schematic object type in SCH_IO_KICAD_SEXPR::Format()" );
484 std::vector< SCH_SHEET_INSTANCE> instances;
504 wxCHECK( aSelection && aSelectionPath && aFormatter, );
514 std::map<wxString, LIB_SYMBOL*> libSymbols;
516 std::set<SCH_TABLE*> promotedTables;
518 for( i = 0; i < aSelection->
GetSize(); ++i )
522 wxCHECK2( item,
continue );
529 wxCHECK2( symbol,
continue );
539 libSymbols[ libSymbolLookup ] = it->second;
542 if( !libSymbols.empty() )
546 for(
const std::pair<const wxString, LIB_SYMBOL*>& libSymbol : libSymbols )
555 for( i = 0; i < aSelection->
GetSize(); ++i )
559 switch( item->
Type() )
615 if( promotedTables.count( table ) )
621 promotedTables.insert( table );
631 wxASSERT(
"Unexpected schematic object type in SCH_IO_KICAD_SEXPR::Format()" );
641 wxCHECK_RET( aSymbol !=
nullptr &&
m_out !=
nullptr,
"" );
647 if( symbol_name.size() )
653 libName =
"_NONAME_";
687 if( mirrorX || mirrorY )
691 mirrorY ?
"y" :
"" );
702 wxASSERT( parentScreen );
706 std::optional<SCH_SHEET_PATH> ordinalPath =
709 wxASSERT( ordinalPath );
712 aSymbol->
GetInstance( ordinalInstance, ordinalPath->Path() );
717 int unit = ordinalInstance.
m_Unit;
719 if( aForClipboard && aRelativePath )
724 unit = unitInstance.
m_Unit;
748 int id = field.GetId();
749 wxString value = field.GetText();
768 else if( aForClipboard && aSymbol->
GetInstances().size() && aRelativePath
785 field.SetText( value );
791 field.SetText( value );
794 for(
const std::unique_ptr<SCH_PIN>&
pin : aSymbol->
GetRawPins() )
796 if(
pin->GetAlt().IsEmpty() )
812 std::map<KIID, std::vector<SCH_SYMBOL_INSTANCE>> projectInstances;
816 wxString projectName;
822 wxCHECK2( inst.m_Path.size(),
continue );
827 bool isOrphaned = ( inst.m_Path[0] == rootSheetUuid )
831 if( !aForClipboard && isOrphaned )
834 auto it = projectInstances.find( inst.m_Path[0] );
836 if( it == projectInstances.end() )
837 projectInstances[ inst.m_Path[0] ] = { inst };
839 it->second.emplace_back( inst );
842 for(
auto& [uuid, instances] : projectInstances )
844 wxCHECK2( instances.size(),
continue );
847 std::sort( instances.begin(), instances.end(),
850 return aLhs.m_Path < aRhs.m_Path;
853 projectName = instances[0].m_ProjectName;
862 if( aForClipboard && aRelativePath )
867 m_out->
Print(
"(path %s (reference %s) (unit %d))",
885 wxCHECK_RET( aField !=
nullptr &&
m_out !=
nullptr,
"" );
891 if( aField->
GetId() == -1 )
895 if( !aField->
GetName().IsEmpty() )
906 m_out->
Print(
"(property %s %s %s (at %s %s %s)",
934 wxCHECK_RET(
m_out !=
nullptr,
"" );
941 wxCHECK_RET(
image !=
nullptr,
"wxImage* is NULL" );
967#define MIME_BASE64_LENGTH 76
971 while( first < out.Length() )
984 wxCHECK_RET( aSheet !=
nullptr &&
m_out !=
nullptr,
"" );
986 m_out->
Print(
"(sheet (at %s %s) (size %s %s)",
1011 m_out->
Print(
"(fill (color %d %d %d %0.4f))",
1030 pin->GetPosition().x ).c_str(),
1032 pin->GetPosition().y ).c_str(),
1043 std::vector< SCH_SHEET_INSTANCE > sheetInstances = aSheet->
GetInstances();
1045 auto it = sheetInstances.begin();
1047 while( it != sheetInstances.end() )
1049 if( it->m_Path.size() == 0 )
1050 it = sheetInstances.erase( it );
1055 if( !sheetInstances.empty() )
1059 KIID lastProjectUuid;
1061 bool inProjectClause =
false;
1063 for(
size_t i = 0; i < sheetInstances.size(); i++ )
1070 if( ( sheetInstances[i].m_Path[0] == rootSheetUuid )
1073 if( inProjectClause && ( ( i + 1 == sheetInstances.size() )
1074 || lastProjectUuid != sheetInstances[i+1].m_Path[0] ) )
1077 inProjectClause =
false;
1083 if( lastProjectUuid != sheetInstances[i].m_Path[0] )
1085 wxString projectName;
1087 if( sheetInstances[i].m_Path[0] == rootSheetUuid )
1090 projectName = sheetInstances[i].m_ProjectName;
1092 lastProjectUuid = sheetInstances[i].m_Path[0];
1094 inProjectClause =
true;
1097 wxString
path = sheetInstances[i].m_Path.AsString();
1101 m_out->
Quotew( sheetInstances[i].m_PageNumber ).c_str() );
1103 if( inProjectClause && ( ( i + 1 == sheetInstances.size() )
1104 || lastProjectUuid != sheetInstances[i+1].m_Path[0] ) )
1107 inProjectClause =
false;
1120 wxCHECK_RET( aJunction !=
nullptr &&
m_out !=
nullptr,
"" );
1122 m_out->
Print(
"(junction (at %s %s) (diameter %s) (color %d %d %d %s)",
1141 wxCHECK_RET( aNoConnect !=
nullptr &&
m_out !=
nullptr,
"" );
1156 wxCHECK_RET( aBusEntry !=
nullptr &&
m_out !=
nullptr,
"" );
1159 if( aBusEntry->
GetClass() ==
"SCH_BUS_BUS_ENTRY" )
1168 m_out->
Print(
"(bus_entry (at %s %s) (size %s %s)",
1176 aBusEntry->
GetSize().
y ).c_str() );
1186 wxCHECK_RET( aShape !=
nullptr &&
m_out !=
nullptr,
"" );
1195 case SHAPE_T::CIRCLE:
1200 case SHAPE_T::RECTANGLE:
1205 case SHAPE_T::BEZIER:
1223 wxCHECK_RET( aRuleArea !=
nullptr &&
m_out !=
nullptr,
"" );
1233 wxCHECK_RET( aLine !=
nullptr &&
m_out !=
nullptr,
"" );
1241 case LAYER_BUS: lineType =
"bus";
break;
1248 m_out->
Print(
"(%s (pts (xy %s %s) (xy %s %s))",
1267 wxCHECK_RET( aText !=
nullptr &&
m_out !=
nullptr,
"" );
1285 flag->GetPinLength() ).c_str() );
1318 if( label && !label->
GetFields().empty() )
1326 aText->EDA_TEXT::Format(
m_out, 0 );
1341 wxCHECK_RET( aTextBox !=
nullptr &&
m_out !=
nullptr,
"" );
1352 m_out->
Print(
"(at %s %s %s) (size %s %s) (margins %s %s %s %s)",
1364 m_out->
Print(
"(span %d %d)", cell->GetColSpan(), cell->GetRowSpan() );
1370 aTextBox->EDA_TEXT::Format(
m_out, 0 );
1387 for(
int row = 0; row < aTable->
GetRowCount(); ++row )
1389 for(
int col = 0; col < aTable->
GetColCount(); ++col )
1395 minRow = std::min( minRow, row );
1396 maxRow = std::max( maxRow, row );
1397 minCol = std::min( minCol, col );
1398 maxCol = std::max( maxCol, col );
1407 wxCHECK_MSG( maxCol >= minCol && maxRow >= minRow, , wxT(
"No selected cells!" ) );
1411 for(
int row = minRow; row <= maxRow; row++ )
1416 for(
int col = minCol; col <= maxCol; col++ )
1423 wxCHECK_RET( aTable !=
nullptr &&
m_out !=
nullptr,
"" );
1447 for(
int col = 0; col < aTable->
GetColCount(); ++col )
1458 for(
int row = 0; row < aTable->
GetRowCount(); ++row )
1482 wxCHECK_RET( aAlias !=
nullptr,
"BUS_ALIAS* is NULL" );
1486 for(
const wxString& member : aAlias->Members() )
1488 if( !members.IsEmpty() )
1489 members += wxS(
" " );
1502 if( aInstances.size() )
1508 wxString
path = instance.m_Path.AsString();
1510 if(
path.IsEmpty() )
1524 const std::map<std::string, UTF8>* aProperties )
1558 const wxString& aLibraryPath,
1559 const std::map<std::string, UTF8>* aProperties )
1563 bool powerSymbolsOnly = ( aProperties &&
1566 cacheLib( aLibraryPath, aProperties );
1570 for( LIB_SYMBOL_MAP::const_iterator it = symbols.begin(); it != symbols.end(); ++it )
1572 if( !powerSymbolsOnly || it->second->IsPower() )
1573 aSymbolNameList.Add( it->first );
1579 const wxString& aLibraryPath,
1580 const std::map<std::string, UTF8>* aProperties )
1584 bool powerSymbolsOnly = ( aProperties &&
1587 cacheLib( aLibraryPath, aProperties );
1591 for( LIB_SYMBOL_MAP::const_iterator it = symbols.begin(); it != symbols.end(); ++it )
1593 if( !powerSymbolsOnly || it->second->IsPower() )
1594 aSymbolList.push_back( it->second );
1600 const wxString& aSymbolName,
1601 const std::map<std::string, UTF8>* aProperties )
1605 cacheLib( aLibraryPath, aProperties );
1607 LIB_SYMBOL_MAP::const_iterator it =
m_cache->
m_symbols.find( aSymbolName );
1613 if( it ==
m_cache->
m_symbols.end() && aSymbolName.Contains( wxT(
"{slash}" ) ) )
1615 wxString unescaped = aSymbolName;
1616 unescaped.Replace( wxT(
"{slash}" ), wxT(
"/" ) );
1628 const std::map<std::string, UTF8>* aProperties )
1632 cacheLib( aLibraryPath, aProperties );
1642 const std::map<std::string, UTF8>* aProperties )
1646 cacheLib( aLibraryPath, aProperties );
1656 const std::map<std::string, UTF8>* aProperties )
1658 if( wxFileExists( aLibraryPath ) )
1660 THROW_IO_ERROR( wxString::Format(
_(
"Symbol library '%s' already exists." ),
1661 aLibraryPath.GetData() ) );
1675 const std::map<std::string, UTF8>* aProperties )
1677 wxFileName fn = aLibraryPath;
1679 if( !fn.FileExists() )
1684 if( wxRemove( aLibraryPath ) )
1686 THROW_IO_ERROR( wxString::Format(
_(
"Symbol library '%s' cannot be deleted." ),
1687 aLibraryPath.GetData() ) );
1701 const std::map<std::string, UTF8>* aProperties )
1722 wxFileName fn( aLibraryPath );
1724 if( fn.FileExists() )
1725 return fn.IsFileWritable();
1727 return fn.IsDirWritable();
1738 std::set<wxString> fieldNames;
1740 for( LIB_SYMBOL_MAP::const_iterator it = symbols.begin(); it != symbols.end(); ++it )
1742 std::vector<SCH_FIELD*> fields;
1743 it->second->GetFields( fields );
1747 if( field->IsMandatory() )
1752 fieldNames.insert( field->GetName() );
1756 std::copy( fieldNames.begin(), fieldNames.end(), std::back_inserter( aNames ) );
1767 std::string aSource,
1774 std::vector<LIB_SYMBOL*> newSymbols;
1775 std::unique_ptr<STRING_LINE_READER> reader = std::make_unique<STRING_LINE_READER>( aSymbolText,
1782 newSymbol = parser.
ParseSymbol( map, aFileVersion );
1785 newSymbols.emplace_back( newSymbol );
constexpr EDA_IU_SCALE schIUScale
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
wxString GetMajorMinorVersion()
Get only the major and minor version in a string major.minor.
This class handle bitmap images in KiCad.
const wxMemoryBuffer & GetImageDataBuffer() const
void SetFlags(EDA_ITEM_FLAGS aMask)
KICAD_T Type() const
Returns the type of object.
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
virtual void SetParent(EDA_ITEM *aParent)
EDA_ITEM * GetParent() const
EDA_ITEM_FLAGS GetFlags() const
FILL_T GetFillMode() const
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
COLOR4D GetFillColor() const
wxString SHAPE_T_asString() const
int GetTextHeight() const
bool IsDefaultFormatting() const
const EDA_ANGLE & GetTextAngle() const
virtual const wxString & GetText() const
Return the string associated with the text object.
virtual void Format(OUTPUTFORMATTER *aFormatter, int aControlBits) const
Output the object to aFormatter in s-expression form.
EE_TYPE OfType(KICAD_T aType) const
void WriteEmbeddedFiles(OUTPUTFORMATTER &aOut, bool aWriteData) const
Output formatter for the embedded files.
void ClearEmbeddedFonts()
Remove all embedded fonts from the collection.
bool GetAreFontsEmbedded() const
A LINE_READER that reads from an open file.
void Rewind()
Rewind the file and resets the line number back to zero.
char * ReadLine() override
Read a line of text into the buffer and increments the line number counter.
PROGRESS_REPORTER * m_progressReporter
Progress reporter to track the progress of the operation, may be nullptr.
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()
bool MakeRelativeTo(const KIID_PATH &aPath)
wxString AsString() const
Define a library symbol object.
An abstract class from which implementation specific LINE_READERs may be derived to read single lines...
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
void Format(OUTPUTFORMATTER *aFormatter) const
Output the page class to aFormatter in s-expression form.
virtual bool KeepRefreshing(bool aWait=false)=0
Update the UI (if any).
virtual void Report(const wxString &aMessage)=0
Display aMessage in the progress bar dialog.
virtual const wxString GetProjectPath() const
Return the full path of the project.
virtual const wxString GetProjectName() const
Return the short name of the project.
A REFERENCE_IMAGE is a wrapper around a BITMAP_IMAGE that is displayed in an editor as a reference fo...
VECTOR2I GetPosition() const
const BITMAP_BASE & GetImage() const
Get the underlying image.
double GetImageScale() const
Holds all the data relating to one schematic.
void EmbedFonts() override
Embed fonts in the schematic.
SCH_SHEET_LIST Hierarchy() const override
Return the full schematic flattened hierarchical sheet list.
EMBEDDED_FILES * GetEmbeddedFiles() override
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.
Object to handle a bitmap image that can be inserted in a schematic.
REFERENCE_IMAGE & GetReferenceImage()
Base class for a bus or wire entry.
VECTOR2I GetPosition() const override
virtual STROKE_PARAMS GetStroke() const override
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
VECTOR2I GetPosition() const override
wxString GetCanonicalName() const
Get a non-language-specific name for a field which can be used for storage, variable look-up,...
wxString GetName(bool aUseDefaultName=true) const
Return the field name (not translated).
bool CanAutoplace() const
A cache assistant for the KiCad s-expression symbol libraries.
static void SaveSymbol(LIB_SYMBOL *aSymbol, OUTPUTFORMATTER &aFormatter, const wxString &aLibName=wxEmptyString, bool aIncludeData=true)
void DeleteSymbol(const wxString &aName) override
void Save(const std::optional< bool > &aOpt=std::nullopt) override
Save the entire library to file m_libFileName;.
Object to parser s-expression symbol library and schematic file formats.
void ParseSchematic(SCH_SHEET *aSheet, bool aIsCopyablyOnly=false, int aFileVersion=SEXPR_SCHEMATIC_FILE_VERSION)
Parse the internal LINE_READER object into aSheet.
LIB_SYMBOL * ParseSymbol(LIB_SYMBOL_MAP &aSymbolLibMap, int aFileVersion=SEXPR_SYMBOL_LIB_FILE_VERSION)
Parse internal LINE_READER object into symbols and return all found.
wxString m_path
Root project path for loading child sheets.
void GetDefaultSymbolFields(std::vector< wxString > &aNames) override
Retrieves a list of (custom) field names that should be shown by default for this library in the symb...
void saveShape(SCH_SHAPE *aShape)
void SaveSchematicFile(const wxString &aFileName, SCH_SHEET *aSheet, SCHEMATIC *aSchematic, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Write aSchematic to a storage file in a format that this SCH_IO implementation knows about,...
void SaveLibrary(const wxString &aLibraryPath, const std::map< std::string, UTF8 > *aProperties=nullptr) override
SCH_SHEET_PATH m_currentSheetPath
void LoadContent(LINE_READER &aReader, SCH_SHEET *aSheet, int aVersion=SEXPR_SCHEMATIC_FILE_VERSION)
void EnumerateSymbolLib(wxArrayString &aSymbolNameList, const wxString &aLibraryPath, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Populate a list of LIB_SYMBOL alias names contained within the library aLibraryPath.
bool m_appending
Schematic load append status.
int m_version
Version of file being loaded.
void loadFile(const wxString &aFileName, SCH_SHEET *aSheet)
static void FormatLibSymbol(LIB_SYMBOL *aPart, OUTPUTFORMATTER &aFormatter)
void DeleteSymbol(const wxString &aLibraryPath, const wxString &aSymbolName, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Delete the entire LIB_SYMBOL associated with aAliasName from the library aLibraryPath.
void loadHierarchy(const SCH_SHEET_PATH &aParentSheetPath, SCH_SHEET *aSheet)
void SaveSymbol(const wxString &aLibraryPath, const LIB_SYMBOL *aSymbol, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Write aSymbol to an existing library located at aLibraryPath.
static std::vector< LIB_SYMBOL * > ParseLibSymbols(std::string &aSymbolText, std::string aSource, int aFileVersion=SEXPR_SCHEMATIC_FILE_VERSION)
void saveBusAlias(std::shared_ptr< BUS_ALIAS > aAlias)
OUTPUTFORMATTER * m_out
The formatter for saving SCH_SCREEN objects.
SCH_SHEET * LoadSchematicFile(const wxString &aFileName, SCHEMATIC *aSchematic, SCH_SHEET *aAppendToMe=nullptr, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Load information from some input file format that this SCH_IO implementation knows about,...
LIB_SYMBOL * LoadSymbol(const wxString &aLibraryPath, const wxString &aAliasName, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Load a LIB_SYMBOL object having aPartName from the aLibraryPath containing a library format that this...
wxString m_error
For throwing exceptions or errors on partial loads.
void saveInstances(const std::vector< SCH_SHEET_INSTANCE > &aSheets)
bool isBuffering(const std::map< std::string, UTF8 > *aProperties)
static const char * PropBuffering
The property used internally by the plugin to enable cache buffering which prevents the library file ...
SCH_SHEET * m_rootSheet
The root sheet of the schematic being loaded.
void cacheLib(const wxString &aLibraryFileName, const std::map< std::string, UTF8 > *aProperties)
void saveRuleArea(SCH_RULE_AREA *aRuleArea)
void saveField(SCH_FIELD *aField)
SCH_IO_KICAD_SEXPR_LIB_CACHE * m_cache
void Format(SCH_SHEET *aSheet)
bool IsLibraryWritable(const wxString &aLibraryPath) override
Return true if the library at aLibraryPath is writable.
void init(SCHEMATIC *aSchematic, const std::map< std::string, UTF8 > *aProperties=nullptr)
initialize PLUGIN like a constructor would.
bool DeleteLibrary(const wxString &aLibraryPath, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Delete an existing library and returns true, or if library does not exist returns false,...
void saveBitmap(const SCH_BITMAP &aBitmap)
void saveText(SCH_TEXT *aText)
void saveSheet(SCH_SHEET *aSheet, const SCH_SHEET_LIST &aSheetList)
int GetModifyHash() const override
Return the modification hash from the library cache.
virtual ~SCH_IO_KICAD_SEXPR()
void saveLine(SCH_LINE *aLine)
void saveNoConnect(SCH_NO_CONNECT *aNoConnect)
void saveTable(SCH_TABLE *aTable)
std::stack< wxString > m_currentPath
Stack to maintain nested sheet paths.
void CreateLibrary(const wxString &aLibraryPath, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Create a new empty library at aLibraryPath empty.
void saveJunction(SCH_JUNCTION *aJunction)
void saveTextBox(SCH_TEXTBOX *aText)
void saveSymbol(SCH_SYMBOL *aSymbol, const SCHEMATIC &aSchematic, const SCH_SHEET_LIST &aSheetList, bool aForClipboard, const SCH_SHEET_PATH *aRelativePath=nullptr)
void saveBusEntry(SCH_BUS_ENTRY_BASE *aBusEntry)
void GetAvailableSymbolFields(std::vector< wxString > &aNames) override
Retrieves a list of (custom) field names that are present on symbols in this library.
bool IsFile(const wxString &aFullPathAndFileName) const
void SetFileName(const wxString &aFileName)
virtual void AddSymbol(const LIB_SYMBOL *aSymbol)
bool IsFileChanged() const
wxString GetFileName() const
void SetModified(bool aModified=true)
Base class that schematic file and library loading and saving plugins should derive from.
Base class for any item which can be embedded within the SCHEMATIC container class,...
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
AUTOPLACE_ALGO GetFieldsAutoplaced() const
Return whether the fields have been automatically placed.
wxString GetClass() const override
Return the class name.
VECTOR2I GetPosition() const override
SPIN_STYLE GetSpinStyle() const
LABEL_FLAG_SHAPE GetShape() const
std::vector< SCH_FIELD > & GetFields()
Segment description base class to describe items which have 2 end points (track, wire,...
virtual STROKE_PARAMS GetStroke() const override
VECTOR2I GetEndPoint() const
VECTOR2I GetStartPoint() const
void SetEndPoint(const VECTOR2I &aPosition)
VECTOR2I GetPosition() const override
const PAGE_INFO & GetPageSettings() const
auto & GetBusAliases() const
Return a set of bus aliases defined in this screen.
const std::map< wxString, LIB_SYMBOL * > & GetLibSymbols() const
Fetch a list of unique LIB_SYMBOL object pointers required to properly render each SCH_SYMBOL in this...
EE_RTREE & Items()
Gets the full RTree, usually for iterating.
const wxString & GetFileName() const
void SetFileName(const wxString &aFileName)
Set the file name for this screen to aFileName.
const TITLE_BLOCK & GetTitleBlock() const
KIID m_uuid
A unique identifier for each schematic file.
void SetFileReadOnly(bool aIsReadOnly)
void SetFileExists(bool aFileExists)
STROKE_PARAMS GetStroke() const override
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
std::optional< SCH_SHEET_PATH > GetSheetPathByKIIDPath(const KIID_PATH &aPath, bool aIncludeLastSheet=true) const
Finds a SCH_SHEET_PATH that matches the provided KIID_PATH.
std::optional< SCH_SHEET_PATH > GetOrdinalPath(const SCH_SCREEN *aScreen) const
Return the ordinal sheet path of aScreen.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
bool empty() const
Forwarded method from std::vector.
KIID_PATH Path() const
Get the sheet path as an KIID_PATH.
SCH_SCREEN * LastScreen()
SCH_SHEET * at(size_t aIndex) const
Forwarded method from std::vector.
void push_back(SCH_SHEET *aSheet)
Forwarded method from std::vector.
void pop_back()
Forwarded method from std::vector.
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
bool GetExcludedFromBOM() const
wxString GetFileName() const
Return the filename corresponding to this sheet.
bool HasRootInstance() const
Check to see if this sheet has a root sheet instance.
std::vector< SCH_FIELD > & GetFields()
bool GetExcludedFromBoard() const
bool SearchHierarchy(const wxString &aFilename, SCH_SCREEN **aScreen)
Search the existing hierarchy for an instance of screen loaded from aFileName.
SCH_SCREEN * GetScreen() const
VECTOR2I GetPosition() const override
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
const SCH_SHEET_INSTANCE & GetRootInstance() const
Return the root sheet instance data.
KIGFX::COLOR4D GetBorderColor() const
bool GetExcludedFromSim() const override
int GetBorderWidth() const
std::vector< SCH_SHEET_PIN * > & GetPins()
const std::vector< SCH_SHEET_INSTANCE > & GetInstances() const
bool GetDNP() const
Set or clear the 'Do Not Populate' flaga.
KIGFX::COLOR4D GetBackgroundColor() const
std::vector< std::unique_ptr< SCH_PIN > > & GetRawPins()
const std::vector< SCH_SYMBOL_INSTANCE > & GetInstances() const
bool UseLibIdLookup() const
wxString GetSchSymbolLibraryName() const
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly) override
Populate a std::vector with SCH_FIELDs.
SCH_FIELD * GetField(MANDATORY_FIELD_T aFieldType)
Return a mandatory field in this symbol.
VECTOR2I GetPosition() const override
const LIB_ID & GetLibId() const override
bool GetInstance(SCH_SYMBOL_INSTANCE &aInstance, const KIID_PATH &aSheetPath, bool aTestFromEnd=false) const
int GetOrientation() const override
Get the display symbol orientation.
wxString GetPrefix() const
void SetRowHeight(int aRow, int aHeight)
const STROKE_PARAMS & GetSeparatorsStroke() const
void SetColCount(int aCount)
bool StrokeExternal() const
int GetRowHeight(int aRow) const
void SetColWidth(int aCol, int aWidth)
std::vector< SCH_TABLECELL * > GetCells() const
int GetColWidth(int aCol) const
const STROKE_PARAMS & GetBorderStroke() const
SCH_TABLECELL * GetCell(int aRow, int aCol) const
bool StrokeColumns() const
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
bool StrokeHeader() const
int GetMarginBottom() const
int GetMarginLeft() const
bool GetExcludedFromSim() const override
int GetMarginRight() const
VECTOR2I GetPosition() const override
bool GetExcludedFromSim() const override
virtual KIGFX::VIEW_ITEM * GetItem(unsigned int aIdx) const override
virtual unsigned int GetSize() const override
Return the number of stored items.
Is a LINE_READER that reads from a multiline 8 bit wide std::string.
Simple container to manage line stroke parameters.
void SetWidth(int aWidth)
void Format(OUTPUTFORMATTER *out, const EDA_IU_SCALE &aIuScale) const
static const char * PropPowerSymsOnly
bool GetExcludedFromBoard() const
bool GetExcludedFromBOM() const
bool GetDNP() const
Set or clear the 'Do Not Populate' flag.
bool GetExcludedFromSim() const override
virtual void Format(OUTPUTFORMATTER *aFormatter) const
Output the object to aFormatter in s-expression form.
static REPORTER & GetInstance()
static void SetReporter(REPORTER *aReporter)
Set the reporter to use for reporting font substitution warnings.
#define MIME_BASE64_LENGTH
static constexpr EDA_ANGLE ANGLE_0
static constexpr EDA_ANGLE ANGLE_90
static constexpr EDA_ANGLE ANGLE_270
static constexpr EDA_ANGLE ANGLE_180
#define STRUCT_DELETED
flag indication structures to be erased
#define SKIP_STRUCT
flag indicating that the structure should be ignored
#define DEFAULT_SIZE_TEXT
This is the "default-of-the-default" hardcoded text size; individual application define their own def...
const wxChar *const traceSchPlugin
Flag to enable legacy schematic plugin debug output.
#define THROW_IO_ERROR(msg)
wxString LayerName(int aLayer)
Returns the default display name for a given layer.
#define UNIMPLEMENTED_FOR(type)
KICOMMON_API std::string FormatInternalUnits(const EDA_IU_SCALE &aIuScale, int aValue)
Converts aValue from internal units to a string appropriate for writing to file.
KICOMMON_API std::string FormatAngle(const EDA_ANGLE &aAngle)
Convert aAngle from board units to a string appropriate for writing to file.
#define SEXPR_SCHEMATIC_FILE_VERSION
Schematic file version.
void formatArc(OUTPUTFORMATTER *aFormatter, EDA_SHAPE *aArc, bool aIsPrivate, const STROKE_PARAMS &aStroke, FILL_T aFillMode, const COLOR4D &aFillColor, bool aInvertY, const KIID &aUuid)
const char * getSheetPinShapeToken(LABEL_FLAG_SHAPE aShape)
void formatCircle(OUTPUTFORMATTER *aFormatter, EDA_SHAPE *aCircle, bool aIsPrivate, const STROKE_PARAMS &aStroke, FILL_T aFillMode, const COLOR4D &aFillColor, bool aInvertY, const KIID &aUuid)
const char * getTextTypeToken(KICAD_T aType)
void formatBezier(OUTPUTFORMATTER *aFormatter, EDA_SHAPE *aBezier, bool aIsPrivate, const STROKE_PARAMS &aStroke, FILL_T aFillMode, const COLOR4D &aFillColor, bool aInvertY, const KIID &aUuid)
void formatRect(OUTPUTFORMATTER *aFormatter, EDA_SHAPE *aRect, bool aIsPrivate, const STROKE_PARAMS &aStroke, FILL_T aFillMode, const COLOR4D &aFillColor, bool aInvertY, const KIID &aUuid)
void formatPoly(OUTPUTFORMATTER *aFormatter, EDA_SHAPE *aPolyLine, bool aIsPrivate, const STROKE_PARAMS &aStroke, FILL_T aFillMode, const COLOR4D &aFillColor, bool aInvertY, const KIID &aUuid)
EDA_ANGLE getSheetPinAngle(SHEET_SIDE aSide)
void formatFill(OUTPUTFORMATTER *aFormatter, FILL_T aFillMode, const COLOR4D &aFillColor)
Fill token formatting helper.
@ SHEET_MANDATORY_FIELDS
The first 2 are mandatory, and must be instantiated in SCH_SHEET.
std::string toUTFTildaText(const wxString &txt)
Convert a wxString to UTF8 and replace any control characters with a ~, where a control character is ...
std::string FormatDouble2Str(double aValue)
Print a float number without using scientific notation and no trailing 0 This function is intended in...
std::string EscapedUTF8(const wxString &aString)
Return an 8 bit UTF8 string given aString in Unicode form.
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
constexpr int MilsToIU(int mils) const
A simple container for sheet instance information.
A simple container for schematic symbol instance information.
std::map< wxString, LIB_SYMBOL *, LibSymbolMapSort > LIB_SYMBOL_MAP
@ FOOTPRINT_FIELD
Field Name Module PCB, i.e. "16DIP300".
@ VALUE_FIELD
Field Value of part, i.e. "3.3K".
@ MANDATORY_FIELDS
The first 5 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors.
@ REFERENCE_FIELD
Field Reference of part, i.e. "IC21".
wxLogTrace helper definitions.