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"
12#include "EllipseParameters.h"
13#include "GuidelineState.h"
15#include <QLineF>
16#include <QObject>
17#include <QPointF>
18#include <QString>
19#include <QVector>
20
22class Guidelines;
23class MainWindow;
24class Transformation;
25
131class GuidelineStateContext : public QObject
132{
133 Q_OBJECT;
134
135public:
138 MainWindow &mainWindow,
139 Guidelines &guidelines,
140 GuidelineState guidelineStateInitial);
141 virtual ~GuidelineStateContext();
142
144 bool cartesian() const;
145
147 ColorPalette color () const;
148
150 QPointF convertGraphCoordinateToScreenPoint (double valueGraph) const;
151
153 double convertScreenPointToGraphCoordinate (const QPointF &posScreen) const;
154
156 GuidelineAbstract *createGuideline (const QString &identifier,
157 GuidelineState stateInitial) const;
158
161 bool doPaint () const;
162
164 void draggedOffScreen ();
165
168
170 void handleActiveChange (bool active);
171
173 void handleGuidelineMode (bool visibile,
174 bool locked);
175
177 void handleHoverEnterEvent ();
178
180 void handleHoverLeaveEvent ();
181
184 void handleMousePress (const QPointF &posScene);
185
187 void handleMouseRelease (const QPointF &posScene);
188
191
193 EllipseParameters pointToEllipse (const QPointF &posScreen) const;
194
196 QLineF pointToLine (const QPointF &posScreen) const;
197
199 QPointF posCursorGraph () const;
200
202 void requestStateTransition (GuidelineState guidelineState);
203
206 void setPosCursorGraph (const QPointF &posGraph);
207
209 QString stateDump () const;
210
212 QString stateName () const;
213
216
219
220public slots:
221 void slotTimeout ();
222
223private:
225
227 void transitionIfRequested ();
228
229 GuidelineAbstract &m_guideline;
230 Guidelines &m_guidelines;
231
232 MainWindow &m_mainWindow;
233
234 QVector<GuidelineStateAbstractBase*> m_states;
235 GuidelineState m_currentState;
236 GuidelineState m_nextState;
237
238 QPointF m_posCursorGraph;
239};
240
241#endif // GUIDELINE_STATE_CONTEXT_H
ColorPalette
GuidelineState
Set of possible Guideline states. See class Guideline for more information.
Model for managing the coordinate values corresponding Guidelines.
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.
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.
GuidelineStateContext(GuidelineAbstract &guideline, MainWindow &mainWindow, Guidelines &guidelines, GuidelineState guidelineStateInitial)
Single constructor.
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.
DocumentModelGuideline modelGuideline() const
Up-to-date guideline settings.
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
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
Definition MainWindow.h:95
Affine transformation between screen and graph coordinates, based on digitized axis points.