Eagle schematic import: Corrected handling of plain/frame
This commit is contained in:
parent
54f67cd6f5
commit
b3d1384896
|
@ -962,12 +962,12 @@ void SCH_EAGLE_PLUGIN::loadSheet( wxXmlNode* aSheetNode, int aSheetIndex )
|
||||||
}
|
}
|
||||||
else if( nodeName == wxT( "frame" ) )
|
else if( nodeName == wxT( "frame" ) )
|
||||||
{
|
{
|
||||||
std::vector<SCH_LINE*> lines;
|
std::vector<SCH_ITEM*> frameItems;
|
||||||
|
|
||||||
loadFrame( plainNode, lines );
|
loadFrame( plainNode, frameItems );
|
||||||
|
|
||||||
for( SCH_LINE* line : lines )
|
for( SCH_ITEM* item : frameItems )
|
||||||
screen->Append( line );
|
screen->Append( item );
|
||||||
}
|
}
|
||||||
|
|
||||||
plainNode = plainNode->GetNext();
|
plainNode = plainNode->GetNext();
|
||||||
|
@ -1025,38 +1025,200 @@ void SCH_EAGLE_PLUGIN::loadSheet( wxXmlNode* aSheetNode, int aSheetIndex )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SCH_EAGLE_PLUGIN::loadFrame( wxXmlNode* aFrameNode, std::vector<SCH_LINE*>& aLines )
|
void SCH_EAGLE_PLUGIN::loadFrame( wxXmlNode* aFrameNode, std::vector<SCH_ITEM*>& aItems )
|
||||||
{
|
{
|
||||||
EFRAME eframe( aFrameNode );
|
EFRAME eframe( aFrameNode );
|
||||||
|
|
||||||
VECTOR2I corner1( eframe.x1.ToSchUnits(), -eframe.y1.ToSchUnits() );
|
int xMin = eframe.x1.ToSchUnits();
|
||||||
VECTOR2I corner3( eframe.x2.ToSchUnits(), -eframe.y2.ToSchUnits() );
|
int xMax = eframe.x2.ToSchUnits();
|
||||||
VECTOR2I corner2( corner3.x, corner1.y );
|
int yMin = -eframe.y1.ToSchUnits();
|
||||||
VECTOR2I corner4( corner1.x, corner3.y );
|
int yMax = -eframe.y2.ToSchUnits();
|
||||||
|
|
||||||
SCH_LINE* line = new SCH_LINE();
|
if( xMin > xMax )
|
||||||
line->SetLineStyle( PLOT_DASH_TYPE::SOLID );
|
std::swap( xMin, xMax );
|
||||||
line->SetStartPoint( corner1 );
|
|
||||||
line->SetEndPoint( corner2 );
|
|
||||||
aLines.push_back( line );
|
|
||||||
|
|
||||||
line = new SCH_LINE();
|
if( yMin > yMax )
|
||||||
line->SetLineStyle( PLOT_DASH_TYPE::SOLID );
|
std::swap( yMin, yMax );
|
||||||
line->SetStartPoint( corner2 );
|
|
||||||
line->SetEndPoint( corner3 );
|
|
||||||
aLines.push_back( line );
|
|
||||||
|
|
||||||
line = new SCH_LINE();
|
SCH_SHAPE* lines = new SCH_SHAPE( SHAPE_T::POLY );
|
||||||
line->SetLineStyle( PLOT_DASH_TYPE::SOLID );
|
lines->AddPoint( VECTOR2I( xMin, yMin ) );
|
||||||
line->SetStartPoint( corner3 );
|
lines->AddPoint( VECTOR2I( xMax, yMin ) );
|
||||||
line->SetEndPoint( corner4 );
|
lines->AddPoint( VECTOR2I( xMax, yMax ) );
|
||||||
aLines.push_back( line );
|
lines->AddPoint( VECTOR2I( xMin, yMax ) );
|
||||||
|
lines->AddPoint( VECTOR2I( xMin, yMin ) );
|
||||||
|
aItems.push_back( lines );
|
||||||
|
|
||||||
line = new SCH_LINE();
|
if( !( eframe.border_left == false ) )
|
||||||
line->SetLineStyle( PLOT_DASH_TYPE::SOLID );
|
{
|
||||||
line->SetStartPoint( corner4 );
|
lines = new SCH_SHAPE( SHAPE_T::POLY );
|
||||||
line->SetEndPoint( corner1 );
|
lines->AddPoint( VECTOR2I( xMin + schIUScale.MilsToIU( 150 ),
|
||||||
aLines.push_back( line );
|
yMin + schIUScale.MilsToIU( 150 ) ) );
|
||||||
|
lines->AddPoint( VECTOR2I( xMin + schIUScale.MilsToIU( 150 ),
|
||||||
|
yMax - schIUScale.MilsToIU( 150 ) ) );
|
||||||
|
aItems.push_back( lines );
|
||||||
|
|
||||||
|
int i;
|
||||||
|
int height = yMax - yMin;
|
||||||
|
int x1 = xMin;
|
||||||
|
int x2 = x1 + schIUScale.MilsToIU( 150 );
|
||||||
|
int legendPosX = xMin + schIUScale.MilsToIU( 75 );
|
||||||
|
double rowSpacing = height / double( eframe.rows );
|
||||||
|
double legendPosY = yMin + ( rowSpacing / 2 );
|
||||||
|
|
||||||
|
for( i = 1; i < eframe.rows; i++ )
|
||||||
|
{
|
||||||
|
int newY = KiROUND( yMin + ( rowSpacing * (double) i ) );
|
||||||
|
lines = new SCH_SHAPE( SHAPE_T::POLY );
|
||||||
|
lines->AddPoint( VECTOR2I( x1, newY ) );
|
||||||
|
lines->AddPoint( VECTOR2I( x2, newY ) );
|
||||||
|
aItems.push_back( lines );
|
||||||
|
}
|
||||||
|
|
||||||
|
char legendChar = 'A';
|
||||||
|
|
||||||
|
for( i = 0; i < eframe.rows; i++ )
|
||||||
|
{
|
||||||
|
SCH_TEXT* legendText = new SCH_TEXT();
|
||||||
|
legendText->SetPosition( VECTOR2I( legendPosX, KiROUND( legendPosY ) ) );
|
||||||
|
legendText->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER );
|
||||||
|
legendText->SetVertJustify( GR_TEXT_V_ALIGN_CENTER );
|
||||||
|
legendText->SetText( wxString( legendChar ) );
|
||||||
|
legendText->SetTextSize( wxSize( schIUScale.MilsToIU( 90 ),
|
||||||
|
schIUScale.MilsToIU( 100 ) ) );
|
||||||
|
aItems.push_back( legendText );
|
||||||
|
legendChar++;
|
||||||
|
legendPosY += rowSpacing;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !( eframe.border_right == false ) )
|
||||||
|
{
|
||||||
|
lines = new SCH_SHAPE( SHAPE_T::POLY );
|
||||||
|
lines->AddPoint( VECTOR2I( xMax - schIUScale.MilsToIU( 150 ),
|
||||||
|
yMin + schIUScale.MilsToIU( 150 ) ) );
|
||||||
|
lines->AddPoint( VECTOR2I( xMax - schIUScale.MilsToIU( 150 ),
|
||||||
|
yMax - schIUScale.MilsToIU( 150 ) ) );
|
||||||
|
aItems.push_back( lines );
|
||||||
|
|
||||||
|
int i;
|
||||||
|
int height = yMax - yMin;
|
||||||
|
int x1 = xMax - schIUScale.MilsToIU( 150 );
|
||||||
|
int x2 = xMax;
|
||||||
|
int legendPosX = xMax - schIUScale.MilsToIU( 75 );
|
||||||
|
double rowSpacing = height / double( eframe.rows );
|
||||||
|
double legendPosY = yMin + ( rowSpacing / 2 );
|
||||||
|
|
||||||
|
for( i = 1; i < eframe.rows; i++ )
|
||||||
|
{
|
||||||
|
int newY = KiROUND( yMin + ( rowSpacing * (double) i ) );
|
||||||
|
lines = new SCH_SHAPE( SHAPE_T::POLY );
|
||||||
|
lines->AddPoint( VECTOR2I( x1, newY ) );
|
||||||
|
lines->AddPoint( VECTOR2I( x2, newY ) );
|
||||||
|
aItems.push_back( lines );
|
||||||
|
}
|
||||||
|
|
||||||
|
char legendChar = 'A';
|
||||||
|
|
||||||
|
for( i = 0; i < eframe.rows; i++ )
|
||||||
|
{
|
||||||
|
SCH_TEXT* legendText = new SCH_TEXT();
|
||||||
|
legendText->SetPosition( VECTOR2I( legendPosX, KiROUND( legendPosY ) ) );
|
||||||
|
legendText->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER );
|
||||||
|
legendText->SetVertJustify( GR_TEXT_V_ALIGN_CENTER );
|
||||||
|
legendText->SetText( wxString( legendChar ) );
|
||||||
|
legendText->SetTextSize( wxSize( schIUScale.MilsToIU( 90 ),
|
||||||
|
schIUScale.MilsToIU( 100 ) ) );
|
||||||
|
aItems.push_back( legendText );
|
||||||
|
legendChar++;
|
||||||
|
legendPosY += rowSpacing;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !( eframe.border_top == false ) )
|
||||||
|
{
|
||||||
|
lines = new SCH_SHAPE( SHAPE_T::POLY );
|
||||||
|
lines->AddPoint( VECTOR2I( xMax - schIUScale.MilsToIU( 150 ),
|
||||||
|
yMin + schIUScale.MilsToIU( 150 ) ) );
|
||||||
|
lines->AddPoint( VECTOR2I( xMin + schIUScale.MilsToIU( 150 ),
|
||||||
|
yMin + schIUScale.MilsToIU( 150 ) ) );
|
||||||
|
aItems.push_back( lines );
|
||||||
|
|
||||||
|
int i;
|
||||||
|
int width = xMax - xMin;
|
||||||
|
int y1 = yMin;
|
||||||
|
int y2 = yMin + schIUScale.MilsToIU( 150 );
|
||||||
|
int legendPosY = yMin + schIUScale.MilsToIU( 75 );
|
||||||
|
double columnSpacing = width / double( eframe.columns );
|
||||||
|
double legendPosX = xMin + ( columnSpacing / 2 );
|
||||||
|
|
||||||
|
for( i = 1; i < eframe.columns; i++ )
|
||||||
|
{
|
||||||
|
int newX = KiROUND( xMin + ( columnSpacing * (double) i ) );
|
||||||
|
lines = new SCH_SHAPE( SHAPE_T::POLY );
|
||||||
|
lines->AddPoint( VECTOR2I( newX, y1 ) );
|
||||||
|
lines->AddPoint( VECTOR2I( newX, y2 ) );
|
||||||
|
aItems.push_back( lines );
|
||||||
|
}
|
||||||
|
|
||||||
|
char legendChar = '1';
|
||||||
|
|
||||||
|
for( i = 0; i < eframe.columns; i++ )
|
||||||
|
{
|
||||||
|
SCH_TEXT* legendText = new SCH_TEXT();
|
||||||
|
legendText->SetPosition( VECTOR2I( KiROUND( legendPosX ), legendPosY ) );
|
||||||
|
legendText->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER );
|
||||||
|
legendText->SetVertJustify( GR_TEXT_V_ALIGN_CENTER );
|
||||||
|
legendText->SetText( wxString( legendChar ) );
|
||||||
|
legendText->SetTextSize( wxSize( schIUScale.MilsToIU( 90 ),
|
||||||
|
schIUScale.MilsToIU( 100 ) ) );
|
||||||
|
aItems.push_back( legendText );
|
||||||
|
legendChar++;
|
||||||
|
legendPosX += columnSpacing;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !( eframe.border_bottom == false ) )
|
||||||
|
{
|
||||||
|
lines = new SCH_SHAPE( SHAPE_T::POLY );
|
||||||
|
lines->AddPoint( VECTOR2I( xMax - schIUScale.MilsToIU( 150 ),
|
||||||
|
yMax - schIUScale.MilsToIU( 150 ) ) );
|
||||||
|
lines->AddPoint( VECTOR2I( xMin + schIUScale.MilsToIU( 150 ),
|
||||||
|
yMax - schIUScale.MilsToIU( 150 ) ) );
|
||||||
|
aItems.push_back( lines );
|
||||||
|
|
||||||
|
int i;
|
||||||
|
int width = xMax - xMin;
|
||||||
|
int y1 = yMax - schIUScale.MilsToIU( 150 );
|
||||||
|
int y2 = yMax;
|
||||||
|
int legendPosY = yMax - schIUScale.MilsToIU( 75 );
|
||||||
|
double columnSpacing = width / double( eframe.columns );
|
||||||
|
double legendPosX = xMin + ( columnSpacing / 2 );
|
||||||
|
|
||||||
|
for( i = 1; i < eframe.columns; i++ )
|
||||||
|
{
|
||||||
|
int newX = KiROUND( xMin + ( columnSpacing * (double) i ) );
|
||||||
|
lines = new SCH_SHAPE( SHAPE_T::POLY );
|
||||||
|
lines->AddPoint( VECTOR2I( newX, y1 ) );
|
||||||
|
lines->AddPoint( VECTOR2I( newX, y2 ) );
|
||||||
|
aItems.push_back( lines );
|
||||||
|
}
|
||||||
|
|
||||||
|
char legendChar = '1';
|
||||||
|
|
||||||
|
for( i = 0; i < eframe.columns; i++ )
|
||||||
|
{
|
||||||
|
SCH_TEXT* legendText = new SCH_TEXT();
|
||||||
|
legendText->SetPosition( VECTOR2I( KiROUND( legendPosX ), legendPosY ) );
|
||||||
|
legendText->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER );
|
||||||
|
legendText->SetVertJustify( GR_TEXT_V_ALIGN_CENTER );
|
||||||
|
legendText->SetText( wxString( legendChar ) );
|
||||||
|
legendText->SetTextSize( wxSize( schIUScale.MilsToIU( 90 ),
|
||||||
|
schIUScale.MilsToIU( 100 ) ) );
|
||||||
|
aItems.push_back( legendText );
|
||||||
|
legendChar++;
|
||||||
|
legendPosX += columnSpacing;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2247,7 +2409,7 @@ void SCH_EAGLE_PLUGIN::loadFrame( wxXmlNode* aFrameNode, std::vector<LIB_ITEM*>&
|
||||||
lines->AddPoint( VECTOR2I( xMin, yMin ) );
|
lines->AddPoint( VECTOR2I( xMin, yMin ) );
|
||||||
aItems.push_back( lines );
|
aItems.push_back( lines );
|
||||||
|
|
||||||
if( !eframe.border_left )
|
if( !( eframe.border_left == false ) )
|
||||||
{
|
{
|
||||||
lines = new LIB_SHAPE( nullptr, SHAPE_T::POLY );
|
lines = new LIB_SHAPE( nullptr, SHAPE_T::POLY );
|
||||||
lines->AddPoint( VECTOR2I( xMin + schIUScale.MilsToIU( 150 ),
|
lines->AddPoint( VECTOR2I( xMin + schIUScale.MilsToIU( 150 ),
|
||||||
|
@ -2288,7 +2450,7 @@ void SCH_EAGLE_PLUGIN::loadFrame( wxXmlNode* aFrameNode, std::vector<LIB_ITEM*>&
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !eframe.border_right )
|
if( !( eframe.border_right == false ) )
|
||||||
{
|
{
|
||||||
lines = new LIB_SHAPE( nullptr, SHAPE_T::POLY );
|
lines = new LIB_SHAPE( nullptr, SHAPE_T::POLY );
|
||||||
lines->AddPoint( VECTOR2I( xMax - schIUScale.MilsToIU( 150 ),
|
lines->AddPoint( VECTOR2I( xMax - schIUScale.MilsToIU( 150 ),
|
||||||
|
@ -2329,7 +2491,7 @@ void SCH_EAGLE_PLUGIN::loadFrame( wxXmlNode* aFrameNode, std::vector<LIB_ITEM*>&
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !eframe.border_top )
|
if( !( eframe.border_top == false ) )
|
||||||
{
|
{
|
||||||
lines = new LIB_SHAPE( nullptr, SHAPE_T::POLY );
|
lines = new LIB_SHAPE( nullptr, SHAPE_T::POLY );
|
||||||
lines->AddPoint( VECTOR2I( xMax - schIUScale.MilsToIU( 150 ),
|
lines->AddPoint( VECTOR2I( xMax - schIUScale.MilsToIU( 150 ),
|
||||||
|
@ -2370,7 +2532,7 @@ void SCH_EAGLE_PLUGIN::loadFrame( wxXmlNode* aFrameNode, std::vector<LIB_ITEM*>&
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !eframe.border_bottom )
|
if( !( eframe.border_bottom == false ) )
|
||||||
{
|
{
|
||||||
lines = new LIB_SHAPE( nullptr, SHAPE_T::POLY );
|
lines = new LIB_SHAPE( nullptr, SHAPE_T::POLY );
|
||||||
lines->AddPoint( VECTOR2I( xMax - schIUScale.MilsToIU( 150 ),
|
lines->AddPoint( VECTOR2I( xMax - schIUScale.MilsToIU( 150 ),
|
||||||
|
|
|
@ -140,7 +140,7 @@ private:
|
||||||
SCH_TEXT* loadLabel( wxXmlNode* aLabelNode, const wxString& aNetName );
|
SCH_TEXT* loadLabel( wxXmlNode* aLabelNode, const wxString& aNetName );
|
||||||
SCH_JUNCTION* loadJunction( wxXmlNode* aJunction );
|
SCH_JUNCTION* loadJunction( wxXmlNode* aJunction );
|
||||||
SCH_TEXT* loadPlainText( wxXmlNode* aSchText );
|
SCH_TEXT* loadPlainText( wxXmlNode* aSchText );
|
||||||
void loadFrame( wxXmlNode* aFrameNode, std::vector<SCH_LINE*>& aLines );
|
void loadFrame( wxXmlNode* aFrameNode, std::vector<SCH_ITEM*>& aItems );
|
||||||
|
|
||||||
bool loadSymbol( wxXmlNode* aSymbolNode, std::unique_ptr<LIB_SYMBOL>& aSymbol,
|
bool loadSymbol( wxXmlNode* aSymbolNode, std::unique_ptr<LIB_SYMBOL>& aSymbol,
|
||||||
EDEVICE* aDevice, int aGateNumber, const wxString& aGateName );
|
EDEVICE* aDevice, int aGateNumber, const wxString& aGateName );
|
||||||
|
|
Loading…
Reference in New Issue