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
162 const std::vector<PADS_SCH::SCH_SIGNAL>& aSignals,
163 const VECTOR2I& aOpcPos,
bool aPinUp,
int aPageHeightIU )
166 std::string opcRef =
"@@@O" + aOpcId;
170 for(
const auto& signal : aSignals )
172 for(
const auto& wire : signal.wires )
174 if( wire.vertices.size() < 2 )
177 if( wire.endpoint_a == opcRef )
187 if( wire.endpoint_b == opcRef )
189 size_t last = wire.vertices.size() - 1;
194 KiROUND( wire.vertices[last - 1].y ) ) );
208 int dx = adjPos.
x - aOpcPos.
x;
209 int dy = adjPos.
y - aOpcPos.
y;
281 const std::map<std::string, UTF8>* aProperties )
283 wxCHECK( !aFileName.IsEmpty() && aSchematic,
nullptr );
291 wxCHECK_MSG( aSchematic->
IsValid(),
nullptr,
"Can't append to a schematic with no root!" );
292 rootSheet = aAppendToMe;
314 wxCHECK( rootScreen,
nullptr );
325 std::string filename( aFileName.ToUTF8() );
327 if( !parser.
Parse( filename ) )
340 const std::string& ref = part.reference;
341 size_t dashPos = ref.rfind(
'-' );
342 size_t dotPos = ref.rfind(
'.' );
343 size_t sepPos = std::string::npos;
345 if( dashPos != std::string::npos )
347 else if( dotPos != std::string::npos )
350 if( sepPos != std::string::npos && sepPos + 1 < ref.size()
351 && std::isalpha(
static_cast<unsigned char>( ref[sepPos + 1] ) ) )
376 if( sheetNumbers.empty() )
377 sheetNumbers.insert( 1 );
379 bool isSingleSheet = ( sheetNumbers.size() == 1 );
389 std::map<int, SheetContext> sheetContexts;
393 int sheetNum = *sheetNumbers.begin();
395 ctx.sheet = rootSheet;
396 ctx.screen = rootScreen;
398 ctx.screen->SetPageSettings( pageInfo );
399 sheetContexts[sheetNum] = ctx;
404 int totalSheets =
static_cast<int>( sheetNumbers.size() );
406 for(
int sheetNum : sheetNumbers )
409 sheetNum, totalSheets, rootSheet, aFileName );
417 if( hdr.sheet_num == sheetNum && !hdr.sheet_name.empty() )
420 wxString::FromUTF8( hdr.sheet_name ) );
430 wxString pageNo = wxString::Format( wxT(
"%d" ), sheetNum );
439 ctx.sheet = subSheet;
442 ctx.screen->SetPageSettings( pageInfo );
443 sheetContexts[sheetNum] = ctx;
451 std::set<std::string> connectorBaseRefs;
455 struct ConnectorGroup
457 std::vector<std::string> pinNumbers;
458 std::map<std::string, int> pinToUnit;
459 std::string partType;
462 std::map<std::string, ConnectorGroup> connectorGroups;
464 for(
const auto& [sheetNum, ctx] : sheetContexts )
466 std::vector<PADS_SCH::PART_PLACEMENT> sheetParts = parser.
GetPartsOnSheet( sheetNum );
470 auto ptIt = parser.
GetPartTypes().find( part.part_type );
472 if( ptIt == parser.
GetPartTypes().end() || !ptIt->second.is_connector )
481 ConnectorGroup&
group = connectorGroups[baseRef];
482 group.partType = part.part_type;
483 group.pinNumbers.push_back( pinNum );
487 for(
auto& [baseRef,
group] : connectorGroups )
489 std::sort(
group.pinNumbers.begin(),
group.pinNumbers.end(),
490 [](
const std::string& a,
const std::string& b )
492 return std::stoi( a ) < std::stoi( b );
495 for(
size_t i = 0; i <
group.pinNumbers.size(); i++ )
496 group.pinToUnit[
group.pinNumbers[i]] =
static_cast<int>( i + 1 );
500 for(
auto& [sheetNum, ctx] : sheetContexts )
502 std::vector<PADS_SCH::PART_PLACEMENT> parts = parser.
GetPartsOnSheet( sheetNum );
506 auto ptIt = parser.
GetPartTypes().find( part.part_type );
509 bool isMultiGate =
false;
510 bool isConnector =
false;
511 bool isPower =
false;
512 std::string libItemName;
513 std::string connectorPinNumber;
519 if( ptDef.
gates.size() > 1 )
524 libItemName = ptDef.
name;
527 else if( !ptDef.
gates.empty() )
530 int idx = std::max( 0, part.gate_index );
531 std::string decalName;
533 if( idx <
static_cast<int>( gate.
decal_names.size() ) )
544 if( symDef && !connectorPinNumber.empty() )
549 auto groupIt = connectorGroups.find( baseRef );
551 if( groupIt != connectorGroups.end() )
553 std::string cacheKey = ptDef.
name +
":conn:" + baseRef;
556 ptDef, *symDef, groupIt->second.pinNumbers, cacheKey );
557 libItemName = ptDef.
name +
"_" + baseRef;
561 connectorBaseRefs.insert( baseRef );
567 libItemName = decalName;
573 int idx = std::max( 0, part.gate_index );
574 idx = std::min( idx,
static_cast<int>( ptDef.
special_variants.size() ) - 1 );
582 libItemName = decalName;
598 wxString::Format( wxT(
"PADS Import: symbol '%s' not found,"
599 " part '%s' skipped" ),
600 wxString::FromUTF8( part.symbol_name ),
601 wxString::FromUTF8( part.reference ) ),
607 libItemName = symDef->
name;
613 if( ptIt != parser.
GetPartTypes().end() && !ptIt->second.sigpins.empty() )
622 std::string powerStyle;
625 && !ptIt->second.special_variants.empty() )
627 int varIdx = std::max( 0, part.gate_index );
630 static_cast<int>( ptIt->second.special_variants.size() ) - 1 );
631 const auto& variant = ptIt->second.special_variants[varIdx];
634 variant.decal_name, variant.pin_type );
637 if( isPower && powerStyle.empty() )
639 std::string rawNetName = part.power_net_name.empty()
641 : part.power_net_name;
647 powerStyle = std::string( powerLibId->GetLibItemName().c_str() );
650 auto symbolPtr = std::make_unique<SCH_SYMBOL>();
654 if( isPower && !powerStyle.empty() )
670 instanceSymbol =
new LIB_SYMBOL( *libSymbol );
683 if( part.rotation == 90.0 )
685 else if( part.rotation == 180.0 )
687 else if( part.rotation == 270.0 )
690 if( part.mirror_flags & 1 )
693 if( part.mirror_flags & 2 )
698 if( isConnector && !connectorPinNumber.empty() )
701 auto groupIt = connectorGroups.find( baseRef );
703 if( groupIt != connectorGroups.end() )
705 auto unitIt = groupIt->second.pinToUnit.find( connectorPinNumber );
707 if( unitIt != groupIt->second.pinToUnit.end() )
708 symbol->
SetUnit( unitIt->second );
717 else if( isMultiGate )
719 symbol->
SetUnit( part.gate_index + 1 );
730 bool isPrimaryUnit = isConnector
732 : ( !isMultiGate || part.gate_index == 0 );
734 if( !isPower && isPrimaryUnit )
736 std::string baseRef = isConnector
744 symbol->
SetRef( &ctx.path, wxString::FromUTF8( part.reference ) );
754 symbol->
SetRef( &ctx.path, wxString::FromUTF8( baseRef ) );
759 if( isMultiGate && !isConnector )
762 symbol->
SetRef( &ctx.path, wxString::FromUTF8( baseRef ) );
770 const std::string& cat = ptIt->second.category;
772 if( cat ==
"CAP" || cat ==
"RES" || cat ==
"IND" )
774 auto valIt = part.attr_overrides.find(
"VALUE" );
776 if( valIt == part.attr_overrides.end() )
777 valIt = part.attr_overrides.find(
"VALUE1" );
779 if( valIt != part.attr_overrides.end() && !valIt->second.empty() )
783 for(
const auto& attr : part.attributes )
785 if( attr.name ==
"VALUE" || attr.name ==
"VALUE1"
786 || attr.name ==
"Value1" )
791 if( part.mirror_flags & 1 )
796 KiROUND( attr.position.y ) ) );
799 int fieldTextSize =
schIUScale.MilsToIU( 50 );
801 VECTOR2I( fieldTextSize, fieldTextSize ) );
809 hJustify, vJustify );
811 if( part.mirror_flags & 1 )
827 wxString netName = part.power_net_name.empty()
828 ? wxString::FromUTF8( part.symbol_name )
829 : wxString::FromUTF8( part.power_net_name );
831 if( netName.StartsWith( wxT(
"/" ) ) )
832 netName = wxT(
"~{" ) + netName.Mid( 1 ) + wxT(
"}" );
843 else if( isMultiGate )
846 hierRef = part.reference;
849 wxString::FromUTF8( hierRef ),
858 if( isConnector && !connectorPinNumber.empty() )
861 wxString labelText = wxString::Format( wxT(
"%s.%s" ),
862 wxString::FromUTF8( baseRef ),
863 wxString::FromUTF8( connectorPinNumber ) );
866 std::vector<SCH_PIN*> pins = symbol->
GetPins();
869 pinPos = pins[0]->GetPosition();
876 ctx.screen->Append( label );
879 ctx.screen->Append( symbolPtr.release() );
886 std::set<std::string> powerSignalNames;
890 if( opc.signal_name.empty() )
893 auto ptIt = parser.
GetPartTypes().find( opc.symbol_lib );
896 && !ptIt->second.special_keyword.empty() && ptIt->second.special_keyword !=
"OFF"
897 && !ptIt->second.special_variants.empty() )
899 int idx = std::max( 0, opc.flags2 );
901 static_cast<int>( ptIt->second.special_variants.size() ) - 1 );
902 const auto& variant = ptIt->second.special_variants[idx];
905 variant.decal_name, variant.pin_type ).empty() )
907 powerSignalNames.insert( opc.signal_name );
915 std::set<std::string> signalOpcIds;
919 if( opc.signal_name.empty() || powerSignalNames.count( opc.signal_name ) )
922 signalOpcIds.insert(
"@@@O" + std::to_string( opc.id ) );
927 std::map<std::string, PADS_SCH::NETNAME_LABEL> netNameLabels;
931 if( !nn.anchor_ref.empty() )
932 netNameLabels[nn.anchor_ref] = nn;
936 for(
auto& [sheetNum, ctx] : sheetContexts )
938 std::vector<PADS_SCH::SCH_SIGNAL> sheetSignals = parser.
GetSignalsOnSheet( sheetNum );
949 for(
size_t v = 0; v + 1 < wire.
vertices.size(); v++ )
966 ctx.screen->Append( line );
980 if( wire.
endpoint_a.find(
'.' ) != std::string::npos
981 && wire.
endpoint_a.find(
"@@@" ) == std::string::npos )
984 std::string ref = wire.
endpoint_a.substr( 0, dotPos );
986 if( connectorBaseRefs.count( ref ) )
988 const auto& vtx = wire.
vertices.front();
999 int dx = adjPos.
x - pos.
x;
1000 int dy = adjPos.
y - pos.
y;
1008 wxString labelText = wxString::FromUTF8( wire.
endpoint_a );
1014 ctx.screen->Append( label );
1019 if( wire.
endpoint_b.find(
'.' ) != std::string::npos
1020 && wire.
endpoint_b.find(
"@@@" ) == std::string::npos )
1023 std::string ref = wire.
endpoint_b.substr( 0, dotPos );
1025 if( connectorBaseRefs.count( ref ) )
1027 const auto& vtx = wire.
vertices.back();
1033 size_t lastIdx = wire.
vertices.size() - 1;
1034 const auto& adj = wire.
vertices[lastIdx - 1];
1039 int dx = adjPos.
x - pos.
x;
1040 int dy = adjPos.
y - pos.
y;
1048 wxString labelText = wxString::FromUTF8( wire.
endpoint_b );
1054 ctx.screen->Append( label );
1063 if( dot.sheet_number != sheetNum )
1070 ctx.screen->Append( junction );
1075 powerSignalNames, netNameLabels );
1083 if( opc.source_sheet != sheetNum )
1086 if( opc.signal_name.empty() )
1094 std::string powerStyle;
1095 auto opcPtIt = parser.
GetPartTypes().find( opc.symbol_lib );
1098 && !opcPtIt->second.special_keyword.empty() && opcPtIt->second.special_keyword !=
"OFF"
1099 && !opcPtIt->second.special_variants.empty() )
1101 int idx = std::max( 0, opc.flags2 );
1102 idx = std::min( idx,
1104 opcPtIt->second.special_variants.size() ) - 1 );
1105 const auto& variant = opcPtIt->second.special_variants[idx];
1108 variant.decal_name, variant.pin_type );
1111 if( !powerStyle.empty() )
1117 auto symbolPtr = std::make_unique<SCH_SYMBOL>();
1130 bool pinUp = ( powerStyle ==
"VCC" || powerStyle ==
"PWR_TRIANGLE" );
1132 std::to_string( opc.id ), sheetSignals, pos, pinUp,
1137 wxString netName = wxString::FromUTF8( opc.signal_name );
1139 if( netName.StartsWith( wxT(
"/" ) ) )
1140 netName = wxT(
"~{" ) + netName.Mid( 1 ) + wxT(
"}" );
1145 wxString pwrRef = wxString::Format( wxT(
"#PWR%03d" ), pwrIndex++ );
1146 symbol->
SetRef( &ctx.path, pwrRef );
1150 ctx.screen->Append( symbolPtr.release() );
1165 auto screenForSheet =
1168 auto ctxIt = sheetContexts.find( aSheetNumber );
1170 return ctxIt != sheetContexts.end() ? ctxIt->second.screen
1171 : sheetContexts.begin()->second.screen;
1175 if( !sheetContexts.empty() )
1179 if( textItem.content.empty() )
1182 SCH_SCREEN* textScreen = screenForSheet( textItem.sheet_number );
1194 if( !sheetContexts.empty() )
1201 SCH_SCREEN* linesScreen = screenForSheet( linesItem.sheet_number );
1203 double ox = linesItem.origin.x;
1204 double oy = linesItem.origin.y;
1233 && prim.
points.size() == 2 )
1254 linesScreen->
Append( rect );
1256 else if( prim.
points.size() >= 2 )
1258 for(
size_t p = 0; p + 1 < prim.
points.size(); p++ )
1276 if( prim.
points[p].arc.has_value() )
1286 double sx = start.
x -
center.x;
1287 double sy = start.
y -
center.y;
1290 double radius = std::sqrt( sx * sx + sy * sy );
1292 double mx = sx + ex;
1293 double my = sy + ey;
1294 double mlen = std::sqrt( mx * mx + my * my );
1301 +
static_cast<int>(
radius * mx / mlen );
1303 +
static_cast<int>(
radius * my / mlen );
1308 +
static_cast<int>( -sy *
radius
1309 / std::max(
radius, 1.0 ) );
1311 +
static_cast<int>( sx *
radius
1312 / std::max(
radius, 1.0 ) );
1328 linesScreen->
Append( arc );
1336 linesScreen->
Append( line );
1345 if( textItem.
content.empty() )
1379 const wxString& aLibraryPath,
1380 const std::map<std::string, UTF8>* aProperties )
1384 bool powerSymbolsOnly = aProperties
1389 if( powerSymbolsOnly && !symbol->IsPower() )
1392 aSymbolNameList.Add(
name );
1398 const wxString& aLibraryPath,
1399 const std::map<std::string, UTF8>* aProperties )
1403 bool powerSymbolsOnly = aProperties
1408 if( powerSymbolsOnly && !symbol->IsPower() )
1411 aSymbolList.push_back( symbol.get() );
1417 const std::map<std::string, UTF8>* aProperties )
1424 return it->second.get();
1432 wxFileName fn( aLibraryPath );
1434 if( fn.IsFileReadable() && fn.GetModificationTime().IsValid() )
1435 return fn.GetModificationTime().GetValue().GetValue();
1457 THROW_IO_ERRORF(
_(
"'%s' is not a PADS Logic ASCII file." ), aLibraryPath );
1462 std::string filename( aLibraryPath.ToUTF8() );
1464 if( !parser.
Parse( filename ) )
1465 THROW_IO_ERRORF(
_(
"Failed to parse PADS Logic file '%s'." ), aLibraryPath );
1470 std::set<std::string> referencedDecals;
1475 for(
const auto& [ptName, ptDef] : parser.
GetPartTypes() )
1477 if( !ptDef.special_keyword.empty() && ptDef.special_keyword !=
"OFF" )
1481 wxString libName = wxString::FromUTF8( ptDef.name );
1483 if( ptDef.gates.size() > 1 )
1489 for(
const std::string& decalName : gate.
decal_names )
1490 referencedDecals.insert( decalName );
1493 else if( !ptDef.gates.empty() )
1496 std::string decalName;
1503 if( symDef && ptDef.is_connector && !gate.
pins.empty() )
1508 std::vector<std::string> pinNumbers;
1509 pinNumbers.reserve( gate.
pins.size() );
1512 pinNumbers.push_back(
pin.pin_id );
1515 referencedDecals.insert( decalName );
1526 referencedDecals.insert( decalName );
1535 if( !ptDef.sigpins.empty() )
1545 if( referencedDecals.count( symDef.name ) )
1548 wxString libName = wxString::FromUTF8( symDef.name );
1569 std::ifstream file( aFileName.fn_str() );
1571 if( !file.is_open() )
1576 if( std::getline( file, line ) )
1578 if( line.find(
"*PADS-POWERLOGIC" ) != std::string::npos )
1581 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)
virtual 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)
virtual void SetTextSize(VECTOR2I aNewSize, bool aEnforceMinTextSize=true)
void SetVertJustify(GR_TEXT_V_ALIGN_T aType)
virtual void SetVisible(bool aVisible)
virtual 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< NETNAME_LABEL > & GetNetNameLabels() 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.
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.
int CreateNetLabels(const std::vector< SCH_SIGNAL > &aSignals, SCH_SCREEN *aScreen, const std::set< std::string > &aSignalOpcIds, const std::set< std::string > &aSkipSignals={}, const std::map< std::string, NETNAME_LABEL > &aNetNameLabels={})
Create net labels for named signals.
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_ERRORF(msg,...)
void DecodeJustification(int aJustification, GR_TEXT_H_ALIGN_T &aHJustify, GR_TEXT_V_ALIGN_T &aVJustify)
Decode a PADS text justification code into KiCad horizontal and vertical alignment.
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.
Net name label from NETNAMES 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)
GR_TEXT_H_ALIGN_T
This is API surface mapped to common.types.HorizontalAlignment.
GR_TEXT_V_ALIGN_T
This is API surface mapped to common.types.VertialAlignment.
constexpr GR_TEXT_H_ALIGN_T GetFlippedAlignment(GR_TEXT_H_ALIGN_T aAlign)
Get the reverse alignment: left-right are swapped, others are unchanged.
VECTOR2< int32_t > VECTOR2I
Definition of file extensions used in Kicad.