92 if( aIncludeLeaderPts )
135 std::optional<VECTOR2I> last;
169 const VECTOR2D endpointD = aEndPoint;
170 const VECTOR2D lineVec = endpointD - lastPt;
182 double angDiff =
std::abs( ( lineA - prevA ).Normalize180().AsDegrees() );
184 bool bendEnd = ( angDiff < 45 ) || ( angDiff > 90 && angDiff < 135 );
200 else if( horizontal )
217 else if( horizontal )
228 return SHAPE_LINE_CHAIN( std::vector<VECTOR2I>{ lastPt, midInt, aEndPoint } );
238 if( lastPt.
x == aEndPoint.
x || lastPt.
y == aEndPoint.
y )
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
"Listener" interface for a class that wants to be updated about polygon geometry changes
bool AddPoint(const VECTOR2I &aPt)
Lock in a polygon point.
void updateTemporaryLines(const VECTOR2I &aEndPoint, LEADER_MODE aModifier=LEADER_MODE::DIRECT)
Update the leader and loop lines points based on a new endpoint (probably a cursor position)
CLIENT & m_client
The current mode of the leader line.
POLYGON_GEOM_MANAGER(CLIENT &aClient)
SHAPE_LINE_CHAIN m_leaderPts
Points between the cursor and start point.
void SetCursorPosition(const VECTOR2I &aPos)
Set the current cursor position.
bool IsSelfIntersecting(bool aIncludeLeaderPts) const
Check whether the locked points constitute a self-intersecting outline.
bool NewPointClosesOutline(const VECTOR2I &aPt) const
std::optional< VECTOR2I > DeleteLastCorner()
Remove the last-added point from the polygon.
SHAPE_LINE_CHAIN m_loopPts
void SetFinished()
Mark the polygon finished and update the client.
void SetLeaderMode(LEADER_MODE aMode)
Set the leader mode to use when calculating the leader/returner lines.
int PolygonPointCount() const
LEADER_MODE m_leaderMode
Flag enabling self-intersecting polygons.
bool IsPolygonInProgress() const
void Reset()
Clear the manager state and start again.
SHAPE_LINE_CHAIN m_lockedPoints
Points in the temporary "leader" line(s)
bool m_intersectionsAllowed
Point that have been "locked in".
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
const SHAPE_LINE_CHAIN Reverse() const
Reverse point order in the line chain.
const std::optional< INTERSECTION > SelfIntersecting() const
Check if the line chain is self-intersecting.
void SetClosed(bool aClosed)
Mark the line chain as closed (i.e.
int PointCount() const
Return the number of points (vertices) in this line chain.
void Append(int aX, int aY, bool aAllowDuplication=false)
Append a new point at the end of the line chain.
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
int SegmentCount() const
Return the number of segments in this line chain.
const VECTOR2I & CLastPoint() const
Return the last point in the line chain.
const std::vector< VECTOR2I > & CPoints() const
static constexpr EDA_ANGLE ANGLE_45
a few functions useful in geometry calculations.
VECTOR2< T > GetVectorSnapped45(const VECTOR2< T > &aVec, bool only45=false)
Snap a vector onto the nearest 0, 45 or 90 degree line.
LEADER_MODE
The kind of the leader line.
@ DIRECT
Unconstrained point-to-point.
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
static SHAPE_LINE_CHAIN build90DegLeader(const VECTOR2I &aEndPoint, const SHAPE_LINE_CHAIN &aLastPoints)
static SHAPE_LINE_CHAIN build45DegLeader(const VECTOR2I &aEndPoint, const SHAPE_LINE_CHAIN &aLastPoints)
VECTOR2< int32_t > VECTOR2I
VECTOR2< double > VECTOR2D