Qt 4.8
|
The QLineF class provides a two-dimensional vector using floating point precision. More...
#include <qline.h>
Public Types | |
enum | IntersectType { NoIntersection, BoundedIntersection, UnboundedIntersection } |
Describes the intersection between two lines. More... | |
Public Functions | |
qreal | angle () const |
Returns the angle of the line in degrees. More... | |
qreal | angle (const QLineF &l) const |
Returns the angle (in degrees) between this line and the given line, taking the direction of the lines into account. More... | |
qreal | angleTo (const QLineF &l) const |
Returns the angle (in positive degrees) from this line to the given line, taking the direction of the lines into account. More... | |
qreal | dx () const |
Returns the horizontal component of the line's vector. More... | |
qreal | dy () const |
Returns the vertical component of the line's vector. More... | |
IntersectType | intersect (const QLineF &l, QPointF *intersectionPoint) const |
Returns a value indicating whether or not this line intersects with the given line. More... | |
bool | isNull () const |
Returns true if the line is not set up with valid start and end point; otherwise returns false. More... | |
qreal | length () const |
Returns the length of the line. More... | |
QLineF | normalVector () const |
Returns a line that is perpendicular to this line with the same starting point and length. More... | |
bool | operator!= (const QLineF &d) const |
Returns true if the given line is not the same as this line. More... | |
bool | operator== (const QLineF &d) const |
Returns true if the given line is the same as this line. More... | |
QPointF | p1 () const |
Returns the line's start point. More... | |
QPointF | p2 () const |
Returns the line's end point. More... | |
QPointF | pointAt (qreal t) const |
Returns the point at the parameterized position specified by t. More... | |
QLineF () | |
Constructs a null line. More... | |
QLineF (const QPointF &pt1, const QPointF &pt2) | |
Constructs a line object that represents the line between p1 and p2. More... | |
QLineF (qreal x1, qreal y1, qreal x2, qreal y2) | |
Constructs a line object that represents the line between (x1, y1) and (x2, y2). More... | |
QLineF (const QLine &line) | |
Construct a QLineF object from the given integer-based line. More... | |
void | setAngle (qreal angle) |
Sets the angle of the line to the given angle (in degrees). More... | |
void | setLength (qreal len) |
Sets the length of the line to the given length. More... | |
void | setLine (qreal x1, qreal y1, qreal x2, qreal y2) |
Sets this line to the start in x1, y1 and end in x2, y2. More... | |
void | setP1 (const QPointF &p1) |
Sets the starting point of this line to p1. More... | |
void | setP2 (const QPointF &p2) |
Sets the end point of this line to p2. More... | |
void | setPoints (const QPointF &p1, const QPointF &p2) |
Sets the start point of this line to p1 and the end point of this line to p2. More... | |
QLine | toLine () const |
Returns an integer based copy of this line. More... | |
void | translate (const QPointF &p) |
Translates this line by the given offset. More... | |
void | translate (qreal dx, qreal dy) |
Translates this line the distance specified by dx and dy. More... | |
QLineF | translated (const QPointF &p) const |
Returns this line translated by the given offset. More... | |
QLineF | translated (qreal dx, qreal dy) const |
Returns this line translated the distance specified by dx and dy. More... | |
QLineF | unitVector () const |
Returns the unit vector for this line, i.e a line starting at the same point as this line with a length of 1.0. More... | |
qreal | x1 () const |
Returns the x-coordinate of the line's start point. More... | |
qreal | x2 () const |
Returns the x-coordinate of the line's end point. More... | |
qreal | y1 () const |
Returns the y-coordinate of the line's start point. More... | |
qreal | y2 () const |
Returns the y-coordinate of the line's end point. More... | |
Static Public Functions | |
static QLineF | fromPolar (qreal length, qreal angle) |
Returns a QLineF with the given length and angle. More... | |
Properties | |
QPointF | pt1 |
QPointF | pt2 |
Related Functions | |
(Note that these are not member functions.) | |
QDataStream & | operator<< (QDataStream &stream, const QLineF &line) |
Writes the given line to the given stream and returns a reference to the stream. More... | |
QDataStream & | operator>> (QDataStream &stream, QLineF &line) |
Reads a line from the given stream into the given line and returns a reference to the stream. More... | |
The QLineF class provides a two-dimensional vector using floating point precision.
A QLineF describes a finite length line (or line segment) on a two-dimensional surface. QLineF defines the start and end points of the line using floating point accuracy for coordinates. Use the toLine() function to retrieve an integer based copy of this line.
The positions of the line's start and end points can be retrieved using the p1(), x1(), y1(), p2(), x2(), and y2() functions. The dx() and dy() functions return the horizontal and vertical components of the line, respectively.
The line's length can be retrieved using the length() function, and altered using the setLength() function. Similarly, angle() and setAngle() are respectively used for retrieving and altering the angle of the line. Use the isNull() function to determine whether the QLineF represents a valid line or a null line.
The intersect() function determines the IntersectType for this line and a given line, while the angle() function returns the angle between the lines. In addition, the unitVector() function returns a line that has the same starting point as this line, but with a length of only 1, while the normalVector() function returns a line that is perpendicular to this line with the same starting point and length.
Finally, the line can be translated a given offset using the translate() function, and can be traversed using the pointAt() function.
Describes the intersection between two lines.
QLineF::UnboundedIntersection | QLineF::BoundedIntersection |
intersect() will also return this value if the intersect point is within the start and end point of only one of the lines.
Enumerator | |
---|---|
NoIntersection | |
BoundedIntersection | |
UnboundedIntersection |
|
inline |
Constructs a null line.
Definition at line 280 of file qline.h.
Referenced by fromPolar(), normalVector(), operator>>(), and translated().
|
inline |
qreal QLineF::angle | ( | ) | const |
Returns the angle of the line in degrees.
The return value will be in the range of values from 0.0 up to but not including 360.0. The angles are measured counter-clockwise from a point on the x-axis to the right of the origin (x > 0).
Definition at line 719 of file qline.cpp.
Referenced by adapted_angle_on_x(), QPainterPath::angleAtPercent(), angleTo(), and QDeclarativePinchArea::updatePinch().
Returns the angle (in degrees) between this line and the given line, taking the direction of the lines into account.
If the lines do not intersect within their range, it is the intersection point of the extended lines that serves as origin (see QLineF::UnboundedIntersection).
When the lines are parallel, this function returns 0 if they have the same direction; otherwise it returns 180.
Definition at line 993 of file qline.cpp.
Returns the angle (in positive degrees) from this line to the given line, taking the direction of the lines into account.
If the lines do not intersect within their range, it is the intersection point of the extended lines that serves as origin (see QLineF::UnboundedIntersection).
The returned value represents the number of degrees you need to add to this line to make it have the same angle as the given line, going counter-clockwise.
Definition at line 951 of file qline.cpp.
|
inline |
Returns the horizontal component of the line's vector.
Return value is positive if x2() >= x1() and negative if x2() < x1().
Definition at line 324 of file qline.h.
Referenced by angle(), QStroker::joinPoints(), QBezier::midTangent(), normalVector(), qt_stroke_side(), setAngle(), and setLength().
|
inline |
Returns the vertical component of the line's vector.
Return value is positive if y2() >= y1() and negative if y2() < y1().
Definition at line 329 of file qline.h.
Referenced by adapted_angle_on_x(), angle(), QStroker::joinPoints(), QBezier::midTangent(), normalVector(), qt_stroke_side(), setAngle(), and setLength().
Returns a QLineF with the given length and angle.
The first point of the line will be on the origin.
Positive values for the angles mean counter-clockwise while negative values mean the clockwise direction. Zero degrees is at the 3 o'clock position.
Definition at line 774 of file qline.cpp.
QLineF::IntersectType QLineF::intersect | ( | const QLineF & | line, |
QPointF * | intersectionPoint | ||
) | const |
Returns a value indicating whether or not this line intersects with the given line.
The actual intersection point is extracted to intersectionPoint (if the pointer is valid). If the lines are parallel, the intersection point is undefined.
Definition at line 813 of file qline.cpp.
Referenced by QStroker::joinPoints().
bool QLineF::isNull | ( | ) | const |
Returns true if the line is not set up with valid start and end point; otherwise returns false.
Definition at line 517 of file qline.cpp.
Referenced by angle(), angleTo(), QBezier::endTangent(), setLength(), and QBezier::startTangent().
qreal QLineF::length | ( | ) | const |
Returns the length of the line.
Definition at line 698 of file qline.cpp.
Referenced by QBezier::addIfClose(), angle(), bezierAtT(), QStroker::joinPoints(), nextBezier(), QPainterPath::percentAtLength(), qt_radial_gradient_adapt_focal_point(), QRasterPaintEnginePrivate::rasterizeLine_dashed(), setAngle(), QRasterPaintEngine::stroke(), and unitVector().
|
inline |
Returns a line that is perpendicular to this line with the same starting point and length.
Definition at line 334 of file qline.h.
Referenced by qt_stroke_side(), and shift().
|
inline |
|
inline |
|
inline |
Returns the line's start point.
Definition at line 314 of file qline.h.
Referenced by _q_interpolate(), QPathSegments::addPath(), QCoreGraphicsPaintEngine::drawLines(), QVGPaintEngine::drawLines(), QOpenGLPaintEngine::drawLines(), QPaintEngine::drawLines(), QRasterPaintEngine::drawLines(), QIntersectionFinder::hasIntersections(), QStroker::joinPoints(), QIntersectionFinder::linesIntersect(), QMatrix::map(), normalVector(), operator<<(), operator<<(), qt_stroke_side(), QRasterPaintEnginePrivate::rasterizeLine_dashed(), QRasterPaintEngine::stroke(), and unitVector().
|
inline |
Returns the line's end point.
Definition at line 319 of file qline.h.
Referenced by _q_interpolate(), QPathSegments::addPath(), QCoreGraphicsPaintEngine::drawLines(), QVGPaintEngine::drawLines(), QOpenGLPaintEngine::drawLines(), QPaintEngine::drawLines(), QRasterPaintEngine::drawLines(), QIntersectionFinder::hasIntersections(), QStroker::joinPoints(), QIntersectionFinder::linesIntersect(), QMatrix::map(), operator<<(), operator<<(), qt_radial_gradient_adapt_focal_point(), qt_stroke_side(), QRasterPaintEnginePrivate::rasterizeLine_dashed(), shift(), and QRasterPaintEngine::stroke().
Returns the point at the parameterized position specified by t.
The function returns the line's start point if t = 0, and its end point if t = 1.
Definition at line 368 of file qline.h.
void QLineF::setAngle | ( | qreal | angle | ) |
Sets the angle of the line to the given angle (in degrees).
This will change the position of the second point of the line such that the line has the given angle.
Positive values for the angles mean counter-clockwise while negative values mean the clockwise direction. Zero degrees is at the 3 o'clock position.
Definition at line 749 of file qline.cpp.
|
inline |
Sets the length of the line to the given length.
QLineF will move the end point - p2() - of the line to give the line its new length. If the given length is negative the angle() is also changed.
If the line is a null line, the length will remain zero regardless of the length specified.
Definition at line 360 of file qline.h.
Referenced by QStroker::joinPoints(), qt_radial_gradient_adapt_focal_point(), qt_stroke_side(), and QRasterPaintEnginePrivate::rasterizeLine_dashed().
Sets this line to the start in x1, y1 and end in x2, y2.
Definition at line 397 of file qline.h.
|
inline |
Sets the starting point of this line to p1.
Definition at line 381 of file qline.h.
Referenced by QRasterPaintEnginePrivate::rasterizeLine_dashed().
|
inline |
Sets the end point of this line to p2.
|
inline |
Returns an integer based copy of this line.
Note that the returned line's start and end points are rounded to the nearest integer.
Definition at line 375 of file qline.h.
|
inline |
Translates this line by the given offset.
Definition at line 339 of file qline.h.
Referenced by QPainter::drawLines(), drawTextItemDecoration(), QStroker::joinPoints(), qt_stroke_side(), and translate().
Translates this line the distance specified by dx and dy.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 345 of file qline.h.
Returns this line translated by the given offset.
Definition at line 350 of file qline.h.
Referenced by translated().
Returns this line translated the distance specified by dx and dy.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 355 of file qline.h.
QLineF QLineF::unitVector | ( | ) | const |
Returns the unit vector for this line, i.e a line starting at the same point as this line with a length of 1.0.
Definition at line 786 of file qline.cpp.
Referenced by setLength(), and shift().
|
inline |
Returns the x-coordinate of the line's start point.
Definition at line 294 of file qline.h.
Referenced by clipLine(), QX11PaintEngine::drawLines(), QVGPaintEngine::drawLines(), QOpenGLPaintEngine::drawLines(), QStroker::joinPoints(), QTransform::map(), and qt_stroke_side().
|
inline |
Returns the x-coordinate of the line's end point.
Definition at line 304 of file qline.h.
Referenced by clipLine(), QX11PaintEngine::drawLines(), QVGPaintEngine::drawLines(), QOpenGLPaintEngine::drawLines(), QStroker::joinPoints(), QTransform::map(), and qt_stroke_side().
|
inline |
Returns the y-coordinate of the line's start point.
Definition at line 299 of file qline.h.
Referenced by clipLine(), QX11PaintEngine::drawLines(), QVGPaintEngine::drawLines(), QOpenGLPaintEngine::drawLines(), QStroker::joinPoints(), QTransform::map(), and qt_stroke_side().
|
inline |
Returns the y-coordinate of the line's end point.
Definition at line 309 of file qline.h.
Referenced by clipLine(), QX11PaintEngine::drawLines(), QVGPaintEngine::drawLines(), QOpenGLPaintEngine::drawLines(), QStroker::joinPoints(), QTransform::map(), and qt_stroke_side().
|
related |
Writes the given line to the given stream and returns a reference to the stream.
Definition at line 1026 of file qline.cpp.
Referenced by operator==().
|
related |
Reads a line from the given stream into the given line and returns a reference to the stream.
Definition at line 1044 of file qline.cpp.
Referenced by operator==().
|
private |
Definition at line 272 of file qline.h.
Referenced by angle(), dx(), dy(), intersect(), isNull(), length(), operator==(), p1(), pointAt(), setAngle(), setLength(), setLine(), setP1(), setPoints(), toLine(), translate(), translated(), unitVector(), x1(), and y1().
|
private |
Definition at line 272 of file qline.h.
Referenced by angle(), dx(), dy(), intersect(), isNull(), length(), operator==(), p2(), pointAt(), setAngle(), setLength(), setLine(), setP2(), setPoints(), toLine(), translate(), translated(), unitVector(), x2(), and y2().