Eeschema Eagle Import: Parse polyline symbol elements.

This commit is contained in:
Russell Oliver 2017-07-17 22:47:49 +10:00 committed by Maciej Suminski
parent 7f8ac1cf02
commit 7af2a21891
2 changed files with 17 additions and 10 deletions

View File

@ -1234,8 +1234,9 @@ void SCH_EAGLE_PLUGIN::loadSymbol( wxXmlNode* aSymbolNode,
} }
else if( nodeName == "polygon" ) else if( nodeName == "polygon" )
{ {
// loadPolygon( aPart, currentNode ); LIB_POLYLINE* libpoly = loadSymbolPolyLine( aPart, currentNode );
// aPart->AddDrawItem(); libpoly->SetUnit( gateNumber );
aPart->AddDrawItem(libpoly);
} }
else if( nodeName == "rectangle" ) else if( nodeName == "rectangle" )
{ {
@ -1350,17 +1351,23 @@ LIB_POLYLINE* SCH_EAGLE_PLUGIN::loadSymbolPolyLine( LIB_PART* aPart, wxXmlNode*
// TODO: Layer map // TODO: Layer map
std::unique_ptr<LIB_POLYLINE> polyLine( new LIB_POLYLINE( aPart ) ); std::unique_ptr<LIB_POLYLINE> polyLine( new LIB_POLYLINE( aPart ) );
NODE_MAP polygonChildren = mapChildren( aPolygonNode ); EPOLYGON epoly( aPolygonNode );
wxXmlNode* vertex = getChildrenNodes( polygonChildren, "vertex" ); wxXmlNode* vertex = aPolygonNode->GetChildren();
wxPoint pt;
while( vertex ) while( vertex )
{ {
auto evertex = EVERTEX( vertex ); if( vertex->GetName() == "vertex" ) // skip <xmlattr> node
auto v = wxPoint( evertex.x * EUNIT_TO_MIL, evertex.y * EUNIT_TO_MIL ); {
polyLine->AddPoint( v ); EVERTEX evertex( vertex );
pt = wxPoint( evertex.x * EUNIT_TO_MIL, evertex.y * EUNIT_TO_MIL );
vertex->GetNext(); polyLine->AddPoint( pt );
} }
vertex = vertex->GetNext();
}
polyLine->SetFillMode( FILLED_SHAPE );
return polyLine.release(); return polyLine.release();
} }

View File

@ -149,7 +149,7 @@ private:
void loadSymbol(wxXmlNode *aSymbolNode, LIB_PART* aPart, EDEVICE* aDevice, int gateNumber, string gateName); void loadSymbol(wxXmlNode *aSymbolNode, LIB_PART* aPart, EDEVICE* aDevice, int gateNumber, string gateName);
LIB_CIRCLE* loadSymbolCircle( LIB_PART* aPart, wxXmlNode* aCircleNode ); LIB_CIRCLE* loadSymbolCircle( LIB_PART* aPart, wxXmlNode* aCircleNode );
LIB_RECTANGLE* loadSymbolRectangle( LIB_PART* aPart, wxXmlNode* aRectNode ); LIB_RECTANGLE* loadSymbolRectangle( LIB_PART* aPart, wxXmlNode* aRectNode );
LIB_POLYLINE* loadSymbolPolyLine( LIB_PART* aPart, wxXmlNode* aRectNode ); LIB_POLYLINE* loadSymbolPolyLine( LIB_PART* aPart, wxXmlNode* aPolygonNode );
LIB_POLYLINE* loadSymbolWire( LIB_PART* aPart, wxXmlNode* aWireNode ); LIB_POLYLINE* loadSymbolWire( LIB_PART* aPart, wxXmlNode* aWireNode );
LIB_PIN* loadPin( LIB_PART*, wxXmlNode* ); LIB_PIN* loadPin( LIB_PART*, wxXmlNode* );
LIB_TEXT* loadSymboltext( LIB_PART* aPart, wxXmlNode* aLibText ); LIB_TEXT* loadSymboltext( LIB_PART* aPart, wxXmlNode* aLibText );