pl_editor: fix move functions for WS_DRAW_ITEM_POLYPOLYGONS

This commit is contained in:
jean-pierre charras 2019-06-13 14:01:57 +02:00
parent 028973d182
commit a41ff7b924
2 changed files with 14 additions and 3 deletions

View File

@ -188,7 +188,7 @@ wxString WS_DRAW_ITEM_TEXT::GetSelectMenuText( EDA_UNITS_T aUnits ) const
} }
// ============================ POLYGON // ============================ POLYGON =================================
void WS_DRAW_ITEM_POLYPOLYGONS::PrintWsItem( wxDC* aDC, const wxPoint& aOffset, COLOR4D aColor ) void WS_DRAW_ITEM_POLYPOLYGONS::PrintWsItem( wxDC* aDC, const wxPoint& aOffset, COLOR4D aColor )
{ {
@ -209,6 +209,17 @@ void WS_DRAW_ITEM_POLYPOLYGONS::PrintWsItem( wxDC* aDC, const wxPoint& aOffset,
} }
void WS_DRAW_ITEM_POLYPOLYGONS::SetPosition( wxPoint aPos )
{
// Note: m_pos is the anchor point of the shape.
wxPoint move_vect = aPos - m_pos;
m_pos = aPos;
// Move polygon corners to the new position:
m_Polygons.Move( move_vect );
}
const EDA_RECT WS_DRAW_ITEM_POLYPOLYGONS::GetBoundingBox() const const EDA_RECT WS_DRAW_ITEM_POLYPOLYGONS::GetBoundingBox() const
{ {
EDA_RECT rect; EDA_RECT rect;
@ -218,7 +229,7 @@ const EDA_RECT WS_DRAW_ITEM_POLYPOLYGONS::GetBoundingBox() const
rect.SetY( box.GetY() ); rect.SetY( box.GetY() );
rect.SetWidth( box.GetWidth() ); rect.SetWidth( box.GetWidth() );
rect.SetHeight( box.GetHeight() ); rect.SetHeight( box.GetHeight() );
printf("bbox %f %f %f %f\n",box.GetX()/1e3,box.GetY()/1e3,box.GetWidth()/1e3,box.GetHeight()/1e3);fflush(0);
return rect; return rect;
} }

View File

@ -167,7 +167,7 @@ public:
SHAPE_POLY_SET& GetPolygons() { return m_Polygons; } SHAPE_POLY_SET& GetPolygons() { return m_Polygons; }
int GetPenWidth() const { return m_penWidth; } int GetPenWidth() const { return m_penWidth; }
const wxPoint GetPosition() const override { return m_pos; } const wxPoint GetPosition() const override { return m_pos; }
void SetPosition( wxPoint aPos ) override { m_pos = aPos; } void SetPosition( wxPoint aPos ) override;
const EDA_RECT GetBoundingBox() const override; const EDA_RECT GetBoundingBox() const override;
bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override; bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override;