diff --git a/common/page_layout/ws_draw_item.cpp b/common/page_layout/ws_draw_item.cpp index 35053421ac..f58f7b437d 100644 --- a/common/page_layout/ws_draw_item.cpp +++ b/common/page_layout/ws_draw_item.cpp @@ -152,6 +152,12 @@ void WS_DRAW_ITEM_TEXT::DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint } +const EDA_RECT WS_DRAW_ITEM_TEXT::GetBoundingBox() const +{ + return EDA_TEXT::GetTextBox( -1 ); +} + + bool WS_DRAW_ITEM_TEXT::HitTest( const wxPoint& aPosition, int aAccuracy ) const { return EDA_TEXT::TextHitTest( aPosition, aAccuracy ); @@ -198,6 +204,17 @@ void WS_DRAW_ITEM_POLYGON::DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPo } +const EDA_RECT WS_DRAW_ITEM_POLYGON::GetBoundingBox() const +{ + EDA_RECT rect( GetPosition(), wxSize( 0, 0 ) ); + + for( wxPoint corner : m_Corners ) + rect.Merge( corner ); + + return rect; +} + + bool WS_DRAW_ITEM_POLYGON::HitTest( const wxPoint& aPosition, int aAccuracy ) const { for( unsigned ii = 1; ii < m_Corners.size(); ii++ ) @@ -261,6 +278,12 @@ void WS_DRAW_ITEM_RECT::DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint } +const EDA_RECT WS_DRAW_ITEM_RECT::GetBoundingBox() const +{ + return EDA_RECT( GetStart(), wxSize( GetEnd().x - GetStart().x, GetEnd().y - GetStart().y ) ); +} + + bool WS_DRAW_ITEM_RECT::HitTest( const wxPoint& aPosition, int aAccuracy ) const { int dist = aAccuracy + ( GetPenWidth() / 2 ); @@ -314,6 +337,12 @@ void WS_DRAW_ITEM_LINE::DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint } +const EDA_RECT WS_DRAW_ITEM_LINE::GetBoundingBox() const +{ + return EDA_RECT( GetStart(), wxSize( GetEnd().x - GetStart().x, GetEnd().y - GetStart().y ) ); +} + + bool WS_DRAW_ITEM_LINE::HitTest( const wxPoint& aPosition, int aAccuracy ) const { int mindist = aAccuracy + ( GetPenWidth() / 2 ); diff --git a/include/ws_draw_item.h b/include/ws_draw_item.h index 71724e9f42..a6e56d496e 100644 --- a/include/ws_draw_item.h +++ b/include/ws_draw_item.h @@ -130,10 +130,7 @@ public: const wxPoint GetPosition() const override { return GetStart(); } void SetPosition( wxPoint aPos ) override { SetStart( aPos ); } - /** The function to draw a WS_DRAW_ITEM_LINE - */ - void DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset, GR_DRAWMODE aDrawMode, - COLOR4D aColor ) override; + const EDA_RECT GetBoundingBox() const override; /** * Virtual function @@ -141,6 +138,11 @@ public: */ bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override; + /** The function to draw a WS_DRAW_ITEM_LINE + */ + void DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset, GR_DRAWMODE aDrawMode, + COLOR4D aColor ) override; + wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override; #if defined(DEBUG) @@ -177,10 +179,7 @@ public: const wxPoint GetPosition() const override { return m_pos; } void SetPosition( wxPoint aPos ) override { m_pos = aPos; } - /** The function to draw a WS_DRAW_ITEM_POLYGON - */ - void DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset, GR_DRAWMODE aDrawMode, - COLOR4D aColor ) override; + const EDA_RECT GetBoundingBox() const override; /** * Virtual function @@ -194,6 +193,11 @@ public: */ bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override; + /** The function to draw a WS_DRAW_ITEM_POLYGON + */ + void DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset, GR_DRAWMODE aDrawMode, + COLOR4D aColor ) override; + wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override; #if defined(DEBUG) @@ -234,6 +238,8 @@ public: void DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset, GR_DRAWMODE aDrawMode, COLOR4D aColor ) override; + const EDA_RECT GetBoundingBox() const override; + /** * Virtual function * return true if the point aPosition is on one edge of the rectangle @@ -283,6 +289,8 @@ public: const wxPoint GetPosition() const override { return GetTextPos(); } void SetPosition( wxPoint aPos ) override { SetTextPos( aPos ); } + const EDA_RECT GetBoundingBox() const override; + /** * Virtual function * return true if the point aPosition is inside one polygon