Special-case hit-testing of filled schematic rule areas.
Fixes https://gitlab.com/kicad/code/kicad/-/issues/17879
This commit is contained in:
parent
dc8fd0996d
commit
4a01f322ff
|
@ -881,7 +881,7 @@ bool EDA_SHAPE::hitTest( const VECTOR2I& aPosition, int aAccuracy ) const
|
||||||
double radius = GetRadius();
|
double radius = GetRadius();
|
||||||
double dist = aPosition.Distance( getCenter() );
|
double dist = aPosition.Distance( getCenter() );
|
||||||
|
|
||||||
if( IsFilled() )
|
if( IsFilledForHitTesting() )
|
||||||
return dist <= radius + maxdist; // Filled circle hit-test
|
return dist <= radius + maxdist; // Filled circle hit-test
|
||||||
else
|
else
|
||||||
return abs( radius - dist ) <= maxdist; // Ring hit-test
|
return abs( radius - dist ) <= maxdist; // Ring hit-test
|
||||||
|
@ -899,7 +899,7 @@ bool EDA_SHAPE::hitTest( const VECTOR2I& aPosition, int aAccuracy ) const
|
||||||
VECTOR2D relPos( VECTOR2D( aPosition ) - getCenter() );
|
VECTOR2D relPos( VECTOR2D( aPosition ) - getCenter() );
|
||||||
double dist = relPos.EuclideanNorm();
|
double dist = relPos.EuclideanNorm();
|
||||||
|
|
||||||
if( IsFilled() )
|
if( IsFilledForHitTesting() )
|
||||||
{
|
{
|
||||||
// Check distance from arc center
|
// Check distance from arc center
|
||||||
if( dist > radius + maxdist )
|
if( dist > radius + maxdist )
|
||||||
|
@ -944,7 +944,7 @@ bool EDA_SHAPE::hitTest( const VECTOR2I& aPosition, int aAccuracy ) const
|
||||||
return TestSegmentHit( aPosition, GetStart(), GetEnd(), maxdist );
|
return TestSegmentHit( aPosition, GetStart(), GetEnd(), maxdist );
|
||||||
|
|
||||||
case SHAPE_T::RECTANGLE:
|
case SHAPE_T::RECTANGLE:
|
||||||
if( IsProxyItem() || IsFilled() ) // Filled rect hit-test
|
if( IsProxyItem() || IsFilledForHitTesting() ) // Filled rect hit-test
|
||||||
{
|
{
|
||||||
SHAPE_POLY_SET poly;
|
SHAPE_POLY_SET poly;
|
||||||
poly.NewOutline();
|
poly.NewOutline();
|
||||||
|
@ -965,7 +965,7 @@ bool EDA_SHAPE::hitTest( const VECTOR2I& aPosition, int aAccuracy ) const
|
||||||
}
|
}
|
||||||
|
|
||||||
case SHAPE_T::POLY:
|
case SHAPE_T::POLY:
|
||||||
if( IsFilled() )
|
if( IsFilledForHitTesting() )
|
||||||
{
|
{
|
||||||
if( !m_poly.COutline( 0 ).IsClosed() )
|
if( !m_poly.COutline( 0 ).IsClosed() )
|
||||||
{
|
{
|
||||||
|
|
|
@ -57,6 +57,11 @@ public:
|
||||||
|
|
||||||
void ViewGetLayers( int aLayers[], int& aCount ) const override;
|
void ViewGetLayers( int aLayers[], int& aCount ) const override;
|
||||||
|
|
||||||
|
bool IsFilledForHitTesting() const override
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
virtual std::vector<SHAPE*> MakeEffectiveShapes( bool aEdgeOnly = false ) const override;
|
virtual std::vector<SHAPE*> MakeEffectiveShapes( bool aEdgeOnly = false ) const override;
|
||||||
|
|
||||||
virtual void Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
|
virtual void Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
|
||||||
|
|
|
@ -93,6 +93,11 @@ public:
|
||||||
return GetFillMode() != FILL_T::NO_FILL;
|
return GetFillMode() != FILL_T::NO_FILL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual bool IsFilledForHitTesting() const
|
||||||
|
{
|
||||||
|
return IsFilled();
|
||||||
|
}
|
||||||
|
|
||||||
void SetFilled( bool aFlag )
|
void SetFilled( bool aFlag )
|
||||||
{
|
{
|
||||||
setFilled( aFlag );
|
setFilled( aFlag );
|
||||||
|
|
Loading…
Reference in New Issue