Engauge Digitizer  2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Static Public Member Functions | Friends | List of all members
Transformation Class Reference

Affine transformation between screen and graph coordinates, based on digitized axis points. More...

#include <Transformation.h>

Collaboration diagram for Transformation:
Collaboration graph

Public Member Functions

 Transformation ()
 Default constructor. This is marked as undefined until the proper number of axis points are added. More...
 
 Transformation (const Transformation &other)
 Copy constructor. More...
 
Transformationoperator= (const Transformation &other)
 Assignment operator. More...
 
void identity ()
 Identity transformation. More...
 
bool operator!= (const Transformation &other)
 Inequality operator. This is marked as defined. More...
 
void coordTextForStatusBar (QPointF cursorScreen, QString &coordsScreen, QString &coordsGraph, QString &resolutionGraph, bool usingScaleBar)
 Return string descriptions of cursor coordinates for status bar. More...
 
DocumentModelCoords modelCoords () const
 Get method for DocumentModelCoords. More...
 
DocumentModelGeneral modelGeneral () const
 Get method for DocumentModelGeneral. More...
 
MainWindowModel modelMainWindow () const
 Get method for MainWindowModel. More...
 
void printStream (QString indentation, QTextStream &str) const
 Debugging method that supports print method of this class and printStream method of some other class(es) More...
 
void resetOnLoad ()
 Reset, when loading a document after the first, to same state that first document was at when loaded. More...
 
bool transformIsDefined () const
 Transform is defined when at least three axis points have been digitized. More...
 
void transformLinearCartesianGraphToRawGraph (const QPointF &coordGraph, QPointF &coordScreen) const
 Transform from linear cartesian graph coordinates to cartesian, polar, linear, log coordinates. More...
 
void transformLinearCartesianGraphToScreen (const QPointF &coordGraph, QPointF &coordScreen) const
 Transform from linear cartesian graph coordinates to cartesian pixel screen coordinates. More...
 
QTransform transformMatrix () const
 Get method for copying only, for the transform matrix. More...
 
void transformRawGraphToLinearCartesianGraph (const QPointF &pointRaw, QPointF &pointLinearCartesian) const
 Convert graph coordinates (linear or log, cartesian or polar) to linear cartesian coordinates. More...
 
void transformRawGraphToScreen (const QPointF &pointRaw, QPointF &pointScreen) const
 Transform from raw graph coordinates to linear cartesian graph coordinates, then to screen coordinates. More...
 
void transformScreenToLinearCartesianGraph (const QPointF &pointScreen, QPointF &pointLinearCartesian) const
 Transform screen coordinates to linear cartesian coordinates. More...
 
void transformScreenToRawGraph (const QPointF &coordScreen, QPointF &coordGraph) const
 Transform from cartesian pixel screen coordinates to cartesian/polar graph coordinates. More...
 
void update (bool fileIsLoaded, const CmdMediator &cmdMediator, const MainWindowModel &modelMainWindow)
 Update transform by iterating through the axis points. More...
 

Static Public Member Functions

static QTransform calculateTransformFromLinearCartesianPoints (const QPointF &posFrom0, const QPointF &posFrom1, const QPointF &posFrom2, const QPointF &posTo0, const QPointF &posTo1, const QPointF &posTo2)
 Calculate QTransform using from/to points that have already been adjusted for, when applicable, log scaling and polar coordinates. More...
 
static QPointF cartesianFromCartesianOrPolar (const DocumentModelCoords &modelCoords, const QPointF &posGraphIn)
 Output cartesian coordinates from input cartesian or polar coordinates. This is static for easier use externally. More...
 
static QPointF cartesianOrPolarFromCartesian (const DocumentModelCoords &modelCoords, const QPointF &posGraphIn)
 Output cartesian or polar coordinates from input cartesian coordinates. This is static for easier use externally. More...
 
static double logToLinearCartesian (double xy)
 Convert cartesian scaling from log to linear. Calling code is responsible for determining if this is necessary. More...
 
static double logToLinearRadius (double r, double rCenter)
 Convert radius scaling from log to linear. Calling code is responsible for determining if this is necessary. More...
 

Friends

class TestExport
 
class TestSplineDrawer
 
class TestTransformation
 

Detailed Description

Affine transformation between screen and graph coordinates, based on digitized axis points.

