29#include <wx/filename.h>
31#include <wx/tokenzr.h>
32#include <wx/wfstream.h>
33#include <wx/txtstrm.h>
34#include <wx/mstream.h>
35#include <wx/xml/xml.h>
91 bbox.
Merge( item->GetBoundingBox() );
100 return aPinName.BeforeFirst(
'@' );
113 wxCHECK( currentSheet,
nullptr );
158 for(
const std::unique_ptr<ELAYER>& elayer : aLayers )
177 switch ( elayer->number)
207 int roti = int( eagleDegrees );
217 wxASSERT_MSG(
false, wxString::Format( wxT(
"Unhandled orientation (%d degrees)" ),
226 bool aMirror,
bool aSpin,
int aAbsDegress )
228 int align = aEagleAlignment;
230 if( aRelDegress == 90 )
234 else if( aRelDegress == 180 )
238 else if( aRelDegress == 270 )
244 if( aMirror ==
true )
246 if( aAbsDegress == 90 || aAbsDegress == 270 )
257 else if( aAbsDegress == 0 || aAbsDegress == 180 )
351 const std::map<std::string, UTF8>* aProperties )
353 wxASSERT( !aFileName || aSchematic !=
nullptr );
373 wxXmlNode* currentNode = xmlDocument.GetRoot();
383 unique_ptr<SCH_SHEET> tempVROwner;
387 wxCHECK_MSG( aSchematic->
IsValid(),
nullptr,
388 wxT(
"Can't append to a schematic with no root!" ) );
399 if( sheetPath.Last() == aAppendToMe )
411 tempVROwner = std::make_unique<SCH_SHEET>( aSchematic );
431 wxCHECK_MSG(
table,
nullptr,
"Could not load symbol lib table." );
433 m_pi.reset( SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_KICAD ) );
441 wxString libTableUri = wxT(
"${KIPRJMOD}/" ) +
getLibFileName().GetFullName();
446 row.
SetURI( libTableUri );
454 m_eagleDoc = std::make_unique<EAGLE_DOC>( currentNode,
this );
476 const wxString& aLibraryPath,
477 const std::map<std::string, UTF8>* aProperties )
488 for(
const auto& [symName, libSymbol] : it->second.KiCadSymbols )
489 aSymbolNameList.push_back( symName );
495 const wxString& aLibraryPath,
496 const std::map<std::string, UTF8>* aProperties )
507 for(
const auto& [symName, libSymbol] : it->second.KiCadSymbols )
508 aSymbolList.push_back( libSymbol.get() );
514 const std::map<std::string, UTF8>* aProperties )
525 auto it2 = it->second.KiCadSymbols.find( aAliasName );
527 if( it2 != it->second.KiCadSymbols.end() )
528 return it2->second.get();
537 wxFileName fn( aLibraryPath );
539 if( fn.IsFileReadable() && fn.GetModificationTime().IsValid() )
540 return fn.GetModificationTime().GetValue().GetValue();
571 std::unique_ptr<EAGLE_DOC> doc = std::make_unique<EAGLE_DOC>( xmlDocument.GetRoot(),
this );
575 m_version = ( doc->version.IsEmpty() ) ? wxString( wxS(
"0.0" ) ) : doc->version;
587 wxXmlDocument xmlDocument;
588 wxFFileInputStream stream(
m_filename.GetFullPath() );
593 wxString::Format(
_(
"Unable to read file '%s'." ),
m_filename.GetFullPath() ) );
597 wxTextInputStream
text( stream );
598 wxString line =
text.ReadLine();
600 if( !line.StartsWith( wxT(
"<?xml" ) ) && !line.StartsWith( wxT(
"<!--" ) )
601 && !line.StartsWith( wxT(
"<eagle " ) ) )
603 THROW_IO_ERROR( wxString::Format(
_(
"'%s' is an Eagle binary-format file; "
604 "only Eagle XML-format files can be imported." ),
608#if wxCHECK_VERSION( 3, 3, 0 )
611 if( !xmlDocument.Load( stream, wxXMLDOC_NONE, &err ) )
613 if( err.message == wxS(
"no element found" ) )
617 wxMemoryOutputStream memOutput;
620 header <<
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
621 header <<
"<!DOCTYPE eagle SYSTEM \"eagle.dtd\">\n";
623 wxScopedCharBuffer headerBuf =
header.utf8_str();
624 memOutput.Write( headerBuf.data(), headerBuf.length() );
626 wxFFileInputStream stream2(
m_filename.GetFullPath() );
627 memOutput.Write( stream2 );
629 wxMemoryInputStream memInput( memOutput );
631 if( !xmlDocument.Load( memInput, wxXMLDOC_NONE, &err ) )
638 THROW_IO_ERROR( wxString::Format(
_(
"Unable to read file '%s'.\n'%s' at line %d, column %d, offset %d" ),
639 m_filename.GetFullPath(), err.message, err.line, err.column,
644 if( !xmlDocument.Load( stream ) )
648 wxMemoryOutputStream memOutput;
651 header <<
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
652 header <<
"<!DOCTYPE eagle SYSTEM \"eagle.dtd\">\n";
654 wxScopedCharBuffer headerBuf =
header.utf8_str();
655 memOutput.Write( headerBuf.data(), headerBuf.length() );
657 wxFFileInputStream stream2(
m_filename.GetFullPath() );
658 memOutput.Write( stream2 );
660 wxMemoryInputStream memInput( memOutput );
662 if( !xmlDocument.Load( memInput ) )
675 wxCHECK( aDrawing, );
679 if( aDrawing->library )
687 if( aDrawing->schematic )
694 for(
const std::unique_ptr<ESHEET>& esheet : aSchematic.
sheets )
696 for(
const std::unique_ptr<ENET>& enet : esheet->nets )
698 wxString netName = enet->netname;
707 for(
const auto& [modname, emodule] : aSchematic.
modules )
709 for(
const std::unique_ptr<ESHEET>& esheet : emodule->sheets )
711 for(
const std::unique_ptr<ENET>& enet : esheet->nets )
713 wxString netName = enet->netname;
728 if( aSchematic.
sheets.empty() )
732 for(
const auto& [
name, epart] : aSchematic.
parts )
735 for(
const auto& [modName, emodule] : aSchematic.
modules )
737 for(
const auto& [partName, epart] : emodule->parts )
743 for(
const auto& [libName, elibrary] : aSchematic.
libraries )
746 elib->
name = elibrary->GetName();
762 std::vector<SCH_SHEET*> eaglePages;
763 eaglePages.reserve( aSchematic.
sheets.size() );
765 for(
const std::unique_ptr<ESHEET>& esheet : aSchematic.
sheets )
769 std::unique_ptr<SCH_SHEET> sheet = std::make_unique<SCH_SHEET>(
m_rootSheet );
771 sheet->SetScreen( screen );
773 wxCHECK2( sheet && screen,
continue );
775 wxString pageNo = wxString::Format( wxT(
"%d" ),
m_sheetIndex );
783 eaglePages.push_back( sheet.release() );
788 if( !eaglePages.empty() )
813 struct MISSING_UNIT_PLACEMENT
823 std::map<SCH_SCREEN*, MISSING_UNIT_PLACEMENT> placements;
827 const SCH_SYMBOL* origSymbol = cmp.second.cmp;
829 for(
auto& unitEntry : cmp.second.units )
831 if( unitEntry.second ==
false )
835 int unit = unitEntry.first;
846 targetScreen = fallbackSheet->
GetScreen();
848 targetScreen = schematicRoot->
GetScreen();
851 auto placementIt = placements.find( targetScreen );
853 if( placementIt == placements.end() )
855 MISSING_UNIT_PLACEMENT placement;
856 placement.screen = targetScreen;
860 SCH_SHEET* targetSheet = placement.sheetpath.Last();
865 placement.newCmpPosition =
VECTOR2I( placement.sheetBbox.GetLeft(),
866 placement.sheetBbox.GetBottom() );
867 placement.maxY = placement.sheetBbox.GetY();
868 placementIt = placements.emplace( targetScreen, placement ).first;
871 MISSING_UNIT_PLACEMENT& placement = placementIt->second;
873 symbol->SetUnitSelection( &placement.sheetpath, unit );
874 symbol->SetUnit( unit );
875 symbol->SetOrientation( 0 );
876 symbol->AddHierarchicalReference( placement.sheetpath.Path(), reference, unit );
879 BOX2I cmpBbox = symbol->GetBoundingBox();
880 int posY = placement.newCmpPosition.y + cmpBbox.
GetHeight();
881 symbol->SetPosition(
VECTOR2I( placement.newCmpPosition.x, posY ) );
882 placement.newCmpPosition.x += cmpBbox.
GetWidth();
883 placement.maxY = std::max( placement.maxY, posY );
885 if( placement.newCmpPosition.x >= placement.pageSizeIU.x )
886 placement.newCmpPosition =
VECTOR2I( placement.sheetBbox.GetLeft(),
891 placement.screen->Append( symbol.release() );
904 wxCHECK( sheet && screen, );
908 std::string filename;
912 if( aSheet->description )
913 sheet->
SetName( aSheet->description.value().text );
918 replace( filename.begin(), filename.end(),
' ',
'_' );
923 fn.SetPath(
m_schematic->Project().GetProjectPath() );
924 fn.SetName( filename );
931 for(
const auto& [
name, moduleinst] : aSheet->moduleinsts )
938 for(
const std::unique_ptr<EPOLYGON>& epoly : aSheet->plain->polygons )
941 for(
const std::unique_ptr<EWIRE>& ewire : aSheet->plain->wires )
947 for(
const std::unique_ptr<ETEXT>& etext : aSheet->plain->texts )
950 for(
const std::unique_ptr<ECIRCLE>& ecircle : aSheet->plain->circles )
953 for(
const std::unique_ptr<ERECT>& erectangle : aSheet->plain->rectangles )
956 for(
const std::unique_ptr<EFRAME>& eframe : aSheet->plain->frames )
958 std::vector<SCH_ITEM*> frameItems;
969 for(
const std::unique_ptr<EINSTANCE>& einstance : aSheet->instances )
977 for(
const std::unique_ptr<EBUS>& ebus : aSheet->busses )
983 loadSegments( ebus->segments, busName, wxString(),
true );
986 for(
const std::unique_ptr<ENET>& enet : aSheet->nets )
989 wxString netName = enet->netname;
990 wxString netClass = wxString::Format( wxS(
"%i" ), enet->netcode );
1009 if( pageSizeIU.
x < targetSheetSize.
x )
1012 if( pageSizeIU.
y < targetSheetSize.
y )
1019 VECTOR2I sheetcentre( pageSizeIU.
x / 2, pageSizeIU.
y / 2 );
1023 VECTOR2I translation = sheetcentre - itemsCentre;
1024 translation.
x = translation.
x - translation.
x %
schIUScale.MilsToIU( 100 );
1025 translation.
y = translation.
y - translation.
y %
schIUScale.MilsToIU( 100 );
1037 std::vector<SCH_ITEM*> allItems;
1039 std::copy( screen->
Items().
begin(), screen->
Items().
end(), std::back_inserter( allItems ) );
1043 item->SetPosition( item->GetPosition() + translation );
1061 wxCHECK( currentSheet &¤tScreen, );
1067 auto it =
m_eagleDoc->drawing->schematic->modules.find( aModuleInstance->moduleinst );
1070 if( it ==
m_eagleDoc->drawing->schematic->modules.end() )
1072 THROW_IO_ERROR( wxString::Format(
_(
"No module instance '%s' found in schematic "
1074 aModuleInstance->name,
m_filename.GetFullPath() ) );
1078 fn.SetName( aModuleInstance->moduleinst );
1082 VECTOR2I size( it->second->dx.ToSchUnits(), it->second->dy.ToSchUnits() );
1084 int halfX =
KiROUND( size.
x / 2.0 );
1085 int halfY =
KiROUND( size.
y / 2.0 );
1086 int portExtWireLength =
schIUScale.mmToIU( 5.08 );
1087 VECTOR2I pos( aModuleInstance->x.ToSchUnits() - halfX,
1088 -aModuleInstance->y.ToSchUnits() - halfY );
1090 std::unique_ptr<SCH_SHEET> newSheet = std::make_unique<SCH_SHEET>( currentSheet, pos, size );
1098 if( schFile->GetFileName() == fn.GetFullPath() )
1100 newScreen = schFile;
1105 bool isNewSchFile = ( newScreen == nullptr );
1113 wxCHECK( newSheet && newScreen, );
1115 newSheet->SetScreen( newScreen );
1116 newSheet->SetFileName( fn.GetFullName() );
1117 newSheet->SetName( aModuleInstance->name );
1119 for(
const auto& [portName, port] : it->second->ports )
1122 int pinOffset = port->coord.ToSchUnits();
1125 if( port->side ==
"left" )
1129 pinPos.
y = pos.
y + halfY - pinOffset;
1130 portExtWireEndpoint = pinPos;
1131 portExtWireEndpoint.
x -= portExtWireLength;
1133 else if( port->side ==
"right" )
1136 pinPos.
x = pos.
x + size.
x;
1137 pinPos.
y = pos.
y + halfY - pinOffset;
1138 portExtWireEndpoint = pinPos;
1139 portExtWireEndpoint.
x += portExtWireLength;
1141 else if( port->side ==
"top" )
1144 pinPos.
x = pos.
x + halfX + pinOffset;
1146 portExtWireEndpoint = pinPos;
1147 portExtWireEndpoint.
y -= portExtWireLength;
1149 else if( port->side ==
"bottom" )
1152 pinPos.
x = pos.
x + halfX + pinOffset;
1153 pinPos.
y = pos.
y + size.
y;
1154 portExtWireEndpoint = pinPos;
1155 portExtWireEndpoint.
y += portExtWireLength;
1160 currentScreen->
Append( portExtWire );
1164 if( port->direction )
1166 if( *port->direction ==
"in" )
1168 else if( *port->direction ==
"out" )
1170 else if( *port->direction ==
"io" )
1172 else if( *port->direction ==
"hiz" )
1187 newSheet->AddPin( sheetPin );
1190 wxString pageNo = wxString::Format( wxT(
"%d" ),
m_sheetIndex );
1192 newSheet->SetParent( currentSheet );
1195 currentScreen->
Append( newSheet.release() );
1197 m_modules.push_back( it->second.get() );
1203 for(
const std::unique_ptr<ESHEET>& esheet : it->second->sheets )
1213 wxCHECK2( emoduleInst,
continue );
1215 refPrefix += emoduleInst->name + wxS(
":" );
1226 wxCHECK2( symbol && !symbol->
GetInstances().empty(),
continue );
1229 wxString newReference = refPrefix + inst.
m_Reference.AfterLast(
':' );
1243 std::vector<SCH_ITEM*>& aItems )
1245 int xMin = aFrame->x1.ToSchUnits();
1246 int xMax = aFrame->x2.ToSchUnits();
1247 int yMin = -aFrame->y1.ToSchUnits();
1248 int yMax = -aFrame->y2.ToSchUnits();
1251 std::swap( xMin, xMax );
1254 std::swap( yMin, yMax );
1262 aItems.push_back( lines );
1264 if( !( aFrame->border_left ==
false ) )
1271 aItems.push_back( lines );
1274 int height = yMax - yMin;
1277 int legendPosX = xMin +
schIUScale.MilsToIU( 75 );
1278 double rowSpacing = height / double( aFrame->rows );
1279 double legendPosY = yMin + ( rowSpacing / 2 );
1281 for( i = 1; i < aFrame->rows; i++ )
1283 int newY =
KiROUND( yMin + ( rowSpacing * (
double) i ) );
1287 aItems.push_back( lines );
1290 char legendChar =
'A';
1292 for( i = 0; i < aFrame->rows; i++ )
1298 legendText->
SetText( wxString( legendChar ) );
1301 aItems.push_back( legendText );
1303 legendPosY += rowSpacing;
1307 if( !( aFrame->border_right ==
false ) )
1314 aItems.push_back( lines );
1317 int height = yMax - yMin;
1320 int legendPosX = xMax -
schIUScale.MilsToIU( 75 );
1321 double rowSpacing = height / double( aFrame->rows );
1322 double legendPosY = yMin + ( rowSpacing / 2 );
1324 for( i = 1; i < aFrame->rows; i++ )
1326 int newY =
KiROUND( yMin + ( rowSpacing * (
double) i ) );
1330 aItems.push_back( lines );
1333 char legendChar =
'A';
1335 for( i = 0; i < aFrame->rows; i++ )
1341 legendText->
SetText( wxString( legendChar ) );
1344 aItems.push_back( legendText );
1346 legendPosY += rowSpacing;
1350 if( !( aFrame->border_top ==
false ) )
1357 aItems.push_back( lines );
1360 int width = xMax - xMin;
1363 int legendPosY = yMin +
schIUScale.MilsToIU( 75 );
1364 double columnSpacing = width / double( aFrame->columns );
1365 double legendPosX = xMin + ( columnSpacing / 2 );
1367 for( i = 1; i < aFrame->columns; i++ )
1369 int newX =
KiROUND( xMin + ( columnSpacing * (
double) i ) );
1373 aItems.push_back( lines );
1376 char legendChar =
'1';
1378 for( i = 0; i < aFrame->columns; i++ )
1384 legendText->
SetText( wxString( legendChar ) );
1387 aItems.push_back( legendText );
1389 legendPosX += columnSpacing;
1393 if( !( aFrame->border_bottom ==
false ) )
1400 aItems.push_back( lines );
1403 int width = xMax - xMin;
1406 int legendPosY = yMax -
schIUScale.MilsToIU( 75 );
1407 double columnSpacing = width / double( aFrame->columns );
1408 double legendPosX = xMin + ( columnSpacing / 2 );
1410 for( i = 1; i < aFrame->columns; i++ )
1412 int newX =
KiROUND( xMin + ( columnSpacing * (
double) i ) );
1416 aItems.push_back( lines );
1419 char legendChar =
'1';
1421 for( i = 0; i < aFrame->columns; i++ )
1427 legendText->
SetText( wxString( legendChar ) );
1430 aItems.push_back( legendText );
1432 legendPosX += columnSpacing;
1439 const wxString& netName,
1440 const wxString& aNetClass,
1448 size_t segmentCount = aSegments.size();
1450 for(
const std::unique_ptr<ESEGMENT>& esegment : aSegments )
1452 bool labelled =
false;
1453 bool firstWireFound =
false;
1459 for(
const std::unique_ptr<EWIRE>& ewire : esegment->wires )
1468 if( !firstWireFound )
1470 firstWire = thisWire;
1471 firstWireFound =
true;
1477 if( !desc.labels.empty() && desc.labels.front()->GetText() == netName )
1480 for(
const SEG& seg : desc.segs )
1489 segDesc.
segs.push_back( thisWire );
1493 for(
const std::unique_ptr<EJUNCTION>& ejunction : esegment->junctions )
1496 for(
const std::unique_ptr<ELABEL>& elabel : esegment->labels )
1501 wxASSERT( segDesc.
labels.empty()
1504 segDesc.
labels.push_back( label );
1508 for(
const std::unique_ptr<EPINREF>& epinref : esegment->pinRefs )
1510 wxString part = epinref->part;
1511 wxString
pin = epinref->pin;
1513 auto powerPort =
m_powerPorts.find( wxT(
"#" ) + part );
1525 if( !labelled && firstWireFound )
1527 std::unique_ptr<SCH_LABEL_BASE> label;
1539 if( segmentCount > 1 ||
m_netCounts[netName] > 1 )
1549 label->SetPosition( firstWire.
A );
1554 if( firstWire.
A.
y == firstWire.
B.
y )
1556 if( firstWire.
B.
x > firstWire.
A.
x )
1561 else if( firstWire.
A.
x == firstWire.
B.
x )
1563 if( firstWire.
B.
y > firstWire.
A.
y )
1569 screen->
Append( label.release() );
1578 std::unique_ptr<SCH_SHAPE> poly = std::make_unique<SCH_SHAPE>(
SHAPE_T::POLY );
1582 for(
const std::unique_ptr<EVERTEX>& evertex : aPolygon->vertices )
1584 pt =
VECTOR2I( evertex->x.ToSchUnits(), -evertex->y.ToSchUnits() );
1590 poly->GetPolyShape().Append( arc, -1, -1,
ARC_ACCURACY );
1594 poly->AddPoint( pt );
1598 prev_curve = evertex->curve;
1601 poly->SetLayer(
kiCadLayer( aPolygon->layer ) );
1605 return poly.release();
1613 start.
x = aWire->x1.ToSchUnits();
1614 start.
y = -aWire->y1.ToSchUnits();
1615 end.x = aWire->x2.ToSchUnits();
1616 end.y = -aWire->y2.ToSchUnits();
1619 endpoints =
SEG( start,
end );
1628 std::unique_ptr<SCH_SHAPE> arc = std::make_unique<SCH_SHAPE>(
SHAPE_T::ARC );
1631 arc->SetCenter(
center );
1632 arc->SetStart( start );
1639 return arc.release();
1643 std::unique_ptr<SCH_LINE> line = std::make_unique<SCH_LINE>();
1645 line->SetStartPoint( start );
1646 line->SetEndPoint(
end );
1647 line->SetLayer(
kiCadLayer( aWire->layer ) );
1650 return line.release();
1658 VECTOR2I center( aCircle->x.ToSchUnits(), -aCircle->y.ToSchUnits() );
1671 std::unique_ptr<SCH_SHAPE> rectangle = std::make_unique<SCH_SHAPE>(
SHAPE_T::RECTANGLE );
1673 rectangle->SetLayer(
kiCadLayer( aRectangle->layer ) );
1674 rectangle->SetPosition(
VECTOR2I( aRectangle->x1.ToSchUnits(), -aRectangle->y1.ToSchUnits() ) );
1675 rectangle->SetEnd(
VECTOR2I( aRectangle->x2.ToSchUnits(), -aRectangle->y2.ToSchUnits() ) );
1677 if( aRectangle->rot )
1679 VECTOR2I pos( rectangle->GetPosition() );
1686 rectangle->SetPosition( pos );
1687 rectangle->SetEnd(
end );
1693 return rectangle.release();
1699 std::unique_ptr<SCH_JUNCTION> junction = std::make_unique<SCH_JUNCTION>();
1701 VECTOR2I pos( aJunction->x.ToSchUnits(), -aJunction->y.ToSchUnits() );
1703 junction->SetPosition( pos );
1705 return junction.release();
1710 const wxString& aNetName,
bool aIsBus )
1712 VECTOR2I elabelpos( aLabel->x.ToSchUnits(), -aLabel->y.ToSchUnits() );
1717 std::unique_ptr<SCH_LABEL_BASE> label;
1719 VECTOR2I textSize =
KiROUND( aLabel->size.ToSchUnits() * 0.7, aLabel->size.ToSchUnits() * 0.7 );
1721 auto findModulePort =
1722 [&]() ->
const EPORT*
1727 const auto& ports =
m_modules.back()->ports;
1728 const auto it = ports.find( aNetName );
1729 return it == ports.end() ? nullptr : it->second.get();
1732 const EPORT* port = findModulePort();
1736 auto hierLabel = std::make_unique<SCH_HIERLABEL>();
1743 if( direction ==
"in" )
1745 else if( direction ==
"out" )
1747 else if( direction ==
"io" )
1749 else if( direction ==
"hiz" )
1757 hierLabel->SetLabelShape( type );
1760 label = std::move( hierLabel );
1764 label = std::make_unique<SCH_LABEL>();
1768 label = std::make_unique<SCH_GLOBALLABEL>();
1772 label->SetPosition( elabelpos );
1773 label->SetTextSize( textSize );
1779 int angle =
KiROUND( aLabel->rot->degrees );
1798 return label.release();
1802std::pair<VECTOR2I, const SEG*>
1804 const std::vector<SEG>& aLines )
const
1807 const SEG* nearestLine =
nullptr;
1809 double d, mindistance = std::numeric_limits<double>::max();
1812 for(
const SEG& line : aLines )
1817 if( d < mindistance )
1820 nearestPoint = testpoint;
1821 nearestLine = &line;
1824 testpoint = line.Center();
1827 if( d < mindistance )
1830 nearestPoint = testpoint;
1831 nearestLine = &line;
1837 if( d < mindistance )
1840 nearestPoint = testpoint;
1841 nearestLine = &line;
1845 return std::make_pair( nearestPoint, nearestLine );
1850 const std::map<wxString, std::unique_ptr<EPART>>& aParts )
1852 wxCHECK( aInstance, );
1858 const auto partIt = aParts.find( aInstance->part );
1860 if( partIt == aParts.end() )
1862 Report( wxString::Format(
_(
"Error parsing Eagle file. Could not find '%s' "
1863 "instance but it is referenced in the schematic." ),
1870 const std::unique_ptr<EPART>& epart = partIt->second;
1872 wxString libName = epart->library;
1875 if( epart->libraryUrn )
1876 libName += wxS(
"_" ) + epart->libraryUrn->assetId;
1878 wxString gatename = epart->deviceset + wxS(
"_" ) + epart->device + wxS(
"_" ) +
1880 wxString symbolname = wxString( epart->deviceset + epart->device );
1881 wxString kiPackageName = epart->deviceset + epart->device;
1883 if( epart->technology )
1884 symbolname += *epart->technology;
1886 symbolname.Replace( wxT(
"*" ), wxEmptyString );
1887 kiPackageName.Replace( wxT(
"*" ), wxEmptyString );
1896 wxString altSymbolName = libName + wxT(
"_" ) + symbolname;
1899 wxString libIdSymbolName = altSymbolName;
1905 Report( wxString::Format( wxS(
"Eagle library '%s' not found while looking up symbol for "
1906 "deviceset '%s', device '%s', and gate '%s." ),
1907 libName, epart->deviceset, epart->device, aInstance->gate ) );
1911 const auto gateIt = libIt->second.GateToUnitMap.find( gatename );
1913 if( gateIt == libIt->second.GateToUnitMap.end() )
1915 Report( wxString::Format( wxS(
"Symbol not found for deviceset '%s', device '%s', and "
1916 "gate '%s in library '%s'." ),
1917 epart->deviceset, epart->device, aInstance->gate, libName ) );
1921 int unit = gateIt->second;
1926 auto p = elib->
package.find( kisymbolname );
1928 if( p != elib->
package.end() )
1930 package = p->second;
1934 p = elib->
package.find( kiPackageName );
1936 if( p != elib->
package.end() )
1937 package = p->second;
1941 std::map<std::string, UTF8> properties;
1948 part =
m_pi->LoadSymbol(
getLibFileName().GetFullPath(), kisymbolname, &properties );
1949 libIdSymbolName = kisymbolname;
1954 Report( wxString::Format(
_(
"Could not find '%s' in the imported library." ),
1961 std::unique_ptr<SCH_SYMBOL> symbol = std::make_unique<SCH_SYMBOL>();
1962 symbol->SetLibId( libId );
1963 symbol->SetUnit( unit );
1964 symbol->SetPosition(
VECTOR2I( aInstance->x.ToSchUnits(), -aInstance->y.ToSchUnits() ) );
1967 if( !package.IsEmpty() )
1969 wxString footprint =
m_schematic->Project().GetProjectName() + wxT(
":" ) + package;
1973 if( aInstance->rot )
1977 if( aInstance->rot->mirror )
1978 symbol->MirrorHorizontally( aInstance->x.ToSchUnits() );
1981 std::vector<SCH_FIELD*> partFields;
1986 for(
const SCH_FIELD* partField : partFields )
1990 if( partField->IsMandatory() )
1991 symbolField = symbol->GetField( partField->GetId() );
1993 symbolField = symbol->GetField( partField->GetName() );
2000 newField.
SetText( partField->GetText() );
2004 symbol->AddField( newField );
2009 symbolField->
SetTextPos( symbol->GetPosition() + partField->GetTextPos() );
2015 wxString reference = package.IsEmpty() ?
'#' + aInstance->part : aInstance->part;
2018 if( reference.find_last_not_of( wxT(
"0123456789" ) ) == ( reference.Length()-1 ) )
2019 reference.Append( wxT(
"0" ) );
2024 if( reference.find_first_not_of( wxT(
"0123456789" ) ) != 0 )
2025 reference.Prepend( wxT(
"UNK" ) );
2029 if( aInstance->part.find_first_not_of( wxT(
"#" ) ) != 0 )
2030 reference.Prepend( wxT(
"UNK" ) );
2033 referenceField->
SetText( reference );
2036 bool userValue =
m_userValue.at( libIdSymbolName );
2044 if( epart->value && !epart->value.CGet().IsEmpty() )
2046 valueField->
SetText( *epart->value );
2050 valueField->
SetText( kisymbolname );
2056 for(
const auto& [ attrName, attr ] : epart->attributes )
2062 if( !symbol->GetFields().empty() )
2063 newField.
SetTextPos( symbol->GetFields().back().GetPosition() );
2066 newField.
SetText( *attr->value );
2070 symbol->AddField( newField );
2073 for(
const auto& [variantName, variant] : epart->variants )
2076 field->
SetName( wxT(
"VARIANT_" ) + variant->name );
2078 if( variant->value )
2079 field->
SetText( *variant->value );
2084 bool valueAttributeFound =
false;
2085 bool nameAttributeFound =
false;
2088 for(
auto& [
name, eattr] : aInstance->attributes )
2092 if( eattr->name.Lower() == wxT(
"name" ) )
2095 nameAttributeFound =
true;
2097 else if( eattr->name.Lower() == wxT(
"value" ) )
2100 valueAttributeFound =
true;
2104 field = symbol->GetField( eattr->name );
2112 int absdegrees = eattr->rot ? eattr->rot->degrees : 0;
2113 bool mirror = eattr->rot ? eattr->rot->mirror :
false;
2115 if( aInstance->rot && aInstance->rot->mirror )
2118 bool spin = eattr->rot ? eattr->rot->spin :
false;
2123 int rotation = aInstance->rot ? aInstance->rot->degrees : 0;
2124 int reldegrees = ( absdegrees - rotation + 360.0 );
2132 if( aInstance->smashed && aInstance->smashed.Get() )
2134 symbol->GetField(
FIELD_T::VALUE )->SetVisible( valueAttributeFound );
2146 wxCHECK2( emoduleInst,
continue );
2148 refPrefix += emoduleInst->name + wxS(
":" );
2151 symbol->AddHierarchicalReference(
m_sheetPath.Path(), refPrefix + reference, unit );
2157 symbol->SetLibSymbol( part->
Flatten().release() );
2159 for(
const SCH_PIN*
pin : symbol->GetLibPins() )
2165 symbol->ClearFlags();
2167 screen->
Append( symbol.release() );
2173 wxCHECK( aLibrary && aEagleLibrary,
nullptr );
2179 wxString prefix = edeviceset->prefix ? edeviceset->prefix.Get() : wxString( wxT(
"" ) );
2180 wxString deviceSetDescr;
2182 if( edeviceset->description )
2186 for(
const std::unique_ptr<EDEVICE>& edevice : edeviceset->devices )
2188 std::vector<std::unique_ptr<LIB_SYMBOL>> derivedSymbols;
2191 wxString symbolName = edeviceset->name + edevice->name;
2192 symbolName.Replace( wxT(
"*" ), wxEmptyString );
2193 wxASSERT( !symbolName.IsEmpty() );
2196 if( edevice->package )
2197 aEagleLibrary->
package[symbolName] = edevice->package.Get();
2200 std::unique_ptr<LIB_SYMBOL> libSymbol = std::make_unique<LIB_SYMBOL>( symbolName );
2203 int gate_count =
static_cast<int>( edeviceset->gates.size() );
2205 if( gate_count > 1 )
2206 libSymbol->SetUnitCount( gate_count,
true );
2208 libSymbol->LockUnits(
true );
2212 if( prefix.length() == 0 )
2220 reference->
SetText( edevice->package ? prefix :
'#' + prefix );
2223 libSymbol->GetValueField().SetVisible(
true );
2226 bool ispower =
false;
2228 for(
const auto& [gateName, egate] : edeviceset->gates )
2230 const auto it = aLibrary->
symbols.find( egate->symbol );
2232 if( it == aLibrary->
symbols.end() )
2234 Report( wxString::Format( wxS(
"Eagle symbol '%s' not found in library '%s'." ),
2235 egate->symbol, aLibrary->
GetName() ) );
2239 wxString gateMapName = edeviceset->name + wxS(
"_" ) + edevice->name +
2240 wxS(
"_" ) + egate->name;
2242 ispower =
loadSymbol( it->second, libSymbol, edevice, gateindex, egate->name );
2249 for(
const std::unique_ptr<ETECHNOLOGY>& technology : edevice->technologies )
2251 std::unique_ptr<LIB_SYMBOL> derivedSymbol;
2253 if( !technology->name.IsEmpty() )
2254 derivedSymbol = std::make_unique<LIB_SYMBOL>( symbolName + technology->name, libSymbol.get() );
2256 for(
const std::unique_ptr<EATTR>& attr : technology->attributes )
2263 if( !derivedSymbol )
2264 field = libSymbol->FindFieldCaseInsensitive( attr->name );
2266 field = derivedSymbol->FindFieldCaseInsensitive( attr->name );
2270 field->
SetText( *attr->value );
2274 SCH_FIELD* newField =
new SCH_FIELD( derivedSymbol ? derivedSymbol.get() : libSymbol.get(),
2278 newField->
SetText( *attr->value );
2282 if( !derivedSymbol )
2283 libSymbol->AddField( newField );
2285 derivedSymbol->AddField( newField );
2290 derivedSymbols.push_back( std::move( derivedSymbol ) );
2293 if( gate_count > 1 )
2294 libSymbol->SetUnitCount( gate_count,
true );
2296 if( gate_count == 1 && ispower )
2297 libSymbol->SetGlobalPower();
2300 if( edevice->package )
2307 libName =
m_schematic->Project().GetProjectName();
2314 wxString packageString = libName + wxT(
":" ) + aEagleLibrary->
package[symbolName];
2316 libSymbol->GetFootprintField().SetText( packageString );
2319 wxString libName = libSymbol->GetName();
2320 libSymbol->SetName( libName );
2321 libSymbol->SetDescription( deviceSetDescr );
2331 libName = aEagleLibrary->
name + wxT(
"_" ) + libName;
2333 libSymbol->SetName( libName );
2337 std::map<std::string, UTF8> properties;
2343 for( std::unique_ptr<LIB_SYMBOL>& symbol : derivedSymbols )
2347 wxString tmp = aEagleLibrary->
name + wxT(
"_" ) + symbol->GetName();
2349 symbol->SetName( tmp );
2354 derivedSymbol->
SetParent( parentSymbol );
2366 aEagleLibrary->
KiCadSymbols[ libName ] = std::move( libSymbol );
2370 m_userValue.emplace( std::make_pair( libName, edeviceset->uservalue ==
true ) );
2372 for( std::unique_ptr<LIB_SYMBOL>& symbol : derivedSymbols )
2374 m_userValue.emplace( std::make_pair( symbol->GetName(), edeviceset->uservalue ==
true ) );
2375 aEagleLibrary->
KiCadSymbols[symbol->GetName()] = std::move( symbol );
2380 return aEagleLibrary;
2385 std::unique_ptr<LIB_SYMBOL>& aSymbol,
2386 const std::unique_ptr<EDEVICE>& aDevice,
int aGateNumber,
2387 const wxString& aGateName )
2389 wxCHECK( aEsymbol && aSymbol && aDevice,
false );
2391 std::vector<SCH_ITEM*> items;
2393 bool showRefDes =
false;
2394 bool showValue =
false;
2395 bool ispower =
false;
2398 for(
const std::unique_ptr<ECIRCLE>& ecircle : aEsymbol->circles )
2401 for(
const std::unique_ptr<EPIN>& epin : aEsymbol->pins )
2403 std::unique_ptr<SCH_PIN>
pin(
loadPin( aSymbol, epin, aGateNumber ) );
2408 if( epin->direction )
2412 if( epin->direction->Lower() == pinDir.first )
2414 pin->SetType( pinDir.second );
2416 if( pinDir.first == wxT(
"sup" ) )
2425 if( aDevice->connects.size() != 0 )
2427 for(
const std::unique_ptr<ECONNECT>& connect : aDevice->connects )
2432 if( connect->gate == aGateName && epin->name == connect->pin )
2434 wxArrayString pads = wxSplit( wxString( connect->pad ),
' ' );
2436 pin->SetUnit( aGateNumber );
2439 if( pads.GetCount() > 1 )
2441 pin->SetNumberTextSize( 0 );
2444 for(
unsigned i = 0; i < pads.GetCount(); i++ )
2448 wxString padname( pads[i] );
2450 aSymbol->AddDrawItem( apin );
2459 pin->SetUnit( aGateNumber );
2460 pin->SetNumber( wxString::Format( wxT(
"%i" ), pincount ) );
2461 aSymbol->AddDrawItem(
pin.release() );
2465 for(
const std::unique_ptr<EPOLYGON>& epolygon : aEsymbol->polygons )
2468 for(
const std::unique_ptr<ERECT>& erectangle : aEsymbol->rectangles )
2471 for(
const std::unique_ptr<ETEXT>& etext : aEsymbol->texts )
2473 std::unique_ptr<SCH_TEXT> libtext(
loadSymbolText( aSymbol, etext, aGateNumber ) );
2475 if( libtext->GetText() == wxT(
"${REFERENCE}" ) )
2481 showRefDes = etext->text == wxT(
">NAME" );
2483 else if( libtext->GetText() == wxT(
"${VALUE}" ) )
2489 showValue = etext->text == wxT(
">VALUE" );
2491 else if( etext->text.StartsWith(
">" ) )
2495 wxString fieldName = etext->text.Mid( 1 );
2497 if( !fieldName.IsEmpty() )
2505 aSymbol->AddField( field );
2510 aSymbol->AddDrawItem( libtext.release() );
2514 for(
const std::unique_ptr<EWIRE>& ewire : aEsymbol->wires )
2515 aSymbol->AddDrawItem(
loadSymbolWire( aSymbol, ewire, aGateNumber ) );
2517 for(
const std::unique_ptr<EFRAME>& eframe : aEsymbol->frames )
2519 std::vector<SCH_ITEM*> frameItems;
2525 item->SetParent( aSymbol.get() );
2526 item->SetUnit( aGateNumber );
2527 aSymbol->AddDrawItem( item );
2531 aSymbol->GetReferenceField().SetVisible( showRefDes );
2532 aSymbol->GetValueField().SetVisible( showValue );
2534 return pincount == 1 ? ispower :
false;
2539 const std::unique_ptr<ECIRCLE>& aCircle,
2542 wxCHECK( aSymbol && aCircle,
nullptr );
2546 VECTOR2I center( aCircle->x.ToSchUnits(), -aCircle->y.ToSchUnits() );
2548 circle->SetParent( aSymbol.get() );
2552 circle->SetUnit( aGateNumber );
2559 const std::unique_ptr<ERECT>& aRectangle,
2562 wxCHECK( aSymbol && aRectangle,
nullptr );
2567 rectangle->
SetPosition(
VECTOR2I( aRectangle->x1.ToSchUnits(), -aRectangle->y1.ToSchUnits() ) );
2568 rectangle->
SetEnd(
VECTOR2I( aRectangle->x2.ToSchUnits(), -aRectangle->y2.ToSchUnits() ) );
2570 if( aRectangle->rot )
2583 rectangle->
SetUnit( aGateNumber );
2593 const std::unique_ptr<EWIRE>& aWire,
int aGateNumber )
2595 wxCHECK( aSymbol && aWire,
nullptr );
2599 begin.
x = aWire->x1.ToSchUnits();
2600 begin.
y = -aWire->y1.ToSchUnits();
2601 end.x = aWire->x2.ToSchUnits();
2602 end.y = -aWire->y2.ToSchUnits();
2621 ( aWire->width.ToSchUnits() /
radius );
2622 begin =
center + centerStartVector;
2656 const std::unique_ptr<EPOLYGON>& aPolygon,
2659 wxCHECK( aSymbol && aPolygon,
nullptr );
2667 for(
const std::unique_ptr<EVERTEX>& evertex : aPolygon->vertices )
2669 pt =
VECTOR2I( evertex->x.ToSchUnits(), evertex->y.ToSchUnits() );
2683 prev_curve = evertex->curve;
2695 const std::unique_ptr<EPIN>& aPin,
int aGateNumber )
2697 wxCHECK( aSymbol && aPin,
nullptr );
2699 std::unique_ptr<SCH_PIN>
pin = std::make_unique<SCH_PIN>( aSymbol.get() );
2700 pin->SetPosition(
VECTOR2I( aPin->x.ToSchUnits(), -aPin->y.ToSchUnits() ) );
2706 pin->SetUnit( aGateNumber );
2708 int roti = aPin->rot ? aPin->rot->degrees : 0;
2716 default: wxFAIL_MSG( wxString::Format( wxT(
"Unhandled orientation (%d degrees)." ), roti ) );
2723 wxString length = aPin->length.Get();
2725 if( length == wxT(
"short" ) )
2727 else if( length == wxT(
"middle" ) )
2729 else if( length == wxT(
"long" ) )
2731 else if( length == wxT(
"point" ) )
2742 wxString visible = aPin->visible.Get();
2744 if( visible == wxT(
"off" ) )
2746 pin->SetNameTextSize( 0 );
2747 pin->SetNumberTextSize( 0 );
2749 else if( visible == wxT(
"pad" ) )
2751 pin->SetNameTextSize( 0 );
2753 else if( visible == wxT(
"pin" ) )
2755 pin->SetNumberTextSize( 0 );
2765 if( aPin->function )
2767 wxString function = aPin->function.Get();
2769 if( function == wxT(
"dot" ) )
2771 else if( function == wxT(
"clk" ) )
2773 else if( function == wxT(
"dotclk" ) )
2777 return pin.release();
2782 const std::unique_ptr<ETEXT>& aText,
int aGateNumber )
2784 wxCHECK( aSymbol && aText,
nullptr );
2786 std::unique_ptr<SCH_TEXT> libtext = std::make_unique<SCH_TEXT>();
2788 libtext->SetParent( aSymbol.get() );
2789 libtext->SetUnit( aGateNumber );
2790 libtext->SetPosition(
VECTOR2I( aText->x.ToSchUnits(), -aText->y.ToSchUnits() ) );
2792 const wxString& eagleText = aText->text;
2793 wxString adjustedText;
2794 wxStringTokenizer tokenizer( eagleText,
"\r\n" );
2797 while( tokenizer.HasMoreTokens() )
2799 wxString tmp =
interpretText( tokenizer.GetNextToken().Trim(
true ).Trim(
false ) );
2801 if( tokenizer.HasMoreTokens() )
2804 adjustedText += tmp;
2807 libtext->SetText( adjustedText.IsEmpty() ? wxString( wxS(
"~" ) ) : adjustedText );
2811 return libtext.release();
2817 wxCHECK( aText,
nullptr );
2819 std::unique_ptr<SCH_TEXT> schtext = std::make_unique<SCH_TEXT>();
2821 const wxString& eagleText = aText->text;
2822 wxString adjustedText;
2823 wxStringTokenizer tokenizer( eagleText,
"\r\n" );
2826 while( tokenizer.HasMoreTokens() )
2828 wxString tmp =
interpretText( tokenizer.GetNextToken().Trim(
true ).Trim(
false ) );
2830 if( tokenizer.HasMoreTokens() )
2833 adjustedText += tmp;
2836 schtext->SetText( adjustedText.IsEmpty() ? wxString( wxS(
"\" \"" ) )
2839 schtext->SetPosition(
VECTOR2I( aText->x.ToSchUnits(), -aText->y.ToSchUnits() ) );
2841 schtext->SetItalic(
false );
2843 return schtext.release();
2848 const std::unique_ptr<ETEXT>& aAttributes )
const
2850 wxCHECK( aText && aAttributes, );
2855 if( aAttributes->ratio && aAttributes->ratio.CGet() > 12 )
2859 int degrees = aAttributes->rot ? aAttributes->rot->degrees : 0;
2860 bool mirror = aAttributes->rot ? aAttributes->rot->mirror :
false;
2861 bool spin = aAttributes->rot ? aAttributes->rot->spin :
false;
2869 wxCHECK( aField && aText, );
2893 auto onIntersection =
2905 const SEG* segAttached = segDesc.LabelAttached( label );
2907 if( segAttached && !onIntersection( labelPos ) )
2921 VECTOR2I wireDirection( segAttached->
B - segAttached->
A );
2923 if( ( wireDirection.
x == 0 ) && (wireDirection.
y == 0 ) )
2927 const VECTOR2I origPos( labelPos );
2930 bool checkPositive =
true;
2931 bool checkNegative =
true;
2936 while( ( !
move || onIntersection( labelPos ) ) && ( checkPositive || checkNegative ) )
2941 if( trial % 2 == 1 )
2943 labelPos =
VECTOR2I( origPos + wireDirection * trial / 2 );
2944 move = checkPositive = segAttached->
Contains( labelPos );
2948 labelPos =
VECTOR2I( origPos - wireDirection * trial / 2 );
2949 move = checkNegative = segAttached->
Contains( labelPos );
2959 if( wireDirection.
x == 0 )
2961 if( wireDirection.
y < 0 )
2966 else if( wireDirection.
y == 0 )
2968 if( wireDirection.
x < 0 )
3002 wxFileInputStream input( aFileName );
3007 wxTextInputStream
text( input );
3009 for(
int i = 0; i < 8; i++ )
3014 if(
text.ReadLine().Contains( wxS(
"<eagle" ) ) )
3032 if( !item->IsType( { SCH_LABEL_LOCATE_ANY_T } ) )
3036 item->SetPosition( aNewEndPoint );
3049 std::vector<SCH_LINE*> buses;
3050 std::vector<SCH_LINE*> wires;
3061 buses.push_back( line );
3062 else if( line->
IsWire() )
3063 wires.push_back( line );
3068 VECTOR2I wireStart = wire->GetStartPoint();
3069 VECTOR2I wireEnd = wire->GetEndPoint();
3073 VECTOR2I busStart = bus->GetStartPoint();
3074 VECTOR2I busEnd = bus->GetEndPoint();
3077 [](
int signX,
int signY ) ->
VECTOR2I
3089 if( wireStart.
y == wireEnd.
y && busStart.
x == busEnd.
x )
3093 if( testBusHit( wireStart ) )
3097 if( wireEnd.
x < busStart.
x )
3104 VECTOR2I p = wireStart + entrySize( -1, 0 );
3106 if( testBusHit( wireStart + entrySize( 0, -1 ) ) )
3115 screen->
Append( busEntry );
3117 wire->SetStartPoint( p );
3119 else if( testBusHit( wireStart + entrySize( 0, 1 ) ) )
3128 screen->
Append( busEntry );
3130 wire->SetStartPoint( p );
3145 VECTOR2I p = wireStart + entrySize( 1, 0 );
3147 if( testBusHit( wireStart + entrySize( 0, -1 ) ) )
3156 screen->
Append( busEntry );
3158 wire->SetStartPoint( p );
3160 else if( testBusHit( wireStart + entrySize( 0, 1 ) ) )
3169 screen->
Append( busEntry );
3171 wire->SetStartPoint( p );
3182 else if( testBusHit( wireEnd ) )
3186 if( wireStart.
x < busStart.
x )
3193 VECTOR2I p = wireEnd + entrySize( -1, 0 );
3195 if( testBusHit( wireEnd + entrySize( 0, -1 ) ) )
3204 screen->
Append( busEntry );
3206 wire->SetEndPoint( p );
3208 else if( testBusHit( wireEnd + entrySize( 0, -1 ) ) )
3217 screen->
Append( busEntry );
3218 moveLabels( wire, wireEnd + entrySize( -1, 0 ) );
3219 wire->SetEndPoint( wireEnd + entrySize( -1, 0 ) );
3234 VECTOR2I p = wireEnd + entrySize( 1, 0 );
3236 if( testBusHit( wireEnd + entrySize( 0, -1 ) ) )
3245 screen->
Append( busEntry );
3247 wire->SetEndPoint( p );
3249 else if( testBusHit( wireEnd + entrySize( 0, 1 ) ) )
3258 screen->
Append( busEntry );
3260 wire->SetEndPoint( p );
3272 else if( wireStart.
x == wireEnd.
x && busStart.
y == busEnd.
y )
3276 if( testBusHit( wireStart ) )
3280 if( wireEnd.
y < busStart.
y )
3288 VECTOR2I p = wireStart + entrySize( 0, -1 );
3290 if( testBusHit( wireStart + entrySize( -1, 0 ) ) )
3300 screen->
Append( busEntry );
3302 wire->SetStartPoint( p );
3304 else if( testBusHit( wireStart + entrySize( 1, 0 ) ) )
3314 screen->
Append( busEntry );
3316 wire->SetStartPoint( p );
3332 VECTOR2I p = wireStart + entrySize( 0, 1 );
3334 if( testBusHit( wireStart + entrySize( -1, 0 ) ) )
3344 screen->
Append( busEntry );
3346 wire->SetStartPoint( p );
3348 else if( testBusHit( wireStart + entrySize( 1, 0 ) ) )
3358 screen->
Append( busEntry );
3360 wire->SetStartPoint( p );
3371 else if( testBusHit( wireEnd ) )
3375 if( wireStart.
y < busStart.
y )
3383 VECTOR2I p = wireEnd + entrySize( 0, -1 );
3385 if( testBusHit( wireEnd + entrySize( -1, 0 ) ) )
3395 screen->
Append( busEntry );
3397 wire->SetEndPoint( p );
3399 else if( testBusHit( wireEnd + entrySize( 1, 0 ) ) )
3409 screen->
Append( busEntry );
3411 wire->SetEndPoint( p );
3427 VECTOR2I p = wireEnd + entrySize( 0, 1 );
3429 if( testBusHit( wireEnd + entrySize( -1, 0 ) ) )
3439 screen->
Append( busEntry );
3441 wire->SetEndPoint( p );
3443 else if( testBusHit( wireEnd + entrySize( 1, 0 ) ) )
3453 screen->
Append( busEntry );
3455 wire->SetEndPoint( p );
3471 if( testBusHit( wireStart ) )
3473 VECTOR2I wirevector = wireStart - wireEnd;
3475 if( wirevector.
x > 0 )
3477 if( wirevector.
y > 0 )
3479 VECTOR2I p = wireStart + entrySize( -1, -1 );
3482 screen->
Append( busEntry );
3485 wire->SetStartPoint( p );
3489 VECTOR2I p = wireStart + entrySize( -1, 1 );
3492 screen->
Append( busEntry );
3495 wire->SetStartPoint( p );
3500 if( wirevector.
y > 0 )
3502 VECTOR2I p = wireStart + entrySize( 1, -1 );
3505 screen->
Append( busEntry );
3508 wire->SetStartPoint( p );
3512 VECTOR2I p = wireStart + entrySize( 1, 1 );
3515 screen->
Append( busEntry );
3518 wire->SetStartPoint( p );
3524 else if( testBusHit( wireEnd ) )
3526 VECTOR2I wirevector = wireStart - wireEnd;
3528 if( wirevector.
x > 0 )
3530 if( wirevector.
y > 0 )
3532 VECTOR2I p = wireEnd + entrySize( 1, 1 );
3535 screen->
Append( busEntry );
3538 wire->SetEndPoint( p );
3542 VECTOR2I p = wireEnd + entrySize( 1, -1 );
3545 screen->
Append( busEntry );
3548 wire->SetEndPoint( p );
3553 if( wirevector.
y > 0 )
3555 VECTOR2I p = wireEnd + entrySize( -1, 1 );
3558 screen->
Append( busEntry );
3561 wire->SetEndPoint( p );
3565 VECTOR2I p = wireEnd + entrySize( -1, -1 );
3568 screen->
Append( busEntry );
3571 wire->SetEndPoint( p );
3585 wxCHECK( aLabel,
nullptr );
3591 if( seg.Contains( labelPos ) )
3603 wxCHECK( aSymbol && aPin,
false );
3611 const auto& items = pointIt->second;
3613 wxCHECK( items.find( aPin ) != items.end(),
false );
3615 return items.size() > 1;
3629 int unit = aSymbol->
GetUnit();
3632 std::set<int> missingUnits;
3639 bool pinInUnit = !unit ||
pin->GetUnit() == unit;
3653 switch(
pin->GetOrientation() )
3670 aScreen->
Append( netLabel );
3673 else if( aUpdateSet )
3678 wxASSERT(
pin->GetUnit() );
3679 missingUnits.insert(
pin->GetUnit() );
3692 entry.
cmp = aSymbol;
3694 entry.
units.emplace( unit,
false );
3699 cmpIt->second.units[unit] =
false;
3702 if( !missingUnits.empty() )
3705 entry.
cmp = aSymbol;
3709 for(
int i : missingUnits )
3711 if( entry.
units.find( i ) != entry.
units.end() )
3712 entry.
units.emplace( i,
true );
3724 wxString ret = wxT(
"{" );
3726 wxStringTokenizer tokenizer( aEagleName,
"," );
3728 while( tokenizer.HasMoreTokens() )
3730 wxString member = tokenizer.GetNextToken();
3737 if( member.Freq(
'!' ) % 2 > 0 )
3738 member << wxT(
"!" );
3740 ret << member << wxS(
" " );
3755 std::unique_ptr<EPART>& epart =
m_eagleDoc->drawing->schematic->parts[aInstance->part];
3757 if( !epart || epart->deviceset.IsEmpty() )
3760 std::unique_ptr<ELIBRARY>& elibrary =
m_eagleDoc->drawing->schematic->libraries[epart->library];
3765 std::unique_ptr<EDEVICE_SET>& edeviceset = elibrary->devicesets[epart->deviceset];
3770 std::unique_ptr<EGATE>& egate = edeviceset->gates[aInstance->gate];
3775 std::unique_ptr<ESYMBOL>& esymbol = elibrary->symbols[egate->symbol];
3778 return esymbol.get();
3785 const wxString& aEagleFieldName,
3788 wxCHECK( aField && !aEagleFieldName.
IsEmpty(), );
3794 for(
const std::unique_ptr<ETEXT>&
text : esymbol->
texts )
3796 if(
text->text == aEagleFieldName )
3799 VECTOR2I pos(
text->x.ToSchUnits() + aInstance->x.ToSchUnits(),
3800 -
text->y.ToSchUnits() - aInstance->y.ToSchUnits() );
3802 bool mirror =
text->rot ?
text->rot->mirror :
false;
3804 if( aInstance->rot && aInstance->rot->mirror )
3808 pos.
y = -aInstance->y.ToSchUnits() +
text->y.ToSchUnits();
3821 std::vector<SCH_FIELD*> fields;
3826 retv = fields[0]->GetPosition();
3828 for(
size_t i = 1; i < fields.size(); i++ )
3830 if( fields[i]->GetPosition().x > retv.
x )
3831 retv.
x = fields[i]->GetPosition().x;
3833 if( fields[i]->GetPosition().y > retv.
y )
3834 retv.
y = fields[i]->GetPosition().y;
constexpr EDA_IU_SCALE schIUScale
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
constexpr size_type GetWidth() const
constexpr Vec Centre() const
constexpr BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
constexpr size_type GetHeight() const
constexpr const SizeVec & GetSize() const
void SetFlags(EDA_ITEM_FLAGS aMask)
virtual void SetParent(EDA_ITEM *aParent)
void SetCenter(const VECTOR2I &aCenter)
SHAPE_POLY_SET & GetPolyShape()
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
void SetStart(const VECTOR2I &aStart)
void SetEnd(const VECTOR2I &aEnd)
void SetArcAngleAndEnd(const EDA_ANGLE &aAngle, bool aCheckNegativeAngle=false)
Set the end point from the angle center and start.
void SetFillMode(FILL_T aFill)
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
int GetTextHeight() const
const EDA_ANGLE & GetTextAngle() const
void SetTextSize(VECTOR2I aNewSize, bool aEnforceMinTextSize=true)
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)
GR_TEXT_H_ALIGN_T GetHorizJustify() const
virtual void SetVisible(bool aVisible)
void SetBold(bool aBold)
Set the text to be bold - this will also update the font if needed.
GR_TEXT_V_ALIGN_T GetVertJustify() const
virtual void SetText(const wxString &aText)
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
void SetItalic(bool aItalic)
Set the text to be italic - this will also update the font if needed.
VECTOR2I GetTextSize() const
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
EE_TYPE Overlapping(const BOX2I &aRect) const
ee_rtree::Iterator begin() const
Return a read/write iterator that points to the first.
ee_rtree::Iterator end() const
Return a read/write iterator that points to one past the last element in the EE_RTREE.
EE_TYPE OfType(KICAD_T aType) const
static std::shared_ptr< ERC_ITEM > Create(int aErrorCode)
Constructs an ERC_ITEM for the given error code.
RAII class to set and restore the fontconfig reporter.
REPORTER * m_reporter
Reporter to log errors/warnings to, may be nullptr.
PROGRESS_REPORTER * m_progressReporter
Progress reporter to track the progress of the operation, may be nullptr.
virtual bool CanReadLibrary(const wxString &aFileName) const
Checks if this IO object can read the specified library file/directory.
virtual void Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)
std::optional< LIBRARY_TABLE * > ProjectTable() const
Retrieves the project library table for this adapter type, or nullopt if one doesn't exist.
void SetNickname(const wxString &aNickname)
void SetType(const wxString &aType)
void SetURI(const wxString &aUri)
A logical library item identifier and consists of various portions much like a URI.
static UTF8 FixIllegalChars(const UTF8 &aLibItemName, bool aLib)
Replace illegal LIB_ID item name characters with underscores '_'.
Define a library symbol object.
std::vector< const SCH_PIN * > GetGraphicalPins(int aUnit=0, int aBodyStyle=0) const
Graphical pins: Return schematic pin objects as drawn (unexpanded), filtered by unit/body.
void GetFields(std::vector< SCH_FIELD * > &aList, bool aVisibleOnly=false) const override
Populate a std::vector with SCH_FIELDs, sorted in ordinal order.
void SetParent(LIB_SYMBOL *aParent=nullptr)
bool IsGlobalPower() const override
int GetUnitCount() const override
std::unique_ptr< LIB_SYMBOL > Flatten() const
Return a flattened symbol inheritance to the caller.
static LOAD_INFO_REPORTER & GetInstance()
static bool ParseBusVector(const wxString &aBus, wxString *aName, std::vector< wxString > *aMemberList)
Parse a bus vector (e.g.
Describe the page size and margins of a paper page on which to eventually print or plot.
void SetHeightMils(double aHeightInMils)
const VECTOR2D GetSizeIU(double aIUScale) const
Gets the page size in internal units.
void SetWidthMils(double aWidthInMils)
static SYMBOL_LIBRARY_ADAPTER * SymbolLibAdapter(PROJECT *aProject)
Accessor for project symbol library manager adapter.
Holds all the data relating to one schematic.
PROJECT & Project() const
Return a reference to the project this schematic is part of.
bool IsValid() const
A simple test if the schematic is loaded, not a complete one.
Class for a wire to bus entry.
virtual const wxString & GetText() const override
Return the string associated with the text object.
void ImportValues(const SCH_FIELD &aSource)
Copy parameters from a SCH_FIELD source.
bool IsEmpty()
Return true if both the name and value of the field are empty.
void SetPosition(const VECTOR2I &aPosition) override
void SetName(const wxString &aName)
void SetText(const wxString &aText) override
void SetSpinStyle(SPIN_STYLE aSpinStyle) override
std::unique_ptr< EAGLE_DOC > m_eagleDoc
SCH_ITEM * loadWire(const std::unique_ptr< EWIRE > &aWire, SEG &endpoints)
void loadTextAttributes(EDA_TEXT *aText, const std::unique_ptr< ETEXT > &aAttributes) const
void loadSegments(const std::vector< std::unique_ptr< ESEGMENT > > &aSegments, const wxString &aNetName, const wxString &aNetClass, bool aIsBus=false)
void loadModuleInstance(const std::unique_ptr< EMODULEINST > &aModuleInstance)
void ensureLoadedLibrary(const wxString &aLibraryPath)
void loadSchematic(const ESCHEMATIC &aSchematic)
SCH_TEXT * loadPlainText(const std::unique_ptr< ETEXT > &aSchText)
void loadSheet(const std::unique_ptr< ESHEET > &aSheet)
void loadLayerDefs(const std::vector< std::unique_ptr< ELAYER > > &aLayers)
VECTOR2I getLastSymbolFieldPosition(const LIB_SYMBOL *aPart)
const ESYMBOL * getEagleSymbol(const std::unique_ptr< EINSTANCE > &aInstance)
EAGLE_LIBRARY * loadLibrary(const ELIBRARY *aLibrary, EAGLE_LIBRARY *aEagleLib)
wxXmlDocument loadXmlDocument(const wxString &aFileName)
wxString translateEagleBusName(const wxString &aEagleName) const
Translate an Eagle-style bus name into one that is KiCad-compatible.
void loadFieldAttributes(SCH_FIELD *aField, const SCH_TEXT *aText) const
Move net labels that are detached from any wire to the nearest wire.
std::map< wxString, wxString > m_powerPorts
map from symbol reference to global label equivalent
SCH_SHEET_PATH m_sheetPath
The current sheet path of the schematic being loaded.
wxString m_libName
Library name to save symbols.
SCH_TEXT * loadSymbolText(std::unique_ptr< LIB_SYMBOL > &aSymbol, const std::unique_ptr< ETEXT > &aText, int aGateNumber)
std::pair< VECTOR2I, const SEG * > findNearestLinePoint(const VECTOR2I &aPoint, const std::vector< SEG > &aLines) const
std::map< wxString, long long > m_timestamps
SCH_LABEL_BASE * loadLabel(const std::unique_ptr< ELABEL > &aLabel, const wxString &aNetName, bool aIsBus=false)
void loadInstance(const std::unique_ptr< EINSTANCE > &aInstance, const std::map< wxString, std::unique_ptr< EPART > > &aParts)
LIB_SYMBOL * LoadSymbol(const wxString &aLibraryPath, const wxString &aAliasName, const std::map< std::string, UTF8 > *aProperties) override
Load a LIB_SYMBOL object having aPartName from the aLibraryPath containing a library format that this...
std::unordered_map< wxString, bool > m_userValue
deviceset/@uservalue for device.
int GetModifyHash() const override
Return the modification hash from the library cache.
std::map< wxString, int > m_netCounts
std::map< wxString, EAGLE_LIBRARY > m_eagleLibs
bool loadSymbol(const std::unique_ptr< ESYMBOL > &aEsymbol, std::unique_ptr< LIB_SYMBOL > &aSymbol, const std::unique_ptr< EDEVICE > &aDevice, int aGateNumber, const wxString &aGateName)
SCH_SHEET * getCurrentSheet()
void loadDrawing(const std::unique_ptr< EDRAWING > &aDrawing)
void EnumerateSymbolLib(wxArrayString &aSymbolNameList, const wxString &aLibraryPath, const std::map< std::string, UTF8 > *aProperties) override
Populate a list of LIB_SYMBOL alias names contained within the library aLibraryPath.
SCH_SHAPE * loadSymbolPolyLine(std::unique_ptr< LIB_SYMBOL > &aSymbol, const std::unique_ptr< EPOLYGON > &aPolygon, int aGateNumber)
std::vector< VECTOR2I > m_wireIntersections
Wires and labels of a single connection (segment in Eagle nomenclature)
std::map< VECTOR2I, std::set< const EDA_ITEM * > > m_connPoints
The fully parsed Eagle schematic file.
bool checkConnections(const SCH_SYMBOL *aSymbol, const SCH_PIN *aPin) const
IO_RELEASER< SCH_IO > m_pi
PI to create KiCad symbol library.
SCH_SHAPE * loadRectangle(const std::unique_ptr< ERECT > &aRect)
void addBusEntries()
This function finds best way to place a bus entry symbol for when an Eagle wire segment ends on an Ea...
bool CanReadSchematicFile(const wxString &aFileName) const override
Checks if this SCH_IO can read the specified schematic file.
void addImplicitConnections(SCH_SYMBOL *aSymbol, SCH_SCREEN *aScreen, bool aUpdateSet)
Create net labels to emulate implicit connections in Eagle.
std::map< int, SCH_LAYER_ID > m_layerMap
SCH_LAYER_ID kiCadLayer(int aEagleLayer)
Return the matching layer or return LAYER_NOTES.
SCH_SHEET * LoadSchematicFile(const wxString &aFileName, SCHEMATIC *aSchematic, SCH_SHEET *aAppendToMe=nullptr, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Load information from some input file format that this SCH_IO implementation knows about,...
SCH_PIN * loadPin(std::unique_ptr< LIB_SYMBOL > &aSymbol, const std::unique_ptr< EPIN > &aPin, int aGateNumber)
SCH_SHAPE * loadCircle(const std::unique_ptr< ECIRCLE > &aCircle)
wxFileName getLibFileName()
Checks if there are other wires or pins at the position of the tested pin.
SCH_SHAPE * loadSymbolRectangle(std::unique_ptr< LIB_SYMBOL > &aSymbol, const std::unique_ptr< ERECT > &aRectangle, int aGateNumber)
SCH_JUNCTION * loadJunction(const std::unique_ptr< EJUNCTION > &aJunction)
wxString m_version
Eagle file version.
void getEagleSymbolFieldAttributes(const std::unique_ptr< EINSTANCE > &aInstance, const wxString &aEagleFieldName, SCH_FIELD *aField)
std::map< wxString, const EPART * > m_partlist
void moveLabels(SCH_LINE *aWire, const VECTOR2I &aNewEndPoint)
Move any labels on the wire to the new end point of the wire.
bool checkHeader(const wxString &aFileName) const
SCHEMATIC * m_schematic
Passed to Load(), the schematic object being loaded.
void countNets(const ESCHEMATIC &aSchematic)
SCH_SHEET * m_rootSheet
The root sheet of the schematic being loaded.
SCH_SHAPE * loadPolyLine(const std::unique_ptr< EPOLYGON > &aPolygon)
SCH_SHAPE * loadSymbolCircle(std::unique_ptr< LIB_SYMBOL > &aSymbol, const std::unique_ptr< ECIRCLE > &aCircle, int aGateNumber)
SCH_SCREEN * getCurrentScreen()
bool CanReadLibrary(const wxString &aFileName) const override
Checks if this IO object can read the specified library file/directory.
std::map< wxString, EAGLE_MISSING_CMP > m_missingCmps
void loadFrame(const std::unique_ptr< EFRAME > &aFrame, std::vector< SCH_ITEM * > &aItems)
std::vector< SEG_DESC > m_segments
Nets as defined in the <nets> sections of an Eagle schematic file.
std::vector< EMODULE * > m_modules
The current module stack being loaded.
std::vector< EMODULEINST * > m_moduleInstances
SCH_ITEM * loadSymbolWire(std::unique_ptr< LIB_SYMBOL > &aSymbol, const std::unique_ptr< EWIRE > &aWire, int aGateNumber)
long long getLibraryTimestamp(const wxString &aLibraryPath) const
static const char * PropBuffering
The property used internally by the plugin to enable cache buffering which prevents the library file ...
virtual bool CanReadSchematicFile(const wxString &aFileName) const
Checks if this SCH_IO can read the specified schematic file.
SCH_IO(const wxString &aName)
Base class for any item which can be embedded within the SCHEMATIC container class,...
SCH_ITEM * Duplicate(bool addToParentGroup, SCH_COMMIT *aCommit=nullptr, bool doClone=false) const
Routine to create a new copy of given item.
virtual void SetUnit(int aUnit)
void SetShape(LABEL_FLAG_SHAPE aShape)
void SetPosition(const VECTOR2I &aPosition) override
virtual void SetSpinStyle(SPIN_STYLE aSpinStyle)
Segment description base class to describe items which have 2 end points (track, wire,...
bool IsWire() const
Return true if the line is a wire.
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
VECTOR2I GetEndPoint() const
VECTOR2I GetStartPoint() const
bool IsBus() const
Return true if the line is a bus.
void SetEndPoint(const VECTOR2I &aPosition)
void SetNumber(const wxString &aNumber)
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
void UpdateSymbolLinks(REPORTER *aReporter=nullptr)
Initialize the LIB_SYMBOL reference for each SCH_SYMBOL found in the full schematic.
const PAGE_INFO & GetPageSettings() const
void Append(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
void SetPageSettings(const PAGE_INFO &aPageSettings)
EE_RTREE & Items()
Get the full RTree, usually for iterating.
void SetFileName(const wxString &aFileName)
Set the file name for this screen to aFileName.
void Update(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
Update aItem's bounding box in the tree.
void SetPosition(const VECTOR2I &aPos) override
void SetStroke(const STROKE_PARAMS &aStroke) override
VECTOR2I GetCenter() const
void AddPoint(const VECTOR2I &aPosition)
VECTOR2I GetPosition() const override
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
Define a sheet pin (label) used in sheets to create hierarchical schematics.
void SetPosition(const VECTOR2I &aPosition) override
void SetSide(SHEET_SIDE aEdge)
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
void SetFileName(const wxString &aFilename)
bool LocatePathOfScreen(SCH_SCREEN *aScreen, SCH_SHEET_PATH *aList)
Search the existing hierarchy for an instance of screen loaded from aFileName.
void SetName(const wxString &aName)
SCH_SCREEN * GetScreen() const
void AutoplaceFields(SCH_SCREEN *aScreen, AUTOPLACE_ALGO aAlgo) override
const std::vector< SCH_SYMBOL_INSTANCE > & GetInstances() const
void AddHierarchicalReference(const KIID_PATH &aPath, const wxString &aRef, int aUnit)
Add a full hierarchical reference to this symbol.
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
VECTOR2I GetPinPhysicalPosition(const SCH_PIN *Pin) const
SCH_FIELD * GetField(FIELD_T aFieldType)
Return a mandatory field in this symbol.
VECTOR2I GetPosition() const override
void SetPosition(const VECTOR2I &aPosition) override
OPT_VECTOR2I Intersect(const SEG &aSeg, bool aIgnoreEndpoints=false, bool aLines=false) const
Compute intersection point of segment (this) with segment aSeg.
bool Contains(const SEG &aSeg) const
SHAPE_ARC & ConstructFromStartEndAngle(const VECTOR2I &aStart, const VECTOR2I &aEnd, const EDA_ANGLE &aAngle, double aWidth=0)
Construct this arc from the given start, end and angle.
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Appends a vertex at the end of the given outline/hole (default: the last outline)
Simple container to manage line stroke parameters.
An interface to the global shared library manager that is schematic-specific and linked to one projec...
std::optional< LIB_STATUS > LoadOne(LIB_DATA *aLib) override
Loads or reloads the given library, if it exists.
double Distance(const VECTOR2< extended_type > &aVector) const
Compute the distance between two vectors.
VECTOR2< T > Resize(T aNewLength) const
Return a vector of the same direction, but length specified in aNewLength.
static REPORTER & GetInstance()
#define DEFAULT_SCH_ENTRY_SIZE
The default text size in mils. (can be changed in preference menu)
wxString escapeName(const wxString &aNetName)
Translates Eagle special characters to their counterparts in KiCad.
wxString interpretText(const wxString &aText)
Interprets special characters in Eagle text and converts them to KiCAD notation.
size_t GetNodeCount(const wxXmlNode *aNode)
Fetch the number of XML nodes within aNode.
VECTOR2I ConvertArcCenter(const VECTOR2I &aStart, const VECTOR2I &aEnd, double aAngle)
Convert an Eagle curve end to a KiCad center for S_ARC.
wxString convertDescription(wxString aDescr)
Converts Eagle's HTML description into KiCad description format.
OPTIONAL_XML_ATTRIBUTE< double > opt_double
static constexpr EDA_ANGLE ANGLE_VERTICAL
#define IGNORE_PARENT_GROUP
#define IS_NEW
New item, just created.
@ RECTANGLE
Use RECTANGLE instead of RECT to avoid collision in a Windows header.
@ FILLED_SHAPE
Fill with object color.
@ ERCE_BUS_ENTRY_NEEDED
Importer failed to auto-place a bus entry.
static const std::string KiCadSchematicFileExtension
static const std::string KiCadSymbolLibFileExtension
#define THROW_IO_ERROR(msg)
macro which captures the "call site" values of FILE_, __FUNCTION & LINE
SCH_LAYER_ID
Eeschema drawing layers.
@ PT_INPUT
usual pin input: must be connected
@ PT_NC
not connected (must be left open)
@ PT_TRISTATE
tri state bus pin
@ 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_PASSIVE
pin for passive symbols: must be connected, and can be connected to any pin.
@ PIN_UP
The pin extends upwards from the connection point: Probably on the bottom side of the symbol.
@ PIN_RIGHT
The pin extends rightwards from the connection point.
@ PIN_LEFT
The pin extends leftwards from the connection point: Probably on the right side of the symbol.
@ PIN_DOWN
The pin extends downwards from the connection: Probably on the top side of the symbol.
static wxString extractNetName(const wxString &aPinName)
static const std::map< wxString, ELECTRICAL_PINTYPE > pinDirectionsMap
Map of EAGLE pin type values to KiCad pin type values.
static SYMBOL_ORIENTATION_T kiCadComponentRotation(float eagleDegrees)
static void eagleToKicadAlignment(EDA_TEXT *aText, int aEagleAlignment, int aRelDegress, bool aMirror, bool aSpin, int aAbsDegress)
static BOX2I getSheetBbox(SCH_SHEET *aSheet)
Strip the Eagle "@<tag>" linking hint from a pin name (e.g. return 'GND' for 'GND@2')
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
SHEET_SIDE
Define the edge of the sheet that the sheet pin is positioned.
std::optional< VECTOR2I > OPT_VECTOR2I
wxString UnescapeString(const wxString &aSource)
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:...
wxString UnescapeHTML(const wxString &aString)
Return a new wxString unescaped from HTML format.
std::map< wxString, std::unique_ptr< LIB_SYMBOL > > KiCadSymbols
std::unordered_map< wxString, wxString > package
std::unordered_map< wxString, int > GateToUnitMap
Map Eagle gate unit number (which are strings) to KiCad library symbol unit number.
std::map< wxString, std::unique_ptr< EDEVICE_SET > > devicesets
wxString GetName() const
Fetch the fully unique library name.
std::map< wxString, std::unique_ptr< ESYMBOL > > symbols
std::map< wxString, std::unique_ptr< EMODULE > > modules
std::vector< std::unique_ptr< ESHEET > > sheets
std::map< wxString, std::unique_ptr< EPART > > parts
std::map< wxString, std::unique_ptr< ELIBRARY > > libraries
std::vector< std::unique_ptr< ETEXT > > texts
Map references to missing symbol units data.
const SCH_SYMBOL * cmp
Screen where the parent symbol is located.
std::map< int, bool > units
Segments representing wires for intersection checking.
std::vector< SCH_LABEL_BASE * > labels
const SEG * LabelAttached(const SCH_LABEL_BASE *aLabel) const
< Test if a particular label is attached to any of the stored segments
A simple container for schematic symbol instance information.
SYMBOL_ORIENTATION_T
enum used in RotationMiroir()
@ USER
The field ID hasn't been set yet; field is invalid.
@ FOOTPRINT
Field Name Module PCB, i.e. "16DIP300".
@ REFERENCE
Field Reference of part, i.e. "IC21".
@ VALUE
Field Value of part, i.e. "3.3K".
std::vector< std::string > header
std::vector< std::vector< std::string > > table
SHAPE_CIRCLE circle(c.m_circle_center, c.m_circle_radius)
bool TestSegmentHit(const VECTOR2I &aRefPoint, const VECTOR2I &aStart, const VECTOR2I &aEnd, int aDist)
Test if aRefPoint is with aDistance on the line defined by aStart and aEnd.
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Calculate the new point of coord coord pX, pY, for a rotation center 0, 0.
VECTOR2< int32_t > VECTOR2I
Definition of file extensions used in Kicad.