25 const double PI = 3.1415926535;
29 m_transformIsDefined (false)
34 m_transformIsDefined (other.transformIsDefined()),
35 m_transform (other.transformMatrix())
60 const QPointF &posFrom1,
61 const QPointF &posFrom2,
62 const QPointF &posTo0,
63 const QPointF &posTo1,
64 const QPointF &posTo2)
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 () *
PI / 180.0;
101 angleRadians = posGraphIn.x () *
PI / 200.0;
105 angleRadians = posGraphIn.x ();
109 angleRadians = posGraphIn.x () * 2.0 *
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 /
PI);
145 posGraphCartesianOrPolar.setX (angleRadians * 200.0 /
PI);
149 posGraphCartesianOrPolar.setX (angleRadians);
153 posGraphCartesianOrPolar.setX (angleRadians / 2.0 /
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 ();
290 QTextStream &str)
const 292 str <<
"Transformation\n";
296 if (m_transformIsDefined) {
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() <<
")";
305 str << indentation <<
"undefined";
314 m_transformIsDefined =
false;
317 double Transformation::roundOffSmallValues (
double value,
double range)
337 return m_transformIsDefined;
341 QPointF &pointRawGraph)
const 346 pointRawGraph = pointLinearCartesianGraph;
357 pointRawGraph.setY (pointRawGraph.y() + m_modelCoords.
originRadius());
362 pointRawGraph.setX (qExp (pointRawGraph.x()));
375 pointRawGraph.setY (qExp (pointRawGraph.y() + qLn (offset)));
380 QPointF &coordScreen)
const 384 coordScreen = m_transform.inverted ().transposed ().map (coordGraph);
393 QPointF &pointLinearCartesian)
const 398 double x = pointRaw.x();
399 double y = pointRaw.y();
430 pointLinearCartesian.setX (x);
431 pointLinearCartesian.setY (y);
435 QPointF &pointScreen)
const 437 QPointF pointLinearCartesianGraph;
440 pointLinearCartesianGraph);
446 QPointF &coordGraph)
const 450 coordGraph = m_transform.transposed ().map (coordScreen);
454 QPointF &coordGraph)
const 456 QPointF pointLinearCartesianGraph;
458 pointLinearCartesianGraph);
471 m_transformIsDefined =
false;
482 Functor2wRet<const QString &, const Point&, CallbackSearchReturn> ftorWithCallback = functor_ret (ftor,
486 if (ftor.transformIsDefined ()) {
488 updateTransformFromMatrices (ftor.matrixScreen(),
493 m_transformIsDefined =
false;
499 void Transformation::updateTransformFromMatrices (
const QTransform &matrixScreen,
500 const QTransform &matrixGraph)
504 m_transformIsDefined =
true;
507 QPointF pointGraphRaw0 (matrixGraph.m11(),
509 QPointF pointGraphRaw1 (matrixGraph.m12(),
511 QPointF pointGraphRaw2 (matrixGraph.m13(),
514 QPointF pointGraphLinearCart0, pointGraphLinearCart1, pointGraphLinearCart2;
516 pointGraphLinearCart0);
518 pointGraphLinearCart1);
520 pointGraphLinearCart2);
524 QPointF (matrixScreen.m12(), matrixScreen.m22()),
525 QPointF (matrixScreen.m13(), matrixScreen.m23()),
526 QPointF (pointGraphLinearCart0.x(), pointGraphLinearCart0.y()),
527 QPointF (pointGraphLinearCart1.x(), pointGraphLinearCart1.y()),
528 QPointF (pointGraphLinearCart2.x(), pointGraphLinearCart2.y()));
531 QTransform matrixGraphLinear (pointGraphLinearCart0.x(),
532 pointGraphLinearCart1.x(),
533 pointGraphLinearCart2.x(),
534 pointGraphLinearCart0.y(),
535 pointGraphLinearCart1.y(),
536 pointGraphLinearCart2.y(),
540 QPointF pointScreenRoundTrip0, pointScreenRoundTrip1, pointScreenRoundTrip2;
542 pointScreenRoundTrip0);
544 pointScreenRoundTrip1);
546 pointScreenRoundTrip2);
548 QPointF pointScreen0 (matrixScreen.m11(),
550 QPointF pointScreen1 (matrixScreen.m12(),
552 QPointF pointScreen2 (matrixScreen.m13(),
558 <<
" matrixGraphLinear=\n" <<
QTransformToString (matrixGraphLinear).toLatin1().data() <<
"\n" 559 <<
" originalScreen0=" <<
QPointFToString (pointScreen0).toLatin1().data() <<
"\n" 560 <<
" originalScreen1=" <<
QPointFToString (pointScreen1).toLatin1().data() <<
"\n" 561 <<
" originalScreen2=" <<
QPointFToString (pointScreen2).toLatin1().data() <<
"\n" 562 <<
" roundTripScreen0=" <<
QPointFToString (pointScreenRoundTrip0).toLatin1().data() <<
"\n" 563 <<
" roundTripScreen1=" <<
QPointFToString (pointScreenRoundTrip1).toLatin1().data() <<
"\n" 564 <<
" roundTripScreen2=" <<
QPointFToString (pointScreenRoundTrip2).toLatin1().data() <<
"\n";
Model for DlgSettingsGeneral and CmdSettingsGeneral.
QString QTransformToString(const QTransform &transform)
const QString INDENTATION_DELTA
DocumentModelGeneral modelGeneral() const
Get method for DocumentModelGeneral.
DocumentAxesPointsRequired documentAxesPointsRequired() const
Get method for DocumentAxesPointsRequired.
#define LOG4CPP_INFO_S(logger)
CoordUnitsPolarTheta coordUnitsTheta() const
Get method for theta unit.
QString QPointFToString(const QPointF &pos)
Model for DlgSettingsMainWindow.
CoordScale coordScaleXTheta() const
Get method for linear/log scale on x/theta.
Model for DlgSettingsCoords and CmdSettingsCoords.
CoordScale coordScaleYRadius() const
Get method for linear/log scale on y/radius.
log4cpp::Category * mainCat
CoordsType coordsType() const
Get method for coordinates type.
double originRadius() const
Get method for origin radius in polar mode.
DocumentModelCoords modelCoords() const
Get method for DocumentModelCoords.
#define ENGAUGE_ASSERT(cond)
Drop in replacement for Q_ASSERT if defined(QT_NO_DEBUG) && !defined(QT_FORCE_ASSERTS) define ENGAUGE...
CallbackSearchReturn callback(const QString &curveName, const Point &point)
Callback method.
#define LOG4CPP_DEBUG_S(logger)