28 m_transformIsDefined (false)
59 const QPointF &posFrom1,
60 const QPointF &posFrom2,
61 const QPointF &posTo0,
62 const QPointF &posTo1,
63 const QPointF &posTo2)
68 from.setMatrix (posFrom0.x(), posFrom1.x(), posFrom2.x(),
69 posFrom0.y(), posFrom1.y(), posFrom2.y(),
72 to.setMatrix (posTo0.x(), posTo1.x(), posTo2.x(),
73 posTo0.y(), posTo1.y(), posTo2.y(),
75 QTransform fromInv = from.inverted ();
81 const QPointF &posGraphIn)
84 QPointF posGraphCartesian = posGraphIn;
89 double angleRadians = 0;
96 angleRadians = posGraphIn.x () * M_PI / 180.0;
100 angleRadians = posGraphIn.x () * M_PI / 200.0;
104 angleRadians = posGraphIn.x ();
108 angleRadians = posGraphIn.x () * 2.0 * M_PI;
115 double radius = posGraphIn.y ();
116 posGraphCartesian.setX (radius * cos (angleRadians));
117 posGraphCartesian.setY (radius * sin (angleRadians));
120 return posGraphCartesian;
124 const QPointF &posGraphIn)
127 QPointF posGraphCartesianOrPolar = posGraphIn;
132 double angleRadians = qAtan2 (posGraphIn.y (),
140 posGraphCartesianOrPolar.setX (angleRadians * 180.0 / M_PI);
144 posGraphCartesianOrPolar.setX (angleRadians * 200.0 / M_PI);
148 posGraphCartesianOrPolar.setX (angleRadians);
152 posGraphCartesianOrPolar.setX (angleRadians / (2.0 * M_PI));
159 double radius = qSqrt (posGraphIn.x () * posGraphIn.x () + posGraphIn.y () * posGraphIn.y ());
160 posGraphCartesianOrPolar.setY (radius);
163 return posGraphCartesianOrPolar;
167 QString &coordsScreen,
168 QString &coordsGraph,
169 QString &resolutionsGraph,
172 const int UNCONSTRAINED_FIELD_WIDTH = 0;
173 const double X_DELTA_PIXELS = 1.0, Y_DELTA_PIXELS = 1.0;
174 const char FORMAT =
'g';
176 QString needMoreText = (usingScaleBar ?
177 QObject::tr (
"Need scale bar") :
178 QObject::tr (
"Need more axis points"));
180 if (cursorScreen.x() < 0 ||
181 cursorScreen.y() < 0) {
186 resolutionsGraph =
"";
190 coordsScreen = QString(
"(%1, %2)")
191 .arg (cursorScreen.x ())
192 .arg (cursorScreen.y ());
194 if (m_transformIsDefined) {
197 QPointF cursorScreenDelta (cursorScreen.x () + X_DELTA_PIXELS,
198 cursorScreen.y () + Y_DELTA_PIXELS);
201 QPointF pointGraph, pointGraphDelta;
208 double resolutionXGraph = qAbs ((pointGraphDelta.x () - pointGraph.x ()) / X_DELTA_PIXELS);
209 double resolutionYGraph = qAbs ((pointGraphDelta.y () - pointGraph.y ()) / Y_DELTA_PIXELS);
213 QString xThetaFormatted, yRadiusFormatted;
223 coordsGraph = QString (
"(%1, %2)")
224 .arg (xThetaFormatted)
225 .arg (yRadiusFormatted);
227 resolutionsGraph = QString (
"(%1, %2)")
228 .arg (resolutionXGraph, UNCONSTRAINED_FIELD_WIDTH, FORMAT,
PRECISION_DIGITS)
229 .arg (resolutionYGraph, UNCONSTRAINED_FIELD_WIDTH, FORMAT,
PRECISION_DIGITS);
233 coordsGraph = QString (
"<font color=\"red\">%1</font>")
235 resolutionsGraph = coordsGraph;
244 m_transformIsDefined =
true;
258 return qLn (r) - qLn (rCenter);
263 return m_modelCoords;
268 return m_modelGeneral;
273 return m_modelMainWindow;
280 QTextStream strInner (&text);
283 strOuter << text.toLatin1().data ();
289 QTextStream &str)
const
291 str <<
"Transformation\n";
295 if (m_transformIsDefined) {
297 str << indentation <<
"affine=" << (m_transform.isAffine() ?
"yes" :
"no") <<
" matrix=("
298 << m_transform.m11() <<
", " << m_transform.m12() <<
", " << m_transform.m13() <<
", "
299 << m_transform.m21() <<
", " << m_transform.m22() <<
", " << m_transform.m23() <<
", "
300 << m_transform.m31() <<
", " << m_transform.m32() <<
", " << m_transform.m33() <<
")";
304 str << indentation <<
"undefined";
313 m_transformIsDefined =
false;
316double Transformation::roundOffSmallValues (
double value,
double range)
336 return m_transformIsDefined;
340 QPointF &pointRawGraph)
const
345 pointRawGraph = pointLinearCartesianGraph;
356 pointRawGraph.setY (pointRawGraph.y() + m_modelCoords.originRadius());
361 pointRawGraph.setX (qExp (pointRawGraph.x()));
371 offset = m_modelCoords.originRadius();
374 pointRawGraph.setY (qExp (pointRawGraph.y() + qLn (offset)));
379 QPointF &coordScreen)
const
383 coordScreen = m_transform.inverted ().transposed ().map (coordGraph);
392 QPointF &pointLinearCartesian)
const
397 double x = pointRaw.x();
398 double y = pointRaw.y();
403 y -= m_modelCoords.originRadius();
414 m_modelCoords.originRadius());
429 pointLinearCartesian.setX (x);
430 pointLinearCartesian.setY (y);
434 QPointF &pointScreen)
const
436 QPointF pointLinearCartesianGraph;
439 pointLinearCartesianGraph);
445 QPointF &coordGraph)
const
449 coordGraph = m_transform.transposed ().map (coordScreen);
453 QPointF &coordGraph)
const
455 QPointF pointLinearCartesianGraph;
457 pointLinearCartesianGraph);
470 m_transformIsDefined =
false;
481 Functor2wRet<const QString &, const Point&, CallbackSearchReturn> ftorWithCallback = functor_ret (ftor,
492 m_transformIsDefined =
false;
498void Transformation::updateTransformFromMatrices (
const QTransform &matrixScreen,
499 const QTransform &matrixGraph)
503 m_transformIsDefined =
true;
506 QPointF pointGraphRaw0 (matrixGraph.m11(),
508 QPointF pointGraphRaw1 (matrixGraph.m12(),
510 QPointF pointGraphRaw2 (matrixGraph.m13(),
513 QPointF pointGraphLinearCart0, pointGraphLinearCart1, pointGraphLinearCart2;
515 pointGraphLinearCart0);
517 pointGraphLinearCart1);
519 pointGraphLinearCart2);
523 QPointF (matrixScreen.m12(), matrixScreen.m22()),
524 QPointF (matrixScreen.m13(), matrixScreen.m23()),
525 QPointF (pointGraphLinearCart0.x(), pointGraphLinearCart0.y()),
526 QPointF (pointGraphLinearCart1.x(), pointGraphLinearCart1.y()),
527 QPointF (pointGraphLinearCart2.x(), pointGraphLinearCart2.y()));
530 QTransform matrixGraphLinear (pointGraphLinearCart0.x(),
531 pointGraphLinearCart1.x(),
532 pointGraphLinearCart2.x(),
533 pointGraphLinearCart0.y(),
534 pointGraphLinearCart1.y(),
535 pointGraphLinearCart2.y());
537 QPointF pointScreenRoundTrip0, pointScreenRoundTrip1, pointScreenRoundTrip2;
539 pointScreenRoundTrip0);
541 pointScreenRoundTrip1);
543 pointScreenRoundTrip2);
545 QPointF pointScreen0 (matrixScreen.m11(),
547 QPointF pointScreen1 (matrixScreen.m12(),
549 QPointF pointScreen2 (matrixScreen.m13(),
555 <<
" matrixGraphLinear=\n" <<
QTransformToString (matrixGraphLinear).toLatin1().data() <<
"\n"
556 <<
" originalScreen0=" <<
QPointFToString (pointScreen0).toLatin1().data() <<
"\n"
557 <<
" originalScreen1=" <<
QPointFToString (pointScreen1).toLatin1().data() <<
"\n"
558 <<
" originalScreen2=" <<
QPointFToString (pointScreen2).toLatin1().data() <<
"\n"
559 <<
" roundTripScreen0=" <<
QPointFToString (pointScreenRoundTrip0).toLatin1().data() <<
"\n"
560 <<
" roundTripScreen1=" <<
QPointFToString (pointScreenRoundTrip1).toLatin1().data() <<
"\n"
561 <<
" 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.
log4cpp::Category * mainCat
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.
#define LOG4CPP_INFO_S(logger)
#define LOG4CPP_DEBUG_S(logger)