Some fixes for legacy schematic/symbol import after symbol Y inversion.

This commit is contained in:
Alex Shvartzkop 2024-05-08 15:57:54 +03:00
parent 546b2e3b91
commit d22d32697f
2 changed files with 30 additions and 30 deletions

View File

@ -1445,7 +1445,7 @@ SCH_SYMBOL* SCH_IO_KICAD_LEGACY::loadSymbol( LINE_READER& aReader )
if( transform.x1 < -1 || transform.x1 > 1 ) if( transform.x1 < -1 || transform.x1 > 1 )
SCH_PARSE_ERROR( "invalid symbol X1 transform value", aReader, line ); SCH_PARSE_ERROR( "invalid symbol X1 transform value", aReader, line );
transform.y1 = parseInt( aReader, line, &line ); transform.y1 = -parseInt( aReader, line, &line );
if( transform.y1 < -1 || transform.y1 > 1 ) if( transform.y1 < -1 || transform.y1 > 1 )
SCH_PARSE_ERROR( "invalid symbol Y1 transform value", aReader, line ); SCH_PARSE_ERROR( "invalid symbol Y1 transform value", aReader, line );
@ -1455,7 +1455,7 @@ SCH_SYMBOL* SCH_IO_KICAD_LEGACY::loadSymbol( LINE_READER& aReader )
if( transform.x2 < -1 || transform.x2 > 1 ) if( transform.x2 < -1 || transform.x2 > 1 )
SCH_PARSE_ERROR( "invalid symbol X2 transform value", aReader, line ); SCH_PARSE_ERROR( "invalid symbol X2 transform value", aReader, line );
transform.y2 = parseInt( aReader, line, &line ); transform.y2 = -parseInt( aReader, line, &line );
if( transform.y2 < -1 || transform.y2 > 1 ) if( transform.y2 < -1 || transform.y2 > 1 )
SCH_PARSE_ERROR( "invalid symbol Y2 transform value", aReader, line ); SCH_PARSE_ERROR( "invalid symbol Y2 transform value", aReader, line );

View File

