From a41ff7b924f3ce73a0639a80671737b0068992e2 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Thu, 13 Jun 2019 14:01:57 +0200 Subject: [PATCH] pl_editor: fix move functions for WS_DRAW_ITEM_POLYPOLYGONS --- common/page_layout/ws_draw_item.cpp | 15 +++++++++++++-- include/ws_draw_item.h | 2 +- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/common/page_layout/ws_draw_item.cpp b/common/page_layout/ws_draw_item.cpp index af97f2902e..bac3a54553 100644 --- a/common/page_layout/ws_draw_item.cpp +++ b/common/page_layout/ws_draw_item.cpp @@ -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 ) { @@ -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 { EDA_RECT rect; @@ -218,7 +229,7 @@ const EDA_RECT WS_DRAW_ITEM_POLYPOLYGONS::GetBoundingBox() const rect.SetY( box.GetY() ); rect.SetWidth( box.GetWidth() ); 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; } diff --git a/include/ws_draw_item.h b/include/ws_draw_item.h index 4795a98c4b..50bc4c4d75 100644 --- a/include/ws_draw_item.h +++ b/include/ws_draw_item.h @@ -167,7 +167,7 @@ public: SHAPE_POLY_SET& GetPolygons() { return m_Polygons; } int GetPenWidth() const { return m_penWidth; } 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; bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override;