Public Member Functions

QwtDoublePoint Class Reference

The QwtDoublePoint class defines a point in double coordinates. More...

#include <qwt_double_rect.h>

List of all members.

Public Member Functions

 QwtDoublePoint ()
 QwtDoublePoint (double x, double y)
 Constructs a point with coordinates specified by x and y.
 QwtDoublePoint (const QPoint &)
QPoint toPoint () const
bool isNull () const
double x () const
 Returns the x-coordinate of the point.
double y () const
 Returns the y-coordinate of the point.
double & rx ()
 Returns a reference to the x-coordinate of the point.
double & ry ()
 Returns a reference to the y-coordinate of the point.
void setX (double x)
 Sets the x-coordinate of the point to the value specified by x.
void setY (double y)
 Sets the y-coordinate of the point to the value specified by y.
bool operator== (const QwtDoublePoint &) const
bool operator!= (const QwtDoublePoint &) const
 Returns true if point1 is not equal to point2; otherwise returns false.
const QwtDoublePoint operator- () const
const QwtDoublePoint operator+ (const QwtDoublePoint &) const
const QwtDoublePoint operator- (const QwtDoublePoint &) const
const QwtDoublePoint operator* (double) const
const QwtDoublePoint operator/ (double) const
QwtDoublePointoperator+= (const QwtDoublePoint &)
QwtDoublePointoperator-= (const QwtDoublePoint &)
QwtDoublePointoperator*= (double)
QwtDoublePointoperator/= (double)

Detailed Description

The QwtDoublePoint class defines a point in double coordinates.

Definition at line 57 of file qwt_double_rect.h.


Constructor & Destructor Documentation

QwtDoublePoint::QwtDoublePoint (  )

Constructs a null point.

See also:
QwtDoublePoint::isNull()

Definition at line 22 of file qwt_double_rect.cpp.

Referenced by operator*(), operator+(), operator-(), and operator/().

                              :
    d_x(0.0),
    d_y(0.0)
{
}
QwtDoublePoint::QwtDoublePoint ( double  x,
double  y 
)

Constructs a point with coordinates specified by x and y.

Definition at line 29 of file qwt_double_rect.cpp.

                                                 :
    d_x(x),
    d_y(y)
{
}
QwtDoublePoint::QwtDoublePoint ( const QPoint &  p )

Copy constructor.

Constructs a point using the values of the point specified.

Definition at line 40 of file qwt_double_rect.cpp.

                                             :
    d_x(double(p.x())),
    d_y(double(p.y()))
{
}

Member Function Documentation

bool QwtDoublePoint::isNull (  ) const [inline]

Returns true if the point is null; otherwise returns false.

A point is considered to be null if both the x- and y-coordinates are equal to zero.

Definition at line 229 of file qwt_double_rect.h.

{ 
    return d_x == 0.0 && d_y == 0.0; 
}
bool QwtDoublePoint::operator!= ( const QwtDoublePoint other ) const

Returns true if point1 is not equal to point2; otherwise returns false.

Definition at line 58 of file qwt_double_rect.cpp.

References operator==().

{
    return !operator==(other);
}
const QwtDoublePoint QwtDoublePoint::operator* ( double  factor ) const

Multiplies the coordinates of the point by the given scale factor, and returns a point with the new coordinates. (Scalar multiplication of a vector.)

Definition at line 99 of file qwt_double_rect.cpp.

References QwtDoublePoint().

{
    return QwtDoublePoint(d_x * factor, d_y * factor);
}
QwtDoublePoint & QwtDoublePoint::operator*= ( double  factor )

Multiplies the coordinates of this point by the given scale factor, and returns a reference to this point with the new coordinates. This is equivalent to scalar multiplication of a vector.

Definition at line 143 of file qwt_double_rect.cpp.

{
    d_x *= factor;
    d_y *= factor;
    return *this;
}
const QwtDoublePoint QwtDoublePoint::operator+ ( const QwtDoublePoint other ) const

Adds the coordinates of the point to the corresponding coordinates of the other point, and returns a point with the new coordinates. (Vector addition.)