Transformation from screen pixels to graph coordinates involves two steps:

  1. Transform from screen pixels (which are linear and cartesian) to linear cartesian graph coordinates
  2. Transform from linear cartesian graph coordinates to the final graph coordinates, which are linear or log scaled, and cartesian or polar

Transformation from graph coordinates to screen pixels reverses the steps involved in the transformation from screen pixels to graph coordinates

Log scaling is calculated as (xLinear - xLogMin) / (xLogMax - xLogMin) = (ln(xLog) - ln(xLogMin)) / (ln(xLogMax) - ln(xLogMin)), which leaves the points (xLogMin,yLonMin) and (xLogMax,yLogMax) unaffected but gives log growth on all other points

Definition at line 31 of file Transformation.h.

Constructor & Destructor Documentation

Transformation::Transformation ( )

Default constructor. This is marked as undefined until the proper number of axis points are added.

Definition at line 28 of file Transformation.cpp.

28  :
29  m_transformIsDefined (false)
30 {
31 }
Transformation::Transformation ( const Transformation other)

Copy constructor.

Definition at line 33 of file Transformation.cpp.

33  :
34  m_transformIsDefined (other.transformIsDefined()),
35  m_transform (other.transformMatrix())
36 {
37  setModelCoords (other.modelCoords(),
38  other.modelGeneral(),
39  other.modelMainWindow());
40 }
QTransform transformMatrix() const
Get method for copying only, for the transform matrix.
MainWindowModel modelMainWindow() const
Get method for MainWindowModel.
DocumentModelCoords modelCoords() const
Get method for DocumentModelCoords.
bool transformIsDefined() const
Transform is defined when at least three axis points have been digitized.
DocumentModelGeneral modelGeneral() const
Get method for DocumentModelGeneral.

Member Function Documentation

QTransform Transformation::calculateTransformFromLinearCartesianPoints ( const QPointF &  posFrom0,
const QPointF &  posFrom1,
const QPointF &  posFrom2,
const QPointF &  posTo0,
const QPointF &  posTo1,
const QPointF &  posTo2 
)
static

Calculate QTransform using from/to points that have already been adjusted for, when applicable, log scaling and polar coordinates.

The points are linear and cartesian.

This method is kept very generic since it used for different types of transformations:

  1. In many place to calculate screen-to/from-graph
  2. By Checker to calculate unaligned-to/from-aligned

Definition at line 59 of file Transformation.cpp.

65 {
66  LOG4CPP_INFO_S ((*mainCat)) << "Transformation::calculateTransformFromLinearCartesianPoints";
67 
68  QTransform from, to;
69  from.setMatrix (posFrom0.x(), posFrom1.x(), posFrom2.x(),
70  posFrom0.y(), posFrom1.y(), posFrom2.y(),
71  1.0, 1.0, 1.0);
72 
73  to.setMatrix (posTo0.x(), posTo1.x(), posTo2.x(),
74  posTo0.y(), posTo1.y(), posTo2.y(),
75  1.0, 1.0, 1.0);
76  QTransform fromInv = from.inverted ();
77 
78  return to * fromInv;
79 }
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
log4cpp::Category * mainCat
Definition: Logger.cpp:14
QPointF Transformation::cartesianFromCartesianOrPolar ( const DocumentModelCoords modelCoords,
const QPointF &  posGraphIn 
)
static

Output cartesian coordinates from input cartesian or polar coordinates. This is static for easier use externally.

Definition at line 81 of file Transformation.cpp.

83 {
84  // Initialize assuming input coordinates are already cartesian
85  QPointF posGraphCartesian = posGraphIn;
86 
87  if (modelCoords.coordsType() == COORDS_TYPE_POLAR) {
88 
89  // Input coordinates are polar so convert them
90  double angleRadians = 0; // Initialized to prevent compiler warning
91  switch (modelCoords.coordUnitsTheta())
92  {
97  angleRadians = posGraphIn.x () * PI / 180.0;
98  break;
99 
101  angleRadians = posGraphIn.x () * PI / 200.0;
102  break;
103 
105  angleRadians = posGraphIn.x ();
106  break;
107 
109  angleRadians = posGraphIn.x () * 2.0 * PI;
110  break;
111 
112  default:
113  ENGAUGE_ASSERT (false);
114  }
115 
116  double radius = posGraphIn.y ();
117  posGraphCartesian.setX (radius * cos (angleRadians));
118  posGraphCartesian.setY (radius * sin (angleRadians));
119  }
120 
121  return posGraphCartesian;
122 }
const double PI
CoordsType coordsType() const
Get method for coordinates type.
CoordUnitsPolarTheta coordUnitsTheta() const
Get method for theta unit.
#define ENGAUGE_ASSERT(cond)
Drop in replacement for Q_ASSERT if defined(QT_NO_DEBUG) &amp;&amp; !defined(QT_FORCE_ASSERTS) define ENGAUGE...
Definition: EngaugeAssert.h:20
QPointF Transformation::cartesianOrPolarFromCartesian ( const DocumentModelCoords modelCoords,
const QPointF &  posGraphIn 
)
static

