Engauge Digitizer 2
Loading...
Searching...
No Matches
CallbackAxisPointsAbstract Class Reference

Callback for collecting axis points and then performing common calculations on those axis points. More...

#include <CallbackAxisPointsAbstract.h>

Inheritance diagram for CallbackAxisPointsAbstract:
Inheritance graph
Collaboration diagram for CallbackAxisPointsAbstract:
Collaboration graph

Public Member Functions

 CallbackAxisPointsAbstract (const DocumentModelCoords &modelCoords, DocumentAxesPointsRequired documentAxesPointsRequired)
 Constructor for when all of the existing axis points are to be processed as is.
 CallbackAxisPointsAbstract (const DocumentModelCoords &modelCoords, const QString pointIdentifierOverride, const QPointF &posGraphOverride, const QPointF &posScreenOverride, DocumentAxesPointsRequired documentAxesPointsRequired)
 Constructor for when the data for one of the existing axis points is to be locally overwritten.
CallbackSearchReturn callback (const QString &curveName, const Point &point)
 Callback method.
QTransform matrixGraph () const
 Returns graph coordinates matrix after transformIsDefined has already indicated success.
QTransform matrixScreen () const
 Returns screen coordinates matrix after transformIsDefined has already indicated success.
double xGraphRange () const
 Return the range of the x graph coordinate from low to high, after the transform is defined.
double yGraphRange () const
 Return the range of the y graph coordinate from low to high, after the transform is defined.

Protected Member Functions

DocumentAxesPointsRequired documentAxesPointsRequired () const
 Number of axes points required for the transformation.
QString errorMessage () const
 This value is checked after iterating to see what was wrong if the axis data was incorrect.
bool isError () const
 This value is checked after iterating to see if the axis data is correct.
unsigned int numberAxisPoints () const
 Number of axis points which is less than 3 if the axes curve is incomplete.

Friends

class TestGraphCoords
 For unit testing.

Detailed Description

Callback for collecting axis points and then performing common calculations on those axis points.

This class collects 3x3 matrix G which contains columns of graph coordinates, and 3x3 matrix S which contains columns of screen coordinates. Although it goes almost as far as solving (G) = (T) (S) for the transformation T, that is left for the Transformation class. This class does, however, do the sanity checking (like for collinear points) so the gui can provide immediate feedback to the user well before the Transformation class gets involved

This class is versatile. The cases are:

  1. Use all existing axis points, and then the subclass can effectively append one more point to check if that additional point would violate any constraints (prior to adding the point)
  2. Use all existing axis points, but override the details of one existing axis point to see if those details violate any constraint (prior to editing the point)
  3. Use all existing axis points as is. This is for computing the transformation after axis points are added/edited

Definition at line 35 of file CallbackAxisPointsAbstract.h.

Constructor & Destructor Documentation

◆ CallbackAxisPointsAbstract() [1/2]

CallbackAxisPointsAbstract::CallbackAxisPointsAbstract ( const DocumentModelCoords & modelCoords,
DocumentAxesPointsRequired documentAxesPointsRequired )

Constructor for when all of the existing axis points are to be processed as is.

Definition at line 24 of file CallbackAxisPointsAbstract.cpp.

25 :
26 m_modelCoords (modelCoords),
27 m_isError (false),
28 m_documentAxesPointsRequired (documentAxesPointsRequired)
29{
30}
DocumentAxesPointsRequired documentAxesPointsRequired() const
Number of axes points required for the transformation.

◆ CallbackAxisPointsAbstract() [2/2]

CallbackAxisPointsAbstract::CallbackAxisPointsAbstract ( const DocumentModelCoords & modelCoords,
const QString pointIdentifierOverride,
const QPointF & posGraphOverride,
const QPointF & posScreenOverride,
DocumentAxesPointsRequired documentAxesPointsRequired )

Constructor for when the data for one of the existing axis points is to be locally overwritten.

Definition at line 32 of file CallbackAxisPointsAbstract.cpp.

36 :
37 m_modelCoords (modelCoords),
38 m_pointIdentifierOverride (pointIdentifierOverride),
39 m_posScreenOverride (posScreenOverride),
40 m_posGraphOverride (posGraphOverride),
41 m_isError (false),
42 m_documentAxesPointsRequired (documentAxesPointsRequired)
43{
44}

Member Function Documentation

◆ callback()

CallbackSearchReturn CallbackAxisPointsAbstract::callback ( const QString & curveName,
const Point & point )

Callback method.

Definition at line 83 of file CallbackAxisPointsAbstract.cpp.

