page layout editor: fix incorrect bitmaps bounding box size.

Bitmap size is using Eeschema units.
So the size was incorrectly calculated for pl_editor.
This commit is contained in:
jean-pierre charras 2020-01-24 11:52:41 +01:00
parent 2cd4d2440c
commit 460060a694
2 changed files with 20 additions and 4 deletions

View File

@ -393,9 +393,9 @@ const EDA_RECT WS_DRAW_ITEM_BITMAP::GetBoundingBox() const
auto* bitmap = static_cast<const WS_DATA_ITEM_BITMAP*>( m_peer );
wxSize bm_size = bitmap->m_ImageBitmap->GetSize();
// Size is in mils, convert to iu (0.001 mm)
bm_size.x *= 25.4;
bm_size.y *= 25.4;
// bm_size is in Eeschma unit (100nm), convert to iu (0.001 mm)
bm_size.x /= 10;
bm_size.y /= 10;
EDA_RECT bbox;
bbox.SetSize( bm_size );

View File

@ -316,9 +316,10 @@ void KIGFX::WS_PAINTER::draw( const WS_DRAW_ITEM_TEXT* aItem, int aLayer ) const
void KIGFX::WS_PAINTER::draw( const WS_DRAW_ITEM_BITMAP* aItem, int aLayer ) const
{
m_gal->Save();
auto* bitmap = static_cast<WS_DATA_ITEM_BITMAP*>( aItem->GetPeer() );
VECTOR2D position = aItem->GetPosition();
m_gal->Translate( position );
auto* bitmap = static_cast<WS_DATA_ITEM_BITMAP*>( aItem->GetPeer() );
// When the image scale factor is not 1.0, we need to modify the actual scale
// as the image scale factor is similar to a local zoom
@ -328,6 +329,21 @@ void KIGFX::WS_PAINTER::draw( const WS_DRAW_ITEM_BITMAP* aItem, int aLayer ) con
m_gal->Scale( VECTOR2D( img_scale, img_scale ) );
m_gal->DrawBitmap( *bitmap->m_ImageBitmap );
#if 0 // For bounding box debug purpose only
EDA_RECT bbox = aItem->GetBoundingBox();
m_gal->SetIsFill( true );
m_gal->SetIsStroke( true );
m_gal->SetFillColor( COLOR4D( 1, 1, 1, 0.4 ) );
m_gal->SetStrokeColor( COLOR4D( 0, 0, 0, 1 ) );
if( img_scale != 1.0 )
m_gal->Scale( VECTOR2D( 1.0, 1.0 ) );
m_gal->DrawRectangle( VECTOR2D( bbox.GetOrigin() ) - position,
VECTOR2D( bbox.GetEnd() ) - position );
#endif
m_gal->Restore();
}