Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

qwt_double_rect.h

00001 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
00002  * Qwt Widget Library
00003  * Copyright (C) 1997   Josef Wilgen
00004  * Copyright (C) 2002   Uwe Rathmann
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the Qwt License, Version 1.0
00008  *****************************************************************************/
00009 
00010 #ifndef QWT_DOUBLE_RECT_H
00011 #define QWT_DOUBLE_RECT_H 1
00012 
00013 #include <qpoint.h>
00014 #include <qsize.h>
00015 #include <qrect.h>
00016 #include "qwt_global.h"
00017 
00022 class QWT_EXPORT QwtDoublePoint
00023 {
00024 public:
00025     QwtDoublePoint();
00026     QwtDoublePoint(double x, double y);
00027     QwtDoublePoint(const QPoint &);
00028 
00029     inline bool isNull()    const;
00030 
00031     inline double x() const;
00032     inline double y() const;
00033     inline void setX(double x);
00034     inline void setY(double y);
00035 
00036     inline double &rx();
00037     inline double &ry();
00038 
00039     bool operator==(const QwtDoublePoint &) const;
00040     bool operator!=(const QwtDoublePoint &) const;
00041 
00042     const QwtDoublePoint operator-() const;
00043     const QwtDoublePoint operator+(const QwtDoublePoint &) const;
00044     const QwtDoublePoint operator-(const QwtDoublePoint &) const;
00045     const QwtDoublePoint operator*(double) const;
00046     const QwtDoublePoint operator/(double) const;
00047 
00048     QwtDoublePoint &operator+=(const QwtDoublePoint &);
00049     QwtDoublePoint &operator-=(const QwtDoublePoint &);
00050     QwtDoublePoint &operator*=(double);
00051     QwtDoublePoint &operator/=(double);
00052 
00053 private:
00054     double d_x;
00055     double d_y;
00056 };
00057 
00062 class QWT_EXPORT QwtDoubleSize
00063 {
00064 public:
00065     QwtDoubleSize();
00066     QwtDoubleSize(double width, double height);
00067     QwtDoubleSize(const QSize &);
00068 
00069     inline bool isNull() const;
00070     inline bool isEmpty() const;
00071     inline bool isValid() const;
00072 
00073     inline double width() const;
00074     inline double height() const;
00075     inline void setWidth( double w );
00076     inline void setHeight( double h );
00077     void transpose();
00078 
00079     QwtDoubleSize expandedTo(const QwtDoubleSize &) const;
00080     QwtDoubleSize boundedTo(const QwtDoubleSize &) const;
00081 
00082     inline double &rwidth();
00083     inline double &rheight();
00084 
00085     bool operator==(const QwtDoubleSize &) const;
00086     bool operator!=(const QwtDoubleSize &) const;
00087 
00088     const QwtDoubleSize operator-() const;
00089     const QwtDoubleSize operator+(const QwtDoubleSize &) const;
00090     const QwtDoubleSize operator-(const QwtDoubleSize &) const;
00091     const QwtDoubleSize operator*(double) const;
00092     const QwtDoubleSize operator/(double) const;
00093 
00094     QwtDoubleSize &operator+=(const QwtDoubleSize &);
00095     QwtDoubleSize &operator-=(const QwtDoubleSize &);
00096     QwtDoubleSize &operator*=(double c);
00097     QwtDoubleSize &operator/=(double c);
00098 
00099 private:
00100     double d_width;
00101     double d_height;
00102 };
00103 
00108 class QWT_EXPORT QwtDoubleRect  
00109 {
00110 public:
00111     QwtDoubleRect();
00112     QwtDoubleRect(double x1, double x2, double y1, double y2);
00113     QwtDoubleRect(double x, double y, const QwtDoubleSize &);
00114 
00115     inline bool isNull()    const;
00116     inline bool isEmpty()   const;
00117     inline bool isValid()   const;
00118 
00119     QwtDoubleRect normalize() const;
00120 
00121     inline double x1()  const;
00122     inline double x2()  const;
00123     inline double y1()  const;
00124     inline double y2()  const;
00125 
00126     inline double &rx1();
00127     inline double &rx2();
00128     inline double &ry1();
00129     inline double &ry2();
00130 
00131     inline void setX1(double);
00132     inline void setX2(double);
00133     inline void setY1(double);
00134     inline void setY2(double);
00135 
00136     QwtDoublePoint center()  const;
00137 
00138     void moveX(double x);
00139     void moveY(double y );
00140     void move(double x, double y);
00141     void moveBy(double dx, double dy);
00142     void moveCenter(const QwtDoublePoint &);
00143     void moveCenter(double dx, double dy);
00144 
00145     void setRect(double x1, double x2, double y1, double y2);
00146 
00147     inline double width()   const;
00148     inline double height()  const;
00149     inline QwtDoubleSize size() const;
00150 
00151     inline void setWidth(double w );
00152     inline void setHeight(double h );
00153     void setSize(const QwtDoubleSize &);
00154 
00155     QwtDoubleRect  operator|(const QwtDoubleRect &r) const;
00156     QwtDoubleRect  operator&(const QwtDoubleRect &r) const;
00157     QwtDoubleRect &operator|=(const QwtDoubleRect &r);
00158     QwtDoubleRect &operator&=(const QwtDoubleRect &r);
00159     bool operator==( const QwtDoubleRect &) const;
00160     bool operator!=( const QwtDoubleRect &) const;
00161 
00162     bool contains(const QwtDoublePoint &p, bool proper = FALSE) const;
00163     bool contains(double x, double y, bool proper = FALSE) const; 
00164     bool contains(const QwtDoubleRect &r, bool proper=FALSE) const;
00165 
00166     QwtDoubleRect unite(const QwtDoubleRect &) const;
00167     QwtDoubleRect intersect(const QwtDoubleRect &) const;
00168     bool intersects(const QwtDoubleRect &) const;
00169 
00170 private:
00171     double d_x1;
00172     double d_x2;
00173     double d_y1;
00174     double d_y2;
00175 };
00176 
00181 inline bool QwtDoublePoint::isNull() const
00182 { 
00183     return d_x == 0.0 && d_y == 0.0; 
00184 }
00185 
00187 inline double QwtDoublePoint::x() const
00188 { 
00189     return d_x; 
00190 }
00191 
00193 inline double QwtDoublePoint::y() const
00194 {   
00195     return d_y; 
00196 }
00197 
00199 inline void QwtDoublePoint::setX(double x)
00200 { 
00201     d_x = x; 
00202 }
00203 
00205 inline void QwtDoublePoint::setY(double y)
00206 { 
00207     d_y = y; 
00208 }
00209 
00211 inline double &QwtDoublePoint::rx()
00212 { 
00213     return d_x; 
00214 }
00215 
00217 inline double &QwtDoublePoint::ry()
00218 { 
00219     return d_y; 
00220 }
00221 
00226 inline bool QwtDoubleSize::isNull() const
00227 { 
00228     return d_width == 0.0 && d_height == 0.0; 
00229 }
00230 
00235 inline bool QwtDoubleSize::isEmpty() const
00236 { 
00237     return d_width <= 0.0 || d_height <= 0.0; 
00238 }
00239 
00244 inline bool QwtDoubleSize::isValid() const
00245 { 
00246     return d_width >= 0.0 && d_height >= 0.0; 
00247 }
00248 
00250 inline double QwtDoubleSize::width() const
00251 { 
00252     return d_width; 
00253 }
00254 
00256 inline double QwtDoubleSize::height() const
00257 { 
00258     return d_height; 
00259 }
00260 
00262 inline void QwtDoubleSize::setWidth(double width)
00263 { 
00264     d_width = width; 
00265 }
00266 
00268 inline void QwtDoubleSize::setHeight(double height)
00269 { 
00270     d_height = height; 
00271 }
00272 
00274 inline double &QwtDoubleSize::rwidth()
00275 { 
00276     return d_width; 
00277 }
00278 
00280 inline double &QwtDoubleSize::rheight()
00281 {   
00282     return d_height; 
00283 }
00284 
00291 inline bool QwtDoubleRect::isNull() const
00292 { 
00293     return d_x2 == d_x1 && d_y2 == d_y1;
00294 }
00295 
00302 inline bool QwtDoubleRect::isEmpty() const
00303 { 
00304     return d_x1 >= d_x2 || d_y1 >= d_y2; 
00305 }
00306 
00313 inline bool QwtDoubleRect::isValid() const
00314 { 
00315     return d_x1 <= d_x2 && d_y1 <= d_y2; 
00316 }
00317 
00319 inline double QwtDoubleRect::x1() const
00320 { 
00321     return d_x1; 
00322 }
00323 
00325 inline double QwtDoubleRect::x2() const
00326 { 
00327     return d_x2; 
00328 }
00329 
00331 inline double QwtDoubleRect::y1() const
00332 { 
00333     return d_y1; 
00334 }
00335 
00337 inline double QwtDoubleRect::y2() const
00338 { 
00339     return d_y2; 
00340 }
00341 
00343 inline double &QwtDoubleRect::rx1()
00344 { 
00345     return d_x1; 
00346 }
00347 
00349 inline double &QwtDoubleRect::rx2()
00350 { 
00351     return d_x2; 
00352 }
00353 
00355 inline double &QwtDoubleRect::ry1()
00356 { 
00357     return d_y1; 
00358 }
00359 
00361 inline double &QwtDoubleRect::ry2()
00362 { 
00363     return d_y2; 
00364 }
00365 
00367 inline void QwtDoubleRect::setX1(double x1)
00368 { 
00369     d_x1 = x1;
00370 }
00371 
00373 inline void QwtDoubleRect::setX2(double x2)
00374 { 
00375     d_x2 = x2;
00376 }
00377 
00379 inline void QwtDoubleRect::setY1(double y1)
00380 { 
00381     d_y1 = y1;
00382 }
00383 
00385 inline void QwtDoubleRect::setY2(double y2)
00386 { 
00387     d_y2 = y2;
00388 }
00389 
00391 inline double QwtDoubleRect::width() const
00392 { 
00393     return  d_x2 - d_x1; 
00394 }
00395 
00397 inline double QwtDoubleRect::height() const
00398 { 
00399     return  d_y2 - d_y1; 
00400 }
00401 
00403 inline QwtDoubleSize QwtDoubleRect::size() const
00404 { 
00405     return QwtDoubleSize(width(), height());
00406 }
00407 
00409 inline void QwtDoubleRect::setWidth(double w)
00410 {
00411     d_x2 = d_x1 + w;
00412 }
00413 
00415 inline void QwtDoubleRect::setHeight(double h)
00416 {
00417     d_y2 = d_y1 + h;
00418 }
00419 
00420 #endif // QWT_DOUBLE_RECT_H

Generated on Sun Nov 21 11:12:42 2004 for Qwt User's Guide by doxygen 1.3.5