85{
86 QPointF posScreen = point.posScreen ();
87 QPointF posGraph = point.posGraph ();
88
89 if (m_pointIdentifierOverride == point.identifier ()) {
90
91 // Override the old point coordinates with its new (if all tests are passed) coordinates
92 posScreen = m_posScreenOverride;
93 posGraph = m_posGraphOverride;
94 }
95
96 // Try to compute transform
97 if (m_documentAxesPointsRequired == DOCUMENT_AXES_POINTS_REQUIRED_2) {
98 return callbackRequire2AxisPoints (posScreen,
99 posGraph);
100 } else if (m_documentAxesPointsRequired == DOCUMENT_AXES_POINTS_REQUIRED_3) {
101 return callbackRequire3AxisPoints (posScreen,
102 posGraph);
103 } else {
104 return callbackRequire4AxisPoints (point.isXOnly(),
105 posScreen,
106 posGraph);
107 }
108}
@ DOCUMENT_AXES_POINTS_REQUIRED_3
@ DOCUMENT_AXES_POINTS_REQUIRED_2
QPointF posGraph(ApplyHasCheck applyHasCheck=KEEP_HAS_CHECK) const
Accessor for graph position. Skip check if copying one instance to another.
Definition Point.cpp:395
QPointF posScreen() const
Accessor for screen position.
Definition Point.cpp:404
QString identifier() const
Unique identifier for a specific Point.
Definition Point.cpp:268
bool isXOnly() const
In DOCUMENT_AXES_POINTS_REQUIRED_4 modes, this is true/false if y/x coordinate is undefined.
Definition Point.cpp:286

◆ documentAxesPointsRequired()

DocumentAxesPointsRequired CallbackAxisPointsAbstract::documentAxesPointsRequired ( ) const
protected

Number of axes points required for the transformation.

Definition at line 319 of file CallbackAxisPointsAbstract.cpp.

320{
321 return m_documentAxesPointsRequired;
322}

◆ errorMessage()

QString CallbackAxisPointsAbstract::errorMessage ( ) const
inlineprotected

This value is checked after iterating to see what was wrong if the axis data was incorrect.

Definition at line 76 of file CallbackAxisPointsAbstract.h.

76{ return m_errorMessage; }

◆ isError()

bool CallbackAxisPointsAbstract::isError ( ) const
inlineprotected

This value is checked after iterating to see if the axis data is correct.

The error state does NOT include the case when there are not enough axis points

Definition at line 80 of file CallbackAxisPointsAbstract.h.

80{ return m_isError; }

◆ matrixGraph()

QTransform CallbackAxisPointsAbstract::matrixGraph ( ) const

Returns graph coordinates matrix after transformIsDefined has already indicated success.

Since QMatrix is deprecated the results are returned as QTransform

Definition at line 493 of file CallbackAxisPointsAbstract.cpp.

494{
495 return m_graphOutputsTransform;
496}

◆ matrixScreen()

QTransform CallbackAxisPointsAbstract::matrixScreen ( ) const

Returns screen coordinates matrix after transformIsDefined has already indicated success.

Since QMatrix is deprecated the results are returned as QTransform

Definition at line 498 of file CallbackAxisPointsAbstract.cpp.

499{
500 return m_screenInputsTransform;
501}

◆ numberAxisPoints()

unsigned int CallbackAxisPointsAbstract::numberAxisPoints ( ) const
protected

Number of axis points which is less than 3 if the axes curve is incomplete.

Definition at line 503 of file CallbackAxisPointsAbstract.cpp.

504{
505 if (m_documentAxesPointsRequired == DOCUMENT_AXES_POINTS_REQUIRED_2) {
506 return unsigned (m_screenInputs.count());
507 } else if (m_documentAxesPointsRequired == DOCUMENT_AXES_POINTS_REQUIRED_3) {
508 return unsigned (m_screenInputs.count());
509 } else {
510 return unsigned (m_screenInputsX.count() + m_screenInputsY.count());
511 }
512}

◆ xGraphRange()

double CallbackAxisPointsAbstract::xGraphRange ( ) const
inline

Return the range of the x graph coordinate from low to high, after the transform is defined.

Definition at line 65 of file CallbackAxisPointsAbstract.h.

65{ return m_xGraphHigh - m_xGraphLow; }

◆ yGraphRange()

double CallbackAxisPointsAbstract::yGraphRange ( ) const
inline

Return the range of the y graph coordinate from low to high, after the transform is defined.

Definition at line 68 of file CallbackAxisPointsAbstract.h.

68{ return m_yGraphHigh - m_yGraphLow; }

◆ TestGraphCoords

friend class TestGraphCoords
friend

For unit testing.

Definition at line 38 of file CallbackAxisPointsAbstract.h.


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