106 return solution.
valid;
152 static const double d = M_SQRT1_2;
153 static const VECTOR2D units[8] = { { 1, 0 }, { d, d }, { 0, 1 }, { -d, d },
154 { -1, 0 }, { -d, -d }, { 0, -1 }, { d, -d } };
158 m_dir = units[octant] * length;
224 if( !
IsReset() || ( aDirection.
x == 0.0 && aDirection.
y == 0.0 ) )
388 if( std::min( ccwAngle, cwAngle ) >=
ANGLE_90 )
ARC_DRAW_MODE
Construction sequence used when interactively drawing a circular arc.
@ TANGENT
End only; start and departure direction come from a tangent seed.
@ START_END_MID
Start, end, then the arc midpoint dragged along the chord bisector.
@ START_DIR_END
Start, a point giving the departure direction, then the end.
@ START_END_CENTER
Start, end, then the center dragged along the chord bisector.
@ CENTER_START_END
Center, then start (sets radius), then sweep to the end.
static EDA_ANGLE snapAngle(const EDA_ANGLE &aAngle)
Snap an angle to the nearest 45 degrees.
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
VECTOR2I GetOrigin() const
Get the center point of the arc (valid when state > FIRST_POINT in center mode)
bool acceptExactPoint(const VECTOR2I &aPt)
Point acceptor for every mode that keeps the clicked endpoints.
void Reset() override
Reset to the initial state, ready for the next arc.
bool HasTangentSeed() const
True when the TANGENT mode is running from a seed, so its first click already sets the end.
KIGEOM::ARC_SOLUTION m_solution
void ToggleClockwise()
Reverse the current arc direction in center mode, or switch between the minor and major arc in START_...
EDA_ANGLE GetStartAngle() const
Get the angle of the vector leading to the start point (valid if step >= SECOND_POINT in center mode)
bool setStart(const VECTOR2I &aEnd)
Set the end of the first radius line (arc start)
VECTOR2I GetStartRadiusEnd() const
Get the coordinates of the arc start.
bool acceptPoint(const VECTOR2I &aPt) override
Function that accepts a point for a stage, or rejects it to return to the previous stage.
bool setDirection(const VECTOR2I &aPt)
Set the departure direction from the second click, snapped if requested.
void SetTangentSeed(const VECTOR2I &aStart, const VECTOR2D &aDirection, bool aDirectionIsAxis=false)
Preload the start point and departure direction for ARC_DRAW_MODE::TANGENT.
int GetPointIndex() const
Index of the point the next click sets, counting a tangent seed as point 0.
bool UsesDirectionClick() const
True when a direction is part of the construction, that is START_DIR_END or an unseeded TANGENT.
VECTOR2I GetEndRadiusEnd() const
Get the coordinates of the arc end point.
bool UsesExactEndpoints() const
True when the committed endpoints are the clicked points, described by GetSolution()
void applySolution(const KIGEOM::ARC_SOLUTION &aSolution)
Take over a valid solution as the canonical arc state.
bool setEnd(const VECTOR2I &aCursor)
Set a point of the second radius line (collinear with arc end)
void clearSolution()
Forget the solution, leaving nothing drawable.
double GetRadius() const
Get the radius of the arc (valid if step >= SECOND_POINT in center mode)
EDA_ANGLE GetSubtended() const
Get the angle of the vector leading to the end point (valid if step >= THIRD_POINT in center mode)
std::array< VECTOR2I, 3 > m_pts
The points set so far for the modes that keep the clicked endpoints, the last following the cursor.
bool setOrigin(const VECTOR2I &aOrigin)
Set the center point of the arc.
void SetMode(ARC_DRAW_MODE aMode)
Select the construction sequence.
@ FIRST_POINT
Waiting to lock in the first point.
@ THIRD_POINT
Waiting to lock in the third point.
@ SECOND_POINT
Waiting to lock in the second point.
VECTOR2I GetLastPoint() const
Get the last point added (locked in or not).
int getStep() const
Get the current stage of the manager.
void AddPoint(const VECTOR2I &aPt, bool aLockIn)
Add a point to the construction manager.
void setGeometryChanged()
Mark the geometry as changed for clients to notice.
virtual void Reset()
Reset the manager to the initial state.
constexpr extended_type Cross(const VECTOR2< T > &aVector) const
Compute cross product of self with aVector.
T EuclideanNorm() const
Compute the Euclidean norm of the vector, which is defined as sqrt(x ** 2 + y ** 2).
constexpr extended_type Dot(const VECTOR2< T > &aVector) const
Compute dot product of self with aVector.
static constexpr EDA_ANGLE ANGLE_0
static constexpr EDA_ANGLE ANGLE_90
static constexpr EDA_ANGLE ANGLE_45
static constexpr EDA_ANGLE ANGLE_360
ARC_SOLUTION ArcFromStartEndCenterDrag(const VECTOR2I &aStart, const VECTOR2I &aEnd, const VECTOR2I &aCursor, bool aMajor)
Arc from aStart to aEnd centered on aCursor projected onto the chord bisector.
ARC_SOLUTION ArcFromStartTangentEnd(const VECTOR2I &aStart, const VECTOR2D &aTangent, const VECTOR2I &aEnd)
Arc leaving aStart along aTangent and ending at aEnd.
ARC_SOLUTION ArcFromStartEndMidDrag(const VECTOR2I &aStart, const VECTOR2I &aEnd, const VECTOR2I &aCursor)
Arc from aStart to aEnd whose midpoint is aCursor projected onto the chord bisector.
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
bool valid
False for degenerate input (collinear points, zero chord, etc)
VECTOR2I mid
The point on the arc halfway along the sweep.
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Calculate the new point of coord coord pX, pY, for a rotation center 0, 0.
constexpr int sign(T val)
VECTOR2< int32_t > VECTOR2I
VECTOR2< double > VECTOR2D