Make PLEditor greedy selections of rectangles sparse.
Fixes https://gitlab.com/kicad/code/kicad/issues/6278
This commit is contained in:
parent
9191b4a41b
commit
599a33a9c6
|
@ -352,6 +352,44 @@ bool WS_DRAW_ITEM_RECT::HitTest( const wxPoint& aPosition, int aAccuracy ) const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool WS_DRAW_ITEM_RECT::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
|
||||||
|
{
|
||||||
|
EDA_RECT sel = aRect;
|
||||||
|
|
||||||
|
if ( aAccuracy )
|
||||||
|
sel.Inflate( aAccuracy );
|
||||||
|
|
||||||
|
if( aContained )
|
||||||
|
return sel.Contains( GetBoundingBox() );
|
||||||
|
|
||||||
|
// For greedy we need to check each side of the rect as we're pretty much always inside the
|
||||||
|
// rect which defines the worksheet frame.
|
||||||
|
EDA_RECT side = GetBoundingBox();
|
||||||
|
side.SetHeight( 0 );
|
||||||
|
|
||||||
|
if( sel.Intersects( side ) )
|
||||||
|
return true;
|
||||||
|
|
||||||
|
side.SetY( GetBoundingBox().GetBottom() );
|
||||||
|
|
||||||
|
if( sel.Intersects( side ) )
|
||||||
|
return true;
|
||||||
|
|
||||||
|
side = GetBoundingBox();
|
||||||
|
side.SetWidth( 0 );
|
||||||
|
|
||||||
|
if( sel.Intersects( side ) )
|
||||||
|
return true;
|
||||||
|
|
||||||
|
side.SetX( GetBoundingBox().GetRight() );
|
||||||
|
|
||||||
|
if( sel.Intersects( side ) )
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
wxString WS_DRAW_ITEM_RECT::GetSelectMenuText( EDA_UNITS aUnits ) const
|
wxString WS_DRAW_ITEM_RECT::GetSelectMenuText( EDA_UNITS aUnits ) const
|
||||||
{
|
{
|
||||||
return wxString::Format( _( "Rectangle, width %s height %s" ),
|
return wxString::Format( _( "Rectangle, width %s height %s" ),
|
||||||
|
|
|
@ -226,6 +226,7 @@ public:
|
||||||
|
|
||||||
const EDA_RECT GetBoundingBox() const override;
|
const EDA_RECT GetBoundingBox() const override;
|
||||||
bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override;
|
bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override;
|
||||||
|
bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override;
|
||||||
|
|
||||||
wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
|
wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue