KiCad PCB EDA Suite
Loading...
Searching...
No Matches
KIGFX::PREVIEW::ARC_GEOM_MANAGER Class Reference

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>

Inheritance diagram for KIGFX::PREVIEW::ARC_GEOM_MANAGER:
KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER

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.
 

Detailed Description

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.

Member Enumeration Documentation

◆ ARC_STEPS

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.

Constructor & Destructor Documentation

◆ ARC_GEOM_MANAGER()

KIGFX::PREVIEW::ARC_GEOM_MANAGER::ARC_GEOM_MANAGER ( )
inline

Definition at line 45 of file arc_geom_manager.h.

Member Function Documentation

◆ acceptPoint()

bool ARC_GEOM_MANAGER::acceptPoint ( const VECTOR2I aPt)
overridevirtual

◆ AddPoint()

void KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER::AddPoint ( const VECTOR2I aPt,
bool  aLockIn 
)
inlineinherited

Add a point to the construction manager.

Parameters
aPtthe new point
aLockInwhether 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().

◆ ClearGeometryChanged()

void KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER::ClearGeometryChanged ( )
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.

◆ GetEndRadiusEnd()

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().

◆ GetLastPoint()

VECTOR2I KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER::GetLastPoint ( ) const
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().

◆ getMaxStep()

int KIGFX::PREVIEW::ARC_GEOM_MANAGER::getMaxStep ( ) const
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.

◆ GetOrigin()

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().

◆ GetRadius()

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().

◆ GetStartAngle()

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().

◆ GetStartRadiusEnd()

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().

◆ GetStep()

ARC_STEPS KIGFX::PREVIEW::ARC_GEOM_MANAGER::GetStep ( ) const
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().

◆ getStep()

int KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER::getStep ( ) const
inlineprotectedinherited

◆ GetSubtended()

EDA_ANGLE ARC_GEOM_MANAGER::GetSubtended ( ) const

◆ HasGeometryChanged()

bool KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER::HasGeometryChanged ( ) const
inlineinherited
Returns
true if the geometry has changed, eg such that a client should redraw.

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().

◆ IsComplete()

bool KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER::IsComplete ( ) const
inlineinherited
Returns
true if the manager reached the final state.

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().

◆ IsReset()

bool KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER::IsReset ( ) const
inlineinherited

◆ performStep()

void KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER::performStep ( bool  aForward)
inlineprivateinherited

◆ RemoveLastPoint()

void KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER::RemoveLastPoint ( )
inlineinherited

◆ Reset()

void KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER::Reset ( )
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().

◆ SetAngleSnap()

void KIGFX::PREVIEW::ARC_GEOM_MANAGER::SetAngleSnap ( bool  aSnap)
inline

Definition at line 79 of file arc_geom_manager.h.

References m_angleSnap.

Referenced by DRAWING_TOOL::drawArc().

◆ SetClockwise()

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().

◆ setEnd()

bool ARC_GEOM_MANAGER::setEnd ( const VECTOR2I aCursor)
private

◆ setGeometryChanged()

void KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER::setGeometryChanged ( )
inlineprotectedinherited

◆ setOrigin()

bool ARC_GEOM_MANAGER::setOrigin ( const VECTOR2I aOrigin)
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().

◆ setStart()

bool ARC_GEOM_MANAGER::setStart ( const VECTOR2I aEnd)
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().

◆ ToggleClockwise()

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().

Member Data Documentation

◆ m_angleSnap

bool KIGFX::PREVIEW::ARC_GEOM_MANAGER::m_angleSnap = false
private

Definition at line 133 of file arc_geom_manager.h.

Referenced by SetAngleSnap(), setEnd(), and setStart().

◆ m_changed

bool KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER::m_changed = false
privateinherited

◆ m_clockwise

bool KIGFX::PREVIEW::ARC_GEOM_MANAGER::m_clockwise = true
private

◆ m_directionLocked

bool KIGFX::PREVIEW::ARC_GEOM_MANAGER::m_directionLocked = false
private

Definition at line 134 of file arc_geom_manager.h.

Referenced by SetClockwise(), setEnd(), and ToggleClockwise().

◆ m_endAngle

EDA_ANGLE KIGFX::PREVIEW::ARC_GEOM_MANAGER::m_endAngle
private

Definition at line 128 of file arc_geom_manager.h.

Referenced by GetEndRadiusEnd(), GetSubtended(), setEnd(), setOrigin(), and setStart().

◆ m_lastPoint

VECTOR2I KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER::m_lastPoint
privateinherited

◆ m_origin

VECTOR2I KIGFX::PREVIEW::ARC_GEOM_MANAGER::m_origin
private

◆ m_radius

double KIGFX::PREVIEW::ARC_GEOM_MANAGER::m_radius = 0.0
private

Definition at line 126 of file arc_geom_manager.h.

Referenced by GetEndRadiusEnd(), GetRadius(), GetStartRadiusEnd(), and setStart().

◆ m_startAngle

EDA_ANGLE KIGFX::PREVIEW::ARC_GEOM_MANAGER::m_startAngle
private

◆ m_step

int KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER::m_step = 0
privateinherited

The documentation for this class was generated from the following files: