00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
#include "qwt_double_rect.h"
00011
00013
00014 QwtDoublePoint::QwtDoublePoint():
00015 d_x(0.0),
00016 d_y(0.0)
00017 {
00018 }
00019
00021
00022 QwtDoublePoint::QwtDoublePoint(
double x,
double y ):
00023 d_x(x),
00024 d_y(y)
00025 {
00026 }
00027
00029 QwtDoublePoint::QwtDoublePoint(
const QPoint &p):
00030 d_x(double(p.x())),
00031 d_y(double(p.y()))
00032 {
00033 }
00034
00036 bool QwtDoublePoint::operator==(
const QwtDoublePoint &other)
const
00037
{
00038
return (d_x == other.
d_x) && (d_y == other.
d_y);
00039 }
00040
00042 bool QwtDoublePoint::operator!=(
const QwtDoublePoint &other)
const
00043
{
00044
return !
operator==(other);
00045 }
00046
00052 const QwtDoublePoint QwtDoublePoint::operator-()
const
00053
{
00054
return QwtDoublePoint(-d_x, -d_y);
00055 }
00056
00062 const QwtDoublePoint QwtDoublePoint::operator+(
00063
const QwtDoublePoint &other)
const
00064
{
00065
return QwtDoublePoint(d_x + other.
d_x, d_y + other.
d_y);
00066 }
00067
00073 const QwtDoublePoint QwtDoublePoint::operator-(
00074
const QwtDoublePoint &other)
const
00075
{
00076
return QwtDoublePoint(d_x - other.
d_x, d_y - other.
d_y);
00077 }
00078
00080
00081 const QwtDoublePoint QwtDoublePoint::operator*(
double c)
const
00082
{
00083
return QwtDoublePoint(d_x * c, d_y * c);
00084 }
00085
00087
00088 const QwtDoublePoint QwtDoublePoint::operator/(
double c)
const
00089
{
00090
return QwtDoublePoint(d_x / c, d_y / c);
00091 }
00092
00094
00095 QwtDoublePoint &
QwtDoublePoint::operator+=(
const QwtDoublePoint &other)
00096 {
00097 d_x += other.
d_x;
00098 d_y += other.
d_y;
00099
return *
this;
00100 }
00101
00103
00104 QwtDoublePoint &
QwtDoublePoint::operator-=(
const QwtDoublePoint &other)
00105 {
00106 d_x -= other.
d_x;
00107 d_y -= other.
d_y;
00108
return *
this;
00109 }
00110
00112
00113 QwtDoublePoint &
QwtDoublePoint::operator*=(
double c)
00114 {
00115 d_x *= c;
00116 d_y *= c;
00117
return *
this;
00118 }
00119
00121
00122 QwtDoublePoint &
QwtDoublePoint::operator/=(
double c)
00123 {
00124 d_x /= c;
00125 d_y /= c;
00126
return *
this;
00127 }
00128
00130
00131 QwtDoubleSize::QwtDoubleSize():
00132 d_width(0.0),
00133 d_height(0.0)
00134 {
00135 }
00136
00138
00139 QwtDoubleSize::QwtDoubleSize(
double w,
double h ):
00140 d_width(w),
00141 d_height(h)
00142 {
00143 }
00144
00146
00147 QwtDoubleSize::QwtDoubleSize(
const QSize &sz):
00148 d_width(double(sz.width())),
00149 d_height(double(sz.height()))
00150 {
00151 }
00152
00154
00155 void QwtDoubleSize::transpose()
00156 {
00157
double tmp = d_width;
00158 d_width = d_height;
00159 d_height = tmp;
00160 }
00161
00167 QwtDoubleSize QwtDoubleSize::expandedTo(
00168
const QwtDoubleSize &other)
const
00169
{
00170
return QwtDoubleSize(
00171 QMAX(d_width, other.
d_width),
00172 QMAX(d_height, other.
d_height)
00173 );
00174 }
00175
00181 QwtDoubleSize QwtDoubleSize::boundedTo(
00182
const QwtDoubleSize &other)
const
00183
{
00184
return QwtDoubleSize(
00185 QMIN(d_width, other.
d_width),
00186 QMIN(d_height, other.
d_height)
00187 );
00188 }
00189
00191
00192 bool QwtDoubleSize::operator==(
const QwtDoubleSize &other)
const
00193
{
00194
return d_width == other.
d_width && d_height == other.
d_height;
00195 }
00196
00198
00199 bool QwtDoubleSize::operator!=(
const QwtDoubleSize &other)
const
00200
{
00201
return !
operator==(other);
00202 }
00203
00209 const QwtDoubleSize QwtDoubleSize::operator-()
const
00210
{
00211
return QwtDoubleSize(-d_width, -d_height);
00212 }
00213
00219 const QwtDoubleSize QwtDoubleSize::operator+(
00220
const QwtDoubleSize &other)
const
00221
{
00222
return QwtDoubleSize(d_width + other.
d_width,
00223 d_height + other.
d_height);
00224 }
00225
00231 const QwtDoubleSize QwtDoubleSize::operator-(
00232
const QwtDoubleSize &other)
const
00233
{
00234
return QwtDoubleSize(d_width - other.
d_width,
00235 d_height - other.
d_height);
00236 }
00237
00239
00240 const QwtDoubleSize QwtDoubleSize::operator*(
double c)
const
00241
{
00242
return QwtDoubleSize(d_width * c, d_height * c);
00243 }
00244
00246
00247 const QwtDoubleSize QwtDoubleSize::operator/(
double c)
const
00248
{
00249
return QwtDoubleSize(d_width / c, d_height / c);
00250 }
00251
00253
00254 QwtDoubleSize &
QwtDoubleSize::operator+=(
const QwtDoubleSize &other)
00255 {
00256 d_width += other.
d_width;
00257 d_height += other.
d_height;
00258
return *
this;
00259 }
00260
00262
00263 QwtDoubleSize &
QwtDoubleSize::operator-=(
const QwtDoubleSize &other)
00264 {
00265 d_width -= other.
d_width;
00266 d_height -= other.
d_height;
00267
return *
this;
00268 }
00269
00270
00271
00272
00273
00274
00275
QwtDoubleSize &QwtDoubleSize::operator*=(
double c)
00276 {
00277 d_width *= c;
00278 d_height *= c;
00279
return *
this;
00280 }
00281
00282
00283
00284
00285
00286
00287
QwtDoubleSize &QwtDoubleSize::operator/=(
double c)
00288 {
00289 d_width /= c;
00290 d_height /= c;
00291
return *
this;
00292 }
00293
00295 QwtDoubleRect::QwtDoubleRect():
00296 d_x1(0.0),
00297 d_x2(0.0),
00298 d_y1(0.0),
00299 d_y2(0.0)
00300 {
00301 }
00302
00308 QwtDoubleRect::QwtDoubleRect(
double x1,
double x2,
00309
double y1,
double y2):
00310 d_x1(x1),
00311 d_x2(x2),
00312 d_y1(y1),
00313 d_y2(y2)
00314 {
00315 }
00316
00322 QwtDoubleRect::QwtDoubleRect(
double x,
double y,
const QwtDoubleSize &size):
00323 d_x1(x),
00324 d_x2(x + size.width()),
00325 d_y1(y),
00326 d_y2(y + size.height())
00327 {
00328 }
00329
00333 void QwtDoubleRect::setRect(
double x1,
double x2,
double y1,
double y2)
00334 {
00335 d_x1 = x1;
00336 d_x2 = x2;
00337 d_y1 = y1;
00338 d_y2 = y2;
00339 }
00340
00346 void QwtDoubleRect::setSize(
const QwtDoubleSize &size)
00347 {
00348
setWidth(size.
width());
00349
setHeight(size.
height());
00350 }
00351
00359 QwtDoubleRect QwtDoubleRect::normalize()
const
00360
{
00361
QwtDoubleRect r;
00362
if ( d_x2 < d_x1 )
00363 {
00364 r.
d_x1 = d_x2;
00365 r.
d_x2 = d_x1;
00366 }
00367
else
00368 {
00369 r.
d_x1 = d_x1;
00370 r.
d_x2 = d_x2;
00371 }
00372
if ( d_y2 < d_y1 )
00373 {
00374 r.
d_y1 = d_y2;
00375 r.
d_y2 = d_y1;
00376 }
00377
else
00378 {
00379 r.
d_y1 = d_y1;
00380 r.
d_y2 = d_y2;
00381 }
00382
return r;
00383 }
00384
00390 QwtDoubleRect QwtDoubleRect::unite(
const QwtDoubleRect &other)
const
00391
{
00392
return *
this | other;
00393 }
00394
00400 QwtDoubleRect QwtDoubleRect::intersect(
const QwtDoubleRect &other)
const
00401
{
00402
return *
this & other;
00403 }
00404
00410 bool QwtDoubleRect::intersects(
const QwtDoubleRect &other)
const
00411
{
00412
return ( QMAX(d_x1, other.
d_x1) <= QMIN(d_x2, other.
d_x2) ) &&
00413 ( QMAX(d_y1, other.
d_y1 ) <= QMIN(d_y2, other.
d_y2) );
00414 }
00415
00417
00418 bool QwtDoubleRect::operator==(
const QwtDoubleRect &other)
const
00419
{
00420
return d_x1 == other.
d_x1 && d_x2 == other.
d_x2 &&
00421 d_y d_x1 == other.
d_x1 && d_x2 == other.
d_x2 &&
00421 d_y d_x1 == other.
d_x1 && d_x2 == other.
d_x2 &&
00421 d_y d_x1 == other.
d_x1 && d_x2 == other.
d_x2 &&
00421 d_y d_x1 == other.
d_x1 && d_x2 == other.
d_x2 &&
00421 d_y d_x1 == other.
d_x1 && d_x2 == other.
d_x2 &&
00421 d_y d_x1 == other.
d_x1 && d_x2 == other.
d_x2 &&
00421 d_y d_x1 == other.
d_x1 && d_x2 == other.
d_x2 &&
00421 d_y d_x1 == other.
d_x1 && d_x2 == other.
d_x2 &&
00421 d_y d_x1 == other.
d_x1 && d_x2 == other.
d_x2 &&
00421 d_y d_x1 == other.
d_x1 && d_x2 == other.
d_x2 &&
00421 d_y d_x1 == other.
d_x1 && d_x2 == other.
d_x2 &&
00421 d_y d_x1 == other.
d_x1 && d_x2 == other.
d_x2 &&
00421 d_y d_x1 == other.
d_x1 && d_x2 == other.
d_x2 &&
00421 d_y d_x1 == other.
d_x1 && d_x2 == other.
d_x2 &&
00421 d_y d_x1 == other.
d_x1 && d_x2 == other.
d_x2 &&
00421 d_y d_x1 == other.
d_x1 && d_x2 == other.
d_x2 &&
00421 d_y d_x1 == other.
d_x1 && d_x2 == other.
d_x2 &&
00421 d_y d_x1 == other.
d_x1 && d_x2 == other.
d_x2 &&
00421 d_y d_x1 == other.
d_x1 && d_x2 == other.
d_x2 &&
00421 d_y d_x1 == other.
d_x1 && d_x2 == other.
d_x2 &&
00421 d_y d_x1 == other.
d_x1 && d_x2 == other.
d_x2 &&
00421 d_y d_x1 == other.
d_x1 && d_x2 == other.
d_x2 &&
00421 d_y d_x1 == other.
d_x1 && d_x2 == other.
d_x2 &&
00421 d_y d_x1 == other.
d_x1 && d_x2 == other.
d_x2 &&
00421 d_y d_x1 == other.
d_x1 && d_x2 == other.
d_x2 &&
00421 d_y d_x1 == other.
d_x1 && d_x2 == other.
d_x2 &&
00421 d_y d_x1 == other.
d_x1 && d_x2 == other.
d_x2 &&
00421 d_y d_x1 == other.
d_x1 && d_x2 == other.
d_x2 &&
00421 d_y d_x1 == other.
d_x1 && d_x2 == other.
d_x2 &&
00421 d_y d_x1 == other.
d_x1 && d_x2 == other.
d_x2 &&
00421 d_y d_x1 == other.
d_x1 && d_x2 == other.
d_x2 &&
00421 d_y d_x1 == other.
d_x1 && d_x2 == other.
d_x2 &&
00421 d_y d_x1 == other.
d_x1 && d_x2 == other.
d_x2 &&
00421 d_y d_x1 == other.
d_x1 && d_x2 == other.
d_x2 &&
00421 d_y d_x1 == other.
d_x1 && d_x2 == other.
d_x2 &&
00421 d_y d_x1 == other.
d_x1 && d_x2 == other.
d_x2 &&
00421 d_y d_x1 == other.
d_x1 && d_x2 == other.
d_x2 &&
00421 d_y d_x1 == other.
d_x1 && d_x2 == other.
d_x2 &&
00421 d_y d_x1 == other.
d_x1 && d_x2 == other.
d_x2 &&
00421 d_y d_x1 == other.
d_x1 && d_x2 == other.
d_x2 &&
00421 d_y d_x1 == other.
d_x1 && d_x2 == other.
d_x2 &&
00421 d_y d_x1 == other.
d_x1 && d_x2 == other.
d_x2 &&
00421 d_y d_x1 == other.
d_x1 && d_x2 == other.
d_x2 &&
00421 d_y d_x1 == other.
d_x1 && d_x2 == other.
d_x2 &&
00421 d_y d_x1 == other.
d_x1 && d_x2 == other.
d_x2 &&
00421 d_y d_x1 == other.
d_x1 && d_x2 == other.
d_x2 &&
00421 d_y d_x1 == other.
d_x1 && d_x2 == other.
d_x2 &&
00421 d_y d_x1 == other.
d_x1 && d_x2 == other.
d_x2 &&
00421 d_y d_x1 == other.
d_x1 && d_x2 == other.
d_x2 &&
00421 d_y d_x1 == other.
d_x1 && d_x2 == other.
d_x2 &&
00421 d_y d_x1 == other.
d_x1 && d_x2 == other.
d_x2 &&
00421 d_y d_x1 == other.
d_x1 && d_x2 == other.
d_x2 &&
00421 d_y d_x1 == other.
d_x1 && d_x2 == other.
d_x2 &&
00421 d_y d_x1 == other.