Browse Source

Respect DXF origin on graphics import if possible

We only need to adjust the DXF import box location if the graphics
imported do not fit on our drawing area

Fixes https://gitlab.com/kicad/code/kicad/-/issues/18523
pcb_db
Seth Hillbrand 10 months ago
parent
commit
d7f89c6576
  1. 17
      common/import_gfx/graphics_importer_buffer.cpp

17
common/import_gfx/graphics_importer_buffer.cpp

@ -128,16 +128,19 @@ void GRAPHICS_IMPORTER_BUFFER::ImportTo( GRAPHICS_IMPORTER& aImporter )
// in the KiCad drawing area
else if( aImporter.GetImportOffsetMM() == VECTOR2D( 0, 0 ) )
{
VECTOR2D offset = boundingBox.GetOrigin();
aImporter.SetImportOffsetMM( -offset );
if( boundingBox.GetRight() > std::numeric_limits<int>::max()
|| boundingBox.GetBottom() > std::numeric_limits<int>::max()
|| boundingBox.GetLeft() < std::numeric_limits<int>::min()
|| boundingBox.GetTop() < std::numeric_limits<int>::min() )
{
VECTOR2D offset = boundingBox.GetOrigin();
aImporter.SetImportOffsetMM( -offset );
}
}
else
{
VECTOR2D bbox_origin = boundingBox.GetOrigin();
aImporter.SetImportOffsetMM( -bbox_origin + aImporter.GetImportOffsetMM() );
double total_scale_x = aImporter.GetScale().x * aImporter.GetMillimeterToIuFactor();
double total_scale_y = aImporter.GetScale().y * aImporter.GetMillimeterToIuFactor();
double total_scale_x = aImporter.GetScale().x * aImporter.GetMillimeterToIuFactor();
double total_scale_y = aImporter.GetScale().y * aImporter.GetMillimeterToIuFactor();
double max_offset_x =
( aImporter.GetImportOffsetMM().x + boundingBox.GetRight() ) * total_scale_x;

Loading…
Cancel
Save