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 TestTransformation;
00035
00036 public:
00038 Transformation();
00039
00041 Transformation (const Transformation &other);
00042
00044 Transformation &operator=(const Transformation &other);
00045
00047 void identity();
00048
00050 bool operator!=(const Transformation &other);
00051
00058 static QTransform calculateTransformFromLinearCartesianPoints (const QPointF &posFrom0,
00059 const QPointF &posFrom1,
00060 const QPointF &posFrom2,
00061 const QPointF &posTo0,
00062 const QPointF &posTo1,
00063 const QPointF &posTo2);
00064
00066 static QPointF cartesianFromCartesianOrPolar (const DocumentModelCoords &modelCoords,
00067 const QPointF &posGraphIn);
00068
00070 static QPointF cartesianOrPolarFromCartesian (const DocumentModelCoords &modelCoords,
00071 const QPointF &posGraphIn);
00072
00074 void coordTextForStatusBar (QPointF cursorScreen,
00075 QString &coordsScreen,
00076 QString &coordsGraph,
00077 QString &resolutionGraph);
00078
00080 static double logToLinearCartesian (double xy);
00081
00083 static double logToLinearRadius (double r,
00084 double rCenter);
00085
00087 DocumentModelCoords modelCoords() const;
00088
00090 DocumentModelGeneral modelGeneral() const;
00091
00093 MainWindowModel modelMainWindow() const;
00094
00096 void printStream (QString indentation,
00097 QTextStream &str) const;
00098
00100 void resetOnLoad();
00101
00103 bool transformIsDefined() const;
00104
00106 void transformLinearCartesianGraphToRawGraph (const QPointF &coordGraph,
00107 QPointF &coordScreen) const;
00108
00110 void transformLinearCartesianGraphToScreen (const QPointF &coordGraph,
00111 QPointF &coordScreen) const;
00112
00114 QTransform transformMatrix () const;
00115
00117 void transformRawGraphToLinearCartesianGraph (const QPointF &pointRaw,
00118 QPointF &pointLinearCartesian) const;
00119
00121 void transformRawGraphToScreen (const QPointF &pointRaw,
00122 QPointF &pointScreen) const;
00123
00125 void transformScreenToLinearCartesianGraph (const QPointF &pointScreen,
00126 QPointF &pointLinearCartesian) const;
00127
00129 void transformScreenToRawGraph (const QPointF &coordScreen,
00130 QPointF &coordGraph) const;
00131
00133 void update (bool fileIsLoaded,
00134 const CmdMediator &cmdMediator,
00135 const MainWindowModel &modelMainWindow);
00136
00137 private:
00138
00139
00140 double roundOffSmallValues (double value, double range);
00141
00142
00143 void setModelCoords (const DocumentModelCoords &modelCoords,
00144 const DocumentModelGeneral &modelGeneral,
00145 const MainWindowModel &modelMainWindow);
00146
00147
00148 void updateTransformFromMatrices (const QTransform &matrixScreen,
00149 const QTransform &matrixGraph);
00150
00151
00152 bool m_transformIsDefined;
00153
00154
00155 QTransform m_transform;
00156
00157
00158 DocumentModelCoords m_modelCoords;
00159
00160
00161 DocumentModelGeneral m_modelGeneral;
00162
00163
00164 MainWindowModel m_modelMainWindow;
00165 };
00166
00168 std::ostringstream &operator<< (std::ostringstream &str,
00169 const Transformation &transformation);
00170
00171 #endif // TRANSFORMATION_H