63 wxString libName = aFileName.GetName();
65 if( libName.IsEmpty() && aRootSheet )
68 libName = fn.GetName();
71 if( libName.IsEmpty() )
90 THROW_IO_ERROR(
_(
"File does not appear to be a CADSTAR parts Library file" ) );
102 std::vector<LIB_SYMBOL*> retVal;
106 std::unique_ptr<LIB_SYMBOL> loadedPart =
loadLibPart( part );
111 retVal.push_back( loadedPart.release() );
118std::unique_ptr<LIB_SYMBOL>
122 std::unique_ptr<LIB_SYMBOL> retSym;
132 if( !
Library.SymbolDefinitions.count( symbolID ) )
134 m_reporter->Report( wxString::Format(
_(
"Unable to find symbol %s, referenced by part "
135 "%s. The part was not loaded." ),
144 std::unique_ptr<LIB_SYMBOL> kiSymDef(
loadSymdef( symbolID )->Duplicate() );
146 if( (
int)sym.
m_Pins.size() != kiSymDef->GetPinCount() )
148 m_reporter->Report( wxString::Format(
_(
"Inconsistent pin numbers in symbol %s "
149 "compared to the one defined in part %s. The "
150 "part was not loaded." ),
164 wxCHECK( termID > 0 && sym.
m_Pins.size() >=
size_t( termID ),
nullptr );
165 std::vector<SCH_PIN*> pins = kiSymDef->GetPinsByNumber( storedPinNum );
166 size_t termIdx = size_t( termID ) - 1;
175 wxString partPinNum = wxString::Format(
"%ld", sym.
m_Pins[termIdx].m_Identifier );
179 pin->SetNumber( partPinNum );
194 wxCHECK( kiSymDef->GetUnitCount() == 1,
nullptr );
196 retSym = std::move( kiSymDef );
198 retSym->SetUnitCount( aPart.
m_Symbols.size(),
true );
200 retSym->SetName( escapedPartName );
202 retSym->GetValueField().SetText( aPart.
m_Value.value_or(
"" ) );
204 retSym->SetDescription( aPart.
m_Description.value_or(
"" ) );
206 auto addFieldIfHasValue =
207 [&](
const wxString&
name,
const std::optional<std::string>& value )
209 if( value.has_value() )
222 wxString modelVal = wxString::Format(
"model=\"%s\"", aPart.
m_SpiceModel.value() );
249 VECTOR2I symCenter = retSym->GetBodyBoundingBox( unit, 0,
false,
false ).GetCenter();
250 symCenter.
y = -symCenter.
y;
256 for(
auto& [signalName, csPinVector] : aPart.
m_HiddenPins )
260 std::unique_ptr<SCH_PIN>
pin = std::make_unique<SCH_PIN>( retSym.get() );
262 long pinNum = csPin.m_Identifier;
263 pin->SetNumber( wxString::Format(
"%ld", pinNum ) );
264 pin->SetName( signalName );
267 pin->SetVisible(
false );
277 direction = { -direction.
y, direction.
x };
282 pin->SetPosition( symCenter + offset );
285 pin->SetUnit( unit );
286 retSym->AddDrawItem(
pin.release() );
306 int aDestUnit,
bool aOverrideFields )
317 itemCopy->
SetUnit( aDestUnit );
322 if( aOverrideFields )
324 std::vector<SCH_FIELD*> fieldsToCopy;
327 for(
SCH_FIELD* templateField : fieldsToCopy )
330 templateField->Copy( appliedField );
338 wxCHECK( aSchematic, );
359 numSteps +=
Parts.PartDefinitions.size();
386 if(
Schematic.VariantHierarchy.Variants.size() > 0 )
389 m_reporter->Report( wxString::Format(
_(
"The CADSTAR design contains variants are not currently "
390 "supported. Only the master variant ('%s') was loaded." ),
391 Schematic.VariantHierarchy.Variants.at(
"V0" ).Name ),
398 m_reporter->Report(
_(
"The CADSTAR design contains grouped items which are not currently supported. "
399 "Any grouped items have been ungrouped." ),
406 m_reporter->Report(
_(
"The CADSTAR design contains re-use blocks which are not curretly supported. "
407 "The re-use block information has been discarded during the import." ),
413 for( std::pair<LAYER_ID, SCH_SHEET*> sheetPair :
m_sheetMap )
418 BOX2I sheetBoundingBox;
429 bbox =
comp->GetBodyAndPinsBoundingBox();
433 if( field.IsVisible() )
434 bbox.
Merge( field.GetBoundingBox() );
440 wxString txt = txtItem->
GetText();
442 if( txt.Contains(
"${" ) )
449 bbox = item->GetBoundingBox();
452 sheetBoundingBox.
Merge( bbox );
471 auto roundToNearestGrid =
472 [&](
int aNumber ) ->
int
474 int error = aNumber %
grid;
475 int absError =
sign( error ) * error;
477 if( absError > (
grid / 2 ) )
478 return aNumber + (
sign( error ) *
grid ) - error;
480 return aNumber - error;
487 int longestSide = std::max( targetSheetSize.
x, targetSheetSize.
y );
488 int margin = ( (double) longestSide * 0.03 );
489 margin = roundToNearestGrid( margin );
490 targetSheetSize += margin * 2;
501 VECTOR2I sheetcentre( pageSizeIU.
x / 2, pageSizeIU.
y / 2 );
505 VECTOR2I translation = sheetcentre - itemsCentre;
506 translation.
x = roundToNearestGrid( translation.
x );
507 translation.
y = roundToNearestGrid( translation.
y );
510 std::vector<SCH_ITEM*> allItems;
513 std::back_inserter( allItems ) );
517 item->Move( translation );
525 m_reporter->Report(
_(
"CADSTAR fonts are different to the ones in KiCad. This will likely "
526 "result in alignment issues. Please review the imported text elements "
527 "carefully and correct manually if required." ),
530 m_reporter->Report(
_(
"The CADSTAR design has been imported successfully.\n"
531 "Please review the import errors and warnings (if any)." ) );
544 constexpr long long maxDesignSizekicad = std::numeric_limits<int>::max();
546 if( designSizeXkicad > maxDesignSizekicad || designSizeYkicad > maxDesignSizekicad )
548 THROW_IO_ERRORF(
_(
"The design is too large and cannot be imported into KiCad. \n"
549 "Please reduce the maximum design size in CADSTAR by navigating to: \n"
550 "Design Tab -> Properties -> Design Options -> Maximum Design Size. \n"
551 "Current Design size: %.2f, %.2f millimeters. \n"
552 "Maximum permitted design size: %.2f, %.2f millimeters.\n" ),
568 if( orphanSheets.size() > 1 )
573 for(
LAYER_ID sheetID : orphanSheets )
589 else if( orphanSheets.size() > 0 )
591 LAYER_ID rootSheetID = orphanSheets.at( 0 );
593 wxFileName loadedFilePath = wxFileName(
Filename );
595 std::string filename = wxString::Format(
"%s_%02d", loadedFilePath.GetName(),
601 wxFileName fn(
m_schematic->Project().GetProjectPath() + filename );
602 m_rootSheet->GetScreen()->SetFileName( fn.GetFullPath() );
607 else if(
Header.Format.Type ==
"SYMBOL" )
609 THROW_IO_ERROR(
_(
"The selected file is a CADSTAR symbol library. It does not contain a "
610 "schematic design so cannot be imported/opened in this way." ) );
614 THROW_IO_ERROR(
_(
"The CADSTAR schematic might be corrupt: there is no root sheet." ) );
621 for( std::pair<BLOCK_ID, BLOCK> blockPair :
Schematic.Blocks )
623 BLOCK& block = blockPair.second;
626 if( block.
Type == BLOCK::TYPE::PARENT )
628 else if( block.
Type == BLOCK::TYPE::CHILD )
637 for( std::pair<TERMINAL_ID, TERMINAL> termPair : block.
Terminals )
640 wxString
name =
"YOU SHOULDN'T SEE THIS TEXT. THIS IS A BUG.";
644 if( block.
Type == BLOCK::TYPE::PARENT )
646 else if( block.
Type == BLOCK::TYPE::CHILD )
669 for( std::pair<PART_ID, PART> partPair :
Parts.PartDefinitions )
671 PART_ID partID = partPair.first;
672 PART part = partPair.second;
675 std::unique_ptr<LIB_SYMBOL> kiSym = std::make_unique<LIB_SYMBOL>( escapedPartName );
682 GATE_ID gateID = gatePair.first;
683 PART::DEFINITION::GATE gate = gatePair.second;
686 if( symbolID.IsEmpty() )
688 m_reporter->Report( wxString::Format(
_(
"Part definition '%s' references symbol "
689 "'%s' (alternate '%s') which could not be "
690 "found in the symbol library. The part has "
691 "not been loaded into the KiCad library." ),
711 m_reporter->Report( wxString::Format(
_(
"Part definition '%s' has an incomplete "
712 "definition (no symbol definitions are "
713 "associated with it). The part has not "
714 "been loaded into the KiCad library." ),
728 bool inserted =
m_partMap.insert( { partID, symbol } ).second;
729 wxCHECK2( inserted,
continue );
741 for( std::pair<SYMBOL_ID, SYMBOL> symPair :
Schematic.Symbols )
743 SYMBOL sym = symPair.second;
752 m_reporter->Report( wxString::Format(
_(
"Symbol '%s' references part '%s' which could not be "
753 "found in the library. The symbol was not loaded." ),
761 if( sym.
GateID.IsEmpty() )
766 std::unique_ptr<LIB_SYMBOL> kiSymCopy;
774 kiSymCopy = std::make_unique<LIB_SYMBOL>( *kiSym );
775 kiSym = kiSymCopy.get();
809 partname.Replace( wxT(
"\n" ), wxT(
"\\n" ) );
810 partname.Replace( wxT(
"\r" ), wxT(
"\\r" ) );
811 partname.Replace( wxT(
"\t" ), wxT(
"\\t" ) );
812 partField->
SetText( partname );
831 wxASSERT( attrField->
GetName() == attrName );
833 attrVal.
Value.Replace( wxT(
"\n" ), wxT(
"\\n" ) );
834 attrVal.
Value.Replace( wxT(
"\r" ), wxT(
"\\r" ) );
835 attrVal.
Value.Replace( wxT(
"\t" ), wxT(
"\\t" ) );
848 THROW_IO_ERRORF(
_(
"Symbol ID '%s' references library symbol '%s' which could not be found "
849 "in the library. Did you export all items of the design?" ),
858 THROW_IO_ERRORF(
_(
"Symbol ID '%s' is a signal reference or global signal but it has too "
859 "many pins. The expected number of pins is 1 but %d were found." ),
872 wxString libraryNetName =
Library.SymbolDefinitions.at( symID ).Alternate;
882 wxString libPartName = libraryNetName;
888 if( libPartName != symbolInstanceNetName )
890 libPartName += wxT(
" (" ) + symbolInstanceNetName + wxT(
")" );
896 wxCHECK( templatePart, );
898 auto ownedPart = std::make_unique<LIB_SYMBOL>( *templatePart );
899 kiPart = ownedPart.get();
903 kiPart->
SetName( libPartName );
909 wxCHECK( pins.size() == 1, );
912 pins.at( 0 )->SetName( symbolInstanceNetName );
963 netLabel->
SetText(
"***UNKNOWN NET****" );
977 if( libSymDef.
Alternate.Lower().Contains(
"in" ) )
979 else if( libSymDef.
Alternate.Lower().Contains(
"bi" ) )
981 else if( libSymDef.
Alternate.Lower().Contains(
"out" ) )
991 screen->
Append( netLabel );
996 wxASSERT_MSG(
false,
"Unknown Symbol Variant." );
1001 m_reporter->Report( wxString::Format(
_(
"Symbol ID '%s' is of an unknown type. It is neither a "
1002 "symbol or a net power / symbol. The symbol was not loaded." ),
1011 if( symbolName.empty() )
1012 symbolName = wxString::Format(
"ID: %s", sym.
ID );
1014 symbolName += sym.
GateID;
1016 m_reporter->Report( wxString::Format(
_(
"Symbol '%s' is scaled in the original CADSTAR schematic "
1017 "but this is not supported in KiCad. When the symbol is "
1018 "reloaded from the library, it will revert to the original "
1030 for( std::pair<BUS_ID, BUS> busPair :
Schematic.Buses )
1032 BUS bus = busPair.second;
1033 bool firstPt =
true;
1036 if( bus.
LayerID != wxT(
"NO_SHEET" ) )
1039 std::shared_ptr<BUS_ALIAS> kiBusAlias = std::make_shared<BUS_ALIAS>();
1041 kiBusAlias->SetName( bus.
Name );
1049 label->
SetText( wxT(
"{" ) + busname + wxT(
"}" ) );
1098 label->
SetText( wxT(
"{" ) + busname + wxT(
"}" ) );
1111 std::map<LAYER_ID, SCH_IO_WIRE_DETOUR> detours;
1112 std::map<NET_ID, int> netIds;
1113 std::set<std::pair<LAYER_ID, VECTOR2I>> terminalPoints;
1115 for(
const auto& [netID, net] :
Schematic.Nets )
1117 const int netIndex = netIds.try_emplace( netID,
static_cast<int>( netIds.size() ) + 1 ).first->second;
1119 for(
const auto& [termID, term] : net.Terminals )
1121 auto symIt =
Schematic.Symbols.find( term.SymbolID );
1129 detours[symIt->second.LayerID].AddContact( kiPos, netIndex );
1130 terminalPoints.emplace( symIt->second.LayerID, kiPos );
1134 for(
const auto& [layerID, sheet] :
m_sheetMap )
1147 if( !terminalPoints.count( { layerID, pos } ) )
1148 detours[layerID].AddContact( pos, detours[layerID].AnonymousNet() );
1153 auto getHierarchicalLabel =
1156 if( aNode.Contains(
"BLKT" ) )
1159 BLOCK_PIN_ID blockPinID = std::make_pair( blockTerm.BlockID, blockTerm.TerminalID );
1169 struct PENDING_CONNECTION
1172 NET_SCH::CONNECTION_SCH Conn;
1174 std::map<NETELEMENT_ID, SCH_LABEL*> Labels;
1177 std::vector<PENDING_CONNECTION> pending;
1179 for( std::pair<NET_ID, NET_SCH> netPair :
Schematic.Nets )
1181 const int netIndex = netIds.at( netPair.first );
1183 wxString netName = net.
Name;
1184 std::map<NETELEMENT_ID, SCH_LABEL*> netlabels;
1186 if( netName.IsEmpty() )
1187 netName = wxString::Format(
"$%ld", net.
SignalNum );
1191 for( std::pair<NETELEMENT_ID, NET_SCH::SYM_TERM> terminalPair : net.
Terminals )
1193 NET_SCH::SYM_TERM netTerm = terminalPair.second;
1202 if( netTerm.HasNetLabel )
1207 applyTextSettings( val, netTerm.NetLabel.TextCodeID, netTerm.NetLabel.Alignment,
1208 netTerm.NetLabel.Justification, netTerm.NetLabel.OrientAngle,
1209 netTerm.NetLabel.Mirror );
1226 else if( !net.
Name.IsEmpty() &&
Schematic.Symbols.count( netTerm.SymbolID )
1227 && netTerm.HasNetLabel )
1237 applyTextSettings( label, netTerm.NetLabel.TextCodeID, netTerm.NetLabel.Alignment,
1238 netTerm.NetLabel.Justification );
1240 netlabels.insert( { netTerm.ID, label } );
1243 m_sheetMap.at( sheet )->GetScreen()->Append( label );
1248 for( std::pair<NETELEMENT_ID, NET_SCH::BLOCK_TERM> blockPair : net.
BlockTerminals )
1250 SCH_HIERLABEL* label = getHierarchicalLabel( net, blockPair.first );
1257 [&](
const NET_SCH::CONNECTION_SCH& aConn )
1259 return aConn.LayerID != wxT(
"NO_SHEET" )
1260 && ( aConn.StartNode == blockPair.first
1261 || aConn.EndNode == blockPair.first );
1264 if( label && !connected )
1266 detours[
Schematic.Blocks.at( blockPair.second.BlockID ).LayerID].AddContact( label->
GetPosition(),
1272 for( std::pair<NETELEMENT_ID, NET_SCH::BUS_TERM> busPair : net.
BusTerminals )
1274 NET_SCH::BUS_TERM busTerm = busPair.second;
1296 if( busTerm.HasNetLabel )
1298 applyTextSettings( label, busTerm.NetLabel.TextCodeID, busTerm.NetLabel.Alignment,
1299 busTerm.NetLabel.Justification );
1306 netlabels.insert( { busTerm.ID, label } );
1311 for( std::pair<NETELEMENT_ID, NET_SCH::DANGLER> danglerPair : net.
Danglers )
1313 NET_SCH::DANGLER dangler = danglerPair.second;
1319 if( dangler.HasNetLabel )
1321 applyTextSettings( label, dangler.NetLabel.TextCodeID, dangler.NetLabel.Alignment,
1322 dangler.NetLabel.Justification );
1326 netlabels.insert( { dangler.ID, label } );
1327 detours[dangler.LayerID].AddContact( label->
GetPosition(), netIndex );
1329 m_sheetMap.at( dangler.LayerID )->GetScreen()->Append( label );
1332 for( NET_SCH::CONNECTION_SCH conn : net.
Connections )
1334 if( conn.LayerID == wxT(
"NO_SHEET" ) )
1345 if( conn.Path.size() < 1 || conn.Path.front().End != start )
1348 if( conn.Path.size() < 2 || conn.Path.back().End !=
end )
1358 for(
const VERTEX& vertex : conn.Path )
1366 std::vector<NETELEMENT_ID> nodes;
1367 nodes.push_back( conn.StartNode );
1368 nodes.push_back( conn.EndNode );
1372 SCH_HIERLABEL* sheetPin = getHierarchicalLabel( net, node );
1383 int leftSide = sheetPosition.
x;
1384 int rightSide = sheetPosition.
x + sheetSize.
x;
1385 int topSide = sheetPosition.
y;
1386 int botSide = sheetPosition.
y + sheetSize.
y;
1390 sheetEdge.
Append( leftSide, topSide );
1391 sheetEdge.
Append( rightSide, topSide );
1392 sheetEdge.
Append( rightSide, botSide );
1393 sheetEdge.
Append( leftSide, botSide );
1394 sheetEdge.
Append( leftSide, topSide );
1396 std::vector<SHAPE_LINE_CHAIN::INTERSECTION> wireToSheetIntersects;
1398 if( !wireChain.
Intersect( sheetEdge, wireToSheetIntersects ) )
1403 if( node == conn.StartNode )
1404 wireChain = wireChain.
Reverse();
1408 if( node == conn.StartNode )
1409 wireChain = wireChain.
Reverse();
1415 VECTOR2I intsctPt = wireToSheetIntersects.at( 0 ).p;
1416 int intsctIndx = wireChain.
FindSegment( intsctPt );
1417 wxASSERT_MSG( intsctIndx != -1,
"Can't find intersecting segment" );
1419 if( node == conn.StartNode )
1420 wireChain.
Replace( 0, intsctIndx, intsctPt );
1422 wireChain.
Replace( intsctIndx + 1, -1, intsctPt );
1430 for(
int i = 1; i < wireChain.
PointCount(); i++ )
1431 detours[conn.LayerID].AddWire(
SEG( wireChain.
CPoint( i - 1 ), wireChain.
CPoint( i ) ), netIndex );
1435 if(
SCH_HIERLABEL* sheetPin = getHierarchicalLabel( net, node ) )
1436 detours[conn.LayerID].AddContact( sheetPin->GetPosition(), netIndex );
1439 pending.push_back( { netPair.first, conn, wireChain, netlabels } );
1442 for( std::pair<NETELEMENT_ID, NET_SCH::JUNCTION_SCH> juncPair : net.
Junctions )
1444 NET_SCH::JUNCTION_SCH junc = juncPair.second;
1449 detours[junc.LayerID].AddContact( kiJunc->
GetPosition(), netIndex );
1450 m_sheetMap.at( junc.LayerID )->GetScreen()->Append( kiJunc );
1452 if( junc.HasNetLabel )
1466 m_sheetMap.at( junc.LayerID )->GetScreen()->Append( label );
1471 for( PENDING_CONNECTION& pend : pending )
1474 const NET_SCH::CONNECTION_SCH& conn = pend.Conn;
1476 const int netIndex = netIds.at( pend.NetID );
1478 bool detourFailed =
false;
1480 for(
int i = 0; i < pend.Chain.PointCount(); i++ )
1484 wireChain.
Append( pend.Chain.CPoint( 0 ) );
1489 detour.
Route(
SEG( pend.Chain.CPoint( i - 1 ), pend.Chain.CPoint( i ) ), netIndex );
1491 detourFailed |=
result.Failed;
1494 if( i + 1 < pend.Chain.PointCount() && detour.
TouchesOtherNet( pend.Chain.CPoint( i ), netIndex ) )
1495 detourFailed =
true;
1503 m_reporter->Report( wxString::Format(
_(
"A connection of net %s passes over a pin or wire of another "
1504 "net and could not be rerouted. The nets may be joined and "
1505 "require manual fixing." ),
1510 auto fixNetLabelsAndSheetPins =
1515 if( pend.Labels.find( aNetEleID ) != pend.Labels.end() )
1516 pend.Labels.at( aNetEleID )->SetSpinStyle( spin.
MirrorY() );
1518 SCH_HIERLABEL* sheetPin = getHierarchicalLabel( net, aNetEleID );
1524 bool firstPt =
true;
1525 bool secondPt =
false;
1545 fixNetLabelsAndSheetPins( wireAngle, conn.StartNode );
1554 if( !conn.ConnectionLineCode.IsEmpty() )
1559 m_sheetMap.at( conn.LayerID )->GetScreen()->Append( wire );
1566 fixNetLabelsAndSheetPins( wireAngle, conn.EndNode );
1574 for( std::pair<FIGURE_ID, FIGURE> figPair :
Schematic.Figures )
1576 FIGURE fig = figPair.second;
1585 for( std::pair<TEXT_ID, TEXT> textPair :
Schematic.Texts )
1587 TEXT txt = textPair.second;
1597 for( std::pair<DOCUMENTATION_SYMBOL_ID, DOCUMENTATION_SYMBOL> docSymPair :
1604 m_reporter->Report( wxString::Format(
_(
"Documentation Symbol '%s' refers to symbol definition "
1605 "ID '%s' which does not exist in the library. The symbol "
1606 "was not loaded." ),
1619 bool mirrorInvert = docSym.
Mirror;
1621 for( std::pair<FIGURE_ID, FIGURE> figPair : docSymDef.
Figures )
1623 FIGURE fig = figPair.second;
1626 centreOfTransform, mirrorInvert );
1629 for( std::pair<TEXT_ID, TEXT> textPair : docSymDef.
Texts )
1631 TEXT txt = textPair.second;
1633 txt.
Mirror = ( txt.
Mirror ) ? !mirrorInvert : mirrorInvert;
1639 scalingFactor, centreOfTransform, mirrorInvert );
1658 auto findAndReplaceTextField =
1661 if(
m_context.TextFieldToValuesMap.find( aField ) !=
m_context.TextFieldToValuesMap.end() )
1663 if(
m_context.TextFieldToValuesMap.at( aField ) != aValue )
1665 m_context.TextFieldToValuesMap.at( aField ) = aValue;
1666 m_context.InconsistentTextFields.insert( aField );
1672 m_context.TextFieldToValuesMap.insert( { aField, aValue } );
1682 std::map<wxString, wxString>& txtVars = pj->
GetTextVars();
1685 if(
Schematic.VariantHierarchy.Variants.size() > 0 )
1695 for( std::pair<TEXT_FIELD_NAME, wxString> txtvalue :
m_context.TextFieldToValuesMap )
1698 wxString varValue = txtvalue.second;
1700 txtVars.insert( { varName, varValue } );
1703 for( std::pair<wxString, wxString> txtvalue :
m_context.FilenamesToTextMap )
1705 wxString varName = txtvalue.first;
1706 wxString varValue = txtvalue.second;
1708 txtVars.insert( { varName, varValue } );
1713 m_reporter->Report(
_(
"Text Variables could not be set as there is no project attached." ),
1724 return existingField;
1728 aKiCadSymbol->
AddField( newfield );
1741 wxCHECK(
Library.SymbolDefinitions.find( aSymdefID ) !=
Library.SymbolDefinitions.end(),
nullptr );
1747 std::unique_ptr<LIB_SYMBOL> kiSym = std::make_unique<LIB_SYMBOL>( csSym.
BuildLibName() );
1748 const int gateNumber = 1;
1751 for( std::pair<FIGURE_ID, FIGURE> figPair : csSym.
Figures )
1753 FIGURE fig = figPair.second;
1760 lineThickness, linestyle );
1768 return getKiCadLibraryPoint( aPt, csSym.Origin );
1783 kiSym->AddDrawItem( shape );
1790 for( std::pair<TERMINAL_ID, TERMINAL> termPair : csSym.
Terminals )
1793 wxString pinNum = wxString::Format(
"%ld", term.
ID );
1794 wxString pinName = wxEmptyString;
1795 std::unique_ptr<SCH_PIN>
pin = std::make_unique<SCH_PIN>( kiSym.get() );
1801 pin->SetLength( 0 );
1803 pin->SetUnit( gateNumber );
1804 pin->SetNumber( pinNum );
1805 pin->SetName( pinName );
1823 pin->SetNumberTextSize( pinNumberHeight );
1824 pin->SetNameTextSize( pinNameHeight );
1826 pinNumToTerminals.insert( {
pin->GetNumber(), term.
ID } );
1827 kiSym->AddDrawItem(
pin.release() );
1835 for( std::pair<TEXT_ID, TEXT> textPair : csSym.
Texts )
1837 TEXT csText = textPair.second;
1839 auto libtext = std::make_unique<SCH_TEXT>( pos, csText.
Text,
LAYER_DEVICE );
1841 libtext->SetUnit( gateNumber );
1843 libtext->SetMultilineAllowed(
true );
1849 if( csText.
Text.Contains(
"\n" ) )
1851 wxArrayString strings;
1854 for(
size_t ii = 0; ii < strings.size(); ++ii )
1856 BOX2I bbox = libtext->GetTextBox(
nullptr, ii );
1859 RotatePoint( linePos, libtext->GetTextPos(), -libtext->GetTextAngle() );
1862 textLine->
SetText( strings[ii] );
1869 kiSym->AddDrawItem( textLine );
1875 libtext->SetMultilineAllowed(
false );
1876 kiSym->AddDrawItem( libtext.release() );
1898 wxCHECK( partField,
nullptr );
1914 for(
auto& [attributeId, textLocation] : csSym.
TextLocations )
1939 if( attrValue.HasLocation )
1946 m_symDefMap.insert( { aSymdefID, std::move( kiSym ) } );
1953 const PART& aCadstarPart,
1957 wxCHECK(
Library.SymbolDefinitions.find( aSymdefID ) !=
Library.SymbolDefinitions.end(), );
1959 std::unique_ptr<LIB_SYMBOL> kiSymDef(
loadSymdef( aSymdefID )->Duplicate() );
1960 wxCHECK( kiSymDef, );
1968 std::vector<SCH_PIN*> pins = kiSymDef->GetPinsByNumber( storedPinNum );
1973 if( pinNum.IsEmpty() )
1975 if( !csPin.Identifier.IsEmpty() )
1976 pinNum = csPin.Identifier;
1978 pinNum = wxString::Format(
"%ld", termID );
1980 pinNum = wxString::Format(
"%ld", csPin.ID );
1986 pin->SetNumber( pinNum );
1987 pin->SetName( pinName );
1990 pinNumMap.insert( { termID, pinNum } );
2007 const POINT& symDefOrigin =
Library.SymbolDefinitions.at( aSymdefID ).Origin;
2008 wxString footprintRefName = wxEmptyString;
2009 wxString footprintAlternateName = wxEmptyString;
2016 wxString attributeValue = aAttributeVal.Value;
2017 attributeValue.Replace( wxT(
"\n" ), wxT(
"\\n" ) );
2018 attributeValue.Replace( wxT(
"\r" ), wxT(
"\\r" ) );
2019 attributeValue.Replace( wxT(
"\t" ), wxT(
"\\t" ) );
2025 if( attrName == wxT(
"(PartDefinitionNameStem)" ) )
2028 attributeValue.Replace( wxT(
" " ),
"_" );
2032 else if( attrName == wxT(
"(PartDescription)" ) )
2037 else if( attrName == wxT(
"(PartDefinitionReferenceName)" ) )
2039 footprintRefName = attributeValue;
2042 else if( attrName == wxT(
"(PartDefinitionAlternateName)" ) )
2044 footprintAlternateName = attributeValue;
2048 bool attrIsNew = aSymbol->
GetField( attrName ) ==
nullptr;
2051 wxASSERT( attrField->
GetName() == attrName );
2052 attrField->
SetText( attributeValue );
2053 attrField->
SetUnit( gateNumber );
2055 const ATTRIBUTE_ID& attrid = aAttributeVal.AttributeID;
2058 if( aAttributeVal.HasLocation )
2063 else if( attrIsNew )
2072 loadLibraryField( attrVal );
2076 loadLibraryField( attrVal );
2089 const wxString& aFootprintName,
2090 const wxString& aFootprintAlternate )
2092 wxString fpNameInLibrary =
generateLibName( aFootprintName, aFootprintAlternate );
2094 if( !fpNameInLibrary.IsEmpty() )
2096 wxArrayString fpFilters;
2097 fpFilters.Add( aFootprintName );
2099 if( !aFootprintAlternate.IsEmpty() )
2100 fpFilters.Add( fpNameInLibrary );
2115 const VERTEX* prev = aCadstarVertices.empty() ? nullptr : &aCadstarVertices.at( 0 );
2120 for(
size_t i = 1; i < aCadstarVertices.size(); i++ )
2122 cur = &aCadstarVertices.at( i );
2131 centerPoint = ( startPoint + endPoint ) / 2;
2157 shape->
SetEnd( startPoint );
2162 shape->
SetEnd( endPoint );
2168 shape->
SetUnit( aGateNumber );
2187 aCadstarAttrLoc.
Mirror );
2205 m_reporter->Report( wxString::Format(
_(
"Symbol '%s' references sheet ID '%s' which does not exist "
2206 "in the design. The symbol was not loaded." ),
2226 int compOrientation = 0;
2228 if( aCadstarSymbol.
Mirror )
2230 compAngle = -compAngle;
2236 EDA_ANGLE test2( aComponentOrientation );
2240 m_reporter->Report( wxString::Format(
_(
"Symbol '%s' is rotated by an angle of %.1f "
2241 "degrees in the original CADSTAR design but "
2242 "KiCad only supports rotation angles multiples "
2243 "of 90 degrees. The connecting wires will need "
2252 wxString gate = ( aCadstarSymbol.
GateID.IsEmpty() ) ? wxString( wxT(
"A" ) ) : aCadstarSymbol.
GateID;
2253 wxString partGateIndex = aCadstarSymbol.
PartRef.
RefID + gate;
2260 std::map<wxString, std::vector<SCH_PIN*>> pinNumToLibPinsMap;
2262 for(
auto& term : termNumMap )
2264 wxString pinNum = term.second;
2265 std::vector<SCH_PIN*> pins =
2267 pinNumToLibPinsMap.insert( { pinNum, pins } );
2270 auto replacePinNumber =
2271 [&](
const wxString& aOldPinNum,
const wxString& aNewPinNum )
2273 if( aOldPinNum == aNewPinNum )
2276 for(
SCH_PIN* libpin : pinNumToLibPinsMap.at( aOldPinNum ) )
2281 for(
auto& pinPair : aCadstarSymbol.
PinNumbers )
2283 SYMBOL::PIN_NUM
pin = pinPair.second;
2285 replacePinNumber( termNumMap.at(
pin.TerminalID ),
2286 wxString::Format(
"%ld",
pin.PinNum ) );
2290 for(
auto& pinPair : aCadstarSymbol.
PinNames )
2293 replacePinNumber( termNumMap.at(
pin.TerminalID ),
pin.NameOrLabel );
2323 if( textIsVertical )
2326 alignment =
mirrorX( alignment );
2332 aCadstarAttrLoc.
Mirror );
2347 aReturnedOrientation =
ANGLE_0;
2365 return compOrientation;
2372 auto logUnknownNetElementError =
2375 m_reporter->Report( wxString::Format(
_(
"Net %s references unknown net element %s. The net was "
2376 "not properly loaded and may require manual fixing." ),
2384 if( aNetElementID.Contains(
"J" ) )
2387 return logUnknownNetElementError();
2389 return aNet.
Junctions.at( aNetElementID ).Location;
2391 else if( aNetElementID.Contains(
"P" ) )
2394 return logUnknownNetElementError();
2400 return logUnknownNetElementError();
2406 if(
Library.SymbolDefinitions.find( symdefid ) ==
Library.SymbolDefinitions.end() )
2407 return logUnknownNetElementError();
2414 m_reporter->Report( wxString::Format(
_(
"Net %s references unknown terminal %s on symbol %s. "
2415 "The net was not properly loaded and may require manual "
2428 VECTOR2I pinOffset = libpinPosition - libOrigin;
2432 VECTOR2I pinPosition = symbolOrigin + pinOffset;
2436 pinPosition.
x = ( 2 * symbolOrigin.
x ) - pinPosition.
x;
2441 RotatePoint( pinPosition, symbolOrigin, -adjustedOrientation );
2444 retval.
x = pinPosition.
x;
2445 retval.
y = pinPosition.
y;
2449 else if( aNetElementID.Contains(
"BT" ) )
2452 return logUnknownNetElementError();
2454 return aNet.
BusTerminals.at( aNetElementID ).SecondPoint;
2456 else if( aNetElementID.Contains(
"BLKT" ) )
2459 return logUnknownNetElementError();
2465 return logUnknownNetElementError();
2471 m_reporter->Report( wxString::Format(
_(
"Net %s references unknown terminal %s on block %s. The net "
2472 "was not properly loaded and may require manual fixing." ),
2481 return block.
Terminals.at( termid ).Position;
2483 else if( aNetElementID.Contains(
"D" ) )
2486 return logUnknownNetElementError();
2488 return aNet.
Danglers.at( aNetElementID ).Position;
2492 return logUnknownNetElementError();
2499 wxString netname = aNet.
Name;
2501 if( netname.IsEmpty() )
2502 netname = wxString::Format(
"$%ld", aNet.
SignalNum );
2514 const double& aScalingFactor,
2516 const bool& aMirrorInvert )
2521 const VERTEX* prev = aCadstarVertices.empty() ? nullptr : &aCadstarVertices.at( 0 );
2526 auto pointTransform =
2530 aScalingFactor, aTransformCentre, aMirrorInvert );
2533 for(
size_t ii = 1; ii < aCadstarVertices.size(); ii++ )
2535 cur = &aCadstarVertices.at( ii );
2537 VECTOR2I transformedStartPoint = pointTransform( prev->
End );
2538 VECTOR2I transformedEndPoint = pointTransform( cur->
End );
2561 segment->
SetLayer( aKiCadSchLayerID );
2573 wxFAIL_MSG(
"Unknown CADSTAR Vertex type" );
2582 const LAYER_ID& aCadstarSheetIDOverride,
2586 const double& aScalingFactor,
2588 const bool& aMirrorInvert )
2591 aCadstarSheetIDOverride, aKiCadSchLayerID, aMoveVector, aRotation,
2592 aScalingFactor, aTransformCentre, aMirrorInvert );
2597 aKiCadSchLayerID, aMoveVector, aRotation, aScalingFactor,
2598 aTransformCentre, aMirrorInvert );
2609 "Sheet already loaded!" );
2612 aParentSheet.
Last(),
2620 wxString
name =
Sheets.SheetNames.at( aCadstarSheetID );
2625 wxString loadedFilename = wxFileName(
Filename ).GetName();
2626 std::string filename = wxString::Format(
"%s_%02d", loadedFilename, sheetNum ).ToStdString();
2633 wxFileName fn(
m_schematic->Project().GetProjectPath() + filename );
2638 wxString pageNumStr = wxString::Format(
"%d",
getSheetNumber( aCadstarSheetID ) );
2643 m_sheetMap.insert( { aCadstarSheetID, sheet } );
2653 "FIXME! Parent sheet should be loaded before attempting to load subsheets" );
2655 for( std::pair<BLOCK_ID, BLOCK> blockPair :
Schematic.Blocks )
2657 BLOCK& block = blockPair.second;
2659 if( block.
LayerID == aCadstarSheetID && block.
Type == BLOCK::TYPE::CHILD )
2663 if( block.
Figures.size() > 0 )
2665 m_reporter->Report( wxString::Format(
_(
"The block ID %s (Block name: '%s') is drawn on sheet "
2666 "'%s' but is not linked to another sheet in the design. "
2667 "KiCad requires all sheet symbols to be associated to a "
2668 "sheet, so the block was not loaded." ),
2670 Sheets.SheetNames.at( aCadstarSheetID ) ),
2680 std::pair<VECTOR2I, VECTOR2I> blockExtents;
2682 if( block.
Figures.size() > 0 )
2688 THROW_IO_ERROR( wxString::Format(
_(
"The CADSTAR schematic might be corrupt: Block %s references "
2689 "a child sheet but has no Figure defined." ),
2698 std::vector<SCH_FIELD> fields = loadedSheet->
GetFields();
2702 field.SetVisible(
false );
2746 std::vector<LAYER_ID> childSheets, orphanSheets;
2749 for( std::pair<BLOCK_ID, BLOCK> blockPair :
Schematic.Blocks )
2751 BLOCK& block = blockPair.second;
2754 if( block.
Type == BLOCK::TYPE::CHILD )
2755 childSheets.push_back( assocSheetID );
2761 if( std::find( childSheets.begin(), childSheets.end(), sheetID ) == childSheets.end() )
2762 orphanSheets.push_back( sheetID );
2765 return orphanSheets;
2775 if( sheetID == aCadstarSheetID )
2788 wxCHECK_MSG( aItem, , wxT(
"aItem is null" ) );
2790 if( aCadstarSheetID ==
"ALL_SHEETS" )
2792 for( std::pair<LAYER_ID, SHEET_NAME> sheetPair :
Sheets.SheetNames )
2794 LAYER_ID sheetID = sheetPair.first;
2800 else if( aCadstarSheetID ==
"NO_SHEET" )
2802 wxFAIL_MSG( wxT(
"Trying to add an item to NO_SHEET? This might be a documentation symbol." ) );
2808 m_sheetMap.at( aCadstarSheetID )->GetScreen()->Append( aItem );
2813 wxFAIL_MSG( wxT(
"Unknown Sheet ID." ) );
2821 const wxString& aSymDefAlternate )
2830 for(
auto& [
id, symdef] :
Library.SymbolDefinitions )
2832 wxString refKey = symdef.ReferenceName.Lower();
2833 wxString altKey = symdef.Alternate.Lower();
2845 else if( altKey.IsEmpty() )
2853 wxString refKeyToFind = aSymdefName.Lower();
2854 wxString altKeyToFind = aSymDefAlternate.Lower();
2872 if(
AttrColors.AttributeColors.find( aCadstarAttributeID ) !=
AttrColors.AttributeColors.end() )
2873 return AttrColors.AttributeColors.at( aCadstarAttributeID ).IsVisible;
2881 wxCHECK(
Assignments.Codedefs.LineCodes.find( aCadstarLineCodeID ) !=
Assignments.Codedefs.LineCodes.end(),
2890 wxCHECK(
Assignments.Codedefs.LineCodes.find( aCadstarLineCodeID ) !=
Assignments.Codedefs.LineCodes.end(),
2893 switch(
Assignments.Codedefs.LineCodes.at( aCadstarLineCodeID ).Style )
2908 wxCHECK(
Assignments.Codedefs.TextCodes.find( aCadstarTextCodeID ) !=
Assignments.Codedefs.TextCodes.end(),
2911 return Assignments.Codedefs.TextCodes.at( aCadstarTextCodeID );
2925 wxCHECK(
Assignments.Codedefs.AttributeNames.find( aCadstarAttributeID )
2927 aCadstarAttributeID );
2929 return Assignments.Codedefs.AttributeNames.at( aCadstarAttributeID ).Name;
2936 wxCHECK(
Parts.PartDefinitions.find( aCadstarPartID ) !=
Parts.PartDefinitions.end(),
PART() );
2938 return Parts.PartDefinitions.at( aCadstarPartID );
2945 wxCHECK(
Assignments.Codedefs.RouteCodes.find( aCadstarRouteCodeID ) !=
Assignments.Codedefs.RouteCodes.end(),
2948 return Assignments.Codedefs.RouteCodes.at( aCadstarRouteCodeID );
2952CADSTAR_SCH_ARCHIVE_LOADER::PART::DEFINITION::PIN
2956 for( std::pair<PART_DEFINITION_PIN_ID, PART::DEFINITION::PIN> pinPair :
2959 PART::DEFINITION::PIN partPin = pinPair.second;
2961 if( partPin.TerminalGate == aGateID && partPin.TerminalPin == aTerminalID )
2965 return PART::DEFINITION::PIN();
2990 if( aCadstarGateID.IsEmpty() )
2993 return (
int) aCadstarGateID.Upper().GetChar( 0 ) - (int) wxUniChar(
'A' ) + 1;
3035 switch( aCadstarAlignment )
3054 default: wxFAIL_MSG(
"Unknown Cadstar Alignment" );
return aCadstarAlignment;
3062 switch( aCadstarAlignment )
3076 default: wxFAIL_MSG(
"Unknown Cadstar Alignment" );
return aCadstarAlignment;
3086 aKiCadTextItem->
SetText( escapedText );
3088 if( !
Assignments.Codedefs.TextCodes.count( aCadstarTextCodeID ) )
3097 if( textWidth == 0 )
3118 const long long aCadstarOrientAngle,
3127 ALIGNMENT textAlignment = aCadstarAlignment;
3133 textAlignment =
mirrorX( aCadstarAlignment );
3138 switch( aAlignment )
3193 wxCHECK( textEdaItem, );
3215 textAlignment =
rotate180( textAlignment );
3219 textAlignment =
rotate180( textAlignment );
3222 wxFAIL_MSG(
"Unknown Quadrant" );
3226 setAlignment( aKiCadTextItem, textAlignment );
3233 setAlignment( aKiCadTextItem, textAlignment );
3235 int off =
static_cast<SCH_TEXT*
>( aKiCadTextItem )->GetTextOffset();
3246 default: wxFAIL_MSG(
"Unexpected Spin Style" );
break;
3274 wxFAIL_MSG(
"Unexpected Spin Style" );
3283 label->SetSpinStyle( spin );
3287 wxFAIL_MSG(
"Unexpected item type" );
3302 aCadstarTextElement.
Mirror );
3309 long long aScalingFactorNumerator,
3310 long long aScalingFactorDenominator )
3314 if( aScalingFactorNumerator == aScalingFactorDenominator )
3318 [&](
int aLength ) ->
int
3320 return( aLength * aScalingFactorNumerator ) / aScalingFactorDenominator;
3326 return VECTOR2I( scaleLen( aCoord.x ), scaleLen( aCoord.y ) );
3332 return VECTOR2I( scaleLen( aSize.x ), scaleLen( aSize.y ) );
3339 switch( item.Type() )
3366 pin.SetPosition( scalePt(
pin.GetPosition() ) );
3367 pin.SetLength( scaleLen(
pin.GetLength() ) );
3407 if( aGateNumber > 0 && shape.
GetUnit() != aGateNumber )
3420 if( pt0 != pt1 && uniqueSegments.count( pt0 ) == 0 && uniqueSegments.count( pt1 ) == 0 )
3423 if( pt0.
x == pt1.
x || pt0.
y == pt1.
y )
3425 uniqueSegments.insert( { pt0, poly } );
3426 uniqueSegments.insert( { pt1, poly } );
3434 auto setPinOrientation =
3450 if( uniqueSegments.count(
pin->GetPosition() ) )
3456 if( otherPt ==
pin->GetPosition() )
3457 otherPt = poly.
CPoint( 1 );
3468std::pair<VECTOR2I, VECTOR2I>
3476 if( upperLeft.
x > v.
End.
x )
3477 upperLeft.
x = v.
End.
x;
3479 if( upperLeft.
y < v.
End.
y )
3480 upperLeft.
y = v.
End.
y;
3482 if( lowerRight.
x < v.
End.
x )
3483 lowerRight.
x = v.
End.
x;
3485 if( lowerRight.
y > v.
End.
y )
3486 lowerRight.
y = v.
End.
y;
3493 if( upperLeft.
x > v.
End.
x )
3494 upperLeft.
x = v.
End.
x;
3496 if( upperLeft.
y < v.
End.
y )
3497 upperLeft.
y = v.
End.
y;
3499 if( lowerRight.
x < v.
End.
x )
3500 lowerRight.
x = v.
End.
x;
3502 if( lowerRight.
y > v.
End.
y )
3503 lowerRight.
y = v.
End.
y;
3510 VECTOR2I size = lowerRightKiCad - upperLeftKiCad;
3512 return { upperLeftKiCad,
VECTOR2I( abs( size.
x ), abs( size.
y ) ) };
3542 const double& aScalingFactor,
3544 const bool& aMirrorInvert )
3548 if( aScalingFactor != 1.0 )
3551 retVal -= aTransformCentre;
3552 retVal.
x =
KiROUND( retVal.
x * aScalingFactor );
3553 retVal.
y =
KiROUND( retVal.
y * aScalingFactor );
3554 retVal += aTransformCentre;
3558 MIRROR( retVal.
x, aTransformCentre.
x );
3560 if( !aRotation.
IsZero() )
3561 RotatePoint( retVal, aTransformCentre, aRotation );
3563 if( aMoveVector !=
VECTOR2I{ 0, 0 } )
3564 retVal += aMoveVector;
3572 return sqrt( ( (
double) aPoint.
x * (
double) aPoint.
x )
3573 + ( (
double) aPoint.
y * (
double) aPoint.
y ) );
constexpr EDA_IU_SCALE schIUScale
constexpr double SCH_IU_PER_MM
Schematic internal units 1=100nm.
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
@ OUTPUT_NOT_OR
Output pin not OR tieable.
@ TRISTATE_DRIVER
Tristate output pin.
@ OUTPUT_OR
Output pin OR tieable.
@ UNCOMMITTED
Uncommitted pin (default)
@ TRISTATE_INPUT
Tristate input pin.
@ TRISTATE_BIDIR
Tristate bi-directional driver pin.
@ OUTPUT_NOT_NORM_OR
Output pin not normally OR tieable.
#define SYMBOL_NAME_ATTRID
Symbol Name attribute ID - used for placement of designators on the schematic.
#define SIGNALNAME_ORIGIN_ATTRID
#define LINK_ORIGIN_ATTRID
const wxString PartAcceptanceFieldName
const wxString PartNumberFieldName
const wxString PartNameFieldName
const wxString PartVersionFieldName
Loads a csa file into a KiCad SCHEMATIC object.
constexpr Vec Centre() const
constexpr BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
constexpr coord_type GetLeft() const
constexpr coord_type GetRight() const
constexpr const SizeVec & GetSize() const
constexpr coord_type GetTop() const
constexpr coord_type GetBottom() const
@ ANTICLOCKWISE_SEMICIRCLE
static wxString EscapeFieldText(const wxString &aFieldText)
@ FRACTIONALGRID
Param1 = Units, Param2 = Divisor.
static const long FONT_BOLD
static const std::map< TEXT_FIELD_NAME, wxString > CADSTAR_TO_KICAD_FIELDS
Map between CADSTAR fields and KiCad text variables.
long TERMINAL_ID
Terminal is the pin identifier in the schematic.
TEXT_FIELD_NAME
These are special fields in text objects enclosed between the tokens '<@' and '>' such as <@[FIELD_NA...
ALIGNMENT
From CADSTAR Help: "Text Alignment enables you to define the position of an alignment origin for all ...
@ NO_ALIGNMENT
NO_ALIGNMENT has different meaning depending on the object type.
static const long UNDEFINED_VALUE
static wxString generateLibName(const wxString &aRefName, const wxString &aAlternateName)
wxString LAYER_ID
ID of a Sheet (if schematic) or board Layer (if PCB)
static void FixTextPositionNoAlignment(EDA_TEXT *aKiCadTextItem)
Correct the position of a text element that had NO_ALIGNMENT in CADSTAR.
@ OUTLINE
Unfilled closed shape.
@ OPENSHAPE
Unfilled open shape. Cannot have cutouts.
@ SOLID
Filled closed shape (solid fill).
@ HATCHED
Filled closed shape (hatch fill).
static const double TXT_HEIGHT_RATIO
CADSTAR fonts are drawn on a 24x24 integer matrix, where the each axis goes from 0 to 24.
void checkPoint()
Updates m_progressReporter or throws if user canceled.
static wxString HandleTextOverbar(wxString aCadstarString)
Convert a string with CADSTAR overbar characters to equivalent in KiCad.
JUSTIFICATION
From CADSTAR Help: "Multi Line Text can also be justified as Left, Centre or Right.
PROGRESS_REPORTER * m_progressReporter
bool CheckFileHeader(const std::filesystem::path &aPath) const
CADSTAR_PARTS_LIB_MODEL ReadFile(const std::filesystem::path &aPath) const
void loadItemOntoKiCadSheet(const LAYER_ID &aCadstarSheetID, SCH_ITEM *aItem)
void Load(SCHEMATIC *aSchematic, SCH_SHEET *aRootSheet)
Loads a CADSTAR Schematic Archive file into the KiCad SCHEMATIC object given.
ROUTECODE getRouteCode(const ROUTECODE_ID &aCadstarRouteCodeID)
static wxString CreateLibName(const wxFileName &aFileName, const SCH_SHEET *aRootSheet)
std::map< BLOCK_PIN_ID, SCH_HIERLABEL * > m_sheetPinMap
Cadstar->KiCad Sheet Pins.
const int SMALL_LABEL_SIZE
VECTOR2I applyTransform(const VECTOR2I &aPoint, const VECTOR2I &aMoveVector={ 0, 0 }, const EDA_ANGLE &aRotation=ANGLE_0, const double &aScalingFactor=1.0, const VECTOR2I &aTransformCentre={ 0, 0 }, const bool &aMirrorInvert=false)
std::map< SYMBOL_ID, SCH_GLOBALLABEL * > m_globalLabelsMap
Cadstar->KiCad Global Labels.
SCH_SYMBOL * loadSchematicSymbol(const SYMBOL &aCadstarSymbol, const LIB_SYMBOL &aKiCadPart, EDA_ANGLE &aComponentOrientation)
void applyTextSettings(EDA_TEXT *aKiCadTextItem, const TEXTCODE_ID &aCadstarTextCodeID, const ALIGNMENT &aCadstarAlignment, const JUSTIFICATION &aCadstarJustification, const long long aCadstarOrientAngle=0, bool aMirrored=false)
void loadSheetAndChildSheets(const LAYER_ID &aCadstarSheetID, const VECTOR2I &aPosition, const VECTOR2I &aSheetSize, const SCH_SHEET_PATH &aParentSheet)
wxString getAttributeName(const ATTRIBUTE_ID &aCadstarAttributeID)
std::vector< LIB_SYMBOL * > m_loadedSymbols
Loaded symbols so far.
static SCH_FIELD * addNewFieldToSymbol(const wxString &aFieldName, LIB_SYMBOL *aKiCadSymbol)
PART getPart(const PART_ID &aCadstarPartID)
std::vector< LAYER_ID > findOrphanSheets()
void setFootprintOnSymbol(LIB_SYMBOL *aKiCadSymbol, const wxString &aFootprintName, const wxString &aFootprintAlternate)
std::map< BUS_ID, std::shared_ptr< BUS_ALIAS > > m_busesMap
Cadstar->KiCad Buses.
SCH_TEXT * getKiCadSchText(const TEXT &aCadstarTextElement)
std::map< TERMINAL_ID, wxString > TERMINAL_TO_PINNUM_MAP
Map between a terminal ID in a symbol definition to the pin number that should be imported into KiCad...
wxString getNetName(const NET_SCH &aNet)
std::pair< BLOCK_ID, TERMINAL_ID > BLOCK_PIN_ID
std::map< SYMBOL_ID, SCH_SYMBOL * > m_powerSymMap
Cadstar->KiCad Power Symbols.
std::pair< PART_ID, GATE_ID > PART_GATE_ID
void loadDocumentationSymbols()
VECTOR2I getKiCadLibraryPoint(const VECTOR2I &aCadstarPoint, const VECTOR2I &aCadstarCentre)
std::vector< std::unique_ptr< LIB_SYMBOL > > m_ownedSymbols
Owns every LIB_SYMBOL the loader allocates while loading a design.
int getKiCadLength(long long aCadstarLength, double aDefaultInMils)
PART::DEFINITION::PIN getPartDefinitionPin(const PART &aCadstarPart, const GATE_ID &aGateID, const TERMINAL_ID &aTerminalID)
std::map< wxString, TERMINAL_ID > PINNUM_TO_TERMINAL_MAP
std::map< SYMDEF_ID, PINNUM_TO_TERMINAL_MAP > m_symDefTerminalsMap
int getTextHeightFromTextCode(const TEXTCODE_ID &aCadstarTextCodeID)
void loadChildSheets(const LAYER_ID &aCadstarSheetID, const SCH_SHEET_PATH &aSheet)
void applyToLibraryFieldAttribute(const ATTRIBUTE_LOCATION &aCadstarAttrLoc, const VECTOR2I &aSymbolOrigin, SCH_FIELD *aKiCadField)
double getPolarRadius(const VECTOR2I &aPoint)
void applyTextCodeIfExists(EDA_TEXT *aKiCadTextItem, const TEXTCODE_ID &aCadstarTextCodeID)
int getSheetNumber(const LAYER_ID &aCadstarSheetID)
int getLineThickness(const LINECODE_ID &aCadstarLineCodeID)
TEXTCODE getTextCode(const TEXTCODE_ID &aCadstarTextCodeID)
SPIN_STYLE getSpinStyle(const long long &aCadstarOrientation, bool aMirror)
std::map< wxString, LIB_SYMBOL * > m_powerSymLibMap
NetName->KiCad Power Lib Symbol.
std::map< std::pair< wxString, wxString >, SYMDEF_ID > m_SymDefNamesCache
Cache storing symbol names and alternates to symdef IDs.
std::map< PART_ID, TERMINAL_TO_PINNUM_MAP > m_pinNumsMap
Cadstar Part->KiCad Pin number map.
void loadHierarchicalSheetPins()
std::vector< LIB_SYMBOL * > LoadPartsLib(const wxString &aFilename)
ELECTRICAL_PINTYPE getKiCadPinType(const CADSTAR_PIN_TYPE &aPinType)
wxString m_footprintLibName
Name of the footprint library to prepend all footprints with.
std::map< PART_ID, LIB_SYMBOL * > m_partMap
Cadstar->KiCad Parts.
bool isAttributeVisible(const ATTRIBUTE_ID &aCadstarAttributeID)
VECTOR2I getKiCadPoint(const VECTOR2I &aCadstarPoint)
EDA_ANGLE getAngle(const long long &aCadstarAngle)
const double ARC_ACCURACY
std::map< wxString, SYMDEF_ID > m_DefaultSymDefNamesCache
Cache storing symbol names (default alternate) to symdef IDs.
void loadSymbolGateAndPartFields(const SYMDEF_ID &aSymdefID, const PART &aCadstarPart, const GATE_ID &aGateID, LIB_SYMBOL *aSymbol)
void loadFigure(const FIGURE &aCadstarFigure, const LAYER_ID &aCadstarSheetIDOverride, SCH_LAYER_ID aKiCadSchLayerID, const VECTOR2I &aMoveVector={ 0, 0 }, const EDA_ANGLE &aRotation=ANGLE_0, const double &aScalingFactor=1.0, const VECTOR2I &aTransformCentre={ 0, 0 }, const bool &aMirrorInvert=false)
std::map< PART_GATE_ID, SYMDEF_ID > m_partSymbolsMap
Map holding the symbols loaded so far for a particular PART_ID and GATE_ID.
LIB_SYMBOL * getScaledLibPart(const LIB_SYMBOL *aSymbol, long long aScalingFactorNumerator, long long aScalingFactorDenominator)
SYMDEF_ID getSymDefFromName(const wxString &aSymdefName, const wxString &aSymDefAlternate)
std::pair< VECTOR2I, VECTOR2I > getFigureExtentsKiCad(const FIGURE &aCadstarFigure)
std::map< LAYER_ID, SCH_SHEET * > m_sheetMap
Cadstar->KiCad Sheets.
void copySymbolItems(LIB_SYMBOL *aSourceSym, LIB_SYMBOL *aDestSym, int aDestUnit, bool aOverrideFields=true)
POINT getLocationOfNetElement(const NET_SCH &aNet, const NETELEMENT_ID &aNetElementID)
void fixUpLibraryPins(LIB_SYMBOL *aSymbolToFix, int aGateNumber)
std::map< SYMDEF_ID, std::unique_ptr< const LIB_SYMBOL > > m_symDefMap
Cadstar->KiCad Lib Symbols loaded so far.
std::unique_ptr< LIB_SYMBOL > loadLibPart(const CADSTAR_PART_ENTRY &aPart)
ALIGNMENT rotate180(const ALIGNMENT &aCadstarAlignment)
long long getCadstarAngle(const EDA_ANGLE &aAngle)
LINE_STYLE getLineStyle(const LINECODE_ID &aCadstarLineCodeID)
VECTOR2I m_designCenter
Required for calculating the offset to apply to the Cadstar design so that it fits in the KiCad canva...
ALIGNMENT mirrorX(const ALIGNMENT &aCadstarAlignment)
void loadLibrarySymbolShapeVertices(const std::vector< VERTEX > &aCadstarVertices, const VECTOR2I &aSymbolOrigin, LIB_SYMBOL *aSymbol, int aGateNumber, int aLineThickness, LINE_STYLE aLineStyle)
int getKiCadOffset(long long aCadstarOffset)
int getComponentOrientation(const EDA_ANGLE &aOrientAngle, EDA_ANGLE &aReturnedOrientation)
void loadShapeVertices(const std::vector< VERTEX > &aCadstarVertices, LINECODE_ID aCadstarLineCodeID, LAYER_ID aCadstarSheetID, SCH_LAYER_ID aKiCadSchLayerID, const VECTOR2I &aMoveVector={ 0, 0 }, const EDA_ANGLE &aRotation=ANGLE_0, const double &aScalingFactor=1.0, const VECTOR2I &aTransformCentre={ 0, 0 }, const bool &aMirrorInvert=false)
const LIB_SYMBOL * loadSymdef(const SYMDEF_ID &aSymdefID)
int getKiCadUnitNumberFromGate(const GATE_ID &aCadstarGateID)
void loadSymbolFieldAttribute(const ATTRIBUTE_LOCATION &aCadstarAttrLoc, const EDA_ANGLE &aComponentOrientation, bool aIsMirrored, SCH_FIELD *aKiCadField)
void loadSchematicSymbolInstances()
ASSIGNMENTS_SCM Assignments
CADSTAR_SCHEMATIC Schematic
int KiCadUnitDivider
Use this value to convert units in this CSA file to KiCad units.
PARTNAMECOL SymbolPartNameColor
void Parse()
Parses the file.
A base class for most all the KiCad significant classes used in schematics and boards.
virtual const BOX2I GetBoundingBox() const
Return the orthogonal bounding box of this object for display purposes.
KICAD_T Type() const
Returns the type of object.
EDA_ITEM * GetParent() const
virtual void SetParent(EDA_ITEM *aParent)
virtual void SetEnd(const VECTOR2I &aEnd)
void SetLineStyle(const LINE_STYLE aStyle)
SHAPE_POLY_SET & GetPolyShape()
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
virtual 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 SetPolyShape(const SHAPE_POLY_SET &aShape)
virtual void SetStart(const VECTOR2I &aStart)
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
virtual VECTOR2I GetTextSize() const
virtual void SetTextSize(VECTOR2I aNewSize, bool aEnforceMinTextSize=true)
virtual const wxString & GetText() const
Return the string associated with the text object.
virtual void SetTextPos(const VECTOR2I &aPoint)
virtual int GetTextHeight() const
void SetVertJustify(GR_TEXT_V_ALIGN_T aType)
virtual int GetTextWidth() const
virtual void SetTextWidth(int aWidth)
virtual void SetVisible(bool aVisible)
virtual void SetTextThickness(int aWidth)
The TextThickness is that set by the user.
virtual void SetTextHeight(int aHeight)
virtual EDA_ANGLE GetTextAngle() const
void SetBold(bool aBold)
Set the text to be bold - this will also update the font if needed.
virtual int GetTextThickness() const
virtual void SetText(const wxString &aText)
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
void SetItalic(bool aItalic)
Set the text to be italic - this will also update the font if needed.
void SetMultilineAllowed(bool aAllow)
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
ee_rtree::Iterator begin() const
Return a read/write iterator that points to the first.
ee_rtree::Iterator end() const
Return a read/write iterator that points to one past the last element in the EE_RTREE.
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.
static UTF8 FixIllegalChars(const UTF8 &aLibItemName, bool aLib)
Replace illegal LIB_ID item name characters with underscores '_'.
Define a library symbol object.
void GetFields(std::vector< SCH_FIELD * > &aList, bool aVisibleOnly=false) const override
Populate a std::vector with SCH_FIELDs, sorted in ordinal order.
std::vector< struct LIB_SYMBOL_UNIT > GetUnitDrawItems()
Return a list of SCH_ITEM objects separated by unit and convert number.
SCH_FIELD * GetField(const wxString &aFieldName)
Find a field within this symbol matching aFieldName; return nullptr if not found.
SCH_FIELD & GetFootprintField()
LIB_ITEMS_CONTAINER & GetDrawItems()
Return a reference to the draw item list.
wxString GetName() const override
void SetDescription(const wxString &aDescription)
Set the Description field text value.
SCH_FIELD & GetValueField()
void RemoveDrawItem(SCH_ITEM *aItem)
Remove draw aItem from list.
void SetFPFilters(const wxArrayString &aFilters)
std::vector< SCH_PIN * > GetPinsByNumber(const wxString &aNumber, int aUnit=0, int aBodyStyle=0)
Return all pin objects with the requested pin aNumber.
void AddField(SCH_FIELD *aField)
Add a field.
std::vector< SCH_PIN * > GetGraphicalPins(int aUnit=0, int aBodyStyle=0) const override
Graphical pins: Return schematic pin objects as drawn (unexpanded), filtered by unit/body.
void AddDrawItem(SCH_ITEM *aItem, bool aSort=true)
Add a new draw aItem to the draw object list and sort according to aSort.
virtual void SetName(const wxString &aName)
SCH_FIELD & GetReferenceField()
ITERATOR_BASE< SCH_ITEM, MULTIVECTOR< SCH_ITEM, FIRST_TYPE_VAL, LAST_TYPE_VAL >, typename ITEM_PTR_VECTOR::iterator > ITERATOR
ITERATOR begin(int aType=UNDEFINED_TYPE)
Describe the page size and margins of a paper page on which to eventually print or plot.
void SetHeightMils(double aHeightInMils)
const VECTOR2D GetSizeIU(double aIUScale) const
Gets the page size in internal units.
void SetWidthMils(double aWidthInMils)
Container for project specific data.
virtual std::map< wxString, wxString > & GetTextVars() const
Holds all the data relating to one schematic.
void SetSize(const VECTOR2I &aSize)
Class for a wire to bus entry.
virtual const wxString & GetText() const override
Return the string associated with the text object.
wxString GetName(bool aUseDefaultName=true) const
Return the field name (not translated).
void SetPosition(const VECTOR2I &aPosition) override
void SetText(const wxString &aText) override
void SetSpinStyle(SPIN_STYLE aSpinStyle) override
void SetSpinStyle(SPIN_STYLE aSpinStyle) override
Keeps wires of one net from touching pins, junctions and wire ends of other nets on import.
RESULT Route(const SEG &aWire, int aNet)
Detour a wire around foreign items lying on it and register the result as the wire's geometry.
bool TouchesOtherNet(const VECTOR2I &aPos, int aNet) const
Base class for any item which can be embedded within the SCHEMATIC container class,...
SCH_ITEM * Duplicate(bool addToParentGroup, SCH_COMMIT *aCommit=nullptr, bool aDoClone=false) const
Routine to create a new copy of given item.
void SetLayer(SCH_LAYER_ID aLayer)
virtual void SetUnit(int aUnit)
VECTOR2I GetPosition() const override
void SetPosition(const VECTOR2I &aPosition) override
void SetShape(LABEL_FLAG_SHAPE aShape)
void SetPosition(const VECTOR2I &aPosition) override
void AutoplaceFields(SCH_SCREEN *aScreen, AUTOPLACE_ALGO aAlgo) override
virtual void SetSpinStyle(SPIN_STYLE aSpinStyle)
Segment description base class to describe items which have 2 end points (track, wire,...
void SetStartPoint(const VECTOR2I &aPosition)
void SetLineWidth(const int aSize)
VECTOR2I GetEndPoint() const
VECTOR2I GetStartPoint() const
void SetLineStyle(const LINE_STYLE aStyle)
void SetEndPoint(const VECTOR2I &aPosition)
const PAGE_INFO & GetPageSettings() const
void Append(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
void AddBusAlias(std::shared_ptr< BUS_ALIAS > aAlias)
Add a bus alias definition.
void SetPageSettings(const PAGE_INFO &aPageSettings)
EE_RTREE & Items()
Get the full RTree, usually for iterating.
void SetFileName(const wxString &aFileName)
Set the file name for this screen to aFileName.
void Update(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
Refresh a changed item in the tree and invalidate connectivity.
void SetPosition(const VECTOR2I &aPos) override
void SetStroke(const STROKE_PARAMS &aStroke) override
void AddPoint(const VECTOR2I &aPosition)
VECTOR2I GetPosition() const override
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
void SetPageNumber(const wxString &aPageNumber)
Set the sheet instance user definable page number.
SCH_SHEET * Last() const
Return a pointer to the last SCH_SHEET of the list.
void push_back(SCH_SHEET *aSheet)
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.
void AddPin(SCH_SHEET_PIN *aSheetPin)
Add aSheetPin to the sheet.
std::vector< SCH_FIELD > & GetFields()
Return a reference to the vector holding the sheet's fields.
SCH_FIELD * GetField(FIELD_T aFieldType)
Return a mandatory field in this sheet.
SCH_SCREEN * GetScreen() const
VECTOR2I GetPosition() const override
void SetFields(const std::vector< SCH_FIELD > &aFields)
Set multiple schematic fields.
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
static bool ClassOf(const EDA_ITEM *aItem)
void AutoplaceFields(SCH_SCREEN *aScreen, AUTOPLACE_ALGO aAlgo) override
void SetPosition(const VECTOR2I &aPosition) override
void UpdatePins()
Updates the cache of SCH_PIN objects for each pin.
void SetRef(const SCH_SHEET_PATH *aSheet, const wxString &aReference)
Set the base 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...
std::vector< SCH_PIN * > GetLibPins() const
Populate a vector with all the pins from the library object that match the current unit and bodyStyle...
SCH_FIELD * AddField(const SCH_FIELD &aField)
Add a field to the symbol.
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
VECTOR2I GetPinPhysicalPosition(const SCH_PIN *Pin) const
SCH_FIELD * GetField(FIELD_T aFieldType)
Return a mandatory field in this symbol.
VECTOR2I GetPosition() const override
void SetPosition(const VECTOR2I &aPosition) override
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
const VECTOR2I & GetArcMid() const
const VECTOR2I & GetP1() const
const VECTOR2I & GetP0() const
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
int Intersect(const SEG &aSeg, std::vector< INTERSECTION > &aIp) const
Find all intersection points between our line chain and the segment aSeg.
const SHAPE_LINE_CHAIN Reverse() const
Reverse point order in the line chain.
void SetPoint(int aIndex, const VECTOR2I &aPos)
Move a point to a specific location.
int FindSegment(const VECTOR2I &aP, int aThreshold=1) const
Search for segment containing point aP.
int PointCount() const
Return the number of points (vertices) in this line chain.
void Replace(int aStartIndex, int aEndIndex, const VECTOR2I &aP)
Replace points with indices in range [start_index, end_index] with a single point aP.
virtual size_t GetPointCount() const override
void Append(int aX, int aY, bool aAllowDuplication=false)
Append a new point at the end of the line chain.
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
const VECTOR2I NearestPoint(const VECTOR2I &aP, bool aAllowInternalShapePoints=true) const
Find a point on the line chain that is closest to point aP.
const std::vector< VECTOR2I > & CPoints() const
bool IsEmpty() const
Return true if the set is empty (no polygons at all)
SHAPE_LINE_CHAIN & Outline(int aIndex)
Return the reference to aIndex-th outline in the set.
Spin style for labels of all kinds on schematics.
SPIN_STYLE MirrorX()
Mirror the label spin style across the X axis or simply swaps up and bottom.
SPIN_STYLE MirrorY()
Mirror the label spin style across the Y axis or simply swaps left and right.
Simple container to manage line stroke parameters.
virtual void SetShowPinNumbers(bool aShow)
Set or clear the pin number visibility flag.
virtual void SetShowPinNames(bool aShow)
Set or clear the pin name visibility flag.
T EuclideanNorm() const
Compute the Euclidean norm of the vector, which is defined as sqrt(x ** 2 + y ** 2).
#define DEFAULT_WIRE_WIDTH_MILS
The default wire width in mils. (can be changed in preference menu)
static constexpr EDA_ANGLE ANGLE_0
static constexpr EDA_ANGLE ANGLE_90
static constexpr EDA_ANGLE ANGLE_VERTICAL
static constexpr EDA_ANGLE ANGLE_HORIZONTAL
static constexpr EDA_ANGLE ANGLE_45
static constexpr EDA_ANGLE ANGLE_270
static constexpr EDA_ANGLE ANGLE_180
static constexpr EDA_ANGLE ANGLE_135
@ FILLED_WITH_BG_BODYCOLOR
@ FILLED_SHAPE
Fill with object color.
#define IGNORE_PARENT_GROUP
#define THROW_IO_ERROR(msg)
macro which captures the "call site" values of FILE_, __FUNCTION & LINE
#define THROW_IO_ERRORF(msg,...)
static const std::string KiCadSchematicFileExtension
SCH_LAYER_ID
Eeschema drawing layers.
MULTIVECTOR< SCH_ITEM, SCH_SHAPE_T, SCH_PIN_T > LIB_ITEMS_CONTAINER
This file contains miscellaneous commonly used macros and functions.
#define KI_FALLTHROUGH
The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely fallthrough from ...
constexpr void MIRROR(T &aPoint, const T &aMirrorRef)
Updates aPoint with the mirror of aPoint relative to the aMirrorRef.
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
ELECTRICAL_PINTYPE
The symbol library pin object electrical types used in ERC tests.
@ PT_INPUT
usual pin input: must be connected
@ PT_BIDI
input or output (like port for a microprocessor)
@ PT_OPENCOLLECTOR
pin type open collector
@ PT_POWER_IN
power input (GND, VCC for ICs). Must be connected to a power output.
@ PT_UNSPECIFIED
unknown electrical properties: creates always a warning when connected
@ PT_PASSIVE
pin for passive symbols: must be connected, and can be connected to any pin.
@ PIN_UP
The pin extends upwards from the connection point: Probably on the bottom side of the symbol.
@ PIN_RIGHT
The pin extends rightwards from the connection point.
@ PIN_LEFT
The pin extends leftwards from the connection point: Probably on the right side of the symbol.
@ PIN_DOWN
The pin extends downwards from the connection: Probably on the top side of the symbol.
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
void wxStringSplit(const wxString &aText, wxArrayString &aStrings, wxChar aSplitter)
Split aString to a string list separated at aSplitter.
bool ReplaceIllegalFileNameChars(std::string &aName, int aReplaceChar)
Checks aName for illegal file name characters.
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...
LINE_STYLE
Dashed line types.
JUSTIFICATION Justification
Note: Justification has no effect on single lines of text.
ALIGNMENT Alignment
In CADSTAR The default alignment for a TEXT object (when "(No Alignment()" is selected) Bottom Left o...
ATTRIBUTE_LOCATION AttributeLocation
bool HasLocation
Flag to know if this ATTRIBUTE_VALUE has a location i.e.
Represent a cutout in a closed shape (e.g.
std::vector< VERTEX > Vertices
long ScaleRatioNumerator
Documentation symbols can be arbitrarily scaled when added to a design.
long ScaleRatioDenominator
Documentation symbols can be arbitrarily scaled when added to a design.
POINT Origin
Origin of the component (this is used as the reference point when placing the component in the design...
LAYER_ID LayerID
Move all objects in the Symdef to this layer.
DOCUMENTATION_SYMBOL_ID ID
SYMDEF_ID SymdefID
Normally documentation symbols only have TEXT, FIGURE and TEXT_LOCATION objects which are all drawn o...
long Modifier1
It seems this is related to weight. 400=Normal, 700=Bold.
wxString Name
This is undefined (wxEmptyString) if the net is unnamed.
long SignalNum
This is undefined if the net has been given a name.
bool HidePinNames
Specifies whether to display the pin names/identifier in the schematic symbol or not.
std::map< GATE_ID, GATE > GateSymbols
std::map< ATTRIBUTE_ID, ATTRIBUTE_VALUE > AttributeValues
Some attributes are defined within the part definition, whilst others are defined in the part.
std::map< PART_DEFINITION_PIN_ID, PIN > Pins
std::map< ATTRIBUTE_ID, ATTRIBUTE_VALUE > AttributeValues
Some attributes are defined within the part definition, whilst others are defined in the part itself.
Represent a point in x,y coordinates.
SHAPE_POLY_SET ConvertToPolySet(const std::function< VECTOR2I(const VECTOR2I &)> aCadstarToKicadPointCallback, int aAccuracy) const
std::vector< VERTEX > Vertices
std::vector< CUTOUT > Cutouts
Not Applicable to OPENSHAPE Type.
std::map< FIGURE_ID, FIGURE > Figures
std::map< ATTRIBUTE_ID, TEXT_LOCATION > TextLocations
This contains location of any attributes, including designator position.
POINT Origin
Origin of the component (this is used as the reference point when placing the component in the design...
wxString Alternate
This is in addition to ReferenceName.
std::map< TEXT_ID, TEXT > Texts
std::map< ATTRIBUTE_ID, ATTRIBUTE_VALUE > AttributeValues
These attributes might also have a location.
wxString BuildLibName() const
long Width
Defaults to 0 if using system fonts or, if using CADSTAR font, defaults to equal height (1:1 aspect r...
Corresponds to CADSTAR "origin".
ALIGNMENT Alignment
In CADSTAR The default alignment for a TEXT object (when "(No Alignment)" is selected) Bottom Left of...
JUSTIFICATION Justification
Note: has no effect on single lines of text.
< Nodename = "VARIANT" or "VMASTER" (master variant
Represents a vertex in a shape.
SHAPE_ARC BuildArc(const VECTOR2I &aPrevPoint, const std::function< VECTOR2I(const VECTOR2I &)> aCadstarToKicadPointCallback) const
void AppendToChain(SHAPE_LINE_CHAIN *aChainToAppendTo, const std::function< VECTOR2I(const VECTOR2I &)> aCadstarToKicadPointCallback, int aAccuracy) const
CADSTAR Parts Library (*.lib) model - a data structure describing the contents of the file format.
std::vector< CADSTAR_PART_ENTRY > m_PartEntries
std::string m_ComponentStem
std::map< std::string, std::vector< CADSTAR_PART_PIN > > m_HiddenPins
Pins with an implied electrical connection to a net, not part of any symbol (Note: we probably will n...
std::map< std::string, CADSTAR_ATTRIBUTE_VALUE > m_SchAttributes
Dollar sign ($) line $[!]<SCM Attribute name>(<Attribute value>) Attributes related to the schematic ...
std::map< std::string, CADSTAR_ATTRIBUTE_VALUE > m_SchAndPcbAttributes
At symbol (@) line [@[!]<SCM/PCB Attribute name>(<Attribute value>)] Attributes related to the PCB co...
std::vector< CADSTAR_PART_SYMBOL_ENTRY > m_Symbols
Symbols that form this part.
std::map< std::string, std::string > m_UserAttributes
Star (*) line *<User-defined name> <Value> This line is ignored by CADSTAR.
std::map< long, std::string > m_PinNamesMap
Map of pin identifiers to alphanumeric pin names.
std::optional< std::string > m_AcceptancePartName
std::optional< std::string > m_Pcb_alternate
std::optional< std::string > m_Version
std::optional< std::string > m_Description
std::optional< std::string > m_Number
std::string m_Pcb_component
std::optional< std::string > m_SpiceModel
std::map< std::string, CADSTAR_ATTRIBUTE_VALUE > m_PcbAttributes
Percentage sign (%) line %[!]<PCB Attribute name>(<Attribute value>) Attributes related to the PCB co...
std::optional< std::string > m_Value
std::map< std::string, CADSTAR_ATTRIBUTE_VALUE > m_PartAttributes
Tilde (~) line ~[!]<Parts Library Attribute Name>(<Attribute Value>) Attributes related to the Part i...
std::map< long, std::string > m_PinLabelsMap
Map of pin identifiers to alphanumeric pin labels.
std::vector< CADSTAR_PART_PIN > m_Pins
std::optional< std::string > m_SymbolAlternateName
TYPE Type
Determines what the associated layer is, whether parent, child or clone.
ATTRIBUTE_LOCATION BlockLabel
LAYER_ID LayerID
The sheet block is on (TODO: verify this is true)
LAYER_ID AssocLayerID
Parent or Child linked sheet.
std::map< TERMINAL_ID, TERMINAL > Terminals
std::map< FIGURE_ID, FIGURE > Figures
LAYER_ID LayerID
Sheet on which bus is located.
ATTRIBUTE_LOCATION AttrLoc
std::map< NETELEMENT_ID, DANGLER > Danglers
std::map< NETELEMENT_ID, SYM_TERM > Terminals
std::vector< CONNECTION_SCH > Connections
std::map< NETELEMENT_ID, BUS_TERM > BusTerminals
std::map< NETELEMENT_ID, BLOCK_TERM > BlockTerminals
std::map< NETELEMENT_ID, JUNCTION_SCH > Junctions
ATTRIBUTE_LOCATION AttrLoc
LAYER_ID LayerID
Sheet on which symbol is located.
SYMBOL_ID VariantParentSymbolID
std::map< ATTRIBUTE_ID, ATTRIBUTE_VALUE > AttributeValues
GATE_ID GateID
The gate this symbol represents within the associated Part.
long ScaleRatioNumerator
Symbols can be arbitrarily scaled in CADSTAR.
std::map< TERMINAL_ID, SYMPINNAME_LABEL > PinNames
Identifier of the pin in the PCB Equivalent to KiCad's Pin Number.
std::map< TERMINAL_ID, PIN_NUM > PinNumbers
This seems to only appear in older designs and is similar to PinNames but only allowing numerical val...
long ScaleRatioDenominator
SYMBOLVARIANT SymbolVariant
std::map< TERMINAL_ID, PIN_NUM_LABEL_LOC > PinLabelLocations
std::map< TERMINAL_ID, PIN_NUM_LABEL_LOC > PinNumberLocations
std::map< TERMINAL_ID, TERMINAL > Terminals
POINT Position
Pad position within the component's coordinate frame.
@ USER
The field ID hasn't been set yet; field is invalid.
@ REFERENCE
Field Reference of part, i.e. "IC21".
@ VALUE
Field Value of part, i.e. "3.3K".
static EDA_ORIENTATION orientation(double d)
wxString result
Test unit parsing edge cases and error handling.
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Calculate the new point of coord coord pX, pY, for a rotation center 0, 0.
constexpr int sign(T val)
VECTOR2< int32_t > VECTOR2I
constexpr int LexicographicalCompare(const VECTOR2< T > &aA, const VECTOR2< T > &aB)
Definition of file extensions used in Kicad.