Definition at line 77 of file qwt_double_rect.cpp.

References QwtDoublePoint().

{
    return QwtDoublePoint(d_x + other.d_x, d_y + other.d_y);
}
QwtDoublePoint & QwtDoublePoint::operator+= ( const QwtDoublePoint other )

Adds the coordinates of this point to the corresponding coordinates of the other point, and returns a reference to this point with the new coordinates. This is equivalent to vector addition.

Definition at line 119 of file qwt_double_rect.cpp.

{
    d_x += other.d_x;
    d_y += other.d_y;
    return *this;
}
const QwtDoublePoint QwtDoublePoint::operator- (  ) const

Negates the coordinates of the point, and returns a point with the new coordinates. (Inversion).

Definition at line 67 of file qwt_double_rect.cpp.

References QwtDoublePoint().

{
    return QwtDoublePoint(-d_x, -d_y);
}
const QwtDoublePoint QwtDoublePoint::operator- ( const QwtDoublePoint other ) const

Subtracts the coordinates of the other point from the corresponding coordinates of the given point, and returns a point with the new coordinates. (Vector subtraction.)

Definition at line 88 of file qwt_double_rect.cpp.

References QwtDoublePoint().

{
    return QwtDoublePoint(d_x - other.d_x, d_y - other.d_y);
}
QwtDoublePoint & QwtDoublePoint::operator-= ( const QwtDoublePoint other )

Subtracts the coordinates of the other point from the corresponding coordinates of this point, and returns a reference to this point with the new coordinates. This is equivalent to vector subtraction.

Definition at line 131 of file qwt_double_rect.cpp.

{
    d_x -= other.d_x;
    d_y -= other.d_y;
    return *this;
}
const QwtDoublePoint QwtDoublePoint::operator/ ( double  factor ) const

Divides the coordinates of the point by the given scale factor, and returns a point with the new coordinates. (Scalar division of a vector.)

Definition at line 109 of file qwt_double_rect.cpp.

References QwtDoublePoint().

{
    return QwtDoublePoint(d_x / factor, d_y / factor);
}
QwtDoublePoint & QwtDoublePoint::operator/= ( double  factor )

Divides the coordinates of this point by the given scale factor, and returns a references to this point with the new coordinates. This is equivalent to scalar division of a vector.

Definition at line 155 of file qwt_double_rect.cpp.

{
    d_x /= factor;
    d_y /= factor;
    return *this;
}
bool QwtDoublePoint::operator== ( const QwtDoublePoint other ) const

Returns true if point1 is equal to point2; otherwise returns false.

Two points are equal to each other if both x-coordinates and both y-coordinates are the same.

Definition at line 52 of file qwt_double_rect.cpp.

Referenced by operator!=().

{
    return (d_x == other.d_x) && (d_y == other.d_y);
}
double & QwtDoublePoint::rx (  ) [inline]

Returns a reference to the x-coordinate of the point.

Definition at line 247 of file qwt_double_rect.h.

{
    return d_x;
}
double & QwtDoublePoint::ry (  ) [inline]

Returns a reference to the y-coordinate of the point.

Definition at line 253 of file qwt_double_rect.h.

{
    return d_y;
}
void QwtDoublePoint::setX ( double  x ) [inline]

Sets the x-coordinate of the point to the value specified by x.

Definition at line 259 of file qwt_double_rect.h.

References x().

Referenced by QwtPlotCurve::drawLines().

{ 
    d_x = x; 
}
void QwtDoublePoint::setY ( double  y ) [inline]

Sets the y-coordinate of the point to the value specified by y.

Definition at line 265 of file qwt_double_rect.h.

References y().

Referenced by QwtPlotCurve::drawLines().

{ 
    d_y = y; 
}
QPoint QwtDoublePoint::toPoint (  ) const [inline]

Rounds the coordinates of this point to the nearest integer and returns a QPoint with these rounded coordinates.

Definition at line 274 of file qwt_double_rect.h.

{
    return QPoint(qRound(d_x), qRound(d_y));
}
double QwtDoublePoint::x (  ) const [inline]
double QwtDoublePoint::y (  ) const [inline]

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines