69 constexpr
long long maxDesignSizekicad = std::numeric_limits<int>::max();
71 if( designSizeXkicad > maxDesignSizekicad || designSizeYkicad > maxDesignSizekicad )
74 _(
"The design is too large and cannot be imported into KiCad. \n" 75 "Please reduce the maximum design size in CADSTAR by navigating to: \n" 76 "Design Tab -> Properties -> Design Options -> Maximum Design Size. \n" 77 "Current Design size: %.2f, %.2f millimeters. \n" 78 "Maximum permitted design size: %.2f, %.2f millimeters.\n" ),
129 "no KiCad equivalent. Only the master variant " 130 "('%s') was loaded." ),
137 m_reporter->
Report(
_(
"The CADSTAR design contains grouped items which has no KiCad " 138 "equivalent. Any grouped items have been ungrouped." ),
144 m_reporter->
Report(
_(
"The CADSTAR design contains re-use blocks which has no KiCad " 145 "equivalent. The re-use block information has been discarded during " 152 for( std::pair<LAYER_ID, SCH_SHEET*> sheetPair :
m_sheetMap )
167 SCH_SYMBOL* comp = static_cast<SCH_SYMBOL*>( item );
172 if( field.IsVisible() )
173 bbox.
Merge( field.GetBoundingBox() );
178 SCH_TEXT* txtItem = static_cast<SCH_TEXT*>( item );
179 wxString txt = txtItem->
GetText();
181 if( txt.Contains( wxT(
"${" ) ) )
188 bbox = item->GetBoundingBox();
191 sheetBoundingBox.
Merge( bbox );
204 auto roundToNearestGrid =
205 [&](
int aNumber ) ->
int 207 int error = aNumber %
grid;
208 int absError =
sign( error ) * error;
210 if( absError > (
grid / 2 ) )
211 return aNumber + (
sign( error ) *
grid ) - error;
213 return aNumber - error;
219 wxSize targetSheetSize = sheetBoundingBox.
GetSize();
220 int longestSide = std::max( targetSheetSize.x, targetSheetSize.y );
221 int margin = ( (double) longestSide * 0.03);
222 margin = roundToNearestGrid( margin );
223 targetSheetSize.IncBy( margin * 2, margin * 2 );
234 wxPoint sheetcentre( pageSizeIU.x / 2, pageSizeIU.y / 2 );
235 wxPoint itemsCentre = sheetBoundingBox.
Centre();
238 wxPoint translation = sheetcentre - itemsCentre;
239 translation.x = roundToNearestGrid( translation.x );
240 translation.y = roundToNearestGrid( translation.y );
243 std::vector<SCH_ITEM*> allItems;
246 std::back_inserter( allItems ) );
250 item->Move( translation );
259 "Please review the import errors and warnings (if any)." ) );
271 if( orphanSheets.size() > 1 )
276 for(
LAYER_ID sheetID : orphanSheets )
278 wxPoint pos( x * Mils2iu( 1000 ), y * Mils2iu( 1000 ) );
279 wxSize siz( Mils2iu( 1000 ), Mils2iu( 1000 ) );
292 else if( orphanSheets.size() > 0 )
294 LAYER_ID rootSheetID = orphanSheets.at( 0 );
296 wxFileName loadedFilePath = wxFileName(
Filename );
299 wxT(
"%s_%02d" ), loadedFilePath.GetName(),
getSheetNumber( rootSheetID ) )
312 THROW_IO_ERROR(
_(
"The CADSTAR schematic might be corrupt: there is no root sheet." ) );
321 BLOCK& block = blockPair.second;
324 if( block.
Type == BLOCK::TYPE::PARENT )
326 else if( block.
Type == BLOCK::TYPE::CHILD )
335 for( std::pair<TERMINAL_ID, TERMINAL> termPair : block.
Terminals )
338 wxString
name = wxT(
"YOU SHOULDN'T SEE THIS TEXT. THIS IS A BUG." );
342 if( block.
Type == BLOCK::TYPE::PARENT )
344 else if( block.
Type == BLOCK::TYPE::CHILD )
369 PART_ID partID = partPair.first;
370 PART part = partPair.second;
383 GATE_ID gateID = gatePair.first;
384 PART::DEFINITION::GATE gate = gatePair.second;
388 if( symbolID.IsEmpty() )
391 "'%s' (alternate '%s') which could not be " 392 "found in the symbol library. The part has " 393 "not been loaded into the KiCad library." ),
413 m_partMap.insert( { partID, loadedPart } );
431 SYMBOL sym = symPair.second;
441 "could not be found in the library. The " 442 "symbol was not loaded" ),
450 if( sym.
GateID.IsEmpty() )
471 double symOrientDeciDeg = 0.0;
504 partname.Replace( wxT(
"\n" ), wxT(
"\\n" ) );
505 partname.Replace( wxT(
"\r" ), wxT(
"\\r" ) );
506 partname.Replace( wxT(
"\t" ), wxT(
"\\t" ) );
507 partField->
SetText( partname );
528 symbol, attrName ) );
531 wxASSERT( attrField->
GetName() == attrName );
533 attrVal.
Value.Replace( wxT(
"\n" ), wxT(
"\\n" ) );
534 attrVal.
Value.Replace( wxT(
"\r" ), wxT(
"\\r" ) );
535 attrVal.
Value.Replace( wxT(
"\t" ), wxT(
"\\t" ) );
549 _(
"Symbol ID '%s' references library symbol '%s' which could not be " 550 "found in the library. Did you export all items of the design?" ),
559 _(
"Symbol ID '%s' is a signal reference or global signal but it has too " 560 "many pins. The expected number of pins is 1 but %d were found." ),
582 wxString libPartName = libraryNetName;
588 if( libPartName != symbolInstanceNetName )
590 libPartName += wxT(
" (" ) + symbolInstanceNetName + wxT(
")" );
633 double returnedOrient = 0.0;
643 wxPoint terminalPosOffset = symbolTerminal.
Position - libSymDef.
Origin;
647 rotateDeciDegree += 1800.0;
649 RotatePoint( &terminalPosOffset, -rotateDeciDegree );
653 netLabel->
SetText( wxT(
"***UNKNOWN NET****" ) );
654 netLabel->
SetTextSize( wxSize( Mils2iu( 50 ), Mils2iu( 50 ) ) );
667 if( libSymDef.
Alternate.Lower().Contains( wxT(
"in" ) ) )
669 else if( libSymDef.
Alternate.Lower().Contains( wxT(
"bi" ) ) )
671 else if( libSymDef.
Alternate.Lower().Contains( wxT(
"out" ) ) )
681 screen->
Append( netLabel );
686 wxASSERT_MSG(
false, wxT(
"Unknown Symbol Variant." ) );
692 "neither a symbol or a net power / symbol. " 693 "The symbol was not loaded." ),
702 if( symbolName.empty() )
708 "CADSTAR schematic but this is not supported " 709 "in KiCad. When the symbol is reloaded from " 710 "the library, it will revert to the original " 724 BUS bus = busPair.second;
728 if( bus.
LayerID != wxT(
"NO_SHEET" ) )
731 std::shared_ptr<BUS_ALIAS> kiBusAlias = std::make_shared<BUS_ALIAS>();
733 kiBusAlias->SetName( bus.
Name );
734 kiBusAlias->SetParent( screen );
742 label->
SetText( wxT(
"{" ) + busname + wxT(
"}" ) );
783 wxPoint nearestPt = (wxPoint) busLineChain.
NearestPoint( busLabelLoc );
793 label->
SetText( wxT(
"{" ) + busname + wxT(
"}" ) );
809 wxString netName = net.
Name;
810 std::map<NETELEMENT_ID, SCH_LABEL*> netlabels;
812 if( netName.IsEmpty() )
817 for( std::pair<NETELEMENT_ID, NET_SCH::SYM_TERM> terminalPair : net.
Terminals )
819 NET_SCH::SYM_TERM netTerm = terminalPair.second;
828 if( netTerm.HasNetLabel )
834 netTerm.NetLabel.TextCodeID,
835 netTerm.NetLabel.Alignment,
836 netTerm.NetLabel.Justification,
837 netTerm.NetLabel.OrientAngle,
838 netTerm.NetLabel.Mirror );
856 && netTerm.HasNetLabel )
866 applyTextSettings( label, netTerm.NetLabel.TextCodeID, netTerm.NetLabel.Alignment,
867 netTerm.NetLabel.Justification );
869 netlabels.insert( { netTerm.ID, label } );
872 m_sheetMap.at( sheet )->GetScreen()->Append( label );
876 auto getHierarchicalLabel =
879 if( aNode.Contains( wxT(
"BLKT" ) ) )
882 BLOCK_PIN_ID blockPinID = std::make_pair( blockTerm.BlockID,
883 blockTerm.TerminalID );
896 for( std::pair<NETELEMENT_ID, NET_SCH::BLOCK_TERM> blockPair : net.
BlockTerminals )
898 SCH_HIERLABEL* label = getHierarchicalLabel( blockPair.first );
905 for( std::pair<NETELEMENT_ID, NET_SCH::BUS_TERM> busPair : net.
BusTerminals )
907 NET_SCH::BUS_TERM busTerm = busPair.second;
918 busEntry->
SetSize( wxSize( size.x, size.y ) );
931 if( busTerm.HasNetLabel )
934 busTerm.NetLabel.TextCodeID,
935 busTerm.NetLabel.Alignment,
936 busTerm.NetLabel.Justification );
943 netlabels.insert( { busTerm.ID, label } );
947 for( std::pair<NETELEMENT_ID, NET_SCH::DANGLER> danglerPair : net.
Danglers )
949 NET_SCH::DANGLER dangler = danglerPair.second;
955 if( dangler.HasNetLabel )
958 dangler.NetLabel.TextCodeID,
959 dangler.NetLabel.Alignment,
960 dangler.NetLabel.Justification );
964 netlabels.insert( { dangler.ID, label } );
966 m_sheetMap.at( dangler.LayerID )->GetScreen()->Append( label );
969 for( NET_SCH::CONNECTION_SCH conn : net.
Connections )
971 if( conn.LayerID == wxT(
"NO_SHEET" ) )
982 if( conn.Path.size() < 1 || conn.Path.front() != start )
983 conn.Path.insert( conn.Path.begin(), start );
985 if( conn.Path.size() < 2 || conn.Path.back() != end )
986 conn.Path.push_back( end );
989 bool secondPt =
false;
995 for(
POINT pt : conn.Path )
1005 std::vector<NETELEMENT_ID> nodes;
1006 nodes.push_back( conn.StartNode );
1007 nodes.push_back( conn.EndNode );
1019 wxSize sheetSize = parentSheet->
GetSize();
1020 wxPoint sheetPosition = parentSheet->
GetPosition();
1022 int leftSide = sheetPosition.x;
1023 int rightSide = sheetPosition.x + sheetSize.x;
1024 int topSide = sheetPosition.y;
1025 int botSide = sheetPosition.y + sheetSize.y;
1029 sheetEdge.
Append( leftSide, topSide );
1030 sheetEdge.
Append( rightSide, topSide );
1031 sheetEdge.
Append( rightSide, botSide );
1032 sheetEdge.
Append( leftSide, botSide );
1033 sheetEdge.
Append( leftSide, topSide );
1037 if( !wireChain.
Intersect( sheetEdge, wireToSheetIntersects ) )
1042 if( node == conn.StartNode )
1043 wireChain = wireChain.
Reverse();
1047 if( node == conn.StartNode )
1048 wireChain = wireChain.
Reverse();
1054 VECTOR2I intsctPt = wireToSheetIntersects.at( 0 ).p;
1055 int intsctIndx = wireChain.
FindSegment( intsctPt );
1056 wxASSERT_MSG( intsctIndx != -1, wxT(
"Can't find intersecting segment" ) );
1058 if( node == conn.StartNode )
1059 wireChain.
Replace( 0, intsctIndx, intsctPt );
1061 wireChain.
Replace( intsctIndx + 1, -1, intsctPt );
1069 auto fixNetLabelsAndSheetPins =
1074 if( netlabels.find( aNetEleID ) != netlabels.end() )
1075 netlabels.at( aNetEleID )->SetLabelSpinStyle( spin.
MirrorY() );
1077 SCH_HIERLABEL* sheetPin = getHierarchicalLabel( aNetEleID );
1088 last = (wxPoint) pt;
1099 wxPoint kiLast = last;
1100 wxPoint kiCurrent = (wxPoint) pt;
1101 double wireangleDeciDeg =
getPolarAngle( kiLast - kiCurrent );
1102 fixNetLabelsAndSheetPins( wireangleDeciDeg, conn.StartNode );
1111 if( !conn.ConnectionLineCode.IsEmpty() )
1114 last = (wxPoint) pt;
1116 m_sheetMap.at( conn.LayerID )->GetScreen()->Append( wire );
1124 double wireangleDeciDeg =
getPolarAngle( kiLast - kiCurrent );
1125 fixNetLabelsAndSheetPins( wireangleDeciDeg, conn.EndNode );
1129 for( std::pair<NETELEMENT_ID, NET_SCH::JUNCTION_SCH> juncPair : net.
Junctions )
1131 NET_SCH::JUNCTION_SCH junc = juncPair.second;
1136 m_sheetMap.at( junc.LayerID )->GetScreen()->Append( kiJunc );
1138 if( junc.HasNetLabel )
1151 m_sheetMap.at( junc.LayerID )->GetScreen()->Append( label );
1162 FIGURE fig = figPair.second;
1173 TEXT txt = textPair.second;
1183 for( std::pair<DOCUMENTATION_SYMBOL_ID, DOCUMENTATION_SYMBOL> docSymPair :
1191 "definition ID '%s' which does not exist in " 1192 "the library. The symbol was not loaded." ),
1202 double scalingFactor =
1205 bool mirrorInvert = docSym.
Mirror;
1207 for( std::pair<FIGURE_ID, FIGURE> figPair : docSymDef.
Figures )
1209 FIGURE fig = figPair.second;
1212 centreOfTransform, mirrorInvert );
1215 for( std::pair<TEXT_ID, TEXT> textPair : docSymDef.
Texts )
1217 TEXT txt = textPair.second;
1219 txt.
Mirror = ( txt.
Mirror ) ? !mirrorInvert : mirrorInvert;
1225 scalingFactor, centreOfTransform, mirrorInvert );
1244 auto findAndReplaceTextField = [&](
TEXT_FIELD_NAME aField, wxString aValue ) {
1266 std::map<wxString, wxString>& txtVars = pj->
GetTextVars();
1282 wxString varValue = txtvalue.second;
1284 txtVars.insert( { varName, varValue } );
1289 wxString varName = txtvalue.first;
1290 wxString varValue = txtvalue.second;
1292 txtVars.insert( { varName, varValue } );
1297 m_reporter->
Report(
_(
"Text Variables could not be set as there is no project attached." ),
1313 std::vector<LIB_ITEM*> drawItems = aSymbol->
GetUnitDrawItems( gateNumber, 0 );
1318 for( std::pair<FIGURE_ID, FIGURE> figPair : symbol.Figures )
1320 FIGURE fig = figPair.second;
1335 for( std::pair<TERMINAL_ID, TERMINAL> termPair : symbol.Terminals )
1339 wxString pinName = wxEmptyString;
1349 if( pinNum.IsEmpty() )
1351 if( !csPin.Identifier.IsEmpty() )
1352 pinNum = csPin.Identifier;
1361 pinNumMap.insert( { term.
ID, pinNum } );
1370 pin->SetLength( 0 );
1372 pin->SetUnit( gateNumber );
1373 pin->SetNumber( pinNum );
1374 pin->SetName( pinName );
1379 if( symbol.PinNumberLocations.count( term.
ID ) )
1385 if( symbol.PinLabelLocations.count( term.
ID ) )
1391 pin->SetNumberTextSize( pinNumberHeight );
1392 pin->SetNameTextSize( pinNameHeight );
1396 pin->SetVisible(
false );
1407 m_pinNumsMap.insert( { aCadstarPart->
ID + aGateID, pinNumMap } );
1409 for( std::pair<TEXT_ID, TEXT> textPair : symbol.Texts )
1411 TEXT csText = textPair.second;
1415 libtext->
SetUnit( gateNumber );
1427 if( csText.
Text.Contains( wxT(
"\n" ) ) )
1429 wxArrayString strings;
1431 wxPoint firstLinePos;
1433 for(
size_t ii = 0; ii < strings.size(); ++ii )
1440 LIB_TEXT* line = static_cast<LIB_TEXT*>( libtext->
Clone() );
1444 line->SetTextPos( linePos );
1447 line->SetMultilineAllowed(
false );
1473 if( symbol.TextLocations.find(
PART_NAME_ATTRID ) != symbol.TextLocations.end() )
1481 field =
new LIB_FIELD( aSymbol, fieldID );
1491 wxString partName = aCadstarPart->
Name;
1492 partName.Replace( wxT(
"\n" ), wxT(
"\\n" ) );
1493 partName.Replace( wxT(
"\r" ), wxT(
"\\r" ) );
1494 partName.Replace( wxT(
"\t" ), wxT(
"\\t" ) );
1504 wxString footprintRefName = wxEmptyString;
1505 wxString footprintAlternateName = wxEmptyString;
1507 auto loadLibraryField =
1513 aAttributeVal.Value.Replace( wxT(
"\n" ), wxT(
"\\n" ) );
1514 aAttributeVal.Value.Replace( wxT(
"\r" ), wxT(
"\\r" ) );
1515 aAttributeVal.Value.Replace( wxT(
"\t" ), wxT(
"\\t" ) );
1521 if( attrName == wxT(
"(PartDefinitionNameStem)" ) )
1524 aAttributeVal.Value.Replace( wxT(
" " ),
"_" );
1528 else if( attrName == wxT(
"(PartDescription)" ) )
1533 else if( attrName == wxT(
"(PartDefinitionReferenceName)" ) )
1535 footprintRefName = aAttributeVal.Value;
1538 else if( attrName == wxT(
"(PartDefinitionAlternateName)" ) )
1540 footprintAlternateName = aAttributeVal.Value;
1549 attrField =
new LIB_FIELD( aSymbol, fieldID );
1550 attrField->
SetName( attrName );
1554 wxASSERT( attrField->
GetName() == attrName );
1555 attrField->
SetText( aAttributeVal.Value );
1556 attrField->
SetUnit( gateNumber );
1561 if( aAttributeVal.HasLocation )
1567 else if( symbol.TextLocations.find( aAttributeVal.AttributeID )
1568 != symbol.TextLocations.end() )
1571 TEXT_LOCATION symTxtLoc = symbol.TextLocations.at( aAttributeVal.AttributeID );
1574 else if( symbol.AttributeValues.find( attrid ) != symbol.AttributeValues.end()
1575 && symbol.AttributeValues.at( attrid ).HasLocation )
1595 loadLibraryField( attrVal );
1599 for( std::pair<ATTRIBUTE_ID, ATTRIBUTE_VALUE> attr : aCadstarPart->
AttributeValues )
1602 loadLibraryField( attrVal );
1605 wxString fpNameInLibrary =
generateLibName( footprintRefName, footprintAlternateName );
1606 wxArrayString fpFilters;
1607 fpFilters.Add( fpNameInLibrary );
1612 wxFileName schFilename(
Filename );
1613 wxString libName = schFilename.GetName();
1627 wxPoint aSymbolOrigin,
1630 int aLineThickness )
1632 const VERTEX* prev = &aCadstarVertices.at( 0 );
1637 for(
size_t i = 1; i < aCadstarVertices.size(); i++ )
1639 cur = &aCadstarVertices.at( i );
1645 wxPoint centerPoint;
1650 centerPoint = ( startPoint + endPoint ) / 2;
1680 shape->
SetEnd( startPoint );
1685 shape->
SetEnd( endPoint );
1691 shape->
SetUnit( aGateNumber );
1710 aCadstarAttrLoc.
Mirror );
1716 double& aComponentOrientationDeciDeg )
1735 int compOrientation = 0;
1737 if( aCadstarSymbol.
Mirror )
1739 compAngleDeciDeg = -compAngleDeciDeg;
1748 "degrees in the original CADSTAR design but " 1749 "KiCad only supports rotation angles multiples " 1750 "of 90 degrees. The connecting wires will need " 1753 compAngleDeciDeg / 10.0 ),
1762 "not exist in the design. The symbol was not " 1772 wxString gate = ( aCadstarSymbol.
GateID.IsEmpty() ) ? wxT(
"A" ) : aCadstarSymbol.
GateID;
1773 wxString partGateIndex = aCadstarSymbol.
PartRef.
RefID + gate;
1780 std::map<wxString, LIB_PIN*> pinNumToLibPinMap;
1782 for(
auto& term : termNumMap )
1784 wxString pinNum = term.second;
1785 pinNumToLibPinMap.insert( { pinNum,
1789 auto replacePinNumber = [&]( wxString aOldPinNum, wxString aNewPinNum )
1791 if( aOldPinNum == aNewPinNum )
1794 LIB_PIN* libpin = pinNumToLibPinMap.at( aOldPinNum );
1799 for(
auto& pinPair : aCadstarSymbol.
PinNumbers )
1801 SYMBOL::PIN_NUM
pin = pinPair.second;
1803 replacePinNumber( termNumMap.at(
pin.TerminalID ),
1808 for(
auto& pinPair : aCadstarSymbol.
PinNames )
1811 replacePinNumber( termNumMap.at(
pin.TerminalID ),
pin.NameOrLabel );
1824 const ATTRIBUTE_LOCATION& aCadstarAttrLoc,
const double& aComponentOrientationDeciDeg,
1825 bool aIsMirrored,
SCH_FIELD* aKiCadField )
1833 long long cadstarAngle =
getCadstarAngle( textAngle - aComponentOrientationDeciDeg );
1840 int textIsVertical =
KiROUND( textAngle / 900.0 ) % 2;
1842 if( textIsVertical )
1845 alignment =
mirrorX( alignment );
1853 aCadstarAttrLoc.
Mirror );
1858 double aOrientAngleDeciDeg,
double& aReturnedOrientationDeciDeg )
1864 if( oDeg >= -450 && oDeg <= 450 )
1867 aReturnedOrientationDeciDeg = 0.0;
1869 else if( oDeg >= 450 && oDeg <= 1350 )
1872 aReturnedOrientationDeciDeg = 900.0;
1874 else if( oDeg >= 1350 || oDeg <= -1350 )
1877 aReturnedOrientationDeciDeg = 1800.0;
1882 aReturnedOrientationDeciDeg = 2700.0;
1885 return compOrientation;
1893 auto logUnknownNetElementError =
1897 "The net was not properly loaded and may " 1898 "require manual fixing." ),
1907 if( aNetElementID.Contains( wxT(
"J" ) ) )
1910 return logUnknownNetElementError();
1912 return aNet.
Junctions.at( aNetElementID ).Location;
1914 else if( aNetElementID.Contains( wxT(
"P" ) ) )
1917 return logUnknownNetElementError();
1923 return logUnknownNetElementError();
1927 wxPoint symbolOrigin = sym.
Origin;
1930 return logUnknownNetElementError();
1932 wxPoint libpinPosition =
1936 wxPoint pinOffset = libpinPosition - libOrigin;
1940 wxPoint pinPosition = symbolOrigin + pinOffset;
1945 pinPosition.x = ( 2 * symbolOrigin.x ) - pinPosition.x;
1947 double adjustedOrientationDecideg;
1950 RotatePoint( &pinPosition, symbolOrigin, -adjustedOrientationDecideg );
1953 retval.x = pinPosition.x;
1954 retval.y = pinPosition.y;
1958 else if( aNetElementID.Contains( wxT(
"BT" ) ) )
1961 return logUnknownNetElementError();
1963 return aNet.
BusTerminals.at( aNetElementID ).SecondPoint;
1965 else if( aNetElementID.Contains( wxT(
"BLKT" ) ) )
1968 return logUnknownNetElementError();
1974 return logUnknownNetElementError();
1976 return Schematic.
Blocks.at( blockid ).Terminals.at( termid ).Position;
1978 else if( aNetElementID.Contains( wxT(
"D" ) ) )
1981 return logUnknownNetElementError();
1983 return aNet.
Danglers.at( aNetElementID ).Position;
1987 return logUnknownNetElementError();
1996 wxString netname = aNet.
Name;
1998 if( netname.IsEmpty() )
2006 const wxPoint& aEndPoint,
const LINECODE_ID& aCadstarLineCodeID,
2008 const wxPoint& aMoveVector,
const double& aRotationAngleDeciDeg,
2009 const double& aScalingFactor,
const wxPoint& aTransformCentre,
const bool& aMirrorInvert )
2013 segment->
SetLayer( aKiCadSchLayerID );
2018 wxPoint startPoint =
applyTransform( aStartPoint, aMoveVector, aRotationAngleDeciDeg,
2019 aScalingFactor, aTransformCentre, aMirrorInvert );
2020 wxPoint endPoint =
applyTransform( aEndPoint, aMoveVector, aRotationAngleDeciDeg,
2021 aScalingFactor, aTransformCentre, aMirrorInvert );
2032 const wxPoint& aMoveVector,
const double& aRotationAngleDeciDeg,
2033 const double& aScalingFactor,
const wxPoint& aTransformCentre,
const bool& aMirrorInvert )
2035 const VERTEX* prev = &aCadstarVertices.at( 0 );
2041 for(
size_t ii = 1; ii < aCadstarVertices.size(); ii++ )
2043 cur = &aCadstarVertices.at( ii );
2053 centerPoint = ( startPoint + endPoint ) / 2;
2065 double arcStartAngle =
getPolarAngle( startPoint - centerPoint );
2066 double arcEndAngle =
getPolarAngle( endPoint - centerPoint );
2067 double arcAngleDeciDeg = arcEndAngle - arcStartAngle;
2074 SHAPE_ARC tempArc( centerPoint, startPoint, arcAngleDeciDeg / 10.0 );
2079 for(
int jj = 0; jj < arcSegments.
SegmentCount(); jj++ )
2081 wxPoint segStart = (wxPoint) arcSegments.
Segment( jj ).
A;
2082 wxPoint segEnd = (wxPoint) arcSegments.
Segment( jj ).
B;
2085 aKiCadSchLayerID, aMoveVector, aRotationAngleDeciDeg,
2086 aScalingFactor, aTransformCentre, aMirrorInvert );
2093 aKiCadSchLayerID, aMoveVector, aRotationAngleDeciDeg,
2094 aScalingFactor, aTransformCentre, aMirrorInvert );
2098 wxFAIL_MSG( wxT(
"Unknown CADSTAR Vertex type" ) );
2109 const wxPoint& aMoveVector,
const double& aRotationAngleDeciDeg,
2110 const double& aScalingFactor,
const wxPoint& aTransformCentre,
const bool& aMirrorInvert )
2113 aCadstarSheetIDOverride, aKiCadSchLayerID, aMoveVector,
2114 aRotationAngleDeciDeg, aScalingFactor, aTransformCentre, aMirrorInvert );
2119 aKiCadSchLayerID, aMoveVector, aRotationAngleDeciDeg, aScalingFactor,
2120 aTransformCentre, aMirrorInvert );
2126 LAYER_ID aCadstarSheetID,
const wxPoint& aPosition, wxSize aSheetSize,
2130 wxT(
"Sheet already loaded!" ) );
2136 sheet->SetSize( aSheetSize );
2137 sheet->SetScreen( screen );
2147 wxString loadedFilename = wxFileName(
Filename ).GetName();
2148 std::string filename =
wxString::Format( wxT(
"%s_%02d" ), loadedFilename, sheetNum ).ToStdString();
2153 filenameField.
SetText( filename );
2156 sheet->GetScreen()->SetFileName( fn.GetFullPath() );
2159 sheet->AddInstance( instance );
2162 sheet->SetPageNumber( instance, pageNumStr );
2164 sheet->AutoplaceFields(
nullptr,
false );
2166 m_sheetMap.insert( { aCadstarSheetID, sheet } );
2176 wxT(
"FIXME! Parent sheet should be loaded before attempting to load subsheets" ) );
2180 BLOCK& block = blockPair.second;
2182 if( block.
LayerID == aCadstarSheetID && block.
Type == BLOCK::TYPE::CHILD )
2186 if( block.
Figures.size() > 0 )
2189 "is drawn on sheet '%s' but is not " 2190 "linked to another sheet in the " 2191 "design. KiCad requires all sheet " 2192 "symbols to be associated to a sheet, " 2193 "so the block was not loaded." ),
2205 std::pair<wxPoint, wxSize> blockExtents;
2207 if( block.
Figures.size() > 0 )
2214 "Block %s references a child sheet but has no " 2215 "Figure defined." ),
2228 field.SetVisible(
false );
2275 std::vector<LAYER_ID> childSheets, orphanSheets;
2280 BLOCK& block = blockPair.second;
2283 if( block.
Type == BLOCK::TYPE::CHILD )
2284 childSheets.push_back( assocSheetID );
2290 if( std::find( childSheets.begin(), childSheets.end(), sheetID ) == childSheets.end() )
2291 orphanSheets.push_back( sheetID );
2294 return orphanSheets;
2304 if( sheetID == aCadstarSheetID )
2316 wxCHECK_MSG( aItem, , wxT(
"aItem is null" ) );
2318 if( aCadstarSheetID == wxT(
"ALL_SHEETS" ) )
2324 LAYER_ID sheetID = sheetPair.first;
2331 aItem = duplicateItem;
2333 else if( aCadstarSheetID == wxT(
"NO_SHEET" ) )
2336 false, wxT(
"Trying to add an item to NO_SHEET? This might be a documentation symbol." ) );
2342 m_sheetMap.at( aCadstarSheetID )->GetScreen()->Append( aItem );
2347 wxASSERT_MSG(
false, wxT(
"Unknown Sheet ID." ) );
2354 const wxString& aSymdefName,
const wxString& aSymDefAlternate )
2363 && symdef.
Alternate.Lower() == aSymDefAlternate.Lower() )
2447 const PART_ID& aCadstarPartID )
2469 for( std::pair<PART_DEFINITION_PIN_ID, PART::DEFINITION::PIN> pinPair :
2472 PART::DEFINITION::PIN partPin = pinPair.second;
2474 if( partPin.TerminalGate == aGateID && partPin.TerminalPin == aTerminalID )
2478 return PART::DEFINITION::PIN();
2503 if( aCadstarGateID.IsEmpty() )
2506 return (
int) aCadstarGateID.Upper().GetChar( 0 ) - (int) wxUniChar(
'A' ) + 1;
2527 const double& aOrientationDeciDeg )
2533 if( oDeg >= -450 && oDeg <= 450 )
2535 else if( oDeg >= 450 && oDeg <= 1350 )
2537 else if( oDeg >= 1350 || oDeg <= -1350 )
2549 switch( aCadstarAlignment )
2568 default: wxFAIL_MSG( wxT(
"Unknown Cadstar Alignment" ) );
return aCadstarAlignment;
2576 switch( aCadstarAlignment )
2590 default: wxFAIL_MSG( wxT(
"Unknown Cadstar Alignment" ) );
return aCadstarAlignment;
2599 const long long aCadstarOrientAngle,
2612 aKiCadTextItem->
SetText( escapedText );
2616 if( textWidth == 0 )
2626 ALIGNMENT textAlignment = aCadstarAlignment;
2632 textAlignment =
mirrorX( aCadstarAlignment );
2636 switch( aAlignment )
2690 EDA_ITEM* textEdaItem = dynamic_cast<EDA_ITEM*>( aKiCadTextItem );
2691 wxCHECK( textEdaItem, );
2693 switch( textEdaItem->
Type() )
2704 int quadrant =
KiROUND( angleDeciDeg / 900.0 );
2717 textAlignment =
rotate180( textAlignment );
2721 textAlignment =
rotate180( textAlignment );
2723 default: wxFAIL_MSG( wxT(
"Unknown Quadrant" ) );
2727 setAlignment( aKiCadTextItem, textAlignment );
2736 setAlignment( aKiCadTextItem, textAlignment );
2738 int off = static_cast<SCH_TEXT*>( aKiCadTextItem )->GetTextOffset();
2760 static_cast<SCH_TEXT*>( aKiCadTextItem )->SetLabelSpinStyle( spin );
2764 wxFAIL_MSG( wxT(
"Unexpected item type" ) );
2783 aCadstarTextElement.
Mirror );
2790 long long aScalingFactorNumerator,
2791 long long aScalingFactorDenominator )
2795 if( aScalingFactorNumerator == aScalingFactorDenominator )
2799 [&](
int aLength ) ->
int 2801 return( aLength * aScalingFactorNumerator ) / aScalingFactorDenominator;
2805 [&]( wxPoint aCoord ) -> wxPoint
2807 return wxPoint( scaleLen( aCoord.x ), scaleLen( aCoord.y ) );
2811 [&]( wxSize aSize ) -> wxSize
2813 return wxSize( scaleLen( aSize.x ), scaleLen( aSize.y ) );
2820 switch( item.Type() )
2824 LIB_SHAPE& shape = static_cast<LIB_SHAPE&>( item );
2844 LIB_PIN&
pin = static_cast<LIB_PIN&>( item );
2846 pin.SetPosition( scalePt(
pin.GetPosition() ) );
2847 pin.SetLength( scaleLen(
pin.GetLength() ) );
2853 LIB_TEXT& txt = static_cast<LIB_TEXT&>( item );
2885 LIB_SHAPE& shape = static_cast<LIB_SHAPE&>( *shapeIt );
2887 if( aGateNumber > 0 && shape.
GetUnit() != aGateNumber )
2900 if( pt0 != pt1 && uniqueSegments.count( pt0 ) == 0 && uniqueSegments.count( pt1 ) == 0 )
2903 if( pt0.
x == pt1.
x || pt0.
y == pt1.
y )
2905 uniqueSegments.insert( { pt0, poly } );
2906 uniqueSegments.insert( { pt1, poly } );
2913 aSymbolToFix->
GetPins( pins, aGateNumber );
2915 for(
auto&
pin : pins )
2917 auto setPinOrientation =
2918 [&](
double aAngleRad )
2922 if( oDeg >= -45 && oDeg <= 45 )
2923 pin->SetOrientation(
'R' );
2924 else if( oDeg >= 45 && oDeg <= 135 )
2925 pin->SetOrientation(
'U' );
2926 else if( oDeg >= 135 || oDeg <= -135 )
2927 pin->SetOrientation(
'L' );
2929 pin->SetOrientation(
'D' );
2932 if( uniqueSegments.count(
pin->GetPosition() ) )
2938 if( otherPt ==
pin->GetPosition() )
2939 otherPt = poly.
CPoint( 1 );
2943 pin->SetLength( vec.EuclideanNorm() );
2944 setPinOrientation( vec.Angle() );
2951 const FIGURE& aCadstarFigure )
2958 if( upperLeft.x > v.
End.x )
2959 upperLeft.x = v.
End.x;
2961 if( upperLeft.y < v.
End.y )
2962 upperLeft.y = v.
End.y;
2964 if( lowerRight.x < v.
End.x )
2965 lowerRight.x = v.
End.x;
2967 if( lowerRight.y > v.
End.y )
2968 lowerRight.y = v.
End.y;
2975 if( upperLeft.x > v.
End.x )
2976 upperLeft.x = v.
End.x;
2978 if( upperLeft.y < v.
End.y )
2979 upperLeft.y = v.
End.y;
2981 if( lowerRight.x < v.
End.x )
2982 lowerRight.x = v.
End.x;
2984 if( lowerRight.y > v.
End.y )
2985 lowerRight.y = v.
End.y;
2992 wxPoint size = lowerRightKiCad - upperLeftKiCad;
2994 return { upperLeftKiCad, wxSize( abs( size.x ), abs( size.y ) ) };
3010 const wxPoint& aCadstarCentre )
3022 const wxPoint& aMoveVector,
const double& aRotationAngleDeciDeg,
3023 const double& aScalingFactor,
const wxPoint& aTransformCentre,
const bool& aMirrorInvert )
3025 wxPoint retVal = aPoint;
3027 if( aScalingFactor != 1.0 )
3030 retVal -= aTransformCentre;
3031 retVal.x =
KiROUND( retVal.x * aScalingFactor );
3032 retVal.y =
KiROUND( retVal.y * aScalingFactor );
3033 retVal += aTransformCentre;
3038 MIRROR( retVal.x, aTransformCentre.x );
3041 if( aRotationAngleDeciDeg != 0.0 )
3043 RotatePoint( &retVal, aTransformCentre, aRotationAngleDeciDeg );
3046 if( aMoveVector != wxPoint{ 0, 0 } )
3048 retVal += aMoveVector;
3064 ( (
double) aPoint.x * (
double) aPoint.x ) + ( (
double) aPoint.y * (
double) aPoint.y ) );
Field Reference of part, i.e. "IC21".
std::map< NETELEMENT_ID, BLOCK_TERM > BlockTerminals
int getKiCadUnitNumberFromGate(const GATE_ID &aCadstarGateID)
power input (GND, VCC for ICs). Must be connected to a power output.
std::vector< VERTEX > Vertices
wxPoint m_designCenter
Used for calculating the required offset to apply to the Cadstar design so that it fits in KiCad canv...
LIB_FIELD * FindField(const wxString &aFieldName)
Find a field within this symbol matching aFieldName and returns it or NULL if not found.
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
LAYER_ID LayerID
Move all objects in the Symdef to this layer.
void GetPins(LIB_PINS &aList, int aUnit=0, int aConvert=0) const
Return a list of pin object pointers from the draw item list.
ELECTRICAL_PINTYPE getKiCadPinType(const PART::PIN_TYPE &aPinType)
std::map< wxString, LIB_SYMBOL * > m_powerSymLibMap
Map of KiCad Power Symbol Library items.
SCH_SYMBOL * loadSchematicSymbol(const SYMBOL &aCadstarSymbol, const LIB_SYMBOL &aKiCadPart, double &aComponentOrientationDeciDeg)
void SetShape(PINSHEETLABEL_SHAPE aShape)
virtual std::map< wxString, wxString > & GetTextVars() const
void AddPoint(const wxPoint &aPosition)
virtual void SetMaxProgress(int aMaxProgress)=0
Fix the value that gives the 100 percent progress bar length (inside the current virtual zone).
std::map< ROUTECODE_ID, ROUTECODE > RouteCodes
ITERATOR begin(int aType=UNDEFINED_TYPE)
int Intersect(const SEG &aSeg, INTERSECTIONS &aIp) const
Find all intersection points between our line chain and the segment aSeg.
T NormalizeAngleNeg(T Angle)
Normalize angle to be in the 0.0 .. -360.0 range: angle is in 1/10 degrees.
int getKiCadLength(long long aCadstarLength)
virtual void BeginPhase(int aPhase)=0
Initialize the aPhase virtual zone of the dialog progress bar.
std::map< PART_ID, TERMINAL_TO_PINNUM_MAP > m_pinNumsMap
Map of pin numbers in CADSTAR parts.
std::vector< INTERSECTION > INTERSECTIONS
std::pair< wxPoint, wxSize > getFigureExtentsKiCad(const FIGURE &aCadstarFigure)
std::map< TERMINAL_ID, TERMINAL > Terminals
void loadShapeVertices(const std::vector< VERTEX > &aCadstarVertices, LINECODE_ID aCadstarLineCodeID, LAYER_ID aCadstarSheetID, SCH_LAYER_ID aKiCadSchLayerID, const wxPoint &aMoveVector={ 0, 0 }, const double &aRotationAngleDeciDeg=0.0, const double &aScalingFactor=1.0, const wxPoint &aTransformCentre={ 0, 0 }, const bool &aMirrorInvert=false)
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 Merge(const EDA_RECT &aRect)
Modify the position and size of the rectangle in order to contain aRect.
virtual size_t GetPointCount() const override
Container for project specific data.
std::map< PART_DEFINITION_PIN_ID, PIN > Pins
const wxString PartNameFieldName
PART::DEFINITION::PIN getPartDefinitionPin(const PART &aCadstarPart, const GATE_ID &aGateID, const TERMINAL_ID &aTerminalID)
void AddField(LIB_FIELD *aField)
Add a field.
void SetPosition(const wxPoint &aPosition) override
LIB_FIELD & GetFootprintField()
Return reference to the footprint field.
int getLineThickness(const LINECODE_ID &aCadstarLineCodeID)
void loadSchematicSymbolInstances()
void SetOrientation(int aOrientation)
Compute the new transform matrix based on aOrientation for the symbol which is applied to the current...
void SetEnd(const wxPoint &aEnd)
wxString ReferenceName
This is the name which identifies the symbol in the library Multiple components may exist with the sa...
wxPoint GetStartPoint() const
SCH_FIELD * GetField(MANDATORY_FIELD_T aFieldType)
Return a mandatory field in this symbol.
long SignalNum
This is undefined if the net has been given a name.
void SetFields(const std::vector< SCH_FIELD > &aFields)
Set multiple schematic fields.
std::map< GATE_ID, GATE > GateSymbols
wxFileName m_libraryFileName
Holds all the data relating to one schematic.
ASSIGNMENTS_SCM Assignments
#define DEFAULT_WIRE_WIDTH_MILS
The default bus width in mils. (can be changed in preference menu)
std::map< ATTRIBUTE_ID, ATTRNAME > AttributeNames
void SetSize(const wxSize &aSize)
SCH_SHEET * Last() const
Return a pointer to the last SCH_SHEET of the list.
#define SIGNALNAME_ORIGIN_ATTRID
long ScaleRatioNumerator
Documentation symbols can be arbitrarily scaled when added to a design.
std::map< SYMDEF_ID, SYMDEF_SCM > SymbolDefinitions
EDA_RECT GetBodyAndPinsBoundingBox() const
Return a bounding box for the symbol body and pins but not the fields.
wxString getAttributeName(const ATTRIBUTE_ID &aCadstarAttributeID)
const wxPoint & GetStart() const
Return the starting point of the graphic.
TEXT_FIELD_NAME
These are special fields in text objects enclosed between the tokens '<@' and '>' such as <@[FIELD_NA...
wxString GetName() const override
TYPE Type
Determines what the associated layer is, whether parent, child or clone.
Define a symbol library graphical text item.
std::map< VARIANT_ID, VARIANT > Variants
void SetPoint(int aIndex, const VECTOR2I &aPos)
Move a point to a specific location.
std::vector< LIB_PIN * > LIB_PINS
Helper for defining a list of pin object pointers.
double getAngleTenthDegree(const long long &aCadstarAngle)
std::map< LINECODE_ID, LINECODE > LineCodes
double getPolarAngle(const wxPoint &aPoint)
void SetLineWidth(const int aSize)
CADSTAR_SCHEMATIC Schematic
void push_back(SCH_SHEET *aSheet)
Forwarded method from std::vector.
wxPoint GetPosition() const override
std::map< LAYER_ID, SCH_SHEET * > m_sheetMap
Map between Cadstar and KiCad Sheets.
void SetItalic(bool isItalic)
Field object used in symbol libraries.
EDA_RECT GetTextBox(int aLine=-1, bool aInvertY=false) const
Useful in multiline texts to calculate the full text or a line area (for zones filling,...
double RAD2DEG(double rad)
pin for passive symbols: must be connected, and can be connected to any pin
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly)
Populate a std::vector with SCH_FIELDs.
void SetTextPos(const wxPoint &aPoint)
void SetUnitCount(int aCount, bool aDuplicateDrawItems=true)
Set the units per symbol count.
const int SMALL_LABEL_SIZE
std::map< NETELEMENT_ID, DANGLER > Danglers
std::map< FIGURE_ID, FIGURE > Figures
double GetTextAngle() const
long ScaleRatioDenominator
Documentation symbols can be arbitrarily scaled when added to a design.
TEXTCODE getTextCode(const TEXTCODE_ID &aCadstarTextCodeID)
unknown electrical properties: creates always a warning when connected
std::map< PART_GATE_ID, SYMDEF_ID > m_partSymbolsMap
Map holding the symbols loaded so far for a particular PART_ID and GATE_ID.
#define SYMBOL_NAME_ATTRID
Symbol Name attribute ID - used for placement of designators on the schematic.
void SetPageSettings(const PAGE_INFO &aPageSettings)
std::map< FIGURE_ID, FIGURE > Figures
#define KI_FALLTHROUGH
The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely fallthrough from ...
bool HasLocation
Flag to know if this ATTRIBUTE_VALUE has a location i.e.
ALIGNMENT Alignment
In CADSTAR The default alignment for a TEXT object (when "(No Alignment()" is selected) Bottom Left o...
void SetTextSize(const wxSize &aNewSize)
std::vector< SCH_FIELD > SCH_FIELDS
A container for several SCH_FIELD items.
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.
long long getCadstarAngle(const double &aAngleTenthDegree)
void loadSheetAndChildSheets(LAYER_ID aCadstarSheetID, const wxPoint &aPosition, wxSize aSheetSize, const SCH_SHEET_PATH &aParentSheet)
std::map< TEXT_ID, TEXT > Texts
LIB_FIELD & GetValueField()
Return reference to the value field.
void RotatePoint(int *pX, int *pY, double angle)
void RemoveDrawItem(LIB_ITEM *aItem)
Remove draw aItem from list.
A logical library item identifier and consists of various portions much like a URI.
const SHAPE_LINE_CHAIN Reverse() const
Reverse point order in the line chain.
void applyTextSettings(EDA_TEXT *aKiCadTextItem, const TEXTCODE_ID &aCadstarTextCodeID, const ALIGNMENT &aCadstarAlignment, const JUSTIFICATION &aCadstarJustification, const long long aCadstarOrientAngle=0, bool aMirrored=false)
ATTRIBUTE_LOCATION BlockLabel
POINT getLocationOfNetElement(const NET_SCH &aNet, const NETELEMENT_ID &aNetElementID)
std::map< BUS_ID, BUS > Buses
int GetTextThickness() const
std::map< wxString, wxString > FilenamesToTextMap
CADSTAR doesn't have user defined text fields but does allow loading text from a file.
void SetName(const wxString &aName)
Set a user definable field name to aName.
wxPoint getKiCadLibraryPoint(const wxPoint &aCadstarPoint, const wxPoint &aCadstarCentre)
int getTextHeightFromTextCode(const TEXTCODE_ID &aCadstarTextCodeID)
std::pair< PART_ID, GATE_ID > PART_GATE_ID
long Modifier1
It seems this is related to weight. 400=Normal, 700=Bold.
SCH_SCREEN * GetScreen() const
Define a library symbol object.
LAYER_ID AssocLayerID
Parent or Child linked sheet.
PLOT_DASH_TYPE getLineStyle(const LINECODE_ID &aCadstarLineCodeID)
const PAGE_INFO & GetPageSettings() const
int FindSegment(const VECTOR2I &aP, int aThreshold=1) const
Search for segment containing point aP.
double getPolarRadius(const wxPoint &aPoint)
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Report a string with a given severity.
LAYER_ID LayerID
Sheet on which symbol is located.
void AddPin(SCH_SHEET_PIN *aSheetPin)
Add aSheetPin to the sheet.
virtual const wxString GetProjectPath() const
Return the full path of the project.
LIB_FIELD & GetReferenceField()
Return reference to the reference designator field.
void loadLibrarySymbolShapeVertices(const std::vector< VERTEX > &aCadstarVertices, wxPoint aSymbolOrigin, LIB_SYMBOL *aSymbol, int aGateNumber, int aLineThickness)
void SetPageNumber(const SCH_SHEET_PATH &aInstance, const wxString &aPageNumber)
Set the page number for the sheet instance aInstance.
POINT Origin
Origin of the component (this is used as the reference point when placing the component in the design...
virtual void SetParent(EDA_ITEM *aParent)
wxString GetName(bool aUseDefaultName=true) const
Return the field name.
std::vector< struct LIB_SYMBOL_UNIT > GetUnitDrawItems()
Return a list of LIB_ITEM objects separated by unit and convert number.
void Parse()
Parses the file.
long ScaleRatioNumerator
Symbols can be arbitrarily scaled in CADSTAR.
std::vector< LAYER_ID > SheetOrder
A vector to also store the order in which sheets are to be displayed.
The base class for drawable items used by schematic library symbols.
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
void Append(int aX, int aY, bool aAllowDuplication=false)
Append a new point at the end of the line chain.
ALIGNMENT Alignment
In CADSTAR The default alignment for a TEXT object (when "(No Alignment()" is selected) Bottom Left o...
const VECTOR2I NearestPoint(const VECTOR2I &aP, bool aAllowInternalShapePoints=true) const
Find a point on the line chain that is closest to point aP.
This file contains miscellaneous commonly used macros and functions.
void SetEndPoint(const wxPoint &aPosition)
Loads a csa file into a KiCad SCHEMATIC object.
std::map< PART_ID, LIB_SYMBOL * > m_partMap
Map between Cadstar and KiCad Parts.
void MIRROR(T &aPoint, const T &aMirrorRef)
Updates aPoint with the mirror of aPoint relative to the aMirrorRef.
std::map< SYMBOL_ID, SYMBOL > Symbols
void loadSymbolFieldAttribute(const ATTRIBUTE_LOCATION &aCadstarAttrLoc, const double &aComponentOrientationDeciDeg, bool aIsMirrored, SCH_FIELD *aKiCadField)
int GetTextHeight() const
ITERATOR end(int aType=UNDEFINED_TYPE)
std::map< ATTRIBUTE_ID, ATTRIBUTE_VALUE > AttributeValues
Some attributes are defined within the part definition, whilst others are defined in the part itself.
ATTRIBUTE_LOCATION AttributeLocation
void loadGraphicStaightSegment(const wxPoint &aStartPoint, const wxPoint &aEndPoint, const LINECODE_ID &aCadstarLineCodeID, const LAYER_ID &aCadstarSheetID, const SCH_LAYER_ID &aKiCadSchLayerID, const wxPoint &aMoveVector={ 0, 0 }, const double &aRotationAngleDeciDeg=0.0, const double &aScalingFactor=1.0, const wxPoint &aTransformCentre={ 0, 0 }, const bool &aMirrorInvert=false)
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...
void SetNumber(const wxString &aNumber)
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
void SetStart(const wxPoint &aStart)
static const long FONT_BOLD
std::vector< SCH_FIELD > & GetFields()
void SetPosition(const wxPoint &aPosition) override
T NormalizeAngle180(T Angle)
Normalize angle to be in the -180.0 .. 180.0 range.
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
virtual void SetVisible(bool aVisible)
void SetShowPinNames(bool aShow)
Set or clear the pin name visibility flag.
PARTNAMECOL SymbolPartNameColor
void SetLineStyle(const PLOT_DASH_TYPE aStyle)
SYMBOLVARIANT SymbolVariant
const wxPoint & GetEnd() const
Return the ending point of the graphic.
SCH_FIELD * AddField(const SCH_FIELD &aField)
Add a field to the symbol.
void loadDocumentationSymbols()
Represents a point in x,y coordinates.
ALIGNMENT
From CADSTAR Help: "Text Alignment enables you to define the position of an alignment origin for all ...
wxPoint applyTransform(const wxPoint &aPoint, const wxPoint &aMoveVector={ 0, 0 }, const double &aRotationAngleDeciDeg=0.0, const double &aScalingFactor=1.0, const wxPoint &aTransformCentre={ 0, 0 }, const bool &aMirrorInvert=false)
Field Value of part, i.e. "3.3K".
virtual void SetText(const wxString &aText)
SCH_ITEM * Duplicate(bool doClone=false) const
Routine to create a new copy of given item.
long ScaleRatioDenominator
bool ReplaceIllegalFileNameChars(std::string *aName, int aReplaceChar)
Checks aName for illegal file name characters.
const std::vector< VECTOR2I > & CPoints() const
SCH_LAYER_ID
Eeschema drawing layers.
std::map< ATTRIBUTE_ID, ATTRCOL > AttributeColors
long TERMINAL_ID
Terminal is the pin identifier in the schematic.
DOCUMENTATION_SYMBOL_ID ID
std::map< NETELEMENT_ID, SYM_TERM > Terminals
const int LexicographicalCompare(const VECTOR2< T > &aA, const VECTOR2< T > &aB)
std::map< PART_ID, PART > PartDefinitions
SHAPE_LINE_CHAIN & Outline(int aIndex)
Describe the page size and margins of a paper page on which to eventually print or plot.
SYMDEF_ID getSymDefFromName(const wxString &aSymdefName, const wxString &aSymDefAlternate)
iterator end()
Returns a read/write iterator that points to one past the last element in the EE_RTREE.
long Width
Defaults to 0 if using system fonts or, if using CADSTAR font, default to equal height (1:1 aspect ra...
void SetPosition(const wxPoint &aPosition) override
const wxSize & GetTextSize() const
std::map< SYMBOL_ID, SCH_GLOBALLABEL * > m_globalLabelsMap
Map between Cadstar and KiCad Global Labels.
void SetVertJustify(EDA_TEXT_VJUSTIFY_T aType)
std::map< BUS_ID, std::shared_ptr< BUS_ALIAS > > m_busesMap
Map of Cadstar and KiCad Buses.
void SetLayer(SCH_LAYER_ID aLayer)
Set the layer this item is on.
void SetStartPoint(const wxPoint &aPosition)
int GetFieldCount() const
Return the number of fields in this symbol.
VARIANT_HIERARCHY VariantHierarchy
SCH_TEXT * getKiCadSchText(const TEXT &aCadstarTextElement)
void UpdatePins()
Updates the cache of SCH_PIN objects for each pin.
int getSheetNumber(LAYER_ID aCadstarSheetID)
void SetDescription(const wxString &aDescription)
void loadChildSheets(LAYER_ID aCadstarSheetID, const SCH_SHEET_PATH &aSheet)
GATE_ID GateID
The gate this symbol represents within the associated Part.
Definition of file extensions used in Kicad.
void loadSymDefIntoLibrary(const SYMDEF_ID &aSymdefID, const PART *aCadstarPart, const GATE_ID &aGateID, LIB_SYMBOL *aSymbol)
std::map< TERMINAL_ID, TERMINAL > Terminals
std::map< TERMINAL_ID, SYMPINNAME_LABEL > PinNames
Identifier of the pin in the PCB Equivalent to KiCad's Pin Number.
EDA_ITEM * GetParent() const
void SetLabelSpinStyle(LABEL_SPIN_STYLE aSpinStyle) override
Set a spin or rotation angle, along with specific horizontal and vertical justification styles with e...
PART getPart(const PART_ID &aCadstarPartID)
void SetWidth(int aWidth)
SYMDEF_ID SymdefID
Normally documentation symbols only have TEXT, FIGURE and TEXT_LOCATION objects which are all drawn o...
void AddDrawItem(LIB_ITEM *aItem, bool aSort=true)
Add a new draw aItem to the draw object list and sort according to aSort.
Define a sheet pin (label) used in sheets to create hierarchical schematics.
std::vector< CONNECTION_SCH > Connections
void loadItemOntoKiCadSheet(LAYER_ID aCadstarSheetID, SCH_ITEM *aItem)
const EDA_RECT GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
std::pair< BLOCK_ID, TERMINAL_ID > BLOCK_PIN_ID
std::map< REUSEBLOCK_ID, REUSEBLOCK > ReuseBlocks
static void FixTextPositionNoAlignment(EDA_TEXT *aKiCadTextItem)
Corrects the position of a text element that had NO_ALIGNMENT in CADSTAR.
std::map< NETELEMENT_ID, BUS_TERM > BusTerminals
ROUTECODE getRouteCode(const ROUTECODE_ID &aCadstarRouteCodeID)
long Param1
Either Units or X step, depending on Type (see GRID_TYPE for more details)
std::map< BLOCK_PIN_ID, SCH_HIERLABEL * > m_sheetPinMap
Map between Cadstar and KiCad Sheets Pins.
wxPoint GetPosition() const override
wxPoint GetPosition() const override
void applyToLibraryFieldAttribute(const ATTRIBUTE_LOCATION &aCadstarAttrLoc, wxPoint aSymbolOrigin, LIB_FIELD *aKiCadField)
LABEL_SPIN_STYLE MirrorY()
Mirror the label spin style across the Y axis or simply swaps left and right.
SCH_FIELD * FindField(const wxString &aFieldName, bool aIncludeDefaultFields=true)
Search for a SCH_FIELD with aFieldName.
SCH_PLUGIN::SCH_PLUGIN_RELEASER * m_plugin
LIB_ITEMS_CONTAINER & GetDrawItems()
Return a reference to the draw item list.
POINT Origin
Origin of the component (this is used as the reference point when placing the component in the design...
static const long UNDEFINED_VALUE
int SegmentCount() const
Return the number of segments in this line chain.
void SetMultilineAllowed(bool aAllow)
void SetHeightMils(int aHeightInMils)
Corresponds to CADSTAR "origin".
std::vector< VERTEX > Vertices
< Nodename = "VARIANT" or "VMASTER" (master variant
SHAPE_POLY_SET & GetPolyShape()
ALIGNMENT mirrorX(const ALIGNMENT &aCadstarAlignment)
void fixUpLibraryPins(LIB_SYMBOL *aSymbolToFix, int aGateNumber)
LAYER_ID LayerID
The sheet block is on (TODO: verify this is true)
std::vector< LAYER_ID > findOrphanSheets()
void loadHierarchicalSheetPins()
std::map< BLOCK_ID, BLOCK > Blocks
std::map< SYMBOL_ID, SCH_SYMBOL * > m_powerSymMap
Map between Cadstar and KiCad Power Symbols.
LABEL_SPIN_STYLE RotateCCW()
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
PLOT_DASH_TYPE
Dashed line types.
PROJECT & Prj() const override
Return a reference to the project this schematic is part of.
static wxString generateLibName(const wxString &aRefName, const wxString &aAlternateName)
void checkPoint()
Updates m_progressReporter or throws if user cancelled.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
ITERATOR_BASE< LIB_ITEM, MULTIVECTOR< LIB_ITEM, FIRST_TYPE_VAL, LAST_TYPE_VAL >, typename ITEM_PTR_VECTOR::iterator > ITERATOR
The const iterator.
int KiCadUnitDivider
Use this value to convert units in this CSA file to KiCad units.
void SetTextWidth(int aWidth)
constexpr double SCH_IU_PER_MM
JUSTIFICATION Justification
Note: Justification has no effect on single lines of text.
Helper object to release a SCH_PLUGIN in the context of a potential thrown exception through its dest...
bool HidePinNames
Specifies whether to display the pin names/identifier in the schematic symbol or not.
JUSTIFICATION
From CADSTAR Help: "Multi Line Text can also be justified as Left, Centre or Right.
bool LocatePathOfScreen(SCH_SCREEN *aScreen, SCH_SHEET_PATH *aList)
Search the existing hierarchy for an instance of screen loaded from aFileName.
void wxStringSplit(const wxString &aText, wxArrayString &aStrings, wxChar aSplitter)
Split aString to a string list separated at aSplitter.
std::vector< CUTOUT > Cutouts
Not Applicable to OPENSHAPE Type.
SEG Segment(int aIndex)
Return a copy of the aIndex-th segment in the line chain.
std::map< TEXTCODE_ID, TEXTCODE > TextCodes
LABEL_SPIN_STYLE MirrorX()
Mirror the label spin style across the X axis or simply swaps up and bottom.
Param1 = Units, Param2 = Divisor.
size_t GetFieldCount() const
LABEL_SPIN_STYLE getSpinStyle(const long long &aCadstarOrientation, bool aMirror)
const SHAPE_LINE_CHAIN ConvertToPolyline(double aAccuracy=DefaultAccuracyForPCB(), double *aEffectiveAccuracy=nullptr) const
Construct a SHAPE_LINE_CHAIN of segments from a given arc.
#define LINK_ORIGIN_ATTRID
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...
void AddBusAlias(std::shared_ptr< BUS_ALIAS > aAlias)
Add a bus alias definition (and transfers ownership of the pointer).
int getComponentOrientation(double aOrientAngleDeciDeg, double &aReturnedOrientationDeciDeg)
Segment description base class to describe items which have 2 end points (track, wire,...
ELECTRICAL_PINTYPE
The symbol library pin object electrical types used in ERC tests.
void Append(SCH_ITEM *aItem)
wxString Name
This is undefined (wxEmptyString) if the net is unnamed.
iterator begin()
Returns a read/write iterator that points to the first element in the EE_RTREE N.B.
void SetHorizJustify(EDA_TEXT_HJUSTIFY_T aType)
usual pin input: must be connected
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
void SetFPFilters(const wxArrayString &aFilters)
T NormalizeAnglePos(T Angle)
Normalize angle to be in the 0.0 .. 360.0 range: angle is in 1/10 degrees.
long Param2
Either Divisor or Y step, depending on Type (see GRID_TYPE for more details)
PROGRESS_REPORTER * m_progressReporter
wxPoint getKiCadPoint(const wxPoint &aCadstarPoint)
void SetRef(const SCH_SHEET_PATH *aSheet, const wxString &aReference)
Set the reference for the given sheet path for this symbol.
wxString GetName(bool aUseDefaultName=true) const
Return the field name.
JUSTIFICATION Justification
Note: Justification has no effect on single lines of text.
EE_RTREE & Items()
Gets the full RTree, usually for iterating.
void SetWidthMils(int aWidthInMils)
virtual void SetNumPhases(int aNumPhases)=0
Set the number of phases.
Handle the component boundary box.
const std::string KiCadSchematicFileExtension
std::map< LAYER_ID, SHEET_NAME > SheetNames
void SetTextHeight(int aHeight)
LAYER_ID LayerID
Sheet on which bus is located.
void SetShowPinNumbers(bool aShow)
Set or clear the pin number visibility flag.
static bool ClassOf(const EDA_ITEM *aItem)
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
std::map< ATTRIBUTE_ID, ATTRIBUTE_VALUE > AttributeValues
Some attributes are defined within the part definition, whilst others are defined in the part.
std::map< ATTRIBUTE_ID, TEXT_LOCATION > TextLocations
This contains location of any attributes, including designator position.
std::map< GROUP_ID, GROUP > Groups
POINT Position
Pad position within the component's coordinate frame.
A base class for most all the KiCad significant classes used in schematics and boards.
ATTRIBUTE_LOCATION AttrLoc
void AutoplaceFields(SCH_SCREEN *aScreen, bool aManual) override
ALIGNMENT rotate180(const ALIGNMENT &aCadstarAlignment)
SYMBOL_ID VariantParentSymbolID
wxString Alternate
This is in addition to ReferenceName.
std::map< NET_ID, NET_SCH > Nets
Class for a wire to bus entry.
ATTRIBUTE_LOCATION AttrLoc
const wxPoint & GetTextPos() const
void SetPosition(const wxPoint &aPosition) override
input or output (like port for a microprocessor)
wxString getNetName(const NET_SCH &aNet)
void SetTextThickness(int aWidth)
The TextThickness is that set by the user.
wxString LAYER_ID
ID of a Sheet (if schematic) or board Layer (if PCB)
LABEL_SPIN_STYLE getSpinStyleDeciDeg(const double &aOrientationDeciDeg)
void Update(SCH_ITEM *aItem)
Update aItem's bounding box in the tree.
virtual void SetTextAngle(double aAngle)
double ArcTangente(int dy, int dx)
void SetLabelSpinStyle(LABEL_SPIN_STYLE aSpinStyle) override
Set a spin or rotation angle, along with specific horizontal and vertical justification styles with e...
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...
void SetFileName(const wxString &aFileName)
Set the file name for this screen to aFileName.
virtual const EDA_RECT GetBoundingBox() const
Return the orthogonal bounding box of this object for display purposes.
std::map< TEXT_ID, TEXT > Texts
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
static wxString HandleTextOverbar(wxString aCadstarString)
Convert a string with CADSTAR overbar characters to equivalent in KiCad.
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 void SetLabelSpinStyle(LABEL_SPIN_STYLE aSpinStyle)
Set a spin or rotation angle, along with specific horizontal and vertical justification styles with e...
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
bool isAttributeVisible(const ATTRIBUTE_ID &aCadstarAttributeID)
wxPoint GetPosition() const override
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...
void SetPosition(const wxPoint &aPosition) override
std::map< DOCUMENTATION_SYMBOL_ID, DOCUMENTATION_SYMBOL > DocumentationSymbols
std::map< FIGURE_ID, FIGURE > Figures
std::map< NETELEMENT_ID, JUNCTION_SCH > Junctions
static constexpr int Millimeter2iu(double mm)
void SetPosition(const wxPoint &aPosition) override
NO_ALIGNMENT has different meaning depending on the object type.
Base class for any item which can be embedded within the SCHEMATIC container class,...
#define THROW_IO_ERROR(msg)
virtual const wxString & GetText() const
Return the string associated with the text object.
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< ATTRIBUTE_ID, ATTRIBUTE_VALUE > AttributeValues
void loadFigure(const FIGURE &aCadstarFigure, const LAYER_ID &aCadstarSheetIDOverride, SCH_LAYER_ID aKiCadSchLayerID, const wxPoint &aMoveVector={ 0, 0 }, const double &aRotationAngleDeciDeg=0.0, const double &aScalingFactor=1.0, const wxPoint &aTransformCentre={ 0, 0 }, const bool &aMirrorInvert=false)
static const std::map< TEXT_FIELD_NAME, wxString > CADSTAR_TO_KICAD_FIELDS
Map between CADSTAR fields and KiCad text variables.
Represents a cutout in a closed shape (e.g.
const wxSize GetSize() const
KICAD_T Type() const
Returns the type of object.
bool AddInstance(const SCH_SHEET_PATH &aInstance)
Add a new instance aSheetPath to the instance list.
Represents a vertex in a shape.
LIB_SYMBOL * getScaledLibPart(const LIB_SYMBOL *aSymbol, long long aScalingFactorNumerator, long long aScalingFactorDenominator)
wxPoint GetEndPoint() const