Engauge Digitizer 2
Loading...
Searching...
No Matches
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"
10#include "Logger.h"
11#include "mmsubs.h"
12#include <QList>
13#include <qmath.h>
14#include <QRectF>
15#include "Transformation.h"
16
20
24
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
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
Definition CoordScale.h:14
CoordScale coordScaleYRadius() const
Get method for linear/log scale on y/radius.
double originRadius() const
Get method for origin radius in polar mode.
Parameters that define an ellipse about the specified center, at the specified angle from alignment w...
EllipseParameters()
Constructor when this class is expected to be never used.
EllipseParameters fromCoordinateR(const Transformation &transformation, const QRectF &sceneRect, double rGraph)
Return line through y in graph coordinates.
EllipseParameters fromPosScreen(const Transformation &transformation, const QRectF &sceneRect, const QPointF &posScreen)
Return line through point in screen coordinates.
Affine transformation between screen and graph coordinates, based on digitized axis points.
void transformRawGraphToScreen(const QPointF &pointRaw, QPointF &pointScreen) const
Transform from raw graph coordinates to linear cartesian graph coordinates, then to screen coordinate...
void transformScreenToRawGraph(const QPointF &coordScreen, QPointF &coordGraph) const
Transform from cartesian pixel screen coordinates to cartesian/polar graph coordinates.
DocumentModelCoords modelCoords() const
Get method for DocumentModelCoords.
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