57 const wxFileName& aLibraryFileName )
71 constexpr long long maxDesignSizekicad = std::numeric_limits<int>::max();
73 if( designSizeXkicad > maxDesignSizekicad || designSizeYkicad > maxDesignSizekicad )
76 _(
"The design is too large and cannot be imported into KiCad. \n"
77 "Please reduce the maximum design size in CADSTAR by navigating to: \n"
78 "Design Tab -> Properties -> Design Options -> Maximum Design Size. \n"
79 "Current Design size: %.2f, %.2f millimeters. \n"
80 "Maximum permitted design size: %.2f, %.2f millimeters.\n" ),
131 "no KiCad equivalent. Only the master variant "
132 "('%s') was loaded." ),
139 m_reporter->
Report(
_(
"The CADSTAR design contains grouped items which has no KiCad "
140 "equivalent. Any grouped items have been ungrouped." ),
146 m_reporter->
Report(
_(
"The CADSTAR design contains re-use blocks which has no KiCad "
147 "equivalent. The re-use block information has been discarded during "
154 for( std::pair<LAYER_ID, SCH_SHEET*> sheetPair :
m_sheetMap )
159 BOX2I sheetBoundingBox;
174 if( field.IsVisible() )
175 bbox.
Merge( field.GetBoundingBox() );
181 wxString txt = txtItem->
GetText();
183 if( txt.Contains(
"${" ) )
190 bbox = item->GetBoundingBox();
193 sheetBoundingBox.
Merge( bbox );
206 auto roundToNearestGrid =
207 [&](
int aNumber ) ->
int
209 int error = aNumber %
grid;
210 int absError =
sign( error ) * error;
212 if( absError > (
grid / 2 ) )
213 return aNumber + (
sign( error ) *
grid ) - error;
215 return aNumber - error;
221 wxSize targetSheetSize = (wxSize)sheetBoundingBox.
GetSize();
222 int longestSide = std::max( targetSheetSize.x, targetSheetSize.y );
223 int margin = ( (double) longestSide * 0.03 );
224 margin = roundToNearestGrid( margin );
225 targetSheetSize.IncBy( margin * 2, margin * 2 );
236 VECTOR2I sheetcentre( pageSizeIU.x / 2, pageSizeIU.y / 2 );
240 VECTOR2I translation = sheetcentre - itemsCentre;
241 translation.
x = roundToNearestGrid( translation.
x );
242 translation.
y = roundToNearestGrid( translation.
y );
245 std::vector<SCH_ITEM*> allItems;
248 std::back_inserter( allItems ) );
252 item->Move( translation );
260 m_reporter->
Report(
_(
"CADSTAR fonts are different to the ones in KiCad. This will likely "
261 "result in alignment issues. Please review the imported text elements "
262 "carefully and correct manually if required." ),
266 "Please review the import errors and warnings (if any)." ) );
277 if( orphanSheets.size() > 1 )
282 for(
LAYER_ID sheetID : orphanSheets )
298 else if( orphanSheets.size() > 0 )
300 LAYER_ID rootSheetID = orphanSheets.at( 0 );
302 wxFileName loadedFilePath = wxFileName(
Filename );
305 loadedFilePath.GetName(),
318 THROW_IO_ERROR(
_(
"The CADSTAR schematic might be corrupt: there is no root sheet." ) );
327 BLOCK& block = blockPair.second;
330 if( block.
Type == BLOCK::TYPE::PARENT )
332 else if( block.
Type == BLOCK::TYPE::CHILD )
341 for( std::pair<TERMINAL_ID, TERMINAL> termPair : block.
Terminals )
344 wxString
name =
"YOU SHOULDN'T SEE THIS TEXT. THIS IS A BUG.";
348 if( block.
Type == BLOCK::TYPE::PARENT )
350 else if( block.
Type == BLOCK::TYPE::CHILD )
375 PART_ID partID = partPair.first;
376 PART part = partPair.second;
386 GATE_ID gateID = gatePair.first;
387 PART::DEFINITION::GATE gate = gatePair.second;
390 if( symbolID.IsEmpty() )
393 "'%s' (alternate '%s') which could not be "
394 "found in the symbol library. The part has "
395 "not been loaded into the KiCad library." ),
416 m_partMap.insert( { partID, loadedPart } );
424 " symbol definitions are associated with it). The part"
425 " has not been loaded into the KiCad library." ),
445 SYMBOL sym = symPair.second;
455 "could not be found in the library. The "
456 "symbol was not loaded" ),
464 if( sym.
GateID.IsEmpty() )
517 partname.Replace( wxT(
"\n" ), wxT(
"\\n" ) );
518 partname.Replace( wxT(
"\r" ), wxT(
"\\r" ) );
519 partname.Replace( wxT(
"\t" ), wxT(
"\\t" ) );
520 partField->
SetText( partname );
543 wxASSERT( attrField->
GetName() == attrName );
545 attrVal.
Value.Replace( wxT(
"\n" ), wxT(
"\\n" ) );
546 attrVal.
Value.Replace( wxT(
"\r" ), wxT(
"\\r" ) );
547 attrVal.
Value.Replace( wxT(
"\t" ), wxT(
"\\t" ) );
561 _(
"Symbol ID '%s' references library symbol '%s' which could not be "
562 "found in the library. Did you export all items of the design?" ),
571 _(
"Symbol ID '%s' is a signal reference or global signal but it has too "
572 "many pins. The expected number of pins is 1 but %d were found." ),
594 wxString libPartName = libraryNetName;
600 if( libPartName != symbolInstanceNetName )
602 libPartName += wxT(
" (" ) + symbolInstanceNetName + wxT(
")" );
665 netLabel->
SetText(
"***UNKNOWN NET****" );
679 if( libSymDef.
Alternate.Lower().Contains(
"in" ) )
681 else if( libSymDef.
Alternate.Lower().Contains(
"bi" ) )
683 else if( libSymDef.
Alternate.Lower().Contains(
"out" ) )
693 screen->
Append( netLabel );
698 wxASSERT_MSG(
false,
"Unknown Symbol Variant." );
704 "neither a symbol or a net power / symbol. "
705 "The symbol was not loaded." ),
714 if( symbolName.empty() )
720 "CADSTAR schematic but this is not supported "
721 "in KiCad. When the symbol is reloaded from "
722 "the library, it will revert to the original "
736 BUS bus = busPair.second;
740 if( bus.
LayerID != wxT(
"NO_SHEET" ) )
743 std::shared_ptr<BUS_ALIAS> kiBusAlias = std::make_shared<BUS_ALIAS>();
745 kiBusAlias->SetName( bus.
Name );
746 kiBusAlias->SetParent( screen );
754 label->
SetText( wxT(
"{" ) + busname + wxT(
"}" ) );
805 label->
SetText( wxT(
"{" ) + busname + wxT(
"}" ) );
820 wxString netName = net.
Name;
821 std::map<NETELEMENT_ID, SCH_LABEL*> netlabels;
823 if( netName.IsEmpty() )
828 for( std::pair<NETELEMENT_ID, NET_SCH::SYM_TERM> terminalPair : net.
Terminals )
830 NET_SCH::SYM_TERM netTerm = terminalPair.second;
839 if( netTerm.HasNetLabel )
845 netTerm.NetLabel.TextCodeID,
846 netTerm.NetLabel.Alignment,
847 netTerm.NetLabel.Justification,
848 netTerm.NetLabel.OrientAngle,
849 netTerm.NetLabel.Mirror );
867 && netTerm.HasNetLabel )
877 applyTextSettings( label, netTerm.NetLabel.TextCodeID, netTerm.NetLabel.Alignment,
878 netTerm.NetLabel.Justification );
880 netlabels.insert( { netTerm.ID, label } );
883 m_sheetMap.at( sheet )->GetScreen()->Append( label );
887 auto getHierarchicalLabel =
890 if( aNode.Contains(
"BLKT" ) )
893 BLOCK_PIN_ID blockPinID = std::make_pair( blockTerm.BlockID,
894 blockTerm.TerminalID );
904 for( std::pair<NETELEMENT_ID, NET_SCH::BLOCK_TERM> blockPair : net.
BlockTerminals )
906 SCH_HIERLABEL* label = getHierarchicalLabel( blockPair.first );
913 for( std::pair<NETELEMENT_ID, NET_SCH::BUS_TERM> busPair : net.
BusTerminals )
915 NET_SCH::BUS_TERM busTerm = busPair.second;
919 m_busesMap.at( bus.
ID )->Members().emplace_back( netName );
926 busEntry->
SetSize( wxSize( size.
x, size.
y ) );
939 if( busTerm.HasNetLabel )
942 busTerm.NetLabel.TextCodeID,
943 busTerm.NetLabel.Alignment,
944 busTerm.NetLabel.Justification );
951 netlabels.insert( { busTerm.ID, label } );
955 for( std::pair<NETELEMENT_ID, NET_SCH::DANGLER> danglerPair : net.
Danglers )
957 NET_SCH::DANGLER dangler = danglerPair.second;
963 if( dangler.HasNetLabel )
966 dangler.NetLabel.TextCodeID,
967 dangler.NetLabel.Alignment,
968 dangler.NetLabel.Justification );
972 netlabels.insert( { dangler.ID, label } );
974 m_sheetMap.at( dangler.LayerID )->GetScreen()->Append( label );
977 for( NET_SCH::CONNECTION_SCH conn : net.
Connections )
979 if( conn.LayerID == wxT(
"NO_SHEET" ) )
990 if( conn.Path.size() < 1 || conn.Path.front() != start )
991 conn.Path.insert( conn.Path.begin(), start );
993 if( conn.Path.size() < 2 || conn.Path.back() != end )
994 conn.Path.push_back( end );
997 bool secondPt =
false;
1003 for(
POINT pt : conn.Path )
1013 std::vector<NETELEMENT_ID> nodes;
1014 nodes.push_back( conn.StartNode );
1015 nodes.push_back( conn.EndNode );
1027 wxSize sheetSize = parentSheet->
GetSize();
1030 int leftSide = sheetPosition.
x;
1031 int rightSide = sheetPosition.
x + sheetSize.x;
1032 int topSide = sheetPosition.
y;
1033 int botSide = sheetPosition.
y + sheetSize.y;
1037 sheetEdge.
Append( leftSide, topSide );
1038 sheetEdge.
Append( rightSide, topSide );
1039 sheetEdge.
Append( rightSide, botSide );
1040 sheetEdge.
Append( leftSide, botSide );
1041 sheetEdge.
Append( leftSide, topSide );
1045 if( !wireChain.
Intersect( sheetEdge, wireToSheetIntersects ) )
1050 if( node == conn.StartNode )
1051 wireChain = wireChain.
Reverse();
1055 if( node == conn.StartNode )
1056 wireChain = wireChain.
Reverse();
1062 VECTOR2I intsctPt = wireToSheetIntersects.at( 0 ).p;
1063 int intsctIndx = wireChain.
FindSegment( intsctPt );
1064 wxASSERT_MSG( intsctIndx != -1,
"Can't find intersecting segment" );
1066 if( node == conn.StartNode )
1067 wireChain.
Replace( 0, intsctIndx, intsctPt );
1069 wireChain.
Replace( intsctIndx + 1, -1, intsctPt );
1077 auto fixNetLabelsAndSheetPins =
1082 if( netlabels.find( aNetEleID ) != netlabels.end() )
1083 netlabels.at( aNetEleID )->SetTextSpinStyle( spin.
MirrorY() );
1085 SCH_HIERLABEL* sheetPin = getHierarchicalLabel( aNetEleID );
1107 fixNetLabelsAndSheetPins( wireAngle, conn.StartNode );
1116 if( !conn.ConnectionLineCode.IsEmpty() )
1121 m_sheetMap.at( conn.LayerID )->GetScreen()->Append( wire );
1128 fixNetLabelsAndSheetPins( wireAngle, conn.EndNode );
1132 for( std::pair<NETELEMENT_ID, NET_SCH::JUNCTION_SCH> juncPair : net.
Junctions )
1134 NET_SCH::JUNCTION_SCH junc = juncPair.second;
1139 m_sheetMap.at( junc.LayerID )->GetScreen()->Append( kiJunc );
1141 if( junc.HasNetLabel )
1154 m_sheetMap.at( junc.LayerID )->GetScreen()->Append( label );
1165 FIGURE fig = figPair.second;
1176 TEXT txt = textPair.second;
1186 for( std::pair<DOCUMENTATION_SYMBOL_ID, DOCUMENTATION_SYMBOL> docSymPair :
1194 "definition ID '%s' which does not exist in "
1195 "the library. The symbol was not loaded." ),
1208 bool mirrorInvert = docSym.
Mirror;
1210 for( std::pair<FIGURE_ID, FIGURE> figPair : docSymDef.
Figures )
1212 FIGURE fig = figPair.second;
1215 centreOfTransform, mirrorInvert );
1218 for( std::pair<TEXT_ID, TEXT> textPair : docSymDef.
Texts )
1220 TEXT txt = textPair.second;
1222 txt.
Mirror = ( txt.
Mirror ) ? !mirrorInvert : mirrorInvert;
1228 scalingFactor, centreOfTransform, mirrorInvert );
1247 auto findAndReplaceTextField =
1271 std::map<wxString, wxString>& txtVars = pj->
GetTextVars();
1287 wxString varValue = txtvalue.second;
1289 txtVars.insert( { varName, varValue } );
1294 wxString varName = txtvalue.first;
1295 wxString varValue = txtvalue.second;
1297 txtVars.insert( { varName, varValue } );
1302 m_reporter->
Report(
_(
"Text Variables could not be set as there is no project attached." ),
1318 std::vector<LIB_ITEM*> drawItems = aSymbol->
GetUnitDrawItems( gateNumber, 0 );
1323 for( std::pair<FIGURE_ID, FIGURE> figPair : symbol.
Figures )
1325 FIGURE fig = figPair.second;
1340 return getKiCadLibraryPoint( aPt, symbol.Origin );
1361 for( std::pair<TERMINAL_ID, TERMINAL> termPair : symbol.
Terminals )
1365 wxString pinName = wxEmptyString;
1375 if( pinNum.IsEmpty() )
1377 if( !csPin.Identifier.IsEmpty() )
1378 pinNum = csPin.Identifier;
1387 pinNumMap.insert( { term.
ID, pinNum } );
1396 pin->SetLength( 0 );
1398 pin->SetUnit( gateNumber );
1399 pin->SetNumber( pinNum );
1400 pin->SetName( pinName );
1417 pin->SetNumberTextSize( pinNumberHeight );
1418 pin->SetNameTextSize( pinNameHeight );
1422 pin->SetVisible(
false );
1433 m_pinNumsMap.insert( { aCadstarPart->
ID + aGateID, pinNumMap } );
1435 for( std::pair<TEXT_ID, TEXT> textPair : symbol.
Texts )
1437 TEXT csText = textPair.second;
1441 libtext->
SetUnit( gateNumber );
1453 if( csText.
Text.Contains(
"\n" ) )
1455 wxArrayString strings;
1457 wxPoint firstLinePos;
1459 for(
size_t ii = 0; ii < strings.size(); ++ii )
1507 field =
new LIB_FIELD( aSymbol, fieldID );
1517 wxString partName = aCadstarPart->
Name;
1518 partName.Replace( wxT(
"\n" ), wxT(
"\\n" ) );
1519 partName.Replace( wxT(
"\r" ), wxT(
"\\r" ) );
1520 partName.Replace( wxT(
"\t" ), wxT(
"\\t" ) );
1530 wxString footprintRefName = wxEmptyString;
1531 wxString footprintAlternateName = wxEmptyString;
1533 auto loadLibraryField =
1539 aAttributeVal.Value.Replace( wxT(
"\n" ), wxT(
"\\n" ) );
1540 aAttributeVal.Value.Replace( wxT(
"\r" ), wxT(
"\\r" ) );
1541 aAttributeVal.Value.Replace( wxT(
"\t" ), wxT(
"\\t" ) );
1547 if( attrName == wxT(
"(PartDefinitionNameStem)" ) )
1550 aAttributeVal.Value.Replace( wxT(
" " ),
"_" );
1554 else if( attrName == wxT(
"(PartDescription)" ) )
1559 else if( attrName == wxT(
"(PartDefinitionReferenceName)" ) )
1561 footprintRefName = aAttributeVal.Value;
1564 else if( attrName == wxT(
"(PartDefinitionAlternateName)" ) )
1566 footprintAlternateName = aAttributeVal.Value;
1575 attrField =
new LIB_FIELD( aSymbol, fieldID );
1576 attrField->
SetName( attrName );
1580 wxASSERT( attrField->
GetName() == attrName );
1581 attrField->
SetText( aAttributeVal.Value );
1582 attrField->
SetUnit( gateNumber );
1587 if( aAttributeVal.HasLocation )
1593 else if( symbol.
TextLocations.find( aAttributeVal.AttributeID )
1621 loadLibraryField( attrVal );
1625 for( std::pair<ATTRIBUTE_ID, ATTRIBUTE_VALUE> attr : aCadstarPart->
AttributeValues )
1628 loadLibraryField( attrVal );
1631 wxString fpNameInLibrary =
generateLibName( footprintRefName, footprintAlternateName );
1633 if( !fpNameInLibrary.IsEmpty() )
1635 wxArrayString fpFilters;
1636 fpFilters.Add( fpNameInLibrary );
1640 wxFileName schFilename(
Filename );
1641 wxString libName = schFilename.GetName();
1655 wxPoint aSymbolOrigin,
1658 int aLineThickness )
1660 const VERTEX* prev = &aCadstarVertices.at( 0 );
1665 for(
size_t i = 1; i < aCadstarVertices.size(); i++ )
1667 cur = &aCadstarVertices.at( i );
1678 centerPoint = ( startPoint + endPoint ) / 2;
1708 shape->
SetEnd( startPoint );
1713 shape->
SetEnd( endPoint );
1719 shape->
SetUnit( aGateNumber );
1738 aCadstarAttrLoc.
Mirror );
1763 int compOrientation = 0;
1765 if( aCadstarSymbol.
Mirror )
1767 compAngle = -compAngle;
1773 EDA_ANGLE test2( aComponentOrientation );
1778 "degrees in the original CADSTAR design but "
1779 "KiCad only supports rotation angles multiples "
1780 "of 90 degrees. The connecting wires will need "
1792 "not exist in the design. The symbol was not "
1802 wxString gate = ( aCadstarSymbol.
GateID.IsEmpty() ) ? wxT(
"A" ) : aCadstarSymbol.
GateID;
1803 wxString partGateIndex = aCadstarSymbol.
PartRef.
RefID + gate;
1810 std::map<wxString, LIB_PIN*> pinNumToLibPinMap;
1812 for(
auto& term : termNumMap )
1814 wxString pinNum = term.second;
1815 pinNumToLibPinMap.insert( { pinNum,
1819 auto replacePinNumber =
1820 [&]( wxString aOldPinNum, wxString aNewPinNum )
1822 if( aOldPinNum == aNewPinNum )
1825 LIB_PIN* libpin = pinNumToLibPinMap.at( aOldPinNum );
1830 for(
auto& pinPair : aCadstarSymbol.
PinNumbers )
1832 SYMBOL::PIN_NUM
pin = pinPair.second;
1834 replacePinNumber( termNumMap.at(
pin.TerminalID ),
1839 for(
auto& pinPair : aCadstarSymbol.
PinNames )
1842 replacePinNumber( termNumMap.at(
pin.TerminalID ),
pin.NameOrLabel );
1872 if( textIsVertical )
1875 alignment =
mirrorX( alignment );
1883 aCadstarAttrLoc.
Mirror );
1898 aReturnedOrientation =
ANGLE_0;
1916 return compOrientation;
1925 auto logUnknownNetElementError =
1929 "The net was not properly loaded and may "
1930 "require manual fixing." ),
1939 if( aNetElementID.Contains(
"J" ) )
1942 return logUnknownNetElementError();
1944 return aNet.
Junctions.at( aNetElementID ).Location;
1946 else if( aNetElementID.Contains(
"P" ) )
1949 return logUnknownNetElementError();
1955 return logUnknownNetElementError();
1962 return logUnknownNetElementError();
1968 VECTOR2I pinOffset = libpinPosition - libOrigin;
1972 VECTOR2I pinPosition = symbolOrigin + pinOffset;
1976 pinPosition.
x = ( 2 * symbolOrigin.
x ) - pinPosition.
x;
1981 RotatePoint( pinPosition, symbolOrigin, -adjustedOrientation );
1984 retval.x = pinPosition.
x;
1985 retval.y = pinPosition.
y;
1989 else if( aNetElementID.Contains(
"BT" ) )
1992 return logUnknownNetElementError();
1994 return aNet.
BusTerminals.at( aNetElementID ).SecondPoint;
1996 else if( aNetElementID.Contains(
"BLKT" ) )
1999 return logUnknownNetElementError();
2005 return logUnknownNetElementError();
2007 return Schematic.
Blocks.at( blockid ).Terminals.at( termid ).Position;
2009 else if( aNetElementID.Contains(
"D" ) )
2012 return logUnknownNetElementError();
2014 return aNet.
Danglers.at( aNetElementID ).Position;
2018 return logUnknownNetElementError();
2027 wxString netname = aNet.
Name;
2029 if( netname.IsEmpty() )
2043 const double& aScalingFactor,
2045 const bool& aMirrorInvert )
2049 segment->
SetLayer( aKiCadSchLayerID );
2055 aTransformCentre, aMirrorInvert );
2057 aTransformCentre, aMirrorInvert );
2072 const double& aScalingFactor,
2074 const bool& aMirrorInvert )
2076 const VERTEX* prev = &aCadstarVertices.at( 0 );
2080 "First vertex should always be a point vertex" );
2082 for(
size_t ii = 1; ii < aCadstarVertices.size(); ii++ )
2084 cur = &aCadstarVertices.at( ii );
2094 centerPoint = ( startPoint + endPoint ) / 2;
2106 EDA_ANGLE arcStartAngle( startPoint - centerPoint );
2107 EDA_ANGLE arcEndAngle( endPoint - centerPoint );
2108 EDA_ANGLE arcAngle = arcEndAngle - arcStartAngle;
2117 SHAPE_ARC tempArc( centerPoint, startPoint, arcAngle );
2122 for(
int jj = 0; jj < arcSegments.
SegmentCount(); jj++ )
2128 aKiCadSchLayerID, aMoveVector, aRotation, aScalingFactor,
2129 aTransformCentre, aMirrorInvert );
2136 aKiCadSchLayerID, aMoveVector, aRotation, aScalingFactor,
2137 aTransformCentre, aMirrorInvert );
2141 wxFAIL_MSG(
"Unknown CADSTAR Vertex type" );
2151 const LAYER_ID& aCadstarSheetIDOverride,
2155 const double& aScalingFactor,
2157 const bool& aMirrorInvert )
2160 aCadstarSheetIDOverride, aKiCadSchLayerID, aMoveVector, aRotation,
2161 aScalingFactor, aTransformCentre, aMirrorInvert );
2166 aKiCadSchLayerID, aMoveVector, aRotation, aScalingFactor,
2167 aTransformCentre, aMirrorInvert );
2178 "Sheet already loaded!" );
2181 aParentSheet.
Last(),
2183 wxSize( aSheetSize ) );
2197 wxString loadedFilename = wxFileName(
Filename ).GetName();
2198 std::string filename =
wxString::Format(
"%s_%02d", loadedFilename, sheetNum ).ToStdString();
2203 filenameField.
SetText( filename );
2215 m_sheetMap.insert( { aCadstarSheetID, sheet } );
2225 "FIXME! Parent sheet should be loaded before attempting to load subsheets" );
2229 BLOCK& block = blockPair.second;
2231 if( block.
LayerID == aCadstarSheetID && block.
Type == BLOCK::TYPE::CHILD )
2235 if( block.
Figures.size() > 0 )
2238 "is drawn on sheet '%s' but is not "
2239 "linked to another sheet in the "
2240 "design. KiCad requires all sheet "
2241 "symbols to be associated to a sheet, "
2242 "so the block was not loaded." ),
2254 std::pair<VECTOR2I, wxSize> blockExtents;
2256 if( block.
Figures.size() > 0 )
2263 "Block %s references a child sheet but has no "
2264 "Figure defined." ),
2277 field.SetVisible(
false );
2324 std::vector<LAYER_ID> childSheets, orphanSheets;
2329 BLOCK& block = blockPair.second;
2332 if( block.
Type == BLOCK::TYPE::CHILD )
2333 childSheets.push_back( assocSheetID );
2339 if( std::find( childSheets.begin(), childSheets.end(), sheetID ) == childSheets.end() )
2340 orphanSheets.push_back( sheetID );
2343 return orphanSheets;
2353 if( sheetID == aCadstarSheetID )
2365 wxCHECK_MSG( aItem, ,
"aItem is null" );
2367 if( aCadstarSheetID ==
"ALL_SHEETS" )
2373 LAYER_ID sheetID = sheetPair.first;
2380 aItem = duplicateItem;
2382 else if( aCadstarSheetID ==
"NO_SHEET" )
2384 wxASSERT_MSG(
false,
2385 "Trying to add an item to NO_SHEET? This might be a documentation symbol." );
2391 m_sheetMap.at( aCadstarSheetID )->GetScreen()->Append( aItem );
2396 wxASSERT_MSG(
false,
"Unknown Sheet ID." );
2404 const wxString& aSymDefAlternate )
2413 && symdef.
Alternate.Lower() == aSymDefAlternate.Lower() )
2516CADSTAR_SCH_ARCHIVE_LOADER::PART::DEFINITION::PIN
2520 for( std::pair<PART_DEFINITION_PIN_ID, PART::DEFINITION::PIN> pinPair :
2523 PART::DEFINITION::PIN partPin = pinPair.second;
2525 if( partPin.TerminalGate == aGateID && partPin.TerminalPin == aTerminalID )
2529 return PART::DEFINITION::PIN();
2554 if( aCadstarGateID.IsEmpty() )
2557 return (
int) aCadstarGateID.Upper().GetChar( 0 ) - (int) wxUniChar(
'A' ) + 1;
2600 switch( aCadstarAlignment )
2619 default: wxFAIL_MSG(
"Unknown Cadstar Alignment" );
return aCadstarAlignment;
2627 switch( aCadstarAlignment )
2641 default: wxFAIL_MSG(
"Unknown Cadstar Alignment" );
return aCadstarAlignment;
2650 const long long aCadstarOrientAngle,
2663 aKiCadTextItem->
SetText( escapedText );
2667 if( textWidth == 0 )
2677 ALIGNMENT textAlignment = aCadstarAlignment;
2683 textAlignment =
mirrorX( aCadstarAlignment );
2688 switch( aAlignment )
2743 wxCHECK( textEdaItem, );
2745 switch( textEdaItem->
Type() )
2771 textAlignment =
rotate180( textAlignment );
2775 textAlignment =
rotate180( textAlignment );
2777 default: wxFAIL_MSG(
"Unknown Quadrant" );
2781 setAlignment( aKiCadTextItem, textAlignment );
2790 setAlignment( aKiCadTextItem, textAlignment );
2792 int off =
static_cast<SCH_TEXT*
>( aKiCadTextItem )->GetTextOffset();
2814 static_cast<SCH_TEXT*
>( aKiCadTextItem )->SetTextSpinStyle( spin );
2818 wxFAIL_MSG(
"Unexpected item type" );
2837 aCadstarTextElement.
Mirror );
2844 long long aScalingFactorNumerator,
2845 long long aScalingFactorDenominator )
2849 if( aScalingFactorNumerator == aScalingFactorDenominator )
2853 [&](
int aLength ) ->
int
2855 return( aLength * aScalingFactorNumerator ) / aScalingFactorDenominator;
2861 return VECTOR2I( scaleLen( aCoord.x ), scaleLen( aCoord.y ) );
2867 return VECTOR2I( scaleLen( aSize.x ), scaleLen( aSize.y ) );
2874 switch( item.Type() )
2900 pin.SetPosition( scalePt(
pin.GetPosition() ) );
2901 pin.SetLength( scaleLen(
pin.GetLength() ) );
2941 if( aGateNumber > 0 && shape.
GetUnit() != aGateNumber )
2954 if( pt0 != pt1 && uniqueSegments.count( pt0 ) == 0 && uniqueSegments.count( pt1 ) == 0 )
2957 if( pt0.
x == pt1.
x || pt0.
y == pt1.
y )
2959 uniqueSegments.insert( { pt0, poly } );
2960 uniqueSegments.insert( { pt1, poly } );
2967 aSymbolToFix->
GetPins( pins, aGateNumber );
2969 for(
auto&
pin : pins )
2971 auto setPinOrientation =
2975 angle.Normalize180();
2978 pin->SetOrientation(
'R' );
2980 pin->SetOrientation(
'U' );
2982 pin->SetOrientation(
'L' );
2984 pin->SetOrientation(
'D' );
2987 if( uniqueSegments.count(
pin->GetPosition() ) )
2993 if( otherPt ==
pin->GetPosition() )
2994 otherPt = poly.
CPoint( 1 );
3005std::pair<VECTOR2I, wxSize>
3013 if( upperLeft.
x > v.
End.x )
3014 upperLeft.
x = v.
End.x;
3016 if( upperLeft.
y < v.
End.y )
3017 upperLeft.
y = v.
End.y;
3019 if( lowerRight.
x < v.
End.x )
3020 lowerRight.
x = v.
End.x;
3022 if( lowerRight.
y > v.
End.y )
3023 lowerRight.
y = v.
End.y;
3030 if( upperLeft.
x > v.
End.x )
3031 upperLeft.
x = v.
End.x;
3033 if( upperLeft.
y < v.
End.y )
3034 upperLeft.
y = v.
End.y;
3036 if( lowerRight.
x < v.
End.x )
3037 lowerRight.
x = v.
End.x;
3039 if( lowerRight.
y > v.
End.y )
3040 lowerRight.
y = v.
End.y;
3047 VECTOR2I size = lowerRightKiCad - upperLeftKiCad;
3049 return { upperLeftKiCad, wxSize(
abs( size.
x ),
abs( size.
y ) ) };
3079 const double& aScalingFactor,
3081 const bool& aMirrorInvert )
3085 if( aScalingFactor != 1.0 )
3088 retVal -= aTransformCentre;
3089 retVal.
x =
KiROUND( retVal.
x * aScalingFactor );
3090 retVal.
y =
KiROUND( retVal.
y * aScalingFactor );
3091 retVal += aTransformCentre;
3095 MIRROR( retVal.
x, aTransformCentre.
x );
3097 if( !aRotation.
IsZero() )
3098 RotatePoint( retVal, aTransformCentre, aRotation );
3100 if( aMoveVector != wxPoint{ 0, 0 } )
3101 retVal += aMoveVector;
3109 return sqrt( ( (
double) aPoint.
x * (
double) aPoint.
x )
3110 + ( (
double) aPoint.
y * (
double) aPoint.
y ) );
constexpr EDA_IU_SCALE schIUScale
constexpr double SCH_IU_PER_MM
#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 PartNameFieldName
Loads a csa file into a KiCad SCHEMATIC object.
coord_type GetTop() const
coord_type GetRight() const
coord_type GetLeft() const
const Vec & GetSize() const
coord_type GetBottom() const
BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
static wxString generateLibName(const wxString &aRefName, const wxString &aAlternateName)
@ ANTICLOCKWISE_SEMICIRCLE
@ 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
wxString LAYER_ID
ID of a Sheet (if schematic) or board Layer (if PCB)
static void FixTextPositionNoAlignment(EDA_TEXT *aKiCadTextItem)
Corrects 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 cancelled.
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
ELECTRICAL_PINTYPE getKiCadPinType(const PART::PIN_TYPE &aPinType)
ROUTECODE getRouteCode(const ROUTECODE_ID &aCadstarRouteCodeID)
void applyToLibraryFieldAttribute(const ATTRIBUTE_LOCATION &aCadstarAttrLoc, wxPoint aSymbolOrigin, LIB_FIELD *aKiCadField)
std::pair< VECTOR2I, wxSize > getFigureExtentsKiCad(const FIGURE &aCadstarFigure)
std::map< BLOCK_PIN_ID, SCH_HIERLABEL * > m_sheetPinMap
Map between Cadstar and KiCad Sheets 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
Map between Cadstar and KiCad Global Labels.
SCH_SYMBOL * loadSchematicSymbol(const SYMBOL &aCadstarSymbol, const LIB_SYMBOL &aKiCadPart, EDA_ANGLE &aComponentOrientation)
SCH_PLUGIN::SCH_PLUGIN_RELEASER * m_plugin
void applyTextSettings(EDA_TEXT *aKiCadTextItem, const TEXTCODE_ID &aCadstarTextCodeID, const ALIGNMENT &aCadstarAlignment, const JUSTIFICATION &aCadstarJustification, const long long aCadstarOrientAngle=0, bool aMirrored=false)
wxString getAttributeName(const ATTRIBUTE_ID &aCadstarAttributeID)
PART getPart(const PART_ID &aCadstarPartID)
std::vector< LAYER_ID > findOrphanSheets()
std::map< BUS_ID, std::shared_ptr< BUS_ALIAS > > m_busesMap
Map of Cadstar and KiCad Buses.
int getSheetNumber(LAYER_ID aCadstarSheetID)
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
Map between Cadstar and KiCad Power Symbols.
std::pair< PART_ID, GATE_ID > PART_GATE_ID
void loadDocumentationSymbols()
VECTOR2I getKiCadLibraryPoint(const VECTOR2I &aCadstarPoint, const VECTOR2I &aCadstarCentre)
PART::DEFINITION::PIN getPartDefinitionPin(const PART &aCadstarPart, const GATE_ID &aGateID, const TERMINAL_ID &aTerminalID)
void Load(SCHEMATIC *aSchematic, SCH_SHEET *aRootSheet, SCH_PLUGIN::SCH_PLUGIN_RELEASER *aSchPlugin, const wxFileName &aLibraryFileName)
Loads a CADSTAR PCB Archive file into the KiCad BOARD object given.
int getTextHeightFromTextCode(const TEXTCODE_ID &aCadstarTextCodeID)
TEXT_SPIN_STYLE getSpinStyle(const long long &aCadstarOrientation, bool aMirror)
double getPolarRadius(const VECTOR2I &aPoint)
int getLineThickness(const LINECODE_ID &aCadstarLineCodeID)
TEXTCODE getTextCode(const TEXTCODE_ID &aCadstarTextCodeID)
std::map< wxString, LIB_SYMBOL * > m_powerSymLibMap
Map of KiCad Power Symbol Library items.
PLOT_DASH_TYPE getLineStyle(const LINECODE_ID &aCadstarLineCodeID)
std::map< PART_ID, TERMINAL_TO_PINNUM_MAP > m_pinNumsMap
Map of pin numbers in CADSTAR parts.
void loadHierarchicalSheetPins()
void loadSymDefIntoLibrary(const SYMDEF_ID &aSymdefID, const PART *aCadstarPart, const GATE_ID &aGateID, LIB_SYMBOL *aSymbol)
void loadSheetAndChildSheets(LAYER_ID aCadstarSheetID, const VECTOR2I &aPosition, VECTOR2I aSheetSize, const SCH_SHEET_PATH &aParentSheet)
void loadItemOntoKiCadSheet(LAYER_ID aCadstarSheetID, SCH_ITEM *aItem)
int getKiCadLength(long long aCadstarLength)
std::map< PART_ID, LIB_SYMBOL * > m_partMap
Map between Cadstar and KiCad Parts.
void loadGraphicStaightSegment(const VECTOR2I &aStartPoint, const VECTOR2I &aEndPoint, const LINECODE_ID &aCadstarLineCodeID, const LAYER_ID &aCadstarSheetID, const 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)
bool isAttributeVisible(const ATTRIBUTE_ID &aCadstarAttributeID)
VECTOR2I getKiCadPoint(const VECTOR2I &aCadstarPoint)
EDA_ANGLE getAngle(const long long &aCadstarAngle)
const double ARC_ACCURACY
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)
void loadLibrarySymbolShapeVertices(const std::vector< VERTEX > &aCadstarVertices, wxPoint aSymbolOrigin, LIB_SYMBOL *aSymbol, int aGateNumber, int aLineThickness)
std::map< PART_GATE_ID, SYMDEF_ID > m_partSymbolsMap
Map holding the symbols loaded so far for a particular PART_ID and GATE_ID.
wxPoint m_designCenter
Used for calculating the required offset to apply to the Cadstar design so that it fits in KiCad canv...
LIB_SYMBOL * getScaledLibPart(const LIB_SYMBOL *aSymbol, long long aScalingFactorNumerator, long long aScalingFactorDenominator)
SYMDEF_ID getSymDefFromName(const wxString &aSymdefName, const wxString &aSymDefAlternate)
std::map< LAYER_ID, SCH_SHEET * > m_sheetMap
Map between Cadstar and KiCad Sheets.
POINT getLocationOfNetElement(const NET_SCH &aNet, const NETELEMENT_ID &aNetElementID)
void fixUpLibraryPins(LIB_SYMBOL *aSymbolToFix, int aGateNumber)
ALIGNMENT rotate180(const ALIGNMENT &aCadstarAlignment)
long long getCadstarAngle(const EDA_ANGLE &aAngle)
void loadChildSheets(LAYER_ID aCadstarSheetID, const SCH_SHEET_PATH &aSheet)
ALIGNMENT mirrorX(const ALIGNMENT &aCadstarAlignment)
wxFileName m_libraryFileName
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)
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.
virtual void SetParent(EDA_ITEM *aParent)
EDA_ITEM * GetParent() const
SHAPE_POLY_SET & GetPolyShape()
void SetPolyShape(const SHAPE_POLY_SET &aShape)
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
void SetStart(const VECTOR2I &aStart)
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
void SetEnd(const VECTOR2I &aEnd)
void SetFillMode(FILL_T aFill)
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
int GetTextHeight() const
BOX2I GetTextBox(int aLine=-1, bool aInvertY=false) const
Useful in multiline texts to calculate the full text or a line area (for zones filling,...
const VECTOR2I & GetTextPos() const
const EDA_ANGLE & GetTextAngle() const
virtual const wxString & GetText() const
Return the string associated with the text object.
void SetTextPos(const VECTOR2I &aPoint)
void SetVertJustify(GR_TEXT_V_ALIGN_T aType)
void SetTextWidth(int aWidth)
virtual void SetVisible(bool aVisible)
void SetTextThickness(int aWidth)
The TextThickness is that set by the user.
void SetTextHeight(int aHeight)
void SetTextSize(const VECTOR2I &aNewSize)
virtual void SetText(const wxString &aText)
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
int GetTextThickness() const
void SetItalic(bool aItalic)
void SetMultilineAllowed(bool aAllow)
VECTOR2I GetTextSize() const
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
iterator end()
Returns a read/write iterator that points to one past the last element in the EE_RTREE.
iterator begin()
Returns a read/write iterator that points to the first element in the EE_RTREE N.B.
Field object used in symbol libraries.
void SetName(const wxString &aName)
Set a user definable field name to aName.
wxString GetName(bool aUseDefaultName=true) const
Return the field name (not translated).
A logical library item identifier and consists of various portions much like a URI.
The base class for drawable items used by schematic library symbols.
void SetPosition(const VECTOR2I &aPosition) override
void SetNumber(const wxString &aNumber)
void SetStroke(const STROKE_PARAMS &aStroke)
void AddPoint(const VECTOR2I &aPosition)
void SetPosition(const VECTOR2I &aPosition) override
VECTOR2I GetPosition() const override
Define a library symbol object.
void RemoveDrawItem(LIB_ITEM *aItem)
Remove draw aItem from list.
void SetShowPinNames(bool aShow)
Set or clear the pin name visibility flag.
LIB_FIELD & GetReferenceField()
Return reference to the reference designator field.
void SetUnitCount(int aCount, bool aDuplicateDrawItems=true)
Set the units per symbol count.
std::vector< struct LIB_SYMBOL_UNIT > GetUnitDrawItems()
Return a list of LIB_ITEM objects separated by unit and convert number.
LIB_FIELD & GetFootprintField()
Return reference to the footprint field.
void SetShowPinNumbers(bool aShow)
Set or clear the pin number visibility flag.
LIB_ITEMS_CONTAINER & GetDrawItems()
Return a reference to the draw item list.
wxString GetName() const override
void SetDescription(const wxString &aDescription)
void AddDrawItem(LIB_ITEM *aItem, bool aSort=true)
Add a new draw aItem to the draw object list and sort according to aSort.
LIB_FIELD * FindField(const wxString &aFieldName)
Find a field within this symbol matching aFieldName and returns it or NULL if not found.
LIB_FIELD & GetValueField()
Return reference to the value field.
void SetFPFilters(const wxArrayString &aFilters)
size_t GetFieldCount() const
void AddField(LIB_FIELD *aField)
Add a field.
void GetPins(LIB_PINS &aList, int aUnit=0, int aConvert=0) const
Return a list of pin object pointers from the draw item list.
Define a symbol library graphical text item.
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
VECTOR2I GetPosition() const override
ITERATOR_BASE< LIB_ITEM, MULTIVECTOR< LIB_ITEM, FIRST_TYPE_VAL, LAST_TYPE_VAL >, typename ITEM_PTR_VECTOR::iterator > ITERATOR
The const iterator.
ITERATOR end(int aType=UNDEFINED_TYPE)
ITERATOR begin(int aType=UNDEFINED_TYPE)
Describe the page size and margins of a paper page on which to eventually print or plot.
void SetWidthMils(int aWidthInMils)
void SetHeightMils(int aHeightInMils)
const wxSize GetSizeIU(double aIUScale) const
Gets the page size in internal units.
virtual void SetNumPhases(int aNumPhases)=0
Set the number of phases.
virtual void BeginPhase(int aPhase)=0
Initialize the aPhase virtual zone of the dialog progress bar.
virtual void SetMaxProgress(int aMaxProgress)=0
Fix the value that gives the 100 percent progress bar length (inside the current virtual zone).
Container for project specific data.
virtual const wxString GetProjectPath() const
Return the full path of the project.
virtual std::map< wxString, wxString > & GetTextVars() const
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Report a string with a given severity.
Holds all the data relating to one schematic.
PROJECT & Prj() const override
Return a reference to the project this schematic is part of.
void SetSize(const wxSize &aSize)
Class for a wire to bus entry.
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
wxString GetName(bool aUseDefaultName=true) const
Return the field name (not translated).
void SetPosition(const VECTOR2I &aPosition) override
void SetTextSpinStyle(TEXT_SPIN_STYLE aSpinStyle) override
Set a spin or rotation angle, along with specific horizontal and vertical justification styles with e...
void SetTextSpinStyle(TEXT_SPIN_STYLE aSpinStyle) override
Set a spin or rotation angle, along with specific horizontal and vertical justification styles with e...
Base class for any item which can be embedded within the SCHEMATIC container class,...
void SetLayer(SCH_LAYER_ID aLayer)
Set the layer this item is on.
SCH_ITEM * Duplicate(bool doClone=false) const
Routine to create a new copy of given item.
void SetPosition(const VECTOR2I &aPosition) override
void SetShape(LABEL_FLAG_SHAPE aShape) override
void AutoplaceFields(SCH_SCREEN *aScreen, bool aManual) override
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 PLOT_DASH_TYPE aStyle)
void SetEndPoint(const VECTOR2I &aPosition)
Helper object to release a SCH_PLUGIN in the context of a potential thrown exception through its dest...
const PAGE_INFO & GetPageSettings() const
void Update(SCH_ITEM *aItem)
Update aItem's bounding box in the tree.
void AddBusAlias(std::shared_ptr< BUS_ALIAS > aAlias)
Add a bus alias definition (and transfers ownership of the pointer).
void SetPageSettings(const PAGE_INFO &aPageSettings)
EE_RTREE & Items()
Gets the full RTree, usually for iterating.
void SetFileName(const wxString &aFileName)
Set the file name for this screen to aFileName.
void Append(SCH_ITEM *aItem)
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.
void AddPin(SCH_SHEET_PIN *aSheetPin)
Add aSheetPin to the sheet.
std::vector< SCH_FIELD > & GetFields()
bool LocatePathOfScreen(SCH_SCREEN *aScreen, SCH_SHEET_PATH *aList)
Search the existing hierarchy for an instance of screen loaded from aFileName.
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.
void AutoplaceFields(SCH_SCREEN *aScreen, bool aManual) override
static bool ClassOf(const EDA_ITEM *aItem)
void SetPosition(const VECTOR2I &aPosition) override
int GetFieldCount() const
Return the number of fields in this symbol.
SCH_FIELD * FindField(const wxString &aFieldName, bool aIncludeDefaultFields=true)
Search for a SCH_FIELD with aFieldName.
SCH_FIELD * GetField(MANDATORY_FIELD_T aFieldType)
Return a mandatory field in this symbol.
void UpdatePins()
Updates the cache of SCH_PIN objects for each pin.
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...
SCH_FIELD * AddField(const SCH_FIELD &aField)
Add a field to the symbol.
BOX2I GetBodyAndPinsBoundingBox() const
Return a bounding box for the symbol body and pins but not the fields.
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly)
Populate a std::vector with SCH_FIELDs.
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
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.
virtual void SetTextSpinStyle(TEXT_SPIN_STYLE aSpinStyle)
Set a spin or rotation angle, along with specific horizontal and vertical justification styles with e...
const SHAPE_LINE_CHAIN ConvertToPolyline(double aAccuracy=DefaultAccuracyForPCB(), double *aEffectiveAccuracy=nullptr) const
Construct a SHAPE_LINE_CHAIN of segments from a given arc.
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
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 Intersect(const SEG &aSeg, INTERSECTIONS &aIp) const
Find all intersection points between our line chain and the segment aSeg.
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.
int SegmentCount() const
Return the number of segments in this line chain.
std::vector< INTERSECTION > INTERSECTIONS
const std::vector< VECTOR2I > & CPoints() const
SEG Segment(int aIndex)
Return a copy of the aIndex-th segment in the line chain.
SHAPE_LINE_CHAIN & Outline(int aIndex)
Simple container to manage line stroke parameters.
TEXT_SPIN_STYLE MirrorY()
Mirror the label spin style across the Y axis or simply swaps left and right.
TEXT_SPIN_STYLE RotateCCW()
TEXT_SPIN_STYLE MirrorX()
Mirror the label spin style across the X axis or simply swaps up and bottom.
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 bus width in mils. (can be changed in preference menu)
static constexpr EDA_ANGLE & ANGLE_180
static constexpr EDA_ANGLE & ANGLE_HORIZONTAL
static constexpr EDA_ANGLE & ANGLE_VERTICAL
static constexpr EDA_ANGLE & ANGLE_45
static constexpr EDA_ANGLE & ANGLE_90
static constexpr EDA_ANGLE & ANGLE_0
static constexpr EDA_ANGLE & ANGLE_270
static constexpr EDA_ANGLE & ANGLE_135
@ FILLED_WITH_BG_BODYCOLOR
const std::string KiCadSchematicFileExtension
#define THROW_IO_ERROR(msg)
SCH_LAYER_ID
Eeschema drawing layers.
std::vector< LIB_PIN * > LIB_PINS
Helper for defining a list of pin object pointers.
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 ...
void MIRROR(T &aPoint, const T &aMirrorRef)
Updates aPoint with the mirror of aPoint relative to the aMirrorRef.
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
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
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
std::vector< SCH_FIELD > SCH_FIELDS
A container for several SCH_FIELD items.
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:...
PLOT_DASH_TYPE
Dashed line types.
std::map< ATTRIBUTE_ID, ATTRCOL > AttributeColors
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.
std::map< LINECODE_ID, LINECODE > LineCodes
std::map< ATTRIBUTE_ID, ATTRNAME > AttributeNames
std::map< ROUTECODE_ID, ROUTECODE > RouteCodes
std::map< TEXTCODE_ID, TEXTCODE > TextCodes
Represents 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.
long Param1
Either Units or X step, depending on Type (see GRID_TYPE for more details)
long Param2
Either Divisor or Y step, depending on Type (see GRID_TYPE for more details)
wxString Name
This is undefined (wxEmptyString) if the net is unnamed.
long SignalNum
This is undefined if the net has been given a name.
std::map< TEXT_FIELD_NAME, wxString > TextFieldToValuesMap
Values for the text field elements used in the CADSTAR design extracted from the text element instanc...
std::map< wxString, wxString > FilenamesToTextMap
CADSTAR doesn't have user defined text fields but does allow loading text from a file.
std::set< TEXT_FIELD_NAME > InconsistentTextFields
Text fields need to be updated in CADSTAR and it is possible that they are not consistent across text...
std::map< PART_ID, PART > PartDefinitions
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.
Represents a point in x,y coordinates.
SHAPE_POLY_SET ConvertToPolySet(const std::function< VECTOR2I(const VECTOR2I &)> aCadstarToKicadPointCallback, double 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
wxString ReferenceName
This is the name which identifies the symbol in the library Multiple components may exist with the sa...
std::map< ATTRIBUTE_ID, ATTRIBUTE_VALUE > AttributeValues
These attributes might also have a location.
long Width
Defaults to 0 if using system fonts or, if using CADSTAR font, default to equal height (1:1 aspect ra...
Corresponds to CADSTAR "origin".
ALIGNMENT Alignment
In CADSTAR The default alignment for a TEXT object (when "(No Alignment()" is selected) Bottom Left o...
JUSTIFICATION Justification
Note: Justification has no effect on single lines of text.
std::map< VARIANT_ID, VARIANT > Variants
< Nodename = "VARIANT" or "VMASTER" (master variant
Represents a vertex in a shape.
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.
std::map< SYMBOL_ID, SYMBOL > Symbols
std::map< REUSEBLOCK_ID, REUSEBLOCK > ReuseBlocks
VARIANT_HIERARCHY VariantHierarchy
std::map< DOCUMENTATION_SYMBOL_ID, DOCUMENTATION_SYMBOL > DocumentationSymbols
std::map< FIGURE_ID, FIGURE > Figures
std::map< TEXT_ID, TEXT > Texts
std::map< BLOCK_ID, BLOCK > Blocks
std::map< BUS_ID, BUS > Buses
std::map< GROUP_ID, GROUP > Groups
std::map< NET_ID, NET_SCH > Nets
ATTRIBUTE_LOCATION AttrLoc
std::map< SYMDEF_ID, SYMDEF_SCM > SymbolDefinitions
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
std::vector< LAYER_ID > SheetOrder
A vector to also store the order in which sheets are to be displayed.
std::map< LAYER_ID, SHEET_NAME > SheetNames
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.
constexpr int IUToMils(int iu) const
constexpr int MilsToIU(int mils) const
@ VALUE_FIELD
Field Value of part, i.e. "3.3K".
@ REFERENCE_FIELD
Field Reference of part, i.e. "IC21".
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
const int LexicographicalCompare(const VECTOR2< T > &aA, const VECTOR2< T > &aB)
Definition of file extensions used in Kicad.