Engauge Digitizer 2
Loading...
Searching...
No Matches
GuidelineStateAbstractBase.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_ABSTRACT_BASE_H
8#define GUIDELINE_STATE_ABSTRACT_BASE_H
9
10#include "EllipseParameters.h"
11#include "GuidelineState.h"
12#include <QColor>
13#include <QLineF>
14#include <QPointF>
15#include <QRectF>
16#include <QString>
17
19
21const int APPEARING_TIMEOUT = 3000;
22
25{
26public:
30
32 virtual void begin () = 0;
33
35 virtual QPointF convertGraphCoordinateToScreenPoint (double valueGraph) const = 0;
36
38 virtual double convertScreenPointToGraphCoordinate (const QPointF &posScreen) const = 0;
39
42 virtual bool doPaint () const = 0;
43
45 virtual void end () = 0;
46
48 virtual void handleActiveChange (bool active) = 0;
49
51 virtual void handleGuidelineMode (bool visibility,
52 bool locked) = 0;
53
55 virtual void handleHoverEnterEvent () = 0;
56
58 virtual void handleHoverLeaveEvent () = 0;
59
62 virtual void handleMousePress (const QPointF &posScene) = 0;
63
65 virtual void handleMouseRelease (const QPointF &posScene) = 0;
66
68 virtual void handleTimeout () = 0;
69
71 virtual EllipseParameters pointToEllipse (const QPointF &posScreen) const = 0;
72
74 virtual QLineF pointToLine (const QPointF &posScreen) const = 0;
75
77 virtual QString stateName () const = 0;
78
80 virtual void updateWithLatestTransformation () = 0;
81
82protected:
83
86
90 void handleMousePressCommon (const QPointF &posAbsolute,
91 GuidelineState stateHandle,
92 GuidelineState stateDeployed);
93
95 QRectF sceneRect () const;
96
97private:
99
100 GuidelineStateContext &m_context;
101};
102
103#endif // GUIDELINE_STATE_ABSTRACT_BASE_H
const int APPEARING_TIMEOUT
Milliseconds before transition from Appearing state to Active state.
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...
virtual void handleHoverEnterEvent()=0
If transparent then make visible when hover starts.
virtual EllipseParameters pointToEllipse(const QPointF &posScreen) const =0
Return ellipse representing constant range, that passes through the specified point.
virtual void handleHoverLeaveEvent()=0
If previously transparent before hover enter then make transparent again.
QRectF sceneRect() const
Scene rectangle in screen coordinates (=pixels)
virtual QPointF convertGraphCoordinateToScreenPoint(double valueGraph) const =0
Convert single graph coordinate into screen point pair.
void handleMousePressCommon(const QPointF &posAbsolute, GuidelineState stateHandle, GuidelineState stateDeployed)
Common mouse press handling.
GuidelineStateContext & context() const
Context in charge of the state classes.
virtual void handleMouseRelease(const QPointF &posScene)=0
At the end of dragging, clone the Guideline that owns the state machine where these states live.
virtual void handleMousePress(const QPointF &posScene)=0
At the start of dragging, convert the Guideline into an invisible handle and visible slaved deployed ...
virtual QLineF pointToLine(const QPointF &posScreen) const =0
Return line parallel to an axis line, that passes through the specified point.
virtual double convertScreenPointToGraphCoordinate(const QPointF &posScreen) const =0
Convert screen point pair into single graph coordinate.
virtual void handleGuidelineMode(bool visibility, bool locked)=0
User toggled Guideline visibility and/or locked mode.
virtual void handleActiveChange(bool active)=0
DigitizeState change so active status may (or may not) be toggled.
virtual void begin()=0
Transition into state.
virtual void updateWithLatestTransformation()=0
Update given Transformation in GuidelineStateContext.
virtual void handleTimeout()=0
Handle timeout from Appearing state.
virtual QString stateName() const =0
Name of state as a string for debugging only.
virtual void end()=0
Transition out of state.
virtual bool doPaint() const =0
Allow/skip painting of the owner Guideline.
GuidelineStateAbstractBase(GuidelineStateContext &context)
Single constructor.
Context class for state machine that belongs to the Guideline class.