Engauge Digitizer 2
Loading...
Searching...
No Matches
GuidelineStateContext.h
Go to the documentation of this file.
1/******************************************************************************************************
2 * (C) 2019 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 GUIDELINE_STATE_CONTEXT_H
8#define GUIDELINE_STATE_CONTEXT_H
9
10#include "ColorPalette.h"
11#include "EllipseParameters.h"
12#include "GuidelineState.h"
14#include <QLineF>
15#include <QObject>
16#include <QPointF>
17#include <QString>
18#include <QVector>
19
21class Guidelines;
22class Transformation;
23
129class GuidelineStateContext : public QObject
130{
131 Q_OBJECT;
132
133public:
136 Guidelines &guidelines,
137 GuidelineState guidelineStateInitial);
138 virtual ~GuidelineStateContext();
139
141 bool cartesian() const;
142
144 ColorPalette color () const;
145
147 QPointF convertGraphCoordinateToScreenPoint (double valueGraph) const;
148
150 double convertScreenPointToGraphCoordinate (const QPointF &posScreen) const;
151
153 GuidelineAbstract *createGuideline (const QString &identifier,
154 GuidelineState stateInitial) const;
155
158 bool doPaint () const;
159
161 void draggedOffScreen ();
162
165
167 void handleActiveChange (bool active);
168
170 void handleGuidelineMode (bool visibile,
171 bool locked);
172
174 void handleHoverEnterEvent ();
175
177 void handleHoverLeaveEvent ();
178
181 void handleMousePress (const QPointF &posScene);
182
184 void handleMouseRelease (const QPointF &posScene);
185
187 EllipseParameters pointToEllipse (const QPointF &posScreen) const;
188
190 QLineF pointToLine (const QPointF &posScreen) const;
191
193 QPointF posCursorGraph () const;
194
196 void requestStateTransition (GuidelineState guidelineState);
197
200 void setPosCursorGraph (const QPointF &posGraph);
201
203 QString stateDump () const;
204
206 QString stateName () const;
207
210
213
214public slots:
215 void slotTimeout ();
216
217private:
219
221 void transitionIfRequested ();
222
223 GuidelineAbstract &m_guideline;
224 Guidelines &m_guidelines;
225
226 QVector<GuidelineStateAbstractBase*> m_states;
227 GuidelineState m_currentState;
228 GuidelineState m_nextState;
229
230 QPointF m_posCursorGraph;
231};
232
233#endif // GUIDELINE_STATE_CONTEXT_H
ColorPalette
GuidelineState
Set of possible Guideline states. See class Guideline for more information.
Parameters that define an ellipse about the specified center, at the specified angle from alignment w...
This class is a special case of the standard QGraphicsLineItem for guidelines, and serves as the base...
QPointF convertGraphCoordinateToScreenPoint(double valueGraph) const
Convert single graph coordinate into screen point pair.
bool doPaint() const
Allow/skip painting of the owner Guideline.
Transformation transformation() const
Return copy of transformation owned by MainWindow.
void draggedOffScreen()
Guideline has been dragged off screen so remove it.
QString stateDump() const
Dump state for debugging only.
void handleActiveChange(bool active)
DigitizeState change so active status may (or may not) be toggled.
GuidelineStateContext(GuidelineAbstract &guideline, Guidelines &guidelines, GuidelineState guidelineStateInitial)
Single constructor.
QPointF posCursorGraph() const
Get method for current cursor coordinate when object was last created/dragged.
void handleHoverLeaveEvent()
If previously transparent before hover enter then make transparent again.
bool cartesian() const
True/false if coordinates are cartesian/polar.
GuidelineAbstract & guideline()
Guideline that owns this context class.
ColorPalette color() const
Color to be used for guidelines.
void setPosCursorGraph(const QPointF &posGraph)
Pass the current cursor coordinate to the state so it can save the relevant coordinate for later adju...
QLineF pointToLine(const QPointF &posScreen) const
Return line parallel to an axis line, that passes through the specified point.
double convertScreenPointToGraphCoordinate(const QPointF &posScreen) const
Convert screen point pair into single graph coordinate.
QString stateName() const
State as a string for debugging only.
void requestStateTransition(GuidelineState guidelineState)
Request a state transition.
EllipseParameters pointToEllipse(const QPointF &posScreen) const
Return ellipse representing constant range, that passes through the specified point.
void handleMousePress(const QPointF &posScene)
At the start of dragging, convert the original Guideline into an invisible handle and visible slaved ...
void handleHoverEnterEvent()
If transparent then make visible when hover starts.
void handleGuidelineMode(bool visibile, bool locked)
User toggled Guideline visibility and/or locked mode.
void updateWithLatestTransformation()
Update given Transformation in GuidelineStateContext.
void handleMouseRelease(const QPointF &posScene)
At the end of dragging, clone the Guideline that owns the state machine where these states live.
GuidelineAbstract * createGuideline(const QString &identifier, GuidelineState stateInitial) const
Factory method for creating a new Guideline.
This class contains all Guideline objects.
Definition Guidelines.h:28
Affine transformation between screen and graph coordinates, based on digitized axis points.