00001 /* 00002 Situare - A location system for Facebook 00003 Copyright (C) 2010 Ixonos Plc. Authors: 00004 00005 Sami Rämö - sami.ramo@ixonos.com 00006 00007 Situare is free software; you can redistribute it and/or 00008 modify it under the terms of the GNU General Public License 00009 version 2 as published by the Free Software Foundation. 00010 00011 Situare is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with Situare; if not, write to the Free Software 00018 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 00019 USA. 00020 */ 00021 00022 00023 #ifndef SCENECOORDINATE_H 00024 #define SCENECOORDINATE_H 00025 00026 #include <QDebug> 00027 #include <QMetaType> 00028 00029 class GeoCoordinate; 00030 00036 class SceneCoordinate 00037 { 00038 public: 00042 SceneCoordinate(); 00043 00050 SceneCoordinate(double x, double y); 00051 00059 SceneCoordinate(const GeoCoordinate &coordinate); 00060 00061 /******************************************************************************* 00062 * MEMBER FUNCTIONS AND SLOTS 00063 ******************************************************************************/ 00064 public: 00073 qreal azimuthTo(const SceneCoordinate &to) const; 00074 00080 bool isNull() const; 00081 00087 void setX(double x); 00088 00094 void setY(double y); 00095 00101 QPointF toPointF() const; 00102 00108 double x() const; 00109 00115 double y() const; 00116 00117 private: 00134 void convertFrom(const GeoCoordinate &coordinate); 00135 00146 void normalize(double &value, int min, int max); 00147 00148 /******************************************************************************* 00149 * DATA MEMBERS 00150 ******************************************************************************/ 00151 private: 00152 double m_x; 00153 double m_y; 00154 00155 /******************************************************************************* 00156 * OPERATORS 00157 ******************************************************************************/ 00158 public: 00162 operator QVariant() const; 00163 00168 SceneCoordinate & operator*=(double factor); 00169 00174 SceneCoordinate & operator+=(const SceneCoordinate &coordinate); 00175 00180 SceneCoordinate & operator-=(const SceneCoordinate &coordinate); 00181 00185 const SceneCoordinate operator+(const SceneCoordinate &other) const; 00186 00190 const SceneCoordinate operator-(const SceneCoordinate &other) const; 00191 }; 00192 00196 QDebug operator<<(QDebug dbg, const SceneCoordinate &coordinate); 00197 00201 const SceneCoordinate operator*(double factor, const SceneCoordinate &coordinate); 00202 00203 Q_DECLARE_METATYPE(SceneCoordinate) 00204 00205 #endif // SCENECOORDINATE_H