Engauge Digitizer
2
Toggle main menu visibility
Loading...
Searching...
No Matches
Guideline
GuidelineStateDeployedConstantRAbstract.cpp
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
#include "
EngaugeAssert.h
"
8
#include "
GuidelineEllipse.h
"
9
#include "
GuidelineProjectorConstantR.h
"
10
#include "
GuidelineStateContext.h
"
11
#include "
GuidelineStateDeployedConstantRAbstract.h
"
12
#include "
Logger.h
"
13
#include <qmath.h>
14
#include "
Transformation.h
"
15
16
GuidelineStateDeployedConstantRAbstract::GuidelineStateDeployedConstantRAbstract
(
GuidelineStateContext
&
context
) :
17
GuidelineStateDeployedAbstract
(
context
)
18
{
19
}
20
21
GuidelineStateDeployedConstantRAbstract::~GuidelineStateDeployedConstantRAbstract
()
22
{
23
}
24
25
QPointF
GuidelineStateDeployedConstantRAbstract::convertGraphCoordinateToScreenPoint
(
double
valueGraph)
const
26
{
27
const
double
ARBITRARY_THETA = 0;
// Value that is legal in all cases
28
QPointF posScreen;
29
context
().
transformation
().
transformRawGraphToScreen
(QPointF (ARBITRARY_THETA,
30
valueGraph),
31
posScreen);
32
33
qCDebug(ENGAUGE_LOG) <<
"GuidelineStateDeployedConstantRAbstract::convertGraphCoordinateToScreenPoint"
34
<<
" pos=("
<< posScreen.x() <<
", "
<< posScreen.y() <<
")"
;
35
36
return
posScreen;
37
}
38
39
double
GuidelineStateDeployedConstantRAbstract::convertScreenPointToGraphCoordinate
(
const
QPointF &posScreen)
const
40
{
41
QPointF posGraph;
42
context
().
transformation
().
transformScreenToRawGraph
(posScreen,
43
posGraph);
44
45
qCDebug(ENGAUGE_LOG) <<
"GuidelineStateDeployedConstantRAbstract::convertScreenPointToGraphCoordinate"
46
<<
" pos=("
<< posGraph.x() <<
", "
<< posGraph.y() <<
")"
;
47
48
return
posGraph.y();
49
}
50
51
EllipseParameters
GuidelineStateDeployedConstantRAbstract::pointToEllipse
(
const
QPointF &posScreen)
const
52
{
53
GuidelineProjectorConstantR
projector;
54
55
return
projector.
fromPosScreen
(
context
().transformation(),
56
sceneRect
(),
57
posScreen);
58
}
59
60
QLineF
GuidelineStateDeployedConstantRAbstract::pointToLine
(
const
QPointF &
/* posScreen */
)
const
61
{
62
// pointToEllipse applies in this state
63
return
QLineF (0, 0, 0, 0);
64
}
65
66
void
GuidelineStateDeployedConstantRAbstract::updateWithLatestTransformation
()
67
{
68
qCDebug(ENGAUGE_LOG) <<
"GuidelineStateDeployedConstantRAbstract::updateWithLatestTransformation"
;
69
70
if
(!
context
().transformation().transformIsDefined()) {
71
// Discard this Guideline immediately if the transformation transitions to undefined
72
context
().
requestStateTransition
(
GUIDELINE_STATE_DISCARDED
);
73
}
else
{
74
75
QPointF posScreen;
76
context
().
transformation
().
transformRawGraphToScreen
(
context
().posCursorGraph(),
77
posScreen);
78
79
GuidelineEllipse
*ellipse =
dynamic_cast<
GuidelineEllipse
*
>
(&
context
().
guideline
());
80
ellipse->
updateGeometry
(posScreen);
81
}
82
}
EngaugeAssert.h
GuidelineEllipse.h
GuidelineProjectorConstantR.h
GuidelineStateContext.h
GuidelineStateDeployedConstantRAbstract.h
GUIDELINE_STATE_DISCARDED
@ GUIDELINE_STATE_DISCARDED
Definition
GuidelineState.h:46
Logger.h
Transformation.h
EllipseParameters
Parameters that define an ellipse about the specified center, at the specified angle from alignment w...
Definition
EllipseParameters.h:16
GuidelineEllipse
Ellipse version of GuidelineAbstract.
Definition
GuidelineEllipse.h:23
GuidelineEllipse::updateGeometry
virtual void updateGeometry(double valueGraph)
Update the geometry so it passes through the specified coordinate value in graph coordinates.
Definition
GuidelineEllipse.cpp:242
GuidelineProjectorConstantR
Project a point along the tangential direction in graph coordinates to produce a curve along the cons...
Definition
GuidelineProjectorConstantR.h:22
GuidelineProjectorConstantR::fromPosScreen
EllipseParameters fromPosScreen(const Transformation &transformation, const QRectF &sceneRect, const QPointF &posScreen)
Return line through point in screen coordinates.
Definition
GuidelineProjectorConstantR.cpp:70
GuidelineStateAbstractBase::sceneRect
QRectF sceneRect() const
Scene rectangle in screen coordinates (=pixels).
Definition
GuidelineStateAbstractBase.cpp:71
GuidelineStateAbstractBase::context
GuidelineStateContext & context() const
Context in charge of the state classes.
Definition
GuidelineStateAbstractBase.cpp:27
GuidelineStateContext
Context class for state machine that belongs to the Guideline class.
Definition
GuidelineStateContext.h:132
GuidelineStateContext::transformation
Transformation transformation() const
Return copy of transformation owned by MainWindow.
Definition
GuidelineStateContext.cpp:267
GuidelineStateContext::guideline
GuidelineAbstract & guideline()
Guideline that owns this context class.
Definition
GuidelineStateContext.cpp:155
GuidelineStateContext::requestStateTransition
void requestStateTransition(GuidelineState guidelineState)
Request a state transition.
Definition
GuidelineStateContext.cpp:233
GuidelineStateDeployedAbstract::GuidelineStateDeployedAbstract
GuidelineStateDeployedAbstract(GuidelineStateContext &context)
Single constructor.
Definition
GuidelineStateDeployedAbstract.cpp:17
GuidelineStateDeployedConstantRAbstract::GuidelineStateDeployedConstantRAbstract
GuidelineStateDeployedConstantRAbstract(GuidelineStateContext &context)
Single constructor.
Definition
GuidelineStateDeployedConstantRAbstract.cpp:16
GuidelineStateDeployedConstantRAbstract::pointToLine
virtual QLineF pointToLine(const QPointF &posScreen) const
Return line parallel to an axis line, that passes through the specified point.
Definition
GuidelineStateDeployedConstantRAbstract.cpp:60
GuidelineStateDeployedConstantRAbstract::convertGraphCoordinateToScreenPoint
virtual QPointF convertGraphCoordinateToScreenPoint(double valueGraph) const
Convert single graph coordinate into screen point pair.
Definition
GuidelineStateDeployedConstantRAbstract.cpp:25
GuidelineStateDeployedConstantRAbstract::convertScreenPointToGraphCoordinate
virtual double convertScreenPointToGraphCoordinate(const QPointF &posScreen) const
Convert screen point pair into single graph coordinate.
Definition
GuidelineStateDeployedConstantRAbstract.cpp:39
GuidelineStateDeployedConstantRAbstract::pointToEllipse
virtual EllipseParameters pointToEllipse(const QPointF &posScreen) const
Return ellipse representing constant range, that passes through the specified point.
Definition
GuidelineStateDeployedConstantRAbstract.cpp:51
GuidelineStateDeployedConstantRAbstract::updateWithLatestTransformation
virtual void updateWithLatestTransformation()
Update given Transformation in GuidelineStateContext.
Definition
GuidelineStateDeployedConstantRAbstract.cpp:66
GuidelineStateDeployedConstantRAbstract::~GuidelineStateDeployedConstantRAbstract
virtual ~GuidelineStateDeployedConstantRAbstract()
Definition
GuidelineStateDeployedConstantRAbstract.cpp:21
Transformation::transformRawGraphToScreen
void transformRawGraphToScreen(const QPointF &pointRaw, QPointF &pointScreen) const
Transform from raw graph coordinates to linear cartesian graph coordinates, then to screen coordinate...
Definition
Transformation.cpp:446
Transformation::transformScreenToRawGraph
void transformScreenToRawGraph(const QPointF &coordScreen, QPointF &coordGraph) const
Transform from cartesian pixel screen coordinates to cartesian/polar graph coordinates.
Definition
Transformation.cpp:465
Generated on
for Engauge Digitizer by
1.17.0