Qwt Polar User's Guide  0.1.0
qwt_polar_point.h
1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
2  * QwtPolar Widget Library
3  * Copyright (C) 2008 Uwe Rathmann
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the Qwt License, Version 1.0
7  *****************************************************************************/
8 
9 #ifndef QWT_POLAR_POINT_H
10 #define QWT_POLAR_POINT_H 1
11 
12 #include "qwt_polar_global.h"
13 #include "qwt_double_rect.h"
14 
22 class QWT_POLAR_EXPORT QwtPolarPoint
23 {
24 public:
25  QwtPolarPoint();
26  QwtPolarPoint(double azimuth, double radius);
28  QwtPolarPoint(const QwtDoublePoint &);
29 
30  void setPoint(const QwtDoublePoint &);
31  QwtDoublePoint toPoint() const;
32 
33  bool isValid() const;
34  bool isNull() const;
35 
36  double radius() const;
37  double azimuth() const;
38 
39  double &rRadius();
40  double &rAzimuth();
41 
42  void setRadius(double);
43  void setAzimuth(double);
44 
45  bool operator==(const QwtPolarPoint &) const;
46  bool operator!=(const QwtPolarPoint &) const;
47 
48  QwtPolarPoint normalized() const;
49 
50 private:
51  double d_azimuth;
52  double d_radius;
53 };
54 
60  d_azimuth(0.0),
61  d_radius(0.0)
62 {
63 }
64 
71 inline QwtPolarPoint::QwtPolarPoint(double azimuth, double radius):
72  d_azimuth(azimuth),
73  d_radius(radius)
74 {
75 }
76 
82  d_azimuth(other.d_azimuth),
83  d_radius(other.d_radius)
84 {
85 }
86 
88 inline bool QwtPolarPoint::isValid() const
89 {
90  return d_radius >= 0.0;
91 }
92 
94 inline bool QwtPolarPoint::isNull() const
95 {
96  return d_radius == 0.0;
97 }
98 
100 inline double QwtPolarPoint::radius() const
101 {
102  return d_radius;
103 }
104 
106 inline double QwtPolarPoint::azimuth() const
107 {
108  return d_azimuth;
109 }
110 
112 inline double &QwtPolarPoint::rRadius()
113 {
114  return d_radius;
115 }
116 
118 inline double &QwtPolarPoint::rAzimuth()
119 {
120  return d_azimuth;
121 }
122 
124 inline void QwtPolarPoint::setRadius(double radius)
125 {
126  d_radius = radius;
127 }
128 
130 inline void QwtPolarPoint::setAzimuth(double azimuth)
131 {
132  d_azimuth = azimuth;
133 }
134 
135 #endif // QWT_POLAR_POINT_H