20#ifndef PREVIEW_ITEMS_ARC_GEOMETRY_MANAGER_H
21#define PREVIEW_ITEMS_ARC_GEOMETRY_MANAGER_H
79 void Reset()
override;
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_DIR_END
Start, a point giving the departure direction, then the end.
@ CENTER_START_END
Center, then start (sets radius), then sweep to the end.
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.
const KIGEOM::ARC_SOLUTION & GetSolution() const
The arc as start, mid and end (never used in center mode).
void Reset() override
Reset to the initial state, ready for the next arc.
void SetAngleSnap(bool aSnap)
Set angle snapping (for the next point)
ARC_STEPS GetStep() const
Get the current step the manager is on (useful when drawing something depends on the current state)
int getMaxStep() const override
The highest step this manager has - used to recognize completion and to clamp the step as it advances...
const VECTOR2D & GetTangentDirection() const
The departure direction of the arc (valid once the direction is set, or seeded)
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 HasPreview() const
True when there is something to preview, which a seeded tangent has before any click.
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.
ARC_DRAW_MODE GetMode() const
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.
bool rejectRegresses() const override
Only the center mode returns to the previous step, so a refused click in the others is ignored.
VECTOR2I GetEndRadiusEnd() const
Get the coordinates of the arc end point.
const VECTOR2I & GetPoint(int aIndex) const
A point of the construction as set so far (index 0 to 2), including the one following the cursor.
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.
ARC_STEPS
The point each step waits for depends on the mode, for example the origin, the start,...
@ 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.
A geometry manager that works by accepting a sequence of points and advancing though stages of geomet...
int getStep() const
Get the current stage of the manager.
The Cairo implementation of the graphics abstraction layer.
VECTOR2< int32_t > VECTOR2I
VECTOR2< double > VECTOR2D