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 ) )
329 THROW_IO_ERROR( wxString::Format( wxT(
"Failed to parse PADS file: %s" ), aFileName ) );
342 const std::string& ref = part.reference;
343 size_t dashPos = ref.rfind(
'-' );
344 size_t dotPos = ref.rfind(
'.' );
345 size_t sepPos = std::string::npos;
347 if( dashPos != std::string::npos )
349 else if( dotPos != std::string::npos )
352 if( sepPos != std::string::npos && sepPos + 1 < ref.size()
353 && std::isalpha(
static_cast<unsigned char>( ref[sepPos + 1] ) ) )
378 if( sheetNumbers.empty() )
379 sheetNumbers.insert( 1 );
381 bool isSingleSheet = ( sheetNumbers.size() == 1 );
391 std::map<int, SheetContext> sheetContexts;
395 int sheetNum = *sheetNumbers.begin();
397 ctx.sheet = rootSheet;
398 ctx.screen = rootScreen;
400 ctx.screen->SetPageSettings( pageInfo );
401 sheetContexts[sheetNum] = ctx;
406 int totalSheets =
static_cast<int>( sheetNumbers.size() );
408 for(
int sheetNum : sheetNumbers )
411 sheetNum, totalSheets, rootSheet, aFileName );
419 if( hdr.sheet_num == sheetNum && !hdr.sheet_name.empty() )
422 wxString::FromUTF8( hdr.sheet_name ) );
432 wxString pageNo = wxString::Format( wxT(
"%d" ), sheetNum );
441 ctx.sheet = subSheet;
444 ctx.screen->SetPageSettings( pageInfo );
445 sheetContexts[sheetNum] = ctx;
453 std::set<std::string> connectorBaseRefs;
457 struct ConnectorGroup
459 std::vector<std::string> pinNumbers;
460 std::map<std::string, int> pinToUnit;
461 std::string partType;
464 std::map<std::string, ConnectorGroup> connectorGroups;
466 for(
const auto& [sheetNum, ctx] : sheetContexts )
468 std::vector<PADS_SCH::PART_PLACEMENT> sheetParts = parser.
GetPartsOnSheet( sheetNum );
472 auto ptIt = parser.
GetPartTypes().find( part.part_type );
474 if( ptIt == parser.
GetPartTypes().end() || !ptIt->second.is_connector )
483 ConnectorGroup&
group = connectorGroups[baseRef];
484 group.partType = part.part_type;
485 group.pinNumbers.push_back( pinNum );
489 for(
auto& [baseRef,
group] : connectorGroups )
491 std::sort(
group.pinNumbers.begin(),
group.pinNumbers.end(),
492 [](
const std::string& a,
const std::string& b )
494 return std::stoi( a ) < std::stoi( b );
497 for(
size_t i = 0; i <
group.pinNumbers.size(); i++ )
498 group.pinToUnit[
group.pinNumbers[i]] =
static_cast<int>( i + 1 );
502 for(
auto& [sheetNum, ctx] : sheetContexts )
504 std::vector<PADS_SCH::PART_PLACEMENT> parts = parser.
GetPartsOnSheet( sheetNum );
508 auto ptIt = parser.
GetPartTypes().find( part.part_type );
511 bool isMultiGate =
false;
512 bool isConnector =
false;
513 bool isPower =
false;
514 std::string libItemName;
515 std::string connectorPinNumber;
521 if( ptDef.
gates.size() > 1 )
526 libItemName = ptDef.
name;
529 else if( !ptDef.
gates.empty() )
532 int idx = std::max( 0, part.gate_index );
533 std::string decalName;
535 if( idx <
static_cast<int>( gate.
decal_names.size() ) )
546 if( symDef && !connectorPinNumber.empty() )
551 auto groupIt = connectorGroups.find( baseRef );
553 if( groupIt != connectorGroups.end() )
555 std::string cacheKey = ptDef.
name +
":conn:" + baseRef;
558 ptDef, *symDef, groupIt->second.pinNumbers, cacheKey );
559 libItemName = ptDef.
name +
"_" + baseRef;
563 connectorBaseRefs.insert( baseRef );
569 libItemName = decalName;
575 int idx = std::max( 0, part.gate_index );
576 idx = std::min( idx,
static_cast<int>( ptDef.
special_variants.size() ) - 1 );
584 libItemName = decalName;
600 wxString::Format( wxT(
"PADS Import: symbol '%s' not found,"
601 " part '%s' skipped" ),
602 wxString::FromUTF8( part.symbol_name ),
603 wxString::FromUTF8( part.reference ) ),
609 libItemName = symDef->
name;
615 if( ptIt != parser.
GetPartTypes().end() && !ptIt->second.sigpins.empty() )
624 std::string powerStyle;
627 && !ptIt->second.special_variants.empty() )
629 int varIdx = std::max( 0, part.gate_index );
632 static_cast<int>( ptIt->second.special_variants.size() ) - 1 );
633 const auto& variant = ptIt->second.special_variants[varIdx];
636 variant.decal_name, variant.pin_type );
639 if( isPower && powerStyle.empty() )
641 std::string rawNetName = part.power_net_name.empty()
643 : part.power_net_name;
649 powerStyle = std::string( powerLibId->GetLibItemName().c_str() );
652 auto symbolPtr = std::make_unique<SCH_SYMBOL>();
656 if( isPower && !powerStyle.empty() )
672 instanceSymbol =
new LIB_SYMBOL( *libSymbol );
685 if( part.rotation == 90.0 )
687 else if( part.rotation == 180.0 )
689 else if( part.rotation == 270.0 )
692 if( part.mirror_flags & 1 )
695 if( part.mirror_flags & 2 )
700 if( isConnector && !connectorPinNumber.empty() )
703 auto groupIt = connectorGroups.find( baseRef );
705 if( groupIt != connectorGroups.end() )
707 auto unitIt = groupIt->second.pinToUnit.find( connectorPinNumber );
709 if( unitIt != groupIt->second.pinToUnit.end() )
710 symbol->
SetUnit( unitIt->second );
719 else if( isMultiGate )
721 symbol->
SetUnit( part.gate_index + 1 );
732 bool isPrimaryUnit = isConnector
734 : ( !isMultiGate || part.gate_index == 0 );
736 if( !isPower && isPrimaryUnit )
738 std::string baseRef = isConnector
746 symbol->
SetRef( &ctx.path, wxString::FromUTF8( part.reference ) );
756 symbol->
SetRef( &ctx.path, wxString::FromUTF8( baseRef ) );
761 if( isMultiGate && !isConnector )
764 symbol->
SetRef( &ctx.path, wxString::FromUTF8( baseRef ) );
772 const std::string& cat = ptIt->second.category;
774 if( cat ==
"CAP" || cat ==
"RES" || cat ==
"IND" )
776 auto valIt = part.attr_overrides.find(
"VALUE" );
778 if( valIt == part.attr_overrides.end() )
779 valIt = part.attr_overrides.find(
"VALUE1" );
781 if( valIt != part.attr_overrides.end() && !valIt->second.empty() )
785 for(
const auto& attr : part.attributes )
787 if( attr.name ==
"VALUE" || attr.name ==
"VALUE1"
788 || attr.name ==
"Value1" )
793 if( part.mirror_flags & 1 )
798 KiROUND( attr.position.y ) ) );
801 int fieldTextSize =
schIUScale.MilsToIU( 50 );
803 VECTOR2I( fieldTextSize, fieldTextSize ) );
811 hJustify, vJustify );
813 if( part.mirror_flags & 1 )
829 wxString netName = part.power_net_name.empty()
830 ? wxString::FromUTF8( part.symbol_name )
831 : wxString::FromUTF8( part.power_net_name );
833 if( netName.StartsWith( wxT(
"/" ) ) )
834 netName = wxT(
"~{" ) + netName.Mid( 1 ) + wxT(
"}" );
845 else if( isMultiGate )
848 hierRef = part.reference;
851 wxString::FromUTF8( hierRef ),
860 if( isConnector && !connectorPinNumber.empty() )
863 wxString labelText = wxString::Format( wxT(
"%s.%s" ),
864 wxString::FromUTF8( baseRef ),
865 wxString::FromUTF8( connectorPinNumber ) );
868 std::vector<SCH_PIN*> pins = symbol->
GetPins();
871 pinPos = pins[0]->GetPosition();
878 ctx.screen->Append( label );
881 ctx.screen->Append( symbolPtr.release() );
888 std::set<std::string> powerSignalNames;
892 if( opc.signal_name.empty() )
895 auto ptIt = parser.
GetPartTypes().find( opc.symbol_lib );
898 && !ptIt->second.special_keyword.empty() && ptIt->second.special_keyword !=
"OFF"
899 && !ptIt->second.special_variants.empty() )
901 int idx = std::max( 0, opc.flags2 );
903 static_cast<int>( ptIt->second.special_variants.size() ) - 1 );
904 const auto& variant = ptIt->second.special_variants[idx];
907 variant.decal_name, variant.pin_type ).empty() )
909 powerSignalNames.insert( opc.signal_name );
917 std::set<std::string> signalOpcIds;
921 if( opc.signal_name.empty() || powerSignalNames.count( opc.signal_name ) )
924 signalOpcIds.insert(
"@@@O" + std::to_string( opc.id ) );
929 std::map<std::string, PADS_SCH::NETNAME_LABEL> netNameLabels;
933 if( !nn.anchor_ref.empty() )
934 netNameLabels[nn.anchor_ref] = nn;
938 for(
auto& [sheetNum, ctx] : sheetContexts )
940 std::vector<PADS_SCH::SCH_SIGNAL> sheetSignals = parser.
GetSignalsOnSheet( sheetNum );
951 for(
size_t v = 0; v + 1 < wire.
vertices.size(); v++ )
968 ctx.screen->Append( line );
982 if( wire.
endpoint_a.find(
'.' ) != std::string::npos
983 && wire.
endpoint_a.find(
"@@@" ) == std::string::npos )
986 std::string ref = wire.
endpoint_a.substr( 0, dotPos );
988 if( connectorBaseRefs.count( ref ) )
990 const auto& vtx = wire.
vertices.front();
1001 int dx = adjPos.
x - pos.
x;
1002 int dy = adjPos.
y - pos.
y;
1010 wxString labelText = wxString::FromUTF8( wire.
endpoint_a );
1016 ctx.screen->Append( label );
1021 if( wire.
endpoint_b.find(
'.' ) != std::string::npos
1022 && wire.
endpoint_b.find(
"@@@" ) == std::string::npos )
1025 std::string ref = wire.
endpoint_b.substr( 0, dotPos );
1027 if( connectorBaseRefs.count( ref ) )
1029 const auto& vtx = wire.
vertices.back();
1035 size_t lastIdx = wire.
vertices.size() - 1;
1036 const auto& adj = wire.
vertices[lastIdx - 1];
1041 int dx = adjPos.
x - pos.
x;
1042 int dy = adjPos.
y - pos.
y;
1050 wxString labelText = wxString::FromUTF8( wire.
endpoint_b );
1056 ctx.screen->Append( label );
1065 if( dot.sheet_number != sheetNum )
1072 ctx.screen->Append( junction );
1077 powerSignalNames, netNameLabels );
1085 if( opc.source_sheet != sheetNum )
1088 if( opc.signal_name.empty() )
1096 std::string powerStyle;
1097 auto opcPtIt = parser.
GetPartTypes().find( opc.symbol_lib );
1100 && !opcPtIt->second.special_keyword.empty() && opcPtIt->second.special_keyword !=
"OFF"
1101 && !opcPtIt->second.special_variants.empty() )
1103 int idx = std::max( 0, opc.flags2 );
1104 idx = std::min( idx,
1106 opcPtIt->second.special_variants.size() ) - 1 );
1107 const auto& variant = opcPtIt->second.special_variants[idx];
1110 variant.decal_name, variant.pin_type );
1113 if( !powerStyle.empty() )
1119 auto symbolPtr = std::make_unique<SCH_SYMBOL>();
1132 bool pinUp = ( powerStyle ==
"VCC" || powerStyle ==
"PWR_TRIANGLE" );
1134 std::to_string( opc.id ), sheetSignals, pos, pinUp,
1139 wxString netName = wxString::FromUTF8( opc.signal_name );
1141 if( netName.StartsWith( wxT(
"/" ) ) )
1142 netName = wxT(
"~{" ) + netName.Mid( 1 ) + wxT(
"}" );
1147 wxString pwrRef = wxString::Format( wxT(
"#PWR%03d" ), pwrIndex++ );
1148 symbol->
SetRef( &ctx.path, pwrRef );
1152 ctx.screen->Append( symbolPtr.release() );
1167 auto screenForSheet =
1170 auto ctxIt = sheetContexts.find( aSheetNumber );
1172 return ctxIt != sheetContexts.end() ? ctxIt->second.screen
1173 : sheetContexts.begin()->second.screen;
1177 if( !sheetContexts.empty() )
1181 if( textItem.content.empty() )
1184 SCH_SCREEN* textScreen = screenForSheet( textItem.sheet_number );
1196 if( !sheetContexts.empty() )
1203 SCH_SCREEN* linesScreen = screenForSheet( linesItem.sheet_number );
1205 double ox = linesItem.origin.x;
1206 double oy = linesItem.origin.y;
1235 && prim.
points.size() == 2 )
1256 linesScreen->
Append( rect );
1258 else if( prim.
points.size() >= 2 )
1260 for(
size_t p = 0; p + 1 < prim.
points.size(); p++ )
1278 if( prim.
points[p].arc.has_value() )
1288 double sx = start.
x -
center.x;
1289 double sy = start.
y -
center.y;
1292 double radius = std::sqrt( sx * sx + sy * sy );
1294 double mx = sx + ex;
1295 double my = sy + ey;
1296 double mlen = std::sqrt( mx * mx + my * my );
1303 +
static_cast<int>(
radius * mx / mlen );
1305 +
static_cast<int>(
radius * my / mlen );
1310 +
static_cast<int>( -sy *
radius
1311 / std::max(
radius, 1.0 ) );
1313 +
static_cast<int>( sx *
radius
1314 / std::max(
radius, 1.0 ) );
1330 linesScreen->
Append( arc );
1338 linesScreen->
Append( line );
1347 if( textItem.
content.empty() )
1381 const wxString& aLibraryPath,
1382 const std::map<std::string, UTF8>* aProperties )
1386 bool powerSymbolsOnly = aProperties
1391 if( powerSymbolsOnly && !symbol->IsPower() )
1394 aSymbolNameList.Add(
name );
1400 const wxString& aLibraryPath,
1401 const std::map<std::string, UTF8>* aProperties )
1405 bool powerSymbolsOnly = aProperties
1410 if( powerSymbolsOnly && !symbol->IsPower() )
1413 aSymbolList.push_back( symbol.get() );
1419 const std::map<std::string, UTF8>* aProperties )
1426 return it->second.get();
1434 wxFileName fn( aLibraryPath );
1436 if( fn.IsFileReadable() && fn.GetModificationTime().IsValid() )
1437 return fn.GetModificationTime().GetValue().GetValue();
1460 THROW_IO_ERROR( wxString::Format(
_(
"'%s' is not a PADS Logic ASCII file." ),
1467 std::string filename( aLibraryPath.ToUTF8() );
1469 if( !parser.
Parse( filename ) )
1472 wxString::Format(
_(
"Failed to parse PADS Logic file '%s'." ), aLibraryPath ) );
1478 std::set<std::string> referencedDecals;
1483 for(
const auto& [ptName, ptDef] : parser.
GetPartTypes() )
1485 if( !ptDef.special_keyword.empty() && ptDef.special_keyword !=
"OFF" )
1489 wxString libName = wxString::FromUTF8( ptDef.name );
1491 if( ptDef.gates.size() > 1 )
1497 for(
const std::string& decalName : gate.
decal_names )
1498 referencedDecals.insert( decalName );
1501 else if( !ptDef.gates.empty() )
1504 std::string decalName;
1511 if( symDef && ptDef.is_connector && !gate.
pins.empty() )
1516 std::vector<std::string> pinNumbers;
1517 pinNumbers.reserve( gate.
pins.size() );
1520 pinNumbers.push_back(
pin.pin_id );
1523 referencedDecals.insert( decalName );
1534 referencedDecals.insert( decalName );
1543 if( !ptDef.sigpins.empty() )
1553 if( referencedDecals.count( symDef.name ) )
1556 wxString libName = wxString::FromUTF8( symDef.name );
1577 std::ifstream file( aFileName.fn_str() );
1579 if( !file.is_open() )
1584 if( std::getline( file, line ) )
1586 if( line.find(
"*PADS-POWERLOGIC" ) != std::string::npos )
1589 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_ERROR(msg)
macro which captures the "call site" values of FILE_, __FUNCTION & LINE
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.