Engauge Digitizer  2
Public Member Functions | List of all members
FittingCurve Class Reference

Curve that overlays the current scene so the regression-fitted curve is visible. More...

#include <FittingCurve.h>

Inheritance diagram for FittingCurve:
Inheritance graph
Collaboration diagram for FittingCurve:
Collaboration graph

Public Member Functions

 FittingCurve (const FittingCurveCoefficients &fittingCoef, double xMin, double xMax, bool isLogXTheta, bool isLogYRadius, const Transformation &transformation)
 Single constructor. More...
 
virtual ~FittingCurve ()
 

Detailed Description

Curve that overlays the current scene so the regression-fitted curve is visible.

Definition at line 16 of file FittingCurve.h.

Constructor & Destructor Documentation

◆ FittingCurve()

FittingCurve::FittingCurve ( const FittingCurveCoefficients fittingCoef,
double  xMin,
double  xMax,
bool  isLogXTheta,
bool  isLogYRadius,
const Transformation transformation 
)

Single constructor.

Definition at line 15 of file FittingCurve.cpp.

21 {
22  const int NUM_POINTS = 1000; // Use so many points that spline interpolation is not needed for smoothness
23  const double Z_LINE = 500; // More than the z value for lines since this line takes priority, and user can hide it
24 
25  setZValue (Z_LINE);
26  setPen (QPen (QColor (Qt::red)));
27 
28  QPainterPath path;
29 
30  if (transformation.transformIsDefined()) {
31 
32  for (int i = 0; i < NUM_POINTS; i++) {
33 
34  // Compute (x,y) point in graph coordinates
35  double s = double (i) / double (NUM_POINTS - 1);
36  double x = xMin + s * (xMax - xMin);
37  double y = yFromCoefficientsAndX (fittingCoef,
38  x);
39 
40  // The coefficients were computed assuming the x and y values were transformed if they were log scale base 10, so
41  // we must compensate here in the same way
42  if (isLogXTheta) {
43  x = qPow (10.0, x);
44  }
45  if (isLogYRadius) {
46  y = qPow (10.0, y);
47  }
48 
49  // Convert to screen coordinates
50  QPointF posGraph (x, y);
51  QPointF posScreen;
52  transformation.transformRawGraphToScreen (posGraph,
53  posScreen);
54 
55  // Add point to line
56  if (i == 0) {
57  path.moveTo (posScreen);
58  } else {
59  path.lineTo (posScreen);
60  }
61  }
62  }
63 
64  setPath (path);
65 }
void transformRawGraphToScreen(const QPointF &pointRaw, QPointF &pointScreen) const
Transform from raw graph coordinates to linear cartesian graph coordinates, then to screen coordinate...
bool transformIsDefined() const
Transform is defined when at least three axis points have been digitized.

◆ ~FittingCurve()

FittingCurve::~FittingCurve ( )
virtual

Definition at line 67 of file FittingCurve.cpp.

68 {
69 }

The documentation for this class was generated from the following files: