Engauge Digitizer 2
Loading...
Searching...
No Matches
CentipedeStateContext Class Reference

State context class for tracking the steps involved in creating centipedes in preparation for creating a guideline. More...

#include <CentipedeStateContext.h>

Collaboration diagram for CentipedeStateContext:
Collaboration graph

Public Member Functions

 CentipedeStateContext (DigitizeStateGuideline &stateGuideline)
 Single constructor.
virtual ~CentipedeStateContext ()
void createGuidelineCommand (bool selectedXTFinal, double valueFinal)
 Create a command for creating a Guideline.
GraphicsScenegraphicsScene () const
 Get method for forwarded GraphicsScene.
virtual void handleKeyPress (Qt::Key key, bool atLeastOneSelectedItem)
virtual void handleMouseMove (QPointF posScreen)
virtual void handleMousePress (GraphicsScene *scene, const Transformation &transformation, const DocumentModelGuideline &modelGuideline, const DocumentModelCoords &modelCoords, QPointF posScreen, bool clickedOnItem)
virtual void handleMouseRelease (QPointF posScreen)
DocumentModelCoords modelCoords () const
 Get method for forwarded DocumentModelCoords.
DocumentModelGuideline modelGuideline () const
 Get method for forwarded DocumentModelGuideline.
QPointF posClickScreen () const
 Get method for forwarded click point.
void requestDelayedStateTransition (CentipedeState centipedeState)
 Initiate state transition to be performed later, when CentipedeState is off the stack.
void requestImmediateStateTransition (CentipedeState centipedeState)
 Perform immediate state transition for immediate action. Called when states are off the stack.
GraphicsScenescene () const
 Get method for forwarded GraphicsScene.
Transformation transformation () const
 Get method for forwarded Transformation.

Detailed Description

State context class for tracking the steps involved in creating centipedes in preparation for creating a guideline.

Definition at line 25 of file CentipedeStateContext.h.

Constructor & Destructor Documentation

◆ CentipedeStateContext()

CentipedeStateContext::CentipedeStateContext ( DigitizeStateGuideline & stateGuideline)

Single constructor.

Definition at line 22 of file CentipedeStateContext.cpp.

22 :
23 m_stateGuideline (stateGuideline),
24 m_scene (nullptr),
25 m_transformation (nullptr)
26{
27 // These states follow the same order as the CentipedeState enumeration
28 m_states.insert (CENTIPEDE_STATE_BUILD_CARTESIAN, new CentipedeStateBuildCartesian (*this));
29 m_states.insert (CENTIPEDE_STATE_BUILD_POLAR , new CentipedeStateBuildPolar (*this));
30 m_states.insert (CENTIPEDE_STATE_PREBUILD , new CentipedeStatePrebuild (*this));
31 ENGAUGE_ASSERT (m_states.size () == NUM_CENTIPEDE_STATES);
32
33 m_currentState = NUM_CENTIPEDE_STATES; // Value that forces a transition right away
35}
@ NUM_CENTIPEDE_STATES
@ CENTIPEDE_STATE_BUILD_CARTESIAN
@ CENTIPEDE_STATE_PREBUILD
@ CENTIPEDE_STATE_BUILD_POLAR
#define ENGAUGE_ASSERT(cond)
Drop in replacement for Q_ASSERT.
void requestImmediateStateTransition(CentipedeState centipedeState)
Perform immediate state transition for immediate action. Called when states are off the stack.

◆ ~CentipedeStateContext()

CentipedeStateContext::~CentipedeStateContext ( )
virtual

Definition at line 37 of file CentipedeStateContext.cpp.

38{
39 // Remove states, one of which may have incomplete in-work graphics items
40 QVector<CentipedeStateAbstractBase*>::iterator itr;
41 for (itr = m_states.begin (); itr != m_states.end (); itr++) {
42 CentipedeStateAbstractBase *state = *itr;
43 delete state;
44 }
45
46 m_states.clear();
47
48 delete m_scene;
49 delete m_transformation;
50}

Member Function Documentation

◆ createGuidelineCommand()

void CentipedeStateContext::createGuidelineCommand ( bool selectedXTFinal,
double valueFinal )

Create a command for creating a Guideline.

Definition at line 70 of file CentipedeStateContext.cpp.

72{
73 m_stateGuideline.createGuidelineCommand (selectedXT,
74 selectedValue);
75}