Output cartesian or polar coordinates from input cartesian coordinates. This is static for easier use externally.

Definition at line 124 of file Transformation.cpp.

126 {
127  // Initialize assuming output coordinates are to be cartesian
128  QPointF posGraphCartesianOrPolar = posGraphIn;
129 
130  if (modelCoords.coordsType() == COORDS_TYPE_POLAR) {
131 
132  // Output coordinates are to be polar so convert them
133  double angleRadians = qAtan2 (posGraphIn.y (),
134  posGraphIn.x ());
135  switch (modelCoords.coordUnitsTheta())
136  {
141  posGraphCartesianOrPolar.setX (angleRadians * 180.0 / PI);
142  break;
143 
145  posGraphCartesianOrPolar.setX (angleRadians * 200.0 / PI);
146  break;
147 
149  posGraphCartesianOrPolar.setX (angleRadians);
150  break;
151 
153  posGraphCartesianOrPolar.setX (angleRadians / 2.0 / PI);
154  break;
155 
156  default:
157  ENGAUGE_ASSERT (false);
158  }
159 
160  double radius = qSqrt (posGraphIn.x () * posGraphIn.x () + posGraphIn.y () * posGraphIn.y ());
161  posGraphCartesianOrPolar.setY (radius);
162  }
163 
164  return posGraphCartesianOrPolar;
165 }
const double PI
CoordsType coordsType() const
Get method for coordinates type.
CoordUnitsPolarTheta coordUnitsTheta() const
Get method for theta unit.
#define ENGAUGE_ASSERT(cond)
Drop in replacement for Q_ASSERT if defined(QT_NO_DEBUG) &amp;&amp; !defined(QT_FORCE_ASSERTS) define ENGAUGE...
Definition: EngaugeAssert.h:20
void Transformation::coordTextForStatusBar ( QPointF  cursorScreen,
QString &  coordsScreen,
QString &  coordsGraph,
QString &  resolutionGraph,
bool  usingScaleBar 
)

Return string descriptions of cursor coordinates for status bar.

Definition at line 167 of file Transformation.cpp.

