Fixed HitTest for text and modules
This commit is contained in:
parent
d9308fcab1
commit
9c80d63b5c
|
@ -260,7 +260,7 @@ public:
|
|||
* @param aAccuracy - Amount to inflate the bounding box.
|
||||
* @return bool - true if a hit, else false
|
||||
*/
|
||||
bool TextHitTest( const wxPoint& aPoint, int aAccuracy = 0 ) const;
|
||||
virtual bool TextHitTest( const wxPoint& aPoint, int aAccuracy = 0 ) const;
|
||||
|
||||
/**
|
||||
* Function TextHitTest (overloaded)
|
||||
|
@ -271,7 +271,7 @@ public:
|
|||
* @param aAccuracy - Amount to inflate the bounding box.
|
||||
* @return bool - true if a hit, else false
|
||||
*/
|
||||
bool TextHitTest( const EDA_RECT& aRect, bool aContains = false, int aAccuracy = 0 ) const;
|
||||
virtual bool TextHitTest( const EDA_RECT& aRect, bool aContains = false, int aAccuracy = 0 ) const;
|
||||
|
||||
/**
|
||||
* Function LenSize
|
||||
|
|
|
@ -614,7 +614,27 @@ bool MODULE::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) co
|
|||
if( aContained )
|
||||
return arect.Contains( m_BoundaryBox );
|
||||
else
|
||||
return m_BoundaryBox.Intersects( arect );
|
||||
{
|
||||
// If the rect does not intersect the bounding box, skip any tests
|
||||
if( !aRect.Intersects( GetBoundingBox() ) )
|
||||
return false;
|
||||
|
||||
// Determine if any elements in the MODULE intersect the rect
|
||||
for( D_PAD* pad = m_Pads; pad; pad = pad->Next() )
|
||||
{
|
||||
if( pad->HitTest( arect, false, 0 ) )
|
||||
return true;
|
||||
}
|
||||
|
||||
for( BOARD_ITEM* item = m_Drawings; item; item = item->Next() )
|
||||
{
|
||||
if( item->HitTest( arect, false, 0 ) )
|
||||
return true;
|
||||
}
|
||||
|
||||
// No items were hit
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -89,6 +89,35 @@ void TEXTE_MODULE::SetTextAngle( double aAngle )
|
|||
EDA_TEXT::SetTextAngle( NormalizeAngle360( aAngle ) );
|
||||
}
|
||||
|
||||
bool TEXTE_MODULE::TextHitTest( const wxPoint& aPoint, int aAccuracy ) const
|
||||
{
|
||||
EDA_RECT rect = GetTextBox( -1 );
|
||||
wxPoint location = aPoint;
|
||||
|
||||
rect.Inflate( aAccuracy );
|
||||
|
||||
RotatePoint( &location, GetTextPos(), -GetDrawRotation() );
|
||||
|
||||
return rect.Contains( location );
|
||||
}
|
||||
|
||||
bool TEXTE_MODULE::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( -1 ), GetDrawRotation() );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void TEXTE_MODULE::Rotate( const wxPoint& aRotCentre, double aAngle )
|
||||
{
|
||||
|
|
|
@ -184,6 +184,10 @@ public:
|
|||
|
||||
void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) override;
|
||||
|
||||
virtual bool TextHitTest( const wxPoint& aPoint, int aAccuracy = 0 ) const override;
|
||||
|
||||
virtual bool TextHitTest( const EDA_RECT& aRect, bool aContains = false, int aAccuracy = 0 ) const override;
|
||||
|
||||
virtual bool HitTest( const wxPoint& aPosition ) const override
|
||||
{
|
||||
return TextHitTest( aPosition );
|
||||
|
|
Loading…
Reference in New Issue