LTspice import: fixes for graphical items.

This commit is contained in:
Alex Shvartzkop 2023-07-11 16:03:24 +05:00
parent a5ba9ccce2
commit 0bc546fa62
2 changed files with 21 additions and 15 deletions

View File

@ -588,8 +588,10 @@ void LTSPICE_SCH_PARSER::CreatePin( LTSPICE_SCHEMATIC::LT_ASC& aAscfile, int aIn
} }
} }
SCH_HIERLABEL* sheetPin = new SCH_HIERLABEL( ToKicadCoords( iopin.Location ) + m_originOffset, SCH_HIERLABEL* sheetPin =
ioPinName, SCH_HIER_LABEL_T ); new SCH_HIERLABEL( ToKicadCoords( iopin.Location ), ioPinName, SCH_HIER_LABEL_T );
sheetPin->Move( m_originOffset );
sheetPin->SetShape( getLabelShape( iopin.Polarity ) ); sheetPin->SetShape( getLabelShape( iopin.Polarity ) );
aSheet->LastScreen()->Append( sheetPin ); aSheet->LastScreen()->Append( sheetPin );
@ -600,13 +602,13 @@ void LTSPICE_SCH_PARSER::CreateLine( LTSPICE_SCHEMATIC::LT_ASC& aAscfile, int aI
SCH_SHEET_PATH* aSheet ) SCH_SHEET_PATH* aSheet )
{ {
LTSPICE_SCHEMATIC::LINE& lt_line = aAscfile.Lines[aIndex]; LTSPICE_SCHEMATIC::LINE& lt_line = aAscfile.Lines[aIndex];
SCH_SHAPE* shape = new SCH_SHAPE( SHAPE_T::POLY ); SCH_LINE* line = new SCH_LINE( ToKicadCoords( lt_line.Start ), SCH_LAYER_ID::LAYER_NOTES );
shape->AddPoint( ToInvertedKicadCoords( lt_line.End ) + m_originOffset ); line->SetEndPoint( ToKicadCoords( lt_line.End ) );
shape->AddPoint( ToInvertedKicadCoords( lt_line.Start ) + m_originOffset ); line->SetStroke( getStroke( lt_line.LineWidth, lt_line.LineStyle ) );
shape->SetStroke( getStroke( lt_line.LineWidth, lt_line.LineStyle ) ); line->Move( m_originOffset );
aSheet->LastScreen()->Append( shape ); aSheet->LastScreen()->Append( line );
} }
@ -619,9 +621,10 @@ void LTSPICE_SCH_PARSER::CreateCircle( LTSPICE_SCHEMATIC::LT_ASC& aAscfile, int
VECTOR2I c = ( lt_circle.TopLeft + lt_circle.BotRight ) / 2; VECTOR2I c = ( lt_circle.TopLeft + lt_circle.BotRight ) / 2;
int r = ( lt_circle.TopLeft.x - lt_circle.BotRight.x ) / 2; int r = ( lt_circle.TopLeft.x - lt_circle.BotRight.x ) / 2;
circle->SetPosition( ToInvertedKicadCoords( c ) ); circle->SetPosition( ToKicadCoords( c ) );
circle->SetEnd( ToInvertedKicadCoords( c ) + VECTOR2I( abs( ToKicadCoords( r ) ), 0 ) ); circle->SetEnd( ToKicadCoords( c ) + VECTOR2I( abs( ToKicadCoords( r ) ), 0 ) );
circle->SetStroke( getStroke( lt_circle.LineWidth, lt_circle.LineStyle ) ); circle->SetStroke( getStroke( lt_circle.LineWidth, lt_circle.LineStyle ) );
circle->Move( m_originOffset );
aSheet->LastScreen()->Append( circle ); aSheet->LastScreen()->Append( circle );
} }
@ -633,10 +636,11 @@ void LTSPICE_SCH_PARSER::CreateArc( LTSPICE_SCHEMATIC::LT_ASC& aAscfile, int aIn
LTSPICE_SCHEMATIC::ARC& lt_arc = aAscfile.Arcs[aIndex]; LTSPICE_SCHEMATIC::ARC& lt_arc = aAscfile.Arcs[aIndex];
SCH_SHAPE* arc = new SCH_SHAPE( SHAPE_T::ARC ); SCH_SHAPE* arc = new SCH_SHAPE( SHAPE_T::ARC );
arc->SetCenter( ToInvertedKicadCoords( ( lt_arc.TopLeft + lt_arc.BotRight ) / 2 ) ); arc->SetCenter( ToKicadCoords( ( lt_arc.TopLeft + lt_arc.BotRight ) / 2 ) );
arc->SetEnd( ToInvertedKicadCoords( lt_arc.ArcEnd ) ); arc->SetEnd( ToKicadCoords( lt_arc.ArcEnd ) );
arc->SetStart( ToInvertedKicadCoords( lt_arc.ArcStart ) ); arc->SetStart( ToKicadCoords( lt_arc.ArcStart ) );
arc->SetStroke( getStroke( lt_arc.LineWidth, lt_arc.LineStyle ) ); arc->SetStroke( getStroke( lt_arc.LineWidth, lt_arc.LineStyle ) );
arc->Move( m_originOffset );
aSheet->LastScreen()->Append( arc ); aSheet->LastScreen()->Append( arc );
} }
@ -648,9 +652,10 @@ void LTSPICE_SCH_PARSER::CreateRect( LTSPICE_SCHEMATIC::LT_ASC& aAscfile, int aI
LTSPICE_SCHEMATIC::RECTANGLE& lt_rect = aAscfile.Rectangles[aIndex]; LTSPICE_SCHEMATIC::RECTANGLE& lt_rect = aAscfile.Rectangles[aIndex];
SCH_SHAPE* rectangle = new SCH_SHAPE( SHAPE_T::RECT ); SCH_SHAPE* rectangle = new SCH_SHAPE( SHAPE_T::RECT );
rectangle->SetPosition( ToInvertedKicadCoords( lt_rect.BotRight ) ); rectangle->SetPosition( ToKicadCoords( lt_rect.TopLeft ) );
rectangle->SetEnd( ToInvertedKicadCoords( lt_rect.TopLeft ) ); rectangle->SetEnd( ToKicadCoords( lt_rect.BotRight ) );
rectangle->SetStroke( getStroke( lt_rect.LineWidth, lt_rect.LineStyle ) ); rectangle->SetStroke( getStroke( lt_rect.LineWidth, lt_rect.LineStyle ) );
rectangle->Move( m_originOffset );
aSheet->LastScreen()->Append( rectangle ); aSheet->LastScreen()->Append( rectangle );
} }

View File

@ -353,9 +353,10 @@ LTSPICE_SCHEMATIC::LINESTYLE LTSPICE_SCHEMATIC::getLineStyle( int aValue )
lineStyleMap[1] = LINESTYLE::DASH; lineStyleMap[1] = LINESTYLE::DASH;
lineStyleMap[2] = LINESTYLE::DOT; lineStyleMap[2] = LINESTYLE::DOT;
lineStyleMap[3] = LINESTYLE::DASHDOT; lineStyleMap[3] = LINESTYLE::DASHDOT;
lineStyleMap[4] = LINESTYLE::DASHDOTDOT;
if( lineStyleMap.find( aValue ) == lineStyleMap.end() ) if( lineStyleMap.find( aValue ) == lineStyleMap.end() )
THROW_IO_ERROR( _( "Expecting 0, 1, 2 or 3" ) ); THROW_IO_ERROR( _( "Expecting 0, 1, 2, 3 or 4" ) );
return lineStyleMap[ aValue ]; return lineStyleMap[ aValue ];
} }