172 {
173  const int UNCONSTRAINED_FIELD_WIDTH = 0;
174  const double X_DELTA_PIXELS = 1.0, Y_DELTA_PIXELS = 1.0;
175  const char FORMAT = 'g';
176 
177  QString needMoreText = (usingScaleBar ?
178  QObject::tr ("Need scale bar") :
179  QObject::tr ("Need more axis points"));
180 
181  if (cursorScreen.x() < 0 ||
182  cursorScreen.y() < 0) {
183 
184  // Out of bounds, so return empty text
185  coordsScreen = "";
186  coordsGraph = "";
187  resolutionsGraph = "";
188 
189  } else {
190 
191  coordsScreen = QString("(%1, %2)")
192  .arg (cursorScreen.x ())
193  .arg (cursorScreen.y ());
194 
195  if (m_transformIsDefined) {
196 
197  // For resolution we compute graph coords for cursorScreen, and then for cursorScreen plus a delta
198  QPointF cursorScreenDelta (cursorScreen.x () + X_DELTA_PIXELS,
199  cursorScreen.y () + Y_DELTA_PIXELS);
200 
201  // Convert to graph coordinates
202  QPointF pointGraph, pointGraphDelta;
203  transformScreenToRawGraph (cursorScreen,
204  pointGraph);
205  transformScreenToRawGraph (cursorScreenDelta,
206  pointGraphDelta);
207 
208  // Compute graph resolutions at cursor
209  double resolutionXGraph = qAbs ((pointGraphDelta.x () - pointGraph.x ()) / X_DELTA_PIXELS);
210  double resolutionYGraph = qAbs ((pointGraphDelta.y () - pointGraph.y ()) / Y_DELTA_PIXELS);
211 
212  // Formatting for date/time and degrees/minutes/seconds is only done on coordinates, and not on resolution
213  FormatCoordsUnits format;
214  QString xThetaFormatted, yRadiusFormatted;
215  format.unformattedToFormatted (pointGraph.x(),
216  pointGraph.y(),
217  m_modelCoords,
218  m_modelGeneral,
219  m_modelMainWindow,
220  xThetaFormatted,
221  yRadiusFormatted,
222  *this);
223 
224  coordsGraph = QString ("(%1, %2)")
225  .arg (xThetaFormatted)
226  .arg (yRadiusFormatted);
227 
228  resolutionsGraph = QString ("(%1, %2)")
229  .arg (resolutionXGraph, UNCONSTRAINED_FIELD_WIDTH, FORMAT, PRECISION_DIGITS)
230  .arg (resolutionYGraph, UNCONSTRAINED_FIELD_WIDTH, FORMAT, PRECISION_DIGITS);
231 
232  } else {
233 
234  coordsGraph = QString ("<font color=\"red\">%1</font>")
235  .arg (needMoreText);
236  resolutionsGraph = coordsGraph;
237 
238  }
239  }
240 }
void transformScreenToRawGraph(const QPointF &coordScreen, QPointF &coordGraph) const
Transform from cartesian pixel screen coordinates to cartesian/polar graph coordinates.
const int PRECISION_DIGITS
Max number of significant digits.
void unformattedToFormatted(double xThetaUnformatted, double yRadiusUnformatted, const DocumentModelCoords &modelCoords, const DocumentModelGeneral &modelGeneral, const MainWindowModel &mainWindowModel, QString &xThetaFormatted, QString &yRadiusFormatted, const Transformation &transformation) const
Convert unformatted numeric value to formatted string. Transformation is used to determine best resol...
Highest-level wrapper around other Formats classes.
void Transformation::identity ( )

Identity transformation.

Definition at line 242 of file Transformation.cpp.

243 {
244  // Initialize assuming points (0,0) (1,0) (0,1)
245  m_transformIsDefined = true;
246 
247  QTransform ident;
248  m_transform = ident;
249 }
double Transformation::logToLinearCartesian ( double  xy)
static

Convert cartesian scaling from log to linear. Calling code is responsible for determining if this is necessary.

Definition at line 251 of file Transformation.cpp.

252 {
253  return qLn (xy);
254 }
double Transformation::logToLinearRadius ( double  r,
double  rCenter 
)
static

Convert radius scaling from log to linear. Calling code is responsible for determining if this is necessary.

Definition at line 256 of file Transformation.cpp.

258 {
259  return qLn (r) - qLn (rCenter);
260 }
DocumentModelCoords Transformation::modelCoords ( ) const

Get method for DocumentModelCoords.

Definition at line 262 of file Transformation.cpp.

263 {
264  return m_modelCoords;
265 }
DocumentModelGeneral Transformation::modelGeneral ( ) const

Get method for DocumentModelGeneral.

Definition at line 267 of file Transformation.cpp.

268 {
269  return m_modelGeneral;
270 }
MainWindowModel Transformation::modelMainWindow ( ) const

Get method for MainWindowModel.

Definition at line 272 of file Transformation.cpp.

273 {
274  return m_modelMainWindow;
275 }
bool Transformation::operator!= ( const Transformation other)

Inequality operator. This is marked as defined.

Definition at line 53 of file Transformation.cpp.

54 {
55  return (m_transformIsDefined != other.transformIsDefined()) ||
56  (m_transform != other.transformMatrix ());
57 }
QTransform transformMatrix() const
Get method for copying only, for the transform matrix.
bool transformIsDefined() const
Transform is defined when at least three axis points have been digitized.
Transformation & Transformation::operator= ( const Transformation other)

Assignment operator.

Definition at line 42 of file Transformation.cpp.

