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 if( elayer->name == wxT(
"Nets" ) )
179 else if( elayer->name == wxT(
"Info" ) || elayer->name == wxT(
"Guide" ) )
181 else if( elayer->name == wxT(
"Busses" ) )
197 int roti = int( eagleDegrees );
207 wxASSERT_MSG(
false, wxString::Format( wxT(
"Unhandled orientation (%d degrees)" ),
216 bool aMirror,
bool aSpin,
int aAbsDegress )
218 int align = aEagleAlignment;
220 if( aRelDegress == 90 )
224 else if( aRelDegress == 180 )
228 else if( aRelDegress == 270 )
234 if( aMirror ==
true )
236 if( aAbsDegress == 90 || aAbsDegress == 270 )
247 else if( aAbsDegress == 0 || aAbsDegress == 180 )
320 m_rootSheet( nullptr ),
321 m_schematic( nullptr ),
342 const std::map<std::string, UTF8>* aProperties )
344 wxASSERT( !aFileName || aSchematic !=
nullptr );
365 wxXmlNode* currentNode = xmlDocument.GetRoot();
371 unique_ptr<SCH_SHEET> deleter( aAppendToMe ?
nullptr :
m_rootSheet );
378 wxCHECK_MSG( aSchematic->
IsValid(),
nullptr,
379 wxT(
"Can't append to a schematic with no root!" ) );
402 wxCHECK_MSG( libTable,
nullptr, wxT(
"Could not load symbol lib table." ) );
404 m_pi.reset( SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_KICAD ) );
405 m_properties = std::make_unique<std::map<std::string, UTF8>>();
414 wxString libTableUri = wxT(
"${KIPRJMOD}/" ) +
getLibFileName().GetFullName();
427 libTable->
Format( &formatter, 0 );
435 m_eagleDoc = std::make_unique<EAGLE_DOC>( currentNode,
this );
454 const wxString& aLibraryPath,
455 const std::map<std::string, UTF8>* aProperties )
466 for(
const auto& [symName, libSymbol] : it->second.KiCadSymbols )
467 aSymbolNameList.push_back( symName );
473 const wxString& aLibraryPath,
474 const std::map<std::string, UTF8>* aProperties )
485 for(
const auto& [symName, libSymbol] : it->second.KiCadSymbols )
486 aSymbolList.push_back( libSymbol.get() );
492 const std::map<std::string, UTF8>* aProperties )
503 auto it2 = it->second.KiCadSymbols.find( aAliasName );
505 if( it2 != it->second.KiCadSymbols.end() )
506 return it2->second.get();
515 wxFileName fn( aLibraryPath );
517 if( fn.IsFileReadable() && fn.GetModificationTime().IsValid() )
518 return fn.GetModificationTime().GetValue().GetValue();
520 return wxDateTime( 0.0 ).GetValue().GetValue();
551 std::unique_ptr<EAGLE_DOC> doc = std::make_unique<EAGLE_DOC>( xmlDocument.GetRoot(),
this );
555 m_version = ( doc->version.IsEmpty() ) ? wxString( wxS(
"0.0" ) ) : doc->version;
567 wxXmlDocument xmlDocument;
568 wxFFileInputStream stream(
m_filename.GetFullPath() );
573 wxString::Format(
_(
"Unable to read file '%s'." ),
m_filename.GetFullPath() ) );
577 wxTextInputStream
text( stream );
578 wxString line =
text.ReadLine();
580 if( !line.StartsWith( wxT(
"<?xml" ) ) && !line.StartsWith( wxT(
"<!--" ) ) )
582 THROW_IO_ERROR( wxString::Format(
_(
"'%s' is an Eagle binary-format file; "
583 "only Eagle XML-format files can be imported." ),
587 if( !xmlDocument.Load( stream ) )
590 wxString::Format(
_(
"Unable to read file '%s'." ),
m_filename.GetFullPath() ) );
599 wxCHECK( aDrawing, );
603 if( aDrawing->library )
611 if( aDrawing->schematic )
618 for(
const std::unique_ptr<ESHEET>& esheet : aSchematic.
sheets )
620 for(
const std::unique_ptr<ENET>& enet : esheet->nets )
622 wxString netName = enet->netname;
631 for(
const auto& [modname, emodule] : aSchematic.
modules )
633 for(
const std::unique_ptr<ESHEET>& esheet : emodule->sheets )
635 for(
const std::unique_ptr<ENET>& enet : esheet->nets )
637 wxString netName = enet->netname;
652 if( aSchematic.
sheets.empty() )
656 for(
const auto& [
name, epart] : aSchematic.
parts )
659 for(
const auto& [modname, emodule] : aSchematic.
modules )
661 for(
const auto& [
name, epart] : emodule->parts )
669 wxString libName = elibrary->name;
673 wxString tmp = *elibrary->urn;
675 libName += tmp.AfterLast(
'/' );
679 elib->
name = libName;
695 size_t sheetCount = aSchematic.
sheets.size();
703 for(
const std::unique_ptr<ESHEET>& esheet : aSchematic.
sheets )
710 std::unique_ptr<SCH_SHEET> sheet = std::make_unique<SCH_SHEET>(
m_rootSheet, pos );
712 sheet->SetScreen( screen );
715 wxCHECK2( sheet && screen,
continue );
717 wxString pageNo = wxString::Format( wxT(
"%d" ),
m_sheetIndex );
727 wxCHECK2( currentScreen,
continue );
729 currentScreen->
Append( sheet.release() );
744 for(
const std::unique_ptr<ESHEET>& esheet : aSchematic.
sheets )
756 int maxY = sheetBbox.
GetY();
763 const SCH_SYMBOL* origSymbol = cmp.second.cmp;
765 for(
auto& unitEntry : cmp.second.units )
767 if( unitEntry.second ==
false )
771 int unit = unitEntry.first;
775 symbol->SetUnitSelection( &sheetpath, unit );
776 symbol->SetUnit( unit );
777 symbol->SetOrientation( 0 );
778 symbol->AddHierarchicalReference( sheetpath.
Path(), reference, unit );
781 BOX2I cmpBbox = symbol->GetBoundingBox();
782 int posY = newCmpPosition.
y + cmpBbox.
GetHeight();
783 symbol->SetPosition(
VECTOR2I( newCmpPosition.
x, posY ) );
785 maxY = std::max( maxY, posY );
787 if( newCmpPosition.
x >= pageSizeIU.
x )
805 wxCHECK( sheet && screen, );
809 std::string filename;
818 replace( filename.begin(), filename.end(),
' ',
'_' );
820 fn.SetName( filename );
830 for(
const std::unique_ptr<EPOLYGON>& epoly : aSheet->plain->polygons )
833 for(
const std::unique_ptr<EWIRE>& ewire : aSheet->plain->wires )
839 for(
const std::unique_ptr<ETEXT>& etext : aSheet->plain->texts )
842 for(
const std::unique_ptr<ECIRCLE>& ecircle : aSheet->plain->circles )
845 for(
const std::unique_ptr<ERECT>& erectangle : aSheet->plain->rectangles )
848 for(
const std::unique_ptr<EFRAME>& eframe : aSheet->plain->frames )
850 std::vector<SCH_ITEM*> frameItems;
861 for(
const auto& [
name, moduleinst] : aSheet->moduleinsts )
864 screen->
Append( modSheet );
867 for(
const std::unique_ptr<EINSTANCE>& einstance : aSheet->instances )
879 for(
const std::unique_ptr<EBUS>& ebus : aSheet->busses )
888 for(
const std::unique_ptr<ENET>& enet : aSheet->nets )
891 wxString netName = enet->netname;
892 wxString netClass = wxString::Format( wxS(
"%i" ), enet->netcode );
911 if( pageSizeIU.
x < targetSheetSize.
x )
914 if( pageSizeIU.
y < targetSheetSize.
y )
921 VECTOR2I sheetcentre( pageSizeIU.
x / 2, pageSizeIU.
y / 2 );
925 VECTOR2I translation = sheetcentre - itemsCentre;
939 std::vector<SCH_ITEM*> allItems;
941 std::copy( screen->
Items().
begin(), screen->
Items().
end(), std::back_inserter( allItems ) );
945 item->SetPosition( item->GetPosition() + translation );
950 label->AutoplaceFields( screen,
false );
963 wxCHECK( currentSheet &¤tScreen,
nullptr );
969 auto it =
m_eagleDoc->drawing->schematic->modules.find( aModuleInstance->moduleinst );
972 if( it ==
m_eagleDoc->drawing->schematic->modules.end() )
974 THROW_IO_ERROR( wxString::Format(
_(
"No module instance '%s' found in schematic "
976 aModuleInstance->name,
m_filename.GetFullPath() ) );
981 fn.SetName( aModuleInstance->name );
985 VECTOR2I size( it->second->dx.ToSchUnits(), it->second->dy.ToSchUnits() );
987 int halfX =
KiROUND( size.
x / 2.0 );
988 int halfY =
KiROUND( size.
y / 2.0 );
990 VECTOR2I pos( aModuleInstance->x.ToSchUnits() - halfX,
991 -aModuleInstance->y.ToSchUnits() - halfY );
993 std::unique_ptr<SCH_SHEET> newSheet = std::make_unique<SCH_SHEET>( currentSheet, pos, size );
997 wxCHECK( newSheet && newScreen,
nullptr );
999 newSheet->SetScreen( newScreen );
1000 newSheet->SetFileName( fn.GetFullName() );
1001 newSheet->SetName( aModuleInstance->name );
1004 for(
const auto& [portName, port] : it->second->ports )
1007 int pinOffset = port->coord.ToSchUnits();
1010 if( port->side ==
"left" )
1012 side = SHEET_SIDE::LEFT;
1014 pinPos.
y = pos.
y + halfY - pinOffset;
1015 portExtWireEndpoint = pinPos;
1016 portExtWireEndpoint.
x -= portExtWireLength;
1018 else if( port->side ==
"right" )
1020 side = SHEET_SIDE::RIGHT;
1021 pinPos.
x = pos.
x + size.
x;
1022 pinPos.
y = pos.
y + halfY - pinOffset;
1023 portExtWireEndpoint = pinPos;
1024 portExtWireEndpoint.
x += portExtWireLength;
1026 else if( port->side ==
"top" )
1028 side = SHEET_SIDE::TOP;
1029 pinPos.
x = pos.
x + halfX + pinOffset;
1031 portExtWireEndpoint = pinPos;
1032 portExtWireEndpoint.
y -= portExtWireLength;
1034 else if( port->side ==
"bottom" )
1036 side = SHEET_SIDE::BOTTOM;
1037 pinPos.
x = pos.
x + halfX + pinOffset;
1038 pinPos.
y = pos.
y + size.
y;
1039 portExtWireEndpoint = pinPos;
1040 portExtWireEndpoint.
y += portExtWireLength;
1045 currentScreen->
Append( portExtWire );
1049 if( port->direction )
1051 if( *port->direction ==
"in" )
1052 pinType = LABEL_FLAG_SHAPE::L_INPUT;
1053 else if( *port->direction ==
"out" )
1054 pinType = LABEL_FLAG_SHAPE::L_OUTPUT;
1055 else if( *port->direction ==
"io" )
1056 pinType = LABEL_FLAG_SHAPE::L_BIDI;
1057 else if( *port->direction ==
"hiz" )
1058 pinType = LABEL_FLAG_SHAPE::L_TRISTATE;
1060 pinType = LABEL_FLAG_SHAPE::L_UNSPECIFIED;
1072 newSheet->AddPin( sheetPin );
1075 wxString pageNo = wxString::Format( wxT(
"%d" ),
m_sheetIndex );
1082 if( it->second->sheets.size() == 1 )
1084 loadSheet( it->second->sheets.at( 0 ) );
1092 for(
const std::unique_ptr<ESHEET>& esheet : it->second->sheets )
1097 std::unique_ptr<SCH_SHEET> sheet = std::make_unique<SCH_SHEET>( newSheet.get(), pos );
1099 sheet->SetScreen( screen );
1101 wxString newFileName = fn.GetName();
1103 newFileName += wxString::Format( wxS(
"_%d" ), i + 1 );
1104 fn.SetName( newFileName );
1106 sheet->SetFileName( fn.GetFullName() );
1108 wxCHECK2( sheet && screen,
continue );
1110 wxString subSheetPageNo = wxString::Format( wxT(
"%d" ),
m_sheetIndex );
1118 newScreen->
Append( sheet.release() );
1137 return newSheet.release();
1142 std::vector<SCH_ITEM*>& aItems )
1144 int xMin = aFrame->x1.ToSchUnits();
1145 int xMax = aFrame->x2.ToSchUnits();
1146 int yMin = -aFrame->y1.ToSchUnits();
1147 int yMax = -aFrame->y2.ToSchUnits();
1150 std::swap( xMin, xMax );
1153 std::swap( yMin, yMax );
1161 aItems.push_back( lines );
1163 if( !( aFrame->border_left ==
false ) )
1170 aItems.push_back( lines );
1173 int height = yMax - yMin;
1177 double rowSpacing = height / double( aFrame->rows );
1178 double legendPosY = yMin + ( rowSpacing / 2 );
1180 for( i = 1; i < aFrame->rows; i++ )
1182 int newY =
KiROUND( yMin + ( rowSpacing * (
double) i ) );
1186 aItems.push_back( lines );
1189 char legendChar =
'A';
1191 for( i = 0; i < aFrame->rows; i++ )
1197 legendText->
SetText( wxString( legendChar ) );
1200 aItems.push_back( legendText );
1202 legendPosY += rowSpacing;
1206 if( !( aFrame->border_right ==
false ) )
1213 aItems.push_back( lines );
1216 int height = yMax - yMin;
1220 double rowSpacing = height / double( aFrame->rows );
1221 double legendPosY = yMin + ( rowSpacing / 2 );
1223 for( i = 1; i < aFrame->rows; i++ )
1225 int newY =
KiROUND( yMin + ( rowSpacing * (
double) i ) );
1229 aItems.push_back( lines );
1232 char legendChar =
'A';
1234 for( i = 0; i < aFrame->rows; i++ )
1240 legendText->
SetText( wxString( legendChar ) );
1243 aItems.push_back( legendText );
1245 legendPosY += rowSpacing;
1249 if( !( aFrame->border_top ==
false ) )
1256 aItems.push_back( lines );
1259 int width = xMax - xMin;
1263 double columnSpacing = width / double( aFrame->columns );
1264 double legendPosX = xMin + ( columnSpacing / 2 );
1266 for( i = 1; i < aFrame->columns; i++ )
1268 int newX =
KiROUND( xMin + ( columnSpacing * (
double) i ) );
1272 aItems.push_back( lines );
1275 char legendChar =
'1';
1277 for( i = 0; i < aFrame->columns; i++ )
1283 legendText->
SetText( wxString( legendChar ) );
1286 aItems.push_back( legendText );
1288 legendPosX += columnSpacing;
1292 if( !( aFrame->border_bottom ==
false ) )
1299 aItems.push_back( lines );
1302 int width = xMax - xMin;
1306 double columnSpacing = width / double( aFrame->columns );
1307 double legendPosX = xMin + ( columnSpacing / 2 );
1309 for( i = 1; i < aFrame->columns; i++ )
1311 int newX =
KiROUND( xMin + ( columnSpacing * (
double) i ) );
1315 aItems.push_back( lines );
1318 char legendChar =
'1';
1320 for( i = 0; i < aFrame->columns; i++ )
1326 legendText->
SetText( wxString( legendChar ) );
1329 aItems.push_back( legendText );
1331 legendPosX += columnSpacing;
1338 const wxString& netName,
1339 const wxString& aNetClass )
1346 size_t segmentCount = aSegments.size();
1348 for(
const std::unique_ptr<ESEGMENT>& esegment : aSegments )
1350 bool labelled =
false;
1351 bool firstWireFound =
false;
1357 for(
const std::unique_ptr<EWIRE>& ewire : esegment->wires )
1366 if( !firstWireFound )
1368 firstWire = thisWire;
1369 firstWireFound =
true;
1375 if( !desc.labels.empty() && desc.labels.front()->GetText() == netName )
1378 for(
const SEG& seg : desc.segs )
1387 segDesc.
segs.push_back( thisWire );
1391 for(
const std::unique_ptr<EJUNCTION>& ejunction : esegment->junctions )
1394 for(
const std::unique_ptr<ELABEL>& elabel : esegment->labels )
1399 wxASSERT( segDesc.
labels.empty()
1402 segDesc.
labels.push_back( label );
1406 for(
const std::unique_ptr<EPINREF>& epinref : esegment->pinRefs )
1408 wxString part = epinref->part;
1409 wxString
pin = epinref->pin;
1411 auto powerPort =
m_powerPorts.find( wxT(
"#" ) + part );
1423 if( !labelled && firstWireFound )
1425 std::unique_ptr<SCH_LABEL_BASE> label;
1430 else if( segmentCount > 1 )
1435 label->SetPosition( firstWire.
A );
1440 if( firstWire.
B.
x > firstWire.
A.
x )
1445 screen->
Append( label.release() );
1454 std::unique_ptr<SCH_SHAPE> poly = std::make_unique<SCH_SHAPE>( SHAPE_T::POLY );
1458 for(
const std::unique_ptr<EVERTEX>& evertex : aPolygon->vertices )
1460 pt =
VECTOR2I( evertex->x.ToSchUnits(), -evertex->y.ToSchUnits() );
1466 poly->GetPolyShape().Append( arc, -1, -1,
ARC_ACCURACY );
1470 poly->AddPoint( pt );
1474 prev_curve = evertex->curve;
1477 poly->SetLayer(
kiCadLayer( aPolygon->layer ) );
1478 poly->SetStroke(
STROKE_PARAMS( aPolygon->width.ToSchUnits(), LINE_STYLE::SOLID ) );
1479 poly->SetFillMode( FILL_T::FILLED_SHAPE );
1481 return poly.release();
1489 start.
x = aWire->x1.ToSchUnits();
1490 start.
y = -aWire->y1.ToSchUnits();
1491 end.
x = aWire->x2.ToSchUnits();
1492 end.
y = -aWire->y2.ToSchUnits();
1495 endpoints =
SEG( start, end );
1499 std::unique_ptr<SCH_SHAPE> arc = std::make_unique<SCH_SHAPE>( SHAPE_T::ARC );
1502 arc->SetCenter( center );
1503 arc->SetStart( start );
1508 arc->SetStroke(
STROKE_PARAMS( aWire->width.ToSchUnits(), LINE_STYLE::SOLID ) );
1510 return arc.release();
1514 std::unique_ptr<SCH_LINE> line = std::make_unique<SCH_LINE>();
1516 line->SetStartPoint( start );
1517 line->SetEndPoint( end );
1518 line->SetLayer(
kiCadLayer( aWire->layer ) );
1519 line->SetStroke(
STROKE_PARAMS( aWire->width.ToSchUnits(), LINE_STYLE::SOLID ) );
1521 return line.release();
1528 std::unique_ptr<SCH_SHAPE> circle = std::make_unique<SCH_SHAPE>( SHAPE_T::CIRCLE );
1529 VECTOR2I center( aCircle->x.ToSchUnits(), -aCircle->y.ToSchUnits() );
1531 circle->SetLayer(
kiCadLayer( aCircle->layer ) );
1532 circle->SetPosition( center );
1533 circle->SetEnd(
VECTOR2I( center.
x + aCircle->radius.ToSchUnits(), center.
y ) );
1534 circle->SetStroke(
STROKE_PARAMS( aCircle->width.ToSchUnits(), LINE_STYLE::SOLID ) );
1536 return circle.release();
1542 std::unique_ptr<SCH_SHAPE> rectangle = std::make_unique<SCH_SHAPE>( SHAPE_T::RECTANGLE );
1544 rectangle->SetLayer(
kiCadLayer( aRectangle->layer ) );
1545 rectangle->SetPosition(
VECTOR2I( aRectangle->x1.ToSchUnits(), -aRectangle->y1.ToSchUnits() ) );
1546 rectangle->SetEnd(
VECTOR2I( aRectangle->x2.ToSchUnits(), -aRectangle->y2.ToSchUnits() ) );
1548 if( aRectangle->rot )
1550 VECTOR2I pos( rectangle->GetPosition() );
1551 VECTOR2I end( rectangle->GetEnd() );
1552 VECTOR2I center( rectangle->GetCenter() );
1557 rectangle->SetPosition( pos );
1558 rectangle->SetEnd( end );
1562 rectangle->SetFillMode( FILL_T::FILLED_SHAPE );
1564 return rectangle.release();
1570 std::unique_ptr<SCH_JUNCTION> junction = std::make_unique<SCH_JUNCTION>();
1572 VECTOR2I pos( aJunction->x.ToSchUnits(), -aJunction->y.ToSchUnits() );
1574 junction->SetPosition( pos );
1576 return junction.release();
1581 const wxString& aNetName )
1583 VECTOR2I elabelpos( aLabel->x.ToSchUnits(), -aLabel->y.ToSchUnits() );
1588 std::unique_ptr<SCH_LABEL_BASE> label;
1591 KiROUND( aLabel->size.ToSchUnits() * 0.7 ) );
1597 label = std::make_unique<SCH_HIERLABEL>();
1604 if( it->second->direction )
1606 wxString direction = *it->second->direction;
1608 if( direction ==
"in" )
1609 type = LABEL_SHAPE::LABEL_INPUT;
1610 else if( direction ==
"out" )
1611 type = LABEL_SHAPE::LABEL_OUTPUT;
1612 else if( direction ==
"io" )
1613 type = LABEL_SHAPE::LABEL_BIDI;
1614 else if( direction ==
"hiz" )
1615 type = LABEL_SHAPE::LABEL_TRISTATE;
1617 type = LABEL_SHAPE::LABEL_PASSIVE;
1622 label->SetLabelShape( type );
1627 label = std::make_unique<SCH_LABEL>();
1633 label = std::make_unique<SCH_GLOBALLABEL>();
1638 label = std::make_unique<SCH_LABEL>();
1642 label->SetPosition( elabelpos );
1643 label->SetTextSize( textSize );
1648 for(
int i = 0; i <
KiROUND( aLabel->rot->degrees / 90 ) %4; ++i )
1649 label->Rotate90(
false );
1651 if( aLabel->rot->mirror )
1652 label->MirrorSpinStyle(
false );
1655 return label.release();
1659std::pair<VECTOR2I, const SEG*>
1661 const std::vector<SEG>& aLines )
const
1664 const SEG* nearestLine =
nullptr;
1666 float d, mindistance = std::numeric_limits<float>::max();
1669 for(
const SEG& line : aLines )
1672 d = sqrt(
abs( ( ( aPoint.
x - testpoint.
x ) ^ 2 ) + ( ( aPoint.
y - testpoint.
y ) ^ 2 ) ) );
1674 if( d < mindistance )
1677 nearestPoint = testpoint;
1678 nearestLine = &line;
1681 testpoint = line.Center();
1682 d = sqrt(
abs( ( ( aPoint.
x - testpoint.
x ) ^ 2 ) + ( ( aPoint.
y - testpoint.
y ) ^ 2 ) ) );
1684 if( d < mindistance )
1687 nearestPoint = testpoint;
1688 nearestLine = &line;
1692 d = sqrt(
abs( ( ( aPoint.
x - testpoint.
x ) ^ 2 ) + ( ( aPoint.
y - testpoint.
y ) ^ 2 ) ) );
1694 if( d < mindistance )
1697 nearestPoint = testpoint;
1698 nearestLine = &line;
1702 return std::make_pair( nearestPoint, nearestLine );
1707 const std::map<wxString, std::unique_ptr<EPART>>& aParts )
1709 wxCHECK( aInstance, );
1715 const auto partIt = aParts.find( aInstance->part );
1717 if( partIt == aParts.end() )
1719 Report( wxString::Format(
_(
"Error parsing Eagle file. Could not find '%s' "
1720 "instance but it is referenced in the schematic." ),
1727 const std::unique_ptr<EPART>& epart = partIt->second;
1729 wxString libName = epart->library;
1732 if( epart->libraryUrn )
1734 wxString tmp = *epart->libraryUrn;
1736 libName += tmp.AfterLast(
'/' );
1739 wxString gatename = epart->deviceset + wxS(
"_" ) + epart->device + wxS(
"_" ) +
1741 wxString symbolname = wxString( epart->deviceset + epart->device );
1742 symbolname.Replace( wxT(
"*" ), wxEmptyString );
1750 wxString altSymbolName = libName + wxT(
"_" ) + symbolname;
1753 wxString libIdSymbolName = altSymbolName;
1759 Report( wxString::Format( wxS(
"Eagle library '%s' not found while looking up symbol for"
1760 "deviceset '%s', device '%s', and gate '%s." ),
1761 libName, epart->deviceset, epart->device, aInstance->gate ) );
1765 const auto gateIt = libIt->second.GateToUnitMap.find( gatename );
1767 if( gateIt == libIt->second.GateToUnitMap.end() )
1769 Report( wxString::Format( wxS(
"Symbol not found for deviceset '%s', device '%s', and "
1770 "gate '%s in library '%s'." ),
1771 epart->deviceset, epart->device, aInstance->gate, libName ) );
1775 int unit = gateIt->second;
1780 auto p = elib->
package.find( kisymbolname );
1782 if( p != elib->
package.end() )
1783 package = p->second;
1785 LIB_SYMBOL* part = m_pi->LoadSymbol( getLibFileName().GetFullPath(), altSymbolName,
1786 m_properties.get() );
1790 part = m_pi->LoadSymbol( getLibFileName().GetFullPath(), kisymbolname,
1791 m_properties.get() );
1792 libIdSymbolName = kisymbolname;
1797 Report( wxString::Format(
_(
"Could not find '%s' in the imported library." ),
1803 LIB_ID libId( getLibName(), libIdSymbolName );
1804 std::unique_ptr<SCH_SYMBOL> symbol = std::make_unique<SCH_SYMBOL>();
1805 symbol->SetLibId( libId );
1806 symbol->SetUnit( unit );
1807 symbol->SetPosition(
VECTOR2I( aInstance->x.ToSchUnits(), -aInstance->y.ToSchUnits() ) );
1810 if( !package.IsEmpty() )
1812 wxString footprint = m_schematic->Prj().GetProjectName() + wxT(
":" ) + package;
1816 if( aInstance->rot )
1820 if( aInstance->rot->mirror )
1821 symbol->MirrorHorizontally( aInstance->x.ToSchUnits() );
1824 std::vector<SCH_FIELD*> partFields;
1827 for(
const SCH_FIELD* field : partFields )
1829 symbol->GetFieldById( field->GetId() )->ImportValues( *field );
1830 symbol->GetFieldById( field->GetId() )->SetTextPos( (
VECTOR2I)symbol->GetPosition()
1831 + field->GetTextPos() );
1836 wxString reference = package.IsEmpty() ?
'#' + aInstance->part : aInstance->part;
1839 if( reference.find_last_not_of( wxT(
"0123456789" ) ) == ( reference.Length()-1 ) )
1840 reference.Append( wxT(
"0" ) );
1845 if( reference.find_first_not_of( wxT(
"0123456789" ) ) != 0 )
1846 reference.Prepend( wxT(
"UNK" ) );
1850 if( aInstance->part.find_first_not_of( wxT(
"#" ) ) != 0 )
1851 reference.Prepend( wxT(
"UNK" ) );
1854 referenceField->
SetText( reference );
1857 bool userValue = m_userValue.at( libIdSymbolName );
1861 getEagleSymbolFieldAttributes( aInstance, wxS(
">NAME" ), referenceField );
1862 getEagleSymbolFieldAttributes( aInstance, wxS(
">VALUE" ), valueField );
1865 if( epart->value && !epart->value.CGet().IsEmpty() )
1867 valueField->
SetText( *epart->value );
1871 valueField->
SetText( kisymbolname );
1877 for(
const auto& [ attrName, attr ] : epart->attributes )
1880 SCH_FIELD* lastField = symbol->GetFieldById( symbol->GetFieldCount() - 1 );
1885 SCH_FIELD newField( newFieldPosition, symbol->GetFieldCount(), symbol.get() );
1890 newField.
SetText( *attr->value );
1894 symbol->AddField( newField );
1897 for(
const auto& [variantName, variant] : epart->variants )
1900 field->
SetName( wxT(
"VARIANT_" ) + variant->name );
1902 if( variant->value )
1903 field->
SetText( *variant->value );
1908 bool valueAttributeFound =
false;
1909 bool nameAttributeFound =
false;
1912 for(
auto& [
name, eattr] : aInstance->attributes )
1916 if( eattr->name.Lower() == wxT(
"name" ) )
1919 nameAttributeFound =
true;
1921 else if( eattr->name.Lower() == wxT(
"value" ) )
1924 valueAttributeFound =
true;
1928 field = symbol->FindField( eattr->name );
1938 int absdegrees = eattr->rot ? eattr->rot->degrees : 0;
1939 bool mirror = eattr->rot ? eattr->rot->mirror :
false;
1941 if( aInstance->rot && aInstance->rot->mirror )
1944 bool spin = eattr->rot ? eattr->rot->spin :
false;
1949 int rotation = aInstance->rot ? aInstance->rot->degrees : 0;
1950 int reldegrees = ( absdegrees - rotation + 360.0 );
1958 if( aInstance->smashed && aInstance->smashed.Get() )
1960 symbol->GetField(
VALUE_FIELD )->SetVisible( valueAttributeFound );
1961 symbol->GetField(
REFERENCE_FIELD )->SetVisible( nameAttributeFound );
1964 symbol->AddHierarchicalReference( m_sheetPath.Path(), reference, unit );
1970 wxCHECK( libSymbol, );
1972 symbol->SetLibSymbol(
new LIB_SYMBOL( *libSymbol ) );
1974 for(
const SCH_PIN*
pin : symbol->GetLibPins() )
1975 m_connPoints[symbol->GetPinPhysicalPosition(
pin )].emplace(
pin );
1978 m_powerPorts[ reference ] = symbol->GetField(
VALUE_FIELD )->GetText();
1980 symbol->ClearFlags();
1982 screen->
Append( symbol.release() );
1988 wxCHECK( aLibrary && aEagleLibrary,
nullptr );
1994 wxString prefix = edeviceset->prefix ? edeviceset->prefix.Get() : wxString( wxT(
"" ) );
1995 wxString deviceSetDescr;
1997 if( edeviceset->description )
2001 for(
const std::unique_ptr<EDEVICE>& edevice : edeviceset->devices )
2004 wxString symbolName = edeviceset->name + edevice->name;
2005 symbolName.Replace( wxT(
"*" ), wxEmptyString );
2006 wxASSERT( !symbolName.IsEmpty() );
2009 if( edevice->package )
2010 aEagleLibrary->
package[symbolName] = edevice->package.Get();
2013 std::unique_ptr<LIB_SYMBOL> libSymbol = std::make_unique<LIB_SYMBOL>( symbolName );
2016 int gate_count =
static_cast<int>( edeviceset->gates.size() );
2017 libSymbol->SetUnitCount( gate_count );
2018 libSymbol->LockUnits(
true );
2022 if( prefix.length() == 0 )
2030 reference->
SetText( edevice->package ? prefix :
'#' + prefix );
2033 libSymbol->GetFieldById(
VALUE_FIELD )->SetVisible(
true );
2036 bool ispower =
false;
2038 for(
const auto& [gateName, egate] : edeviceset->gates )
2040 const auto it = aLibrary->
symbols.find( egate->symbol );
2042 if( it == aLibrary->
symbols.end() )
2044 Report( wxString::Format( wxS(
"Eagle symbol '%s' not found in library '%s'." ),
2045 egate->symbol, aLibrary->
name ) );
2049 wxString gateMapName = edeviceset->name + wxS(
"_" ) + edevice->name +
2050 wxS(
"_" ) + egate->name;
2052 ispower =
loadSymbol( it->second, libSymbol, edevice, gateindex, egate->name );
2057 libSymbol->SetUnitCount( gate_count );
2059 if( gate_count == 1 && ispower )
2060 libSymbol->SetPower();
2063 if( edevice->package )
2077 wxString packageString = libName + wxT(
":" ) + aEagleLibrary->
package[symbolName];
2079 libSymbol->GetFootprintField().SetText( packageString );
2082 wxString libName = libSymbol->GetName();
2083 libSymbol->SetName( libName );
2084 libSymbol->SetDescription( deviceSetDescr );
2094 libName = aEagleLibrary->
name + wxT(
"_" ) + libName;
2096 libSymbol->SetName( libName );
2110 aEagleLibrary->
KiCadSymbols[ libName ] = std::move( libSymbol );
2114 m_userValue.emplace( std::make_pair( libName, edeviceset->uservalue ==
true ) );
2118 return aEagleLibrary;
2123 std::unique_ptr<LIB_SYMBOL>& aSymbol,
2124 const std::unique_ptr<EDEVICE>& aDevice,
int aGateNumber,
2125 const wxString& aGateName )
2127 wxCHECK( aEsymbol && aSymbol && aDevice,
false );
2129 wxString symbolName = aEsymbol->name;
2130 std::vector<SCH_ITEM*> items;
2132 bool showRefDes =
false;
2133 bool showValue =
false;
2134 bool ispower =
false;
2137 for(
const std::unique_ptr<ECIRCLE>& ecircle : aEsymbol->circles )
2140 for(
const std::unique_ptr<EPIN>& epin : aEsymbol->pins )
2142 std::unique_ptr<SCH_PIN>
pin(
loadPin( aSymbol, epin, aGateNumber ) );
2145 pin->SetType( ELECTRICAL_PINTYPE::PT_BIDI );
2147 if( epin->direction )
2151 if( epin->direction->Lower() == pinDir.first )
2153 pin->SetType( pinDir.second );
2155 if( pinDir.first == wxT(
"sup" ) )
2164 if( aDevice->connects.size() != 0 )
2166 for(
const std::unique_ptr<ECONNECT>& connect : aDevice->connects )
2168 if( connect->gate == aGateName &&
pin->GetName() == connect->pin )
2170 wxArrayString pads = wxSplit( wxString( connect->pad ),
' ' );
2172 pin->SetUnit( aGateNumber );
2175 if( pads.GetCount() > 1 )
2177 pin->SetNumberTextSize( 0 );
2180 for(
unsigned i = 0; i < pads.GetCount(); i++ )
2184 wxString padname( pads[i] );
2186 aSymbol->AddDrawItem( apin );
2195 pin->SetUnit( aGateNumber );
2196 pin->SetNumber( wxString::Format( wxT(
"%i" ), pincount ) );
2197 aSymbol->AddDrawItem(
pin.release() );
2201 for(
const std::unique_ptr<EPOLYGON>& epolygon : aEsymbol->polygons )
2204 for(
const std::unique_ptr<ERECT>& erectangle : aEsymbol->rectangles )
2207 for(
const std::unique_ptr<ETEXT>& etext : aEsymbol->texts )
2209 std::unique_ptr<SCH_TEXT> libtext(
loadSymbolText( aSymbol, etext, aGateNumber ) );
2211 if( libtext->GetText() == wxT(
"${REFERENCE}" ) )
2218 showRefDes = etext->text == wxT(
">NAME" );
2220 else if( libtext->GetText() == wxT(
"${VALUE}" ) )
2227 showValue = etext->text == wxT(
">VALUE" );
2231 aSymbol->AddDrawItem( libtext.release() );
2235 for(
const std::unique_ptr<EWIRE>& ewire : aEsymbol->wires )
2236 aSymbol->AddDrawItem(
loadSymbolWire( aSymbol, ewire, aGateNumber ) );
2238 for(
const std::unique_ptr<EFRAME>& eframe : aEsymbol->frames )
2240 std::vector<SCH_ITEM*> frameItems;
2246 item->SetParent( aSymbol.get() );
2247 item->SetUnit( aGateNumber );
2248 aSymbol->AddDrawItem( item );
2253 aSymbol->GetFieldById(
VALUE_FIELD )->SetVisible( showValue );
2255 return pincount == 1 ? ispower :
false;
2260 const std::unique_ptr<ECIRCLE>& aCircle,
2263 wxCHECK( aSymbol && aCircle,
nullptr );
2267 VECTOR2I center( aCircle->x.ToSchUnits(), -aCircle->y.ToSchUnits() );
2271 circle->
SetEnd(
VECTOR2I( center.
x + aCircle->radius.ToSchUnits(), center.
y ) );
2273 circle->
SetUnit( aGateNumber );
2280 const std::unique_ptr<ERECT>& aRectangle,
2283 wxCHECK( aSymbol && aRectangle,
nullptr );
2288 rectangle->
SetPosition(
VECTOR2I( aRectangle->x1.ToSchUnits(), -aRectangle->y1.ToSchUnits() ) );
2289 rectangle->
SetEnd(
VECTOR2I( aRectangle->x2.ToSchUnits(), -aRectangle->y2.ToSchUnits() ) );
2291 if( aRectangle->rot )
2301 rectangle->
SetEnd( end );
2304 rectangle->
SetUnit( aGateNumber );
2314 const std::unique_ptr<EWIRE>& aWire,
int aGateNumber )
2316 wxCHECK( aSymbol && aWire,
nullptr );
2320 begin.
x = aWire->x1.ToSchUnits();
2321 begin.
y = -aWire->y1.ToSchUnits();
2322 end.
x = aWire->x2.ToSchUnits();
2323 end.
y = -aWire->y2.ToSchUnits();
2333 double radius = sqrt( ( ( center.
x - begin.
x ) * ( center.
x - begin.
x ) ) +
2334 ( ( center.
y - begin.
y ) * ( center.
y - begin.
y ) ) );
2339 if( aWire->cap ==
EWIRE::FLAT && aWire->width.ToSchUnits() >= 2 * radius )
2341 VECTOR2I centerStartVector = ( begin - center ) *
2342 ( aWire->width.ToSchUnits() / radius );
2343 begin = center + centerStartVector;
2375 const std::unique_ptr<EPOLYGON>& aPolygon,
2378 wxCHECK( aSymbol && aPolygon,
nullptr );
2386 for(
const std::unique_ptr<EVERTEX>& evertex : aPolygon->vertices )
2388 pt =
VECTOR2I( evertex->x.ToSchUnits(), evertex->y.ToSchUnits() );
2402 prev_curve = evertex->curve;
2414 const std::unique_ptr<EPIN>& aPin,
int aGateNumber )
2416 wxCHECK( aSymbol && aPin,
nullptr );
2418 std::unique_ptr<SCH_PIN>
pin = std::make_unique<SCH_PIN>( aSymbol.get() );
2419 pin->SetPosition(
VECTOR2I( aPin->x.ToSchUnits(), -aPin->y.ToSchUnits() ) );
2420 pin->SetName( aPin->name );
2421 pin->SetUnit( aGateNumber );
2423 int roti = aPin->rot ? aPin->rot->degrees : 0;
2427 case 0:
pin->SetOrientation( PIN_ORIENTATION::PIN_RIGHT );
break;
2428 case 90:
pin->SetOrientation( PIN_ORIENTATION::PIN_UP );
break;
2429 case 180:
pin->SetOrientation( PIN_ORIENTATION::PIN_LEFT );
break;
2430 case 270:
pin->SetOrientation( PIN_ORIENTATION::PIN_DOWN );
break;
2431 default: wxFAIL_MSG( wxString::Format( wxT(
"Unhandled orientation (%d degrees)." ), roti ) );
2438 wxString length = aPin->length.Get();
2440 if( length == wxT(
"short" ) )
2442 else if( length == wxT(
"middle" ) )
2444 else if( length == wxT(
"long" ) )
2446 else if( length == wxT(
"point" ) )
2453 wxString visible = aPin->visible.Get();
2455 if( visible == wxT(
"off" ) )
2457 pin->SetNameTextSize( 0 );
2458 pin->SetNumberTextSize( 0 );
2460 else if( visible == wxT(
"pad" ) )
2462 pin->SetNameTextSize( 0 );
2464 else if( visible == wxT(
"pin" ) )
2466 pin->SetNumberTextSize( 0 );
2476 if( aPin->function )
2478 wxString function = aPin->function.Get();
2480 if( function == wxT(
"dot" ) )
2481 pin->SetShape( GRAPHIC_PINSHAPE::INVERTED );
2482 else if( function == wxT(
"clk" ) )
2483 pin->SetShape( GRAPHIC_PINSHAPE::CLOCK );
2484 else if( function == wxT(
"dotclk" ) )
2485 pin->SetShape( GRAPHIC_PINSHAPE::INVERTED_CLOCK );
2488 return pin.release();
2493 const std::unique_ptr<ETEXT>& aText,
int aGateNumber )
2495 wxCHECK( aSymbol && aText,
nullptr );
2497 std::unique_ptr<SCH_TEXT> libtext = std::make_unique<SCH_TEXT>();
2499 libtext->SetParent( aSymbol.get() );
2500 libtext->SetUnit( aGateNumber );
2501 libtext->SetPosition(
VECTOR2I( aText->x.ToSchUnits(), -aText->y.ToSchUnits() ) );
2503 const wxString& eagleText = aText->text;
2504 wxString adjustedText;
2505 wxStringTokenizer tokenizer( eagleText,
"\r\n" );
2508 while( tokenizer.HasMoreTokens() )
2510 wxString tmp =
interpretText( tokenizer.GetNextToken().Trim(
true ).Trim(
false ) );
2512 if( tokenizer.HasMoreTokens() )
2515 adjustedText += tmp;
2518 libtext->SetText( adjustedText.IsEmpty() ? wxString( wxS(
"~" ) ) : adjustedText );
2522 return libtext.release();
2528 wxCHECK( aText,
nullptr );
2530 std::unique_ptr<SCH_TEXT> schtext = std::make_unique<SCH_TEXT>();
2532 const wxString& eagleText = aText->text;
2533 wxString adjustedText;
2534 wxStringTokenizer tokenizer( eagleText,
"\r\n" );
2537 while( tokenizer.HasMoreTokens() )
2539 wxString tmp =
interpretText( tokenizer.GetNextToken().Trim(
true ).Trim(
false ) );
2541 if( tokenizer.HasMoreTokens() )
2544 adjustedText += tmp;
2547 schtext->SetText( adjustedText.IsEmpty() ? wxString( wxS(
"\" \"" ) )
2550 schtext->SetPosition(
VECTOR2I( aText->x.ToSchUnits(), -aText->y.ToSchUnits() ) );
2552 schtext->SetItalic(
false );
2554 return schtext.release();
2559 const std::unique_ptr<ETEXT>& aAttributes )
const
2561 wxCHECK( aText && aAttributes, );
2566 if( aAttributes->ratio && aAttributes->ratio.CGet() > 12 )
2570 int degrees = aAttributes->rot ? aAttributes->rot->degrees : 0;
2571 bool mirror = aAttributes->rot ? aAttributes->rot->mirror :
false;
2572 bool spin = aAttributes->rot ? aAttributes->rot->spin :
false;
2580 wxCHECK( aField && aText, );
2604 auto onIntersection =
2613 for(
SCH_TEXT* label : segDesc.labels )
2616 const SEG* segAttached = segDesc.LabelAttached( label );
2618 if( segAttached && !onIntersection( labelPos ) )
2632 VECTOR2I wireDirection( segAttached->
B - segAttached->
A );
2634 const VECTOR2I origPos( labelPos );
2637 bool checkPositive =
true, checkNegative =
true,
move =
false;
2641 while( ( !
move || onIntersection( labelPos ) ) && ( checkPositive || checkNegative ) )
2646 if( trial % 2 == 1 )
2648 labelPos =
VECTOR2I( origPos + wireDirection * trial / 2 );
2649 move = checkPositive = segAttached->
Contains( labelPos );
2653 labelPos =
VECTOR2I( origPos - wireDirection * trial / 2 );
2654 move = checkNegative = segAttached->
Contains( labelPos );
2690 wxFileInputStream input( aFileName );
2695 wxTextInputStream
text( input );
2697 for(
int i = 0; i < 4; i++ )
2702 if(
text.ReadLine().Contains( wxS(
"<eagle" ) ) )
2720 if( !item->IsType( { SCH_LABEL_LOCATE_ANY_T } ) )
2724 item->SetPosition( aNewEndPoint );
2737 std::vector<SCH_LINE*> buses;
2738 std::vector<SCH_LINE*> wires;
2749 buses.push_back( line );
2750 else if( line->
IsWire() )
2751 wires.push_back( line );
2756 VECTOR2I wireStart = wire->GetStartPoint();
2757 VECTOR2I wireEnd = wire->GetEndPoint();
2761 VECTOR2I busStart = bus->GetStartPoint();
2762 VECTOR2I busEnd = bus->GetEndPoint();
2765 [](
int signX,
int signY ) ->
VECTOR2I
2777 if( wireStart.
y == wireEnd.
y && busStart.
x == busEnd.
x )
2781 if( testBusHit( wireStart ) )
2785 if( wireEnd.
x < busStart.
x )
2792 VECTOR2I p = wireStart + entrySize( -1, 0 );
2794 if( testBusHit( wireStart + entrySize( 0, -1 ) ) )
2803 screen->
Append( busEntry );
2805 wire->SetStartPoint( p );
2807 else if( testBusHit( wireStart + entrySize( 0, 1 ) ) )
2816 screen->
Append( busEntry );
2818 wire->SetStartPoint( p );
2824 screen->
Append( marker );
2834 VECTOR2I p = wireStart + entrySize( 1, 0 );
2836 if( testBusHit( wireStart + entrySize( 0, -1 ) ) )
2845 screen->
Append( busEntry );
2847 wire->SetStartPoint( p );
2849 else if( testBusHit( wireStart + entrySize( 0, 1 ) ) )
2858 screen->
Append( busEntry );
2860 wire->SetStartPoint( p );
2866 screen->
Append( marker );
2872 else if( testBusHit( wireEnd ) )
2876 if( wireStart.
x < busStart.
x )
2883 VECTOR2I p = wireEnd + entrySize( -1, 0 );
2885 if( testBusHit( wireEnd + entrySize( 0, -1 ) ) )
2894 screen->
Append( busEntry );
2896 wire->SetEndPoint( p );
2898 else if( testBusHit( wireEnd + entrySize( 0, -1 ) ) )
2907 screen->
Append( busEntry );
2908 moveLabels( wire, wireEnd + entrySize( -1, 0 ) );
2909 wire->SetEndPoint( wireEnd + entrySize( -1, 0 ) );
2915 screen->
Append( marker );
2925 VECTOR2I p = wireEnd + entrySize( 1, 0 );
2927 if( testBusHit( wireEnd + entrySize( 0, -1 ) ) )
2936 screen->
Append( busEntry );
2938 wire->SetEndPoint( p );
2940 else if( testBusHit( wireEnd + entrySize( 0, 1 ) ) )
2949 screen->
Append( busEntry );
2951 wire->SetEndPoint( p );
2957 screen->
Append( marker );
2964 else if( wireStart.
x == wireEnd.
x && busStart.
y == busEnd.
y )
2968 if( testBusHit( wireStart ) )
2972 if( wireEnd.
y < busStart.
y )
2980 VECTOR2I p = wireStart + entrySize( 0, -1 );
2982 if( testBusHit( wireStart + entrySize( -1, 0 ) ) )
2992 screen->
Append( busEntry );
2994 wire->SetStartPoint( p );
2996 else if( testBusHit( wireStart + entrySize( 1, 0 ) ) )
3006 screen->
Append( busEntry );
3008 wire->SetStartPoint( p );
3014 screen->
Append( marker );
3025 VECTOR2I p = wireStart + entrySize( 0, 1 );
3027 if( testBusHit( wireStart + entrySize( -1, 0 ) ) )
3037 screen->
Append( busEntry );
3039 wire->SetStartPoint( p );
3041 else if( testBusHit( wireStart + entrySize( 1, 0 ) ) )
3051 screen->
Append( busEntry );
3053 wire->SetStartPoint( p );
3059 screen->
Append( marker );
3065 else if( testBusHit( wireEnd ) )
3069 if( wireStart.
y < busStart.
y )
3077 VECTOR2I p = wireEnd + entrySize( 0, -1 );
3079 if( testBusHit( wireEnd + entrySize( -1, 0 ) ) )
3089 screen->
Append( busEntry );
3091 wire->SetEndPoint( p );
3093 else if( testBusHit( wireEnd + entrySize( 1, 0 ) ) )
3103 screen->
Append( busEntry );
3105 wire->SetEndPoint( p );
3111 screen->
Append( marker );
3122 VECTOR2I p = wireEnd + entrySize( 0, 1 );
3124 if( testBusHit( wireEnd + entrySize( -1, 0 ) ) )
3134 screen->
Append( busEntry );
3136 wire->SetEndPoint( p );
3138 else if( testBusHit( wireEnd + entrySize( 1, 0 ) ) )
3148 screen->
Append( busEntry );
3150 wire->SetEndPoint( p );
3156 screen->
Append( marker );
3167 if( testBusHit( wireStart ) )
3169 VECTOR2I wirevector = wireStart - wireEnd;
3171 if( wirevector.
x > 0 )
3173 if( wirevector.
y > 0 )
3175 VECTOR2I p = wireStart + entrySize( -1, -1 );
3178 screen->
Append( busEntry );
3181 wire->SetStartPoint( p );
3185 VECTOR2I p = wireStart + entrySize( -1, 1 );
3188 screen->
Append( busEntry );
3191 wire->SetStartPoint( p );
3196 if( wirevector.
y > 0 )
3198 VECTOR2I p = wireStart + entrySize( 1, -1 );
3201 screen->
Append( busEntry );
3204 wire->SetStartPoint( p );
3208 VECTOR2I p = wireStart + entrySize( 1, 1 );
3211 screen->
Append( busEntry );
3214 wire->SetStartPoint( p );
3220 else if( testBusHit( wireEnd ) )
3222 VECTOR2I wirevector = wireStart - wireEnd;
3224 if( wirevector.
x > 0 )
3226 if( wirevector.
y > 0 )
3228 VECTOR2I p = wireEnd + entrySize( 1, 1 );
3231 screen->
Append( busEntry );
3234 wire->SetEndPoint( p );
3238 VECTOR2I p = wireEnd + entrySize( 1, -1 );
3241 screen->
Append( busEntry );
3244 wire->SetEndPoint( p );
3249 if( wirevector.
y > 0 )
3251 VECTOR2I p = wireEnd + entrySize( -1, 1 );
3254 screen->
Append( busEntry );
3257 wire->SetEndPoint( p );
3261 VECTOR2I p = wireEnd + entrySize( -1, -1 );
3264 screen->
Append( busEntry );
3267 wire->SetEndPoint( p );
3281 wxCHECK( aLabel,
nullptr );
3285 for(
const SEG& seg : segs )
3287 if( seg.Contains( labelPos ) )
3299 wxCHECK( aSymbol && aPin,
false );
3307 const auto& items = pointIt->second;
3309 wxCHECK( items.find( aPin ) != items.end(),
false );
3311 return items.size() > 1;
3325 int unit = aSymbol->
GetUnit();
3327 std::vector<SCH_PIN*> pins = aSymbol->
GetLibSymbolRef()->GetAllLibPins();
3328 std::set<int> missingUnits;
3333 if(
pin->GetType() == ELECTRICAL_PINTYPE::PT_POWER_IN )
3335 bool pinInUnit = !unit ||
pin->GetUnit() == unit;
3349 switch(
pin->GetOrientation() )
3352 case PIN_ORIENTATION::PIN_RIGHT:
3355 case PIN_ORIENTATION::PIN_LEFT:
3358 case PIN_ORIENTATION::PIN_UP:
3361 case PIN_ORIENTATION::PIN_DOWN:
3366 aScreen->
Append( netLabel );
3369 else if( aUpdateSet )
3374 wxASSERT(
pin->GetUnit() );
3375 missingUnits.insert(
pin->GetUnit() );
3388 entry.
cmp = aSymbol;
3389 entry.
units.emplace( unit,
false );
3394 cmpIt->second.units[unit] =
false;
3397 if( !missingUnits.empty() )
3400 entry.
cmp = aSymbol;
3403 for(
int i : missingUnits )
3405 if( entry.
units.find( i ) != entry.
units.end() )
3406 entry.
units.emplace( i,
true );
3418 wxString ret = wxT(
"{" );
3420 wxStringTokenizer tokenizer( aEagleName, wxT(
"," ) );
3422 while( tokenizer.HasMoreTokens() )
3424 wxString member = tokenizer.GetNextToken();
3431 if( member.Freq(
'!' ) % 2 > 0 )
3432 member << wxT(
"!" );
3434 ret << member << wxS(
" " );
3449 std::unique_ptr<EPART>& epart =
m_eagleDoc->drawing->schematic->parts[aInstance->part];
3451 if( !epart || epart->deviceset.IsEmpty() )
3454 std::unique_ptr<ELIBRARY>& elibrary =
m_eagleDoc->drawing->schematic->libraries[epart->library];
3459 std::unique_ptr<EDEVICE_SET>& edeviceset = elibrary->devicesets[epart->deviceset];
3464 std::unique_ptr<EGATE>& egate = edeviceset->gates[aInstance->gate];
3469 std::unique_ptr<ESYMBOL>& esymbol = elibrary->symbols[egate->symbol];
3472 return esymbol.get();
3479 const wxString& aEagleFieldName,
3482 wxCHECK( aField && !aEagleFieldName.
IsEmpty(), );
3488 for(
const std::unique_ptr<ETEXT>&
text : esymbol->
texts )
3490 if(
text->text == aEagleFieldName )
3493 VECTOR2I pos(
text->x.ToSchUnits() + aInstance->x.ToSchUnits(),
3494 -
text->y.ToSchUnits() - aInstance->y.ToSchUnits() );
3496 bool mirror =
text->rot ?
text->rot->mirror :
false;
3498 if( aInstance->rot && aInstance->rot->mirror )
3502 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()
Returns a read/write iterator that points to one past the last element in the EE_RTREE.
iterator begin()
Returns a read/write iterator that points to the first element in the EE_RTREE N.B.
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.
bool IsPower() const override
void GetFields(std::vector< SCH_FIELD * > &aList)
Return a list of fields within this symbol.
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.
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.
PROJECT & Prj() const override
Return a reference to the project this schematic is part of.
Class for a wire to bus entry.
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
VECTOR2I GetPosition() const override
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
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.
EMODULE * m_module
The current module being loaded or nullptr.
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...
SCH_SHEET * loadModuleInstance(const std::unique_ptr< EMODULEINST > &aModuleInstance)
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.
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()
Gets 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
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.
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, bool aManual) override
SCH_FIELD * GetField(MANDATORY_FIELD_T aFieldType)
Return a mandatory field in this symbol.
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
VECTOR2I GetPinPhysicalPosition(const SCH_PIN *Pin) const
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)
Interprets special characters in Eagle text and converts them to KiCAD notation.
wxString interpretText(const wxString &aText)
Translates Eagle special text reference to a KiCad variable reference.
size_t GetNodeCount(const wxXmlNode *aNode)
Fetch the number of XML nodes within aNode.
VECTOR2I ConvertArcCenter(const VECTOR2I &aStart, const VECTOR2I &aEnd, double aAngle)
wxString convertDescription(wxString aDescr)
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
tris 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.
SYMBOL_ORIENTATION_T
enum used in RotationMiroir()
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
std::map< wxString, std::unique_ptr< ESYMBOL > > symbols
std::map< wxString, std::unique_ptr< EPART > > parts
std::map< wxString, std::unique_ptr< EPORT > > ports
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
@ FOOTPRINT_FIELD
Field Name Module PCB, i.e. "16DIP300".
@ VALUE_FIELD
Field Value of part, i.e. "3.3K".
@ REFERENCE_FIELD
Field Reference of part, i.e. "IC21".
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.