00001
00002
00003
00004
00005
00006
00007 #ifndef TRANSFORMATION_H
00008 #define TRANSFORMATION_H
00009
00010 #include "CmdMediator.h"
00011 #include "DocumentModelCoords.h"
00012 #include "DocumentModelGeneral.h"
00013 #include "MainWindowModel.h"
00014 #include <QPointF>
00015 #include <QString>
00016 #include <QTransform>
00017
00031 class Transformation
00032 {
00033
00034 friend class TestExport;
00035 friend class TestTransformation;
00036
00037 public:
00039 Transformation();
00040
00042 Transformation (const Transformation &other);
00043
00045 Transformation &operator=(const Transformation &other);
00046
00048 void identity();
00049
00051 bool operator!=(const Transformation &other);
00052
00059 static QTransform calculateTransformFromLinearCartesianPoints (const QPointF &posFrom0,
00060 const QPointF &posFrom1,
00061 const QPointF &posFrom2,
00062 const QPointF &posTo0,
00063 const QPointF &posTo1,
00064 const QPointF &posTo2);
00065
00067 static QPointF cartesianFromCartesianOrPolar (const DocumentModelCoords &modelCoords,
00068 const QPointF &posGraphIn);
00069
00071 static QPointF cartesianOrPolarFromCartesian (const DocumentModelCoords &modelCoords,
00072 const QPointF &posGraphIn);
00073
00075 void coordTextForStatusBar (QPointF cursorScreen,
00076 QString &coordsScreen,
00077 QString &coordsGraph,
00078 QString &resolutionGraph,
00079 const QString &needMoreText);
00080
00082 static double logToLinearCartesian (double xy);
00083
00085 static double logToLinearRadius (double r,
00086 double rCenter);
00087
00089 DocumentModelCoords modelCoords() const;
00090
00092 DocumentModelGeneral modelGeneral() const;
00093
00095 MainWindowModel modelMainWindow() const;
00096
00098 void printStream (QString indentation,
00099 QTextStream &str) const;
00100
00102 void resetOnLoad();
00103
00105 bool transformIsDefined() const;
00106
00108 void transformLinearCartesianGraphToRawGraph (const QPointF &coordGraph,
00109 QPointF &coordScreen) const;
00110
00112 void transformLinearCartesianGraphToScreen (const QPointF &coordGraph,
00113 QPointF &coordScreen) const;
00114
00116 QTransform transformMatrix () const;
00117
00119 void transformRawGraphToLinearCartesianGraph (const QPointF &pointRaw,
00120 QPointF &pointLinearCartesian) const;
00121
00123 void transformRawGraphToScreen (const QPointF &pointRaw,
00124 QPointF &pointScreen) const;
00125
00127 void transformScreenToLinearCartesianGraph (const QPointF &pointScreen,
00128 QPointF &pointLinearCartesian) const;
00129
00131 void transformScreenToRawGraph (const QPointF &coordScreen,
00132 QPointF &coordGraph) const;
00133
00135 void update (bool fileIsLoaded,
00136 const CmdMediator &cmdMediator,
00137 const MainWindowModel &modelMainWindow);
00138
00139 private:
00140
00141
00142 double roundOffSmallValues (double value, double range);
00143
00144
00145 void setModelCoords (const DocumentModelCoords &modelCoords,
00146 const DocumentModelGeneral &modelGeneral,
00147 const MainWindowModel &modelMainWindow);
00148
00149
00150 void updateTransformFromMatrices (const QTransform &matrixScreen,
00151 const QTransform &matrixGraph);
00152
00153
00154 bool m_transformIsDefined;
00155
00156
00157 QTransform m_transform;
00158
00159
00160 DocumentModelCoords m_modelCoords;
00161
00162
00163 DocumentModelGeneral m_modelGeneral;
00164
00165
00166 MainWindowModel m_modelMainWindow;
00167 };
00168
00170 std::ostringstream &operator<< (std::ostringstream &str,
00171 const Transformation &transformation);
00172
00173 #endif // TRANSFORMATION_H