29 m_transformIsDefined (false)
60 const QPointF &posFrom1,
61 const QPointF &posFrom2,
62 const QPointF &posTo0,
63 const QPointF &posTo1,
64 const QPointF &posTo2)
66 qCInfo(ENGAUGE_LOG) <<
"Transformation::calculateTransformFromLinearCartesianPoints";
69 from.setMatrix (posFrom0.x(), posFrom1.x(), posFrom2.x(),
70 posFrom0.y(), posFrom1.y(), posFrom2.y(),
73 to.setMatrix (posTo0.x(), posTo1.x(), posTo2.x(),
74 posTo0.y(), posTo1.y(), posTo2.y(),
76 QTransform fromInv = from.inverted ();
82 const QPointF &posGraphIn)
85 QPointF posGraphCartesian = posGraphIn;
90 double angleRadians = 0;
97 angleRadians = posGraphIn.x () * M_PI / 180.0;
101 angleRadians = posGraphIn.x () * M_PI / 200.0;
105 angleRadians = posGraphIn.x ();
109 angleRadians = posGraphIn.x () * 2.0 * M_PI;
116 double radius = posGraphIn.y ();
117 posGraphCartesian.setX (radius * cos (angleRadians));
118 posGraphCartesian.setY (radius * sin (angleRadians));
121 return posGraphCartesian;
125 const QPointF &posGraphIn)
128 QPointF posGraphCartesianOrPolar = posGraphIn;
133 double angleRadians = qAtan2 (posGraphIn.y (),
141 posGraphCartesianOrPolar.setX (angleRadians * 180.0 / M_PI);
145 posGraphCartesianOrPolar.setX (angleRadians * 200.0 / M_PI);
149 posGraphCartesianOrPolar.setX (angleRadians);
153 posGraphCartesianOrPolar.setX (angleRadians / (2.0 * M_PI));
160 double radius = qSqrt (posGraphIn.x () * posGraphIn.x () + posGraphIn.y () * posGraphIn.y ());
161 posGraphCartesianOrPolar.setY (radius);
164 return posGraphCartesianOrPolar;
168 QString &coordsScreen,
169 QString &coordsGraph,
170 QString &resolutionsGraph,
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';
177 QString needMoreText = (usingScaleBar ?
178 QObject::tr (
"Need scale bar") :
179 QObject::tr (
"Need more axis points"));
181 if (cursorScreen.x() < 0 ||
182 cursorScreen.y() < 0) {
187 resolutionsGraph =
"";
191 coordsScreen = QString(
"(%1, %2)")
192 .arg (cursorScreen.x ())
193 .arg (cursorScreen.y ());
195 if (m_transformIsDefined) {
198 QPointF cursorScreenDelta (cursorScreen.x () + X_DELTA_PIXELS,
199 cursorScreen.y () + Y_DELTA_PIXELS);
202 QPointF pointGraph, pointGraphDelta;
209 double resolutionXGraph = qAbs ((pointGraphDelta.x () - pointGraph.x ()) / X_DELTA_PIXELS);
210 double resolutionYGraph = qAbs ((pointGraphDelta.y () - pointGraph.y ()) / Y_DELTA_PIXELS);
214 QString xThetaFormatted, yRadiusFormatted;
224 coordsGraph = QString (
"(%1, %2)")
225 .arg (xThetaFormatted)
226 .arg (yRadiusFormatted);
228 resolutionsGraph = QString (
"(%1, %2)")
229 .arg (resolutionXGraph, UNCONSTRAINED_FIELD_WIDTH, FORMAT,
PRECISION_DIGITS)
230 .arg (resolutionYGraph, UNCONSTRAINED_FIELD_WIDTH, FORMAT,
PRECISION_DIGITS);
234 coordsGraph = QString (
"<font color=\"red\">%1</font>")
236 resolutionsGraph = coordsGraph;
245 m_transformIsDefined =
true;
259 return qLn (r) - qLn (rCenter);
264 return m_modelCoords;
269 return m_modelGeneral;
274 return m_modelMainWindow;
281 QTextStream strInner (&text);
284 strOuter << text.toLatin1().data ();
293 QTextStream strInner (&text);
302 QTextStream &str)
const
304 str <<
"Transformation\n";
308 if (m_transformIsDefined) {
310 str << indentation <<
"affine=" << (m_transform.isAffine() ?
"yes" :
"no") <<
" matrix=("
311 << m_transform.m11() <<
", " << m_transform.m12() <<
", " << m_transform.m13() <<
", "
312 << m_transform.m21() <<
", " << m_transform.m22() <<
", " << m_transform.m23() <<
", "
313 << m_transform.m31() <<
", " << m_transform.m32() <<
", " << m_transform.m33() <<
")";
317 str << indentation <<
"undefined";
324 qCInfo(ENGAUGE_LOG) <<
"Transformation::resetOnLoad";
326 m_transformIsDefined =
false;
329double Transformation::roundOffSmallValues (
double value,
double range)
349 return m_transformIsDefined;
353 QPointF &pointRawGraph)
const
358 pointRawGraph = pointLinearCartesianGraph;
369 pointRawGraph.setY (pointRawGraph.y() + m_modelCoords.originRadius());
374 pointRawGraph.setX (qExp (pointRawGraph.x()));
384 offset = m_modelCoords.originRadius();
387 pointRawGraph.setY (qExp (pointRawGraph.y() + qLn (offset)));
392 QPointF &coordScreen)
const
396 coordScreen = m_transform.inverted ().transposed ().map (coordGraph);
405 QPointF &pointLinearCartesian)
const
410 double x = pointRaw.x();
411 double y = pointRaw.y();
416 y -= m_modelCoords.originRadius();
427 m_modelCoords.originRadius());
442 pointLinearCartesian.setX (x);
443 pointLinearCartesian.setY (y);
447 QPointF &pointScreen)
const
449 QPointF pointLinearCartesianGraph;
452 pointLinearCartesianGraph);
458 QPointF &coordGraph)
const
462 coordGraph = m_transform.transposed ().map (coordScreen);
466 QPointF &coordGraph)
const
468 QPointF pointLinearCartesianGraph;
470 pointLinearCartesianGraph);
479 qCDebug(ENGAUGE_LOG) <<
"Transformation::update";
483 m_transformIsDefined =
false;
494 Functor2wRet<const QString &, const Point&, CallbackSearchReturn> ftorWithCallback = functor_ret (ftor,
505 m_transformIsDefined =
false;
511void Transformation::updateTransformFromMatrices (
const QTransform &matrixScreen,
512 const QTransform &matrixGraph)
516 m_transformIsDefined =
true;
519 QPointF pointGraphRaw0 (matrixGraph.m11(),
521 QPointF pointGraphRaw1 (matrixGraph.m12(),
523 QPointF pointGraphRaw2 (matrixGraph.m13(),
526 QPointF pointGraphLinearCart0, pointGraphLinearCart1, pointGraphLinearCart2;
528 pointGraphLinearCart0);
530 pointGraphLinearCart1);
532 pointGraphLinearCart2);
536 QPointF (matrixScreen.m12(), matrixScreen.m22()),
537 QPointF (matrixScreen.m13(), matrixScreen.m23()),
538 QPointF (pointGraphLinearCart0.x(), pointGraphLinearCart0.y()),
539 QPointF (pointGraphLinearCart1.x(), pointGraphLinearCart1.y()),
540 QPointF (pointGraphLinearCart2.x(), pointGraphLinearCart2.y()));
543 QTransform matrixGraphLinear (pointGraphLinearCart0.x(),
544 pointGraphLinearCart1.x(),
545 pointGraphLinearCart2.x(),
546 pointGraphLinearCart0.y(),
547 pointGraphLinearCart1.y(),
548 pointGraphLinearCart2.y());
550 QPointF pointScreenRoundTrip0, pointScreenRoundTrip1, pointScreenRoundTrip2;
552 pointScreenRoundTrip0);
554 pointScreenRoundTrip1);
556 pointScreenRoundTrip2);
558 QPointF pointScreen0 (matrixScreen.m11(),
560 QPointF pointScreen1 (matrixScreen.m12(),
562 QPointF pointScreen2 (matrixScreen.m13(),
565 qCInfo(ENGAUGE_LOG) <<
"Transformation::updateTransformFromMatrices"
568 <<
" matrixGraphLinear=\n" <<
QTransformToString (matrixGraphLinear).toLatin1().data() <<
"\n"
569 <<
" originalScreen0=" <<
QPointFToString (pointScreen0).toLatin1().data() <<
"\n"
570 <<
" originalScreen1=" <<
QPointFToString (pointScreen1).toLatin1().data() <<
"\n"
571 <<
" originalScreen2=" <<
QPointFToString (pointScreen2).toLatin1().data() <<
"\n"
572 <<
" roundTripScreen0=" <<
QPointFToString (pointScreenRoundTrip0).toLatin1().data() <<
"\n"
573 <<
" roundTripScreen1=" <<
QPointFToString (pointScreenRoundTrip1).toLatin1().data() <<
"\n"
574 <<
" roundTripScreen2=" <<
QPointFToString (pointScreenRoundTrip2).toLatin1().data() <<
"\n";
@ COORD_UNITS_POLAR_THETA_DEGREES_MINUTES_SECONDS_NSEW
@ COORD_UNITS_POLAR_THETA_TURNS
@ COORD_UNITS_POLAR_THETA_RADIANS
@ COORD_UNITS_POLAR_THETA_DEGREES_MINUTES
@ COORD_UNITS_POLAR_THETA_DEGREES
@ COORD_UNITS_POLAR_THETA_DEGREES_MINUTES_SECONDS
@ COORD_UNITS_POLAR_THETA_GRADIANS
#define ENGAUGE_ASSERT(cond)
Drop in replacement for Q_ASSERT.
const QString INDENTATION_DELTA
QString QTransformToString(const QTransform &transform)
QString QPointFToString(const QPointF &pos)
QTransform matrixGraph() const
Returns graph coordinates matrix after transformIsDefined has already indicated success.
CallbackSearchReturn callback(const QString &curveName, const Point &point)
Callback method.
QTransform matrixScreen() const
Returns screen coordinates matrix after transformIsDefined has already indicated success.
Model for DlgSettingsCoords and CmdSettingsCoords.
Model for DlgSettingsGeneral and CmdSettingsGeneral.
DocumentModelGeneral modelGeneral() const
Get method for DocumentModelGeneral.
DocumentModelCoords modelCoords() const
Get method for DocumentModelCoords.
DocumentAxesPointsRequired documentAxesPointsRequired() const
Get method for DocumentAxesPointsRequired.
Model for DlgSettingsMainWindow.