32#include <wx/filename.h>
33#include <wx/tokenzr.h>
34#include <wx/wfstream.h>
35#include <wx/xml/xml.h>
93static int countChildren( wxXmlNode* aCurrentNode,
const wxString& aName )
99 aCurrentNode = aCurrentNode->GetChildren();
101 while( aCurrentNode )
103 if( aCurrentNode->GetName() == aName )
107 aCurrentNode = aCurrentNode->GetNext();
120 bbox.
Merge( item->GetBoundingBox() );
129 return aPinName.BeforeFirst(
'@' );
142 wxCHECK( currentSheet,
nullptr );
181 std::vector<ELAYER> eagleLayers;
184 wxXmlNode* layerNode = aLayers->GetChildren();
188 ELAYER elayer( layerNode );
189 eagleLayers.push_back( elayer );
191 layerNode = layerNode->GetNext();
195 for(
const ELAYER& elayer : eagleLayers )
214 if( elayer.name == wxT(
"Nets" ) )
216 else if( elayer.name == wxT(
"Info" ) || elayer.name == wxT(
"Guide" ) )
218 else if( elayer.name == wxT(
"Busses" ) )
234 int roti = int( eagleDegrees );
244 wxASSERT_MSG(
false,
wxString::Format( wxT(
"Unhandled orientation (%d degrees)" ), roti ) );
252 bool aMirror,
bool aSpin,
int aAbsDegress )
254 int align = aEagleAlignment;
256 if( aRelDegress == 90 )
260 else if( aRelDegress == 180 )
262 else if( aRelDegress == 270 )
268 if( aMirror ==
true )
270 if( aAbsDegress == 90 || aAbsDegress == 270 )
281 else if( aAbsDegress == 0 || aAbsDegress == 180 )
354 m_progressReporter( nullptr ),
356 m_lastProgressCount( 0 ),
373 return wxT(
"EAGLE" );
397 const unsigned PROGRESS_DELTA = 5;
418 wxASSERT( !aFileName || aSchematic !=
nullptr );
433 wxXmlDocument xmlDocument;
434 wxFFileInputStream stream(
m_filename.GetFullPath() );
436 if( !stream.IsOk() || !xmlDocument.Load( stream ) )
443 unique_ptr<SCH_SHEET> deleter( aAppendToMe ?
nullptr :
m_rootSheet );
450 wxCHECK_MSG( aSchematic->
IsValid(),
nullptr,
451 wxT(
"Can't append to a schematic with no root!" ) );
474 wxCHECK_MSG( libTable,
nullptr, wxT(
"Could not load symbol lib table." ) );
476 m_pi.
set( SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_KICAD ) );
486 wxString libTableUri = wxT(
"${KIPRJMOD}/" ) +
getLibFileName().GetFullName();
499 libTable->
Format( &formatter, 0 );
508 wxXmlNode* currentNode = xmlDocument.GetRoot();
512 m_version = currentNode->GetAttribute( wxT(
"version" ), wxT(
"0.0" ) );
539 auto layers = drawingChildren[
"layers"];
549 auto schematic = drawingChildren[
"schematic"];
562 wxXmlNode* sheetNode =
getChildrenNodes( schematicChildren, wxT(
"sheets" ) );
574 wxString netName = netNode->GetAttribute( wxT(
"name" ) );
582 netNode = netNode->GetNext();
585 sheetNode = sheetNode->GetNext();
594 wxXmlNode* partNode =
getChildrenNodes( schematicChildren, wxT(
"parts" ) );
595 wxXmlNode* libraryNode =
getChildrenNodes( schematicChildren, wxT(
"libraries" ) );
596 wxXmlNode* sheetNode =
getChildrenNodes( schematicChildren, wxT(
"sheets" ) );
602 []( wxXmlNode* aNode ) ->
unsigned
609 aNode = aNode->GetNext();
625 wxXmlNode* devicesetNode =
getChildrenNodes( libraryChildren, wxT(
"devicesets" ) );
627 while( devicesetNode )
630 wxXmlNode* deviceNode =
getChildrenNodes( deviceSetChildren, wxT(
"devices" ) );
631 wxXmlNode* gateNode =
getChildrenNodes( deviceSetChildren, wxT(
"gates" ) );
633 m_totalCount += count_nodes( deviceNode ) * count_nodes( gateNode );
635 devicesetNode = devicesetNode->GetNext();
638 libraryNode = libraryNode->GetNext();
653 sheetNode = sheetNode->GetNext();
664 std::unique_ptr<EPART> epart = std::make_unique<EPART>( partNode );
667 m_partlist[epart->name.Upper()] = std::move( epart );
668 partNode = partNode->GetNext();
676 wxString libName = libraryNode->GetAttribute( wxT(
"name" ) );
679 elib->
name = libName;
683 libraryNode = libraryNode->GetNext();
697 int sheetCount =
countChildren( sheetNode->GetParent(), wxT(
"sheet" ) );
713 std::unique_ptr<SCH_SHEET> sheet = std::make_unique<SCH_SHEET>(
m_rootSheet, pos );
715 sheet->SetScreen( screen );
718 wxCHECK2( sheet && screen,
continue );
730 wxCHECK2( currentScreen,
continue );
732 currentScreen->
Append( sheet.release() );
734 sheetNode = sheetNode->GetNext();
752 sheetNode = sheetNode->GetNext();
764 int maxY = sheetBbox.
GetY();
771 const SCH_SYMBOL* origSymbol = cmp.second.cmp;
773 for(
auto& unitEntry : cmp.second.units )
775 if( unitEntry.second ==
false )
779 int unit = unitEntry.first;
783 symbol->SetUnitSelection( &sheetpath, unit );
784 symbol->SetUnit( unit );
785 symbol->SetOrientation( 0 );
786 symbol->AddHierarchicalReference( sheetpath.
Path(), reference, unit );
789 BOX2I cmpBbox = symbol->GetBoundingBox();
790 int posY = newCmpPosition.
y + cmpBbox.
GetHeight();
791 symbol->SetPosition(
VECTOR2I( newCmpPosition.
x, posY ) );
793 maxY = std::max( maxY, posY );
795 if( newCmpPosition.
x >= pageSizeIU.GetWidth() )
814 wxXmlNode* descriptionNode =
getChildrenNodes( sheetChildren, wxT(
"description" ) );
821 std::string filename;
825 if( descriptionNode )
827 des = descriptionNode->GetContent();
828 des.Replace( wxT(
"\n" ), wxT(
"_" ),
true );
830 filename = des.ToStdString();
835 sheetNameField.
SetText( filename );
839 replace( filename.begin(), filename.end(),
' ',
'_' );
842 fn.SetName( filename );
845 filenameField.
SetText( fn.GetFullName() );
855 wxXmlNode* instanceNode =
getChildrenNodes( sheetChildren, wxT(
"instances" ) );
857 while( instanceNode )
862 instanceNode = instanceNode->GetNext();
882 busNode = busNode->GetNext();
894 wxString netName = netNode->GetAttribute( wxT(
"name" ) );
895 wxString netClass = netNode->GetAttribute( wxT(
"class" ) );
901 netNode = netNode->GetNext();
925 wxString nodeName = plainNode->GetName();
927 if( nodeName == wxT(
"polygon" ) )
931 else if( nodeName == wxT(
"wire" ) )
936 else if( nodeName == wxT(
"text" ) )
940 else if( nodeName == wxT(
"circle" ) )
944 else if( nodeName == wxT(
"rectangle" ) )
948 else if( nodeName == wxT(
"frame" ) )
950 std::vector<SCH_ITEM*> frameItems;
958 plainNode = plainNode->GetNext();
971 if( pageSizeIU.x < targetSheetSize.
x )
974 if( pageSizeIU.y < targetSheetSize.
y )
981 VECTOR2I sheetcentre( pageSizeIU.x / 2, pageSizeIU.y / 2 );
985 VECTOR2I translation = sheetcentre - itemsCentre;
999 std::vector<SCH_ITEM*> allItems;
1001 std::copy( screen->
Items().
begin(), screen->
Items().
end(), std::back_inserter( allItems ) );
1005 item->SetPosition( item->GetPosition() + translation );
1010 label->AutoplaceFields( screen,
false );
1021 EFRAME eframe( aFrameNode );
1029 std::swap( xMin, xMax );
1032 std::swap( yMin, yMax );
1040 aItems.push_back( lines );
1049 aItems.push_back( lines );
1052 int height = yMax - yMin;
1056 double rowSpacing = height / double( eframe.
rows );
1057 double legendPosY = yMin + ( rowSpacing / 2 );
1059 for( i = 1; i < eframe.
rows; i++ )
1061 int newY =
KiROUND( yMin + ( rowSpacing * (
double) i ) );
1065 aItems.push_back( lines );
1068 char legendChar =
'A';
1070 for( i = 0; i < eframe.
rows; i++ )
1076 legendText->
SetText( wxString( legendChar ) );
1079 aItems.push_back( legendText );
1081 legendPosY += rowSpacing;
1092 aItems.push_back( lines );
1095 int height = yMax - yMin;
1099 double rowSpacing = height / double( eframe.
rows );
1100 double legendPosY = yMin + ( rowSpacing / 2 );
1102 for( i = 1; i < eframe.
rows; i++ )
1104 int newY =
KiROUND( yMin + ( rowSpacing * (
double) i ) );
1108 aItems.push_back( lines );
1111 char legendChar =
'A';
1113 for( i = 0; i < eframe.
rows; i++ )
1119 legendText->
SetText( wxString( legendChar ) );
1122 aItems.push_back( legendText );
1124 legendPosY += rowSpacing;
1135 aItems.push_back( lines );
1138 int width = xMax - xMin;
1142 double columnSpacing = width / double( eframe.
columns );
1143 double legendPosX = xMin + ( columnSpacing / 2 );
1145 for( i = 1; i < eframe.
columns; i++ )
1147 int newX =
KiROUND( xMin + ( columnSpacing * (
double) i ) );
1151 aItems.push_back( lines );
1154 char legendChar =
'1';
1156 for( i = 0; i < eframe.
columns; i++ )
1162 legendText->
SetText( wxString( legendChar ) );
1165 aItems.push_back( legendText );
1167 legendPosX += columnSpacing;
1178 aItems.push_back( lines );
1181 int width = xMax - xMin;
1185 double columnSpacing = width / double( eframe.
columns );
1186 double legendPosX = xMin + ( columnSpacing / 2 );
1188 for( i = 1; i < eframe.
columns; i++ )
1190 int newX =
KiROUND( xMin + ( columnSpacing * (
double) i ) );
1194 aItems.push_back( lines );
1197 char legendChar =
'1';
1199 for( i = 0; i < eframe.
columns; i++ )
1205 legendText->
SetText( wxString( legendChar ) );
1208 aItems.push_back( legendText );
1210 legendPosX += columnSpacing;
1217 const wxString& aNetClass )
1220 wxXmlNode* currentSegment = aSegmentsNode->GetChildren();
1225 int segmentCount =
countChildren( aSegmentsNode, wxT(
"segment" ) );
1227 while( currentSegment )
1229 bool labelled =
false;
1231 bool firstWireFound =
false;
1237 wxXmlNode* segmentAttribute = currentSegment->GetChildren();
1239 while( segmentAttribute )
1241 if( segmentAttribute->GetName() == wxT(
"wire" ) )
1250 if( !firstWireFound )
1252 firstWire = thisWire;
1253 firstWireFound =
true;
1259 if( !desc.labels.empty() && desc.labels.front()->GetText() == netName )
1262 for(
const SEG& seg : desc.segs )
1271 segDesc.
segs.push_back( thisWire );
1275 segmentAttribute = segmentAttribute->GetNext();
1278 segmentAttribute = currentSegment->GetChildren();
1280 while( segmentAttribute )
1282 wxString nodeName = segmentAttribute->GetName();
1284 if( nodeName == wxT(
"junction" ) )
1288 else if( nodeName == wxT(
"label" ) )
1292 wxASSERT( segDesc.
labels.empty()
1294 segDesc.
labels.push_back( label );
1297 else if( nodeName == wxT(
"pinref" ) )
1299 segmentAttribute->GetAttribute( wxT(
"gate" ) );
1300 wxString part = segmentAttribute->GetAttribute( wxT(
"part" ) );
1301 wxString
pin = segmentAttribute->GetAttribute( wxT(
"pin" ) );
1303 auto powerPort =
m_powerPorts.find( wxT(
"#" ) + part );
1311 else if( nodeName == wxT(
"wire" ) )
1321 segmentAttribute = segmentAttribute->GetNext();
1327 if( !labelled && firstWireFound )
1329 std::unique_ptr<SCH_TEXT> label;
1334 else if( segmentCount > 1 )
1339 label->SetPosition( firstWire.
A );
1344 if( firstWire.
B.
x > firstWire.
A.
x )
1349 screen->
Append( label.release() );
1353 currentSegment = currentSegment->GetNext();
1360 std::unique_ptr<SCH_SHAPE> poly = std::make_unique<SCH_SHAPE>(
SHAPE_T::POLY );
1362 wxXmlNode* vertex = aPolygonNode->GetChildren();
1368 if( vertex->GetName() == wxT(
"vertex" ) )
1377 poly->GetPolyShape().Append( arc, -1, -1,
ARC_ACCURACY );
1381 poly->AddPoint( pt );
1385 prev_curve = evertex.
curve;
1388 vertex = vertex->GetNext();
1395 return poly.release();
1410 endpoints =
SEG( start, end );
1414 std::unique_ptr<SCH_SHAPE> arc = std::make_unique<SCH_SHAPE>(
SHAPE_T::ARC );
1417 arc->SetCenter( center );
1418 arc->SetStart( start );
1423 return arc.release();
1427 std::unique_ptr<SCH_LINE> line = std::make_unique<SCH_LINE>();
1429 line->SetStartPoint( start );
1430 line->SetEndPoint( end );
1434 return line.release();
1441 std::unique_ptr<SCH_SHAPE> circle = std::make_unique<SCH_SHAPE>(
SHAPE_T::CIRCLE );
1446 circle->SetPosition( center );
1450 return circle.release();
1456 std::unique_ptr<SCH_SHAPE> rectangle = std::make_unique<SCH_SHAPE>(
SHAPE_T::RECT );
1457 ERECT rect( aRectNode );
1465 VECTOR2I pos( rectangle->GetPosition() );
1466 VECTOR2I end( rectangle->GetEnd() );
1467 VECTOR2I center( rectangle->GetCenter() );
1472 rectangle->SetPosition( pos );
1473 rectangle->SetEnd( end );
1479 return rectangle.release();
1485 std::unique_ptr<SCH_JUNCTION> junction = std::make_unique<SCH_JUNCTION>();
1490 junction->SetPosition( pos );
1492 return junction.release();
1504 std::unique_ptr<SCH_TEXT> label;
1510 label = std::make_unique<SCH_GLOBALLABEL>();
1512 label = std::make_unique<SCH_LABEL>();
1514 label->SetPosition( elabelpos );
1516 label->SetTextSize( textSize );
1522 label->Rotate90(
false );
1525 label->MirrorSpinStyle(
false );
1528 return label.release();
1532std::pair<VECTOR2I, const SEG*>
1534 const std::vector<SEG>& aLines )
const
1537 const SEG* nearestLine =
nullptr;
1539 float d, mindistance = std::numeric_limits<float>::max();
1542 for(
const SEG& line : aLines )
1545 d = sqrt(
abs( ( ( aPoint.
x - testpoint.
x ) ^ 2 ) + ( ( aPoint.
y - testpoint.
y ) ^ 2 ) ) );
1547 if( d < mindistance )
1550 nearestPoint = testpoint;
1551 nearestLine = &line;
1554 testpoint = line.Center();
1555 d = sqrt(
abs( ( ( aPoint.
x - testpoint.
x ) ^ 2 ) + ( ( aPoint.
y - testpoint.
y ) ^ 2 ) ) );
1557 if( d < mindistance )
1560 nearestPoint = testpoint;
1561 nearestLine = &line;
1565 d = sqrt(
abs( ( ( aPoint.
x - testpoint.
x ) ^ 2 ) + ( ( aPoint.
y - testpoint.
y ) ^ 2 ) ) );
1567 if( d < mindistance )
1570 nearestPoint = testpoint;
1571 nearestLine = &line;
1575 return std::make_pair( nearestPoint, nearestLine );
1595 "instance but it is referenced in the schematic." ),
1602 EPART* epart = part_it->second.get();
1604 wxString libraryname = epart->
library;
1607 symbolname.Replace( wxT(
"*" ), wxEmptyString );
1615 wxString altSymbolName = libraryname + wxT(
"_" ) + symbolname;
1618 wxString libIdSymbolName = altSymbolName;
1620 int unit =
m_eagleLibs[libraryname].GateUnit[gatename];
1625 auto p = elib->
package.find( kisymbolname );
1627 if( p != elib->
package.end() )
1628 package = p->second;
1637 libIdSymbolName = kisymbolname;
1649 std::unique_ptr<SCH_SYMBOL> symbol = std::make_unique<SCH_SYMBOL>();
1650 symbol->SetLibId( libId );
1651 symbol->SetUnit( unit );
1655 if( !package.IsEmpty() )
1666 symbol->MirrorHorizontally( einstance.
x.
ToSchUnits() );
1669 std::vector<LIB_FIELD*> partFields;
1672 for(
const LIB_FIELD* field : partFields )
1674 symbol->GetFieldById( field->GetId() )->ImportValues( *field );
1675 symbol->GetFieldById( field->GetId() )->SetTextPos( (
VECTOR2I)symbol->GetPosition()
1676 + field->GetTextPos() );
1681 wxString reference = package.IsEmpty() ?
'#' + einstance.
part : einstance.
part;
1684 if( reference.find_last_not_of( wxT(
"0123456789" ) ) == ( reference.Length()-1 ) )
1685 reference.Append( wxT(
"0" ) );
1690 if( reference.find_first_not_of( wxT(
"0123456789" ) ) != 0 )
1691 reference.Prepend( wxT(
"UNK" ) );
1695 if( einstance.
part.find_first_not_of( wxT(
"#" ) ) != 0 )
1696 reference.Prepend( wxT(
"UNK" ) );
1699 referenceField->
SetText( reference );
1703 bool userValue =
m_userValue.at( libIdSymbolName );
1706 if( userValue && epart->
value )
1712 valueField->
SetText( kisymbolname );
1726 for(
const auto& a : epart->
variant )
1729 field->
SetName( wxT(
"VARIANT_" ) + a.first );
1734 bool valueAttributeFound =
false;
1735 bool nameAttributeFound =
false;
1737 wxXmlNode* attributeNode = aInstanceNode->GetChildren();
1740 while( attributeNode )
1742 if( attributeNode->GetName() == wxT(
"attribute" ) )
1747 if( attr.
name.Lower() == wxT(
"name" ) )
1750 nameAttributeFound =
true;
1752 else if( attr.
name.Lower() == wxT(
"value" ) )
1755 valueAttributeFound =
true;
1759 field = symbol->FindField( attr.
name );
1776 bool spin = attr.
rot ? attr.
rot->
spin :
false;
1782 int reldegrees = ( absdegrees - rotation + 360.0 );
1789 else if( attributeNode->GetName() == wxT(
"variant" ) )
1791 wxString variantName, fieldValue;
1793 if( attributeNode->GetAttribute( wxT(
"name" ), &variantName )
1794 && attributeNode->GetAttribute( wxT(
"value" ), &fieldValue ) )
1797 field.
SetName( wxT(
"VARIANT_" ) + variantName );
1800 symbol->AddField( field );
1804 attributeNode = attributeNode->GetNext();
1810 if( !valueAttributeFound )
1811 symbol->GetField(
VALUE_FIELD )->SetVisible(
false );
1813 if( !nameAttributeFound )
1817 symbol->AddHierarchicalReference(
m_sheetPath.
Path(), reference, unit );
1823 wxCHECK( libSymbol, );
1825 symbol->SetLibSymbol(
new LIB_SYMBOL( *libSymbol ) );
1827 std::vector<LIB_PIN*> pins;
1828 symbol->GetLibPins( pins );
1836 symbol->ClearFlags();
1838 screen->
Append( symbol.release() );
1848 wxXmlNode* symbolNode =
getChildrenNodes( libraryChildren, wxT(
"symbols" ) );
1852 wxString symbolName = symbolNode->GetAttribute( wxT(
"name" ) );
1853 aEagleLibrary->
SymbolNodes[symbolName] = symbolNode;
1854 symbolNode = symbolNode->GetNext();
1858 wxXmlNode* devicesetNode =
getChildrenNodes( libraryChildren, wxT(
"devicesets" ) );
1860 while( devicesetNode )
1865 wxString prefix = edeviceset.
prefix ? edeviceset.
prefix.
Get() : wxT(
"" );
1868 wxXmlNode* deviceNode =
getChildrenNodes( deviceSetChildren, wxT(
"devices" ) );
1877 wxString symbolName = edeviceset.
name + edevice.
name;
1878 symbolName.Replace( wxT(
"*" ), wxEmptyString );
1879 wxASSERT( !symbolName.IsEmpty() );
1886 std::unique_ptr<LIB_SYMBOL> libSymbol = std::make_unique<LIB_SYMBOL>( symbolName );
1889 wxXmlNode* gateNode =
getChildrenNodes( deviceSetChildren, wxT(
"gates" ) );
1890 int gates_count =
countChildren( deviceSetChildren[
"gates"], wxT(
"gate" ) );
1891 libSymbol->SetUnitCount( gates_count );
1892 libSymbol->LockUnits(
true );
1896 if( prefix.length() == 0 )
1908 bool ispower =
false;
1918 gateindex, egate.
name );
1921 gateNode = gateNode->GetNext();
1924 libSymbol->SetUnitCount( gates_count );
1926 if( gates_count == 1 && ispower )
1927 libSymbol->SetPower();
1934 aEagleLibrary->
package[symbolName];
1935 libSymbol->GetFootprintField().SetText( packageString );
1938 wxString libName = libSymbol->GetName();
1939 libSymbol->SetName( libName );
1945 libName = aEagleLibrary->
name + wxT(
"_" ) + libName;
1947 libSymbol->SetName( libName );
1952 aEagleLibrary->
KiCadSymbols.insert( libName, libSymbol.release() );
1959 deviceNode = deviceNode->GetNext();
1962 devicesetNode = devicesetNode->GetNext();
1965 return aEagleLibrary;
1970 EDEVICE* aDevice,
int aGateNumber,
const wxString& aGateName )
1972 wxString symbolName = aSymbolNode->GetAttribute( wxT(
"name" ) );
1973 std::vector<LIB_ITEM*> items;
1975 wxXmlNode* currentNode = aSymbolNode->GetChildren();
1977 bool showRefDes =
false;
1978 bool showValue =
false;
1979 bool ispower =
false;
1982 while( currentNode )
1984 wxString nodeName = currentNode->GetName();
1986 if( nodeName == wxT(
"circle" ) )
1988 aSymbol->AddDrawItem(
loadSymbolCircle( aSymbol, currentNode, aGateNumber ) );
1990 else if( nodeName == wxT(
"pin" ) )
1993 std::unique_ptr<LIB_PIN>
pin(
loadPin( aSymbol, currentNode, &ePin, aGateNumber ) );
2002 if( ePin.
direction->Lower() == pinDir.first )
2004 pin->SetType( pinDir.second );
2006 if( pinDir.first == wxT(
"sup" ) )
2014 if( aDevice->
connects.size() != 0 )
2018 if( connect.
gate == aGateName &&
pin->GetName() == connect.
pin )
2020 wxArrayString pads = wxSplit( wxString( connect.
pad ),
' ' );
2022 pin->SetUnit( aGateNumber );
2025 if( pads.GetCount() > 1 )
2027 pin->SetNumberTextSize( 0 );
2030 for(
unsigned i = 0; i < pads.GetCount(); i++ )
2034 wxString padname( pads[i] );
2036 aSymbol->AddDrawItem( apin );
2045 pin->SetUnit( aGateNumber );
2047 aSymbol->AddDrawItem(
pin.release() );
2050 else if( nodeName == wxT(
"polygon" ) )
2054 else if( nodeName == wxT(
"rectangle" ) )
2058 else if( nodeName == wxT(
"text" ) )
2060 std::unique_ptr<LIB_TEXT> libtext(
loadSymbolText( aSymbol, currentNode, aGateNumber ) );
2062 if( libtext->GetText() == wxT(
"${REFERENCE}" ) )
2069 showRefDes = currentNode->GetNodeContent() == wxT(
">NAME" );
2071 else if( libtext->GetText() == wxT(
"${VALUE}" ) )
2078 showValue = currentNode->GetNodeContent() == wxT(
">VALUE" );
2082 aSymbol->AddDrawItem( libtext.release() );
2085 else if( nodeName == wxT(
"wire" ) )
2087 aSymbol->AddDrawItem(
loadSymbolWire( aSymbol, currentNode, aGateNumber ) );
2089 else if( nodeName == wxT(
"frame" ) )
2091 std::vector<LIB_ITEM*> frameItems;
2097 item->SetParent( aSymbol.get() );
2098 item->SetUnit( aGateNumber );
2099 aSymbol->AddDrawItem( item );
2112 currentNode = currentNode->GetNext();
2119 aSymbol->GetFieldById(
VALUE_FIELD )->SetVisible(
false );
2121 return pincount == 1 ? ispower :
false;
2126 wxXmlNode* aCircleNode,
int aGateNumber )
2136 circle->
SetUnit( aGateNumber );
2143 wxXmlNode* aRectNode,
int aGateNumber )
2145 ERECT rect( aRectNode );
2161 rectangle->
SetEnd( end );
2164 rectangle->
SetUnit( aGateNumber );
2174 wxXmlNode* aWireNode,
int aGateNumber )
2193 double radius = sqrt( ( ( center.
x - begin.
x ) * ( center.
x - begin.
x ) ) +
2194 ( ( center.
y - begin.
y ) * ( center.
y - begin.
y ) ) );
2200 begin = center + centerStartVector;
2232 wxXmlNode* aPolygonNode,
int aGateNumber )
2236 wxXmlNode* vertex = aPolygonNode->GetChildren();
2242 if( vertex->GetName() == wxT(
"vertex" ) )
2259 prev_curve = evertex.
curve;
2262 vertex = vertex->GetNext();
2274 EPIN* aEPin,
int aGateNumber )
2276 std::unique_ptr<LIB_PIN>
pin = std::make_unique<LIB_PIN>( aSymbol.get() );
2279 pin->SetUnit( aGateNumber );
2285 case 0:
pin->SetOrientation(
'R' );
break;
2286 case 90:
pin->SetOrientation(
'U' );
break;
2287 case 180:
pin->SetOrientation(
'L' );
break;
2288 case 270:
pin->SetOrientation(
'D' );
break;
2289 default: wxFAIL_MSG(
wxString::Format( wxT(
"Unhandled orientation (%d degrees)." ), roti ) );
2298 if( length == wxT(
"short" ) )
2300 else if( length == wxT(
"middle" ) )
2302 else if( length == wxT(
"long" ) )
2304 else if( length == wxT(
"point" ) )
2313 if( visible == wxT(
"off" ) )
2315 pin->SetNameTextSize( 0 );
2316 pin->SetNumberTextSize( 0 );
2318 else if( visible == wxT(
"pad" ) )
2320 pin->SetNameTextSize( 0 );
2322 else if( visible == wxT(
"pin" ) )
2324 pin->SetNumberTextSize( 0 );
2338 if( function == wxT(
"dot" ) )
2340 else if( function == wxT(
"clk" ) )
2342 else if( function == wxT(
"dotclk" ) )
2346 return pin.release();
2351 wxXmlNode* aLibText,
int aGateNumber )
2353 std::unique_ptr<LIB_TEXT> libtext = std::make_unique<LIB_TEXT>( aSymbol.get() );
2354 ETEXT etext( aLibText );
2356 libtext->SetUnit( aGateNumber );
2359 const wxString& eagleText = aLibText->GetNodeContent();
2360 wxString adjustedText;
2361 wxStringTokenizer tokenizer( eagleText,
"\r\n" );
2364 while( tokenizer.HasMoreTokens() )
2366 wxString tmp =
interpretText( tokenizer.GetNextToken().Trim(
true ).Trim(
false ) );
2368 if( tokenizer.HasMoreTokens() )
2371 adjustedText += tmp;
2374 libtext->SetText( adjustedText.IsEmpty() ? wxT(
"~" ) : adjustedText );
2377 return libtext.release();
2383 EFRAME eframe( aFrameNode );
2391 std::swap( xMin, xMax );
2394 std::swap( yMin, yMax );
2402 aItems.push_back( lines );
2411 aItems.push_back( lines );
2414 int height = yMax - yMin;
2418 double rowSpacing = height / double( eframe.
rows );
2419 double legendPosY = yMax - ( rowSpacing / 2 );
2421 for( i = 1; i < eframe.
rows; i++ )
2423 int newY =
KiROUND( yMin + ( rowSpacing * (
double) i ) );
2427 aItems.push_back( lines );
2430 char legendChar =
'A';
2432 for( i = 0; i < eframe.
rows; i++ )
2436 legendText->
SetText( wxString( legendChar ) );
2439 aItems.push_back( legendText );
2441 legendPosY -= rowSpacing;
2452 aItems.push_back( lines );
2455 int height = yMax - yMin;
2459 double rowSpacing = height / double( eframe.
rows );
2460 double legendPosY = yMax - ( rowSpacing / 2 );
2462 for( i = 1; i < eframe.
rows; i++ )
2464 int newY =
KiROUND( yMin + ( rowSpacing * (
double) i ) );
2468 aItems.push_back( lines );
2471 char legendChar =
'A';
2473 for( i = 0; i < eframe.
rows; i++ )
2477 legendText->
SetText( wxString( legendChar ) );
2480 aItems.push_back( legendText );
2482 legendPosY -= rowSpacing;
2493 aItems.push_back( lines );
2496 int width = xMax - xMin;
2500 double columnSpacing = width / double( eframe.
columns );
2501 double legendPosX = xMin + ( columnSpacing / 2 );
2503 for( i = 1; i < eframe.
columns; i++ )
2505 int newX =
KiROUND( xMin + ( columnSpacing * (
double) i ) );
2509 aItems.push_back( lines );
2512 char legendChar =
'1';
2514 for( i = 0; i < eframe.
columns; i++ )
2518 legendText->
SetText( wxString( legendChar ) );
2521 aItems.push_back( legendText );
2523 legendPosX += columnSpacing;
2534 aItems.push_back( lines );
2537 int width = xMax - xMin;
2541 double columnSpacing = width / double( eframe.
columns );
2542 double legendPosX = xMin + ( columnSpacing / 2 );
2544 for( i = 1; i < eframe.
columns; i++ )
2546 int newX =
KiROUND( xMin + ( columnSpacing * (
double) i ) );
2550 aItems.push_back( lines );
2553 char legendChar =
'1';
2555 for( i = 0; i < eframe.
columns; i++ )
2559 legendText->
SetText( wxString( legendChar ) );
2562 aItems.push_back( legendText );
2564 legendPosX += columnSpacing;
2572 std::unique_ptr<SCH_TEXT> schtext = std::make_unique<SCH_TEXT>();
2575 const wxString& eagleText = aSchText->GetNodeContent();
2576 wxString adjustedText;
2577 wxStringTokenizer tokenizer( eagleText,
"\r\n" );
2580 while( tokenizer.HasMoreTokens() )
2582 wxString tmp =
interpretText( tokenizer.GetNextToken().Trim(
true ).Trim(
false ) );
2584 if( tokenizer.HasMoreTokens() )
2587 adjustedText += tmp;
2590 schtext->SetText( adjustedText.IsEmpty() ? wxT(
"\" \"" ) :
escapeName( adjustedText ) );
2593 schtext->SetItalic(
false );
2595 return schtext.release();
2603 if( aAttribs.
ratio )
2614 bool mirror = aAttribs.
rot ? aAttribs.
rot->
mirror :
false;
2615 bool spin = aAttribs.
rot ? aAttribs.
rot->
spin :
false;
2641 auto onIntersection =
2650 for(
SCH_TEXT* label : segDesc.labels )
2653 const SEG* segAttached = segDesc.LabelAttached( label );
2655 if( segAttached && !onIntersection( labelPos ) )
2669 VECTOR2I wireDirection( segAttached->
B - segAttached->
A );
2671 const VECTOR2I origPos( labelPos );
2674 bool checkPositive =
true, checkNegative =
true,
move =
false;
2678 while( ( !
move || onIntersection( labelPos ) ) && ( checkPositive || checkNegative ) )
2683 if( trial % 2 == 1 )
2685 labelPos =
VECTOR2I( origPos + wireDirection * trial / 2 );
2686 move = checkPositive = segAttached->
Contains( labelPos );
2690 labelPos =
VECTOR2I( origPos - wireDirection * trial / 2 );
2691 move = checkNegative = segAttached->
Contains( labelPos );
2710 wxTextFile tempFile;
2712 tempFile.Open( aFileName );
2716 firstline = tempFile.GetFirstLine();
2717 wxString secondline = tempFile.GetNextLine();
2718 wxString thirdline = tempFile.GetNextLine();
2721 return firstline.StartsWith( wxT(
"<?xml" ) )
2722 && secondline.StartsWith( wxT(
"<!DOCTYPE eagle SYSTEM" ) )
2723 && thirdline.StartsWith( wxT(
"<eagle version" ) );
2735 if( !item->IsType( { SCH_LABEL_LOCATE_ANY_T } ) )
2739 item->SetPosition( aNewEndPoint );
2752 std::vector<SCH_LINE*> buses;
2753 std::vector<SCH_LINE*> wires;
2764 buses.push_back( line );
2765 else if( line->
IsWire() )
2766 wires.push_back( line );
2771 VECTOR2I wireStart = wire->GetStartPoint();
2772 VECTOR2I wireEnd = wire->GetEndPoint();
2776 VECTOR2I busStart = bus->GetStartPoint();
2777 VECTOR2I busEnd = bus->GetEndPoint();
2780 [](
int signX,
int signY ) ->
VECTOR2I
2792 if( wireStart.
y == wireEnd.
y && busStart.
x == busEnd.
x )
2796 if( testBusHit( wireStart ) )
2800 if( wireEnd.
x < busStart.
x )
2807 VECTOR2I p = wireStart + entrySize( -1, 0 );
2809 if( testBusHit( wireStart + entrySize( 0, -1 ) ) )
2818 screen->
Append( busEntry );
2820 wire->SetStartPoint( p );
2822 else if( testBusHit( wireStart + entrySize( 0, 1 ) ) )
2831 screen->
Append( busEntry );
2833 wire->SetStartPoint( p );
2839 screen->
Append( marker );
2849 VECTOR2I p = wireStart + entrySize( 1, 0 );
2851 if( testBusHit( wireStart + entrySize( 0, -1 ) ) )
2860 screen->
Append( busEntry );
2862 wire->SetStartPoint( p );
2864 else if( testBusHit( wireStart + entrySize( 0, 1 ) ) )
2873 screen->
Append( busEntry );
2875 wire->SetStartPoint( p );
2881 screen->
Append( marker );
2887 else if( testBusHit( wireEnd ) )
2891 if( wireStart.
x < busStart.
x )
2898 VECTOR2I p = wireEnd + entrySize( -1, 0 );
2900 if( testBusHit( wireEnd + entrySize( 0, -1 ) ) )
2909 screen->
Append( busEntry );
2911 wire->SetEndPoint( p );
2913 else if( testBusHit( wireEnd + entrySize( 0, -1 ) ) )
2922 screen->
Append( busEntry );
2923 moveLabels( wire, wireEnd + entrySize( -1, 0 ) );
2924 wire->SetEndPoint( wireEnd + entrySize( -1, 0 ) );
2930 screen->
Append( marker );
2940 VECTOR2I p = wireEnd + entrySize( 1, 0 );
2942 if( testBusHit( wireEnd + entrySize( 0, -1 ) ) )
2951 screen->
Append( busEntry );
2953 wire->SetEndPoint( p );
2955 else if( testBusHit( wireEnd + entrySize( 0, 1 ) ) )
2964 screen->
Append( busEntry );
2966 wire->SetEndPoint( p );
2972 screen->
Append( marker );
2979 else if( wireStart.
x == wireEnd.
x && busStart.
y == busEnd.
y )
2983 if( testBusHit( wireStart ) )
2987 if( wireEnd.
y < busStart.
y )
2995 VECTOR2I p = wireStart + entrySize( 0, -1 );
2997 if( testBusHit( wireStart + entrySize( -1, 0 ) ) )
3007 screen->
Append( busEntry );
3009 wire->SetStartPoint( p );
3011 else if( testBusHit( wireStart + entrySize( 1, 0 ) ) )
3021 screen->
Append( busEntry );
3023 wire->SetStartPoint( p );
3029 screen->
Append( marker );
3040 VECTOR2I p = wireStart + entrySize( 0, 1 );
3042 if( testBusHit( wireStart + entrySize( -1, 0 ) ) )
3052 screen->
Append( busEntry );
3054 wire->SetStartPoint( p );
3056 else if( testBusHit( wireStart + entrySize( 1, 0 ) ) )
3066 screen->
Append( busEntry );
3068 wire->SetStartPoint( p );
3074 screen->
Append( marker );
3080 else if( testBusHit( wireEnd ) )
3084 if( wireStart.
y < busStart.
y )
3092 VECTOR2I p = wireEnd + entrySize( 0, -1 );
3094 if( testBusHit( wireEnd + entrySize( -1, 0 ) ) )
3104 screen->
Append( busEntry );
3106 wire->SetEndPoint( p );
3108 else if( testBusHit( wireEnd + entrySize( 1, 0 ) ) )
3118 screen->
Append( busEntry );
3120 wire->SetEndPoint( p );
3126 screen->
Append( marker );
3137 VECTOR2I p = wireEnd + entrySize( 0, 1 );
3139 if( testBusHit( wireEnd + entrySize( -1, 0 ) ) )
3149 screen->
Append( busEntry );
3151 wire->SetEndPoint( p );
3153 else if( testBusHit( wireEnd + entrySize( 1, 0 ) ) )
3163 screen->
Append( busEntry );
3165 wire->SetEndPoint( p );
3171 screen->
Append( marker );
3182 if( testBusHit( wireStart ) )
3184 VECTOR2I wirevector = wireStart - wireEnd;
3186 if( wirevector.
x > 0 )
3188 if( wirevector.
y > 0 )
3190 VECTOR2I p = wireStart + entrySize( -1, -1 );
3193 screen->
Append( busEntry );
3196 wire->SetStartPoint( p );
3200 VECTOR2I p = wireStart + entrySize( -1, 1 );
3203 screen->
Append( busEntry );
3206 wire->SetStartPoint( p );
3211 if( wirevector.
y > 0 )
3213 VECTOR2I p = wireStart + entrySize( 1, -1 );
3216 screen->
Append( busEntry );
3219 wire->SetStartPoint( p );
3223 VECTOR2I p = wireStart + entrySize( 1, 1 );
3226 screen->
Append( busEntry );
3229 wire->SetStartPoint( p );
3235 else if( testBusHit( wireEnd ) )
3237 VECTOR2I wirevector = wireStart - wireEnd;
3239 if( wirevector.
x > 0 )
3241 if( wirevector.
y > 0 )
3243 VECTOR2I p = wireEnd + entrySize( 1, 1 );
3246 screen->
Append( busEntry );
3249 wire->SetEndPoint( p );
3253 VECTOR2I p = wireEnd + entrySize( 1, -1 );
3256 screen->
Append( busEntry );
3259 wire->SetEndPoint( p );
3264 if( wirevector.
y > 0 )
3266 VECTOR2I p = wireEnd + entrySize( -1, 1 );
3269 screen->
Append( busEntry );
3272 wire->SetEndPoint( p );
3276 VECTOR2I p = wireEnd + entrySize( -1, -1 );
3279 screen->
Append( busEntry );
3282 wire->SetEndPoint( p );
3298 for(
const SEG& seg : segs )
3300 if( seg.Contains( labelPos ) )
3312 wxCHECK( aSymbol && aPin,
false );
3320 const auto& items = pointIt->second;
3322 wxCHECK( items.find( aPin ) != items.end(),
false );
3324 return items.size() > 1;
3338 int unit = aSymbol->
GetUnit();
3340 std::vector<LIB_PIN*> pins;
3342 std::set<int> missingUnits;
3349 bool pinInUnit = !unit ||
pin->GetUnit() == unit;
3363 switch(
pin->GetOrientation() )
3371 aScreen->
Append( netLabel );
3374 else if( aUpdateSet )
3379 wxASSERT(
pin->GetUnit() );
3380 missingUnits.insert(
pin->GetUnit() );
3393 entry.
cmp = aSymbol;
3394 entry.
units.emplace( unit,
false );
3399 cmpIt->second.units[unit] =
false;
3402 if( !missingUnits.empty() )
3405 entry.
cmp = aSymbol;
3408 for(
int i : missingUnits )
3410 if( entry.
units.find( i ) != entry.
units.end() )
3411 entry.
units.emplace( i,
true );
3423 wxString ret = wxT(
"{" );
3425 wxStringTokenizer tokenizer( aEagleName, wxT(
"," ) );
3427 while( tokenizer.HasMoreTokens() )
3429 wxString member = tokenizer.GetNextToken();
3436 if( member.Freq(
'!' ) % 2 > 0 )
3437 member << wxT(
"!" );
3439 ret << member << wxS(
" " );
constexpr EDA_IU_SCALE schIUScale
coord_type GetHeight() const
coord_type GetWidth() const
coord_type GetLeft() const
const Vec & GetSize() const
coord_type GetBottom() const
BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
void SetFlags(EDA_ITEM_FLAGS aMask)
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
virtual const wxString & GetText() const
Return the string associated with the text object.
virtual bool IsVisible() const
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 SetTextThickness(int aWidth)
The TextThickness is that set by the user.
GR_TEXT_V_ALIGN_T GetVertJustify() const
void SetTextSize(const VECTOR2I &aNewSize)
virtual void SetText(const wxString &aText)
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
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.
Field object used in symbol libraries.
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 '_'.
The base class for drawable items used by schematic library symbols.
void SetPosition(const VECTOR2I &aPosition) override
void SetNumber(const wxString &aNumber)
void SetStroke(const STROKE_PARAMS &aStroke)
void AddPoint(const VECTOR2I &aPosition)
void SetPosition(const VECTOR2I &aPosition) override
VECTOR2I GetCenter() const
VECTOR2I GetPosition() const override
Define a library symbol object.
LIB_FIELD * GetFieldById(int aId) const
Return pointer to the requested field.
void GetFields(std::vector< LIB_FIELD * > &aList)
Return a list of fields within this symbol.
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.
Define a symbol library graphical text item.
VECTOR2I GetPosition() const override
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.
const T & CGet() const
Return a constant reference to the value of the attribute assuming it is available.
T & Get()
Return a reference to the value of the attribute assuming it is available.
Describe the page size and margins of a paper page on which to eventually print or plot.
void SetWidthMils(int aWidthInMils)
void SetHeightMils(int aHeightInMils)
const wxSize GetSizeIU(double aIUScale) const
Gets the page size in internal units.
virtual bool KeepRefreshing(bool aWait=false)=0
Update the UI (if any).
virtual void Report(const wxString &aMessage)=0
Display aMessage in the progress bar dialog.
virtual void SetCurrentProgress(double aProgress)=0
Set the progress value to aProgress (0..1).
virtual const wxString GetProjectPath() const
Return the full path of the project.
virtual const wxString GetProjectName() const
Return the short name of the project.
virtual void SetElem(ELEM_T aIndex, _ELEM *aElem)
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Report a string with a given severity.
Holds all the data relating to one schematic.
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.
void loadTextAttributes(EDA_TEXT *aText, const ETEXT &aAttribs) const
std::map< wxString, EAGLE_MISSING_CMP > m_missingCmps
LIB_SHAPE * loadSymbolPolyLine(std::unique_ptr< LIB_SYMBOL > &aSymbol, wxXmlNode *aPolygonNode, int aGateNumber)
SCH_TEXT * loadLabel(wxXmlNode *aLabelNode, const wxString &aNetName)
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 * m_rootSheet
The root sheet of the schematic being loaded.
LIB_ITEM * loadSymbolWire(std::unique_ptr< LIB_SYMBOL > &aSymbol, wxXmlNode *aWireNode, int aGateNumber)
const wxString GetLibraryFileExtension() const override
Return the library file extension for the SCH_PLUGIN object.
unsigned m_totalCount
for progress reporting
std::unique_ptr< STRING_UTF8_MAP > m_properties
Library plugin properties.
std::vector< SEG_DESC > m_segments
Nets as defined in the <nets> sections of an Eagle schematic file.
void loadSchematic(wxXmlNode *aSchematicNode)
SCH_SHEET * getCurrentSheet()
void countNets(wxXmlNode *aSchematicNode)
SCH_SHAPE * loadCircle(wxXmlNode *aCircleNode)
SCH_TEXT * loadPlainText(wxXmlNode *aSchText)
int GetModifyHash() const override
Return the modification hash from the library cache.
SCH_SCREEN * getCurrentScreen()
const double ARC_ACCURACY
void loadFieldAttributes(LIB_FIELD *aField, const LIB_TEXT *aText) const
Move net labels that are detached from any wire to the nearest wire.
const wxString GetName() const override
Return a brief hard coded name for this SCH_PLUGIN.
std::map< wxString, int > m_netCounts
wxString m_version
Eagle file version.
void loadInstance(wxXmlNode *aInstanceNode)
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.
std::vector< VECTOR2I > m_wireIntersections
Wires and labels of a single connection (segment in Eagle nomenclature)
void loadDrawing(wxXmlNode *aDrawingNode)
LIB_SHAPE * loadSymbolRectangle(std::unique_ptr< LIB_SYMBOL > &aSymbol, wxXmlNode *aRectNode, int aGateNumber)
SCH_JUNCTION * loadJunction(wxXmlNode *aJunction)
void loadFrame(wxXmlNode *aFrameNode, std::vector< SCH_ITEM * > &aItems)
const wxString GetFileExtension() const override
Return the file extension for the SCH_PLUGIN.
REPORTER * m_reporter
Reporter for warnings/errors.
EAGLE_LIBRARY * loadLibrary(wxXmlNode *aLibraryNode, EAGLE_LIBRARY *aEagleLib)
LIB_PIN * loadPin(std::unique_ptr< LIB_SYMBOL > &aSymbol, wxXmlNode *, EPIN *epin, int aGateNumber)
std::map< VECTOR2I, std::set< const EDA_ITEM * > > m_connPoints
wxString translateEagleBusName(const wxString &aEagleName) const
Translate an Eagle-style bus name into one that is KiCad-compatible.
bool loadSymbol(wxXmlNode *aSymbolNode, std::unique_ptr< LIB_SYMBOL > &aSymbol, EDEVICE *aDevice, int aGateNumber, const wxString &aGateName)
std::unordered_map< wxString, bool > m_userValue
deviceset/@uservalue for device.
wxString m_libName
Library name to save symbols.
wxFileName getLibFileName()
Checks if there are other wires or pins at the position of the tested pin.
void loadLayerDefs(wxXmlNode *aLayers)
LIB_SHAPE * loadSymbolCircle(std::unique_ptr< LIB_SYMBOL > &aSymbol, wxXmlNode *aCircleNode, int aGateNumber)
LIB_TEXT * loadSymbolText(std::unique_ptr< LIB_SYMBOL > &aSymbol, wxXmlNode *aLibText, int aGateNumber)
std::map< wxString, EAGLE_LIBRARY > m_eagleLibs
void addImplicitConnections(SCH_SYMBOL *aSymbol, SCH_SCREEN *aScreen, bool aUpdateSet)
Create net labels to emulate implicit connections in Eagle.
unsigned m_lastProgressCount
void loadSegments(wxXmlNode *aSegmentsNode, const wxString &aNetName, const wxString &aNetClass)
std::pair< VECTOR2I, const SEG * > findNearestLinePoint(const VECTOR2I &aPoint, const std::vector< SEG > &aLines) const
std::map< int, SCH_LAYER_ID > m_layerMap
SCH_SHEET * Load(const wxString &aFileName, SCHEMATIC *aSchematic, SCH_SHEET *aAppendToMe=nullptr, const STRING_UTF8_MAP *aProperties=nullptr) override
Load information from some input file format that this SCH_PLUGIN implementation knows about,...
SCH_SHAPE * loadRectangle(wxXmlNode *aRectNode)
SCH_LAYER_ID kiCadLayer(int aEagleLayer)
Return the matching layer or return LAYER_NOTES.
bool checkConnections(const SCH_SYMBOL *aSymbol, const LIB_PIN *aPin) const
SCH_PLUGIN::SCH_PLUGIN_RELEASER m_pi
PI to create KiCad symbol library.
void loadSheet(wxXmlNode *aSheetNode, int sheetcount)
SCHEMATIC * m_schematic
Passed to Load(), the schematic object being loaded.
PROGRESS_REPORTER * m_progressReporter
optional; may be nullptr
SCH_SHAPE * loadPolyLine(wxXmlNode *aPolygonNode)
SCH_ITEM * loadWire(wxXmlNode *aWireNode, SEG &endpoints)
bool CheckHeader(const wxString &aFileName) override
Return true if the first line in aFileName begins with the expected header.
void moveLabels(SCH_LINE *aWire, const VECTOR2I &aNewEndPoint)
Move any labels on the wire to the new end point of the wire.
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
void SetPosition(const VECTOR2I &aPosition) override
void SetName(const wxString &aName)
void SetTextSpinStyle(TEXT_SPIN_STYLE aSpinStyle) override
Set a spin or rotation angle, along with specific horizontal and vertical justification styles with e...
Base class for any item which can be embedded within the SCHEMATIC container class,...
SCH_ITEM * Duplicate(bool doClone=false) const
Routine to create a new copy of given item.
static const char * PropBuffering
The property used internally by the plugin to enable cache buffering which prevents the library file ...
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 set(SCH_PLUGIN *aPlugin)
virtual void SaveSymbol(const wxString &aLibraryPath, const LIB_SYMBOL *aSymbol, const STRING_UTF8_MAP *aProperties=nullptr)
Write aSymbol to an existing library located at aLibraryPath.
virtual void SaveLibrary(const wxString &aFileName, const STRING_UTF8_MAP *aProperties=nullptr)
virtual LIB_SYMBOL * LoadSymbol(const wxString &aLibraryPath, const wxString &aPartName, const STRING_UTF8_MAP *aProperties=nullptr)
Load a LIB_SYMBOL object having aPartName from the aLibraryPath containing a library format that this...
virtual void CreateSymbolLib(const wxString &aLibraryPath, const STRING_UTF8_MAP *aProperties=nullptr)
Create a new empty symbol library at aLibraryPath.
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 Update(SCH_ITEM *aItem)
Update aItem's bounding box in the tree.
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 Append(SCH_ITEM *aItem)
void AddPoint(const VECTOR2I &aPosition)
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.
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.
std::vector< SCH_FIELD > & GetFields()
bool LocatePathOfScreen(SCH_SCREEN *aScreen, SCH_SHEET_PATH *aList)
Search the existing hierarchy for an instance of screen loaded from aFileName.
SCH_SCREEN * GetScreen() const
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.
VECTOR2I GetPinPhysicalPosition(const LIB_PIN *Pin) const
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
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)
Add a new vertex to the contour indexed by aOutline and aHole (defaults to the outline of the last po...
A name/value tuple with unique names and optional values.
Simple container to manage line stroke parameters.
Hold a record identifying a symbol library accessed by the appropriate symbol library SCH_PLUGIN obje...
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()
#define DEFAULT_SCH_ENTRY_SIZE
The default text size in mils. (can be changed in preference menu)
NODE_MAP MapChildren(wxXmlNode *aCurrentNode)
Provide an easy access to the children of an XML node via their names.
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.
VECTOR2I ConvertArcCenter(const VECTOR2I &aStart, const VECTOR2I &aEnd, double aAngle)
static wxXmlNode * getChildrenNodes(NODE_MAP &aMap, const wxString &aName)
std::unordered_map< wxString, wxXmlNode * > NODE_MAP
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.
int GetPenSizeForBold(int aTextSize)
const std::string KiCadSymbolLibFileExtension
const std::string KiCadSchematicFileExtension
#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
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
static int countChildren(wxXmlNode *aCurrentNode, const wxString &aName)
Provide an easy access to the children of an XML node via their names.
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 '
[email protected]')
SYMBOL_ORIENTATION_T
enum used in RotationMiroir()
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
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:...
std::unordered_map< wxString, int > GateUnit
std::unordered_map< wxString, wxString > package
boost::ptr_map< wxString, LIB_SYMBOL > KiCadSymbols
std::unordered_map< wxString, wxXmlNode * > SymbolNodes
Parse an Eagle "attribute" XML element.
constexpr int IUToMils(int iu) const
constexpr int MilsToIU(int mils) const
std::vector< ECONNECT > connects
Parse an Eagle frame element.
std::map< std::string, std::string > variant
std::map< std::string, std::string > attribute
Eagle polygon, without vertices which are parsed as needed.
Eagle XML rectangle in binary.
wxSize ConvertSize() const
Calculate text size based on font type and size.
opt_double curve
range is -359.9..359.9
opt_double curve
range is -359.9..359.9
std::map< int, bool > units
Segments representing wires for intersection checking.
const SEG * LabelAttached(const SCH_TEXT *aLabel) const
< Test if a particular label is attached to any of the stored segments
std::vector< SCH_TEXT * > labels
Definition for symbol library class.
@ 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)
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition of file extensions used in Kicad.