QGpCoreTools/NamedPoint.h
Go to the documentation of this file.
00001 /***************************************************************************
00002 **
00003 **  This file is part of QGpCoreTools.
00004 **
00005 **  This library is free software; you can redistribute it and/or
00006 **  modify it under the terms of the GNU Lesser General Public
00007 **  License as published by the Free Software Foundation; either
00008 **  version 2.1 of the License, or (at your option) any later version.
00009 **
00010 **  This file is distributed in the hope that it will be useful, but WITHOUT
00011 **  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 **  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
00013 **  License for more details.
00014 **
00015 **  You should have received a copy of the GNU Lesser General Public
00016 **  License along with this library; if not, write to the Free Software
00017 **  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00018 **
00019 **  See http://www.geopsy.org for more information.
00020 **
00021 **  Created : 2008-07-25
00022 **  Authors :
00023 **    Marc Wathelet
00024 **    Marc Wathelet (LGIT, Grenoble, France)
00025 **
00026 ***************************************************************************/
00027 
00028 #ifndef NAMEDPOINT_H
00029 #define NAMEDPOINT_H
00030 
00031 #include "Point.h"
00032 #include "QGpCoreToolsDLLExport.h"
00033 
00034 namespace QGpCoreTools {
00035 
00036 class QGPCORETOOLS_EXPORT NamedPoint : public Point
00037 {
00038 public:
00039   NamedPoint() : Point() {}
00040   NamedPoint(double x, double y, double z=0.0, const QString& name=QString::null) : Point(x, y, z) {_name=name;}
00041   NamedPoint(const NamedPoint& p) : Point(p) {_name=p._name;}
00042   NamedPoint(const QString& name, const Point& p) : Point(p) {_name=name;}
00043   NamedPoint(const Point& p) : Point(p) {}
00044   NamedPoint(const Point2D& p) : Point(p) {}
00045 
00046   inline NamedPoint& operator=(const Point& p);
00047   inline NamedPoint& operator=(const Point2D& p);
00048   inline NamedPoint& operator=(const NamedPoint& p);
00049 
00050   inline NamedPoint operator+(const Point& p) const;
00051   inline NamedPoint operator-(const Point& p) const;
00052   inline NamedPoint operator*(double mul) const;
00053   inline NamedPoint operator*(const Point& p) const;
00054   inline NamedPoint operator/(double div) const;
00055   inline NamedPoint operator/(const Point& p) const;
00056 
00057   const QString& name() const {return _name;}
00058   void setName(QString n) {_name=n;}
00059 
00060   void setCoordinates(const Point& p) { *this=p;}
00061   const Point& coordinates() const {return *this;}
00062 
00063   bool fromString(StringSection str);
00064   QString toString(int precision=6, char format='g') const;
00065 private:
00066   QString _name;
00067 };
00068 
00069 inline NamedPoint& NamedPoint::operator=(const Point& p)
00070 {
00071   TRACE;
00072   Point::operator=(p);
00073   return *this;
00074 }
00075 
00076 inline NamedPoint& NamedPoint::operator=(const Point2D& p)
00077 {
00078   TRACE;
00079   Point::operator=(p);
00080   return *this;
00081 }
00082 
00083 inline NamedPoint& NamedPoint::operator=(const NamedPoint& p)
00084 {
00085   TRACE;
00086   Point::operator=(p);
00087   _name=p._name;
00088   return *this;
00089 }
00090 
00091 inline NamedPoint NamedPoint::operator+(const Point& p) const
00092 {
00093   return NamedPoint(x()+p.x(), y()+p.y(), z()+p.z(), _name);
00094 }
00095 
00096 inline NamedPoint NamedPoint::operator-(const Point& p) const
00097 {
00098   return NamedPoint(x()-p.x(), y()-p.y(), z()-p.z(), _name);
00099 }
00100 
00101 inline NamedPoint NamedPoint::operator*(double mul) const
00102 {
00103   return NamedPoint(x()*mul, y()*mul, z()*mul, _name);
00104 }
00105 
00106 inline NamedPoint NamedPoint::operator*(const Point& p) const
00107 {
00108   return NamedPoint(x()*p.x(), y()*p.y(), z()*p.z(), _name);
00109 }
00110 
00111 inline NamedPoint NamedPoint::operator/(double div) const
00112 {
00113   return NamedPoint(x()/div, y()/div, z()/div, _name);
00114 }
00115 
00116 inline NamedPoint NamedPoint::operator/(const Point& p) const
00117 {
00118   return NamedPoint (x()/p.x(), y()/p.y(), z()/p.z(), _name);
00119 }
00120 
00121 } // namespace QGpCoreTools
00122 
00123 #endif // NAMEDPOINT_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines