Fix knockout text bounding boxes and hit testing.
Fixes https://gitlab.com/kicad/code/kicad/issues/12133
This commit is contained in:
parent
6a9b821b5c
commit
509d233d97
|
@ -781,7 +781,7 @@ bool EDA_SHAPE::hitTest( const VECTOR2I& aPosition, int aAccuracy ) const
|
|||
for( const VECTOR2I& pt : GetRectCorners() )
|
||||
poly.Append( pt );
|
||||
|
||||
return poly.Collide( VECTOR2I( aPosition ), maxdist );
|
||||
return poly.Collide( aPosition, maxdist );
|
||||
}
|
||||
else // Open rect hit-test
|
||||
{
|
||||
|
@ -795,9 +795,9 @@ bool EDA_SHAPE::hitTest( const VECTOR2I& aPosition, int aAccuracy ) const
|
|||
|
||||
case SHAPE_T::POLY:
|
||||
if( IsFilled() )
|
||||
return m_poly.Collide( VECTOR2I( aPosition ), maxdist );
|
||||
return m_poly.Collide( aPosition, maxdist );
|
||||
else
|
||||
return m_poly.CollideEdge( VECTOR2I( aPosition ), nullptr, maxdist );
|
||||
return m_poly.CollideEdge( aPosition, nullptr, maxdist );
|
||||
|
||||
default:
|
||||
UNIMPLEMENTED_FOR( SHAPE_T_asString() );
|
||||
|
|
|
@ -148,10 +148,22 @@ void PCB_TEXT::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_IT
|
|||
}
|
||||
|
||||
|
||||
int PCB_TEXT::getKnockoutMargin() const
|
||||
{
|
||||
VECTOR2I textSize( GetTextWidth(), GetTextHeight() );
|
||||
int thickness = GetTextThickness();
|
||||
|
||||
return thickness * 1.5 + GetKnockoutTextMargin( textSize, thickness );
|
||||
}
|
||||
|
||||
|
||||
const EDA_RECT PCB_TEXT::GetBoundingBox() const
|
||||
{
|
||||
EDA_RECT rect = GetTextBox();
|
||||
|
||||
if( IsKnockout() )
|
||||
rect.Inflate( getKnockoutMargin() );
|
||||
|
||||
if( !GetTextAngle().IsZero() )
|
||||
rect = rect.GetBoundingBoxRotated( GetTextPos(), GetTextAngle() );
|
||||
|
||||
|
@ -161,7 +173,18 @@ const EDA_RECT PCB_TEXT::GetBoundingBox() const
|
|||
|
||||
bool PCB_TEXT::TextHitTest( const VECTOR2I& aPoint, int aAccuracy ) const
|
||||
{
|
||||
return EDA_TEXT::TextHitTest( aPoint, aAccuracy );
|
||||
if( IsKnockout() )
|
||||
{
|
||||
SHAPE_POLY_SET poly;
|
||||
|
||||
TransformBoundingBoxWithClearanceToPolygon( &poly, getKnockoutMargin() );
|
||||
|
||||
return poly.Collide( aPoint, aAccuracy );
|
||||
}
|
||||
else
|
||||
{
|
||||
return EDA_TEXT::TextHitTest( aPoint, aAccuracy );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -153,6 +153,9 @@ public:
|
|||
#if defined(DEBUG)
|
||||
virtual void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
|
||||
#endif
|
||||
|
||||
protected:
|
||||
int getKnockoutMargin() const;
|
||||
};
|
||||
|
||||
#endif // #define PCB_TEXT_H
|
||||
|
|
Loading…
Reference in New Issue