Back to index

scribus-ng  1.3.4.dfsg+svn20071115
fpoint.h
Go to the documentation of this file.
00001 /*
00002 For general Scribus (>=1.3.2) copyright and licensing information please refer
00003 to the COPYING file provided with the program. Following this notice may exist
00004 a copyright and/or license notice that predates the release of Scribus 1.3.2
00005 for which a new license (GPL+exception) is in place.
00006 */
00007 /***************************************************************************
00008                           fpoint.h  -  description
00009                              -------------------
00010     begin                : Mit Jul 24 2002
00011     copyright            : (C) 2002 by Franz Schmid
00012     email                : Franz.Schmid@altmuehlnet.de
00013  ***************************************************************************/
00014 
00015 /***************************************************************************
00016  *                                                                         *
00017  *   This program is free software; you can redistribute it and/or modify  *
00018  *   it under the terms of the GNU General Public License as published by  *
00019  *   the Free Software Foundation; either version 2 of the License, or     *
00020  *   (at your option) any later version.                                   *
00021  *                                                                         *
00022  ***************************************************************************/
00023 
00024 #ifndef FPOINT_H
00025 #define FPOINT_H
00026 
00027 #include <qpoint.h>
00028 #include "scribusapi.h"
00033 class SCRIBUS_API FPoint
00034 {
00035 public: 
00036        FPoint() : xp(0), yp(0) {};
00037        FPoint(double x, double y) : xp(x), yp(y) {};
00038        FPoint(const QPoint & p) : xp(p.x()), yp(p.y()) {};
00039        FPoint(const FPoint & p) : xp(p.xp), yp(p.yp) {};
00040        //Creates a transformed point, replaces ScribusView::transformPoint()
00041        FPoint(const double x, const double y, const double dx, const double dy, const double rot, const double sx, const double sy, const bool invert=false);
00042 //  ~FPoint() {};
00043        FPoint &  operator=(const FPoint & rhs);
00044        double x() const;
00045        double y() const;
00046        void setX(double x);
00047        void setY(double y);
00048        void setXY(double x, double y);
00049        bool operator==(const FPoint &rhs) const;
00050        bool operator!=(const FPoint &rhs) const;
00051        FPoint &operator+=( const FPoint &p );
00052        FPoint &operator-=( const FPoint &p );
00053        friend inline const FPoint operator+( const FPoint &, const FPoint & );
00054        friend inline const FPoint operator-( const FPoint &, const FPoint & );
00055        friend inline const FPoint operator*( const FPoint &, const double & );
00056        friend inline const FPoint operator*( const double &, const FPoint & );
00057        friend inline const double  operator*( const FPoint &a, const FPoint &b );
00058        //Transform an existing point
00059        void transform(const double dx, const double dy, const double rot, const double sx, const double sy, const bool invert);
00060        //Transform an existing point, return a new one
00061        FPoint transformPoint(const double dx, const double dy, const double rot, const double sx, const double sy, const bool invert);
00062        friend class FPointArray;
00063 
00064 private:
00065        double xp;
00066        double yp;
00067 };
00068 
00069 
00070 inline const FPoint operator+( const FPoint &p1, const FPoint &p2 ) { 
00071        return FPoint(p1.xp+p2.xp, p1.yp+p2.yp); 
00072 }
00073 
00074 inline const FPoint operator-( const FPoint &p1, const FPoint &p2 ) { 
00075        return FPoint(p1.xp-p2.xp, p1.yp-p2.yp); 
00076 }
00077 
00078 inline const FPoint operator*( const FPoint &p, const double &c ) { 
00079        return FPoint(p.xp*c, p.yp*c); 
00080 }
00081 
00082 inline const FPoint operator*( const double &c, const FPoint &p ) { 
00083        return FPoint(p.xp*c, p.yp*c); 
00084 }
00085 
00086 inline const double operator*( const FPoint &a, const FPoint &b ) {
00087        return a.xp * b.xp + a.yp * b.yp; 
00088 }
00089 
00090 inline FPoint &  FPoint::operator=(const FPoint & rhs)  { 
00091        xp = rhs.xp; 
00092        yp = rhs.yp; 
00093        return *this; 
00094 }
00095 
00096 inline double FPoint::x() const { 
00097        return xp; 
00098 }
00099 
00100 inline double FPoint::y() const { 
00101        return yp; 
00102 }
00103 
00104 inline void FPoint::setX(double x) { 
00105        xp = x; 
00106 }
00107 
00108 inline void FPoint::setY(double y) { 
00109        yp = y; 
00110 }
00111 
00112 inline void FPoint::setXY(double x, double y) { 
00113        xp = x;
00114        yp = y; 
00115 }
00116  
00117 inline FPoint & FPoint::operator+=( const FPoint &p ) { 
00118        xp += p.xp; 
00119        yp += p.yp; 
00120        return *this; 
00121 }
00122 
00123 inline FPoint & FPoint::operator-=( const FPoint &p ) { 
00124        xp -= p.xp; 
00125        yp -= p.yp; 
00126        return *this; 
00127 }
00128 
00129 #endif