43 {
44  m_transformIsDefined = other.transformIsDefined();
45  m_transform = other.transformMatrix ();
46  setModelCoords (other.modelCoords(),
47  other.modelGeneral(),
48  other.modelMainWindow());
49 
50  return *this;
51 }
QTransform transformMatrix() const
Get method for copying only, for the transform matrix.
MainWindowModel modelMainWindow() const
Get method for MainWindowModel.
DocumentModelCoords modelCoords() const
Get method for DocumentModelCoords.
bool transformIsDefined() const
Transform is defined when at least three axis points have been digitized.
DocumentModelGeneral modelGeneral() const
Get method for DocumentModelGeneral.
void Transformation::printStream ( QString  indentation,
QTextStream &  str 
) const

Debugging method that supports print method of this class and printStream method of some other class(es)

Definition at line 289 of file Transformation.cpp.

291 {
292  str << "Transformation\n";
293 
294  indentation += INDENTATION_DELTA;
295 
296  if (m_transformIsDefined) {
297 
298  str << indentation << "affine=" << (m_transform.isAffine() ? "yes" : "no") << " matrix=("
299  << m_transform.m11() << ", " << m_transform.m12() << ", " << m_transform.m13() << ", "
300  << m_transform.m21() << ", " << m_transform.m22() << ", " << m_transform.m23() << ", "
301  << m_transform.m31() << ", " << m_transform.m32() << ", " << m_transform.m33() << ")";
302 
303  } else {
304 
305  str << indentation << "undefined";
306 
307  }
308 }
const QString INDENTATION_DELTA
void Transformation::resetOnLoad ( )

Reset, when loading a document after the first, to same state that first document was at when loaded.

Definition at line 310 of file Transformation.cpp.

311 {
312  LOG4CPP_INFO_S ((*mainCat)) << "Transformation::resetOnLoad";
313 
314  m_transformIsDefined = false;
315 }
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
log4cpp::Category * mainCat
Definition: Logger.cpp:14
bool Transformation::transformIsDefined ( ) const

Transform is defined when at least three axis points have been digitized.

Definition at line 335 of file Transformation.cpp.

336 {
337  return m_transformIsDefined;
338 }
void Transformation::transformLinearCartesianGraphToRawGraph ( const QPointF &  coordGraph,
QPointF &  coordScreen 
) const

Transform from linear cartesian graph coordinates to cartesian, polar, linear, log coordinates.

Definition at line 340 of file Transformation.cpp.

342 {
343  // WARNING - the code in this method must mirror the code in transformRawGraphToLinearCartesianGraph. In
344  // other words, making a change here without a corresponding change there will produce a bug
345 
346  pointRawGraph = pointLinearCartesianGraph;
347 
348  // Apply polar coordinates if appropriate
349  if (m_modelCoords.coordsType() == COORDS_TYPE_POLAR) {
350  pointRawGraph = cartesianOrPolarFromCartesian (m_modelCoords,
351  pointRawGraph);
352  }
353 
354  // Apply linear offset to radius if appropriate
355  if ((m_modelCoords.coordsType() == COORDS_TYPE_POLAR) &&
356  (m_modelCoords.coordScaleYRadius() == COORD_SCALE_LINEAR)) {
357  pointRawGraph.setY (pointRawGraph.y() + m_modelCoords.originRadius());
358  }
359 
360  // Apply log scaling if appropriate
361  if (m_modelCoords.coordScaleXTheta() == COORD_SCALE_LOG) {
362  pointRawGraph.setX (qExp (pointRawGraph.x()));
363  }
364 
365  if (m_modelCoords.coordScaleYRadius() == COORD_SCALE_LOG) {
366  double offset;
367  if (m_modelCoords.coordsType() == COORDS_TYPE_CARTESIAN) {
368  // Cartesian
369  offset = ZERO_OFFSET_AFTER_LOG;
370  } else {
371  // Polar radius
372  offset = m_modelCoords.originRadius();
373  }
374 
375  pointRawGraph.setY (qExp (pointRawGraph.y() + qLn (offset)));
376  }
377 }
const double ZERO_OFFSET_AFTER_LOG
static QPointF cartesianOrPolarFromCartesian(const DocumentModelCoords &modelCoords, const QPointF &posGraphIn)
Output cartesian or polar coordinates from input cartesian coordinates. This is static for easier use...
CoordScale coordScaleYRadius() const
Get method for linear/log scale on y/radius.
double originRadius() const
Get method for origin radius in polar mode.
CoordScale coordScaleXTheta() const
Get method for linear/log scale on x/theta.
CoordsType coordsType() const
Get method for coordinates type.
void Transformation::transformLinearCartesianGraphToScreen ( const QPointF &  coordGraph,
QPointF &  coordScreen 
) const

