Fix SCH_BITMAP handling in gal.

This commit is contained in:
jean-pierre charras 2018-09-08 13:12:41 +02:00 committed by Jeff Young
parent e55763947e
commit 1a0f3b79cc
7 changed files with 40 additions and 6 deletions

View File

@ -124,6 +124,7 @@ SCH_BITMAP* SCH_EDIT_FRAME::CreateNewImage( wxDC* aDC )
return NULL; return NULL;
} }
image->SetFlags( IS_NEW | IS_MOVED );
auto view = static_cast<SCH_DRAW_PANEL*>( m_canvas )->GetView(); auto view = static_cast<SCH_DRAW_PANEL*>( m_canvas )->GetView();

View File

@ -142,7 +142,8 @@ bool SCH_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
bool actionCancelled = false; bool actionCancelled = false;
item = LocateAndShowItem( aPosition, SCH_COLLECTOR::AllItemsButPins, 0, &actionCancelled ); item = LocateAndShowItem( aPosition, SCH_COLLECTOR::AllItemsButPins, 0, &actionCancelled );
printf("Locateandshow %d %d item %p\n", aPosition.x, aPosition.y, item ); printf("Locateandshow %d %d item %p type %d\n", aPosition.x, aPosition.y,
item, item ? item->Type() : 0 ); fflush(0);
// If the clarify item selection context menu is aborted, don't show the context menu. // If the clarify item selection context menu is aborted, don't show the context menu.
if( item == NULL && actionCancelled ) if( item == NULL && actionCancelled )

View File

@ -128,8 +128,7 @@ void SCH_BITMAP::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset
GRSetDrawMode( aDC, aDrawMode ); GRSetDrawMode( aDC, aDrawMode );
#endif #endif
//fixme-gal m_image->DrawBitmap( aDC, pos );
//m_image->DrawBitmap( aPanel, aDC, pos );
} }
else // draws bounding box only (used to move items) else // draws bounding box only (used to move items)
{ {

View File

@ -84,6 +84,17 @@ public:
return m_image->GetScalingFactor(); return m_image->GetScalingFactor();
} }
/**
* @return the m_Scale image "zoom" value
* m_Scale is an user dependant value, and is similar to a "zoom" value
* m_Scale = 1.0 = original size of bitmap.
* m_Scale < 1.0 = the bitmap is drawn smaller than its original size.
* m_Scale > 1.0 = the bitmap is drawn bigger than its original size.
*/
double GetImageScale() const
{
return m_image->GetScale();
}
wxString GetClass() const override wxString GetClass() const override
{ {

View File

@ -1317,7 +1317,14 @@ void SCH_PAINTER::draw( SCH_BITMAP *aBitmap, int aLayer )
{ {
m_gal->Save(); m_gal->Save();
m_gal->Translate( aBitmap->GetPosition() ); m_gal->Translate( aBitmap->GetPosition() );
// When the image scale factor is not 1.0, we need to modify the actual
// as the image scale factor is similar to a local zoom
if( aBitmap->GetImageScale() != 1.0 )
m_gal->Scale( VECTOR2D( aBitmap->GetImageScale(), aBitmap->GetImageScale() ) );
m_gal->DrawBitmap( *aBitmap->GetImage() ); m_gal->DrawBitmap( *aBitmap->GetImage() );
m_gal->Restore(); m_gal->Restore();
} }

View File

@ -430,17 +430,18 @@ void SCH_EDIT_FRAME::OnMoveItem( wxCommandEvent& aEvent )
case SCH_SHEET_PIN_T: case SCH_SHEET_PIN_T:
case SCH_FIELD_T: case SCH_FIELD_T:
case SCH_SHEET_T: case SCH_SHEET_T:
case SCH_BITMAP_T:
PrepareMoveItem( item, nullptr ); PrepareMoveItem( item, nullptr );
break; break;
case SCH_BITMAP_T: /* case SCH_BITMAP_T:
// move an image is a special case: // move an image is a special case:
// we cannot undraw/redraw a bitmap just using our xor mode // we cannot undraw/redraw a bitmap just using our xor mode
// the MoveImage function handle this undraw/redraw difficulty // the MoveImage function handle this undraw/redraw difficulty
// By redrawing the full bounding box // By redrawing the full bounding box
// MoveImage( (SCH_BITMAP*) item, &dc ); MoveImage( (SCH_BITMAP*) item, &dc );
break; break;
*/
case SCH_MARKER_T: case SCH_MARKER_T:
// Moving a marker has no sense // Moving a marker has no sense
break; break;
@ -923,6 +924,9 @@ void SCH_EDIT_FRAME::OnRotate( wxCommandEvent& aEvent )
case SCH_BITMAP_T: case SCH_BITMAP_T:
RotateImage( (SCH_BITMAP*) item ); RotateImage( (SCH_BITMAP*) item );
// The bitmap is cached in Opengl: clear the cache, because
// the cache data is invalid
GetCanvas()->GetGAL()->ClearCache();
break; break;
case SCH_SHEET_T: case SCH_SHEET_T:
@ -1093,6 +1097,9 @@ void SCH_EDIT_FRAME::OnEditItem( wxCommandEvent& aEvent )
case SCH_BITMAP_T: case SCH_BITMAP_T:
EditImage( (SCH_BITMAP*) item ); EditImage( (SCH_BITMAP*) item );
// The bitmap is cached in Opengl: clear the cache, because
// the cache data is perhaps invalid
GetCanvas()->GetGAL()->ClearCache();
break; break;
case SCH_LINE_T: // These items have no param to edit case SCH_LINE_T: // These items have no param to edit
@ -1284,6 +1291,10 @@ void SCH_EDIT_FRAME::OnOrient( wxCommandEvent& aEvent )
else if( aEvent.GetId() == ID_SCH_MIRROR_Y ) else if( aEvent.GetId() == ID_SCH_MIRROR_Y )
MirrorImage( (SCH_BITMAP*) item, false ); MirrorImage( (SCH_BITMAP*) item, false );
// The bitmap is cached in Opengl: clear the cache, because
// the cache data is invalid
GetCanvas()->GetGAL()->ClearCache();
break; break;
case SCH_SHEET_T: case SCH_SHEET_T:

View File

@ -381,6 +381,10 @@ void SCH_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRed
} }
} }
// Bitmaps are cached in Opengl: clear the cache, because
// the cache data can be invalid
GetCanvas()->GetGAL()->ClearCache();
GetCanvas()->GetView()->UpdateAllItems( KIGFX::ALL ); GetCanvas()->GetView()->UpdateAllItems( KIGFX::ALL );
} }