@ -584,7 +584,7 @@ void SCH_IO_KICAD_LEGACY_LIB_CACHE::loadField( std::unique_ptr<LIB_SYMBOL>& aSym
VECTOR2I pos; VECTOR2I pos;
pos.x = schIUScale.MilsToIU( parseInt( aReader, line, &line ) ); pos.x = schIUScale.MilsToIU( parseInt( aReader, line, &line ) );
pos.y = schIUScale.MilsToIU( parseInt( aReader, line, &line ) ); pos.y = -schIUScale.MilsToIU( parseInt( aReader, line, &line ) );
field->SetPosition( pos ); field->SetPosition( pos );
VECTOR2I textSize; VECTOR2I textSize;
@ -848,7 +848,7 @@ SCH_SHAPE* SCH_IO_KICAD_LEGACY_LIB_CACHE::loadArc( LINE_READER& aReader )
VECTOR2I center; VECTOR2I center;
center.x = schIUScale.MilsToIU( parseInt( aReader, line, &line ) ); center.x = schIUScale.MilsToIU( parseInt( aReader, line, &line ) );
center.y = schIUScale.MilsToIU( parseInt( aReader, line, &line ) ); center.y = -schIUScale.MilsToIU( parseInt( aReader, line, &line ) );
arc->SetPosition( center ); arc->SetPosition( center );
@ -878,9 +878,9 @@ SCH_SHAPE* SCH_IO_KICAD_LEGACY_LIB_CACHE::loadArc( LINE_READER& aReader )
VECTOR2I arcStart, arcEnd; VECTOR2I arcStart, arcEnd;
arcStart.x = schIUScale.MilsToIU( parseInt( aReader, line, &line ) ); arcStart.x = schIUScale.MilsToIU( parseInt( aReader, line, &line ) );
arcStart.y = schIUScale.MilsToIU( parseInt( aReader, line, &line ) ); arcStart.y = -schIUScale.MilsToIU( parseInt( aReader, line, &line ) );
arcEnd.x = schIUScale.MilsToIU( parseInt( aReader, line, &line ) ); arcEnd.x = schIUScale.MilsToIU( parseInt( aReader, line, &line ) );
arcEnd.y = schIUScale.MilsToIU( parseInt( aReader, line, &line ) ); arcEnd.y = -schIUScale.MilsToIU( parseInt( aReader, line, &line ) );
arc->SetStart( arcStart ); arc->SetStart( arcStart );
arc->SetEnd( arcEnd ); arc->SetEnd( arcEnd );
@ -929,7 +929,7 @@ SCH_SHAPE* SCH_IO_KICAD_LEGACY_LIB_CACHE::loadCircle( LINE_READER& aReader )
VECTOR2I center; VECTOR2I center;
center.x = schIUScale.MilsToIU( parseInt( aReader, line, &line ) ); center.x = schIUScale.MilsToIU( parseInt( aReader, line, &line ) );
center.y = schIUScale.MilsToIU( parseInt( aReader, line, &line ) ); center.y = -schIUScale.MilsToIU( parseInt( aReader, line, &line ) );
int radius = schIUScale.MilsToIU( parseInt( aReader, line, &line ) ); int radius = schIUScale.MilsToIU( parseInt( aReader, line, &line ) );
@ -968,7 +968,7 @@ SCH_TEXT* SCH_IO_KICAD_LEGACY_LIB_CACHE::loadText( LINE_READER& aReader,
angleInTenths = parseInt( aReader, line, &line ); angleInTenths = parseInt( aReader, line, &line );
center.x = schIUScale.MilsToIU( parseInt( aReader, line, &line ) ); center.x = schIUScale.MilsToIU( parseInt( aReader, line, &line ) );
center.y = schIUScale.MilsToIU( parseInt( aReader, line, &line ) ); center.y = -schIUScale.MilsToIU( parseInt( aReader, line, &line ) );
size.x = size.y = schIUScale.MilsToIU( parseInt( aReader, line, &line ) ); size.x = size.y = schIUScale.MilsToIU( parseInt( aReader, line, &line ) );
visible = !parseInt( aReader, line, &line ); visible = !parseInt( aReader, line, &line );
unit = parseInt( aReader, line, &line ); unit = parseInt( aReader, line, &line );
@ -1059,13 +1059,13 @@ SCH_SHAPE* SCH_IO_KICAD_LEGACY_LIB_CACHE::loadRect( LINE_READER& aReader )
VECTOR2I pos; VECTOR2I pos;
pos.x = schIUScale.MilsToIU( parseInt( aReader, line, &line ) ); pos.x = schIUScale.MilsToIU( parseInt( aReader, line, &line ) );
pos.y = schIUScale.MilsToIU( parseInt( aReader, line, &line ) ); pos.y = -schIUScale.MilsToIU( parseInt( aReader, line, &line ) );
rectangle->SetPosition( pos ); rectangle->SetPosition( pos );
VECTOR2I end; VECTOR2I end;
end.x = schIUScale.MilsToIU( parseInt( aReader, line, &line ) ); end.x = schIUScale.MilsToIU( parseInt( aReader, line, &line ) );
end.y = schIUScale.MilsToIU( parseInt( aReader, line, &line ) ); end.y = -schIUScale.MilsToIU( parseInt( aReader, line, &line ) );
rectangle->SetEnd( end ); rectangle->SetEnd( end );
rectangle->SetUnit( parseInt( aReader, line, &line ) ); rectangle->SetUnit( parseInt( aReader, line, &line ) );
@ -1133,7 +1133,7 @@ SCH_PIN* SCH_IO_KICAD_LEGACY_LIB_CACHE::loadPin( std::unique_ptr<LIB_SYMBOL>& aS
} }
pos += tmp.size() + 1; pos += tmp.size() + 1;
position.y = schIUScale.MilsToIU( (int) num ); position.y = -schIUScale.MilsToIU( (int) num );
tmp = tokens.GetNextToken(); tmp = tokens.GetNextToken();
@ -1332,7 +1332,7 @@ SCH_SHAPE* SCH_IO_KICAD_LEGACY_LIB_CACHE::loadPolyLine( LINE_READER& aReader )
for( int i = 0; i < points; i++ ) for( int i = 0; i < points; i++ )
{ {
pt.x = schIUScale.MilsToIU( parseInt( aReader, line, &line ) ); pt.x = schIUScale.MilsToIU( parseInt( aReader, line, &line ) );
pt.y = schIUScale.MilsToIU( parseInt( aReader, line, &line ) ); pt.y = -schIUScale.MilsToIU( parseInt( aReader, line, &line ) );
polyLine->AddPoint( pt ); polyLine->AddPoint( pt );
} }
@ -1366,19 +1366,19 @@ SCH_SHAPE* SCH_IO_KICAD_LEGACY_LIB_CACHE::loadBezier( LINE_READER& aReader )
VECTOR2I pt; VECTOR2I pt;
pt.x = schIUScale.MilsToIU( parseInt( aReader, line, &line ) ); pt.x = schIUScale.MilsToIU( parseInt( aReader, line, &line ) );
pt.y = schIUScale.MilsToIU( parseInt( aReader, line, &line ) ); pt.y = -schIUScale.MilsToIU( parseInt( aReader, line, &line ) );
bezier->SetStart( pt ); bezier->SetStart( pt );
pt.x = schIUScale.MilsToIU( parseInt( aReader, line, &line ) ); pt.x = schIUScale.MilsToIU( parseInt( aReader, line, &line ) );
pt.y = schIUScale.MilsToIU( parseInt( aReader, line, &line ) ); pt.y = -schIUScale.MilsToIU( parseInt( aReader, line, &line ) );
bezier->SetBezierC1( pt ); bezier->SetBezierC1( pt );
pt.x = schIUScale.MilsToIU( parseInt( aReader, line, &line ) ); pt.x = schIUScale.MilsToIU( parseInt( aReader, line, &line ) );
pt.y = schIUScale.MilsToIU( parseInt( aReader, line, &line ) ); pt.y = -schIUScale.MilsToIU( parseInt( aReader, line, &line ) );
bezier->SetBezierC2( pt ); bezier->SetBezierC2( pt );
pt.x = schIUScale.MilsToIU( parseInt( aReader, line, &line ) ); pt.x = schIUScale.MilsToIU( parseInt( aReader, line, &line ) );
pt.y = schIUScale.MilsToIU( parseInt( aReader, line, &line ) ); pt.y = -schIUScale.MilsToIU( parseInt( aReader, line, &line ) );
bezier->SetEnd( pt ); bezier->SetEnd( pt );
bezier->RebuildBezierToSegmentsPointsList( bezier->GetWidth() ); bezier->RebuildBezierToSegmentsPointsList( bezier->GetWidth() );
@ -1629,7 +1629,7 @@ void SCH_IO_KICAD_LEGACY_LIB_CACHE::saveArc( SCH_SHAPE* aArc, OUTPUTFORMATTER& a
aFormatter.Print( 0, "A %d %d %d %d %d %d %d %d %c %d %d %d %d\n", aFormatter.Print( 0, "A %d %d %d %d %d %d %d %d %c %d %d %d %d\n",
schIUScale.IUToMils( aArc->GetPosition().x ), schIUScale.IUToMils( aArc->GetPosition().x ),
schIUScale.IUToMils( aArc->GetPosition().y ), schIUScale.IUToMils( -aArc->GetPosition().y ),
schIUScale.IUToMils( aArc->GetRadius() ), schIUScale.IUToMils( aArc->GetRadius() ),
startAngle.AsTenthsOfADegree(), startAngle.AsTenthsOfADegree(),
endAngle.AsTenthsOfADegree(), endAngle.AsTenthsOfADegree(),
@ -1638,9 +1638,9 @@ void SCH_IO_KICAD_LEGACY_LIB_CACHE::saveArc( SCH_SHAPE* aArc, OUTPUTFORMATTER& a
schIUScale.IUToMils( aArc->GetWidth() ), schIUScale.IUToMils( aArc->GetWidth() ),
fill_tab[ static_cast<int>( aArc->GetFillMode() ) - 1 ], fill_tab[ static_cast<int>( aArc->GetFillMode() ) - 1 ],
schIUScale.IUToMils( aArc->GetStart().x ), schIUScale.IUToMils( aArc->GetStart().x ),
schIUScale.IUToMils( aArc->GetStart().y ), schIUScale.IUToMils( -aArc->GetStart().y ),
schIUScale.IUToMils( aArc->GetEnd().x ), schIUScale.IUToMils( aArc->GetEnd().x ),
schIUScale.IUToMils( aArc->GetEnd().y ) ); schIUScale.IUToMils( -aArc->GetEnd().y ) );
} }
@ -1655,13 +1655,13 @@ void SCH_IO_KICAD_LEGACY_LIB_CACHE::saveBezier( SCH_SHAPE* aBezier, OUTPUTFORMAT
aFormatter.Print( 0, " %d %d %d %d %d %d %d %d", aFormatter.Print( 0, " %d %d %d %d %d %d %d %d",
schIUScale.IUToMils( aBezier->GetStart().x ), schIUScale.IUToMils( aBezier->GetStart().x ),
schIUScale.IUToMils( aBezier->GetStart().y ), schIUScale.IUToMils( -aBezier->GetStart().y ),
schIUScale.IUToMils( aBezier->GetBezierC1().x ), schIUScale.IUToMils( aBezier->GetBezierC1().x ),
schIUScale.IUToMils( aBezier->GetBezierC1().y ), schIUScale.IUToMils( -aBezier->GetBezierC1().y ),
schIUScale.IUToMils( aBezier->GetBezierC2().x ), schIUScale.IUToMils( aBezier->GetBezierC2().x ),
schIUScale.IUToMils( aBezier->GetBezierC2().y ), schIUScale.IUToMils( -aBezier->GetBezierC2().y ),
schIUScale.IUToMils( aBezier->GetEnd().x ), schIUScale.IUToMils( aBezier->GetEnd().x ),
schIUScale.IUToMils( aBezier->GetEnd().y ) ); schIUScale.IUToMils( -aBezier->GetEnd().y ) );
aFormatter.Print( 0, " %c\n", fill_tab[ static_cast<int>( aBezier->GetFillMode() ) - 1 ] ); aFormatter.Print( 0, " %c\n", fill_tab[ static_cast<int>( aBezier->GetFillMode() ) - 1 ] );
} }
@ -1673,7 +1673,7 @@ void SCH_IO_KICAD_LEGACY_LIB_CACHE::saveCircle( SCH_SHAPE* aCircle, OUTPUTFORMAT
aFormatter.Print( 0, "C %d %d %d %d %d %d %c\n", aFormatter.Print( 0, "C %d %d %d %d %d %d %c\n",
schIUScale.IUToMils( aCircle->GetPosition().x ), schIUScale.IUToMils( aCircle->GetPosition().x ),
schIUScale.IUToMils( aCircle->GetPosition().y ), schIUScale.IUToMils( -aCircle->GetPosition().y ),
schIUScale.IUToMils( aCircle->GetRadius() ), schIUScale.IUToMils( aCircle->GetRadius() ),
aCircle->GetUnit(), aCircle->GetUnit(),
aCircle->GetBodyStyle(), aCircle->GetBodyStyle(),
@ -1709,7 +1709,7 @@ void SCH_IO_KICAD_LEGACY_LIB_CACHE::saveField( const SCH_FIELD* aField,
id, id,
EscapedUTF8( text ).c_str(), // wraps in quotes EscapedUTF8( text ).c_str(), // wraps in quotes
schIUScale.IUToMils( aField->GetTextPos().x ), schIUScale.IUToMils( aField->GetTextPos().x ),
schIUScale.IUToMils( aField->GetTextPos().y ), schIUScale.IUToMils( -aField->GetTextPos().y ),
schIUScale.IUToMils( aField->GetTextWidth() ), schIUScale.IUToMils( aField->GetTextWidth() ),
aField->GetTextAngle().IsHorizontal() ? 'H' : 'V', aField->GetTextAngle().IsHorizontal() ? 'H' : 'V',
aField->IsVisible() ? 'V' : 'I', aField->IsVisible() ? 'V' : 'I',
@ -1761,7 +1761,7 @@ void SCH_IO_KICAD_LEGACY_LIB_CACHE::savePin( const SCH_PIN* aPin, OUTPUTFORMATTE
aFormatter.Print( 0, " %s %d %d %d %c %d %d %d %d %c", aFormatter.Print( 0, " %s %d %d %d %c %d %d %d %d %c",
aPin->GetNumber().IsEmpty() ? "~" : TO_UTF8( aPin->GetNumber() ), aPin->GetNumber().IsEmpty() ? "~" : TO_UTF8( aPin->GetNumber() ),
schIUScale.IUToMils( aPin->GetPosition().x ), schIUScale.IUToMils( aPin->GetPosition().x ),
schIUScale.IUToMils( aPin->GetPosition().y ), schIUScale.IUToMils( -aPin->GetPosition().y ),
schIUScale.IUToMils( (int) aPin->GetLength() ), schIUScale.IUToMils( (int) aPin->GetLength() ),
(int) aPin->GetOrientation(), (int) aPin->GetOrientation(),
schIUScale.IUToMils( aPin->GetNumberTextSize() ), schIUScale.IUToMils( aPin->GetNumberTextSize() ),
@ -1808,7 +1808,7 @@ void SCH_IO_KICAD_LEGACY_LIB_CACHE::savePolyLine( SCH_SHAPE* aPolyLine,
schIUScale.IUToMils( aPolyLine->GetWidth() ) ); schIUScale.IUToMils( aPolyLine->GetWidth() ) );
for( const VECTOR2I& pt : aPolyLine->GetPolyShape().Outline( 0 ).CPoints() ) for( const VECTOR2I& pt : aPolyLine->GetPolyShape().Outline( 0 ).CPoints() )
aFormatter.Print( 0, " %d %d", schIUScale.IUToMils( pt.x ), schIUScale.IUToMils( pt.y ) ); aFormatter.Print( 0, " %d %d", schIUScale.IUToMils( pt.x ), -schIUScale.IUToMils( pt.y ) );
aFormatter.Print( 0, " %c\n", fill_tab[ static_cast<int>( aPolyLine->GetFillMode() ) - 1 ] ); aFormatter.Print( 0, " %c\n", fill_tab[ static_cast<int>( aPolyLine->GetFillMode() ) - 1 ] );
} }
@ -1822,9 +1822,9 @@ void SCH_IO_KICAD_LEGACY_LIB_CACHE::saveRectangle( SCH_SHAPE* aRectangle,
aFormatter.Print( 0, "S %d %d %d %d %d %d %d %c\n", aFormatter.Print( 0, "S %d %d %d %d %d %d %d %c\n",
schIUScale.IUToMils( aRectangle->GetPosition().x ), schIUScale.IUToMils( aRectangle->GetPosition().x ),
schIUScale.IUToMils( aRectangle->GetPosition().y ), schIUScale.IUToMils( -aRectangle->GetPosition().y ),
schIUScale.IUToMils( aRectangle->GetEnd().x ), schIUScale.IUToMils( aRectangle->GetEnd().x ),
schIUScale.IUToMils( aRectangle->GetEnd().y ), schIUScale.IUToMils( -aRectangle->GetEnd().y ),
aRectangle->GetUnit(), aRectangle->GetUnit(),
aRectangle->GetBodyStyle(), aRectangle->GetBodyStyle(),
schIUScale.IUToMils( aRectangle->GetWidth() ), schIUScale.IUToMils( aRectangle->GetWidth() ),
@ -1848,7 +1848,7 @@ void SCH_IO_KICAD_LEGACY_LIB_CACHE::saveText( const SCH_TEXT* aText, OUTPUTFORMA
aFormatter.Print( 0, "T %g %d %d %d %d %d %d %s", aFormatter.Print( 0, "T %g %d %d %d %d %d %d %s",
(double) aText->GetTextAngle().AsTenthsOfADegree(), (double) aText->GetTextAngle().AsTenthsOfADegree(),
schIUScale.IUToMils( aText->GetTextPos().x ), schIUScale.IUToMils( aText->GetTextPos().x ),
schIUScale.IUToMils( aText->GetTextPos().y ), schIUScale.IUToMils( -aText->GetTextPos().y ),
schIUScale.IUToMils( aText->GetTextWidth() ), schIUScale.IUToMils( aText->GetTextWidth() ),
!aText->IsVisible(), !aText->IsVisible(),
aText->GetUnit(), aText->GetUnit(),