From 1b9a8564afe868981d89dfcae406d35f8abfe75f Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Thu, 6 May 2021 18:48:23 +0200 Subject: [PATCH] Pcbnew: fix incorrect PCB_TEXT::TextHitTest( const EDA_RECT& aRect,... ). It was not taking in account the text rotation in block selection. Fixes #8366 https://gitlab.com/kicad/code/kicad/issues/8366 --- pcbnew/pcb_text.cpp | 19 +++++++++++++++++++ pcbnew/pcb_text.h | 3 +++ 2 files changed, 22 insertions(+) diff --git a/pcbnew/pcb_text.cpp b/pcbnew/pcb_text.cpp index e8a9ac21b0..31ee45f70f 100644 --- a/pcbnew/pcb_text.cpp +++ b/pcbnew/pcb_text.cpp @@ -138,6 +138,25 @@ const EDA_RECT PCB_TEXT::GetBoundingBox() const } +bool PCB_TEXT::TextHitTest( const wxPoint& aPoint, int aAccuracy ) const +{ + return EDA_TEXT::TextHitTest( aPoint, aAccuracy ); +} + + +bool PCB_TEXT::TextHitTest( const EDA_RECT& aRect, bool aContains, int aAccuracy ) const +{ + EDA_RECT rect = aRect; + + rect.Inflate( aAccuracy ); + + if( aContains ) + return rect.Contains( GetBoundingBox() ); + else + return rect.Intersects( GetTextBox(), GetDrawRotation() ); +} + + void PCB_TEXT::Rotate( const wxPoint& aRotCentre, double aAngle ) { wxPoint pt = GetTextPos(); diff --git a/pcbnew/pcb_text.h b/pcbnew/pcb_text.h index 89885c1218..3f71539028 100644 --- a/pcbnew/pcb_text.h +++ b/pcbnew/pcb_text.h @@ -92,6 +92,9 @@ public: void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& aList ) override; + bool TextHitTest( const wxPoint& aPoint, int aAccuracy = 0 ) const override; + bool TextHitTest( const EDA_RECT& aRect, bool aContains, int aAccuracy = 0 ) const override; + bool HitTest( const wxPoint& aPosition, int aAccuracy ) const override { return TextHitTest( aPosition, aAccuracy );