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 "DigitizeStateSegment.h"
15#include "DigitizeStateSelect.h"
16#include "DocumentModelSegments.h"
17#include "EngaugeAssert.h"
18#include "GraphicsScene.h"
19#include "GraphicsView.h"
21#include "MainWindow.h"
22#include <QApplication>
24#include <QGraphicsScene>
25#include <QGraphicsView>
26#include "QtToString.h"
31 m_mainWindow (mainWindow),
33 m_imageIsLoaded (false),
34 m_isGnuplot (isGnuplot)
44 ENGAUGE_ASSERT (m_states.size () == NUM_DIGITIZE_STATES);
46 m_currentState = NUM_DIGITIZE_STATES;
48 DIGITIZE_STATE_EMPTY);
51DigitizeStateContext::~DigitizeStateContext()
57 return m_states [m_currentState]->activeCurve ();
63 LOG4CPP_INFO_S ((*mainCat)) <<
"DigitizeStateContext::appendNewCmd";
65 cmdMediator->push (cmd);
68void DigitizeStateContext::completeRequestedStateTransitionIfExists (
CmdMediator *cmdMediator)
70 if (m_currentState != m_requestedState) {
74 if (m_currentState != NUM_DIGITIZE_STATES) {
77 m_states [m_currentState]->end ();
81 DigitizeState previousState = m_currentState;
82 m_currentState = m_requestedState;
83 m_states [m_requestedState]->begin (cmdMediator,
93 const QString &pointIdentifier)
95 m_states [m_currentState]->handleContextMenuEvent (cmdMediator,
101 m_states [m_currentState]->handleCurveChange(cmdMediator);
106 bool atLeastOneSelectedItem)
108 m_states [m_currentState]->handleKeyPress (cmdMediator,
110 atLeastOneSelectedItem);
112 completeRequestedStateTransitionIfExists(cmdMediator);
118 m_states [m_currentState]->handleLeave (cmdMediator);
120 completeRequestedStateTransitionIfExists(cmdMediator);
127 m_states [m_currentState]->handleMouseMove (cmdMediator,
130 completeRequestedStateTransitionIfExists(cmdMediator);
137 m_states [m_currentState]->handleMousePress (cmdMediator,
140 completeRequestedStateTransitionIfExists(cmdMediator);
147 m_states [m_currentState]->handleMouseRelease (cmdMediator,
150 completeRequestedStateTransitionIfExists(cmdMediator);
154 const QCursor &cursor)
156 m_states [m_currentState]->handleSetOverrideCursor (cmdMediator,
177 m_requestedState = digitizeState;
181 DigitizeState digitizeState)
183 m_requestedState = digitizeState;
184 completeRequestedStateTransitionIfExists(cmdMediator);
189 LOG4CPP_INFO_S ((*mainCat)) <<
"DigitizeStateContext::resetOnLoad";
193 if (m_currentState != DIGITIZE_STATE_EMPTY) {
194 m_requestedState = DIGITIZE_STATE_EMPTY;
195 completeRequestedStateTransitionIfExists(cmdMediator);
201 LOG4CPP_INFO_S ((*mainCat)) <<
"DigitizeStateContext::setCursor";
203 ENGAUGE_ASSERT(m_currentState < m_states.count());
205 m_states [m_currentState]->setCursor (cmdMediator);
210 LOG4CPP_DEBUG_S ((*mainCat)) <<
"DigitizeStateContext::setDragMode";
212 if (m_imageIsLoaded) {
213 m_view.setDragMode (dragMode);
220 LOG4CPP_INFO_S ((*mainCat)) <<
"DigitizeStateContext::setImageIsLoaded";
222 m_imageIsLoaded = imageIsLoaded;
228 ENGAUGE_ASSERT (m_currentState != NUM_DIGITIZE_STATES);
230 return m_states [m_currentState]->state();
236 LOG4CPP_INFO_S ((*mainCat)) <<
"DigitizeStateContext::updateModelDigitizeCurve";
238 ENGAUGE_ASSERT(m_currentState < m_states.count());
240 m_states [m_currentState]->updateModelDigitizeCurve (cmdMediator,
246 LOG4CPP_INFO_S ((*mainCat)) <<
"DigitizeStateContext::updateModelSegments";
248 ENGAUGE_ASSERT(m_currentState < m_states.count());
250 m_states [m_currentState]->updateModelSegments (modelSegments);
Digitizing state for digitizing one axis point at a time.
Digitizing state for selecting a color for DigitizeStateSegment.
QString state() const
State name for debugging.
bool isGnuplot() const
Get method for gnuplot flag.
void resetOnLoad(CmdMediator *cmdMediator)
Resetting makes re-initializes for documents after the first.
void handleMouseRelease(CmdMediator *cmdMediator, QPointF pos)
See DigitizeStateAbstractBase::handleMouseRelease.
DigitizeStateContext(MainWindow &mainWindow, QGraphicsView &view, bool isGnuplot)
Single constructor.
void handleContextMenuEvent(CmdMediator *cmdMediator, const QString &pointIdentifier)
See DigitizeStateAbstractBase::handleContextMenuEvent.
void handleMouseMove(CmdMediator *cmdMediator, QPointF pos)
See DigitizeStateAbstractBase::handleMouseMove.
void requestImmediateStateTransition(CmdMediator *cmdMediator, DigitizeState digitizeState)
Perform immediate state transition. Called from outside state machine.
void updateModelDigitizeCurve(CmdMediator *cmdMediator, const DocumentModelDigitizeCurve &modelDigitizeCurve)
Update the digitize curve settings.
void setDragMode(QGraphicsView::DragMode dragMode)
Set QGraphicsView drag mode (in m_view). Called from DigitizeStateAbstractBase subclasses.
void handleMousePress(CmdMediator *cmdMediator, QPointF pos)
See DigitizeStateAbstractBase::handleMousePress.
void appendNewCmd(CmdMediator *cmdMediator, QUndoCommand *cmd)
Append just-created QUndoCommand to command stack. This is called from DigitizeStateAbstractBase subc...
void setCursor(CmdMediator *cmdMediator)
Set cursor after asking state for the new cursor shape.
void handleSetOverrideCursor(CmdMediator *cmdMediator, const QCursor &cursor)
See DigitizeStateAbstractBase::handleSetOverrideCursor.
void setImageIsLoaded(CmdMediator *cmdMediator, bool imageIsLoaded)
Set the image so QGraphicsView cursor and drag mode are accessible.
QString activeCurve() const
Curve name for active Curve. This can include AXIS_CURVE_NAME, and empty string.
void handleKeyPress(CmdMediator *cmdMediator, Qt::Key key, bool atLeastOneSelectedItem)
See DigitizeStateAbstractBase::handleKeyPress.
void updateModelSegments(const DocumentModelSegments &modelSegments)
Update the segments given the new settings.
void requestDelayedStateTransition(DigitizeState digitizeState)
Initiate state transition to be performed later, when DigitizeState is off the stack.
QGraphicsView & view()
QGraphicsView for use by DigitizeStateAbstractBase subclasses.
void handleCurveChange(CmdMediator *cmdMediator)
See DigitizeStateAbstractBase::handleCurveChange.
MainWindow & mainWindow()
Reference to the MainWindow, without const.
void handleLeave(CmdMediator *cmdMediator)
See DigitizeStateAbstractBase::handleLeave.
Digitizing state for creating Curve Points, one at a time.
Digitizing state before a Document has been created. In this state, the cursor is Qt::ArrowCursor.
Digitizing state for matching Curve Points, one at a time.
Digitizing state for creating multiple Points along a highlighted segment.
Digitizing state for selecting one or more Points in the Document.
Model for DlgSettingsDigitizeCurve and CmdSettingsDigitizeCurve.
Model for DlgSettingsSegments and CmdSettingsSegments.
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
CmdMediator * cmdMediator()
Accessor for commands to process the Document.
void updateDigitizeStateIfSoftwareTriggered(DigitizeState digitizeState)
After software-triggered state transition, this method manually triggers the action as if user had cl...