◆ graphicsScene()

GraphicsScene * CentipedeStateContext::graphicsScene ( ) const

Get method for forwarded GraphicsScene.

◆ handleKeyPress()

void CentipedeStateContext::handleKeyPress ( Qt::Key key,
bool atLeastOneSelectedItem )
virtual

Definition at line 77 of file CentipedeStateContext.cpp.

79{
80 m_states [m_currentState]->handleKeyPress (key,
81 atLeastOneSelectedItem);
82
83 completeRequestedStateTransitionIfExists();
84
85}

◆ handleMouseMove()

void CentipedeStateContext::handleMouseMove ( QPointF posScreen)
virtual

Definition at line 87 of file CentipedeStateContext.cpp.

88{
89 m_states [m_currentState]->handleMouseMove (pos);
90
91 completeRequestedStateTransitionIfExists();
92
93}

◆ handleMousePress()

void CentipedeStateContext::handleMousePress ( GraphicsScene * scene,
const Transformation & transformation,
const DocumentModelGuideline & modelGuideline,
const DocumentModelCoords & modelCoords,
QPointF posScreen,
bool clickedOnItem )
virtual

Definition at line 95 of file CentipedeStateContext.cpp.

101{
102 // If a graphics item can be, or was, selected then do not create a new CentipedePair (by
103 // skipping the state transition
104 if (!clickedOnItem) {
105
106 // Forward context variables
107 m_scene = scene;
108 m_transformation = new Transformation (transformation);
109 m_modelGuideline = modelGuideline;
110 m_modelCoords = modelCoords;
111 m_posClickScreen = pos;
112
113 m_states [m_currentState]->handleMousePress (pos);
114
115 completeRequestedStateTransitionIfExists();
116 }
117}
DocumentModelCoords modelCoords() const
Get method for forwarded DocumentModelCoords.
GraphicsScene & scene() const
Get method for forwarded GraphicsScene.
DocumentModelGuideline modelGuideline() const
Get method for forwarded DocumentModelGuideline.
Transformation transformation() const
Get method for forwarded Transformation.

◆ handleMouseRelease()

void CentipedeStateContext::handleMouseRelease ( QPointF posScreen)
virtual

Definition at line 119 of file CentipedeStateContext.cpp.

120{
121 m_states [m_currentState]->handleMouseRelease (pos);
122
123 completeRequestedStateTransitionIfExists();
124}

◆ modelCoords()

DocumentModelCoords CentipedeStateContext::modelCoords ( ) const

Get method for forwarded DocumentModelCoords.

Definition at line 126 of file CentipedeStateContext.cpp.

127{
128 return m_modelCoords;
129}

◆ modelGuideline()

DocumentModelGuideline CentipedeStateContext::modelGuideline ( ) const

Get method for forwarded DocumentModelGuideline.

Definition at line 131 of file CentipedeStateContext.cpp.

132{
133 return m_modelGuideline;
134}

◆ posClickScreen()

QPointF CentipedeStateContext::posClickScreen ( ) const

Get method for forwarded click point.

Definition at line 136 of file CentipedeStateContext.cpp.

137{
138 return m_posClickScreen;
139}

◆ requestDelayedStateTransition()

void CentipedeStateContext::requestDelayedStateTransition ( CentipedeState centipedeState)

Initiate state transition to be performed later, when CentipedeState is off the stack.

Definition at line 141 of file CentipedeStateContext.cpp.

142{
143 m_requestedState = centipedeState;
144}

◆ requestImmediateStateTransition()

void CentipedeStateContext::requestImmediateStateTransition ( CentipedeState centipedeState)

Perform immediate state transition for immediate action. Called when states are off the stack.

Definition at line 146 of file CentipedeStateContext.cpp.

147{
148 m_requestedState = centipedeState;
149 completeRequestedStateTransitionIfExists();
150}

◆ scene()

GraphicsScene & CentipedeStateContext::scene ( ) const

Get method for forwarded GraphicsScene.

Definition at line 152 of file CentipedeStateContext.cpp.

153{
154 return *m_scene;
155}

◆ transformation()

Transformation CentipedeStateContext::transformation ( ) const

Get method for forwarded Transformation.

Definition at line 157 of file CentipedeStateContext.cpp.

158{
159 return *m_transformation;
160}

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