#include <qwt_double_rect.h>
Public Member Functions | |
QwtDoubleRect () | |
Constructs an rectangle with all components set to 0.0. | |
QwtDoubleRect (double left, double top, double width, double height) | |
QwtDoubleRect (const QwtDoublePoint &, const QwtDoubleSize &) | |
QwtDoubleRect (const QRect &) | |
QRect | toRect () const |
bool | isNull () const |
bool | isEmpty () const |
bool | isValid () const |
QwtDoubleRect | normalized () const |
double | x () const |
Returns x. | |
double | y () const |
Returns y. | |
double | left () const |
Returns left. | |
double | right () const |
Returns right. | |
double | top () const |
Returns top. | |
double | bottom () const |
Returns bottom. | |
void | setX (double) |
Set left. | |
void | setY (double) |
Set left. | |
void | setLeft (double) |
Set left. | |
void | setRight (double) |
Set right. | |
void | setTop (double) |
Set top. | |
void | setBottom (double) |
Set bottom. | |
QwtDoublePoint | center () const |
Returns the center point of the rectangle. | |
void | moveLeft (double x) |
moves x1() to x, leaving the size unchanged | |
void | moveRight (double x) |
moves x1() to x, leaving the size unchanged | |
void | moveTop (double y) |
moves y1() to y, leaving the size unchanged | |
void | moveBottom (double y) |
moves y1() to y, leaving the size unchanged | |
void | moveTo (double x, double y) |
moves left() to x and top() to y, leaving the size unchanged | |
void | moveTo (const QwtDoublePoint &) |
void | moveBy (double dx, double dy) |
moves x1() by dx and y1() by dy. leaving the size unchanged | |
void | moveCenter (const QwtDoublePoint &) |
moves the center to pos, leaving the size unchanged | |
void | moveCenter (double dx, double dy) |
moves the center to (x, y), leaving the size unchanged | |
void | setRect (double x1, double x2, double width, double height) |
double | width () const |
Returns the width. | |
double | height () const |
Returns the height. | |
QwtDoubleSize | size () const |
Returns the size. | |
void | setWidth (double w) |
Set the width, by right = left + w;. | |
void | setHeight (double h) |
Set the height, by bottom = top + h;. | |
void | setSize (const QwtDoubleSize &) |
QwtDoubleRect | operator| (const QwtDoubleRect &r) const |
QwtDoubleRect | operator& (const QwtDoubleRect &r) const |
QwtDoubleRect & | operator|= (const QwtDoubleRect &r) |
Unites this rectangle with rectangle other. | |
QwtDoubleRect & | operator&= (const QwtDoubleRect &r) |
Intersects this rectangle with rectangle other. | |
bool | operator== (const QwtDoubleRect &) const |
Returns true if this rect and other are equal; otherwise returns false. | |
bool | operator!= (const QwtDoubleRect &) const |
Returns true if this rect and other are different; otherwise returns false. | |
bool | contains (const QwtDoublePoint &p, bool proper=false) const |
bool | contains (double x, double y, bool proper=false) const |
bool | contains (const QwtDoubleRect &r, bool proper=false) const |
QwtDoubleRect | unite (const QwtDoubleRect &) const |
QwtDoubleRect | intersect (const QwtDoubleRect &) const |
bool | intersects (const QwtDoubleRect &) const |
QwtDoublePoint | bottomRight () const |
QwtDoublePoint | topRight () const |
QwtDoublePoint | topLeft () const |
QwtDoublePoint | bottomLeft () const |
The QwtDoubleRect class defines a size in double coordinates.
Definition at line 142 of file qwt_double_rect.h.
QwtDoubleRect::QwtDoubleRect | ( | ) |
Constructs an rectangle with all components set to 0.0.
Definition at line 301 of file qwt_double_rect.cpp.
Referenced by operator&(), and operator|().
: d_left(0.0), d_right(0.0), d_top(0.0), d_bottom(0.0) { }
QwtDoubleRect::QwtDoubleRect | ( | double | left, |
double | top, | ||
double | width, | ||
double | height | ||
) |
QwtDoubleRect::QwtDoubleRect | ( | const QwtDoublePoint & | p, |
const QwtDoubleSize & | size | ||
) |
QwtDoubleRect::QwtDoubleRect | ( | const QRect & | rect ) |
Definition at line 335 of file qwt_double_rect.cpp.
: d_left(rect.left()), d_right(rect.right()), d_top(rect.top()), d_bottom(rect.bottom()) { }
double QwtDoubleRect::bottom | ( | ) | const [inline] |
Returns bottom.
Definition at line 398 of file qwt_double_rect.h.
Referenced by bottomLeft(), bottomRight(), QmitkHistogram::boundingRect(), QwtPlotCurve::maxYValue(), QwtPlotZoomer::move(), operator&(), QwtPlotZoomer::rescale(), QwtPlotPicker::transform(), QwtPlotItem::transform(), QwtPlot::updateAxes(), and QwtPlotSvgItem::viewBox().
{
return d_bottom;
}
QwtDoublePoint QwtDoubleRect::bottomLeft | ( | ) | const [inline] |
Definition at line 493 of file qwt_double_rect.h.
References bottom(), and left().
{ return QwtDoublePoint(bottom(), left()); }
QwtDoublePoint QwtDoubleRect::bottomRight | ( | ) | const [inline] |
Definition at line 478 of file qwt_double_rect.h.
References bottom(), and right().
{ return QwtDoublePoint(bottom(), right()); }
QwtDoublePoint QwtDoubleRect::center | ( | ) | const |
Returns the center point of the rectangle.
Definition at line 499 of file qwt_double_rect.cpp.
Referenced by QwtPlotZoomer::end().
{ return QwtDoublePoint(d_left + (d_right - d_left) / 2.0, d_top + (d_bottom - d_top) / 2.0); }
bool QwtDoubleRect::contains | ( | double | x, |
double | y, | ||
bool | proper = false |
||
) | const |
Returns true if the point (x, y) is inside or on the edge of the rectangle; otherwise returns false.
If proper is true, this function returns true only if p is inside (not on the edge).
Definition at line 512 of file qwt_double_rect.cpp.
{ 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; }
bool QwtDoubleRect::contains | ( | const QwtDoubleRect & | other, |
bool | proper = false |
||
) | const |
Returns true if the rectangle other is inside this rectangle; otherwise returns false.
If proper is true, this function returns true only if other is entirely inside (not on the edge).
Definition at line 539 of file qwt_double_rect.cpp.
References contains().
bool QwtDoubleRect::contains | ( | const QwtDoublePoint & | p, |
bool | proper = false |
||
) | const |
Returns true if the point p is inside or on the edge of the rectangle; otherwise returns false.
If proper is true, this function returns true only if p is inside (not on the edge).
Definition at line 527 of file qwt_double_rect.cpp.
References QwtDoublePoint::x(), and QwtDoublePoint::y().
Referenced by QwtPolygonClipperF::clipPolygon(), contains(), and QwtPlotSvgItem::draw().
double QwtDoubleRect::height | ( | ) | const [inline] |
Returns the height.
Definition at line 446 of file qwt_double_rect.h.
Referenced by QwtPlotZoomer::move(), moveBottom(), moveCenter(), moveTop(), QwtPlotSvgItem::render(), QwtPlotSpectrogram::renderImage(), setRect(), size(), and toRect().
{
return d_bottom - d_top;
}
QwtDoubleRect QwtDoubleRect::intersect | ( | const QwtDoubleRect & | other ) | const |
Returns the intersection of this rectangle and rectangle other. r.intersect(s) is equivalent to r&s.
Definition at line 415 of file qwt_double_rect.cpp.
{ return *this & other; }
bool QwtDoubleRect::intersects | ( | const QwtDoubleRect & | other ) | const |
Returns true if this rectangle intersects with rectangle other; otherwise returns false.
Definition at line 424 of file qwt_double_rect.cpp.
bool QwtDoubleRect::isEmpty | ( | ) | const [inline] |
Returns true if the rectangle is empty; otherwise returns false. An empty rectangle has a width() <= 0 or height() <= 0. An empty rectangle is not valid. isEmpty() == !isValid()
Definition at line 349 of file qwt_double_rect.h.
Referenced by operator|(), and QwtPlotSpectrogram::renderImage().
{
return d_left >= d_right || d_top >= d_bottom;
}
bool QwtDoubleRect::isNull | ( | ) | const [inline] |
Returns true if the rectangle is a null rectangle; otherwise returns false. A null rectangle has both the width and the height set to 0. A null rectangle is also empty and invalid.
Definition at line 337 of file qwt_double_rect.h.
Referenced by operator&().
{
return d_right == d_left && d_bottom == d_top;
}
bool QwtDoubleRect::isValid | ( | ) | const [inline] |
Returns true if the rectangle is valid; otherwise returns false. A valid rectangle has a width() > 0 and height() > 0. Note that non-trivial operations like intersections are not defined for invalid rectangles. isValid() == !isEmpty()
Definition at line 362 of file qwt_double_rect.h.
Referenced by QmitkHistogram::boundingRect(), QwtPlotSvgItem::draw(), QwtPlotSpectrogram::draw(), QwtPlotSvgItem::render(), and QwtPlotSvgItem::viewBox().
{
return d_left < d_right && d_top < d_bottom;
}
double QwtDoubleRect::left | ( | ) | const [inline] |
Returns left.
Definition at line 380 of file qwt_double_rect.h.
Referenced by bottomLeft(), QwtPlotCurve::minXValue(), QwtPlotZoomer::move(), QwtPlotZoomer::moveBy(), operator&(), QwtPlotZoomer::rescale(), setRect(), topLeft(), QwtPlotPicker::transform(), QwtPlotItem::transform(), QwtPlot::updateAxes(), and QwtPlotSvgItem::viewBox().
{
return d_left;
}
void QwtDoubleRect::moveBottom | ( | double | y ) |
void QwtDoubleRect::moveBy | ( | double | dx, |
double | dy | ||
) |
moves x1() by dx and y1() by dy. leaving the size unchanged
Definition at line 585 of file qwt_double_rect.cpp.
{ d_left += dx; d_right += dx; d_top += dy; d_bottom += dy; }
void QwtDoubleRect::moveCenter | ( | const QwtDoublePoint & | pos ) |
moves the center to pos, leaving the size unchanged
Definition at line 594 of file qwt_double_rect.cpp.
References QwtDoublePoint::x(), and QwtDoublePoint::y().
Referenced by QwtPlotZoomer::end().
{ moveCenter(pos.x(), pos.y()); }
void QwtDoubleRect::moveCenter | ( | double | dx, |
double | dy | ||
) |
void QwtDoubleRect::moveLeft | ( | double | x ) |
void QwtDoubleRect::moveRight | ( | double | x ) |
void QwtDoubleRect::moveTo | ( | double | x, |
double | y | ||
) |
moves left() to x and top() to y, leaving the size unchanged
Definition at line 578 of file qwt_double_rect.cpp.
References moveLeft(), and moveTop().
Referenced by moveCenter(), and moveTo().
void QwtDoubleRect::moveTo | ( | const QwtDoublePoint & | p ) | [inline] |
Moves the top left corner of the rectangle to p, without changing the rectangles size.
Definition at line 473 of file qwt_double_rect.h.
References moveTo(), QwtDoublePoint::x(), and QwtDoublePoint::y().
void QwtDoubleRect::moveTop | ( | double | y ) |
QwtDoubleRect QwtDoubleRect::normalized | ( | ) | const |
Returns a normalized rectangle, i.e. a rectangle that has a non-negative width and height.
It swaps x1 and x2 if x1() > x2(), and swaps y1 and y2 if y1() > y2().
Definition at line 376 of file qwt_double_rect.cpp.
Referenced by QwtPlotZoomer::end(), QwtPlotItem::invTransform(), operator&(), QwtPlotPicker::scaleRect(), and QwtPlotZoomer::zoom().
{ QwtDoubleRect r; if ( d_right < d_left ) { r.d_left = d_right; r.d_right = d_left; } else { r.d_left = d_left; r.d_right = d_right; } if ( d_bottom < d_top ) { r.d_top = d_bottom; r.d_bottom = d_top; } else { r.d_top = d_top; r.d_bottom = d_bottom; } return r; }
bool QwtDoubleRect::operator!= | ( | const QwtDoubleRect & | other ) | const |
Returns true if this rect and other are different; otherwise returns false.
Definition at line 438 of file qwt_double_rect.cpp.
References operator==().
{ return !operator==(other); }
QwtDoubleRect QwtDoubleRect::operator& | ( | const QwtDoubleRect & | other ) | const |
Returns the intersection of this rectangle and rectangle other. Returns an empty rectangle if there is no intersection.
Definition at line 468 of file qwt_double_rect.cpp.
References bottom(), isNull(), left(), normalized(), QwtDoubleRect(), qwtMax, qwtMin, right(), and top().
{ 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); }
QwtDoubleRect & QwtDoubleRect::operator&= | ( | const QwtDoubleRect & | r ) |
Intersects this rectangle with rectangle other.
Definition at line 492 of file qwt_double_rect.cpp.
{ *this = *this & other; return *this; }
bool QwtDoubleRect::operator== | ( | const QwtDoubleRect & | other ) | const |
Returns true if this rect and other are equal; otherwise returns false.
Definition at line 431 of file qwt_double_rect.cpp.
Referenced by operator!=().
{
return d_left == other.d_left && d_right == other.d_right &&
d_top == other.d_top && d_bottom == other.d_bottom;
}
QwtDoubleRect QwtDoubleRect::operator| | ( | const QwtDoubleRect & | other ) | const |
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.
Definition at line 448 of file qwt_double_rect.cpp.
References isEmpty(), QwtDoubleRect(), qwtMax, and qwtMin.
{ if ( isEmpty() ) return other; if ( other.isEmpty() ) return *this; 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); }
QwtDoubleRect & QwtDoubleRect::operator|= | ( | const QwtDoubleRect & | r ) |
Unites this rectangle with rectangle other.
Definition at line 485 of file qwt_double_rect.cpp.
{ *this = *this | other; return *this; }
double QwtDoubleRect::right | ( | ) | const [inline] |
Returns right.
Definition at line 386 of file qwt_double_rect.h.
Referenced by bottomRight(), QwtPlotCurve::maxXValue(), QwtPlotZoomer::move(), operator&(), QwtPlotZoomer::rescale(), topRight(), QwtPlotPicker::transform(), QwtPlotItem::transform(), QwtPlot::updateAxes(), and QwtPlotSvgItem::viewBox().
{
return d_right;
}
void QwtDoubleRect::setBottom | ( | double | y ) | [inline] |
Set bottom.
Definition at line 434 of file qwt_double_rect.h.
References y().
Referenced by QmitkHistogram::boundingRect().
{ d_bottom = y; }
void QwtDoubleRect::setHeight | ( | double | h ) | [inline] |
Set the height, by bottom = top + h;.
Definition at line 464 of file qwt_double_rect.h.
Referenced by setSize().
{ d_bottom = d_top + h; }
void QwtDoubleRect::setLeft | ( | double | x ) | [inline] |
void QwtDoubleRect::setRect | ( | double | left, |
double | top, | ||
double | width, | ||
double | height | ||
) |
void QwtDoubleRect::setRight | ( | double | x ) | [inline] |
void QwtDoubleRect::setSize | ( | const QwtDoubleSize & | size ) |
Sets the size of the rectangle to size. Changes x2 and y2 only.
Definition at line 364 of file qwt_double_rect.cpp.
References QwtDoubleSize::height(), setHeight(), setWidth(), and QwtDoubleSize::width().
Referenced by QwtPlotZoomer::end().
void QwtDoubleRect::setTop | ( | double | y ) | [inline] |
Set top.
Definition at line 428 of file qwt_double_rect.h.
References y().
Referenced by QmitkHistogram::boundingRect().
{ d_top = y; }
void QwtDoubleRect::setWidth | ( | double | w ) | [inline] |
Set the width, by right = left + w;.
Definition at line 458 of file qwt_double_rect.h.
Referenced by QwtPlot::print(), QwtPlot::printCanvas(), and setSize().
{ d_right = d_left + w; }
void QwtDoubleRect::setX | ( | double | x ) | [inline] |
void QwtDoubleRect::setY | ( | double | y ) | [inline] |
QwtDoubleSize QwtDoubleRect::size | ( | ) | const [inline] |
Returns the size.
Definition at line 452 of file qwt_double_rect.h.
References height(), and width().
Referenced by QwtPlotZoomer::end(), and QwtPlotSpectrogram::renderImage().
{ return QwtDoubleSize(width(), height()); }
double QwtDoubleRect::top | ( | ) | const [inline] |
Returns top.
Definition at line 392 of file qwt_double_rect.h.
Referenced by QmitkHistogram::boundingRect(), QwtPlotCurve::minYValue(), QwtPlotZoomer::move(), QwtPlotZoomer::moveBy(), operator&(), QwtPlotZoomer::rescale(), setRect(), topLeft(), topRight(), QwtPlotPicker::transform(), QwtPlotItem::transform(), QwtPlot::updateAxes(), and QwtPlotSvgItem::viewBox().
{
return d_top;
}
QwtDoublePoint QwtDoubleRect::topLeft | ( | ) | const [inline] |
Definition at line 488 of file qwt_double_rect.h.
{ return QwtDoublePoint(top(), left()); }
QwtDoublePoint QwtDoubleRect::topRight | ( | ) | const [inline] |
Definition at line 483 of file qwt_double_rect.h.
References right(), and top().
{ return QwtDoublePoint(top(), right()); }
QRect QwtDoubleRect::toRect | ( | ) | const |
QwtDoubleRect QwtDoubleRect::unite | ( | const QwtDoubleRect & | other ) | const |
Returns the bounding rectangle of this rectangle and rectangle other. r.unite(s) is equivalent to r|s.
Definition at line 406 of file qwt_double_rect.cpp.
{ return *this | other; }
double QwtDoubleRect::width | ( | ) | const [inline] |
Returns the width.
Definition at line 440 of file qwt_double_rect.h.
Referenced by QwtPlotZoomer::move(), moveCenter(), moveLeft(), moveRight(), QwtPlotSvgItem::render(), QwtPlotSpectrogram::renderImage(), setRect(), size(), and toRect().
{
return d_right - d_left;
}
double QwtDoubleRect::x | ( | ) | const [inline] |
Returns x.
Definition at line 368 of file qwt_double_rect.h.
Referenced by moveLeft(), moveRight(), QwtPlotSvgItem::render(), QwtPlotSpectrogram::renderImage(), setLeft(), setRight(), setX(), and toRect().
{
return d_left;
}
double QwtDoubleRect::y | ( | ) | const [inline] |
Returns y.
Definition at line 374 of file qwt_double_rect.h.
Referenced by moveBottom(), moveTop(), QwtPlotSvgItem::render(), QwtPlotSpectrogram::renderImage(), setBottom(), setTop(), setY(), and toRect().
{
return d_top;
}