42 #ifndef QPAINTERPATH_H 43 #define QPAINTERPATH_H 45 #include <QtGui/qmatrix.h> 46 #include <QtCore/qglobal.h> 47 #include <QtCore/qrect.h> 48 #include <QtCore/qline.h> 49 #include <QtCore/qvector.h> 50 #include <QtCore/qscopedpointer.h> 83 bool isMoveTo()
const {
return type == MoveToElement; }
84 bool isLineTo()
const {
return type == LineToElement; }
85 bool isCurveTo()
const {
return type == CurveToElement; }
98 #ifdef Q_COMPILER_RVALUE_REFS 125 QPointF currentPosition()
const;
127 void addRect(
const QRectF &rect);
129 void addEllipse(
const QRectF &rect);
132 void addPolygon(
const QPolygonF &polygon);
136 void addRegion(
const QRegion ®ion);
144 void addRoundRect(
const QRectF &rect,
int xRnd,
int yRnd);
147 inline void addRoundRect(
const QRectF &rect,
int roundness);
153 bool contains(
const QPointF &pt)
const;
154 bool contains(
const QRectF &rect)
const;
155 bool intersects(
const QRectF &rect)
const;
158 inline void translate(
const QPointF &offset);
164 QRectF controlPointRect()
const;
179 inline int elementCount()
const;
181 inline void setElementPositionAt(
int i,
qreal x,
qreal y);
183 qreal length()
const;
213 inline void ensureData() {
if (!d_ptr) ensureData_helper(); }
214 void ensureData_helper();
215 inline void detach();
216 void detach_helper();
218 void computeBoundingRect()
const;
219 void computeControlPointRect()
const;
231 #ifndef QT_NO_DATASTREAM 248 #ifndef QT_NO_DATASTREAM 259 #ifndef QT_NO_DATASTREAM 271 void setWidth(
qreal width);
280 void setMiterLimit(
qreal length);
281 qreal miterLimit()
const;
283 void setCurveThreshold(
qreal threshold);
284 qreal curveThreshold()
const;
290 void setDashOffset(
qreal offset);
291 qreal dashOffset()
const;
315 arcTo(
QRectF(x, y, w, h), startAngle, arcLength);
320 arcMoveTo(
QRectF(x, y, w, h), angle);
337 addEllipse(
QRectF(x, y, w, h));
342 addEllipse(
QRectF(center.
x() - rx, center.
y() - ry, 2 * rx, 2 * ry));
347 addRect(
QRectF(x, y, w, h));
354 addRoundedRect(
QRectF(x, y, w, h), xRadius, yRadius, mode);
360 addRoundRect(
QRectF(x, y, w, h), xRnd, yRnd);
366 int xRnd = roundness;
367 int yRnd = roundness;
369 xRnd =
int(roundness * rect.
height()/rect.
width());
371 yRnd = int(roundness * rect.
width()/rect.
height());
372 addRoundRect(rect, xRnd, yRnd);
378 addRoundRect(
QRectF(x, y, w, h), roundness);
383 addText(
QPointF(x, y), f, text);
387 { translate(offset.
x(), offset.
y()); }
390 {
return translated(offset.
x(), offset.
y()); }
394 return !d_ptr || (d_ptr->elements.size() == 1 && d_ptr->elements.first().type == MoveToElement);
399 return d_ptr ? d_ptr->elements.size() : 0;
405 Q_ASSERT(i >= 0 && i < elementCount());
406 return d_ptr->elements.at(i);
412 Q_ASSERT(i >= 0 && i < elementCount());
427 #ifndef QT_NO_DEBUG_STREAM 435 #endif // QPAINTERPATH_H ElementType type
the type of element
The QDebug class provides an output stream for debugging information.
The QPainterPath::Element class specifies the position and type of a subpath.
bool isEmpty() const
Returns true if either there are no elements in this path, or if the only element is a MoveToElement;...
ElementType
This enum describes the types of elements used to connect vertices in subpaths.
void addRoundRect(const QRectF &rect, int xRnd, int yRnd)
Adds a rectangle r with rounded corners to the path.
timeval operator-(const timeval &t1, const timeval &t2)
#define QT_END_NAMESPACE
This macro expands to.
void translate(qreal dx, qreal dy)
Translates all elements in the path by ({dx}, {dy}).
T * data() const
Returns the value of the pointer referenced by this object.
The QMatrix class specifies 2D transformations of a coordinate system.
The QAtomicInt class provides platform-independent atomic operations on integers. ...
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
void addRoundedRect(const QRectF &rect, qreal xRadius, qreal yRadius, Qt::SizeMode mode=Qt::AbsoluteSize)
Adds the given rectangle rect with rounded corners to the path.
The QPointF class defines a point in the plane using floating point precision.
bool isLineTo() const
Returns true if the element is a line, otherwise returns false.
static Q_DECL_CONSTEXPR bool qFuzzyCompare(double p1, double p2)
#define Q_DISABLE_COPY(Class)
Disables the use of copy constructors and assignment operators for the given Class.
bool operator!=(QBool b1, bool b2)
const QVectorPath & qtVectorPathForPath(const QPainterPath &path)
bool operator==(const Element &e) const
Returns true if this element is equal to other; otherwise returns false.
bool isCurveTo() const
Returns true if the element is a curve, otherwise returns false.
qreal y
the y coordinate of the element's position.
The QString class provides a Unicode character string.
void arcMoveTo(const QRectF &rect, qreal angle)
Creates a move to that lies on the arc that occupies the given rectangle at angle.
const QPainterPath::Element & elementAt(int i) const
Returns the element at the given index in the painter path.
qreal x() const
Returns the x-coordinate of this point.
static const QRectF boundingRect(const QPointF *points, int pointCount)
void lineTo(const QPointF &p)
Adds a straight line from the current position to the given endPoint.
void setElementPositionAt(int i, qreal x, qreal y)
Sets the x and y coordinate of the element at index index to x and y.
#define QT_BEGIN_NAMESPACE
This macro expands to.
The QRectF class defines a rectangle in the plane using floating point precision. ...
static bool isEmpty(const char *str)
QPainterPathData * d_func() const
void swap(QPainterPath &other)
Swaps painter path other with this painter path.
qreal height() const
Returns the height of the rectangle.
Q_DECLARE_TYPEINFO(QPainterPath::Element, Q_PRIMITIVE_TYPE)
The QPolygonF class provides a vector of points using floating point precision.
void addRect(const QRectF &rect)
Adds the given rectangle to this path as a closed subpath.
bool operator!=(const Element &e) const
Returns true if this element is not equal to other; otherwise returns false.
qreal width() const
Returns the width of the rectangle.
The QRegion class specifies a clip region for a painter.
The QPainterPathStroker class is used to generate fillable outlines for a given painter path...
void qSwap(T &value1, T &value2)
Q_CORE_EXPORT QTextStream & center(QTextStream &s)
Q_GUI_EXPORT QDataStream & operator<<(QDataStream &, const QPainterPath &)
qreal angle(const QPointF &p1, const QPointF &p2)
Q_GUI_EXPORT QDataStream & operator>>(QDataStream &, QPainterPath &)
The QFont class specifies a font used for drawing text.
Q_CORE_EXPORT QBitArray operator &(const QBitArray &, const QBitArray &)
void arcTo(const QRectF &rect, qreal startAngle, qreal arcLength)
Creates an arc that occupies the given rectangle, beginning at the specified startAngle and extending...
void addText(const QPointF &point, const QFont &f, const QString &text)
Adds the given text to this path as a set of closed subpaths created from the font supplied...
bool isMoveTo() const
Returns true if the element is moving the current position, otherwise returns false.
QVector< QPainterPath::Element > elements
void quadTo(const QPointF &ctrlPt, const QPointF &endPt)
Adds a quadratic Bezier curve between the current position and the given endPoint with the control po...
qreal x
the x coordinate of the element's position.
qreal y() const
Returns the y-coordinate of this point.
void cubicTo(const QPointF &ctrlPt1, const QPointF &ctrlPt2, const QPointF &endPt)
Adds a cubic Bezier curve between the current position and the given endPoint using the control point...
#define Q_DECLARE_PRIVATE(Class)
int elementCount() const
Returns the number of path elements in the painter path.
static void setCapStyle(int cap_style, GC gc)
The QDataStream class provides serialization of binary data to a QIODevice.
Q_CORE_EXPORT QBitArray operator|(const QBitArray &, const QBitArray &)
timeval & operator+=(timeval &t1, const timeval &t2)
bool operator==(QBool b1, bool b2)
void addEllipse(const QRectF &rect)
Creates an ellipse within the specified boundingRectangle and adds it to the painter path as a closed...
QScopedPointer< QPainterPathPrivate, QPainterPathPrivateDeleter > d_ptr
The QList class is a template class that provides lists.
QPainterPath translated(qreal dx, qreal dy) const
Returns a copy of the path that is translated by ({dx}, {dy}).
timeval operator+(const timeval &t1, const timeval &t2)