Engauge Digitizer
2
Toggle main menu visibility
Loading...
Searching...
No Matches
Guideline
GuidelineProjectorConstantR.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 <algorithm>
8
#include "
EllipseParameters.h
"
9
#include "
GuidelineProjectorConstantR.h
"
10
#include "
Logger.h
"
11
#include "
mmsubs.h
"
12
#include <QList>
13
#include <qmath.h>
14
#include <QRectF>
15
#include "
Transformation.h
"
16
17
GuidelineProjectorConstantR::GuidelineProjectorConstantR
()
18
{
19
}
20
21
GuidelineProjectorConstantR::~GuidelineProjectorConstantR
()
22
{
23
}
24
25
EllipseParameters
GuidelineProjectorConstantR::fromCoordinateR
(
const
Transformation
&transformation,
26
const
QRectF &
/* sceneRect */
,
27
double
rGraph)
28
{
29
QPointF posGraphCenter (0, 0);
30
if
(transformation.
modelCoords
().
coordScaleYRadius
() ==
COORD_SCALE_LOG
) {
31
posGraphCenter = QPointF (0,
32
transformation.
modelCoords
().
originRadius
());
33
}
34
35
// Points at 45, 135, 225 and 315 degrees at range rGraph
36
QPointF posScreenOrigin, posScreen0, posScreen90, posScreen180;
37
transformation.
transformRawGraphToScreen
(posGraphCenter,
38
posScreenOrigin);
39
transformation.
transformRawGraphToScreen
(QPointF (0, rGraph),
40
posScreen0);
41
transformation.
transformRawGraphToScreen
(QPointF (90, rGraph),
42
posScreen90);
43
transformation.
transformRawGraphToScreen
(QPointF (180, rGraph),
44
posScreen180);
45
46
QPointF centerTo90 = posScreen90 - posScreenOrigin;
47
48
// Corners of parallelogram circumscribing the ellipse
49
QPointF posScreenTL = posScreen180 + centerTo90;
50
QPointF posScreenTR = posScreen0 + centerTo90;
51
QPointF posScreenBR = posScreen0 - centerTo90;
52
53
double
angleRadians = 0, aAligned = 0, bAligned = 0;
54
ellipseFromParallelogram
(posScreenTL.x() - posScreenOrigin.x(),
55
posScreenTL.y() - posScreenOrigin.y(),
56
posScreenTR.x() - posScreenOrigin.x(),
57
posScreenTR.y() - posScreenOrigin.y(),
58
posScreenBR.x() - posScreenOrigin.x(),
59
posScreenBR.y() - posScreenOrigin.y(),
60
angleRadians,
61
aAligned,
62
bAligned);
63
64
return
EllipseParameters
(posScreenOrigin,
65
angleRadians,
66
aAligned,
67
bAligned);
68
}
69
70
EllipseParameters
GuidelineProjectorConstantR::fromPosScreen
(
const
Transformation
&transformation,
71
const
QRectF &sceneRect,
72
const
QPointF &posScreen)
73
{
74
QPointF posGraph;
75
transformation.
transformScreenToRawGraph
(posScreen, posGraph);
76
77
double
rGraph = posGraph.y();
78
79
if
((transformation.
modelCoords
().
coordScaleYRadius
() ==
COORD_SCALE_LOG
) &&
80
(rGraph <= 0)) {
81
82
// Range enforcement on the range values with log scale should have prevented this branch
83
qCCritical(ENGAUGE_LOG) <<
"GuidelineProjectorConstantR::fromPosScreen out of bounds range "
<< rGraph;
84
85
}
86
87
return
fromCoordinateR
(transformation,
88
sceneRect,
89
rGraph);
90
}
COORD_SCALE_LOG
@ COORD_SCALE_LOG
Definition
CoordScale.h:14
EllipseParameters.h
GuidelineProjectorConstantR.h
Logger.h
Transformation.h
DocumentModelCoords::coordScaleYRadius
CoordScale coordScaleYRadius() const
Get method for linear/log scale on y/radius.
Definition
DocumentModelCoords.cpp:88
DocumentModelCoords::originRadius
double originRadius() const
Get method for origin radius in polar mode.
Definition
DocumentModelCoords.cpp:174
EllipseParameters
Parameters that define an ellipse about the specified center, at the specified angle from alignment w...
Definition
EllipseParameters.h:16
GuidelineProjectorConstantR::GuidelineProjectorConstantR
GuidelineProjectorConstantR()
Single constructor.
Definition
GuidelineProjectorConstantR.cpp:17
GuidelineProjectorConstantR::fromCoordinateR
EllipseParameters fromCoordinateR(const Transformation &transformation, const QRectF &sceneRect, double rGraph)
Return line through y in graph coordinates.
Definition
GuidelineProjectorConstantR.cpp:25
GuidelineProjectorConstantR::fromPosScreen
EllipseParameters fromPosScreen(const Transformation &transformation, const QRectF &sceneRect, const QPointF &posScreen)
Return line through point in screen coordinates.
Definition
GuidelineProjectorConstantR.cpp:70
GuidelineProjectorConstantR::~GuidelineProjectorConstantR
~GuidelineProjectorConstantR()
Definition
GuidelineProjectorConstantR.cpp:21
Transformation
Affine transformation between screen and graph coordinates, based on digitized axis points.
Definition
Transformation.h:32
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
Transformation::modelCoords
DocumentModelCoords modelCoords() const
Get method for DocumentModelCoords.
Definition
Transformation.cpp:262
ellipseFromParallelogram
void ellipseFromParallelogram(double xTL, double yTL, double xTR, double yTR, double xBR, double yBR, double &angleRadians, double &aAligned, double &bAligned)
Calculate ellipse parameters that is incribed in a parallelogram centered at the origin,...
Definition
mmsubs.cpp:70
mmsubs.h
Generated on
for Engauge Digitizer by
1.17.0