Engauge Digitizer
2
Toggle main menu visibility
Loading...
Searching...
No Matches
Guideline
GuidelineStateDeployedConstantYAbstract.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 "
GuidelineLine.h
"
9
#include "
GuidelineProjectorConstantY.h
"
10
#include "
GuidelineStateContext.h
"
11
#include "
GuidelineStateDeployedConstantYAbstract.h
"
12
#include "
Logger.h
"
13
#include "
Transformation.h
"
14
15
GuidelineStateDeployedConstantYAbstract::GuidelineStateDeployedConstantYAbstract
(
GuidelineStateContext
&
context
) :
16
GuidelineStateDeployedAbstract
(
context
)
17
{
18
}
19
20
GuidelineStateDeployedConstantYAbstract::~GuidelineStateDeployedConstantYAbstract
()
21
{
22
}
23
24
QPointF
GuidelineStateDeployedConstantYAbstract::convertGraphCoordinateToScreenPoint
(
double
valueGraph)
const
25
{
26
const
double
ARBITRARY_X = 1.0;
// Value that is legal in all cases, including log scaling
27
QPointF posScreen;
28
context
().
transformation
().
transformRawGraphToScreen
(QPointF (ARBITRARY_X,
29
valueGraph),
30
posScreen);
31
32
qCDebug(ENGAUGE_LOG) <<
"GuidelineStateDeployedConstantYAbstract::convertGraphCoordinateToScreenPoint"
33
<<
" pos=("
<< posScreen.x() <<
", "
<< posScreen.y() <<
")"
;
34
35
return
posScreen;
36
}
37
38
double
GuidelineStateDeployedConstantYAbstract::convertScreenPointToGraphCoordinate
(
const
QPointF &posScreen)
const
39
{
40
QPointF posGraph;
41
context
().
transformation
().
transformScreenToRawGraph
(posScreen,
42
posGraph);
43
44
qCDebug(ENGAUGE_LOG) <<
"GuidelineStateDeployedConstantYAbstract::convertScreenPointToGraphCoordinate"
45
<<
" pos=("
<< posGraph.x() <<
", "
<< posGraph.y() <<
")"
;
46
47
return
posGraph.y();
48
}
49
50
EllipseParameters
GuidelineStateDeployedConstantYAbstract::pointToEllipse
(
const
QPointF &
/* posScreen */
)
const
51
{
52
// pointToLine applies in this state
53
return
EllipseParameters
();
54
}
55
56
QLineF
GuidelineStateDeployedConstantYAbstract::pointToLine
(
const
QPointF &posScreen)
const
57
{
58
GuidelineProjectorConstantY
projector;
59
60
return
projector.
fromPosScreen
(
context
().transformation(),
61
sceneRect
(),
62
posScreen);
63
}
64
65
void
GuidelineStateDeployedConstantYAbstract::updateWithLatestTransformation
()
66
{
67
qCDebug(ENGAUGE_LOG) <<
"GuidelineStateDeployedConstantYAbstract::updateWithLatestTransformation"
;
68
69
if
(!
context
().transformation().transformIsDefined()) {
70
// Discard this Guideline immediately if the transformation transitions to undefined
71
context
().
requestStateTransition
(
GUIDELINE_STATE_DISCARDED
);
72
}
else
{
73
74
GuidelineProjectorConstantY
projector;
75
76
GuidelineLine
*line =
dynamic_cast<
GuidelineLine
*
>
(&
context
().
guideline
());
77
line->setLine (projector.
fromCoordinateY
(
context
().transformation(),
78
sceneRect
(),
79
context
().posCursorGraph ().y()));
80
}
81
}
EngaugeAssert.h
GuidelineLine.h
GuidelineProjectorConstantY.h
GuidelineStateContext.h
GuidelineStateDeployedConstantYAbstract.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
GuidelineLine
Line version of GuidelineAbstract.
Definition
GuidelineLine.h:23
GuidelineProjectorConstantY
Project a point along the horizontal direction in graph coordinates to produce a line segment along t...
Definition
GuidelineProjectorConstantY.h:21
GuidelineProjectorConstantY::fromCoordinateY
QLineF fromCoordinateY(const Transformation &transformation, const QRectF &sceneRect, double yGraph)
Return line through y in graph coordinates.
Definition
GuidelineProjectorConstantY.cpp:54
GuidelineProjectorConstantY::fromPosScreen
QLineF fromPosScreen(const Transformation &transformation, const QRectF &sceneRect, const QPointF &posScreen)
Return line through point in screen coordinates.
Definition
GuidelineProjectorConstantY.cpp:83
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
GuidelineStateDeployedConstantYAbstract::pointToEllipse
virtual EllipseParameters pointToEllipse(const QPointF &posScreen) const
Return ellipse representing constant range, that passes through the specified point.
Definition
GuidelineStateDeployedConstantYAbstract.cpp:50
GuidelineStateDeployedConstantYAbstract::updateWithLatestTransformation
virtual void updateWithLatestTransformation()
Update given Transformation in GuidelineStateContext.
Definition
GuidelineStateDeployedConstantYAbstract.cpp:65
GuidelineStateDeployedConstantYAbstract::convertGraphCoordinateToScreenPoint
virtual QPointF convertGraphCoordinateToScreenPoint(double valueGraph) const
Convert single graph coordinate into screen point pair.
Definition
GuidelineStateDeployedConstantYAbstract.cpp:24
GuidelineStateDeployedConstantYAbstract::pointToLine
virtual QLineF pointToLine(const QPointF &posScreen) const
Return line parallel to an axis line, that passes through the specified point.
Definition
GuidelineStateDeployedConstantYAbstract.cpp:56
GuidelineStateDeployedConstantYAbstract::~GuidelineStateDeployedConstantYAbstract
virtual ~GuidelineStateDeployedConstantYAbstract()
Definition
GuidelineStateDeployedConstantYAbstract.cpp:20
GuidelineStateDeployedConstantYAbstract::convertScreenPointToGraphCoordinate
virtual double convertScreenPointToGraphCoordinate(const QPointF &posScreen) const
Convert screen point pair into single graph coordinate.
Definition
GuidelineStateDeployedConstantYAbstract.cpp:38
GuidelineStateDeployedConstantYAbstract::GuidelineStateDeployedConstantYAbstract
GuidelineStateDeployedConstantYAbstract(GuidelineStateContext &context)
Single constructor.
Definition
GuidelineStateDeployedConstantYAbstract.cpp:15
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