Rotate the bounding box for hit tests on the fly
This commit is contained in:
parent
721c30e464
commit
a82edb60fe
|
@ -737,7 +737,7 @@ EDA_RECT EDA_RECT::Common( const EDA_RECT& aRect ) const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const EDA_RECT EDA_RECT::GetBoundingBoxRotated( wxPoint aRotCenter, double aAngle )
|
const EDA_RECT EDA_RECT::GetBoundingBoxRotated( wxPoint aRotCenter, double aAngle ) const
|
||||||
{
|
{
|
||||||
wxPoint corners[4];
|
wxPoint corners[4];
|
||||||
|
|
||||||
|
|
|
@ -360,7 +360,7 @@ public:
|
||||||
* useful to calculate bounding box of rotated items, when
|
* useful to calculate bounding box of rotated items, when
|
||||||
* rotation if not k*90 degrees
|
* rotation if not k*90 degrees
|
||||||
*/
|
*/
|
||||||
const EDA_RECT GetBoundingBoxRotated( wxPoint aRotCenter, double aAngle );
|
const EDA_RECT GetBoundingBoxRotated( wxPoint aRotCenter, double aAngle ) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -719,7 +719,7 @@ void MODULE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM
|
||||||
|
|
||||||
bool MODULE::HitTest( const wxPoint& aPosition, int aAccuracy ) const
|
bool MODULE::HitTest( const wxPoint& aPosition, int aAccuracy ) const
|
||||||
{
|
{
|
||||||
EDA_RECT rect = m_BoundaryBox;
|
EDA_RECT rect = m_BoundaryBox.GetBoundingBoxRotated( GetPosition(), m_Orient );
|
||||||
return rect.Inflate( aAccuracy ).Contains( aPosition );
|
return rect.Inflate( aAccuracy ).Contains( aPosition );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -736,7 +736,7 @@ bool MODULE::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) co
|
||||||
arect.Inflate( aAccuracy );
|
arect.Inflate( aAccuracy );
|
||||||
|
|
||||||
if( aContained )
|
if( aContained )
|
||||||
return arect.Contains( m_BoundaryBox );
|
return arect.Contains( m_BoundaryBox.GetBoundingBoxRotated( GetPosition(), m_Orient ) );
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// If the rect does not intersect the bounding box, skip any tests
|
// If the rect does not intersect the bounding box, skip any tests
|
||||||
|
@ -1369,8 +1369,6 @@ void MODULE::SetOrientation( double aNewAngle )
|
||||||
static_cast<TEXTE_MODULE*>( item )->SetDrawCoord();
|
static_cast<TEXTE_MODULE*>( item )->SetDrawCoord();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_BoundaryBox = m_BoundaryBox.GetBoundingBoxRotated( GetPosition(), angleChange );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue