PCB_SHAPE::GetFocusPosition(): returns a point on the outline instead of center.
This function is used in DRC to locate a graphic shape. For not filled shapes, this point must be on the shape outline, not on the center of the shape (the center shows nothing) Fixes #8832 https://gitlab.com/kicad/code/kicad/issues/8832
This commit is contained in:
parent
1a301d8eea
commit
49e1b5785f
|
@ -76,6 +76,47 @@ wxPoint PCB_SHAPE::GetPosition() const
|
|||
}
|
||||
|
||||
|
||||
const wxPoint PCB_SHAPE::GetFocusPosition() const
|
||||
{
|
||||
// For some shapes return the visual center, but for not filled polygonal shapes,
|
||||
// the center is usually far from the shape: a point on the outline is better
|
||||
|
||||
switch( m_shape )
|
||||
{
|
||||
case SHAPE_T::CIRCLE:
|
||||
if( !IsFilled() )
|
||||
return wxPoint( GetCenter().x + GetRadius(), GetCenter().y );
|
||||
break;
|
||||
|
||||
case SHAPE_T::RECT:
|
||||
if( !IsFilled() )
|
||||
return GetStart();
|
||||
break;
|
||||
|
||||
case SHAPE_T::POLY:
|
||||
if( !IsFilled() )
|
||||
{
|
||||
VECTOR2I pos = GetPolyShape().Outline(0).CPoint(0);
|
||||
return wxPoint( pos.x, pos.y );
|
||||
}
|
||||
break;
|
||||
|
||||
case SHAPE_T::ARC:
|
||||
return GetArcMid();
|
||||
break;
|
||||
|
||||
case SHAPE_T::BEZIER:
|
||||
return GetStart();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return GetCenter();
|
||||
}
|
||||
|
||||
|
||||
double PCB_SHAPE::GetLength() const
|
||||
{
|
||||
double length = 0.0;
|
||||
|
|
|
@ -205,10 +205,12 @@ public:
|
|||
*/
|
||||
void SetArcGeometry( const wxPoint& aStart, const wxPoint& aMid, const wxPoint& aEnd );
|
||||
|
||||
const wxPoint GetFocusPosition() const override
|
||||
{
|
||||
return GetCenter();
|
||||
}
|
||||
/**
|
||||
* Allows items to return their visual center rather than their anchor.
|
||||
* For some shapes this is similar to GetPosition, but for polygonal shapes,
|
||||
* the anchor is not suitable (shows nothing): a point on the outline is better
|
||||
*/
|
||||
const wxPoint GetFocusPosition() const override;
|
||||
|
||||
/**
|
||||
* Return the parent footprint or NULL if PCB_SHAPE does not belong to a footprint.
|
||||
|
|
Loading…
Reference in New Issue