Engauge Digitizer  2
DigitizeStateAbstractBase.h
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 QString;
19 class QStringList;
20 
22 enum DigitizeState {
23  DIGITIZE_STATE_AXIS,
24  DIGITIZE_STATE_COLOR_PICKER,
25  DIGITIZE_STATE_CURVE,
26  DIGITIZE_STATE_EMPTY,
27  DIGITIZE_STATE_POINT_MATCH,
28  DIGITIZE_STATE_SEGMENT,
29  DIGITIZE_STATE_SELECT,
30  DIGITIZE_STATE_SCALE, // Out of order for backwards compatibility with pre-version 10
31  NUM_DIGITIZE_STATES
32 };
33 
36 {
37 public:
40  virtual ~DigitizeStateAbstractBase ();
41 
43  virtual QString activeCurve () const = 0;
44 
47  virtual void begin(CmdMediator *cmdMediator,
48  DigitizeState previousState) = 0;
49 
52 
54  const DigitizeStateContext &context() const;
55 
57  virtual void end() = 0;
58 
60  virtual void handleContextMenuEventAxis (CmdMediator *cmdMediator,
61  const QString &pointIdentifier) = 0;
62 
64  virtual void handleContextMenuEventGraph (CmdMediator *cmdMediator,
65  const QStringList &pointIdentifiers) = 0;
66 
68  virtual void handleCurveChange (CmdMediator *cmdMediator) = 0;
69 
71  virtual void handleKeyPress (CmdMediator *cmdMediator,
72  Qt::Key key,
73  bool atLeastOneSelectedItem) = 0;
74 
76  virtual void handleMouseMove (CmdMediator *cmdMediator,
77  QPointF posScreen) = 0;
78 
80  virtual void handleMousePress (CmdMediator *cmdMediator,
81  QPointF pos) = 0;
82 
84  virtual void handleMouseRelease (CmdMediator *cmdMediator,
85  QPointF pos) = 0;
86 
88  void setCursor(CmdMediator *cmdMediator);
89 
91  virtual QString state() const = 0;
92 
94  virtual void updateAfterPointAddition () = 0;
95 
97  virtual void updateModelDigitizeCurve (CmdMediator *cmdMediator,
98  const DocumentModelDigitizeCurve &modelDigitizeCurve) = 0;
99 
101  virtual void updateModelSegments(const DocumentModelSegments &modelSegments) = 0;
102 
103 protected:
105  virtual QCursor cursor (CmdMediator *cmdMediator) const = 0;
106 
107 private:
109 
110  DigitizeStateContext &m_context;
111 
112 };
113 
114 #endif // DIGITIZE_STATE_ABSTRACT_BASE_H
virtual void handleMousePress(CmdMediator *cmdMediator, QPointF pos)=0
Handle a mouse press that was intercepted earlier.
virtual void handleKeyPress(CmdMediator *cmdMediator, Qt::Key key, bool atLeastOneSelectedItem)=0
Handle a key press that was intercepted earlier.
virtual QCursor cursor(CmdMediator *cmdMediator) const =0
Returns the state-specific cursor shape.
virtual QString activeCurve() const =0
Name of the active Curve. This can include AXIS_CURVE_NAME.
virtual void handleMouseRelease(CmdMediator *cmdMediator, QPointF pos)=0
Handle a mouse release that was intercepted earlier.
virtual void handleContextMenuEventAxis(CmdMediator *cmdMediator, const QString &pointIdentifier)=0
Handle a right click, on an axis point, that was intercepted earlier.
DigitizeStateContext & context()
Reference to the DigitizeStateContext that contains all the DigitizeStateAbstractBase subclasses...
virtual void end()=0
Method that is called at the exact moment a state is exited. Typically called just before begin for t...
Model for DlgSettingsDigitizeCurve and CmdSettingsDigitizeCurve.
void setCursor(CmdMediator *cmdMediator)
Update the cursor according to the current state.
Container for all DigitizeStateAbstractBase subclasses. This functions as the context class in a stan...
virtual void updateModelSegments(const DocumentModelSegments &modelSegments)=0
Update the segments given the new settings.
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...
Command queue stack.
Definition: CmdMediator.h:23
virtual void updateModelDigitizeCurve(CmdMediator *cmdMediator, const DocumentModelDigitizeCurve &modelDigitizeCurve)=0
Update the digitize curve settings.
Model for DlgSettingsSegments and CmdSettingsSegments.
virtual void handleContextMenuEventGraph(CmdMediator *cmdMediator, const QStringList &pointIdentifiers)=0
Handle a right click, on a graph point, that was intercepted earlier.
virtual void handleCurveChange(CmdMediator *cmdMediator)=0
Handle the selection of a new curve. At a minimum, DigitizeStateSegment will generate a new set of Se...
Base class for all digitizing states. This serves as an interface to DigitizeStateContext.
virtual void updateAfterPointAddition()=0
Update graphics attributes after possible new points. This is useful for highlight opacity...
virtual QString state() const =0
State name for debugging.
virtual void begin(CmdMediator *cmdMediator, DigitizeState previousState)=0
Method that is called at the exact moment a state is entered.