KiCad PCB EDA Suite
|
Manage the construction of a circular arc though sequential setting of critical points: center, arc start and arc end. More...
#include <arc_geom_manager.h>
Public Types | |
enum | ARC_STEPS { SET_ORIGIN = 0 , SET_START , SET_ANGLE , COMPLETE } |
Public Member Functions | |
ARC_GEOM_MANAGER () | |
int | getMaxStep () const override |
The highest step this manager has - used to recognize completion and to clamp the step as it advances. | |
ARC_STEPS | GetStep () const |
Get the current step the manager is on (useful when drawing something depends on the current state) | |
bool | acceptPoint (const VECTOR2I &aPt) override |
The arc to be clockwise from start. | |
void | SetClockwise (bool aCw) |
Reverse the current are direction. | |
void | ToggleClockwise () |
Set angle snapping (for the next point) | |
void | SetAngleSnap (bool aSnap) |
VECTOR2I | GetOrigin () const |
< Get the center point of the arc (valid when state > SET_ORIGIN) | |
VECTOR2I | GetStartRadiusEnd () const |
Get the coordinates of the arc end point. | |
VECTOR2I | GetEndRadiusEnd () const |
Get the radius of the arc (valid if step >= SET_START) | |
double | GetRadius () const |
Get the angle of the vector leading to the start point (valid if step >= SET_START) | |
EDA_ANGLE | GetStartAngle () const |
Get the angle of the vector leading to the end point (valid if step >= SET_ANGLE) | |
EDA_ANGLE | GetSubtended () const |
void | AddPoint (const VECTOR2I &aPt, bool aLockIn) |
Add a point to the construction manager. | |
void | RemoveLastPoint () |
Undo the last point, and move the manager back to the previous step. | |
bool | IsReset () const |
void | Reset () |
Reset the manager to the initial state. | |
bool | IsComplete () const |
VECTOR2I | GetLastPoint () const |
Get the last point added (locked in or not). | |
bool | HasGeometryChanged () const |
void | ClearGeometryChanged () |
Clear the geometry changed flag, call after the client code has updated everything as needed. | |
Protected Member Functions | |
void | setGeometryChanged () |
< Mark the geometry as changed for clients to notice | |
int | getStep () const |
Private Member Functions | |
bool | setOrigin (const VECTOR2I &aOrigin) |
< Set the center point of the arc | |
bool | setStart (const VECTOR2I &aEnd) |
Set a point of the second radius line (collinear with arc end) | |
bool | setEnd (const VECTOR2I &aCursor) |
void | performStep (bool aForward) |
Has the geometry changed such that a client should redraw? | |
Private Attributes | |
bool | m_clockwise = true |
VECTOR2I | m_origin |
double | m_radius = 0.0 |
EDA_ANGLE | m_startAngle |
EDA_ANGLE | m_endAngle |
bool | m_angleSnap = false |
bool | m_directionLocked = false |
bool | m_changed = false |
The last (raw) point added, which is usually the cursor position. | |
VECTOR2I | m_lastPoint |
int | m_step = 0 |
The current manager step, from 0 to some highest number that depends on the manager. | |
Manage the construction of a circular arc though sequential setting of critical points: center, arc start and arc end.
The manager is driven by setting cursor points, which update the geometry, and optionally advance the manager state.
Interfaces are provided to return both arc geometry (can be used to set up real arcs on PCBs, for example) as well as important control points for informational overlays.
Definition at line 42 of file arc_geom_manager.h.
Enumerator | |
---|---|
SET_ORIGIN | Waiting to lock in origin point. |
SET_START | Waiting to lock in the arc start point. |
SET_ANGLE | Waiting to lock in the arc end point. |
COMPLETE |
Definition at line 48 of file arc_geom_manager.h.
|
inline |
Definition at line 45 of file arc_geom_manager.h.
|
overridevirtual |
The arc to be clockwise from start.
Implements KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER.
Definition at line 40 of file arc_geom_manager.cpp.
References COMPLETE, KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER::getStep(), SET_ANGLE, SET_ORIGIN, SET_START, setEnd(), setOrigin(), and setStart().
|
inlineinherited |
Add a point to the construction manager.
aPt | the new point |
aLockIn | whether to "lock in" the point, and move the geometry manager to the next (or previous) step. False to update geometry and not affect manager state. |
Definition at line 61 of file multistep_geom_manager.h.
References KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER::acceptPoint(), KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER::m_lastPoint, KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER::performStep(), and KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER::setGeometryChanged().
Referenced by DRAWING_TOOL::drawArc(), and DRAWING_TOOL::drawOneBezier().
|
inlineinherited |
Clear the geometry changed flag, call after the client code has updated everything as needed.
Definition at line 137 of file multistep_geom_manager.h.
References KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER::m_changed.
VECTOR2I ARC_GEOM_MANAGER::GetEndRadiusEnd | ( | ) | const |
Get the radius of the arc (valid if step >= SET_START)
Definition at line 84 of file arc_geom_manager.cpp.
References m_endAngle, m_origin, m_radius, and RotatePoint().
Referenced by DRAWING_TOOL::drawArc(), updateArcFromConstructionMgr(), and KIGFX::PREVIEW::ARC_ASSISTANT::ViewDraw().
|
inlineinherited |
Get the last point added (locked in or not).
This can* be useful when drawing previews, as the point given isn't always what gets locked into the geometry, if that step doesn't have full degrees of freedom.
Definition at line 120 of file multistep_geom_manager.h.
References KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER::m_lastPoint.
Referenced by KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER::RemoveLastPoint(), KIGFX::PREVIEW::ARC_ASSISTANT::ViewDraw(), and KIGFX::PREVIEW::BEZIER_ASSISTANT::ViewDraw().
|
inlineoverridevirtual |
The highest step this manager has - used to recognize completion and to clamp the step as it advances.
Moves the manager forward or backward through the stages
Implements KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER.
Definition at line 56 of file arc_geom_manager.h.
References COMPLETE.
VECTOR2I ARC_GEOM_MANAGER::GetOrigin | ( | ) | const |
< Get the center point of the arc (valid when state > SET_ORIGIN)
Get the coordinates of the arc start
Definition at line 70 of file arc_geom_manager.cpp.
References m_origin.
Referenced by updateArcFromConstructionMgr(), and KIGFX::PREVIEW::ARC_ASSISTANT::ViewDraw().
double ARC_GEOM_MANAGER::GetRadius | ( | ) | const |
Get the angle of the vector leading to the start point (valid if step >= SET_START)
Definition at line 92 of file arc_geom_manager.cpp.
References m_radius.
Referenced by KIGFX::PREVIEW::ARC_ASSISTANT::ViewDraw().
EDA_ANGLE ARC_GEOM_MANAGER::GetStartAngle | ( | ) | const |
Get the angle of the vector leading to the end point (valid if step >= SET_ANGLE)
Definition at line 98 of file arc_geom_manager.cpp.
References ANGLE_360, m_clockwise, and m_startAngle.
Referenced by KIGFX::PREVIEW::ARC_ASSISTANT::ViewDraw().
VECTOR2I ARC_GEOM_MANAGER::GetStartRadiusEnd | ( | ) | const |
Get the coordinates of the arc end point.
Definition at line 76 of file arc_geom_manager.cpp.
References m_origin, m_radius, m_startAngle, and RotatePoint().
Referenced by DRAWING_TOOL::drawArc(), updateArcFromConstructionMgr(), and KIGFX::PREVIEW::ARC_ASSISTANT::ViewDraw().
|
inline |
Get the current step the manager is on (useful when drawing something depends on the current state)
Definition at line 65 of file arc_geom_manager.h.
References KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER::getStep().
Referenced by DRAWING_TOOL::drawArc(), and KIGFX::PREVIEW::ARC_ASSISTANT::ViewDraw().
|
inlineprotectedinherited |
Definition at line 151 of file multistep_geom_manager.h.
References KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER::m_step.
Referenced by acceptPoint(), KIGFX::PREVIEW::BEZIER_GEOM_MANAGER::acceptPoint(), GetStep(), and KIGFX::PREVIEW::BEZIER_GEOM_MANAGER::GetStep().
EDA_ANGLE ARC_GEOM_MANAGER::GetSubtended | ( | ) | const |
Definition at line 109 of file arc_geom_manager.cpp.
References ANGLE_360, m_clockwise, m_endAngle, and m_startAngle.
Referenced by setEnd(), updateArcFromConstructionMgr(), and KIGFX::PREVIEW::ARC_ASSISTANT::ViewDraw().
|
inlineinherited |
Definition at line 128 of file multistep_geom_manager.h.
References KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER::m_changed.
Referenced by DRAWING_TOOL::drawArc(), and DRAWING_TOOL::drawOneBezier().
|
inlineinherited |
Definition at line 109 of file multistep_geom_manager.h.
References KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER::getMaxStep(), and KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER::m_step.
Referenced by DRAWING_TOOL::drawArc(), and DRAWING_TOOL::drawOneBezier().
|
inlineinherited |
Definition at line 92 of file multistep_geom_manager.h.
References KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER::m_step.
Referenced by KIGFX::PREVIEW::ARC_ASSISTANT::ViewBBox(), KIGFX::PREVIEW::BEZIER_ASSISTANT::ViewBBox(), KIGFX::PREVIEW::ARC_ASSISTANT::ViewDraw(), and KIGFX::PREVIEW::BEZIER_ASSISTANT::ViewDraw().
|
inlineprivateinherited |
Has the geometry changed such that a client should redraw?
Definition at line 169 of file multistep_geom_manager.h.
References KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER::getMaxStep(), and KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER::m_step.
Referenced by KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER::AddPoint(), and KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER::RemoveLastPoint().
|
inlineinherited |
Undo the last point, and move the manager back to the previous step.
Definition at line 79 of file multistep_geom_manager.h.
References KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER::acceptPoint(), KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER::GetLastPoint(), KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER::performStep(), and KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER::setGeometryChanged().
Referenced by DRAWING_TOOL::drawArc(), and DRAWING_TOOL::drawOneBezier().
|
inlineinherited |
Reset the manager to the initial state.
Definition at line 100 of file multistep_geom_manager.h.
References KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER::m_step, and KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER::setGeometryChanged().
|
inline |
Definition at line 79 of file arc_geom_manager.h.
References m_angleSnap.
Referenced by DRAWING_TOOL::drawArc().
void ARC_GEOM_MANAGER::SetClockwise | ( | bool | aCw | ) |
Reverse the current are direction.
Definition at line 54 of file arc_geom_manager.cpp.
References m_clockwise, m_directionLocked, and KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER::setGeometryChanged().
|
private |
Definition at line 153 of file arc_geom_manager.cpp.
References std::abs(), ANGLE_0, ANGLE_360, ANGLE_90, GetSubtended(), m_angleSnap, m_clockwise, m_directionLocked, m_endAngle, m_origin, m_startAngle, and snapAngle().
Referenced by acceptPoint().
|
inlineprotectedinherited |
< Mark the geometry as changed for clients to notice
Get the current stage of the manager
Definition at line 145 of file multistep_geom_manager.h.
References KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER::m_changed.
Referenced by KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER::AddPoint(), KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER::RemoveLastPoint(), KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER::Reset(), SetClockwise(), and ToggleClockwise().
|
private |
< Set the center point of the arc
Set the end of the first radius line (arc start)
Definition at line 123 of file arc_geom_manager.cpp.
References ANGLE_0, m_endAngle, m_origin, and m_startAngle.
Referenced by acceptPoint().
|
private |
Set a point of the second radius line (collinear with arc end)
Definition at line 133 of file arc_geom_manager.cpp.
References ANGLE_0, ANGLE_360, VECTOR2< T >::EuclideanNorm(), m_angleSnap, m_endAngle, m_origin, m_radius, m_startAngle, and snapAngle().
Referenced by acceptPoint().
void ARC_GEOM_MANAGER::ToggleClockwise | ( | ) |
Set angle snapping (for the next point)
Definition at line 62 of file arc_geom_manager.cpp.
References m_clockwise, m_directionLocked, and KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER::setGeometryChanged().
Referenced by DRAWING_TOOL::drawArc().
|
private |
Definition at line 133 of file arc_geom_manager.h.
Referenced by SetAngleSnap(), setEnd(), and setStart().
|
privateinherited |
The last (raw) point added, which is usually the cursor position.
Definition at line 178 of file multistep_geom_manager.h.
Referenced by KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER::ClearGeometryChanged(), KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER::HasGeometryChanged(), and KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER::setGeometryChanged().
|
private |
Definition at line 124 of file arc_geom_manager.h.
Referenced by GetStartAngle(), GetSubtended(), SetClockwise(), setEnd(), and ToggleClockwise().
|
private |
Definition at line 134 of file arc_geom_manager.h.
Referenced by SetClockwise(), setEnd(), and ToggleClockwise().
|
private |
Definition at line 128 of file arc_geom_manager.h.
Referenced by GetEndRadiusEnd(), GetSubtended(), setEnd(), setOrigin(), and setStart().
|
privateinherited |
Definition at line 181 of file multistep_geom_manager.h.
Referenced by KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER::AddPoint(), and KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER::GetLastPoint().
|
private |
Definition at line 125 of file arc_geom_manager.h.
Referenced by GetEndRadiusEnd(), GetOrigin(), GetStartRadiusEnd(), setEnd(), setOrigin(), and setStart().
|
private |
Definition at line 126 of file arc_geom_manager.h.
Referenced by GetEndRadiusEnd(), GetRadius(), GetStartRadiusEnd(), and setStart().
|
private |
Definition at line 127 of file arc_geom_manager.h.
Referenced by GetStartAngle(), GetStartRadiusEnd(), GetSubtended(), setEnd(), setOrigin(), and setStart().
|
privateinherited |
The current manager step, from 0 to some highest number that depends on the manager.
Definition at line 186 of file multistep_geom_manager.h.
Referenced by KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER::getStep(), KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER::IsComplete(), KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER::IsReset(), KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER::performStep(), and KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER::Reset().