7 #include "CmdMediator.h" 8 #include "DigitizeStateAxis.h" 9 #include "DigitizeStateColorPicker.h" 10 #include "DigitizeStateContext.h" 11 #include "DigitizeStateCurve.h" 12 #include "DigitizeStateEmpty.h" 13 #include "DigitizeStatePointMatch.h" 14 #include "DigitizeStateScale.h" 15 #include "DigitizeStateSegment.h" 16 #include "DigitizeStateSelect.h" 17 #include "DocumentModelSegments.h" 18 #include "EngaugeAssert.h" 19 #include "GraphicsScene.h" 20 #include "GraphicsView.h" 22 #include "MainWindow.h" 24 #include <QGraphicsScene> 25 #include <QGraphicsView> 27 #include "QtToString.h" 28 #include "Transformation.h" 33 m_mainWindow (mainWindow),
35 m_imageIsLoaded (false),
36 m_isGnuplot (isGnuplot)
47 ENGAUGE_ASSERT (m_states.size () == NUM_DIGITIZE_STATES);
49 m_currentState = NUM_DIGITIZE_STATES;
51 DIGITIZE_STATE_EMPTY);
54 DigitizeStateContext::~DigitizeStateContext()
56 qDeleteAll (m_states);
61 return m_states [m_currentState]->activeCurve ();
67 LOG4CPP_INFO_S ((*mainCat)) <<
"DigitizeStateContext::appendNewCmd";
69 cmdMediator->push (cmd);
73 const QSize &size)
const 75 return m_states [m_currentState]->canPaste (transformation,
79 void DigitizeStateContext::completeRequestedStateTransitionIfExists (
CmdMediator *cmdMediator)
81 if (m_currentState != m_requestedState) {
85 if (m_currentState != NUM_DIGITIZE_STATES) {
88 m_states [m_currentState]->end ();
92 DigitizeState previousState = m_currentState;
93 m_currentState = m_requestedState;
94 m_states [m_requestedState]->begin (cmdMediator,
104 const QString &pointIdentifier)
106 m_states [m_currentState]->handleContextMenuEventAxis (cmdMediator,
111 const QStringList &pointIdentifiers)
113 m_states [m_currentState]->handleContextMenuEventGraph (cmdMediator,
119 m_states [m_currentState]->handleCurveChange(cmdMediator);
124 bool atLeastOneSelectedItem)
126 m_states [m_currentState]->handleKeyPress (cmdMediator,
128 atLeastOneSelectedItem);
130 completeRequestedStateTransitionIfExists(cmdMediator);
137 m_states [m_currentState]->handleMouseMove (cmdMediator,
140 completeRequestedStateTransitionIfExists(cmdMediator);
147 m_states [m_currentState]->handleMousePress (cmdMediator,
150 completeRequestedStateTransitionIfExists(cmdMediator);
157 m_states [m_currentState]->handleMouseRelease (cmdMediator,
160 completeRequestedStateTransitionIfExists(cmdMediator);
180 m_requestedState = digitizeState;
184 DigitizeState digitizeState)
186 m_requestedState = digitizeState;
187 completeRequestedStateTransitionIfExists(cmdMediator);
192 LOG4CPP_INFO_S ((*mainCat)) <<
"DigitizeStateContext::resetOnLoad";
196 if (m_currentState != DIGITIZE_STATE_EMPTY) {
197 m_requestedState = DIGITIZE_STATE_EMPTY;
198 completeRequestedStateTransitionIfExists(cmdMediator);
204 LOG4CPP_INFO_S ((*mainCat)) <<
"DigitizeStateContext::setCursor";
206 ENGAUGE_ASSERT(m_currentState < m_states.count());
208 m_states [m_currentState]->setCursor (cmdMediator);
213 LOG4CPP_DEBUG_S ((*mainCat)) <<
"DigitizeStateContext::setDragMode";
215 if (m_imageIsLoaded) {
216 m_view.setDragMode (dragMode);
223 LOG4CPP_INFO_S ((*mainCat)) <<
"DigitizeStateContext::setImageIsLoaded";
225 m_imageIsLoaded = imageIsLoaded;
231 ENGAUGE_ASSERT (m_currentState != NUM_DIGITIZE_STATES);
233 return m_states [m_currentState]->state();
238 ENGAUGE_ASSERT (m_currentState != NUM_DIGITIZE_STATES);
240 m_states [m_currentState]->updateAfterPointAddition ();
246 LOG4CPP_INFO_S ((*mainCat)) <<
"DigitizeStateContext::updateModelDigitizeCurve";
248 ENGAUGE_ASSERT(m_currentState < m_states.count());
250 m_states [m_currentState]->updateModelDigitizeCurve (cmdMediator,
256 LOG4CPP_INFO_S ((*mainCat)) <<
"DigitizeStateContext::updateModelSegments";
258 ENGAUGE_ASSERT(m_currentState < m_states.count());
260 m_states [m_currentState]->updateModelSegments (modelSegments);
void requestDelayedStateTransition(DigitizeState digitizeState)
Initiate state transition to be performed later, when DigitizeState is off the stack.
void updateAfterPointAddition()
Update the graphics attributes.
void resetOnLoad(CmdMediator *cmdMediator)
Resetting makes re-initializes for documents after the first.
Digitizing state for creating the scale bar.
void updateDigitizeStateIfSoftwareTriggered(DigitizeState digitizeState)
After software-triggered state transition, this method manually triggers the action as if user had cl...
void setDragMode(QGraphicsView::DragMode dragMode)
Set QGraphicsView drag mode (in m_view). Called from DigitizeStateAbstractBase subclasses.
void updateModelDigitizeCurve(CmdMediator *cmdMediator, const DocumentModelDigitizeCurve &modelDigitizeCurve)
Update the digitize curve settings.
void handleContextMenuEventAxis(CmdMediator *cmdMediator, const QString &pointIdentifier)
See DigitizeStateAbstractBase::handleContextMenuEventAxis.
void setCursor(CmdMediator *cmdMediator)
Set cursor after asking state for the new cursor shape.
Digitizing state for selecting a color for DigitizeStateSegment.
void handleCurveChange(CmdMediator *cmdMediator)
See DigitizeStateAbstractBase::handleCurveChange.
void handleContextMenuEventGraph(CmdMediator *cmdMediator, const QStringList &pointIdentifiers)
See DigitizeStateAbstractBase::handleContextMenuEventGraph.
QString state() const
State name for debugging.
bool isGnuplot() const
Get method for gnuplot flag.
QString activeCurve() const
Curve name for active Curve. This can include AXIS_CURVE_NAME, and empty string.
Digitizing state before a Document has been created. In this state, the cursor is Qt::ArrowCursor.
CmdMediator * cmdMediator()
Accessor for commands to process the Document.
void handleKeyPress(CmdMediator *cmdMediator, Qt::Key key, bool atLeastOneSelectedItem)
See DigitizeStateAbstractBase::handleKeyPress.
MainWindow & mainWindow()
Reference to the MainWindow, without const.
void setImageIsLoaded(CmdMediator *cmdMediator, bool imageIsLoaded)
Set the image so QGraphicsView cursor and drag mode are accessible.
Digitizing state for matching Curve Points, one at a time.
Model for DlgSettingsDigitizeCurve and CmdSettingsDigitizeCurve.
Digitizing state for selecting one or more Points in the Document.
void appendNewCmd(CmdMediator *cmdMediator, QUndoCommand *cmd)
Append just-created QUndoCommand to command stack. This is called from DigitizeStateAbstractBase subc...
DigitizeStateContext(MainWindow &mainWindow, QGraphicsView &view, bool isGnuplot)
Single constructor.
void updateModelSegments(const DocumentModelSegments &modelSegments)
Update the segments given the new settings.
bool canPaste(const Transformation &transformation, const QSize &viewSize) const
Return true if there is good data in the clipboard for pasting, and that operation is compatible with...
void handleMouseMove(CmdMediator *cmdMediator, QPointF pos)
See DigitizeStateAbstractBase::handleMouseMove.
void handleMouseRelease(CmdMediator *cmdMediator, QPointF pos)
See DigitizeStateAbstractBase::handleMouseRelease.
Model for DlgSettingsSegments and CmdSettingsSegments.
Digitizing state for creating Curve Points, one at a time.
QGraphicsView & view()
QGraphicsView for use by DigitizeStateAbstractBase subclasses.
void handleMousePress(CmdMediator *cmdMediator, QPointF pos)
See DigitizeStateAbstractBase::handleMousePress.
Digitizing state for creating multiple Points along a highlighted segment.
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
Digitizing state for digitizing one axis point at a time.
void requestImmediateStateTransition(CmdMediator *cmdMediator, DigitizeState digitizeState)
Perform immediate state transition. Called from outside state machine.