Engauge Digitizer  2
 All Classes Files Functions Variables Enumerations Enumerator Friends Pages
TransformationStateContext.cpp
1 #include "CmdMediator.h"
2 #include "EngaugeAssert.h"
3 #include "Logger.h"
4 #include <QGraphicsScene>
5 #include <QImage>
6 #include "TransformationStateAbstractBase.h"
7 #include "TransformationStateContext.h"
8 #include "TransformationStateDefined.h"
9 #include "TransformationStateUndefined.h"
10 
12  bool isGnuplot) :
13  m_isGnuplot (isGnuplot)
14 {
15  m_states.insert (TRANSFORMATION_STATE_DEFINED , new TransformationStateDefined (*this, scene));
16  m_states.insert (TRANSFORMATION_STATE_UNDEFINED, new TransformationStateUndefined (*this, scene));
17  ENGAUGE_ASSERT (m_states.size () == NUM_TRANSFORMATION_STATES);
18 
19  m_currentState = NUM_TRANSFORMATION_STATES; // Value that forces a transition right away
20 }
21 
22 TransformationStateContext::~TransformationStateContext()
23 {
24 }
25 
27 {
28  return m_isGnuplot;
29 }
30 
32 {
33  LOG4CPP_INFO_S ((*mainCat)) << "TransformationStateContext::resetOnLoad";
34 
35  m_currentState = NUM_TRANSFORMATION_STATES;
36 }
37 
38 void TransformationStateContext::triggerStateTransition (TransformationState transformationState,
39  CmdMediator &cmdMediator,
40  const Transformation &transformation,
41  const QString &selectedGraphCurve)
42 {
43  LOG4CPP_INFO_S ((*mainCat)) << "TransformationStateContext::triggerStateTransition";
44 
45  // Transition if we are not already at the requested state
46  if (transformationState != m_currentState) {
47 
48  // End the current state if there is one
49  if (m_currentState != NUM_TRANSFORMATION_STATES) {
50  m_states[m_currentState]->end(cmdMediator,
51  transformation);
52  }
53 
54  m_currentState = transformationState;
55 
56  // Start the requested state
57  m_states[m_currentState]->begin(cmdMediator,
58  transformation,
59  selectedGraphCurve);
60  }
61 }
62 
64  const Transformation &transformation)
65 {
66  LOG4CPP_INFO_S ((*mainCat)) << "TransformationStateContext::updateAxesChecker";
67 
68  // Skip if there is no image so the state has not yet been set yet
69  if (m_currentState < NUM_TRANSFORMATION_STATES) {
70 
71  m_states[m_currentState]->updateAxesChecker (cmdMediator,
72  transformation);
73 
74  }
75 }
Class to show transformation since transformation is defined.
void triggerStateTransition(TransformationState transformationState, CmdMediator &cmdMediator, const Transformation &transformation, const QString &selectedGraphCurve)
Trigger a state transition to be performed immediately.
Class to not show transformation since transformation is undefined.
bool isGnuplot() const
Flag for gnuplot debug files.
Affine transformation between screen and graph coordinates, based on digitized axis points...
void resetOnLoad()
Reset, when loading a document after the first, to same state that first document was at when loaded...
Command queue stack.
Definition: CmdMediator.h:16
TransformationStateContext(QGraphicsScene &scene, bool isGnuplot)
Single constructor.
void updateAxesChecker(CmdMediator &cmdMediator, const Transformation &transformation)
Apply the new DocumentModelAxesChecker.