Qt 4.8
|
The QPolygonF class provides a vector of points using floating point precision. More...
#include <qpolygon.h>
Public Functions | |
QRectF | boundingRect () const |
Returns the bounding rectangle of the polygon, or QRectF(0,0,0,0) if the polygon is empty. More... | |
bool | containsPoint (const QPointF &pt, Qt::FillRule fillRule) const |
Returns true if the given point is inside the polygon according to the specified fillRule; otherwise returns false. More... | |
QPolygonF | intersected (const QPolygonF &r) const |
Returns a polygon which is the intersection of this polygon and r. More... | |
bool | isClosed () const |
Returns true if the polygon is closed; otherwise returns false. More... | |
QPolygonF () | |
Constructs a polygon with no points. More... | |
QPolygonF (int size) | |
Constructs a polygon of the given size. More... | |
QPolygonF (const QPolygonF &a) | |
Constructs a copy of the given polygon. More... | |
QPolygonF (const QVector< QPointF > &v) | |
Constructs a polygon containing the specified points. More... | |
QPolygonF (const QRectF &r) | |
Constructs a closed polygon from the specified rectangle. More... | |
QPolygonF (const QPolygon &a) | |
Constructs a float based polygon from the specified integer based polygon. More... | |
QPolygonF | subtracted (const QPolygonF &r) const |
Returns a polygon which is r subtracted from this polygon. More... | |
void | swap (QPolygonF &other) |
Swaps polygon other with this polygon. More... | |
QPolygon | toPolygon () const |
Creates and returns a QPolygon by converting each QPointF to a QPoint. More... | |
void | translate (qreal dx, qreal dy) |
Translates all points in the polygon by ({dx}, {dy}). More... | |
void | translate (const QPointF &offset) |
Translate all points in the polygon by the given offset. More... | |
QPolygonF | translated (qreal dx, qreal dy) const |
Returns a copy of the polygon that is translated by ({dx}, {dy}). More... | |
QPolygonF | translated (const QPointF &offset) const |
Returns a copy of the polygon that is translated by the given offset. More... | |
QPolygonF | united (const QPolygonF &r) const |
Returns a polygon which is the union of this polygon and r. More... | |
~QPolygonF () | |
Destroys the polygon. More... | |
Public Functions inherited from QVector< QPointF > | |
void | append (const QPointF &t) |
Inserts value at the end of the vector. More... | |
const QPointF & | at (int i) const |
Returns the item at index position i in the vector. More... | |
reference | back () |
This function is provided for STL compatibility. More... | |
const_reference | back () const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
iterator | begin () |
Returns an STL-style iterator pointing to the first item in the vector. More... | |
const_iterator | begin () const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
int | capacity () const |
Returns the maximum number of items that can be stored in the vector without forcing a reallocation. More... | |
void | clear () |
Removes all the elements from the vector and releases the memory used by the vector. More... | |
const_iterator | constBegin () const |
Returns a const STL-style iterator pointing to the first item in the vector. More... | |
const QPointF * | constData () const |
Returns a const pointer to the data stored in the vector. More... | |
const_iterator | constEnd () const |
Returns a const STL-style iterator pointing to the imaginary item after the last item in the vector. More... | |
bool | contains (const QPointF &t) const |
Returns true if the vector contains an occurrence of value; otherwise returns false. More... | |
int | count (const QPointF &t) const |
Returns the number of occurrences of value in the vector. More... | |
int | count () const |
Same as size(). More... | |
QPointF * | data () |
Returns a pointer to the data stored in the vector. More... | |
const QPointF * | data () const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
void | detach () |
bool | empty () const |
This function is provided for STL compatibility. More... | |
iterator | end () |
Returns an STL-style iterator pointing to the imaginary item after the last item in the vector. More... | |
const_iterator | end () const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
bool | endsWith (const QPointF &t) const |
Returns true if this vector is not empty and its last item is equal to value; otherwise returns false. More... | |
iterator | erase (iterator begin, iterator end) |
Removes all the items from begin up to (but not including) end. More... | |
iterator | erase (iterator pos) |
Removes the item pointed to by the iterator pos from the vector, and returns an iterator to the next item in the vector (which may be end()). More... | |
QVector< QPointF > & | fill (const QPointF &t, int size=-1) |
Assigns value to all items in the vector. More... | |
QPointF & | first () |
Returns a reference to the first item in the vector. More... | |
const QPointF & | first () const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
QPointF & | front () |
This function is provided for STL compatibility. More... | |
const_reference | front () const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
int | indexOf (const QPointF &t, int from=0) const |
Returns the index position of the first occurrence of value in the vector, searching forward from index position from. More... | |
void | insert (int i, const QPointF &t) |
Inserts value at index position i in the vector. More... | |
void | insert (int i, int n, const QPointF &t) |
Inserts count copies of value at index position i in the vector. More... | |
iterator | insert (iterator before, int n, const QPointF &x) |
Inserts count copies of value in front of the item pointed to by the iterator before. More... | |
iterator | insert (iterator before, const QPointF &x) |
Inserts value in front of the item pointed to by the iterator before. More... | |
bool | isDetached () const |
bool | isEmpty () const |
Returns true if the vector has size 0; otherwise returns false. More... | |
bool | isSharedWith (const QVector< QPointF > &other) const |
QPointF & | last () |
Returns a reference to the last item in the vector. More... | |
const QPointF & | last () const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
int | lastIndexOf (const QPointF &t, int from=-1) const |
Returns the index position of the last occurrence of the value value in the vector, searching backward from index position from. More... | |
QVector< QPointF > | mid (int pos, int length=-1) const |
Returns a vector whose elements are copied from this vector, starting at position pos. More... | |
bool | operator!= (const QVector< QPointF > &v) const |
Returns true if other is not equal to this vector; otherwise returns false. More... | |
QVector< QPointF > | operator+ (const QVector< QPointF > &l) const |
Returns a vector that contains all the items in this vector followed by all the items in the other vector. More... | |
QVector< QPointF > & | operator+= (const QVector< QPointF > &l) |
Appends the items of the other vector to this vector and returns a reference to this vector. More... | |
QVector< QPointF > & | operator+= (const QPointF &t) |
Appends value to the vector. More... | |
QVector< QPointF > & | operator<< (const QVector< QPointF > &l) |
Appends other to the vector and returns a reference to the vector. More... | |
QVector< QPointF > & | operator<< (const QPointF &t) |
Appends value to the vector and returns a reference to this vector. More... | |
QVector< QPointF > & | operator= (const QVector< QPointF > &v) |
Assigns other to this vector and returns a reference to this vector. More... | |
bool | operator== (const QVector< QPointF > &v) const |
Returns true if other is equal to this vector; otherwise returns false. More... | |
QPointF & | operator[] (int i) |
Returns the item at index position i as a modifiable reference. More... | |
const QPointF & | operator[] (int i) const |
Same as at(i). More... | |
void | pop_back () |
This function is provided for STL compatibility. More... | |
void | pop_front () |
This function is provided for STL compatibility. More... | |
void | prepend (const QPointF &t) |
Inserts value at the beginning of the vector. More... | |
void | push_back (const QPointF &t) |
This function is provided for STL compatibility. More... | |
void | push_front (const QPointF &t) |
This function is provided for STL compatibility. More... | |
QVector () | |
Constructs an empty vector. More... | |
QVector (int size) | |
Constructs a vector with an initial size of size elements. More... | |
QVector (int size, const QPointF &t) | |
Constructs a vector with an initial size of size elements. More... | |
QVector (const QVector< QPointF > &v) | |
Constructs a copy of other. More... | |
void | remove (int i) |
Removes the element at index position i. More... | |
void | remove (int i, int n) |
Removes count elements from the middle of the vector, starting at index position i. More... | |
void | replace (int i, const QPointF &t) |
Replaces the item at index position i with value. More... | |
void | reserve (int size) |
Attempts to allocate memory for at least size elements. More... | |
void | resize (int size) |
Sets the size of the vector to size. More... | |
void | setSharable (bool sharable) |
int | size () const |
Returns the number of items in the vector. More... | |
void | squeeze () |
Releases any memory not required to store the items. More... | |
bool | startsWith (const QPointF &t) const |
Returns true if this vector is not empty and its first item is equal to value; otherwise returns false. More... | |
void | swap (QVector< QPointF > &other) |
Swaps vector other with this vector. More... | |
QList< QPointF > | toList () const |
Returns a QList object with the data contained in this QVector. More... | |
std::vector< QPointF > | toStdVector () const |
Returns a std::vector object with the data contained in this QVector. More... | |
QPointF | value (int i) const |
Returns the value at index position i in the vector. More... | |
QPointF | value (int i, const QPointF &defaultValue) const |
If the index i is out of bounds, the function returns defaultValue. More... | |
~QVector () | |
Destroys the vector. More... | |
Related Functions | |
(Note that these are not member functions.) | |
QDataStream & | operator<< (QDataStream &stream, const QPolygonF &polygon) |
Writes the given polygon to the given stream, and returns a reference to the stream. More... | |
QDataStream & | operator>> (QDataStream &stream, QPolygonF &polygon) |
Reads a polygon from the given stream into the given polygon, and returns a reference to the stream. More... | |
Related Functions inherited from QVector< QPointF > | |
QDataStream & | operator<< (QDataStream &out, const QVector< QPointF > &vector) |
Writes the vector vector to stream out. More... | |
QDataStream & | operator>> (QDataStream &in, QVector< QPointF > &vector) |
Reads a vector from stream in into vector. More... | |
Additional Inherited Members | |
Public Types inherited from QVector< QPointF > | |
typedef const QPointF * | const_iterator |
The QVector::const_iterator typedef provides an STL-style const iterator for QVector and QStack. More... | |
typedef const value_type * | const_pointer |
Typedef for const T *. More... | |
typedef const value_type & | const_reference |
Typedef for T &. More... | |
typedef const_iterator | ConstIterator |
Qt-style synonym for QVector::const_iterator. More... | |
typedef qptrdiff | difference_type |
Typedef for ptrdiff_t. More... | |
typedef QPointF * | iterator |
The QVector::iterator typedef provides an STL-style non-const iterator for QVector and QStack. More... | |
typedef iterator | Iterator |
Qt-style synonym for QVector::iterator. More... | |
typedef value_type * | pointer |
Typedef for T *. More... | |
typedef value_type & | reference |
Typedef for T &. More... | |
typedef int | size_type |
Typedef for int. More... | |
typedef QPointF | value_type |
Typedef for T. More... | |
Static Public Functions inherited from QVector< QPointF > | |
static QVector< QPointF > | fromList (const QList< QPointF > &list) |
Returns a QVector object with the data contained in list. More... | |
static QVector< QPointF > | fromStdVector (const std::vector< QPointF > &vector) |
Returns a QVector object with the data contained in vector. More... | |
Public Variables inherited from QVector< QPointF > | |
QVectorData * | d |
Data * | p |
The QPolygonF class provides a vector of points using floating point precision.
A QPolygonF is a QVector<QPointF>. The easiest way to add points to a QPolygonF is to use its streaming operator, as illustrated below:
In addition to the functions provided by QVector, QPolygonF provides the boundingRect() and translate() functions for geometry operations. Use the QMatrix::map() function for more general transformations of QPolygonFs.
QPolygonF also provides the isClosed() function to determine whether a polygon's start and end points are the same, and the toPolygon() function returning an integer precision copy of this polygon.
The QPolygonF class is Implicit Data Sharing.
Definition at line 134 of file qpolygon.h.
|
inline |
Constructs a polygon with no points.
Definition at line 137 of file qpolygon.h.
|
inline |
|
inline |
Constructs a polygon of the given size.
Creates an empty polygon if size == 0.
Definition at line 165 of file qpolygon.h.
|
inline |
QPolygonF::QPolygonF | ( | const QRectF & | rectangle | ) |
Constructs a closed polygon from the specified rectangle.
The polygon contains the four vertices of the rectangle in clockwise order starting and ending with the top-left vertex.
Definition at line 626 of file qpolygon.cpp.
QPolygonF::QPolygonF | ( | const QPolygon & | polygon | ) |
Constructs a float based polygon from the specified integer based polygon.
Definition at line 648 of file qpolygon.cpp.
QRectF QPolygonF::boundingRect | ( | ) | const |
Returns the bounding rectangle of the polygon, or QRectF(0,0,0,0) if the polygon is empty.
Definition at line 742 of file qpolygon.cpp.
Referenced by QGLPathMaskGenerator::computeScreenRect(), QPicturePaintEngine::drawPolygon(), QGraphicsSceneIndex::items(), QMacPixmapData::macCreatePixels(), QGraphicsViewPrivate::mapToScene(), QAccessibleDial::rect(), QGraphicsView::render(), QPainterPath::toFillPolygons(), QX11PixmapData::transformed(), and QImage::transformed().
bool QPolygonF::containsPoint | ( | const QPointF & | point, |
Qt::FillRule | fillRule | ||
) | const |
Returns true if the given point is inside the polygon according to the specified fillRule; otherwise returns false.
Definition at line 940 of file qpolygon.cpp.
Returns a polygon which is the intersection of this polygon and r.
Set operations on polygons will treat the polygons as areas. Non-closed polygons will be treated as implicitly closed.
Definition at line 1096 of file qpolygon.cpp.
|
inline |
Returns true if the polygon is closed; otherwise returns false.
A polygon is said to be closed if its start point and end point are equal.
Definition at line 154 of file qpolygon.h.
Referenced by QPainterPath::toFillPolygon(), and QPainterPath::toFillPolygons().
Returns a polygon which is r subtracted from this polygon.
Set operations on polygons will treat the polygons as areas. Non-closed polygons will be treated as implicitly closed.
Definition at line 1117 of file qpolygon.cpp.
|
inline |
Swaps polygon other with this polygon.
This operation is very fast and never fails.
Definition at line 144 of file qpolygon.h.
QPolygon QPolygonF::toPolygon | ( | ) | const |
Creates and returns a QPolygon by converting each QPointF to a QPoint.
Definition at line 772 of file qpolygon.cpp.
Referenced by QOpenGLPaintEngine::clip(), clipTransformIsSimple(), QPolygon::intersected(), QMatrix::map(), QTransform::map(), QPolygon::subtracted(), QX11PaintEnginePrivate::systemStateChanged(), QPolygon::united(), QCoreGraphicsPaintEngine::updateClipPath(), QX11PaintEngine::updateState(), and QOpenGLPaintEngine::updateState().
Translates all points in the polygon by ({dx}, {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 179 of file qpolygon.h.
Referenced by translated().
void QPolygonF::translate | ( | const QPointF & | offset | ) |
Translate all points in the polygon by the given offset.
Definition at line 671 of file qpolygon.cpp.
Returns a copy of the polygon that is translated by ({dx}, {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 182 of file qpolygon.h.
Referenced by QTransform::map(), QGraphicsItem::mapFromParent(), QGraphicsItem::mapFromScene(), QGraphicsItem::mapToParent(), and QGraphicsItem::mapToScene().
Returns a copy of the polygon that is translated by the given offset.
Definition at line 702 of file qpolygon.cpp.
Returns a polygon which is the union of this polygon and r.
Set operations on polygons will treat the polygons as areas. Non-closed polygons will be treated as implicitly closed.
Definition at line 1075 of file qpolygon.cpp.
|
related |
Writes the given polygon to the given stream, and returns a reference to the stream.
Definition at line 871 of file qpolygon.cpp.
Referenced by QPolygonF().
|
related |
Reads a polygon from the given stream into the given polygon, and returns a reference to the stream.
Definition at line 895 of file qpolygon.cpp.
Referenced by QPolygonF().