You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
600 lines
0 B
600 lines
0 B
15 years ago
|
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||
|
* Qwt Widget Library
|
||
|
* Copyright (C) 1997 Josef Wilgen
|
||
|
* Copyright (C) 2002 Uwe Rathmann
|
||
|
*
|
||
|
* This library is free software; you can redistribute it and/or
|
||
|
* modify it under the terms of the Qwt License, Version 1.0
|
||
|
*****************************************************************************/
|
||
|
|
||
|
#include <qglobal.h>
|
||
|
|
||
|
#if QT_VERSION < 0x040000
|
||
|
|
||
|
#include "qwt_math.h"
|
||
|
#include "qwt_double_rect.h"
|
||
|
|
||
14 years ago
|
/*!
|
||
15 years ago
|
Constructs a null point.
|
||
|
|
||
|
\sa QwtDoublePoint::isNull
|
||
|
*/
|
||
|
QwtDoublePoint::QwtDoublePoint():
|
||
|
d_x(0.0),
|
||
|
d_y(0.0)
|
||
|
{
|
||
|
}
|
||
|
|
||
|
//! Constructs a point with coordinates specified by x and y.
|
||
|
QwtDoublePoint::QwtDoublePoint(double x, double y ):
|
||
|
d_x(x),
|
||
|
d_y(y)
|
||
|
{
|
||
|
}
|
||
|
|
||
14 years ago
|
/*!
|
||
|
Copy constructor.
|
||
15 years ago
|
|
||
|
Constructs a point using the values of the point specified.
|
||
|
*/
|
||
|
QwtDoublePoint::QwtDoublePoint(const QPoint &p):
|
||
|
d_x(double(p.x())),
|
||
|
d_y(double(p.y()))
|
||
|
{
|
||
|
}
|
||
|
|
||
14 years ago
|
/*!
|
||
15 years ago
|
Returns true if point1 is equal to point2; otherwise returns false.
|
||
|
|
||
14 years ago
|
Two points are equal to each other if both x-coordinates and
|
||
15 years ago
|
both y-coordinates are the same.
|
||
|
*/
|
||
|
bool QwtDoublePoint::operator==(const QwtDoublePoint &other) const
|
||
|
{
|
||
|
return (d_x == other.d_x) && (d_y == other.d_y);
|
||
|
}
|
||
|
|
||
|
//! Returns true if point1 is not equal to point2; otherwise returns false.
|
||
|
bool QwtDoublePoint::operator!=(const QwtDoublePoint &other) const
|
||
|
{
|
||
|
return !operator==(other);
|
||
|
}
|
||
|
|
||
14 years ago
|
/*!
|
||
|
Negates the coordinates of the point, and returns a point with the
|
||
15 years ago
|
new coordinates. (Inversion).
|
||
|
*/
|
||
|
const QwtDoublePoint QwtDoublePoint::operator-() const
|
||
|
{
|
||
|
return QwtDoublePoint(-d_x, -d_y);
|
||
|
}
|
||
|
|
||
14 years ago
|
/*!
|
||
|
Adds the coordinates of the point to the corresponding coordinates of
|
||
|
the other point, and returns a point with the new coordinates.
|
||
15 years ago
|
(Vector addition.)
|
||
|
*/
|
||
|
const QwtDoublePoint QwtDoublePoint::operator+(
|
||
|
const QwtDoublePoint &other) const
|
||
|
{
|
||
|
return QwtDoublePoint(d_x + other.d_x, d_y + other.d_y);
|
||
|
}
|
||
|
|
||
14 years ago
|
/*!
|
||
|
Subtracts the coordinates of the other point from the corresponding
|
||
|
coordinates of the given point, and returns a point with the new
|
||
15 years ago
|
coordinates. (Vector subtraction.)
|
||
|
*/
|
||
|
const QwtDoublePoint QwtDoublePoint::operator-(
|
||
|
const QwtDoublePoint &other) const
|
||
|
{
|
||
|
return QwtDoublePoint(d_x - other.d_x, d_y - other.d_y);
|
||
|
}
|
||
|
|
||
|
/*!
|
||
14 years ago
|
Multiplies the coordinates of the point by the given scale factor,
|
||
|
and returns a point with the new coordinates.
|
||
15 years ago
|
(Scalar multiplication of a vector.)
|
||
|
*/
|
||
|
const QwtDoublePoint QwtDoublePoint::operator*(double factor) const
|
||
|
{
|
||
|
return QwtDoublePoint(d_x * factor, d_y * factor);
|
||
|
}
|
||
|
|
||
|
/*!
|
||
14 years ago
|
Divides the coordinates of the point by the given scale factor,
|
||
|
and returns a point with the new coordinates.
|
||
15 years ago
|
(Scalar division of a vector.)
|
||
|
*/
|
||
|
const QwtDoublePoint QwtDoublePoint::operator/(double factor) const
|
||
|
{
|
||
|
return QwtDoublePoint(d_x / factor, d_y / factor);
|
||
|
}
|
||
|
|
||
|
/*!
|
||
14 years ago
|
Adds the coordinates of this point to the corresponding coordinates
|
||
|
of the other point, and returns a reference to this point with the
|
||
15 years ago
|
new coordinates. This is equivalent to vector addition.
|
||
|
*/
|
||
|
QwtDoublePoint &QwtDoublePoint::operator+=(const QwtDoublePoint &other)
|
||
|
{
|
||
|
d_x += other.d_x;
|
||
|
d_y += other.d_y;
|
||
|
return *this;
|
||
|
}
|
||
|
|
||
|
/*!
|
||
14 years ago
|
Subtracts the coordinates of the other point from the corresponding
|
||
|
coordinates of this point, and returns a reference to this point with
|
||
15 years ago
|
the new coordinates. This is equivalent to vector subtraction.
|
||
|
*/
|
||
|
QwtDoublePoint &QwtDoublePoint::operator-=(const QwtDoublePoint &other)
|
||
|
{
|
||
|
d_x -= other.d_x;
|
||
|
d_y -= other.d_y;
|
||
|
return *this;
|
||
|
}
|
||
|
|
||
|
/*!
|
||
14 years ago
|
Multiplies the coordinates of this point by the given scale factor,
|
||
|
and returns a reference to this point with the new coordinates.
|
||
15 years ago
|
This is equivalent to scalar multiplication of a vector.
|
||
|
*/
|
||
|
QwtDoublePoint &QwtDoublePoint::operator*=(double factor)
|
||
|
{
|
||
|
d_x *= factor;
|
||
|
d_y *= factor;
|
||
|
return *this;
|
||
|
}
|
||
|
|
||
|
/*!
|
||
14 years ago
|
Divides the coordinates of this point by the given scale factor,
|
||
|
and returns a references to this point with the new coordinates.
|
||
15 years ago
|
This is equivalent to scalar division of a vector.
|
||
|
*/
|
||
|
QwtDoublePoint &QwtDoublePoint::operator/=(double factor)
|
||
|
{
|
||
|
d_x /= factor;
|
||
|
d_y /= factor;
|
||
|
return *this;
|
||
|
}
|
||
|
|
||
|
//! Constructs an invalid size.
|
||
|
QwtDoubleSize::QwtDoubleSize():
|
||
|
d_width(-1.0),
|
||
|
d_height(-1.0)
|
||
14 years ago
|
{
|
||
|
}
|
||
15 years ago
|
|
||
|
//! Constructs a size with width width and height height.
|
||
|
QwtDoubleSize::QwtDoubleSize( double width, double height ):
|
||
|
d_width(width),
|
||
|
d_height(height)
|
||
14 years ago
|
{
|
||
|
}
|
||
15 years ago
|
|
||
|
//! Constructs a size with floating point accuracy from the given size.
|
||
|
QwtDoubleSize::QwtDoubleSize(const QSize &sz):
|
||
|
d_width(double(sz.width())),
|
||
|
d_height(double(sz.height()))
|
||
14 years ago
|
{
|
||
|
}
|
||
15 years ago
|
|
||
|
//! Swaps the width and height values.
|
||
|
void QwtDoubleSize::transpose()
|
||
14 years ago
|
{
|
||
15 years ago
|
double tmp = d_width;
|
||
|
d_width = d_height;
|
||
|
d_height = tmp;
|
||
|
}
|
||
|
|
||
14 years ago
|
/*!
|
||
|
Returns a size with the maximum width and height of this
|
||
15 years ago
|
size and other.
|
||
|
*/
|
||
|
QwtDoubleSize QwtDoubleSize::expandedTo(
|
||
|
const QwtDoubleSize &other) const
|
||
14 years ago
|
{
|
||
15 years ago
|
return QwtDoubleSize(
|
||
14 years ago
|
qwtMax(d_width, other.d_width),
|
||
|
qwtMax(d_height, other.d_height)
|
||
|
);
|
||
|
}
|
||
15 years ago
|
|
||
|
/*!
|
||
|
Returns a size with the minimum width and height of this size and other.
|
||
|
*/
|
||
|
QwtDoubleSize QwtDoubleSize::boundedTo(
|
||
|
const QwtDoubleSize &other) const
|
||
14 years ago
|
{
|
||
15 years ago
|
return QwtDoubleSize(
|
||
14 years ago
|
qwtMin(d_width, other.d_width),
|
||
|
qwtMin(d_height, other.d_height)
|
||
|
);
|
||
|
}
|
||
15 years ago
|
|
||
|
//! Returns true if s1 and s2 are equal; otherwise returns false.
|
||
|
bool QwtDoubleSize::operator==(const QwtDoubleSize &other) const
|
||
14 years ago
|
{
|
||
15 years ago
|
return d_width == other.d_width && d_height == other.d_height;
|
||
14 years ago
|
}
|
||
15 years ago
|
|
||
|
//! Returns true if s1 and s2 are different; otherwise returns false.
|
||
|
bool QwtDoubleSize::operator!=(const QwtDoubleSize &other) const
|
||
14 years ago
|
{
|
||
15 years ago
|
return !operator==(other);
|
||
14 years ago
|
}
|
||
15 years ago
|
|
||
14 years ago
|
/*!
|
||
15 years ago
|
Returns the size formed by adding both components by
|
||
|
the components of other. Each component is added separately.
|
||
|
*/
|
||
|
const QwtDoubleSize QwtDoubleSize::operator+(
|
||
|
const QwtDoubleSize &other) const
|
||
14 years ago
|
{
|
||
15 years ago
|
return QwtDoubleSize(d_width + other.d_width,
|
||
14 years ago
|
d_height + other.d_height);
|
||
|
}
|
||
15 years ago
|
|
||
14 years ago
|
/*!
|
||
15 years ago
|
Returns the size formed by subtracting both components by
|
||
|
the components of other. Each component is subtracted separately.
|
||
14 years ago
|
*/
|
||
15 years ago
|
const QwtDoubleSize QwtDoubleSize::operator-(
|
||
|
const QwtDoubleSize &other) const
|
||
14 years ago
|
{
|
||
15 years ago
|
return QwtDoubleSize(d_width - other.d_width,
|
||
14 years ago
|
d_height - other.d_height);
|
||
|
}
|
||
15 years ago
|
|
||
|
//! Returns the size formed by multiplying both components by c.
|
||
|
const QwtDoubleSize QwtDoubleSize::operator*(double c) const
|
||
14 years ago
|
{
|
||
15 years ago
|
return QwtDoubleSize(d_width * c, d_height * c);
|
||
14 years ago
|
}
|
||
15 years ago
|
|
||
|
//! Returns the size formed by dividing both components by c.
|
||
|
const QwtDoubleSize QwtDoubleSize::operator/(double c) const
|
||
14 years ago
|
{
|
||
15 years ago
|
return QwtDoubleSize(d_width / c, d_height / c);
|
||
14 years ago
|
}
|
||
15 years ago
|
|
||
|
//! Adds size other to this size and returns a reference to this size.
|
||
|
QwtDoubleSize &QwtDoubleSize::operator+=(const QwtDoubleSize &other)
|
||
14 years ago
|
{
|
||
|
d_width += other.d_width;
|
||
15 years ago
|
d_height += other.d_height;
|
||
|
return *this;
|
||
|
}
|
||
|
|
||
|
//! Subtracts size other from this size and returns a reference to this size.
|
||
|
QwtDoubleSize &QwtDoubleSize::operator-=(const QwtDoubleSize &other)
|
||
14 years ago
|
{
|
||
|
d_width -= other.d_width;
|
||
15 years ago
|
d_height -= other.d_height;
|
||
|
return *this;
|
||
|
}
|
||
|
|
||
14 years ago
|
/*
|
||
|
Multiplies this size's width and height by c,
|
||
15 years ago
|
and returns a reference to this size.
|
||
|
*/
|
||
|
QwtDoubleSize &QwtDoubleSize::operator*=(double c)
|
||
14 years ago
|
{
|
||
|
d_width *= c;
|
||
15 years ago
|
d_height *= c;
|
||
|
return *this;
|
||
|
}
|
||
|
|
||
14 years ago
|
/*
|
||
|
Devides this size's width and height by c,
|
||
15 years ago
|
and returns a reference to this size.
|
||
|
*/
|
||
|
QwtDoubleSize &QwtDoubleSize::operator/=(double c)
|
||
|
{
|
||
|
d_width /= c;
|
||
|
d_height /= c;
|
||
|
return *this;
|
||
14 years ago
|
}
|
||
15 years ago
|
|
||
14 years ago
|
//! Constructs an rectangle with all components set to 0.0
|
||
15 years ago
|
QwtDoubleRect::QwtDoubleRect():
|
||
|
d_left(0.0),
|
||
|
d_right(0.0),
|
||
|
d_top(0.0),
|
||
|
d_bottom(0.0)
|
||
|
{
|
||
|
}
|
||
|
|
||
14 years ago
|
/*!
|
||
15 years ago
|
Constructs an rectangle with x1 to x2 as x-range and,
|
||
|
y1 to y2 as y-range.
|
||
|
*/
|
||
|
QwtDoubleRect::QwtDoubleRect(double left, double top,
|
||
14 years ago
|
double width, double height):
|
||
15 years ago
|
d_left(left),
|
||
|
d_right(left + width),
|
||
|
d_top(top),
|
||
|
d_bottom(top + height)
|
||
|
{
|
||
|
}
|
||
|
|
||
14 years ago
|
/*!
|
||
|
Constructs a rectangle with topLeft as the top-left corner and
|
||
15 years ago
|
size as the rectangle size.
|
||
|
*/
|
||
|
QwtDoubleRect::QwtDoubleRect(
|
||
14 years ago
|
const QwtDoublePoint &p, const QwtDoubleSize &size):
|
||
15 years ago
|
d_left(p.x()),
|
||
|
d_right(p.x() + size.width()),
|
||
|
d_top(p.y()),
|
||
|
d_bottom(p.y() + size.height())
|
||
|
{
|
||
|
}
|
||
|
|
||
|
QwtDoubleRect::QwtDoubleRect(const QRect &rect):
|
||
|
d_left(rect.left()),
|
||
|
d_right(rect.right()),
|
||
|
d_top(rect.top()),
|
||
|
d_bottom(rect.bottom())
|
||
|
{
|
||
|
}
|
||
|
|
||
|
QRect QwtDoubleRect::toRect() const
|
||
|
{
|
||
|
return QRect(qRound(x()), qRound(y()), qRound(width()), qRound(height()));
|
||
|
}
|
||
|
|
||
14 years ago
|
/*!
|
||
15 years ago
|
Set the x-range from x1 to x2 and the y-range from y1 to y2.
|
||
|
*/
|
||
14 years ago
|
void QwtDoubleRect::setRect(double left, double top,
|
||
|
double width, double height)
|
||
15 years ago
|
{
|
||
|
d_left = left;
|
||
|
d_right = left + width;
|
||
|
d_top = top;
|
||
|
d_bottom = top + height;
|
||
|
}
|
||
|
|
||
|
/*!
|
||
14 years ago
|
Sets the size of the rectangle to size.
|
||
15 years ago
|
Changes x2 and y2 only.
|
||
|
*/
|
||
|
void QwtDoubleRect::setSize(const QwtDoubleSize &size)
|
||
|
{
|
||
|
setWidth(size.width());
|
||
|
setHeight(size.height());
|
||
|
}
|
||
|
|
||
|
/*!
|
||
14 years ago
|
Returns a normalized rectangle, i.e. a rectangle that has a non-negative
|
||
|
width and height.
|
||
15 years ago
|
|
||
14 years ago
|
It swaps x1 and x2 if x1() > x2(), and swaps y1 and y2 if y1() > y2().
|
||
15 years ago
|
*/
|
||
|
QwtDoubleRect QwtDoubleRect::normalized() const
|
||
|
{
|
||
|
QwtDoubleRect r;
|
||
14 years ago
|
if ( d_right < d_left ) {
|
||
15 years ago
|
r.d_left = d_right;
|
||
|
r.d_right = d_left;
|
||
14 years ago
|
} else {
|
||
15 years ago
|
r.d_left = d_left;
|
||
14 years ago
|
r.d_right = d_right;
|
||
15 years ago
|
}
|
||
14 years ago
|
if ( d_bottom < d_top ) {
|
||
|
r.d_top = d_bottom;
|
||
15 years ago
|
r.d_bottom = d_top;
|
||
14 years ago
|
} else {
|
||
15 years ago
|
r.d_top = d_top;
|
||
|
r.d_bottom = d_bottom;
|
||
|
}
|
||
|
return r;
|
||
|
}
|
||
|
|
||
|
/*!
|
||
14 years ago
|
Returns the bounding rectangle of this rectangle and rectangle other.
|
||
|
r.unite(s) is equivalent to r|s.
|
||
15 years ago
|
*/
|
||
|
QwtDoubleRect QwtDoubleRect::unite(const QwtDoubleRect &other) const
|
||
|
{
|
||
|
return *this | other;
|
||
|
}
|
||
|
|
||
|
/*!
|
||
14 years ago
|
Returns the intersection of this rectangle and rectangle other.
|
||
|
r.intersect(s) is equivalent to r&s.
|
||
15 years ago
|
*/
|
||
|
QwtDoubleRect QwtDoubleRect::intersect(const QwtDoubleRect &other) const
|
||
|
{
|
||
|
return *this & other;
|
||
|
}
|
||
|
|
||
|
/*!
|
||
14 years ago
|
Returns true if this rectangle intersects with rectangle other;
|
||
|
otherwise returns false.
|
||
15 years ago
|
*/
|
||
|
bool QwtDoubleRect::intersects(const QwtDoubleRect &other) const
|
||
|
{
|
||
|
return ( qwtMax(d_left, other.d_left) <= qwtMin(d_right, other.d_right) ) &&
|
||
14 years ago
|
( qwtMax(d_top, other.d_top ) <= qwtMin(d_bottom, other.d_bottom) );
|
||
15 years ago
|
}
|
||
|
|
||
14 years ago
|
//! Returns true if this rect and other are equal; otherwise returns false.
|
||
15 years ago
|
bool QwtDoubleRect::operator==(const QwtDoubleRect &other) const
|
||
|
{
|
||
14 years ago
|
return d_left == other.d_left && d_right == other.d_right &&
|
||
|
d_top == other.d_top && d_bottom == other.d_bottom;
|
||
15 years ago
|
}
|
||
|
|
||
14 years ago
|
//! Returns true if this rect and other are different; otherwise returns false.
|
||
15 years ago
|
bool QwtDoubleRect::operator!=(const QwtDoubleRect &other) const
|
||
|
{
|
||
|
return !operator==(other);
|
||
|
}
|
||
|
|
||
|
/*!
|
||
14 years ago
|
Returns the bounding rectangle of this rectangle and rectangle other.
|
||
|
The bounding rectangle of a nonempty rectangle and an empty or
|
||
|
invalid rectangle is defined to be the nonempty rectangle.
|
||
15 years ago
|
*/
|
||
|
QwtDoubleRect QwtDoubleRect::operator|(const QwtDoubleRect &other) const
|
||
|
{
|
||
14 years ago
|
if ( isEmpty() )
|
||
15 years ago
|
return other;
|
||
|
|
||
14 years ago
|
if ( other.isEmpty() )
|
||
15 years ago
|
return *this;
|
||
14 years ago
|
|
||
15 years ago
|
const double minX = qwtMin(d_left, other.d_left);
|
||
|
const double maxX = qwtMax(d_right, other.d_right);
|
||
|
const double minY = qwtMin(d_top, other.d_top);
|
||
|
const double maxY = qwtMax(d_bottom, other.d_bottom);
|
||
|
|
||
|
return QwtDoubleRect(minX, minY, maxX - minX, maxY - minY);
|
||
|
}
|
||
|
|
||
|
/*!
|
||
14 years ago
|
Returns the intersection of this rectangle and rectangle other.
|
||
|
Returns an empty rectangle if there is no intersection.
|
||
15 years ago
|
*/
|
||
|
QwtDoubleRect QwtDoubleRect::operator&(const QwtDoubleRect &other) const
|
||
|
{
|
||
|
if (isNull() || other.isNull())
|
||
|
return QwtDoubleRect();
|
||
|
|
||
|
const QwtDoubleRect r1 = normalized();
|
||
|
const QwtDoubleRect r2 = other.normalized();
|
||
|
|
||
|
const double minX = qwtMax(r1.left(), r2.left());
|
||
|
const double maxX = qwtMin(r1.right(), r2.right());
|
||
|
const double minY = qwtMax(r1.top(), r2.top());
|
||
|
const double maxY = qwtMin(r1.bottom(), r2.bottom());
|
||
|
|
||
|
return QwtDoubleRect(minX, minY, maxX - minX, maxY - minY);
|
||
|
}
|
||
|
|
||
14 years ago
|
//! Unites this rectangle with rectangle other.
|
||
15 years ago
|
QwtDoubleRect &QwtDoubleRect::operator|=(const QwtDoubleRect &other)
|
||
|
{
|
||
|
*this = *this | other;
|
||
|
return *this;
|
||
|
}
|
||
|
|
||
14 years ago
|
//! Intersects this rectangle with rectangle other.
|
||
15 years ago
|
QwtDoubleRect &QwtDoubleRect::operator&=(const QwtDoubleRect &other)
|
||
|
{
|
||
|
*this = *this & other;
|
||
|
return *this;
|
||
|
}
|
||
|
|
||
14 years ago
|
//! Returns the center point of the rectangle.
|
||
15 years ago
|
QwtDoublePoint QwtDoubleRect::center() const
|
||
|
{
|
||
14 years ago
|
return QwtDoublePoint(d_left + (d_right - d_left) / 2.0,
|
||
|
d_top + (d_bottom - d_top) / 2.0);
|
||
15 years ago
|
}
|
||
|
|
||
|
/*!
|
||
14 years ago
|
Returns true if the point (x, y) is inside or on the edge of the rectangle;
|
||
|
otherwise returns false.
|
||
15 years ago
|
|
||
14 years ago
|
If proper is true, this function returns true only if p is inside
|
||
|
(not on the edge).
|
||
15 years ago
|
*/
|
||
|
bool QwtDoubleRect::contains(double x, double y, bool proper) const
|
||
|
{
|
||
|
if ( proper )
|
||
|
return x > d_left && x < d_right && y > d_top && y < d_bottom;
|
||
|
else
|
||
|
return x >= d_left && x <= d_right && y >= d_top && y <= d_bottom;
|
||
|
}
|
||
|
|
||
|
/*!
|
||
14 years ago
|
Returns true if the point p is inside or on the edge of the rectangle;
|
||
|
otherwise returns false.
|
||
15 years ago
|
|
||
14 years ago
|
If proper is true, this function returns true only if p is inside
|
||
|
(not on the edge).
|
||
15 years ago
|
*/
|
||
|
bool QwtDoubleRect::contains(const QwtDoublePoint &p, bool proper) const
|
||
|
{
|
||
|
return contains(p.x(), p.y(), proper);
|
||
|
}
|
||
|
|
||
|
/*!
|
||
14 years ago
|
Returns true if the rectangle other is inside this rectangle;
|
||
|
otherwise returns false.
|
||
15 years ago
|
|
||
14 years ago
|
If proper is true, this function returns true only if other is entirely
|
||
|
inside (not on the edge).
|
||
15 years ago
|
*/
|
||
|
bool QwtDoubleRect::contains(const QwtDoubleRect &other, bool proper) const
|
||
|
{
|
||
14 years ago
|
return contains(other.d_left, other.d_top, proper) &&
|
||
|
contains(other.d_right, other.d_bottom, proper);
|
||
15 years ago
|
}
|
||
|
|
||
|
//! moves x1() to x, leaving the size unchanged
|
||
|
void QwtDoubleRect::moveLeft(double x)
|
||
|
{
|
||
|
const double w = width();
|
||
|
d_left = x;
|
||
|
d_right = d_left + w;
|
||
|
}
|
||
|
|
||
|
//! moves x1() to x, leaving the size unchanged
|
||
|
void QwtDoubleRect::moveRight(double x)
|
||
|
{
|
||
|
const double w = width();
|
||
|
d_right = x;
|
||
|
d_left = d_right - w;
|
||
|
}
|
||
|
|
||
|
//! moves y1() to y, leaving the size unchanged
|
||
|
void QwtDoubleRect::moveTop(double y)
|
||
|
{
|
||
|
const double h = height();
|
||
|
d_top = y;
|
||
|
d_bottom = d_top + h;
|
||
|
}
|
||
|
|
||
|
//! moves y1() to y, leaving the size unchanged
|
||
|
void QwtDoubleRect::moveBottom(double y)
|
||
|
{
|
||
|
const double h = height();
|
||
|
d_bottom = y;
|
||
|
d_top = d_bottom - h;
|
||
|
}
|
||
|
|
||
|
//! moves left() to x and top() to y, leaving the size unchanged
|
||
|
void QwtDoubleRect::moveTo(double x, double y)
|
||
|
{
|
||
|
moveLeft(x);
|
||
|
moveTop(y);
|
||
|
}
|
||
|
|
||
|
//! moves x1() by dx and y1() by dy. leaving the size unchanged
|
||
|
void QwtDoubleRect::moveBy(double dx, double dy)
|
||
|
{
|
||
|
d_left += dx;
|
||
|
d_right += dx;
|
||
|
d_top += dy;
|
||
|
d_bottom += dy;
|
||
|
}
|
||
|
|
||
|
//! moves the center to pos, leaving the size unchanged
|
||
|
void QwtDoubleRect::moveCenter(const QwtDoublePoint &pos)
|
||
|
{
|
||
|
moveCenter(pos.x(), pos.y());
|
||
|
}
|
||
|
|
||
|
//! moves the center to (x, y), leaving the size unchanged
|
||
|
void QwtDoubleRect::moveCenter(double x, double y)
|
||
|
{
|
||
|
moveTo(x - width() / 2.0, y - height() / 2.0);
|
||
|
}
|
||
|
|
||
|
#endif // QT_VERSION < 0x040000
|