35 m_intersectionsAllowed( true )
92 if( aIncludeLeaderPts )
134 std::optional<VECTOR2I> last;
168 const VECTOR2D endpointD = aEndPoint;
169 const VECTOR2D lineVec = endpointD - lastPt;
181 double angDiff =
std::abs( ( lineA - prevA ).Normalize180().AsDegrees() );
183 bool bendEnd = ( angDiff < 45 ) || ( angDiff > 90 && angDiff < 135 );
199 else if( horizontal )
216 else if( horizontal )
227 return SHAPE_LINE_CHAIN( std::vector<VECTOR2I>{ lastPt, midInt, aEndPoint } );
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
"Listener" interface for a class that wants to be updated about polygon geometry changes
virtual void OnGeometryChange(const POLYGON_GEOM_MANAGER &aMgr)=0
Called when the polygon is complete.
virtual bool OnFirstPoint(POLYGON_GEOM_MANAGER &aMgr)=0
Called before the first point is added - clients can do initialization here, and can veto the start o...
virtual void OnComplete(const POLYGON_GEOM_MANAGER &aMgr)=0
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.
LEADER_MODE
The kind of the leader line.
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.
virtual const VECTOR2I GetPoint(int aIndex) const override
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 Clear()
Remove all points from the 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.
void Remove(int aStartIndex, int aEndIndex)
Remove the range of points [start_index, end_index] from the line chain.
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.
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
static SHAPE_LINE_CHAIN build45DegLeader(const VECTOR2I &aEndPoint, SHAPE_LINE_CHAIN aLastPoints)
VECTOR2< double > VECTOR2D