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

Manage the construction of an elliptical arc through sequential setting of critical points: two bounding-box corners (to define the ellipse), then start and end angles on the ellipse. More...

#include <ellipse_geom_manager.h>

Inheritance diagram for KIGFX::PREVIEW::ELLIPSE_GEOM_MANAGER:
KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER

Public Types

enum  ELLIPSE_STEPS {
  SET_BBOX_C1 = 0 , SET_BBOX_C2 , SET_START_ANGLE , SET_END_ANGLE ,
  COMPLETE
}
 

Public Member Functions

 ELLIPSE_GEOM_MANAGER ()
 
int getMaxStep () const override
 The highest step this manager has - used to recognize completion and to clamp the step as it advances.
 
ELLIPSE_STEPS GetStep () const
 
ELLIPSE< int > GetEllipse () const
 Get the ellipse defined by the current geometry (valid after SET_BBOX_C2).
 
EDA_ANGLE GetStartAngle () const
 Get the end angle (valid after SET_END_ANGLE). Always > startAngle.
 
EDA_ANGLE GetEndAngle () const
 Get the first bbox corner (valid after SET_BBOX_C1).
 
VECTOR2I GetBboxCorner1 () const
 Get the second bbox corner (valid after SET_BBOX_C2).
 
VECTOR2I GetBboxCorner2 () 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

bool acceptPoint (const VECTOR2I &aPt) override
 < Function that accepts a point for a stage, or rejects it to return to the previous stage
 
void setGeometryChanged ()
 < Mark the geometry as changed for clients to notice
 
int getStep () const
 

Private Member Functions

bool setBboxCorner1 (const VECTOR2I &aPt)
 
bool setBboxCorner2 (const VECTOR2I &aPt)
 
bool setStartAngle (const VECTOR2I &aPt)
 
bool setEndAngle (const VECTOR2I &aPt)
 
void performStep (bool aForward)
 Has the geometry changed such that a client should redraw?
 

Private Attributes

VECTOR2I m_bboxC1
 
VECTOR2I m_bboxC2
 
VECTOR2I m_center
 
double m_majorRadius = 1.0
 
double m_minorRadius = 1.0
 
EDA_ANGLE m_rotation = ANGLE_0
 
EDA_ANGLE m_startAngle = ANGLE_0
 
EDA_ANGLE m_endAngle = ANGLE_360
 
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 an elliptical arc through sequential setting of critical points: two bounding-box corners (to define the ellipse), then start and end angles on the ellipse.

The manager is driven by setting cursor points, which update the geometry and optionally advance the manager state.

Definition at line 40 of file ellipse_geom_manager.h.

Member Enumeration Documentation

◆ ELLIPSE_STEPS

Enumerator
SET_BBOX_C1 

Waiting to lock in first bbox corner.

SET_BBOX_C2 

Waiting to lock in second bbox corner.

SET_START_ANGLE 

Waiting to lock in the start angle.

SET_END_ANGLE 

Waiting to lock in the end angle.

COMPLETE 

Definition at line 45 of file ellipse_geom_manager.h.

Constructor & Destructor Documentation

◆ ELLIPSE_GEOM_MANAGER()

KIGFX::PREVIEW::ELLIPSE_GEOM_MANAGER::ELLIPSE_GEOM_MANAGER ( )
inline

Definition at line 43 of file ellipse_geom_manager.h.

Member Function Documentation

◆ acceptPoint()

bool ELLIPSE_GEOM_MANAGER::acceptPoint ( const VECTOR2I & aPt)
overrideprotectedvirtual

< Function that accepts a point for a stage, or rejects it to return to the previous stage

Implements KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER.

Definition at line 28 of file ellipse_geom_manager.cpp.

References COMPLETE, GetStep(), SET_BBOX_C1, SET_BBOX_C2, SET_END_ANGLE, SET_START_ANGLE, setBboxCorner1(), setBboxCorner2(), setEndAngle(), and setStartAngle().

◆ 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 57 of file multistep_geom_manager.h.

References acceptPoint(), m_lastPoint, performStep(), and setGeometryChanged().

◆ 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 133 of file multistep_geom_manager.h.

References m_changed.

◆ GetBboxCorner1()

VECTOR2I KIGFX::PREVIEW::ELLIPSE_GEOM_MANAGER::GetBboxCorner1 ( ) const
inline

Get the second bbox corner (valid after SET_BBOX_C2).

Definition at line 77 of file ellipse_geom_manager.h.

References m_bboxC1.

◆ GetBboxCorner2()

VECTOR2I KIGFX::PREVIEW::ELLIPSE_GEOM_MANAGER::GetBboxCorner2 ( ) const
inline

Definition at line 80 of file ellipse_geom_manager.h.

References m_bboxC2.

◆ GetEllipse()

ELLIPSE< int > ELLIPSE_GEOM_MANAGER::GetEllipse ( ) const

Get the ellipse defined by the current geometry (valid after SET_BBOX_C2).

Until the angles are set, the ellipse is considered to be a full ellipse. After the angles are set, the ellipse is considered to be an arc segment. Get the start angle (valid after SET_START_ANGLE).

Definition at line 112 of file ellipse_geom_manager.cpp.

References m_center, m_endAngle, m_majorRadius, m_minorRadius, m_rotation, and m_startAngle.

◆ GetEndAngle()

EDA_ANGLE KIGFX::PREVIEW::ELLIPSE_GEOM_MANAGER::GetEndAngle ( ) const
inline

Get the first bbox corner (valid after SET_BBOX_C1).

Definition at line 74 of file ellipse_geom_manager.h.

References m_endAngle.

◆ 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 116 of file multistep_geom_manager.h.

References m_lastPoint.

Referenced by RemoveLastPoint().

◆ getMaxStep()