Transform from linear cartesian graph coordinates to cartesian pixel screen coordinates.

Definition at line 379 of file Transformation.cpp.

381 {
382  ENGAUGE_ASSERT (m_transformIsDefined);
383 
384  coordScreen = m_transform.inverted ().transposed ().map (coordGraph);
385 }
#define ENGAUGE_ASSERT(cond)
Drop in replacement for Q_ASSERT if defined(QT_NO_DEBUG) &amp;&amp; !defined(QT_FORCE_ASSERTS) define ENGAUGE...
Definition: EngaugeAssert.h:20
QTransform Transformation::transformMatrix ( ) const

Get method for copying only, for the transform matrix.

Definition at line 387 of file Transformation.cpp.

388 {
389  return m_transform;
390 }
void Transformation::transformRawGraphToLinearCartesianGraph ( const QPointF &  pointRaw,
QPointF &  pointLinearCartesian 
) const

Convert graph coordinates (linear or log, cartesian or polar) to linear cartesian coordinates.

Definition at line 392 of file Transformation.cpp.

394 {
395  // WARNING - the code in this method must mirror the code in transformLinearCartesianGraphToRawGraph. In
396  // other words, making a change here without a corresponding change there will produce a bug
397 
398  double x = pointRaw.x();
399  double y = pointRaw.y();
400 
401  // Apply linear offset to radius if appropriate
402  if ((m_modelCoords.coordsType() == COORDS_TYPE_POLAR) &&
403  (m_modelCoords.coordScaleYRadius() == COORD_SCALE_LINEAR)) {
404  y -= m_modelCoords.originRadius();
405  }
406 
407  // Apply log scaling if appropriate
408  if (m_modelCoords.coordScaleXTheta() == COORD_SCALE_LOG) {
409  x = logToLinearCartesian (x);
410  }
411 
412  if (m_modelCoords.coordScaleYRadius() == COORD_SCALE_LOG) {
413  if (m_modelCoords.coordsType() == COORDS_TYPE_POLAR) {
414  y = logToLinearRadius (y,
415  m_modelCoords.originRadius());
416  } else {
417  y = logToLinearRadius (y,
419  }
420  }
421 
422  // Apply polar coordinates if appropriate. Note range coordinate has just been transformed if it has log scaling
423  if (m_modelCoords.coordsType() == COORDS_TYPE_POLAR) {
424  QPointF pointCart = cartesianFromCartesianOrPolar (m_modelCoords,
425  QPointF (x, y));
426  x = pointCart.x();
427  y = pointCart.y();
428  }
429 
430  pointLinearCartesian.setX (x);
431  pointLinearCartesian.setY (y);
432 }
static QPointF cartesianFromCartesianOrPolar(const DocumentModelCoords &modelCoords, const QPointF &posGraphIn)
Output cartesian coordinates from input cartesian or polar coordinates. This is static for easier use...
const double ZERO_OFFSET_AFTER_LOG
static double logToLinearRadius(double r, double rCenter)
Convert radius scaling from log to linear. Calling code is responsible for determining if this is nec...
CoordScale coordScaleYRadius() const
Get method for linear/log scale on y/radius.
double originRadius() const
Get method for origin radius in polar mode.
static double logToLinearCartesian(double xy)
Convert cartesian scaling from log to linear. Calling code is responsible for determining if this is ...
CoordScale coordScaleXTheta() const
Get method for linear/log scale on x/theta.
CoordsType coordsType() const
Get method for coordinates type.
void Transformation::transformRawGraphToScreen ( const QPointF &  pointRaw,
QPointF &  pointScreen 
) const

Transform from raw graph coordinates to linear cartesian graph coordinates, then to screen coordinates.

Definition at line 434 of file Transformation.cpp.

436 {
437  QPointF pointLinearCartesianGraph;
438 
440  pointLinearCartesianGraph);
441  transformLinearCartesianGraphToScreen (pointLinearCartesianGraph,
442  pointScreen);
443 }
void transformLinearCartesianGraphToScreen(const QPointF &coordGraph, QPointF &coordScreen) const
Transform from linear cartesian graph coordinates to cartesian pixel screen coordinates.
void transformRawGraphToLinearCartesianGraph(const QPointF &pointRaw, QPointF &pointLinearCartesian) const
Convert graph coordinates (linear or log, cartesian or polar) to linear cartesian coordinates...
void Transformation::transformScreenToLinearCartesianGraph ( const QPointF &  pointScreen,
QPointF &  pointLinearCartesian 
) const

