Qwt Polar User's Guide 0.1.0
qwt_polar_point.h
00001 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
00002  * QwtPolar Widget Library
00003  * Copyright (C) 2008   Uwe Rathmann
00004  * 
00005  * This library is free software; you can redistribute it and/or
00006  * modify it under the terms of the Qwt License, Version 1.0
00007  *****************************************************************************/
00008 
00009 #ifndef QWT_POLAR_POINT_H
00010 #define QWT_POLAR_POINT_H 1
00011 
00012 #include "qwt_polar_global.h"
00013 #include "qwt_double_rect.h"
00014 
00022 class QWT_POLAR_EXPORT QwtPolarPoint
00023 {
00024 public:
00025     QwtPolarPoint();
00026     QwtPolarPoint(double azimuth, double radius);
00027     QwtPolarPoint(const QwtPolarPoint &);
00028     QwtPolarPoint(const QwtDoublePoint &);
00029 
00030     void setPoint(const QwtDoublePoint &);
00031     QwtDoublePoint toPoint() const;
00032 
00033     bool isValid() const;
00034     bool isNull() const;
00035 
00036     double radius() const;
00037     double azimuth() const;
00038 
00039     double &rRadius();
00040     double &rAzimuth();
00041 
00042     void setRadius(double);
00043     void setAzimuth(double);
00044 
00045     bool operator==(const QwtPolarPoint &) const;
00046     bool operator!=(const QwtPolarPoint &) const;
00047 
00048     QwtPolarPoint normalized() const;
00049 
00050 private:
00051     double d_azimuth;
00052     double d_radius;
00053 };
00054 
00059 inline QwtPolarPoint::QwtPolarPoint():
00060     d_azimuth(0.0),
00061     d_radius(0.0)
00062 {
00063 }
00064 
00071 inline QwtPolarPoint::QwtPolarPoint(double azimuth, double radius):
00072     d_azimuth(azimuth),
00073     d_radius(radius)
00074 {
00075 }
00076 
00081 inline QwtPolarPoint::QwtPolarPoint(const QwtPolarPoint &other):
00082     d_azimuth(other.d_azimuth),
00083     d_radius(other.d_radius)
00084 {
00085 }
00086 
00088 inline bool QwtPolarPoint::isValid() const
00089 { 
00090     return d_radius >= 0.0;
00091 }
00092 
00094 inline bool QwtPolarPoint::isNull() const
00095 { 
00096     return d_radius == 0.0;
00097 }
00098 
00100 inline double QwtPolarPoint::radius() const
00101 { 
00102     return d_radius; 
00103 }
00104 
00106 inline double QwtPolarPoint::azimuth() const
00107 {   
00108     return d_azimuth; 
00109 }
00110 
00112 inline double &QwtPolarPoint::rRadius()
00113 {
00114     return d_radius;
00115 }
00116 
00118 inline double &QwtPolarPoint::rAzimuth()
00119 {
00120     return d_azimuth;
00121 }
00122 
00124 inline void QwtPolarPoint::setRadius(double radius)
00125 { 
00126     d_radius = radius; 
00127 }
00128 
00130 inline void QwtPolarPoint::setAzimuth(double azimuth)
00131 { 
00132     d_azimuth = azimuth; 
00133 }
00134 
00135 #endif // QWT_POLAR_POINT_H