30#include <wx/mstream.h>
56#include <schematic_lexer.h>
65#include <boost/algorithm/string/join.hpp>
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() )
76 m_progressReporter( nullptr )
103 wxASSERT( !aFileName || aSchematic !=
nullptr );
108 wxFileName fn = aFileName;
113 wxASSERT( fn.IsAbsolute() );
123 if( !normedFn.IsAbsolute() )
125 if( aFileName.Right( normedFn.GetFullPath().Length() ) == normedFn.GetFullPath() )
126 m_path = aFileName.Left( aFileName.Length() - normedFn.GetFullPath().Length() );
140 init( aSchematic, aProperties );
142 if( aAppendToMe ==
nullptr )
145 std::unique_ptr<SCH_SHEET> newSheet = std::make_unique<SCH_SHEET>( aSchematic );
147 wxFileName relPath( aFileName );
153 newSheet->SetFileName( relPath.GetFullPath() );
158 sheet = newSheet.release();
163 wxCHECK_MSG( aSchematic->
IsValid(),
nullptr,
"Can't append to a schematic with no root!" );
192 if( !fileName.IsAbsolute() )
201 wxLogTrace(
traceSchPlugin,
"Loading '%s'", fileName.GetFullPath() );
205 while( !ancestorSheetPath.
empty() )
212 m_error += wxString::Format(
_(
"Could not load sheet '%s' because it already "
213 "appears as a direct ancestor in the schematic "
215 fileName.GetFullPath() );
217 fileName = wxEmptyString;
225 if( ancestorSheetPath.
empty() )
246 loadFile( fileName.GetFullPath(), aSheet );
261 if( fileName.FileExists() )
299 size_t lineCount = 0;
334 wxCHECK_RET( aSheet !=
nullptr,
"NULL SCH_SHEET object." );
335 wxCHECK_RET( !aFileName.IsEmpty(),
"No schematic file name defined." );
339 init( aSchematic, aProperties );
341 wxFileName fn = aFileName;
345 wxASSERT( fn.IsAbsolute() );
360 wxCHECK_RET( aSheet !=
nullptr,
"NULL SCH_SHEET* object." );
361 wxCHECK_RET(
m_schematic !=
nullptr,
"NULL SCHEMATIC* object." );
367 m_out->
Print( 0,
"(kicad_sch (version %d) (generator eeschema)\n\n",
379 for( std::pair<const wxString, LIB_SYMBOL*>& libSymbol : screen->
GetLibSymbols() )
384 for(
const std::shared_ptr<BUS_ALIAS>& alias : screen->
GetBusAliases() )
391 if( a->
Type() != b->Type() )
392 return a->
Type() < b->Type();
394 return a->
m_Uuid < b->m_Uuid;
397 std::multiset<
SCH_ITEM*,
decltype( cmp )> save_map( cmp );
403 save_map.insert( item );
411 if( itemType != item->Type() )
413 itemType = item->Type();
423 switch( item->Type() )
453 if( layer != item->GetLayer() )
457 layer = item->GetLayer();
461 layer = item->GetLayer();
486 wxASSERT(
"Unexpected schematic object type in SCH_SEXPR_PLUGIN::Format()" );
492 std::vector< SCH_SHEET_INSTANCE> instances;
506 wxCHECK( aSelection && aSelectionPath && aFormatter, );
516 std::map<wxString, LIB_SYMBOL*> libSymbols;
519 for( i = 0; i < aSelection->
GetSize(); ++i )
523 wxCHECK2( item,
continue );
530 wxCHECK2( symbol,
continue );
540 libSymbols[ libSymbolLookup ] = it->second;
543 if( !libSymbols.empty() )
547 for(
const std::pair<const wxString, LIB_SYMBOL*>& libSymbol : libSymbols )
557 for( i = 0; i < aSelection->
GetSize(); ++i )
561 switch( item->
Type() )
621 wxASSERT(
"Unexpected schematic object type in SCH_SEXPR_PLUGIN::Format()" );
629 std::vector<SCH_SHEET_INSTANCE> sheetinstances = selectedSheets.
GetSheetInstances();
633 wxASSERT_MSG( sheetInstance.m_Path.MakeRelativeTo( selectionPath ),
634 "Sheet is not inside the selection path?" );
637 selectionPath = aSelectionPath->
Path();
639 std::vector<SCH_SYMBOL_INSTANCE> symbolInstances = selectedSymbols.
GetSymbolInstances();
643 wxASSERT_MSG( symbolInstance.m_Path.MakeRelativeTo( selectionPath ),
644 "Symbol is not inside the selection path?" );
650 int aNestLevel,
bool aForClipboard )
652 wxCHECK_RET( aSymbol !=
nullptr &&
m_out !=
nullptr,
"" );
661 if( symbol_name.size() )
667 libName =
"_NONAME_";
690 m_out->
Print( 0,
" (lib_id %s) (at %s %s %s)",
701 if( mirrorX || mirrorY )
742 int id = field.GetId();
743 wxString value = field.GetText();
771 field.SetText( value );
777 field.SetText( value );
780 for(
const std::unique_ptr<SCH_PIN>&
pin : aSymbol->
GetRawPins() )
782 if(
pin->GetAlt().IsEmpty() )
784 m_out->
Print( aNestLevel + 1,
"(pin %s (uuid %s))\n",
790 m_out->
Print( aNestLevel + 1,
"(pin %s (uuid %s) (alternate %s))\n",
799 m_out->
Print( aNestLevel + 1,
"(instances\n" );
801 KIID lastProjectUuid;
804 bool project_open =
false;
821 project_open =
false;
829 wxString projectName;
837 m_out->
Print( aNestLevel + 2,
"(project %s\n",
846 m_out->
Print( aNestLevel + 4,
"(reference %s) (unit %d)\n",
855 project_open =
false;
868 wxCHECK_RET( aField !=
nullptr &&
m_out !=
nullptr,
"" );
874 if( aField->
GetId() == -1 )
884 m_out->
Print( aNestLevel,
"(property %s %s (at %s %s %s)",
915 wxCHECK_RET( aBitmap !=
nullptr &&
m_out !=
nullptr,
"" );
919 wxCHECK_RET(
image !=
nullptr,
"wxImage* is NULL" );
921 m_out->
Print( aNestLevel,
"(image (at %s %s)",
946 wxMemoryOutputStream stream;
948 image->SaveFile( stream, wxBITMAP_TYPE_PNG );
951 wxStreamBuffer* buffer = stream.GetOutputStreamBuffer();
952 wxString out = wxBase64Encode( buffer->GetBufferStart(), buffer->GetBufferSize() );
956#define MIME_BASE64_LENGTH 76
960 while( first < out.Length() )
975 wxCHECK_RET( aSheet !=
nullptr &&
m_out !=
nullptr,
"" );
977 m_out->
Print( aNestLevel,
"(sheet (at %s %s) (size %s %s)",
1000 m_out->
Print( aNestLevel + 1,
"(fill (color %d %d %d %0.4f))\n",
1017 m_out->
Print( aNestLevel + 1,
"(pin %s %s (at %s %s %s)\n",
1021 pin->GetPosition().x ).c_str(),
1023 pin->GetPosition().y ).c_str(),
1026 pin->Format(
m_out, aNestLevel + 1, 0 );
1034 std::vector< SCH_SHEET_INSTANCE > sheetInstances = aSheet->
GetInstances();
1036 auto it = sheetInstances.begin();
1038 while( it != sheetInstances.end() )
1040 if( it->m_Path.size() == 0 )
1041 it = sheetInstances.erase( it );
1046 if( !sheetInstances.empty() )
1048 m_out->
Print( aNestLevel + 1,
"(instances\n" );
1050 KIID lastProjectUuid;
1053 bool project_open =
false;
1055 for(
size_t i = 0; i < sheetInstances.size(); i++ )
1062 if( ( sheetInstances[i].m_Path[0] == rootSheetUuid )
1065 if( project_open && ( ( i + 1 == sheetInstances.size() )
1066 || lastProjectUuid != sheetInstances[i+1].m_Path[0] ) )
1069 project_open =
false;
1075 if( lastProjectUuid != sheetInstances[i].m_Path[0] )
1077 wxString projectName;
1079 if( sheetInstances[i].m_Path[0] == rootSheetUuid )
1082 projectName = sheetInstances[i].m_ProjectName;
1084 lastProjectUuid = sheetInstances[i].m_Path[0];
1085 m_out->
Print( aNestLevel + 2,
"(project %s\n",
1087 project_open =
true;
1090 wxString
path = sheetInstances[i].m_Path.AsString();
1092 m_out->
Print( aNestLevel + 3,
"(path %s (page %s))\n",
1094 m_out->
Quotew( sheetInstances[i].m_PageNumber ).c_str() );
1096 if( project_open && ( ( i + 1 == sheetInstances.size() )
1097 || lastProjectUuid != sheetInstances[i+1].m_Path[0] ) )
1100 project_open =
false;
1113 wxCHECK_RET( aJunction !=
nullptr &&
m_out !=
nullptr,
"" );
1115 m_out->
Print( aNestLevel,
"(junction (at %s %s) (diameter %s) (color %d %d %d %s)\n",
1135 wxCHECK_RET( aNoConnect !=
nullptr &&
m_out !=
nullptr,
"" );
1137 m_out->
Print( aNestLevel,
"(no_connect (at %s %s) (uuid %s))\n",
1148 wxCHECK_RET( aBusEntry !=
nullptr &&
m_out !=
nullptr,
"" );
1151 if( aBusEntry->
GetClass() ==
"SCH_BUS_BUS_ENTRY" )
1156 saveLine( &busEntryLine, aNestLevel );
1160 m_out->
Print( aNestLevel,
"(bus_entry (at %s %s) (size %s %s)\n",
1168 aBusEntry->
GetSize().
y ).c_str() );
1183 wxCHECK_RET( aShape !=
nullptr &&
m_out !=
nullptr,
"" );
1192 case SHAPE_T::CIRCLE:
1202 case SHAPE_T::BEZIER:
1220 wxCHECK_RET( aLine !=
nullptr &&
m_out !=
nullptr,
"" );
1228 case LAYER_BUS: lineType =
"bus";
break;
1235 m_out->
Print( aNestLevel,
"(%s (pts (xy %s %s) (xy %s %s))\n",
1257 wxCHECK_RET( aText !=
nullptr &&
m_out !=
nullptr,
"" );
1277 flag->GetPinLength() ).c_str() );
1303 if( aText->
GetText().Length() < 50 )
1315 m_out->
Print( aNestLevel + 1,
"(at %s %s %s)",
1327 aText->EDA_TEXT::Format(
m_out, aNestLevel, 0 );
1343 wxCHECK_RET( aTextBox !=
nullptr &&
m_out !=
nullptr,
"" );
1351 m_out->
Print( aNestLevel + 1,
"(exclude_from_sim %s) (at %s %s %s) (size %s %s)\n",
1364 aTextBox->EDA_TEXT::Format(
m_out, aNestLevel, 0 );
1375 wxCHECK_RET( aAlias !=
nullptr,
"BUS_ALIAS* is NULL" );
1379 for(
const wxString& member : aAlias->Members() )
1381 if( !members.IsEmpty() )
1382 members += wxS(
" " );
1387 m_out->
Print( aNestLevel,
"(bus_alias %s (members %s))\n",
1396 if( aInstances.size() )
1399 m_out->
Print( aNestLevel,
"(sheet_instances\n" );
1403 wxString
path = instance.m_Path.AsString();
1405 if(
path.IsEmpty() )
1408 m_out->
Print( aNestLevel + 1,
"(path %s (page %s))\n",
1450 const wxString& aLibraryPath,
1455 bool powerSymbolsOnly = ( aProperties &&
1458 cacheLib( aLibraryPath, aProperties );
1462 for( LIB_SYMBOL_MAP::const_iterator it = symbols.begin(); it != symbols.end(); ++it )
1464 if( !powerSymbolsOnly || it->second->IsPower() )
1465 aSymbolNameList.Add( it->first );
1471 const wxString& aLibraryPath,
1476 bool powerSymbolsOnly = ( aProperties &&
1479 cacheLib( aLibraryPath, aProperties );
1483 for( LIB_SYMBOL_MAP::const_iterator it = symbols.begin(); it != symbols.end(); ++it )
1485 if( !powerSymbolsOnly || it->second->IsPower() )
1486 aSymbolList.push_back( it->second );
1496 cacheLib( aLibraryPath, aProperties );
1498 LIB_SYMBOL_MAP::const_iterator it =
m_cache->
m_symbols.find( aSymbolName );
1516 cacheLib( aLibraryPath, aProperties );
1530 cacheLib( aLibraryPath, aProperties );
1542 if( wxFileExists( aLibraryPath ) )
1544 THROW_IO_ERROR( wxString::Format(
_(
"Symbol library '%s' already exists." ),
1545 aLibraryPath.GetData() ) );
1561 wxFileName fn = aLibraryPath;
1563 if( !fn.FileExists() )
1568 if( wxRemove( aLibraryPath ) )
1570 THROW_IO_ERROR( wxString::Format(
_(
"Symbol library '%s' cannot be deleted." ),
1571 aLibraryPath.GetData() ) );
1606 wxTextFile tempFile;
1608 tempFile.Open( aFileName );
1611 firstline = tempFile.GetFirstLine();
1614 return firstline.StartsWith( wxS(
"EESchema" ) );
1620 wxFileName fn( aLibraryPath );
1622 return ( fn.FileExists() && fn.IsFileWritable() ) || fn.IsDirWritable();
1633 std::set<wxString> fieldNames;
1635 for( LIB_SYMBOL_MAP::const_iterator it = symbols.begin(); it != symbols.end(); ++it )
1637 std::vector<LIB_FIELD*> fields;
1638 it->second->GetFields( fields );
1642 if( field->IsMandatory() )
1647 fieldNames.insert( field->GetName() );
1651 std::copy( fieldNames.begin(), fieldNames.end(), std::back_inserter( aNames ) );
constexpr EDA_IU_SCALE schIUScale
This class handle bitmap images in KiCad.
KICAD_T Type() const
Returns the type of object.
virtual void SetParent(EDA_ITEM *aParent)
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 aNestLevel, int aControlBits) const
Output the object to aFormatter in s-expression form.
EE_TYPE OfType(KICAD_T aType) 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.
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()
wxString AsString() const
Field object used in symbol libraries.
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, int aNestLevel, int aControlBits) 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.
Holds all the data relating to one schematic.
SCH_SHEET_LIST GetSheets() const override
Builds and returns an updated schematic hierarchy TODO: can this be cached?
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.
VECTOR2I GetPosition() const override
BITMAP_BASE * GetImage() const
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,...
bool CanAutoplace() const
Base class for any item which can be embedded within the SCHEMATIC container class,...
virtual wxString GetClass() const override
Return the class name.
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
FIELDS_AUTOPLACED GetFieldsAutoplaced() const
Return whether the fields have been automatically placed.
VECTOR2I GetPosition() const override
LABEL_FLAG_SHAPE GetShape() const override
std::vector< SCH_FIELD > & GetFields()
bool IsFile(const wxString &aFullPathAndFileName) const
wxString GetFileName() const
bool IsFileChanged() const
void SetFileName(const wxString &aFileName)
virtual void AddSymbol(const LIB_SYMBOL *aSymbol)
void SetModified(bool aModified=true)
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
Container to create a flattened list of symbols because in a complex hierarchy, a symbol can be used ...
void SortByReferenceOnly()
Sort the list of references by reference.
std::vector< SCH_SYMBOL_INSTANCE > GetSymbolInstances() const
const PAGE_INFO & GetPageSettings() const
std::map< wxString, LIB_SYMBOL * > & GetLibSymbols()
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)
std::set< std::shared_ptr< BUS_ALIAS > > GetBusAliases() const
Return a list of bus aliases defined in this screen.
void SetFileExists(bool aFileExists)
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)
A cache assistant for the KiCad s-expression symbol libraries.
static void SaveSymbol(LIB_SYMBOL *aSymbol, OUTPUTFORMATTER &aFormatter, int aNestLevel=0, const wxString &aLibName=wxEmptyString)
void Save(const std::optional< bool > &aOpt=std::nullopt) override
Save the entire library to file m_libFileName;.
void DeleteSymbol(const wxString &aName) override
wxString m_error
For throwing exceptions or errors on partial loads.
void saveBusAlias(std::shared_ptr< BUS_ALIAS > aAlias, int aNestLevel)
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...
SCH_SHEET_PATH m_currentSheetPath
void cacheLib(const wxString &aLibraryFileName, const STRING_UTF8_MAP *aProperties)
wxString m_path
Root project path for loading child sheets.
void saveField(SCH_FIELD *aField, int aNestLevel)
void saveTextBox(SCH_TEXTBOX *aText, int aNestLevel)
OUTPUTFORMATTER * m_out
The formatter for saving SCH_SCREEN objects.
void Format(SCH_SHEET *aSheet)
void SaveSymbol(const wxString &aLibraryPath, const LIB_SYMBOL *aSymbol, const STRING_UTF8_MAP *aProperties=nullptr) override
Write aSymbol to an existing library located at aLibraryPath.
static void FormatLibSymbol(LIB_SYMBOL *aPart, OUTPUTFORMATTER &aFormatter)
void SaveLibrary(const wxString &aLibraryPath, const STRING_UTF8_MAP *aProperties=nullptr) override
void GetAvailableSymbolFields(std::vector< wxString > &aNames) override
Retrieves a list of (custom) field names that are present on symbols in this library.
bool DeleteSymbolLib(const wxString &aLibraryPath, const STRING_UTF8_MAP *aProperties=nullptr) override
Delete an existing symbol library and returns true if successful, or if library does not exist return...
std::stack< wxString > m_currentPath
Stack to maintain nested sheet paths.
void loadFile(const wxString &aFileName, SCH_SHEET *aSheet)
void saveLine(SCH_LINE *aLine, int aNestLevel)
void saveInstances(const std::vector< SCH_SHEET_INSTANCE > &aSheets, int aNestLevel)
virtual ~SCH_SEXPR_PLUGIN()
bool m_appending
Schematic load append status.
SCH_SHEET * m_rootSheet
The root sheet of the schematic being loaded.
void DeleteSymbol(const wxString &aLibraryPath, const wxString &aSymbolName, const STRING_UTF8_MAP *aProperties=nullptr) override
Delete the entire LIB_SYMBOL associated with aAliasName from the library aLibraryPath.
void saveText(SCH_TEXT *aText, int aNestLevel)
static LIB_SYMBOL * ParseLibSymbol(LINE_READER &aReader, int aVersion=SEXPR_SCHEMATIC_FILE_VERSION)
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.
void saveSymbol(SCH_SYMBOL *aSymbol, const SCHEMATIC &aSchematic, int aNestLevel, bool aForClipboard)
void saveSheet(SCH_SHEET *aSheet, int aNestLevel)
SCH_SHEET * Load(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,...
SCH_SEXPR_PLUGIN_CACHE * m_cache
void CreateSymbolLib(const wxString &aLibraryPath, const STRING_UTF8_MAP *aProperties=nullptr) override
Create a new empty symbol library at aLibraryPath.
void LoadContent(LINE_READER &aReader, SCH_SHEET *aSheet, int aVersion=SEXPR_SCHEMATIC_FILE_VERSION)
bool IsSymbolLibWritable(const wxString &aLibraryPath) override
Return true if the library at aLibraryPath is writable.
void loadHierarchy(const SCH_SHEET_PATH &aParentSheetPath, SCH_SHEET *aSheet)
bool isBuffering(const STRING_UTF8_MAP *aProperties)
PROGRESS_REPORTER * m_progressReporter
void init(SCHEMATIC *aSchematic, const STRING_UTF8_MAP *aProperties=nullptr)
initialize PLUGIN like a constructor would.
static const char * PropBuffering
The property used internally by the plugin to enable cache buffering which prevents the library file ...
void saveShape(SCH_SHAPE *aShape, int aNestLevel)
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 saveBitmap(SCH_BITMAP *aBitmap, int aNestLevel)
bool CheckHeader(const wxString &aFileName) override
Return true if the first line in aFileName begins with the expected header.
void saveBusEntry(SCH_BUS_ENTRY_BASE *aBusEntry, int aNestLevel)
void Save(const wxString &aFileName, SCH_SHEET *aSheet, SCHEMATIC *aSchematic, const STRING_UTF8_MAP *aProperties=nullptr) override
Write aSchematic to a storage file in a format that this SCH_PLUGIN implementation knows about,...
int m_version
Version of file being loaded.
int GetModifyHash() const override
Return the modification hash from the library cache.
void saveNoConnect(SCH_NO_CONNECT *aNoConnect, int aNestLevel)
void saveJunction(SCH_JUNCTION *aJunction, int aNestLevel)
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.
void SortByPageNumbers(bool aUpdateVirtualPageNums=true)
Sort the list of sheets by page number.
std::vector< SCH_SHEET_INSTANCE > GetSheetInstances() const
Fetch the instance information for all of the sheets in the hiearchy.
void GetSymbolsWithinPath(SCH_REFERENCE_LIST &aReferences, const SCH_SHEET_PATH &aSheetPath, bool aIncludePowerSymbols=true, bool aForceIncludeOrphanSymbols=false) const
Add a SCH_REFERENCE object to aReferences for each symbol in the list of sheets that are contained wi...
void GetSheetsWithinPath(SCH_SHEET_PATHS &aSheets, const SCH_SHEET_PATH &aSheetPath) const
Add a SCH_SHEET_PATH object to aSheets for each sheet in the list that are contained within aSheetPat...
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 AppendSymbol(SCH_REFERENCE_LIST &aReferences, SCH_SYMBOL *aSymbol, bool aIncludePowerSymbols=true, bool aForceIncludeOrphanSymbols=false) const
Append a SCH_REFERENCE object to aReferences based on aSymbol.
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.
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 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
int GetBorderWidth() const
std::vector< SCH_SHEET_PIN * > & GetPins()
const std::vector< SCH_SHEET_INSTANCE > & GetInstances() const
KIGFX::COLOR4D GetBackgroundColor() const
std::vector< std::unique_ptr< SCH_PIN > > & GetRawPins()
const std::vector< SCH_SYMBOL_INSTANCE > & GetInstanceReferences()
bool UseLibIdLookup() const
wxString GetSchSymbolLibraryName() const
bool GetIncludeOnBoard() const
bool GetIncludeInBom() const
SCH_FIELD * GetField(MANDATORY_FIELD_T aFieldType)
Return a mandatory field in this symbol.
VECTOR2I GetPosition() const override
int GetOrientation() const
Get the display symbol orientation.
const LIB_ID & GetLibId() const
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly)
Populate a std::vector with SCH_FIELDs.
void SortInstances(bool(*aSortFunction)(const SCH_SYMBOL_INSTANCE &aLhs, const SCH_SYMBOL_INSTANCE &aRhs))
bool GetExcludeFromSim() const override
VECTOR2I GetPosition() const override
TEXT_SPIN_STYLE GetTextSpinStyle() const
bool GetExcludeFromSim() const override
virtual KIGFX::VIEW_ITEM * GetItem(unsigned int aIdx) const override
virtual unsigned int GetSize() const override
Return the number of stored items.
A name/value tuple with unique names and optional values.
bool Exists(const std::string &aProperty) const
Simple container to manage line stroke parameters.
void SetWidth(int aWidth)
void Format(OUTPUTFORMATTER *out, const EDA_IU_SCALE &aIuScale, int nestLevel) const
static const char * PropPowerSymsOnly
virtual void Format(OUTPUTFORMATTER *aFormatter, int aNestLevel, int aControlBits) const
Output the object to aFormatter in s-expression form.
static constexpr EDA_ANGLE & ANGLE_180
static constexpr EDA_ANGLE & ANGLE_90
static constexpr EDA_ANGLE & ANGLE_0
static constexpr EDA_ANGLE & ANGLE_270
#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.
SCH_LAYER_ID
Eeschema drawing layers.
#define UNIMPLEMENTED_FOR(type)
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
std::string FormatInternalUnits(const EDA_IU_SCALE &aIuScale, int aValue)
Converts aValue from internal units to a string appropriate for writing to file.
std::string FormatAngle(const EDA_ANGLE &aAngle)
Converts aAngle from board units to a string appropriate for writing to file.
#define SEXPR_SCHEMATIC_FILE_VERSION
Schematic file version.
Schematic and symbol library s-expression file format parser definitions.
#define MIME_BASE64_LENGTH
void formatCircle(OUTPUTFORMATTER *aFormatter, int aNestLevel, EDA_SHAPE *aCircle, bool aIsPrivate, const STROKE_PARAMS &aStroke, FILL_T aFillMode, const COLOR4D &aFillColor, const KIID &aUuid)
void formatArc(OUTPUTFORMATTER *aFormatter, int aNestLevel, EDA_SHAPE *aArc, bool aIsPrivate, const STROKE_PARAMS &aStroke, FILL_T aFillMode, const COLOR4D &aFillColor, const KIID &aUuid)
const char * getSheetPinShapeToken(LABEL_FLAG_SHAPE aShape)
void formatFill(OUTPUTFORMATTER *aFormatter, int aNestLevel, FILL_T aFillMode, const COLOR4D &aFillColor)
Fill token formatting helper.
const char * getTextTypeToken(KICAD_T aType)
void formatRect(OUTPUTFORMATTER *aFormatter, int aNestLevel, EDA_SHAPE *aRect, bool aIsPrivate, const STROKE_PARAMS &aStroke, FILL_T aFillMode, const COLOR4D &aFillColor, const KIID &aUuid)
void formatBezier(OUTPUTFORMATTER *aFormatter, int aNestLevel, EDA_SHAPE *aBezier, bool aIsPrivate, const STROKE_PARAMS &aStroke, FILL_T aFillMode, const COLOR4D &aFillColor, const KIID &aUuid)
void formatPoly(OUTPUTFORMATTER *aFormatter, int aNestLevel, EDA_SHAPE *aPolyLine, bool aIsPrivate, const STROKE_PARAMS &aStroke, FILL_T aFillMode, const COLOR4D &aFillColor, const KIID &aUuid)
EDA_ANGLE getSheetPinAngle(SHEET_SIDE aSide)
@ SHEET_MANDATORY_FIELDS
The first 2 are mandatory, and must be instantiated in SCH_SHEET.
bool SortSymbolInstancesByProjectUuid(const SCH_SYMBOL_INSTANCE &aLhs, const SCH_SYMBOL_INSTANCE &aRhs)
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:...
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 4 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.
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".