Transform screen coordinates to linear cartesian coordinates.

Definition at line 445 of file Transformation.cpp.

447 {
448  ENGAUGE_ASSERT (m_transformIsDefined);
449 
450  coordGraph = m_transform.transposed ().map (coordScreen);
451 }
#define ENGAUGE_ASSERT(cond)
Drop in replacement for Q_ASSERT if defined(QT_NO_DEBUG) &amp;&amp; !defined(QT_FORCE_ASSERTS) define ENGAUGE...
Definition: EngaugeAssert.h:20
void Transformation::transformScreenToRawGraph ( const QPointF &  coordScreen,
QPointF &  coordGraph 
) const

Transform from cartesian pixel screen coordinates to cartesian/polar graph coordinates.

Definition at line 453 of file Transformation.cpp.

455 {
456  QPointF pointLinearCartesianGraph;
458  pointLinearCartesianGraph);
459  transformLinearCartesianGraphToRawGraph (pointLinearCartesianGraph,
460  coordGraph);
461 }
void transformScreenToLinearCartesianGraph(const QPointF &pointScreen, QPointF &pointLinearCartesian) const
Transform screen coordinates to linear cartesian coordinates.
void transformLinearCartesianGraphToRawGraph(const QPointF &coordGraph, QPointF &coordScreen) const
Transform from linear cartesian graph coordinates to cartesian, polar, linear, log coordinates...
void Transformation::update ( bool  fileIsLoaded,
const CmdMediator cmdMediator,
const MainWindowModel modelMainWindow 
)

Update transform by iterating through the axis points.

Definition at line 463 of file Transformation.cpp.

466 {
467  LOG4CPP_DEBUG_S ((*mainCat)) << "Transformation::update";
468 
469  if (!fileIsLoaded) {
470 
471  m_transformIsDefined = false;
472 
473  } else {
474 
475  setModelCoords (cmdMediator.document().modelCoords(),
476  cmdMediator.document().modelGeneral(),
478 
479  CallbackUpdateTransform ftor (m_modelCoords,
480  cmdMediator.document().documentAxesPointsRequired());
481 
482  Functor2wRet<const QString &, const Point&, CallbackSearchReturn> ftorWithCallback = functor_ret (ftor,
484  cmdMediator.iterateThroughCurvePointsAxes (ftorWithCallback);
485 
486  if (ftor.transformIsDefined ()) {
487 
488  updateTransformFromMatrices (ftor.matrixScreen(),
489  ftor.matrixGraph());
490 
491  } else {
492 
493  m_transformIsDefined = false;
494 
495  }
496  }
497 }
Callback for collecting axis points and then calculating the current transform from those axis points...
DocumentAxesPointsRequired documentAxesPointsRequired() const
Get method for DocumentAxesPointsRequired.
Definition: Document.cpp:363
DocumentModelCoords modelCoords() const
Get method for DocumentModelCoords.
Definition: Document.cpp:695
Document & document()
Provide the Document to commands, primarily for undo/redo processing.
Definition: CmdMediator.cpp:72
MainWindowModel modelMainWindow() const
Get method for MainWindowModel.
log4cpp::Category * mainCat
Definition: Logger.cpp:14
void iterateThroughCurvePointsAxes(const Functor2wRet< const QString &, const Point &, CallbackSearchReturn > &ftorWithCallback)
See Curve::iterateThroughCurvePoints, for the single axes curve.
Definition: CmdMediator.cpp:87
DocumentModelGeneral modelGeneral() const
Get method for DocumentModelGeneral.
Definition: Document.cpp:723
CallbackSearchReturn callback(const QString &curveName, const Point &point)
Callback method.
#define LOG4CPP_DEBUG_S(logger)
Definition: convenience.h:20

Friends And Related Function Documentation

friend class TestExport
friend

Definition at line 34 of file Transformation.h.

friend class TestSplineDrawer
friend

Definition at line 35 of file Transformation.h.

friend class TestTransformation
friend

Definition at line 36 of file Transformation.h.


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