Engauge Digitizer  2
DigitizeStateAbstractBase.h
Go to the documentation of this file.
1 /******************************************************************************************************
2  * (C) 2014 markummitchell@github.com. This file is part of Engauge Digitizer, which is released *
3  * under GNU General Public License version 2 (GPLv2) or (at your option) any later version. See file *
4  * LICENSE or go to gnu.org/licenses for details. Distribution requires prior written permission. *
5  ******************************************************************************************************/
6 
7 #ifndef DIGITIZE_STATE_ABSTRACT_BASE_H
8 #define DIGITIZE_STATE_ABSTRACT_BASE_H
9 
10 #include "PointStyle.h"
11 #include <QCursor>
12 #include <QPointF>
13 
14 class CmdMediator;
18 class QSize;
19 class QString;
20 class QStringList;
21 class Transformation;
22 
32  DIGITIZE_STATE_SCALE, // Out of order for backwards compatibility with pre-version 10
34 };
35 
38 {
39 public:
42  virtual ~DigitizeStateAbstractBase ();
43 
45  virtual QString activeCurve () const = 0;
46 
49  virtual void begin(CmdMediator *cmdMediator,
50  DigitizeState previousState) = 0;
51 
53  virtual bool canPaste (const Transformation &transformation,
54  const QSize &viewSize) const = 0;
55 
58 
60  const DigitizeStateContext &context() const;
61 
63  virtual void end() = 0;
64 
66  virtual void handleContextMenuEventAxis (CmdMediator *cmdMediator,
67  const QString &pointIdentifier) = 0;
68 
70  virtual void handleContextMenuEventGraph (CmdMediator *cmdMediator,
71  const QStringList &pointIdentifiers) = 0;
72 
74  virtual void handleCurveChange (CmdMediator *cmdMediator) = 0;
75 
77  virtual void handleKeyPress (CmdMediator *cmdMediator,
78  Qt::Key key,
79  bool atLeastOneSelectedItem) = 0;
80 
82  virtual void handleMouseMove (CmdMediator *cmdMediator,
83  QPointF posScreen) = 0;
84 
86  virtual void handleMousePress (CmdMediator *cmdMediator,
87  QPointF pos) = 0;
88 
90  virtual void handleMouseRelease (CmdMediator *cmdMediator,
91  QPointF pos) = 0;
92 
94  void setCursor(CmdMediator *cmdMediator);
95 
97  virtual QString state() const = 0;
98 
100  virtual void updateAfterPointAddition () = 0;
101 
103  virtual void updateModelDigitizeCurve (CmdMediator *cmdMediator,
104  const DocumentModelDigitizeCurve &modelDigitizeCurve) = 0;
105 
107  virtual void updateModelSegments(const DocumentModelSegments &modelSegments) = 0;
108 
109 protected:
111  bool canPasteProtected (const Transformation &transformation,
112  const QSize &viewSize) const;
113 
115  virtual QCursor cursor (CmdMediator *cmdMediator) const = 0;
116 
117 private:
119 
120  DigitizeStateContext &m_context;
121 
122 };
123 
124 #endif // DIGITIZE_STATE_ABSTRACT_BASE_H
DIGITIZE_STATE_CURVE
Definition: DigitizeStateAbstractBase.h:26
DigitizeStateAbstractBase::cursor
virtual QCursor cursor(CmdMediator *cmdMediator) const =0
Returns the state-specific cursor shape.
DIGITIZE_STATE_EMPTY
Definition: DigitizeStateAbstractBase.h:27
DigitizeStateContext
Container for all DigitizeStateAbstractBase subclasses. This functions as the context class in a stan...
Definition: DigitizeStateContext.h:26
DIGITIZE_STATE_COLOR_PICKER
Definition: DigitizeStateAbstractBase.h:25
DigitizeStateAbstractBase::context
DigitizeStateContext & context()
Reference to the DigitizeStateContext that contains all the DigitizeStateAbstractBase subclasses,...
Definition: DigitizeStateAbstractBase.cpp:41
PointStyle.h
DigitizeStateAbstractBase::handleKeyPress
virtual void handleKeyPress(CmdMediator *cmdMediator, Qt::Key key, bool atLeastOneSelectedItem)=0
Handle a key press that was intercepted earlier.
DigitizeStateAbstractBase::handleMousePress
virtual void handleMousePress(CmdMediator *cmdMediator, QPointF pos)=0
Handle a mouse press that was intercepted earlier.
DigitizeStateAbstractBase::activeCurve
virtual QString activeCurve() const =0
Name of the active Curve. This can include AXIS_CURVE_NAME.
DIGITIZE_STATE_AXIS
Definition: DigitizeStateAbstractBase.h:24
Transformation
Affine transformation between screen and graph coordinates, based on digitized axis points.
Definition: Transformation.h:30
DigitizeStateAbstractBase::begin
virtual void begin(CmdMediator *cmdMediator, DigitizeState previousState)=0
Method that is called at the exact moment a state is entered.
DIGITIZE_STATE_SEGMENT
Definition: DigitizeStateAbstractBase.h:29
DIGITIZE_STATE_SELECT
Definition: DigitizeStateAbstractBase.h:30
DigitizeStateAbstractBase::handleContextMenuEventAxis
virtual void handleContextMenuEventAxis(CmdMediator *cmdMediator, const QString &pointIdentifier)=0
Handle a right click, on an axis point, that was intercepted earlier.
DigitizeStateAbstractBase::end
virtual void end()=0
Method that is called at the exact moment a state is exited. Typically called just before begin for t...
DigitizeState
DigitizeState
Set of possible states of Digitize toolbar.
Definition: DigitizeStateAbstractBase.h:23
DIGITIZE_STATE_SCALE
Definition: DigitizeStateAbstractBase.h:31
DigitizeStateAbstractBase::updateModelSegments
virtual void updateModelSegments(const DocumentModelSegments &modelSegments)=0
Update the segments given the new settings.
DIGITIZE_STATE_POINT_MATCH
Definition: DigitizeStateAbstractBase.h:28
DocumentModelSegments
Model for DlgSettingsSegments and CmdSettingsSegments.
Definition: DocumentModelSegments.h:16
DigitizeStateAbstractBase::setCursor
void setCursor(CmdMediator *cmdMediator)
Update the cursor according to the current state.
Definition: DigitizeStateAbstractBase.cpp:51
DigitizeStateAbstractBase::canPasteProtected
bool canPasteProtected(const Transformation &transformation, const QSize &viewSize) const
Protected version of canPaste method. Some, but not all, leaf classes use this method.
Definition: DigitizeStateAbstractBase.cpp:32
DocumentModelDigitizeCurve
Model for DlgSettingsDigitizeCurve and CmdSettingsDigitizeCurve.
Definition: DocumentModelDigitizeCurve.h:17
CmdMediator
Command queue stack.
Definition: CmdMediator.h:22
DigitizeStateAbstractBase::updateAfterPointAddition
virtual void updateAfterPointAddition()=0
Update graphics attributes after possible new points. This is useful for highlight opacity.
NUM_DIGITIZE_STATES
Definition: DigitizeStateAbstractBase.h:32
DigitizeStateAbstractBase::handleMouseMove
virtual void handleMouseMove(CmdMediator *cmdMediator, QPointF posScreen)=0
Handle a mouse move. This is part of an experiment to see if augmenting the cursor in Point Match mod...
DigitizeStateAbstractBase::handleMouseRelease
virtual void handleMouseRelease(CmdMediator *cmdMediator, QPointF pos)=0
Handle a mouse release that was intercepted earlier.
DigitizeStateAbstractBase::canPaste
virtual bool canPaste(const Transformation &transformation, const QSize &viewSize) const =0
Return true if there is good data in the clipboard for pasting, and that is compatible with the curre...
DigitizeStateAbstractBase::updateModelDigitizeCurve
virtual void updateModelDigitizeCurve(CmdMediator *cmdMediator, const DocumentModelDigitizeCurve &modelDigitizeCurve)=0
Update the digitize curve settings.
DigitizeStateAbstractBase::handleCurveChange
virtual void handleCurveChange(CmdMediator *cmdMediator)=0
Handle the selection of a new curve. At a minimum, DigitizeStateSegment will generate a new set of Se...
DigitizeStateAbstractBase
Base class for all digitizing states. This serves as an interface to DigitizeStateContext.
Definition: DigitizeStateAbstractBase.h:36
DigitizeStateAbstractBase::handleContextMenuEventGraph
virtual void handleContextMenuEventGraph(CmdMediator *cmdMediator, const QStringList &pointIdentifiers)=0
Handle a right click, on a graph point, that was intercepted earlier.
DigitizeStateAbstractBase::state
virtual QString state() const =0
State name for debugging.
DigitizeStateAbstractBase::~DigitizeStateAbstractBase
virtual ~DigitizeStateAbstractBase()
Definition: DigitizeStateAbstractBase.cpp:28