55#include <wx/filename.h>
66 size_t sepPos = aRef.rfind(
'-' );
68 if( sepPos == std::string::npos )
69 sepPos = aRef.rfind(
'.' );
71 if( sepPos != std::string::npos && sepPos + 1 < aRef.size()
72 && std::isdigit(
static_cast<unsigned char>( aRef[sepPos + 1] ) ) )
74 return aRef.substr( sepPos + 1 );
88 size_t sepPos = aRef.rfind(
'-' );
90 if( sepPos == std::string::npos )
91 sepPos = aRef.rfind(
'.' );
93 if( sepPos != std::string::npos && sepPos + 1 < aRef.size()
94 && std::isdigit(
static_cast<unsigned char>( aRef[sepPos + 1] ) ) )
96 return aRef.substr( 0, sepPos );
109 size_t sepPos = aRef.rfind(
'-' );
111 if( sepPos == std::string::npos )
112 sepPos = aRef.rfind(
'.' );
114 if( sepPos != std::string::npos && sepPos + 1 < aRef.size()
115 && std::isalpha(
static_cast<unsigned char>( aRef[sepPos + 1] ) ) )
117 return aRef.substr( 0, sepPos );
131 int charHeight =
static_cast<int>( scaledSize
133 int charWidth =
static_cast<int>( scaledSize
153 else if( justVal >= 2 )
195 const std::vector<PADS_SCH::SCH_SIGNAL>& aSignals,
196 const VECTOR2I& aOpcPos,
bool aPinUp,
int aPageHeightIU )
199 std::string opcRef =
"@@@O" + aOpcId;
203 for(
const auto& signal : aSignals )
205 for(
const auto& wire : signal.wires )
207 if( wire.vertices.size() < 2 )
210 if( wire.endpoint_a == opcRef )
220 if( wire.endpoint_b == opcRef )
222 size_t last = wire.vertices.size() - 1;
227 KiROUND( wire.vertices[last - 1].y ) ) );
241 int dx = adjPos.
x - aOpcPos.
x;
242 int dy = adjPos.
y - aOpcPos.
y;
314 const std::map<std::string, UTF8>* aProperties )
316 wxCHECK( !aFileName.IsEmpty() && aSchematic,
nullptr );
324 wxCHECK_MSG( aSchematic->
IsValid(),
nullptr,
"Can't append to a schematic with no root!" );
325 rootSheet = aAppendToMe;
347 wxCHECK( rootScreen,
nullptr );
358 std::string filename( aFileName.ToUTF8() );
360 if( !parser.
Parse( filename ) )
362 THROW_IO_ERROR( wxString::Format( wxT(
"Failed to parse PADS file: %s" ), aFileName ) );
375 const std::string& ref = part.reference;
376 size_t dashPos = ref.rfind(
'-' );
377 size_t dotPos = ref.rfind(
'.' );
378 size_t sepPos = std::string::npos;
380 if( dashPos != std::string::npos )
382 else if( dotPos != std::string::npos )
385 if( sepPos != std::string::npos && sepPos + 1 < ref.size()
386 && std::isalpha(
static_cast<unsigned char>( ref[sepPos + 1] ) ) )
411 if( sheetNumbers.empty() )
412 sheetNumbers.insert( 1 );
414 bool isSingleSheet = ( sheetNumbers.size() == 1 );
424 std::map<int, SheetContext> sheetContexts;
428 int sheetNum = *sheetNumbers.begin();
430 ctx.sheet = rootSheet;
431 ctx.screen = rootScreen;
433 ctx.screen->SetPageSettings( pageInfo );
434 sheetContexts[sheetNum] = ctx;
439 int totalSheets =
static_cast<int>( sheetNumbers.size() );
441 for(
int sheetNum : sheetNumbers )
444 sheetNum, totalSheets, rootSheet, aFileName );
452 if( hdr.sheet_num == sheetNum && !hdr.sheet_name.empty() )
455 wxString::FromUTF8( hdr.sheet_name ) );
465 wxString pageNo = wxString::Format( wxT(
"%d" ), sheetNum );
474 ctx.sheet = subSheet;
477 ctx.screen->SetPageSettings( pageInfo );
478 sheetContexts[sheetNum] = ctx;
486 std::set<std::string> connectorBaseRefs;
490 struct ConnectorGroup
492 std::vector<std::string> pinNumbers;
493 std::map<std::string, int> pinToUnit;
494 std::string partType;
497 std::map<std::string, ConnectorGroup> connectorGroups;
499 for(
const auto& [sheetNum, ctx] : sheetContexts )
501 std::vector<PADS_SCH::PART_PLACEMENT> sheetParts = parser.
GetPartsOnSheet( sheetNum );
505 auto ptIt = parser.
GetPartTypes().find( part.part_type );
507 if( ptIt == parser.
GetPartTypes().end() || !ptIt->second.is_connector )
516 ConnectorGroup&
group = connectorGroups[baseRef];
517 group.partType = part.part_type;
518 group.pinNumbers.push_back( pinNum );
522 for(
auto& [baseRef,
group] : connectorGroups )
524 std::sort(
group.pinNumbers.begin(),
group.pinNumbers.end(),
525 [](
const std::string& a,
const std::string& b )
527 return std::stoi( a ) < std::stoi( b );
530 for(
size_t i = 0; i <
group.pinNumbers.size(); i++ )
531 group.pinToUnit[
group.pinNumbers[i]] =
static_cast<int>( i + 1 );
535 for(
auto& [sheetNum, ctx] : sheetContexts )
537 std::vector<PADS_SCH::PART_PLACEMENT> parts = parser.
GetPartsOnSheet( sheetNum );
541 auto ptIt = parser.
GetPartTypes().find( part.part_type );
544 bool isMultiGate =
false;
545 bool isConnector =
false;
546 bool isPower =
false;
547 std::string libItemName;
548 std::string connectorPinNumber;
554 if( ptDef.
gates.size() > 1 )
559 libItemName = ptDef.
name;
562 else if( !ptDef.
gates.empty() )
565 int idx = std::max( 0, part.gate_index );
566 std::string decalName;
568 if( idx <
static_cast<int>( gate.
decal_names.size() ) )
579 if( symDef && !connectorPinNumber.empty() )
584 auto groupIt = connectorGroups.find( baseRef );
586 if( groupIt != connectorGroups.end() )
588 std::string cacheKey = ptDef.
name +
":conn:" + baseRef;
591 ptDef, *symDef, groupIt->second.pinNumbers, cacheKey );
592 libItemName = ptDef.
name +
"_" + baseRef;
596 connectorBaseRefs.insert( baseRef );
602 libItemName = decalName;
608 int idx = std::max( 0, part.gate_index );
609 idx = std::min( idx,
static_cast<int>( ptDef.
special_variants.size() ) - 1 );
617 libItemName = decalName;
633 wxString::Format( wxT(
"PADS Import: symbol '%s' not found,"
634 " part '%s' skipped" ),
635 wxString::FromUTF8( part.symbol_name ),
636 wxString::FromUTF8( part.reference ) ),
642 libItemName = symDef->
name;
648 if( ptIt != parser.
GetPartTypes().end() && !ptIt->second.sigpins.empty() )
657 std::string powerStyle;
660 && !ptIt->second.special_variants.empty() )
662 int varIdx = std::max( 0, part.gate_index );
665 static_cast<int>( ptIt->second.special_variants.size() ) - 1 );
666 const auto& variant = ptIt->second.special_variants[varIdx];
669 variant.decal_name, variant.pin_type );
672 if( isPower && powerStyle.empty() )
674 std::string rawNetName = part.power_net_name.empty()
676 : part.power_net_name;
682 powerStyle = std::string( powerLibId->GetLibItemName().c_str() );
685 auto symbolPtr = std::make_unique<SCH_SYMBOL>();
689 if( isPower && !powerStyle.empty() )
705 instanceSymbol =
new LIB_SYMBOL( *libSymbol );
718 if( part.rotation == 90.0 )
720 else if( part.rotation == 180.0 )
722 else if( part.rotation == 270.0 )
725 if( part.mirror_flags & 1 )
728 if( part.mirror_flags & 2 )
733 if( isConnector && !connectorPinNumber.empty() )
736 auto groupIt = connectorGroups.find( baseRef );
738 if( groupIt != connectorGroups.end() )
740 auto unitIt = groupIt->second.pinToUnit.find( connectorPinNumber );
742 if( unitIt != groupIt->second.pinToUnit.end() )
743 symbol->
SetUnit( unitIt->second );
752 else if( isMultiGate )
754 symbol->
SetUnit( part.gate_index + 1 );
765 bool isPrimaryUnit = isConnector
767 : ( !isMultiGate || part.gate_index == 0 );
769 if( !isPower && isPrimaryUnit )
771 std::string baseRef = isConnector
779 symbol->
SetRef( &ctx.path, wxString::FromUTF8( part.reference ) );
789 symbol->
SetRef( &ctx.path, wxString::FromUTF8( baseRef ) );
794 if( isMultiGate && !isConnector )
797 symbol->
SetRef( &ctx.path, wxString::FromUTF8( baseRef ) );
805 const std::string& cat = ptIt->second.category;
807 if( cat ==
"CAP" || cat ==
"RES" || cat ==
"IND" )
809 auto valIt = part.attr_overrides.find(
"VALUE" );
811 if( valIt == part.attr_overrides.end() )
812 valIt = part.attr_overrides.find(
"VALUE1" );
814 if( valIt != part.attr_overrides.end() && !valIt->second.empty() )
818 for(
const auto& attr : part.attributes )
820 if( attr.name ==
"VALUE" || attr.name ==
"VALUE1"
821 || attr.name ==
"Value1" )
826 if( part.mirror_flags & 1 )
831 KiROUND( attr.position.y ) ) );
834 int fieldTextSize =
schIUScale.MilsToIU( 50 );
836 VECTOR2I( fieldTextSize, fieldTextSize ) );
850 wxString netName = part.power_net_name.empty()
851 ? wxString::FromUTF8( part.symbol_name )
852 : wxString::FromUTF8( part.power_net_name );
854 if( netName.StartsWith( wxT(
"/" ) ) )
855 netName = wxT(
"~{" ) + netName.Mid( 1 ) + wxT(
"}" );
866 else if( isMultiGate )
869 hierRef = part.reference;
872 wxString::FromUTF8( hierRef ),
881 if( isConnector && !connectorPinNumber.empty() )
884 wxString labelText = wxString::Format( wxT(
"%s.%s" ),
885 wxString::FromUTF8( baseRef ),
886 wxString::FromUTF8( connectorPinNumber ) );
889 std::vector<SCH_PIN*> pins = symbol->
GetPins();
892 pinPos = pins[0]->GetPosition();
899 ctx.screen->Append( label );
902 ctx.screen->Append( symbolPtr.release() );
909 std::set<std::string> powerSignalNames;
913 if( opc.signal_name.empty() )
916 auto ptIt = parser.
GetPartTypes().find( opc.symbol_lib );
919 && !ptIt->second.special_keyword.empty() && ptIt->second.special_keyword !=
"OFF"
920 && !ptIt->second.special_variants.empty() )
922 int idx = std::max( 0, opc.flags2 );
924 static_cast<int>( ptIt->second.special_variants.size() ) - 1 );
925 const auto& variant = ptIt->second.special_variants[idx];
928 variant.decal_name, variant.pin_type ).empty() )
930 powerSignalNames.insert( opc.signal_name );
938 std::set<std::string> signalOpcIds;
942 if( opc.signal_name.empty() || powerSignalNames.count( opc.signal_name ) )
945 signalOpcIds.insert(
"@@@O" + std::to_string( opc.id ) );
949 for(
auto& [sheetNum, ctx] : sheetContexts )
951 std::vector<PADS_SCH::SCH_SIGNAL> sheetSignals = parser.
GetSignalsOnSheet( sheetNum );
962 for(
size_t v = 0; v + 1 < wire.
vertices.size(); v++ )
979 ctx.screen->Append( line );
993 if( wire.
endpoint_a.find(
'.' ) != std::string::npos
994 && wire.
endpoint_a.find(
"@@@" ) == std::string::npos )
997 std::string ref = wire.
endpoint_a.substr( 0, dotPos );
999 if( connectorBaseRefs.count( ref ) )
1001 const auto& vtx = wire.
vertices.front();
1007 const auto& adj = wire.
vertices[1];
1012 int dx = adjPos.
x - pos.
x;
1013 int dy = adjPos.
y - pos.
y;
1021 wxString labelText = wxString::FromUTF8( wire.
endpoint_a );
1027 ctx.screen->Append( label );
1032 if( wire.
endpoint_b.find(
'.' ) != std::string::npos
1033 && wire.
endpoint_b.find(
"@@@" ) == std::string::npos )
1036 std::string ref = wire.
endpoint_b.substr( 0, dotPos );
1038 if( connectorBaseRefs.count( ref ) )
1040 const auto& vtx = wire.
vertices.back();
1046 size_t lastIdx = wire.
vertices.size() - 1;
1047 const auto& adj = wire.
vertices[lastIdx - 1];
1052 int dx = adjPos.
x - pos.
x;
1053 int dy = adjPos.
y - pos.
y;
1061 wxString labelText = wxString::FromUTF8( wire.
endpoint_b );
1067 ctx.screen->Append( label );
1076 if( dot.sheet_number != sheetNum )
1083 ctx.screen->Append( junction );
1096 if( opc.source_sheet != sheetNum )
1099 if( opc.signal_name.empty() )
1107 std::string powerStyle;
1108 auto opcPtIt = parser.
GetPartTypes().find( opc.symbol_lib );
1111 && !opcPtIt->second.special_keyword.empty() && opcPtIt->second.special_keyword !=
"OFF"
1112 && !opcPtIt->second.special_variants.empty() )
1114 int idx = std::max( 0, opc.flags2 );
1115 idx = std::min( idx,
1117 opcPtIt->second.special_variants.size() ) - 1 );
1118 const auto& variant = opcPtIt->second.special_variants[idx];
1121 variant.decal_name, variant.pin_type );
1124 if( !powerStyle.empty() )
1130 auto symbolPtr = std::make_unique<SCH_SYMBOL>();
1143 bool pinUp = ( powerStyle ==
"VCC" || powerStyle ==
"PWR_TRIANGLE" );
1145 std::to_string( opc.id ), sheetSignals, pos, pinUp,
1150 wxString netName = wxString::FromUTF8( opc.signal_name );
1152 if( netName.StartsWith( wxT(
"/" ) ) )
1153 netName = wxT(
"~{" ) + netName.Mid( 1 ) + wxT(
"}" );
1158 wxString pwrRef = wxString::Format( wxT(
"#PWR%03d" ), pwrIndex++ );
1159 symbol->
SetRef( &ctx.path, pwrRef );
1163 ctx.screen->Append( symbolPtr.release() );
1175 if( !sheetContexts.empty() )
1177 SCH_SCREEN* textScreen = sheetContexts.begin()->second.screen;
1181 if( textItem.content.empty() )
1193 if( !sheetContexts.empty() )
1195 SCH_SCREEN* linesScreen = sheetContexts.begin()->second.screen;
1202 double ox = linesItem.origin.x;
1203 double oy = linesItem.origin.y;
1232 && prim.
points.size() == 2 )
1253 linesScreen->
Append( rect );
1255 else if( prim.
points.size() >= 2 )
1257 for(
size_t p = 0; p + 1 < prim.
points.size(); p++ )
1275 if( prim.
points[p].arc.has_value() )
1285 double sx = start.
x -
center.x;
1286 double sy = start.
y -
center.y;
1289 double radius = std::sqrt( sx * sx + sy * sy );
1291 double mx = sx + ex;
1292 double my = sy + ey;
1293 double mlen = std::sqrt( mx * mx + my * my );
1300 +
static_cast<int>(
radius * mx / mlen );
1302 +
static_cast<int>(
radius * my / mlen );
1307 +
static_cast<int>( -sy *
radius
1308 / std::max(
radius, 1.0 ) );
1310 +
static_cast<int>( sx *
radius
1311 / std::max(
radius, 1.0 ) );
1327 linesScreen->
Append( arc );
1335 linesScreen->
Append( line );
1344 if( textItem.
content.empty() )
1378 const wxString& aLibraryPath,
1379 const std::map<std::string, UTF8>* aProperties )
1383 bool powerSymbolsOnly = aProperties
1388 if( powerSymbolsOnly && !symbol->IsPower() )
1391 aSymbolNameList.Add(
name );
1397 const wxString& aLibraryPath,
1398 const std::map<std::string, UTF8>* aProperties )
1402 bool powerSymbolsOnly = aProperties
1407 if( powerSymbolsOnly && !symbol->IsPower() )
1410 aSymbolList.push_back( symbol.get() );
1416 const std::map<std::string, UTF8>* aProperties )
1423 return it->second.get();
1431 wxFileName fn( aLibraryPath );
1433 if( fn.IsFileReadable() && fn.GetModificationTime().IsValid() )
1434 return fn.GetModificationTime().GetValue().GetValue();
1457 THROW_IO_ERROR( wxString::Format(
_(
"'%s' is not a PADS Logic ASCII file." ),
1464 std::string filename( aLibraryPath.ToUTF8() );
1466 if( !parser.
Parse( filename ) )
1469 wxString::Format(
_(
"Failed to parse PADS Logic file '%s'." ), aLibraryPath ) );
1475 std::set<std::string> referencedDecals;
1480 for(
const auto& [ptName, ptDef] : parser.
GetPartTypes() )
1482 if( !ptDef.special_keyword.empty() && ptDef.special_keyword !=
"OFF" )
1486 wxString libName = wxString::FromUTF8( ptDef.name );
1488 if( ptDef.gates.size() > 1 )
1494 for(
const std::string& decalName : gate.
decal_names )
1495 referencedDecals.insert( decalName );
1498 else if( !ptDef.gates.empty() )
1501 std::string decalName;
1508 if( symDef && ptDef.is_connector && !gate.
pins.empty() )
1513 std::vector<std::string> pinNumbers;
1514 pinNumbers.reserve( gate.
pins.size() );
1517 pinNumbers.push_back(
pin.pin_id );
1520 referencedDecals.insert( decalName );
1531 referencedDecals.insert( decalName );
1540 if( !ptDef.sigpins.empty() )
1550 if( referencedDecals.count( symDef.name ) )
1553 wxString libName = wxString::FromUTF8( symDef.name );
1574 std::ifstream file( aFileName.fn_str() );
1576 if( !file.is_open() )
1581 if( std::getline( file, line ) )
1583 if( line.find(
"*PADS-POWERLOGIC" ) != std::string::npos )
1586 if( line.find(
"*PADS-LOGIC" ) != std::string::npos )
constexpr EDA_IU_SCALE schIUScale
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
void SetFlags(EDA_ITEM_FLAGS aMask)
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
void SetEnd(const VECTOR2I &aEnd)
void SetArcGeometry(const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd)
Set the three controlling points for an arc.
void SetFillMode(FILL_T aFill)
void SetTextSize(VECTOR2I aNewSize, bool aEnforceMinTextSize=true)
void SetVertJustify(GR_TEXT_V_ALIGN_T aType)
virtual void SetVisible(bool aVisible)
void SetTextThickness(int aWidth)
The TextThickness is that set by the user.
void SetTextAngleDegrees(double aOrientation)
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
REPORTER * m_reporter
Reporter to log errors/warnings to, may be nullptr.
PROGRESS_REPORTER * m_progressReporter
Progress reporter to track the progress of the operation, may be nullptr.
virtual bool CanReadLibrary(const wxString &aFileName) const
Checks if this IO object can read the specified library file/directory.
A logical library item identifier and consists of various portions much like a URI.
int SetLibItemName(const UTF8 &aLibItemName)
Override the library item name portion of the LIB_ID to aLibItemName.
int SetLibNickname(const UTF8 &aLibNickname)
Override the logical library name portion of the LIB_ID to aLibNickname.
Define a library symbol object.
virtual void SetName(const wxString &aName)
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Parser for PADS Logic schematic design export files.
const std::vector< TEXT_ITEM > & GetTextItems() const
const std::vector< TIED_DOT > & GetTiedDots() const
const std::vector< OFF_PAGE_CONNECTOR > & GetOffPageConnectors() const
bool Parse(const std::string &aFileName)
const std::vector< SHEET_HEADER > & GetSheetHeaders() const
const std::vector< LINES_ITEM > & GetLinesItems() const
std::vector< SCH_SIGNAL > GetSignalsOnSheet(int aSheetNumber) const
std::set< int > GetSheetNumbers() const
const std::vector< SYMBOL_DEF > & GetSymbolDefs() const
const std::vector< PART_PLACEMENT > & GetPartPlacements() const
const std::map< std::string, PARTTYPE_DEF > & GetPartTypes() const
std::vector< PART_PLACEMENT > GetPartsOnSheet(int aSheetNumber) const
const SYMBOL_DEF * GetSymbolDef(const std::string &aName) const
const PARAMETERS & GetParameters() const
Builder class to create KiCad schematic elements from parsed PADS data.
int CreateNetLabels(const std::vector< SCH_SIGNAL > &aSignals, SCH_SCREEN *aScreen, const std::set< std::string > &aSignalOpcIds, const std::set< std::string > &aSkipSignals={})
Create net labels for named signals.
void ApplyPartAttributes(SCH_SYMBOL *aSymbol, const PART_PLACEMENT &aPlacement)
Apply part attributes to a symbol instance.
void CreateTitleBlock(SCH_SCREEN *aScreen)
Create title block from parsed PADS parameters.
int CreateCustomFields(SCH_SYMBOL *aSymbol, const PART_PLACEMENT &aPlacement)
Create custom fields from non-standard PADS attributes.
SCH_SHEET * CreateHierarchicalSheet(int aSheetNumber, int aTotalSheets, SCH_SHEET *aParentSheet, const wxString &aBaseFilename)
Create hierarchical sheet for a sub-schematic page.
Builder class to convert PADS symbol definitions to KiCad LIB_SYMBOL objects.
LIB_SYMBOL * BuildMultiUnitSymbol(const PARTTYPE_DEF &aPartType, const std::vector< SYMBOL_DEF > &aSymbolDefs)
Build a composite multi-unit LIB_SYMBOL from a multi-gate PARTTYPE.
void AddHiddenPowerPins(LIB_SYMBOL *aSymbol, const std::vector< PARTTYPE_DEF::SIGPIN > &aSigpins)
Add hidden power pins from PARTTYPE SIGPIN entries to an existing symbol.
LIB_SYMBOL * GetOrCreateMultiUnitSymbol(const PARTTYPE_DEF &aPartType, const std::vector< SYMBOL_DEF > &aSymbolDefs)
Get or create a multi-unit symbol for the given PARTTYPE.
static std::optional< LIB_ID > GetKiCadPowerSymbolId(const std::string &aPadsName)
Get KiCad power library symbol ID for a PADS power symbol.
LIB_SYMBOL * BuildKiCadPowerSymbol(const std::string &aKiCadName)
Build a power symbol using hard-coded KiCad-standard graphics.
static bool IsPowerSymbol(const std::string &aName)
Check if a symbol name indicates a power symbol.
static std::string GetPowerStyleFromVariant(const std::string &aDecalName, const std::string &aPinType)
Map a PADS special_variant to a power symbol style name.
LIB_SYMBOL * GetOrCreateSymbol(const SYMBOL_DEF &aSymbolDef)
Get or create a symbol for the given definition.
LIB_SYMBOL * GetOrCreateMultiUnitConnectorSymbol(const PARTTYPE_DEF &aPartType, const SYMBOL_DEF &aSymbolDef, const std::vector< std::string > &aPinNumbers, const std::string &aCacheKey)
Get or create a multi-unit connector symbol, cached by base reference.
LIB_SYMBOL * BuildMultiUnitConnectorSymbol(const PARTTYPE_DEF &aPartType, const SYMBOL_DEF &aSymbolDef, const std::vector< std::string > &aPinNumbers)
Build a multi-unit connector symbol where each unit represents one pin.
LIB_SYMBOL * BuildSymbol(const SYMBOL_DEF &aSymbolDef)
Build a KiCad LIB_SYMBOL from a PADS symbol definition.
LIB_SYMBOL * GetOrCreatePartTypeSymbol(const PARTTYPE_DEF &aPartType, const SYMBOL_DEF &aSymbolDef)
Get or create a single-gate symbol with PARTTYPE-specific pin remapping.
Describe the page size and margins of a paper page on which to eventually print or plot.
int GetHeightIU(double aIUScale) const
Gets the page height in IU.
bool SetType(PAGE_SIZE_TYPE aPageSize, bool aIsPortrait=false)
Set the name of the page type and also the sizes and margins commonly associated with that type name.
Holds all the data relating to one schematic.
SCHEMATIC_SETTINGS & Settings() const
bool IsValid() const
A simple test if the schematic is loaded, not a complete one.
void SetTopLevelSheets(const std::vector< SCH_SHEET * > &aSheets)
void SetPosition(const VECTOR2I &aPosition) override
void SetText(const wxString &aText) override
std::map< wxString, std::unique_ptr< LIB_SYMBOL > > m_librarySymbols
LIB_SYMBOL * LoadSymbol(const wxString &aLibraryPath, const wxString &aPartName, 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...
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.
long long getLibraryTimestamp(const wxString &aLibraryPath) const
bool CanReadLibrary(const wxString &aFileName) const override
Checks if this IO object can read the specified library file/directory.
bool checkFileHeader(const wxString &aFileName) const
Check if the file header indicates a PADS Logic schematic file.
void ensureLoadedLibrary(const wxString &aLibraryPath)
Parse the PADS Logic ASCII file and populate the library symbol cache.
wxString m_cachedLibraryPath
bool CanReadSchematicFile(const wxString &aFileName) const override
Checks if this SCH_IO can read the specified schematic file.
long long m_cachedLibraryTimestamp
std::unordered_map< wxString, SEVERITY > m_errorMessages
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,...
virtual bool CanReadSchematicFile(const wxString &aFileName) const
Checks if this SCH_IO can read the specified schematic file.
SCH_IO(const wxString &aName)
void SetConnectivityDirty(bool aDirty=true)
virtual void SetUnit(int aUnit)
virtual void SetSpinStyle(SPIN_STYLE aSpinStyle)
Segment description base class to describe items which have 2 end points (track, wire,...
virtual void SetStroke(const STROKE_PARAMS &aStroke) override
void SetEndPoint(const VECTOR2I &aPosition)
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
void UpdateSymbolLinks(REPORTER *aReporter=nullptr)
Initialize the LIB_SYMBOL reference for each SCH_SYMBOL found in the full schematic.
std::vector< SCH_SHEET_INSTANCE > m_sheetInstances
void Append(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
const KIID & GetUuid() const
void SetFileName(const wxString &aFileName)
Set the file name for this screen to aFileName.
void SetPosition(const VECTOR2I &aPos) override
void SetStroke(const STROKE_PARAMS &aStroke) override
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
KIID_PATH Path() const
Get the sheet path as an KIID_PATH.
void SetPageNumber(const wxString &aPageNumber)
Set the sheet instance user definable page number.
void push_back(SCH_SHEET *aSheet)
Forwarded method from std::vector.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
void SetFileName(const wxString &aFilename)
SCH_FIELD * GetField(FIELD_T aFieldType)
Return a mandatory field in 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)
void SetPosition(const VECTOR2I &aPosition) override
std::vector< const SCH_PIN * > GetPins(const SCH_SHEET_PATH *aSheet) const
Retrieve a list of the SCH_PINs for the given sheet path.
void SetRef(const SCH_SHEET_PATH *aSheet, const wxString &aReference)
Set the reference for the given sheet path for this symbol.
void SetOrientation(int aOrientation)
Compute the new transform matrix based on aOrientation for the symbol which is applied to the current...
void AddHierarchicalReference(const KIID_PATH &aPath, const wxString &aRef, int aUnit)
Add a full hierarchical reference to this symbol.
VECTOR2I GetPosition() const override
void SetValueFieldText(const wxString &aValue, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString)
void SetLibSymbol(LIB_SYMBOL *aLibSymbol)
Set this schematic symbol library symbol reference to aLibSymbol.
SCH_FIELD * GetField(FIELD_T aFieldType)
Return a mandatory field in this symbol.
Simple container to manage line stroke parameters.
static const char * PropPowerSymsOnly
#define IS_NEW
New item, just created.
@ RECTANGLE
Use RECTANGLE instead of RECT to avoid collision in a Windows header.
@ FILLED_SHAPE
Fill with object color.
double m_PadsSchTextWidthScale
PADS text width scale factor for schematic imports.
double m_PadsSchTextHeightScale
PADS text height scale factor for schematic imports.
#define THROW_IO_ERROR(msg)
macro which captures the "call site" values of FILE_, __FUNCTION & LINE
LINE_STYLE PadsLineStyleToKiCad(int aPadsStyle)
Convert a PADS line style integer to a KiCad LINE_STYLE enum value.
KIID GenerateDeterministicUuid(const std::string &aIdentifier)
Generate a deterministic KIID from a PADS component identifier.
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
Common utilities and types for parsing PADS file formats.
static int computePowerOrientation(const std::string &aOpcId, const std::vector< PADS_SCH::SCH_SIGNAL > &aSignals, const VECTOR2I &aOpcPos, bool aPinUp, int aPageHeightIU)
Determine the orientation for a power symbol at an OPC position based on the wire direction at that p...
static std::string extractConnectorBaseRef(const std::string &aRef)
Extract the base reference from a connector reference designator.
static SCH_TEXT * createSchText(const PADS_SCH::TEXT_ITEM &aText, const VECTOR2I &aPos)
static std::string extractConnectorPinNumber(const std::string &aRef)
Extract the numeric connector pin suffix from a reference designator.
static std::string stripGateSuffix(const std::string &aRef)
Strip any alphabetic gate suffix (e.g.
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
LINE_STYLE
Dashed line types.
Gate definition within a PARTTYPE.
std::vector< std::string > decal_names
std::vector< PARTTYPE_PIN > pins
Graphical line/shape item from LINES section.
Off-page reference from OFFPAGE REFS section.
General schematic parameters from SCH and FIELDS sections.
std::string border_template
Part type definition from PARTTYPE section.
std::vector< GATE_DEF > gates
std::vector< SPECIAL_VARIANT > special_variants
std::string special_keyword
Pin definition within a PARTTYPE GATE.
Part instance from PART section.
Signal (net) definition from CONNECTION and SIGNAL sections.
Symbol definition from CAEDECAL section.
Graphic primitive from CAEDECAL or LINES sections (OPEN, CLOSED, CIRCLE, COPCLS).
std::vector< GRAPHIC_POINT > points
Free text item from TEXT section.
Junction dot from TIEDOTS section.
Wire segment connecting two endpoints through coordinate vertices.
std::vector< POINT > vertices
A simple container for sheet instance information.
@ REFERENCE
Field Reference of part, i.e. "IC21".
@ VALUE
Field Value of part, i.e. "3.3K".
SHAPE_CIRCLE circle(c.m_circle_center, c.m_circle_radius)
VECTOR2< int32_t > VECTOR2I
Definition of file extensions used in Kicad.