31#include <wx/filename.h>
33#include <wx/tokenzr.h>
34#include <wx/wfstream.h>
35#include <wx/txtstrm.h>
36#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 )
330 m_rootSheet( nullptr ),
331 m_schematic( nullptr ),
351 const std::map<std::string, UTF8>* aProperties )
353 wxASSERT( !aFileName || aSchematic !=
nullptr );
374 wxXmlNode* currentNode = xmlDocument.GetRoot();
380 unique_ptr<SCH_SHEET> deleter( aAppendToMe ?
nullptr :
m_rootSheet );
387 wxCHECK_MSG( aSchematic->
IsValid(),
nullptr,
388 wxT(
"Can't append to a schematic with no root!" ) );
399 if( sheetPath.Last() == aAppendToMe )
429 wxCHECK_MSG( libTable,
nullptr, wxT(
"Could not load symbol lib table." ) );
431 m_pi.reset( SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_KICAD ) );
432 m_properties = std::make_unique<std::map<std::string, UTF8>>();
441 wxString libTableUri = wxT(
"${KIPRJMOD}/" ) +
getLibFileName().GetFullName();
454 libTable->
Format( &formatter, 0 );
462 m_eagleDoc = std::make_unique<EAGLE_DOC>( currentNode,
this );
481 const wxString& aLibraryPath,
482 const std::map<std::string, UTF8>* aProperties )
493 for(
const auto& [symName, libSymbol] : it->second.KiCadSymbols )
494 aSymbolNameList.push_back( symName );
500 const wxString& aLibraryPath,
501 const std::map<std::string, UTF8>* aProperties )
512 for(
const auto& [symName, libSymbol] : it->second.KiCadSymbols )
513 aSymbolList.push_back( libSymbol.get() );
519 const std::map<std::string, UTF8>* aProperties )
530 auto it2 = it->second.KiCadSymbols.find( aAliasName );
532 if( it2 != it->second.KiCadSymbols.end() )
533 return it2->second.get();
542 wxFileName fn( aLibraryPath );
544 if( fn.IsFileReadable() && fn.GetModificationTime().IsValid() )
545 return fn.GetModificationTime().GetValue().GetValue();
547 return wxDateTime( 0.0 ).GetValue().GetValue();
578 std::unique_ptr<EAGLE_DOC> doc = std::make_unique<EAGLE_DOC>( xmlDocument.GetRoot(),
this );
582 m_version = ( doc->version.IsEmpty() ) ? wxString( wxS(
"0.0" ) ) : doc->version;
594 wxXmlDocument xmlDocument;
595 wxFFileInputStream stream(
m_filename.GetFullPath() );
600 wxString::Format(
_(
"Unable to read file '%s'." ),
m_filename.GetFullPath() ) );
604 wxTextInputStream
text( stream );
605 wxString line =
text.ReadLine();
607 if( !line.StartsWith( wxT(
"<?xml" ) ) && !line.StartsWith( wxT(
"<!--" ) ) )
609 THROW_IO_ERROR( wxString::Format(
_(
"'%s' is an Eagle binary-format file; "
610 "only Eagle XML-format files can be imported." ),
614 if( !xmlDocument.Load( stream ) )
617 wxString::Format(
_(
"Unable to read file '%s'." ),
m_filename.GetFullPath() ) );
626 wxCHECK( aDrawing, );
630 if( aDrawing->library )
638 if( aDrawing->schematic )
645 for(
const std::unique_ptr<ESHEET>& esheet : aSchematic.
sheets )
647 for(
const std::unique_ptr<ENET>& enet : esheet->nets )
649 wxString netName = enet->netname;
658 for(
const auto& [modname, emodule] : aSchematic.
modules )
660 for(
const std::unique_ptr<ESHEET>& esheet : emodule->sheets )
662 for(
const std::unique_ptr<ENET>& enet : esheet->nets )
664 wxString netName = enet->netname;
679 if( aSchematic.
sheets.empty() )
683 for(
const auto& [
name, epart] : aSchematic.
parts )
686 for(
const auto& [modName, emodule] : aSchematic.
modules )
688 for(
const auto& [partName, epart] : emodule->parts )
694 for(
const auto& [libName, elibrary] : aSchematic.
libraries )
697 elib->
name = elibrary->GetName();
709 size_t sheetCount = aSchematic.
sheets.size();
717 for(
const std::unique_ptr<ESHEET>& esheet : aSchematic.
sheets )
724 std::unique_ptr<SCH_SHEET> sheet = std::make_unique<SCH_SHEET>(
m_rootSheet, pos );
726 sheet->SetScreen( screen );
729 wxCHECK2( sheet && screen,
continue );
731 wxString pageNo = wxString::Format( wxT(
"%d" ),
m_sheetIndex );
741 wxCHECK2( currentScreen,
continue );
744 currentScreen->
Append( sheet.release() );
759 for(
const std::unique_ptr<ESHEET>& esheet : aSchematic.
sheets )
771 int maxY = sheetBbox.
GetY();
778 const SCH_SYMBOL* origSymbol = cmp.second.cmp;
780 for(
auto& unitEntry : cmp.second.units )
782 if( unitEntry.second ==
false )
786 int unit = unitEntry.first;
787 const wxString reference = origSymbol->
GetField( FIELD_T::REFERENCE )->
GetText();
790 symbol->SetUnitSelection( &sheetpath, unit );
791 symbol->SetUnit( unit );
792 symbol->SetOrientation( 0 );
793 symbol->AddHierarchicalReference( sheetpath.
Path(), reference, unit );
796 BOX2I cmpBbox = symbol->GetBoundingBox();
797 int posY = newCmpPosition.
y + cmpBbox.
GetHeight();
798 symbol->SetPosition(
VECTOR2I( newCmpPosition.
x, posY ) );
800 maxY = std::max( maxY, posY );
802 if( newCmpPosition.
x >= pageSizeIU.
x )
820 wxCHECK( sheet && screen, );
824 std::string filename;
833 replace( filename.begin(), filename.end(),
' ',
'_' );
835 fn.SetName( filename );
841 for(
const auto& [
name, moduleinst] : aSheet->moduleinsts )
848 for(
const std::unique_ptr<EPOLYGON>& epoly : aSheet->plain->polygons )
851 for(
const std::unique_ptr<EWIRE>& ewire : aSheet->plain->wires )
857 for(
const std::unique_ptr<ETEXT>& etext : aSheet->plain->texts )
860 for(
const std::unique_ptr<ECIRCLE>& ecircle : aSheet->plain->circles )
863 for(
const std::unique_ptr<ERECT>& erectangle : aSheet->plain->rectangles )
866 for(
const std::unique_ptr<EFRAME>& eframe : aSheet->plain->frames )
868 std::vector<SCH_ITEM*> frameItems;
879 for(
const std::unique_ptr<EINSTANCE>& einstance : aSheet->instances )
887 for(
const std::unique_ptr<EBUS>& ebus : aSheet->busses )
896 for(
const std::unique_ptr<ENET>& enet : aSheet->nets )
899 wxString netName = enet->netname;
900 wxString netClass = wxString::Format( wxS(
"%i" ), enet->netcode );
919 if( pageSizeIU.
x < targetSheetSize.
x )
922 if( pageSizeIU.
y < targetSheetSize.
y )
929 VECTOR2I sheetcentre( pageSizeIU.
x / 2, pageSizeIU.
y / 2 );
933 VECTOR2I translation = sheetcentre - itemsCentre;
947 std::vector<SCH_ITEM*> allItems;
949 std::copy( screen->
Items().
begin(), screen->
Items().
end(), std::back_inserter( allItems ) );
953 item->SetPosition( item->GetPosition() + translation );
971 wxCHECK( currentSheet &¤tScreen, );
977 auto it =
m_eagleDoc->drawing->schematic->modules.find( aModuleInstance->moduleinst );
980 if( it ==
m_eagleDoc->drawing->schematic->modules.end() )
982 THROW_IO_ERROR( wxString::Format(
_(
"No module instance '%s' found in schematic "
984 aModuleInstance->name,
m_filename.GetFullPath() ) );
988 fn.SetName( aModuleInstance->moduleinst );
992 VECTOR2I size( it->second->dx.ToSchUnits(), it->second->dy.ToSchUnits() );
994 int halfX =
KiROUND( size.
x / 2.0 );
995 int halfY =
KiROUND( size.
y / 2.0 );
997 VECTOR2I pos( aModuleInstance->x.ToSchUnits() - halfX,
998 -aModuleInstance->y.ToSchUnits() - halfY );
1000 std::unique_ptr<SCH_SHEET> newSheet = std::make_unique<SCH_SHEET>( currentSheet, pos, size );
1008 if( schFile->GetFileName() == fn.GetFullPath() )
1010 newScreen = schFile;
1015 bool isNewSchFile = ( newScreen == nullptr );
1023 wxCHECK( newSheet && newScreen, );
1025 newSheet->SetScreen( newScreen );
1026 newSheet->SetFileName( fn.GetFullName() );
1027 newSheet->SetName( aModuleInstance->name );
1029 for(
const auto& [portName, port] : it->second->ports )
1032 int pinOffset = port->coord.ToSchUnits();
1035 if( port->side ==
"left" )
1037 side = SHEET_SIDE::LEFT;
1039 pinPos.
y = pos.
y + halfY - pinOffset;
1040 portExtWireEndpoint = pinPos;
1041 portExtWireEndpoint.
x -= portExtWireLength;
1043 else if( port->side ==
"right" )
1045 side = SHEET_SIDE::RIGHT;
1046 pinPos.
x = pos.
x + size.
x;
1047 pinPos.
y = pos.
y + halfY - pinOffset;
1048 portExtWireEndpoint = pinPos;
1049 portExtWireEndpoint.
x += portExtWireLength;
1051 else if( port->side ==
"top" )
1053 side = SHEET_SIDE::TOP;
1054 pinPos.
x = pos.
x + halfX + pinOffset;
1056 portExtWireEndpoint = pinPos;
1057 portExtWireEndpoint.
y -= portExtWireLength;
1059 else if( port->side ==
"bottom" )
1061 side = SHEET_SIDE::BOTTOM;
1062 pinPos.
x = pos.
x + halfX + pinOffset;
1063 pinPos.
y = pos.
y + size.
y;
1064 portExtWireEndpoint = pinPos;
1065 portExtWireEndpoint.
y += portExtWireLength;
1070 currentScreen->
Append( portExtWire );
1074 if( port->direction )
1076 if( *port->direction ==
"in" )
1077 pinType = LABEL_FLAG_SHAPE::L_INPUT;
1078 else if( *port->direction ==
"out" )
1079 pinType = LABEL_FLAG_SHAPE::L_OUTPUT;
1080 else if( *port->direction ==
"io" )
1081 pinType = LABEL_FLAG_SHAPE::L_BIDI;
1082 else if( *port->direction ==
"hiz" )
1083 pinType = LABEL_FLAG_SHAPE::L_TRISTATE;
1085 pinType = LABEL_FLAG_SHAPE::L_UNSPECIFIED;
1097 newSheet->AddPin( sheetPin );
1100 wxString pageNo = wxString::Format( wxT(
"%d" ),
m_sheetIndex );
1102 newSheet->SetParent( currentSheet );
1105 currentScreen->
Append( newSheet.release() );
1107 m_modules.push_back( it->second.get() );
1113 for(
const std::unique_ptr<ESHEET>& esheet : it->second->sheets )
1123 wxCHECK2( emoduleInst,
continue );
1125 refPrefix += emoduleInst->name + wxS(
":" );
1136 wxCHECK2( symbol && !symbol->
GetInstances().empty(),
continue );
1139 wxString newReference = refPrefix + inst.
m_Reference.AfterLast(
':' );
1153 std::vector<SCH_ITEM*>& aItems )
1155 int xMin = aFrame->x1.ToSchUnits();
1156 int xMax = aFrame->x2.ToSchUnits();
1157 int yMin = -aFrame->y1.ToSchUnits();
1158 int yMax = -aFrame->y2.ToSchUnits();
1161 std::swap( xMin, xMax );
1164 std::swap( yMin, yMax );
1172 aItems.push_back( lines );
1174 if( !( aFrame->border_left ==
false ) )
1181 aItems.push_back( lines );
1184 int height = yMax - yMin;
1188 double rowSpacing = height / double( aFrame->rows );
1189 double legendPosY = yMin + ( rowSpacing / 2 );
1191 for( i = 1; i < aFrame->rows; i++ )
1193 int newY =
KiROUND( yMin + ( rowSpacing * (
double) i ) );
1197 aItems.push_back( lines );
1200 char legendChar =
'A';
1202 for( i = 0; i < aFrame->rows; i++ )
1208 legendText->
SetText( wxString( legendChar ) );
1211 aItems.push_back( legendText );
1213 legendPosY += rowSpacing;
1217 if( !( aFrame->border_right ==
false ) )
1224 aItems.push_back( lines );
1227 int height = yMax - yMin;
1231 double rowSpacing = height / double( aFrame->rows );
1232 double legendPosY = yMin + ( rowSpacing / 2 );
1234 for( i = 1; i < aFrame->rows; i++ )
1236 int newY =
KiROUND( yMin + ( rowSpacing * (
double) i ) );
1240 aItems.push_back( lines );
1243 char legendChar =
'A';
1245 for( i = 0; i < aFrame->rows; i++ )
1251 legendText->
SetText( wxString( legendChar ) );
1254 aItems.push_back( legendText );
1256 legendPosY += rowSpacing;
1260 if( !( aFrame->border_top ==
false ) )
1267 aItems.push_back( lines );
1270 int width = xMax - xMin;
1274 double columnSpacing = width / double( aFrame->columns );
1275 double legendPosX = xMin + ( columnSpacing / 2 );
1277 for( i = 1; i < aFrame->columns; i++ )
1279 int newX =
KiROUND( xMin + ( columnSpacing * (
double) i ) );
1283 aItems.push_back( lines );
1286 char legendChar =
'1';
1288 for( i = 0; i < aFrame->columns; i++ )
1294 legendText->
SetText( wxString( legendChar ) );
1297 aItems.push_back( legendText );
1299 legendPosX += columnSpacing;
1303 if( !( aFrame->border_bottom ==
false ) )
1310 aItems.push_back( lines );
1313 int width = xMax - xMin;
1317 double columnSpacing = width / double( aFrame->columns );
1318 double legendPosX = xMin + ( columnSpacing / 2 );
1320 for( i = 1; i < aFrame->columns; i++ )
1322 int newX =
KiROUND( xMin + ( columnSpacing * (
double) i ) );
1326 aItems.push_back( lines );
1329 char legendChar =
'1';
1331 for( i = 0; i < aFrame->columns; i++ )
1337 legendText->
SetText( wxString( legendChar ) );
1340 aItems.push_back( legendText );
1342 legendPosX += columnSpacing;
1349 const wxString& netName,
1350 const wxString& aNetClass )
1357 size_t segmentCount = aSegments.size();
1359 for(
const std::unique_ptr<ESEGMENT>& esegment : aSegments )
1361 bool labelled =
false;
1362 bool firstWireFound =
false;
1368 for(
const std::unique_ptr<EWIRE>& ewire : esegment->wires )
1377 if( !firstWireFound )
1379 firstWire = thisWire;
1380 firstWireFound =
true;
1386 if( !desc.labels.empty() && desc.labels.front()->GetText() == netName )
1389 for(
const SEG& seg : desc.segs )
1398 segDesc.
segs.push_back( thisWire );
1402 for(
const std::unique_ptr<EJUNCTION>& ejunction : esegment->junctions )
1405 for(
const std::unique_ptr<ELABEL>& elabel : esegment->labels )
1410 wxASSERT( segDesc.
labels.empty()
1413 segDesc.
labels.push_back( label );
1417 for(
const std::unique_ptr<EPINREF>& epinref : esegment->pinRefs )
1419 wxString part = epinref->part;
1420 wxString
pin = epinref->pin;
1422 auto powerPort =
m_powerPorts.find( wxT(
"#" ) + part );
1434 if( !labelled && firstWireFound )
1436 std::unique_ptr<SCH_LABEL_BASE> label;
1441 else if( segmentCount > 1 )
1446 label->SetPosition( firstWire.
A );
1451 if( firstWire.
B.
x > firstWire.
A.
x )
1456 screen->
Append( label.release() );
1465 std::unique_ptr<SCH_SHAPE> poly = std::make_unique<SCH_SHAPE>( SHAPE_T::POLY );
1469 for(
const std::unique_ptr<EVERTEX>& evertex : aPolygon->vertices )
1471 pt =
VECTOR2I( evertex->x.ToSchUnits(), -evertex->y.ToSchUnits() );
1477 poly->GetPolyShape().Append( arc, -1, -1,
ARC_ACCURACY );
1481 poly->AddPoint( pt );
1485 prev_curve = evertex->curve;
1488 poly->SetLayer(
kiCadLayer( aPolygon->layer ) );
1489 poly->SetStroke(
STROKE_PARAMS( aPolygon->width.ToSchUnits(), LINE_STYLE::SOLID ) );
1490 poly->SetFillMode( FILL_T::FILLED_SHAPE );
1492 return poly.release();
1500 start.
x = aWire->x1.ToSchUnits();
1501 start.
y = -aWire->y1.ToSchUnits();
1502 end.
x = aWire->x2.ToSchUnits();
1503 end.
y = -aWire->y2.ToSchUnits();
1506 endpoints =
SEG( start,
end );
1510 std::unique_ptr<SCH_SHAPE> arc = std::make_unique<SCH_SHAPE>( SHAPE_T::ARC );
1513 arc->SetCenter(
center );
1514 arc->SetStart( start );
1519 arc->SetStroke(
STROKE_PARAMS( aWire->width.ToSchUnits(), LINE_STYLE::SOLID ) );
1521 return arc.release();
1525 std::unique_ptr<SCH_LINE> line = std::make_unique<SCH_LINE>();
1527 line->SetStartPoint( start );
1528 line->SetEndPoint(
end );
1529 line->SetLayer(
kiCadLayer( aWire->layer ) );
1530 line->SetStroke(
STROKE_PARAMS( aWire->width.ToSchUnits(), LINE_STYLE::SOLID ) );
1532 return line.release();
1539 std::unique_ptr<SCH_SHAPE>
circle = std::make_unique<SCH_SHAPE>( SHAPE_T::CIRCLE );
1540 VECTOR2I center( aCircle->x.ToSchUnits(), -aCircle->y.ToSchUnits() );
1553 std::unique_ptr<SCH_SHAPE> rectangle = std::make_unique<SCH_SHAPE>( SHAPE_T::RECTANGLE );
1555 rectangle->SetLayer(
kiCadLayer( aRectangle->layer ) );
1556 rectangle->SetPosition(
VECTOR2I( aRectangle->x1.ToSchUnits(), -aRectangle->y1.ToSchUnits() ) );
1557 rectangle->SetEnd(
VECTOR2I( aRectangle->x2.ToSchUnits(), -aRectangle->y2.ToSchUnits() ) );
1559 if( aRectangle->rot )
1561 VECTOR2I pos( rectangle->GetPosition() );
1568 rectangle->SetPosition( pos );
1569 rectangle->SetEnd(
end );
1573 rectangle->SetFillMode( FILL_T::FILLED_SHAPE );
1575 return rectangle.release();
1581 std::unique_ptr<SCH_JUNCTION> junction = std::make_unique<SCH_JUNCTION>();
1583 VECTOR2I pos( aJunction->x.ToSchUnits(), -aJunction->y.ToSchUnits() );
1585 junction->SetPosition( pos );
1587 return junction.release();
1592 const wxString& aNetName )
1594 VECTOR2I elabelpos( aLabel->x.ToSchUnits(), -aLabel->y.ToSchUnits() );
1599 std::unique_ptr<SCH_LABEL_BASE> label;
1602 KiROUND( aLabel->size.ToSchUnits() * 0.7 ) );
1608 label = std::make_unique<SCH_HIERLABEL>();
1611 const auto it =
m_modules.back()->ports.find( aNetName );
1615 if( it->second->direction )
1617 wxString direction = *it->second->direction;
1619 if( direction ==
"in" )
1620 type = LABEL_SHAPE::LABEL_INPUT;
1621 else if( direction ==
"out" )
1622 type = LABEL_SHAPE::LABEL_OUTPUT;
1623 else if( direction ==
"io" )
1624 type = LABEL_SHAPE::LABEL_BIDI;
1625 else if( direction ==
"hiz" )
1626 type = LABEL_SHAPE::LABEL_TRISTATE;
1628 type = LABEL_SHAPE::LABEL_PASSIVE;
1633 label->SetLabelShape( type );
1638 label = std::make_unique<SCH_LABEL>();
1644 label = std::make_unique<SCH_GLOBALLABEL>();
1649 label = std::make_unique<SCH_LABEL>();
1653 label->SetPosition( elabelpos );
1654 label->SetTextSize( textSize );
1659 for(
int i = 0; i <
KiROUND( aLabel->rot->degrees / 90 ) %4; ++i )
1660 label->Rotate90(
false );
1662 if( aLabel->rot->mirror )
1663 label->MirrorSpinStyle(
false );
1666 return label.release();
1670std::pair<VECTOR2I, const SEG*>
1672 const std::vector<SEG>& aLines )
const
1675 const SEG* nearestLine =
nullptr;
1677 float d, mindistance = std::numeric_limits<float>::max();
1680 for(
const SEG& line : aLines )
1683 d = sqrt(
abs( ( ( aPoint.
x - testpoint.
x ) ^ 2 ) + ( ( aPoint.
y - testpoint.
y ) ^ 2 ) ) );
1685 if( d < mindistance )
1688 nearestPoint = testpoint;
1689 nearestLine = &line;
1692 testpoint = line.Center();
1693 d = sqrt(
abs( ( ( aPoint.
x - testpoint.
x ) ^ 2 ) + ( ( aPoint.
y - testpoint.
y ) ^ 2 ) ) );
1695 if( d < mindistance )
1698 nearestPoint = testpoint;
1699 nearestLine = &line;
1703 d = sqrt(
abs( ( ( aPoint.
x - testpoint.
x ) ^ 2 ) + ( ( aPoint.
y - testpoint.
y ) ^ 2 ) ) );
1705 if( d < mindistance )
1708 nearestPoint = testpoint;
1709 nearestLine = &line;
1713 return std::make_pair( nearestPoint, nearestLine );
1718 const std::map<wxString, std::unique_ptr<EPART>>& aParts )
1720 wxCHECK( aInstance, );
1726 const auto partIt = aParts.find( aInstance->part );
1728 if( partIt == aParts.end() )
1730 Report( wxString::Format(
_(
"Error parsing Eagle file. Could not find '%s' "
1731 "instance but it is referenced in the schematic." ),
1738 const std::unique_ptr<EPART>& epart = partIt->second;
1740 wxString libName = epart->library;
1743 if( epart->libraryUrn )
1744 libName += wxS(
"_" ) + epart->libraryUrn->assetId;
1746 wxString gatename = epart->deviceset + wxS(
"_" ) + epart->device + wxS(
"_" ) +
1748 wxString symbolname = wxString( epart->deviceset + epart->device );
1749 symbolname.Replace( wxT(
"*" ), wxEmptyString );
1757 wxString altSymbolName = libName + wxT(
"_" ) + symbolname;
1760 wxString libIdSymbolName = altSymbolName;
1766 Report( wxString::Format( wxS(
"Eagle library '%s' not found while looking up symbol for "
1767 "deviceset '%s', device '%s', and gate '%s." ),
1768 libName, epart->deviceset, epart->device, aInstance->gate ) );
1772 const auto gateIt = libIt->second.GateToUnitMap.find( gatename );
1774 if( gateIt == libIt->second.GateToUnitMap.end() )
1776 Report( wxString::Format( wxS(
"Symbol not found for deviceset '%s', device '%s', and "
1777 "gate '%s in library '%s'." ),
1778 epart->deviceset, epart->device, aInstance->gate, libName ) );
1782 int unit = gateIt->second;
1787 auto p = elib->
package.find( kisymbolname );
1789 if( p != elib->
package.end() )
1790 package = p->second;
1792 LIB_SYMBOL* part = m_pi->LoadSymbol( getLibFileName().GetFullPath(), altSymbolName,
1793 m_properties.get() );
1797 part = m_pi->LoadSymbol( getLibFileName().GetFullPath(), kisymbolname,
1798 m_properties.get() );
1799 libIdSymbolName = kisymbolname;
1804 Report( wxString::Format(
_(
"Could not find '%s' in the imported library." ),
1810 LIB_ID libId( getLibName(), libIdSymbolName );
1811 std::unique_ptr<SCH_SYMBOL> symbol = std::make_unique<SCH_SYMBOL>();
1812 symbol->SetLibId( libId );
1813 symbol->SetUnit( unit );
1814 symbol->SetPosition(
VECTOR2I( aInstance->x.ToSchUnits(), -aInstance->y.ToSchUnits() ) );
1817 if( !package.IsEmpty() )
1819 wxString footprint = m_schematic->Prj().GetProjectName() + wxT(
":" ) + package;
1820 symbol->GetField( FIELD_T::FOOTPRINT )->SetText( footprint );
1823 if( aInstance->rot )
1827 if( aInstance->rot->mirror )
1828 symbol->MirrorHorizontally( aInstance->x.ToSchUnits() );
1831 std::vector<SCH_FIELD*> partFields;
1834 for(
const SCH_FIELD* partField : partFields )
1838 if( partField->IsMandatory() )
1839 symbolField = symbol->GetField( partField->GetId() );
1841 symbolField = symbol->GetField( partField->GetName() );
1844 symbolField->
SetTextPos( symbol->GetPosition() + partField->GetTextPos() );
1849 wxString reference = package.IsEmpty() ?
'#' + aInstance->part : aInstance->part;
1852 if( reference.find_last_not_of( wxT(
"0123456789" ) ) == ( reference.Length()-1 ) )
1853 reference.Append( wxT(
"0" ) );
1858 if( reference.find_first_not_of( wxT(
"0123456789" ) ) != 0 )
1859 reference.Prepend( wxT(
"UNK" ) );
1863 if( aInstance->part.find_first_not_of( wxT(
"#" ) ) != 0 )
1864 reference.Prepend( wxT(
"UNK" ) );
1866 SCH_FIELD* referenceField = symbol->GetField( FIELD_T::REFERENCE );
1867 referenceField->
SetText( reference );
1869 SCH_FIELD* valueField = symbol->GetField( FIELD_T::VALUE );
1870 bool userValue = m_userValue.at( libIdSymbolName );
1874 getEagleSymbolFieldAttributes( aInstance, wxS(
">NAME" ), referenceField );
1875 getEagleSymbolFieldAttributes( aInstance, wxS(
">VALUE" ), valueField );
1878 if( epart->value && !epart->value.CGet().IsEmpty() )
1880 valueField->
SetText( *epart->value );
1884 valueField->
SetText( kisymbolname );
1890 for(
const auto& [ attrName, attr ] : epart->attributes )
1894 if( !symbol->GetFields().empty() )
1895 newFieldPosition = symbol->GetFields().back().GetPosition();
1897 SCH_FIELD newField( newFieldPosition, FIELD_T::USER, symbol.get() );
1902 newField.
SetText( *attr->value );
1906 symbol->AddField( newField );
1909 for(
const auto& [variantName, variant] : epart->variants )
1911 SCH_FIELD* field = symbol->AddField( *symbol->GetField( FIELD_T::VALUE ) );
1912 field->
SetName( wxT(
"VARIANT_" ) + variant->name );
1914 if( variant->value )
1915 field->
SetText( *variant->value );
1920 bool valueAttributeFound =
false;
1921 bool nameAttributeFound =
false;
1924 for(
auto& [
name, eattr] : aInstance->attributes )
1928 if( eattr->name.Lower() == wxT(
"name" ) )
1930 field = symbol->GetField( FIELD_T::REFERENCE );
1931 nameAttributeFound =
true;
1933 else if( eattr->name.Lower() == wxT(
"value" ) )
1935 field = symbol->GetField( FIELD_T::VALUE );
1936 valueAttributeFound =
true;
1940 field = symbol->GetField( eattr->name );
1950 int absdegrees = eattr->rot ? eattr->rot->degrees : 0;
1951 bool mirror = eattr->rot ? eattr->rot->mirror :
false;
1953 if( aInstance->rot && aInstance->rot->mirror )
1956 bool spin = eattr->rot ? eattr->rot->spin :
false;
1961 int rotation = aInstance->rot ? aInstance->rot->degrees : 0;
1962 int reldegrees = ( absdegrees - rotation + 360.0 );
1970 if( aInstance->smashed && aInstance->smashed.Get() )
1972 symbol->GetField( FIELD_T::VALUE )->SetVisible( valueAttributeFound );
1973 symbol->GetField( FIELD_T::REFERENCE )->SetVisible( nameAttributeFound );
1982 for(
const EMODULEINST* emoduleInst : m_moduleInstances )
1984 wxCHECK2( emoduleInst,
continue );
1986 refPrefix += emoduleInst->name + wxS(
":" );
1989 symbol->AddHierarchicalReference( m_sheetPath.Path(), refPrefix + reference, unit );
1995 wxCHECK( libSymbol, );
1997 symbol->SetLibSymbol(
new LIB_SYMBOL( *libSymbol ) );
1999 for(
const SCH_PIN*
pin : symbol->GetLibPins() )
2000 m_connPoints[symbol->GetPinPhysicalPosition(
pin )].emplace(
pin );
2003 m_powerPorts[ reference ] = symbol->GetField( FIELD_T::VALUE )->GetText();
2005 symbol->ClearFlags();
2007 screen->
Append( symbol.release() );
2013 wxCHECK( aLibrary && aEagleLibrary,
nullptr );
2019 wxString prefix = edeviceset->prefix ? edeviceset->prefix.Get() : wxString( wxT(
"" ) );
2020 wxString deviceSetDescr;
2022 if( edeviceset->description )
2026 for(
const std::unique_ptr<EDEVICE>& edevice : edeviceset->devices )
2029 wxString symbolName = edeviceset->name + edevice->name;
2030 symbolName.Replace( wxT(
"*" ), wxEmptyString );
2031 wxASSERT( !symbolName.IsEmpty() );
2034 if( edevice->package )
2035 aEagleLibrary->
package[symbolName] = edevice->package.Get();
2038 std::unique_ptr<LIB_SYMBOL> libSymbol = std::make_unique<LIB_SYMBOL>( symbolName );
2041 int gate_count =
static_cast<int>( edeviceset->gates.size() );
2042 libSymbol->SetUnitCount( gate_count );
2043 libSymbol->LockUnits(
true );
2045 SCH_FIELD* reference = libSymbol->GetField( FIELD_T::REFERENCE );
2047 if( prefix.length() == 0 )
2055 reference->
SetText( edevice->package ? prefix :
'#' + prefix );
2058 libSymbol->GetValueField().SetVisible(
true );
2061 bool ispower =
false;
2063 for(
const auto& [gateName, egate] : edeviceset->gates )
2065 const auto it = aLibrary->
symbols.find( egate->symbol );
2067 if( it == aLibrary->
symbols.end() )
2069 Report( wxString::Format( wxS(
"Eagle symbol '%s' not found in library '%s'." ),
2070 egate->symbol, aLibrary->
GetName() ) );
2074 wxString gateMapName = edeviceset->name + wxS(
"_" ) + edevice->name +
2075 wxS(
"_" ) + egate->name;
2077 ispower =
loadSymbol( it->second, libSymbol, edevice, gateindex, egate->name );
2082 libSymbol->SetUnitCount( gate_count );
2084 if( gate_count == 1 && ispower )
2085 libSymbol->SetGlobalPower();
2088 if( edevice->package )
2102 wxString packageString = libName + wxT(
":" ) + aEagleLibrary->
package[symbolName];
2104 libSymbol->GetFootprintField().SetText( packageString );
2107 wxString libName = libSymbol->GetName();
2108 libSymbol->SetName( libName );
2109 libSymbol->SetDescription( deviceSetDescr );
2119 libName = aEagleLibrary->
name + wxT(
"_" ) + libName;
2121 libSymbol->SetName( libName );
2135 aEagleLibrary->
KiCadSymbols[ libName ] = std::move( libSymbol );
2139 m_userValue.emplace( std::make_pair( libName, edeviceset->uservalue ==
true ) );
2143 return aEagleLibrary;
2148 std::unique_ptr<LIB_SYMBOL>& aSymbol,
2149 const std::unique_ptr<EDEVICE>& aDevice,
int aGateNumber,
2150 const wxString& aGateName )
2152 wxCHECK( aEsymbol && aSymbol && aDevice,
false );
2154 wxString symbolName = aEsymbol->name;
2155 std::vector<SCH_ITEM*> items;
2157 bool showRefDes =
false;
2158 bool showValue =
false;
2159 bool ispower =
false;
2162 for(
const std::unique_ptr<ECIRCLE>& ecircle : aEsymbol->circles )
2165 for(
const std::unique_ptr<EPIN>& epin : aEsymbol->pins )
2167 std::unique_ptr<SCH_PIN>
pin(
loadPin( aSymbol, epin, aGateNumber ) );
2170 pin->SetType( ELECTRICAL_PINTYPE::PT_BIDI );
2172 if( epin->direction )
2176 if( epin->direction->Lower() == pinDir.first )
2178 pin->SetType( pinDir.second );
2180 if( pinDir.first == wxT(
"sup" ) )
2189 if( aDevice->connects.size() != 0 )
2191 for(
const std::unique_ptr<ECONNECT>& connect : aDevice->connects )
2193 if( connect->gate == aGateName &&
pin->GetName() == connect->pin )
2195 wxArrayString pads = wxSplit( wxString( connect->pad ),
' ' );
2197 pin->SetUnit( aGateNumber );
2200 if( pads.GetCount() > 1 )
2202 pin->SetNumberTextSize( 0 );
2205 for(
unsigned i = 0; i < pads.GetCount(); i++ )
2209 wxString padname( pads[i] );
2211 aSymbol->AddDrawItem( apin );
2220 pin->SetUnit( aGateNumber );
2221 pin->SetNumber( wxString::Format( wxT(
"%i" ), pincount ) );
2222 aSymbol->AddDrawItem(
pin.release() );
2226 for(
const std::unique_ptr<EPOLYGON>& epolygon : aEsymbol->polygons )
2229 for(
const std::unique_ptr<ERECT>& erectangle : aEsymbol->rectangles )
2232 for(
const std::unique_ptr<ETEXT>& etext : aEsymbol->texts )
2234 std::unique_ptr<SCH_TEXT> libtext(
loadSymbolText( aSymbol, etext, aGateNumber ) );
2236 if( libtext->GetText() == wxT(
"${REFERENCE}" ) )
2242 showRefDes = etext->text == wxT(
">NAME" );
2244 else if( libtext->GetText() == wxT(
"${VALUE}" ) )
2250 showValue = etext->text == wxT(
">VALUE" );
2254 aSymbol->AddDrawItem( libtext.release() );
2258 for(
const std::unique_ptr<EWIRE>& ewire : aEsymbol->wires )
2259 aSymbol->AddDrawItem(
loadSymbolWire( aSymbol, ewire, aGateNumber ) );
2261 for(
const std::unique_ptr<EFRAME>& eframe : aEsymbol->frames )
2263 std::vector<SCH_ITEM*> frameItems;
2269 item->SetParent( aSymbol.get() );
2270 item->SetUnit( aGateNumber );
2271 aSymbol->AddDrawItem( item );
2275 aSymbol->GetReferenceField().SetVisible( showRefDes );
2276 aSymbol->GetValueField().SetVisible( showValue );
2278 return pincount == 1 ? ispower :
false;
2283 const std::unique_ptr<ECIRCLE>& aCircle,
2286 wxCHECK( aSymbol && aCircle,
nullptr );
2290 VECTOR2I center( aCircle->x.ToSchUnits(), -aCircle->y.ToSchUnits() );
2292 circle->SetParent( aSymbol.get() );
2296 circle->SetUnit( aGateNumber );
2303 const std::unique_ptr<ERECT>& aRectangle,
2306 wxCHECK( aSymbol && aRectangle,
nullptr );
2311 rectangle->
SetPosition(
VECTOR2I( aRectangle->x1.ToSchUnits(), -aRectangle->y1.ToSchUnits() ) );
2312 rectangle->
SetEnd(
VECTOR2I( aRectangle->x2.ToSchUnits(), -aRectangle->y2.ToSchUnits() ) );
2314 if( aRectangle->rot )
2327 rectangle->
SetUnit( aGateNumber );
2337 const std::unique_ptr<EWIRE>& aWire,
int aGateNumber )
2339 wxCHECK( aSymbol && aWire,
nullptr );
2343 begin.
x = aWire->x1.ToSchUnits();
2344 begin.
y = -aWire->y1.ToSchUnits();
2345 end.
x = aWire->x2.ToSchUnits();
2346 end.
y = -aWire->y2.ToSchUnits();
2365 ( aWire->width.ToSchUnits() /
radius );
2366 begin =
center + centerStartVector;
2398 const std::unique_ptr<EPOLYGON>& aPolygon,
2401 wxCHECK( aSymbol && aPolygon,
nullptr );
2409 for(
const std::unique_ptr<EVERTEX>& evertex : aPolygon->vertices )
2411 pt =
VECTOR2I( evertex->x.ToSchUnits(), evertex->y.ToSchUnits() );
2425 prev_curve = evertex->curve;
2437 const std::unique_ptr<EPIN>& aPin,
int aGateNumber )
2439 wxCHECK( aSymbol && aPin,
nullptr );
2441 std::unique_ptr<SCH_PIN>
pin = std::make_unique<SCH_PIN>( aSymbol.get() );
2442 pin->SetPosition(
VECTOR2I( aPin->x.ToSchUnits(), -aPin->y.ToSchUnits() ) );
2443 pin->SetName( aPin->name );
2444 pin->SetUnit( aGateNumber );
2446 int roti = aPin->rot ? aPin->rot->degrees : 0;
2450 case 0:
pin->SetOrientation( PIN_ORIENTATION::PIN_RIGHT );
break;
2451 case 90:
pin->SetOrientation( PIN_ORIENTATION::PIN_UP );
break;
2452 case 180:
pin->SetOrientation( PIN_ORIENTATION::PIN_LEFT );
break;
2453 case 270:
pin->SetOrientation( PIN_ORIENTATION::PIN_DOWN );
break;
2454 default: wxFAIL_MSG( wxString::Format( wxT(
"Unhandled orientation (%d degrees)." ), roti ) );
2461 wxString length = aPin->length.Get();
2463 if( length == wxT(
"short" ) )
2465 else if( length == wxT(
"middle" ) )
2467 else if( length == wxT(
"long" ) )
2469 else if( length == wxT(
"point" ) )
2480 wxString visible = aPin->visible.Get();
2482 if( visible == wxT(
"off" ) )
2484 pin->SetNameTextSize( 0 );
2485 pin->SetNumberTextSize( 0 );
2487 else if( visible == wxT(
"pad" ) )
2489 pin->SetNameTextSize( 0 );
2491 else if( visible == wxT(
"pin" ) )
2493 pin->SetNumberTextSize( 0 );
2503 if( aPin->function )
2505 wxString function = aPin->function.Get();
2507 if( function == wxT(
"dot" ) )
2508 pin->SetShape( GRAPHIC_PINSHAPE::INVERTED );
2509 else if( function == wxT(
"clk" ) )
2510 pin->SetShape( GRAPHIC_PINSHAPE::CLOCK );
2511 else if( function == wxT(
"dotclk" ) )
2512 pin->SetShape( GRAPHIC_PINSHAPE::INVERTED_CLOCK );
2515 return pin.release();
2520 const std::unique_ptr<ETEXT>& aText,
int aGateNumber )
2522 wxCHECK( aSymbol && aText,
nullptr );
2524 std::unique_ptr<SCH_TEXT> libtext = std::make_unique<SCH_TEXT>();
2526 libtext->SetParent( aSymbol.get() );
2527 libtext->SetUnit( aGateNumber );
2528 libtext->SetPosition(
VECTOR2I( aText->x.ToSchUnits(), -aText->y.ToSchUnits() ) );
2530 const wxString& eagleText = aText->text;
2531 wxString adjustedText;
2532 wxStringTokenizer tokenizer( eagleText,
"\r\n" );
2535 while( tokenizer.HasMoreTokens() )
2537 wxString tmp =
interpretText( tokenizer.GetNextToken().Trim(
true ).Trim(
false ) );
2539 if( tokenizer.HasMoreTokens() )
2542 adjustedText += tmp;
2545 libtext->SetText( adjustedText.IsEmpty() ? wxString( wxS(
"~" ) ) : adjustedText );
2549 return libtext.release();
2555 wxCHECK( aText,
nullptr );
2557 std::unique_ptr<SCH_TEXT> schtext = std::make_unique<SCH_TEXT>();
2559 const wxString& eagleText = aText->text;
2560 wxString adjustedText;
2561 wxStringTokenizer tokenizer( eagleText,
"\r\n" );
2564 while( tokenizer.HasMoreTokens() )
2566 wxString tmp =
interpretText( tokenizer.GetNextToken().Trim(
true ).Trim(
false ) );
2568 if( tokenizer.HasMoreTokens() )
2571 adjustedText += tmp;
2574 schtext->SetText( adjustedText.IsEmpty() ? wxString( wxS(
"\" \"" ) )
2577 schtext->SetPosition(
VECTOR2I( aText->x.ToSchUnits(), -aText->y.ToSchUnits() ) );
2579 schtext->SetItalic(
false );
2581 return schtext.release();
2586 const std::unique_ptr<ETEXT>& aAttributes )
const
2588 wxCHECK( aText && aAttributes, );
2593 if( aAttributes->ratio && aAttributes->ratio.CGet() > 12 )
2597 int degrees = aAttributes->rot ? aAttributes->rot->degrees : 0;
2598 bool mirror = aAttributes->rot ? aAttributes->rot->mirror :
false;
2599 bool spin = aAttributes->rot ? aAttributes->rot->spin :
false;
2607 wxCHECK( aField && aText, );
2631 auto onIntersection =
2640 for(
SCH_TEXT* label : segDesc.labels )
2643 const SEG* segAttached = segDesc.LabelAttached( label );
2645 if( segAttached && !onIntersection( labelPos ) )
2659 VECTOR2I wireDirection( segAttached->
B - segAttached->
A );
2661 const VECTOR2I origPos( labelPos );
2664 bool checkPositive =
true, checkNegative =
true,
move =
false;
2668 while( ( !
move || onIntersection( labelPos ) ) && ( checkPositive || checkNegative ) )
2673 if( trial % 2 == 1 )
2675 labelPos =
VECTOR2I( origPos + wireDirection * trial / 2 );
2676 move = checkPositive = segAttached->
Contains( labelPos );
2680 labelPos =
VECTOR2I( origPos - wireDirection * trial / 2 );
2681 move = checkNegative = segAttached->
Contains( labelPos );
2717 wxFileInputStream input( aFileName );
2722 wxTextInputStream
text( input );
2724 for(
int i = 0; i < 8; i++ )
2729 if(
text.ReadLine().Contains( wxS(
"<eagle" ) ) )
2747 if( !item->IsType( { SCH_LABEL_LOCATE_ANY_T } ) )
2751 item->SetPosition( aNewEndPoint );
2764 std::vector<SCH_LINE*> buses;
2765 std::vector<SCH_LINE*> wires;
2776 buses.push_back( line );
2777 else if( line->
IsWire() )
2778 wires.push_back( line );
2783 VECTOR2I wireStart = wire->GetStartPoint();
2784 VECTOR2I wireEnd = wire->GetEndPoint();
2788 VECTOR2I busStart = bus->GetStartPoint();
2789 VECTOR2I busEnd = bus->GetEndPoint();
2792 [](
int signX,
int signY ) ->
VECTOR2I
2804 if( wireStart.
y == wireEnd.
y && busStart.
x == busEnd.
x )
2808 if( testBusHit( wireStart ) )
2812 if( wireEnd.
x < busStart.
x )
2819 VECTOR2I p = wireStart + entrySize( -1, 0 );
2821 if( testBusHit( wireStart + entrySize( 0, -1 ) ) )
2830 screen->
Append( busEntry );
2832 wire->SetStartPoint( p );
2834 else if( testBusHit( wireStart + entrySize( 0, 1 ) ) )
2843 screen->
Append( busEntry );
2845 wire->SetStartPoint( p );
2851 screen->
Append( marker );
2861 VECTOR2I p = wireStart + entrySize( 1, 0 );
2863 if( testBusHit( wireStart + entrySize( 0, -1 ) ) )
2872 screen->
Append( busEntry );
2874 wire->SetStartPoint( p );
2876 else if( testBusHit( wireStart + entrySize( 0, 1 ) ) )
2885 screen->
Append( busEntry );
2887 wire->SetStartPoint( p );
2893 screen->
Append( marker );
2899 else if( testBusHit( wireEnd ) )
2903 if( wireStart.
x < busStart.
x )
2910 VECTOR2I p = wireEnd + entrySize( -1, 0 );
2912 if( testBusHit( wireEnd + entrySize( 0, -1 ) ) )
2921 screen->
Append( busEntry );
2923 wire->SetEndPoint( p );
2925 else if( testBusHit( wireEnd + entrySize( 0, -1 ) ) )
2934 screen->
Append( busEntry );
2935 moveLabels( wire, wireEnd + entrySize( -1, 0 ) );
2936 wire->SetEndPoint( wireEnd + entrySize( -1, 0 ) );
2942 screen->
Append( marker );
2952 VECTOR2I p = wireEnd + entrySize( 1, 0 );
2954 if( testBusHit( wireEnd + entrySize( 0, -1 ) ) )
2963 screen->
Append( busEntry );
2965 wire->SetEndPoint( p );
2967 else if( testBusHit( wireEnd + entrySize( 0, 1 ) ) )
2976 screen->
Append( busEntry );
2978 wire->SetEndPoint( p );
2984 screen->
Append( marker );
2991 else if( wireStart.
x == wireEnd.
x && busStart.
y == busEnd.
y )
2995 if( testBusHit( wireStart ) )
2999 if( wireEnd.
y < busStart.
y )
3007 VECTOR2I p = wireStart + entrySize( 0, -1 );
3009 if( testBusHit( wireStart + entrySize( -1, 0 ) ) )
3019 screen->
Append( busEntry );
3021 wire->SetStartPoint( p );
3023 else if( testBusHit( wireStart + entrySize( 1, 0 ) ) )
3033 screen->
Append( busEntry );
3035 wire->SetStartPoint( p );
3041 screen->
Append( marker );
3052 VECTOR2I p = wireStart + entrySize( 0, 1 );
3054 if( testBusHit( wireStart + entrySize( -1, 0 ) ) )
3064 screen->
Append( busEntry );
3066 wire->SetStartPoint( p );
3068 else if( testBusHit( wireStart + entrySize( 1, 0 ) ) )
3078 screen->
Append( busEntry );
3080 wire->SetStartPoint( p );
3086 screen->
Append( marker );
3092 else if( testBusHit( wireEnd ) )
3096 if( wireStart.
y < busStart.
y )
3104 VECTOR2I p = wireEnd + entrySize( 0, -1 );
3106 if( testBusHit( wireEnd + entrySize( -1, 0 ) ) )
3116 screen->
Append( busEntry );
3118 wire->SetEndPoint( p );
3120 else if( testBusHit( wireEnd + entrySize( 1, 0 ) ) )
3130 screen->
Append( busEntry );
3132 wire->SetEndPoint( p );
3138 screen->
Append( marker );
3149 VECTOR2I p = wireEnd + entrySize( 0, 1 );
3151 if( testBusHit( wireEnd + entrySize( -1, 0 ) ) )
3161 screen->
Append( busEntry );
3163 wire->SetEndPoint( p );
3165 else if( testBusHit( wireEnd + entrySize( 1, 0 ) ) )
3175 screen->
Append( busEntry );
3177 wire->SetEndPoint( p );
3183 screen->
Append( marker );
3194 if( testBusHit( wireStart ) )
3196 VECTOR2I wirevector = wireStart - wireEnd;
3198 if( wirevector.
x > 0 )
3200 if( wirevector.
y > 0 )
3202 VECTOR2I p = wireStart + entrySize( -1, -1 );
3205 screen->
Append( busEntry );
3208 wire->SetStartPoint( p );
3212 VECTOR2I p = wireStart + entrySize( -1, 1 );
3215 screen->
Append( busEntry );
3218 wire->SetStartPoint( p );
3223 if( wirevector.
y > 0 )
3225 VECTOR2I p = wireStart + entrySize( 1, -1 );
3228 screen->
Append( busEntry );
3231 wire->SetStartPoint( p );
3235 VECTOR2I p = wireStart + entrySize( 1, 1 );
3238 screen->
Append( busEntry );
3241 wire->SetStartPoint( p );
3247 else if( testBusHit( wireEnd ) )
3249 VECTOR2I wirevector = wireStart - wireEnd;
3251 if( wirevector.
x > 0 )
3253 if( wirevector.
y > 0 )
3255 VECTOR2I p = wireEnd + entrySize( 1, 1 );
3258 screen->
Append( busEntry );
3261 wire->SetEndPoint( p );
3265 VECTOR2I p = wireEnd + entrySize( 1, -1 );
3268 screen->
Append( busEntry );
3271 wire->SetEndPoint( p );
3276 if( wirevector.
y > 0 )
3278 VECTOR2I p = wireEnd + entrySize( -1, 1 );
3281 screen->
Append( busEntry );
3284 wire->SetEndPoint( p );
3288 VECTOR2I p = wireEnd + entrySize( -1, -1 );
3291 screen->
Append( busEntry );
3294 wire->SetEndPoint( p );
3308 wxCHECK( aLabel,
nullptr );
3312 for(
const SEG& seg : segs )
3314 if( seg.Contains( labelPos ) )
3326 wxCHECK( aSymbol && aPin,
false );
3334 const auto& items = pointIt->second;
3336 wxCHECK( items.find( aPin ) != items.end(),
false );
3338 return items.size() > 1;
3352 int unit = aSymbol->
GetUnit();
3353 const wxString reference = aSymbol->
GetField( FIELD_T::REFERENCE )->
GetText();
3355 std::set<int> missingUnits;
3360 if(
pin->GetType() == ELECTRICAL_PINTYPE::PT_POWER_IN )
3362 bool pinInUnit = !unit ||
pin->GetUnit() == unit;
3376 switch(
pin->GetOrientation() )
3379 case PIN_ORIENTATION::PIN_RIGHT:
3382 case PIN_ORIENTATION::PIN_LEFT:
3385 case PIN_ORIENTATION::PIN_UP:
3388 case PIN_ORIENTATION::PIN_DOWN:
3393 aScreen->
Append( netLabel );
3396 else if( aUpdateSet )
3401 wxASSERT(
pin->GetUnit() );
3402 missingUnits.insert(
pin->GetUnit() );
3415 entry.
cmp = aSymbol;
3416 entry.
units.emplace( unit,
false );
3421 cmpIt->second.units[unit] =
false;
3424 if( !missingUnits.empty() )
3427 entry.
cmp = aSymbol;
3430 for(
int i : missingUnits )
3432 if( entry.
units.find( i ) != entry.
units.end() )
3433 entry.
units.emplace( i,
true );
3445 wxString ret = wxT(
"{" );
3447 wxStringTokenizer tokenizer( aEagleName, wxT(
"," ) );
3449 while( tokenizer.HasMoreTokens() )
3451 wxString member = tokenizer.GetNextToken();
3458 if( member.Freq(
'!' ) % 2 > 0 )
3459 member << wxT(
"!" );
3461 ret << member << wxS(
" " );
3476 std::unique_ptr<EPART>& epart =
m_eagleDoc->drawing->schematic->parts[aInstance->part];
3478 if( !epart || epart->deviceset.IsEmpty() )
3481 std::unique_ptr<ELIBRARY>& elibrary =
m_eagleDoc->drawing->schematic->libraries[epart->library];
3486 std::unique_ptr<EDEVICE_SET>& edeviceset = elibrary->devicesets[epart->deviceset];
3491 std::unique_ptr<EGATE>& egate = edeviceset->gates[aInstance->gate];
3496 std::unique_ptr<ESYMBOL>& esymbol = elibrary->symbols[egate->symbol];
3499 return esymbol.get();
3506 const wxString& aEagleFieldName,
3509 wxCHECK( aField && !aEagleFieldName.
IsEmpty(), );
3515 for(
const std::unique_ptr<ETEXT>&
text : esymbol->
texts )
3517 if(
text->text == aEagleFieldName )
3520 VECTOR2I pos(
text->x.ToSchUnits() + aInstance->x.ToSchUnits(),
3521 -
text->y.ToSchUnits() - aInstance->y.ToSchUnits() );
3523 bool mirror =
text->rot ?
text->rot->mirror :
false;
3525 if( aInstance->rot && aInstance->rot->mirror )
3529 pos.
y = -aInstance->y.ToSchUnits() +
text->y.ToSchUnits();
constexpr EDA_IU_SCALE schIUScale
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
constexpr coord_type GetY() const
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 coord_type GetLeft() const
constexpr const SizeVec & GetSize() const
constexpr coord_type GetBottom() 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,...
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
iterator end()
Return a read/write iterator that points to one past the last element in the EE_RTREE.
iterator begin()
Return a read/write iterator that points to the first.
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.
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)
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.
void GetFields(std::vector< SCH_FIELD * > &aList, bool aVisibleOnly=false) const override
Populate a std::vector with SCH_FIELDs, sorted in ordinal order.
bool IsGlobalPower() const override
int GetUnitCount() const override
bool HasLibrary(const wxString &aNickname, bool aCheckEnabled=false) const
Test for the existence of aNickname in the library table.
bool InsertRow(LIB_TABLE_ROW *aRow, bool doReplace=false)
Adds aRow if it does not already exist or if doReplace is true.
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
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)
virtual bool KeepRefreshing(bool aWait=false)=0
Update the UI (if any).
virtual void SetNumPhases(int aNumPhases)=0
Set the number of phases.
virtual void Report(const wxString &aMessage)=0
Display aMessage in the progress bar dialog.
static SYMBOL_LIB_TABLE * SchSymbolLibTable(PROJECT *aProject)
Accessor for project symbol library table.
virtual void SetElem(PROJECT::ELEM aIndex, _ELEM *aElem)
virtual const wxString GetProjectPath() const
Return the full path of the project.
virtual const wxString GetProjectName() const
Return the short name of the project.
Holds all the data relating to one schematic.
PROJECT & Prj() const
Return a reference to the project this schematic is part of.
void SetRoot(SCH_SHEET *aRootSheet)
Initialize the schematic with a new root sheet.
bool IsValid() const
A simple test if the schematic is loaded, not a complete one.
Class for a wire to bus entry.
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 loadModuleInstance(const std::unique_ptr< EMODULEINST > &aModuleInstance)
SCH_TEXT * loadLabel(const std::unique_ptr< ELABEL > &aLabel, const wxString &aNetName)
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)
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
const double ARC_ACCURACY
std::map< wxString, long long > m_timestamps
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.
void loadSegments(const std::vector< std::unique_ptr< ESEGMENT > > &aSegments, const wxString &aNetName, const wxString &aNetClass)
bool checkConnections(const SCH_SYMBOL *aSymbol, const SCH_PIN *aPin) const
std::unique_ptr< std::map< std::string, UTF8 > > m_properties
Library plugin properties.
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 ...
Base class that schematic file and library loading and saving plugins should derive from.
virtual bool CanReadSchematicFile(const wxString &aFileName) const
Checks if this SCH_IO can read the specified schematic file.
Base class for any item which can be embedded within the SCHEMATIC container class,...
virtual void SetUnit(int aUnit)
SCH_ITEM * Duplicate(bool doClone=false) const
Routine to create a new copy of given item.
void SetShape(LABEL_FLAG_SHAPE aShape)
void SetPosition(const VECTOR2I &aPosition) override
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.
const KIID & GetUuid() const
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...
KIID_PATH Path() const
Get the sheet path as an KIID_PATH.
SCH_SCREEN * LastScreen()
void SetPageNumber(const wxString &aPageNumber)
Set the sheet instance user definable page number.
SCH_SHEET * Last() const
Return a pointer to the last SCH_SHEET of the list.
void push_back(SCH_SHEET *aSheet)
Forwarded method from std::vector.
void pop_back()
Forwarded method from std::vector.
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)
wxString GetFileName() const
Return the filename corresponding to this sheet.
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 SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
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.
Hold a record identifying a symbol library accessed by the appropriate symbol library SCH_IO object i...
static const wxString GetSymbolLibTableFileName()
virtual void Format(OUTPUTFORMATTER *aOutput, int aIndentLevel) const override
Generate the table in s-expression format to aOutput with an indentation level of aIndentLevel.
LIB_SYMBOL * LoadSymbol(const wxString &aNickname, const wxString &aName)
Load a LIB_SYMBOL having aName from the library given by aNickname.
VECTOR2< T > Resize(T aNewLength) const
Return a vector of the same direction, but length specified in aNewLength.
static REPORTER & GetInstance()
static void SetReporter(REPORTER *aReporter)
Set the reporter to use for reporting font substitution warnings.
#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.
static constexpr EDA_ANGLE ANGLE_VERTICAL
#define IS_NEW
New item, just created.
@ 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)
SCH_LAYER_ID
Eeschema drawing layers.
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
@ 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.
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)
Extract the net name part from a pin name (e.g. return 'GND' for pin named '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.
constexpr int IUToMils(int iu) const
constexpr int MilsToIU(int mils) const
constexpr int mmToIU(double mm) const
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.
std::map< int, bool > units
Segments representing wires for intersection checking.
std::vector< SCH_TEXT * > labels
const SEG * LabelAttached(const SCH_TEXT *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()
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.