int KIGFX::PREVIEW::ELLIPSE_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 54 of file ellipse_geom_manager.h.

References COMPLETE.

◆ GetStartAngle()

EDA_ANGLE KIGFX::PREVIEW::ELLIPSE_GEOM_MANAGER::GetStartAngle ( ) const
inline

Get the end angle (valid after SET_END_ANGLE). Always > startAngle.

Definition at line 71 of file ellipse_geom_manager.h.

References m_startAngle.

◆ GetStep()

ELLIPSE_STEPS KIGFX::PREVIEW::ELLIPSE_GEOM_MANAGER::GetStep ( ) const
inline

Definition at line 56 of file ellipse_geom_manager.h.

References KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER::getStep().

Referenced by acceptPoint().

◆ getStep()

◆ 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 124 of file multistep_geom_manager.h.

References m_changed.

◆ IsComplete()

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

Definition at line 105 of file multistep_geom_manager.h.

References getMaxStep(), and m_step.

◆ IsReset()

bool KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER::IsReset ( ) const
inlineinherited
Returns
true if the manager is in the initial state

Definition at line 88 of file multistep_geom_manager.h.

References m_step.

◆ performStep()

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

Has the geometry changed such that a client should redraw?

Definition at line 165 of file multistep_geom_manager.h.

References getMaxStep(), and m_step.

Referenced by AddPoint(), and RemoveLastPoint().

◆ RemoveLastPoint()

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

Undo the last point, and move the manager back to the previous step.

Definition at line 75 of file multistep_geom_manager.h.

References acceptPoint(), GetLastPoint(), performStep(), and setGeometryChanged().

◆ Reset()

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

Reset the manager to the initial state.

Definition at line 96 of file multistep_geom_manager.h.

References m_step, and setGeometryChanged().

◆ setBboxCorner1()

bool ELLIPSE_GEOM_MANAGER::setBboxCorner1 ( const VECTOR2I & aPt)
private

Definition at line 45 of file ellipse_geom_manager.cpp.

References m_bboxC1, and m_bboxC2.

Referenced by acceptPoint().

◆ setBboxCorner2()

bool ELLIPSE_GEOM_MANAGER::setBboxCorner2 ( const VECTOR2I & aPt)
private

◆ setEndAngle()

bool ELLIPSE_GEOM_MANAGER::setEndAngle ( const VECTOR2I & aPt)
private

◆ setGeometryChanged()

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

< Mark the geometry as changed for clients to notice

Get the current stage of the manager

Definition at line 141 of file multistep_geom_manager.h.

References m_changed.

Referenced by AddPoint(), RemoveLastPoint(), Reset(), KIGFX::PREVIEW::ARC_GEOM_MANAGER::SetClockwise(), and KIGFX::PREVIEW::ARC_GEOM_MANAGER::ToggleClockwise().

◆ setStartAngle()

bool ELLIPSE_GEOM_MANAGER::setStartAngle ( const VECTOR2I & aPt)
private

Member Data Documentation

◆ m_bboxC1

VECTOR2I KIGFX::PREVIEW::ELLIPSE_GEOM_MANAGER::m_bboxC1
private

Definition at line 91 of file ellipse_geom_manager.h.

Referenced by GetBboxCorner1(), setBboxCorner1(), and setBboxCorner2().

◆ m_bboxC2

VECTOR2I KIGFX::PREVIEW::ELLIPSE_GEOM_MANAGER::m_bboxC2
private

Definition at line 92 of file ellipse_geom_manager.h.

Referenced by GetBboxCorner2(), setBboxCorner1(), and setBboxCorner2().

◆ m_center

VECTOR2I KIGFX::PREVIEW::ELLIPSE_GEOM_MANAGER::m_center
private

Definition at line 93 of file ellipse_geom_manager.h.

Referenced by GetEllipse(), setBboxCorner2(), setEndAngle(), and setStartAngle().

◆ m_changed

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

The last (raw) point added, which is usually the cursor position.

Definition at line 174 of file multistep_geom_manager.h.

Referenced by ClearGeometryChanged(), HasGeometryChanged(), and setGeometryChanged().

◆ m_endAngle

EDA_ANGLE KIGFX::PREVIEW::ELLIPSE_GEOM_MANAGER::m_endAngle = ANGLE_360
private

◆ m_lastPoint

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

Definition at line 177 of file multistep_geom_manager.h.

Referenced by AddPoint(), and GetLastPoint().

◆ m_majorRadius

double KIGFX::PREVIEW::ELLIPSE_GEOM_MANAGER::m_majorRadius = 1.0
private

Definition at line 94 of file ellipse_geom_manager.h.

Referenced by GetEllipse(), setBboxCorner2(), setEndAngle(), and setStartAngle().

◆ m_minorRadius

double KIGFX::PREVIEW::ELLIPSE_GEOM_MANAGER::m_minorRadius = 1.0
private

Definition at line 95 of file ellipse_geom_manager.h.

Referenced by GetEllipse(), setBboxCorner2(), setEndAngle(), and setStartAngle().

◆ m_rotation

EDA_ANGLE KIGFX::PREVIEW::ELLIPSE_GEOM_MANAGER::m_rotation = ANGLE_0
private

Definition at line 96 of file ellipse_geom_manager.h.

Referenced by GetEllipse(), setBboxCorner2(), setEndAngle(), and setStartAngle().

◆ m_startAngle

EDA_ANGLE KIGFX::PREVIEW::ELLIPSE_GEOM_MANAGER::m_startAngle = ANGLE_0
private

◆ m_step

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

The current manager step, from 0 to some highest number that depends on the manager.

Definition at line 182 of file multistep_geom_manager.h.

Referenced by getStep(), IsComplete(), IsReset(), performStep(), and Reset().


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