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

Manage the construction of a bezier through a series of steps. More...

#include <bezier_geom_manager.h>

Inheritance diagram for KIGFX::PREVIEW::BEZIER_GEOM_MANAGER:
KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER

Public Types

enum  BEZIER_STEPS {
  SET_START = 0 , SET_CONTROL1 , SET_END , SET_CONTROL2 ,
  COMPLETE
}
 

Public Member Functions

 BEZIER_GEOM_MANAGER ()
 
int getMaxStep () const override
 The highest step this manager has - used to recognize completion and to clamp the step as it advances.
 
BEZIER_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
 < Function that accepts a point for a stage, or rejects it to return to the previous stage
 
VECTOR2I GetStart () const
 < Get the center point of the arc (valid when state > SET_ORIGIN)
 
VECTOR2I GetControlC1 () const
 
VECTOR2I GetControlC2 () const
 Get the coordinates of the arc end point.
 
VECTOR2I GetEnd () 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 setStart (const VECTOR2I &aOrigin)
 < Set the center point of the arc
 
bool setControlC1 (const VECTOR2I &aControl)
 
bool setEnd (const VECTOR2I &aCursor)
 
bool setControlC2 (const VECTOR2I &aControl)
 
void performStep (bool aForward)
 Has the geometry changed such that a client should redraw?
 

Private Attributes

VECTOR2I m_start
 
VECTOR2I m_controlC1
 
VECTOR2I m_end
 
VECTOR2I m_controlC2
 
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 bezier through a series of steps.

See also KIGFX::PREVIEW::ARC_GEOM_MANAGER.

Interfaces are provided to return both arc geometry (can be used to set up real beziers on PCBs, for example) as well as important control points for informational overlays.

Definition at line 44 of file bezier_geom_manager.h.

Member Enumeration Documentation

◆ BEZIER_STEPS

Enumerator
SET_START 

Waiting to lock in the start point.

SET_CONTROL1 

Waiting to lock in the first control point.

SET_END 

Waiting to lock in the end point.

SET_CONTROL2 

Waiting to lock in the second control point.

COMPLETE 

Definition at line 49 of file bezier_geom_manager.h.

Constructor & Destructor Documentation

◆ BEZIER_GEOM_MANAGER()

KIGFX::PREVIEW::BEZIER_GEOM_MANAGER::BEZIER_GEOM_MANAGER ( )
inline

Definition at line 47 of file bezier_geom_manager.h.

Member Function Documentation

◆ acceptPoint()

bool BEZIER_GEOM_MANAGER::acceptPoint ( const VECTOR2I aPt)
overridevirtual

< 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 29 of file bezier_geom_manager.cpp.

References COMPLETE, KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER::getStep(), SET_CONTROL1, SET_CONTROL2, SET_END, SET_START, setControlC1(), setControlC2(), setEnd(), and setStart().

◆ 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.

◆ GetControlC1()

VECTOR2I BEZIER_GEOM_MANAGER::GetControlC1 ( ) const

◆ GetControlC2()

VECTOR2I BEZIER_GEOM_MANAGER::GetControlC2 ( ) const

Get the coordinates of the arc end point.

Definition at line 59 of file bezier_geom_manager.cpp.

References m_controlC2, and m_end.

Referenced by updateBezierFromConstructionMgr(), and KIGFX::PREVIEW::BEZIER_ASSISTANT::ViewDraw().

◆ GetEnd()

VECTOR2I BEZIER_GEOM_MANAGER::GetEnd ( ) const

◆ 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::BEZIER_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 58 of file bezier_geom_manager.h.

References COMPLETE.

◆ GetStart()

VECTOR2I BEZIER_GEOM_MANAGER::GetStart ( ) const

< Get the center point of the arc (valid when state > SET_ORIGIN)

Get the coordinates of the arc start

Definition at line 44 of file bezier_geom_manager.cpp.

References m_start.

Referenced by updateBezierFromConstructionMgr(), and KIGFX::PREVIEW::BEZIER_ASSISTANT::ViewDraw().

◆ GetStep()

BEZIER_STEPS KIGFX::PREVIEW::BEZIER_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 64 of file bezier_geom_manager.h.

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

Referenced by DRAWING_TOOL::drawOneBezier(), and KIGFX::PREVIEW::BEZIER_ASSISTANT::ViewDraw().

◆ getStep()

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

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

◆ setControlC1()

bool BEZIER_GEOM_MANAGER::setControlC1 ( const VECTOR2I aControl)
private

Definition at line 77 of file bezier_geom_manager.cpp.

References m_controlC1, m_controlC2, and m_end.

Referenced by acceptPoint().

◆ setControlC2()

bool BEZIER_GEOM_MANAGER::setControlC2 ( const VECTOR2I aControl)
private

Definition at line 93 of file bezier_geom_manager.cpp.

References m_controlC2.

Referenced by acceptPoint().

◆ setEnd()

bool BEZIER_GEOM_MANAGER::setEnd ( const VECTOR2I aCursor)
private

Definition at line 86 of file bezier_geom_manager.cpp.

References m_controlC2, m_end, and m_start.

Referenced by acceptPoint().

◆ setGeometryChanged()

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

◆ setStart()

bool BEZIER_GEOM_MANAGER::setStart ( const VECTOR2I aOrigin)
private

< Set the center point of the arc

Definition at line 66 of file bezier_geom_manager.cpp.

References m_controlC1, m_controlC2, m_end, and m_start.

Referenced by acceptPoint().

Member Data Documentation

◆ m_changed

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

◆ m_controlC1

VECTOR2I KIGFX::PREVIEW::BEZIER_GEOM_MANAGER::m_controlC1
private

Definition at line 97 of file bezier_geom_manager.h.

Referenced by GetControlC1(), setControlC1(), and setStart().

◆ m_controlC2

VECTOR2I KIGFX::PREVIEW::BEZIER_GEOM_MANAGER::m_controlC2
private

Definition at line 99 of file bezier_geom_manager.h.

Referenced by GetControlC2(), setControlC1(), setControlC2(), setEnd(), and setStart().

◆ m_end

VECTOR2I KIGFX::PREVIEW::BEZIER_GEOM_MANAGER::m_end
private

Definition at line 98 of file bezier_geom_manager.h.

Referenced by GetControlC2(), GetEnd(), setControlC1(), setEnd(), and setStart().

◆ m_lastPoint

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

◆ m_start

VECTOR2I KIGFX::PREVIEW::BEZIER_GEOM_MANAGER::m_start
private

Definition at line 96 of file bezier_geom_manager.h.

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

◆ m_step

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

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