25#include <QGraphicsScene>
26#include <QGraphicsView>
36 m_imageIsLoaded (false),
58 qDeleteAll (m_states);
63 return m_states [m_currentState]->activeCurve ();
71 cmdMediator->push (cmd);
75 const QSize &size)
const
77 return m_states [m_currentState]->canPaste (transformation,
81void DigitizeStateContext::completeRequestedStateTransitionIfExists (
CmdMediator *cmdMediator)
83 if (m_currentState != m_requestedState) {
90 m_states [m_currentState]->end ();
95 m_currentState = m_requestedState;
96 m_states [m_requestedState]->begin (cmdMediator,
107 return m_currentState;
112 return m_states [m_currentState]->guidelinesAreSelectable();
116 const QString &pointIdentifier)
118 m_states [m_currentState]->handleContextMenuEventAxis (cmdMediator,
123 const QStringList &pointIdentifiers)
125 m_states [m_currentState]->handleContextMenuEventGraph (cmdMediator,
131 m_states [m_currentState]->handleCurveChange(cmdMediator);
136 bool atLeastOneSelectedItem)
138 m_states [m_currentState]->handleKeyPress (cmdMediator,
140 atLeastOneSelectedItem);
142 completeRequestedStateTransitionIfExists(cmdMediator);
149 m_states [m_currentState]->handleMouseMove (cmdMediator,
152 completeRequestedStateTransitionIfExists(cmdMediator);
159 m_states [m_currentState]->handleMousePress (cmdMediator,
162 completeRequestedStateTransitionIfExists(cmdMediator);
169 m_states [m_currentState]->handleMouseRelease (cmdMediator,
172 completeRequestedStateTransitionIfExists(cmdMediator);
192 m_requestedState = digitizeState;
198 m_requestedState = digitizeState;
199 completeRequestedStateTransitionIfExists(cmdMediator);
210 completeRequestedStateTransitionIfExists(cmdMediator);
220 m_states [m_currentState]->setCursor (cmdMediator);
227 if (m_imageIsLoaded) {
228 m_view.setDragMode (dragMode);
237 m_imageIsLoaded = imageIsLoaded;
245 return m_states [m_currentState]->state();
252 m_states [m_currentState]->updateAfterPointAddition ();
262 m_states [m_currentState]->updateModelDigitizeCurve (cmdMediator,
272 m_states [m_currentState]->updateModelSegments (modelSegments);
DigitizeState
Set of possible states of Digitize toolbar.
@ DIGITIZE_STATE_POINT_MATCH
@ DIGITIZE_STATE_COLOR_PICKER
@ DIGITIZE_STATE_GUIDELINE
#define ENGAUGE_ASSERT(cond)
Drop in replacement for Q_ASSERT.
log4cpp::Category * mainCat
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.
virtual ~DigitizeStateContext()
void handleMouseRelease(CmdMediator *cmdMediator, QPointF pos)
See DigitizeStateAbstractBase::handleMouseRelease.
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...
DigitizeStateContext(MainWindow &mainWindow, QGraphicsView &view, bool isGnuplot)
Single constructor.
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 handleContextMenuEventGraph(CmdMediator *cmdMediator, const QStringList &pointIdentifiers)
See DigitizeStateAbstractBase::handleContextMenuEventGraph.
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 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.
bool guidelinesAreSelectable() const
Enable/disable guidelines according to state.
void requestDelayedStateTransition(DigitizeState digitizeState)
Initiate state transition to be performed later, when DigitizeState is off the stack.
void updateAfterPointAddition()
Update the graphics attributes.
QGraphicsView & view()
QGraphicsView for use by DigitizeStateAbstractBase subclasses.
void handleCurveChange(CmdMediator *cmdMediator)
See DigitizeStateAbstractBase::handleCurveChange.
MainWindow & mainWindow()
Reference to the MainWindow, without const.
void handleContextMenuEventAxis(CmdMediator *cmdMediator, const QString &pointIdentifier)
See DigitizeStateAbstractBase::handleContextMenuEventAxis.
friend class MainWindow
For CmdAbstract constructor only, via MainWindow, we offer the state to friend class MainWindow.
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 creating, moving and removing guidelines.
Digitizing state for matching Curve Points, one at a time.
Digitizing state for creating the scale bar.
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.
void updateDigitizeStateIfSoftwareTriggered(DigitizeState digitizeState)
After software-triggered state transition, this method manually triggers the action as if user had cl...
#define LOG4CPP_INFO_S(logger)
#define LOG4CPP_DEBUG_S(logger)