![]() |
Qt 6.x
The Qt SDK
|
\inmodule QtGui More...
#include <qpainterpath.h>
Classes | |
class | Element |
\inmodule QtGui More... | |
Public Types | |
enum | ElementType { MoveToElement , LineToElement , CurveToElement , CurveToDataElement } |
This enum describes the types of elements used to connect vertices in subpaths. More... | |
Public Member Functions | |
QPainterPath () noexcept | |
Constructs an empty QPainterPath object. | |
QPainterPath (const QPointF &startPoint) | |
Creates a QPainterPath object with the given startPoint as its current position. | |
QPainterPath (const QPainterPath &other) | |
Creates a QPainterPath object that is a copy of the given path. | |
QPainterPath & | operator= (const QPainterPath &other) |
Assigns the given path to this painter path. | |
~QPainterPath () | |
Destroys this QPainterPath object. | |
void | swap (QPainterPath &other) noexcept |
void | clear () |
Clears the path elements stored. | |
void | reserve (int size) |
Reserves a given amount of elements in QPainterPath's internal memory. | |
int | capacity () const |
Returns the number of elements allocated by the QPainterPath. | |
void | closeSubpath () |
Closes the current subpath by drawing a line to the beginning of the subpath, automatically starting a new path. | |
void | moveTo (const QPointF &p) |
Moves the current point to the given point, implicitly starting a new subpath and closing the previous one. | |
void | moveTo (qreal x, qreal y) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Moves the current position to ({x}, {y}) and starts a new subpath, implicitly closing the previous path. | |
void | lineTo (const QPointF &p) |
Adds a straight line from the current position to the given endPoint. | |
void | lineTo (qreal x, qreal y) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Draws a line from the current position to the point ({x}, {y}). | |
void | arcMoveTo (const QRectF &rect, qreal angle) |
void | arcMoveTo (qreal x, qreal y, qreal w, qreal h, qreal angle) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
void | arcTo (const QRectF &rect, qreal startAngle, qreal arcLength) |
Creates an arc that occupies the given rectangle, beginning at the specified startAngle and extending sweepLength degrees counter-clockwise. | |
void | arcTo (qreal x, qreal y, qreal w, qreal h, qreal startAngle, qreal arcLength) |
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 points specified by c1, and c2. | |
void | cubicTo (qreal ctrlPt1x, qreal ctrlPt1y, qreal ctrlPt2x, qreal ctrlPt2y, qreal endPtx, qreal endPty) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Adds a cubic Bezier curve between the current position and the end point ({endPointX}, {endPointY}) with control points specified by ({c1X}, {c1Y}) and ({c2X}, {c2Y}). | |
void | quadTo (const QPointF &ctrlPt, const QPointF &endPt) |
Adds a quadratic Bezier curve between the current position and the given endPoint with the control point specified by c. | |
void | quadTo (qreal ctrlPtx, qreal ctrlPty, qreal endPtx, qreal endPty) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Adds a quadratic Bezier curve between the current point and the endpoint ({endPointX}, {endPointY}) with the control point specified by ({cx}, {cy}). | |
QPointF | currentPosition () const |
Returns the current position of the path. | |
void | addRect (const QRectF &rect) |
Adds the given rectangle to this path as a closed subpath. | |
void | addRect (qreal x, qreal y, qreal w, qreal h) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Adds a rectangle at position ({x}, {y}), with the given width and height, as a closed subpath. | |
void | addEllipse (const QRectF &rect) |
Creates an ellipse within the specified boundingRectangle and adds it to the painter path as a closed subpath. | |
void | addEllipse (qreal x, qreal y, qreal w, qreal h) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Creates an ellipse within the bounding rectangle defined by its top-left corner at (x, y), width and height, and adds it to the painter path as a closed subpath. | |
void | addEllipse (const QPointF ¢er, qreal rx, qreal ry) |
void | addPolygon (const QPolygonF &polygon) |
Adds the given polygon to the path as an (unclosed) subpath. | |
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. | |
void | addText (qreal x, qreal y, const QFont &f, const QString &text) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Adds the given text to this path as a set of closed subpaths created from the font supplied. | |
void | addPath (const QPainterPath &path) |
Adds the given path to this path as a closed subpath. | |
void | addRegion (const QRegion ®ion) |
Adds the given region to the path by adding each rectangle in the region as a separate closed subpath. | |
void | addRoundedRect (const QRectF &rect, qreal xRadius, qreal yRadius, Qt::SizeMode mode=Qt::AbsoluteSize) |
void | addRoundedRect (qreal x, qreal y, qreal w, qreal h, qreal xRadius, qreal yRadius, Qt::SizeMode mode=Qt::AbsoluteSize) |
void | connectPath (const QPainterPath &path) |
Connects the given path to this path by adding a line from the last element of this path to the first element of the given path. | |
bool | contains (const QPointF &pt) const |
Returns true if the given point is inside the path, otherwise returns false . | |
bool | contains (const QRectF &rect) const |
Returns true if the given rectangle is inside the path, otherwise returns false . | |
bool | intersects (const QRectF &rect) const |
Returns true if any point in the given rectangle intersects the path; otherwise returns false . | |
void | translate (qreal dx, qreal dy) |
Translates all elements in the path by ({dx}, {dy}). | |
void | translate (const QPointF &offset) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
QPainterPath | translated (qreal dx, qreal dy) const |
Returns a copy of the path that is translated by ({dx}, {dy}). | |
QPainterPath | translated (const QPointF &offset) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
QRectF | boundingRect () const |
Returns the bounding rectangle of this painter path as a rectangle with floating point precision. | |
QRectF | controlPointRect () const |
Returns the rectangle containing all the points and control points in this path. | |
Qt::FillRule | fillRule () const |
Returns the painter path's currently set fill rule. | |
void | setFillRule (Qt::FillRule fillRule) |
Sets the fill rule of the painter path to the given fillRule. | |
bool | isEmpty () const |
Returns true if either there are no elements in this path, or if the only element is a MoveToElement; otherwise returns false . | |
QPainterPath | toReversed () const |
Creates and returns a reversed copy of the path. | |
QList< QPolygonF > | toSubpathPolygons (const QTransform &matrix=QTransform()) const |
Converts the path into a list of polygons using the QTransform matrix, and returns the list. | |
QList< QPolygonF > | toFillPolygons (const QTransform &matrix=QTransform()) const |
Converts the path into a list of polygons using the QTransform matrix, and returns the list. | |
QPolygonF | toFillPolygon (const QTransform &matrix=QTransform()) const |
Converts the path into a polygon using the QTransform matrix, and returns the polygon. | |
int | elementCount () const |
Returns the number of path elements in the painter path. | |
QPainterPath::Element | elementAt (int i) const |
Returns the element at the given index in the painter path. | |
void | setElementPositionAt (int i, qreal x, qreal y) |
qreal | length () const |
Returns the length of the current path. | |
qreal | percentAtLength (qreal t) const |
Returns percentage of the whole path at the specified length len. | |
QPointF | pointAtPercent (qreal t) const |
Returns the point at at the percentage t of the current path. | |
qreal | angleAtPercent (qreal t) const |
Returns the angle of the path tangent at the percentage t. | |
qreal | slopeAtPercent (qreal t) const |
Returns the slope of the path at the percentage t. | |
bool | intersects (const QPainterPath &p) const |
bool | contains (const QPainterPath &p) const |
QPainterPath | united (const QPainterPath &r) const |
QPainterPath | intersected (const QPainterPath &r) const |
QPainterPath | subtracted (const QPainterPath &r) const |
QPainterPath | simplified () const |
bool | operator== (const QPainterPath &other) const |
Returns true if this painterpath is equal to the given path. | |
bool | operator!= (const QPainterPath &other) const |
Returns true if this painter path differs from the given path. | |
QPainterPath | operator& (const QPainterPath &other) const |
QPainterPath | operator| (const QPainterPath &other) const |
QPainterPath | operator+ (const QPainterPath &other) const |
QPainterPath | operator- (const QPainterPath &other) const |
QPainterPath & | operator&= (const QPainterPath &other) |
QPainterPath & | operator|= (const QPainterPath &other) |
QPainterPath & | operator+= (const QPainterPath &other) |
QPainterPath & | operator-= (const QPainterPath &other) |
Friends | |
class | QPainterPathStroker |
class | QPainterPathStrokerPrivate |
class | QTransform |
class | QVectorPath |
Q_GUI_EXPORT const QVectorPath & | qtVectorPathForPath (const QPainterPath &) |
Q_GUI_EXPORT QDataStream & | operator<< (QDataStream &, const QPainterPath &) |
Writes the given painter path to the given stream, and returns a reference to the stream. | |
Q_GUI_EXPORT QDataStream & | operator>> (QDataStream &, QPainterPath &) |
Reads a painter path from the given stream into the specified path, and returns a reference to the stream. | |
Related Symbols | |
(Note that these are not member symbols.) | |
QDataStream & | operator<< (QDataStream &stream, const QPainterPath &path) |
Writes the given painter path to the given stream, and returns a reference to the stream. | |
QDataStream & | operator>> (QDataStream &stream, QPainterPath &path) |
Reads a painter path from the given stream into the specified path, and returns a reference to the stream. | |
\inmodule QtGui
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be constructed and reused.
A painter path is an object composed of a number of graphical building blocks, such as rectangles, ellipses, lines, and curves. Building blocks can be joined in closed subpaths, for example as a rectangle or an ellipse. A closed path has coinciding start and end points. Or they can exist independently as unclosed subpaths, such as lines and curves.
A QPainterPath object can be used for filling, outlining, and clipping. To generate fillable outlines for a given painter path, use the QPainterPathStroker class. The main advantage of painter paths over normal drawing operations is that complex shapes only need to be created once; then they can be drawn many times using only calls to the QPainter::drawPath() function.
QPainterPath provides a collection of functions that can be used to obtain information about the path and its elements. In addition it is possible to reverse the order of the elements using the toReversed() function. There are also several functions to convert this painter path object into a polygon representation.
Definition at line 28 of file qpainterpath.h.
This enum describes the types of elements used to connect vertices in subpaths.
Note that elements added as closed subpaths using the addEllipse(), addPath(), addPolygon(), addRect(), addRegion() and addText() convenience functions, is actually added to the path as a collection of separate elements using the moveTo(), lineTo() and cubicTo() functions.
\value MoveToElement A new subpath. See also moveTo(). \value LineToElement A line. See also lineTo(). \value CurveToElement A curve. See also cubicTo() and quadTo(). \value CurveToDataElement The extra data required to describe a curve in a CurveToElement element.
Enumerator | |
---|---|
MoveToElement | |
LineToElement | |
CurveToElement | |
CurveToDataElement |
Definition at line 31 of file qpainterpath.h.
|
noexcept |
Constructs an empty QPainterPath object.
Definition at line 500 of file qpainterpath.cpp.
Referenced by intersected(), and simplified().
|
explicit |
Creates a QPainterPath object with the given startPoint as its current position.
Definition at line 519 of file qpainterpath.cpp.
References e, MoveToElement, QPointF::x(), and QPointF::y().
|
default |
Creates a QPainterPath object that is a copy of the given path.
QPainterPath::~QPainterPath | ( | ) |
Destroys this QPainterPath object.
Definition at line 578 of file qpainterpath.cpp.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Creates an ellipse positioned at {center} with radii {rx} and {ry}, and adds it to the painter path as a closed subpath.
Definition at line 272 of file qpainterpath.h.
Creates an ellipse within the specified boundingRectangle and adds it to the painter path as a closed subpath.
The ellipse is composed of a clockwise curve, starting and finishing at zero degrees (the 3 o'clock position).
\table 100% \row
Definition at line 1099 of file qpainterpath.cpp.
References boundingRect(), cubicTo(), hasValidCoords(), QRectF::isNull(), moveTo(), qt_curves_for_arc(), qWarning, and QList< T >::size().
Referenced by QMacStylePrivate::drawFocusRing(), QQC2::QWindowsStyle::drawPrimitive(), and src_gui_painting_qpainterpath::Wrapper::wrapper5().
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Creates an ellipse within the bounding rectangle defined by its top-left corner at (x, y), width and height, and adds it to the painter path as a closed subpath.
Definition at line 267 of file qpainterpath.h.
void QPainterPath::addPath | ( | const QPainterPath & | path | ) |
Adds the given path to this path as a closed subpath.
Definition at line 1225 of file qpainterpath.cpp.
References d, MoveToElement, and other().
Referenced by QPathClipper::clip(), QMacStylePrivate::drawFocusRing(), and qt_graphicsItem_shapeFromPath().
Adds the given polygon to the path as an (unclosed) subpath.
Note that the current position after the polygon has been added, is the last point in polygon. To draw a line back to the first point, use the closeSubpath() function.
\table 100% \row
Definition at line 1065 of file qpainterpath.cpp.
References i, LineToElement, and moveTo().
Referenced by QPolygon::intersected(), QPolygonF::intersected(), QPolygon::intersects(), QPolygonF::intersects(), QPolygon::subtracted(), QPolygonF::subtracted(), QPolygon::united(), QPolygonF::united(), and src_gui_painting_qpainterpath::Wrapper::wrapper4().
Adds the given rectangle to this path as a closed subpath.
The rectangle is added as a clockwise set of lines. The painter path's current position after the rectangle has been added is at the top-left corner of the rectangle.
\table 100% \row
Definition at line 1019 of file qpainterpath.cpp.
References hasValidCoords(), LineToElement, moveTo(), qWarning, QList< T >::size(), and QPainterPath::Element::x.
Referenced by QGraphicsTextItemPrivate::_q_mouseOnEdge(), addRegion(), addRoundedRect(), addSelectedRegionsToPath(), addText(), QPathClipper::clip(), QOutlineMapper::clipElements(), QGraphicsItem::clipPath(), QGraphicsItem::collidesWithPath(), QTextLayout::draw(), QMacStylePrivate::drawFocusRing(), QPainter::drawRects(), QPainter::drawRects(), QX11PaintEnginePrivate::fillPath(), QtPrivate::intersect_point(), QtPrivate::intersect_rect(), QGraphicsSceneIndexPrivate::itemCollidesWithPath(), QGraphicsWidget::paintWindowFrame(), QGraphicsPixmapItemPrivate::updateShape(), and src_gui_painting_qpainterpath::Wrapper::wrapper3().
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Adds a rectangle at position ({x}, {y}), with the given width and height, as a closed subpath.
Definition at line 277 of file qpainterpath.h.
References addRect().
Adds the given region to the path by adding each rectangle in the region as a separate closed subpath.
Definition at line 1294 of file qpainterpath.cpp.
References addRect(), and rect.
void QPainterPath::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 xRadius and yRadius arguments specify the radii of the ellipses defining the corners of the rounded rectangle. When mode is Qt::RelativeSize, xRadius and yRadius are specified in percentage of half the rectangle's width and height respectively, and should be in the range 0.0 to 100.0.
Definition at line 3112 of file qpainterpath.cpp.
References Qt::AbsoluteSize, addRect(), arcMoveTo(), arcTo(), closeSubpath(), qMin(), rect, and QList< T >::size().
Referenced by QMacStylePrivate::drawFocusRing(), and QtWaylandClient::QWaylandBradientDecoration::paint().
|
inline |
Adds the given rectangle x, y, w, h with rounded corners to the path.
Definition at line 282 of file qpainterpath.h.
Adds the given text to this path as a set of closed subpaths created from the font supplied.
The subpaths are positioned so that the left end of the text's baseline lies at the specified point.
Some fonts may yield overlapping subpaths and will require the Qt::WindingFill
fill rule for correct rendering.
\table 100% \row
Definition at line 1151 of file qpainterpath.cpp.
References QFontEngine::addOutlineToPath(), addRect(), QScriptItem::analysis, QFontEngine::ascent(), QList< T >::at(), QScriptAnalysis::bidiLevel, QTextEngine::bidiReorder(), QVarLengthArray< T, Prealloc >::data(), QScriptAnalysis::flags, QTextEngine::fontEngine(), i, QString::isEmpty(), item, QTextEngine::LayoutData::items, layout, QTextEngine::layoutData, QScriptLine::length, line, QTextEngine::lines, QFontEngine::lineThickness(), opt, pos, Q_ASSERT, Q_UNUSED, QTextItem::RightToLeft, QTextEngine::shapedGlyphs(), QList< T >::size(), QScriptAnalysis::TabOrObject, text, QFixed::toReal(), QFontEngine::underlinePosition(), QScriptItem::width, QPointF::x(), and QPointF::y().
Referenced by QQuickContext2D::createTextGlyphs(), and src_gui_painting_qpainterpath::Wrapper::wrapper6().
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Adds the given text to this path as a set of closed subpaths created from the font supplied.
The subpaths are positioned so that the left end of the text's baseline lies at the point specified by (x, y).
Definition at line 289 of file qpainterpath.h.
References addText(), and text.
Returns the angle of the path tangent at the percentage t.
The argument t has to be between 0 and 1.
Positive values for the angles mean counter-clockwise while negative values mean the clockwise direction. Zero degrees is at the 3 o'clock position.
Note that similarly to the other percent methods, the percentage measurement is not linear with regards to the length if curves are present in the path. When curves are present the percentage argument is mapped to the t parameter of the Bezier equations.
Definition at line 3034 of file qpainterpath.cpp.
References QLineF::angle(), bezierAtT(), length(), qWarning, slopeAt(), QBezier::x1, QBezier::x2, QBezier::x3, QBezier::x4, QBezier::y1, QBezier::y2, QBezier::y3, and QBezier::y4.
Creates a move to that lies on the arc that occupies the given rectangle at angle.
Angles are specified in degrees. Clockwise arcs can be specified using negative angles.
Definition at line 966 of file qpainterpath.cpp.
References moveTo(), qt_find_ellipse_coords(), and rect.
Referenced by addRoundedRect().
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Creates a move to that lies on the arc that occupies the QRectF(x, y, width, height) at angle.
Definition at line 250 of file qpainterpath.h.
Creates an arc that occupies the given rectangle, beginning at the specified startAngle and extending sweepLength degrees counter-clockwise.
Angles are specified in degrees. Clockwise arcs can be specified using negative angles.
Note that this function connects the starting point of the arc to the current position if they are not already connected. After the arc has been added, the current position is the last point in arc. To draw a line back to the first point, use the closeSubpath() function.
\table 100% \row
Definition at line 909 of file qpainterpath.cpp.
References cubicTo(), hasValidCoords(), i, isValidCoord(), lineTo(), qt_curves_for_arc(), qWarning, and rect.
Referenced by addRoundedRect(), and src_gui_painting_qpainterpath::Wrapper::wrapper2().
|
inline |
Definition at line 245 of file qpainterpath.h.
QRectF QPainterPath::boundingRect | ( | ) | const |
Returns the bounding rectangle of this painter path as a rectangle with floating point precision.
Definition at line 1450 of file qpainterpath.cpp.
References d.
Referenced by QDistanceField::QDistanceField(), addEllipse(), boundsOnStroke(), QPathClipper::clip(), QPainterPrivate::draw_helper(), QSGDistanceFieldGlyphCache::glyphData(), operator==(), QGeoMapPolylineGeometry::updateSourcePoints(), and QGeoMapPolygonGeometry::updateSourcePoints().
int QPainterPath::capacity | ( | ) | const |
Returns the number of elements allocated by the QPainterPath.
Definition at line 624 of file qpainterpath.cpp.
References d.
void QPainterPath::clear | ( | ) |
Clears the path elements stored.
This allows the path to reuse previous memory allocations.
Definition at line 590 of file qpainterpath.cpp.
References QList< T >::append(), QPainterPathPrivate::clear(), and MoveToElement.
Referenced by QDeclarativeGeoMapItemUtils::projectBbox().
void QPainterPath::closeSubpath | ( | ) |
Closes the current subpath by drawing a line to the beginning of the subpath, automatically starting a new path.
The current point of the new path is (0, 0).
If the subpath does not contain any elements, this function does nothing.
Definition at line 644 of file qpainterpath.cpp.
References QPainterPathPrivate::close(), and isEmpty().
Referenced by addRoundedRect(), QQuickContext2D::clip(), convertCGPathToQPainterPath(), QPainter::drawConvexPolygon(), QPainter::drawConvexPolygon(), QPainter::drawPolygon(), QPainter::drawPolygon(), QDeclarativeGeoMapItemUtils::projectBbox(), and QGeoMapPolygonGeometry::updateSourcePoints().
void QPainterPath::connectPath | ( | const QPainterPath & | path | ) |
Connects the given path to this path by adding a line from the last element of this path to the first element of the given path.
Definition at line 1256 of file qpainterpath.cpp.
References d, LineToElement, MoveToElement, and other().
bool QPainterPath::contains | ( | const QPainterPath & | p | ) | const |
Returns true
if the given path p is contained within the current path. Returns false
if any edges of the current path and p intersect.
Set operations on paths will treat the paths as areas. Non-closed paths will be treated as implicitly closed.
Definition at line 3281 of file qpainterpath.cpp.
References QPathClipper::contains(), contains(), and isEmpty().
bool QPainterPath::contains | ( | const QPointF & | point | ) | const |
Returns true
if the given point is inside the path, otherwise returns false
.
Definition at line 1797 of file qpainterpath.cpp.
References contains(), controlPointRect(), CurveToElement, d, e, QBezier::fromPoints(), i, isEmpty(), LineToElement, MoveToElement, qt_painterpath_isect_curve(), qt_painterpath_isect_line(), and Qt::WindingFill.
Referenced by QPathClipper::contains(), contains(), QGraphicsItem::contains(), contains(), contains(), QPathClipper::intersect(), QtPrivate::intersect_path(), intersects(), intersects(), and QGraphicsSceneIndexPrivate::itemCollidesWithPath().
bool QPainterPath::contains | ( | const QRectF & | rect | ) | const |
Returns true
if the given rectangle is inside the path, otherwise returns false
.
Definition at line 2170 of file qpainterpath.cpp.
References contains(), controlPointRect(), CurveToElement, d, e, el, fillRule(), i, isEmpty(), LineToElement, MoveToElement, Qt::OddEvenFill, qt_painterpath_check_crossing(), and rect.
QRectF QPainterPath::controlPointRect | ( | ) | const |
Returns the rectangle containing all the points and control points in this path.
This function is significantly faster to compute than the exact boundingRect(), and the returned rectangle is always a superset of the rectangle returned by boundingRect().
Definition at line 1471 of file qpainterpath.cpp.
References d.
Referenced by QAlphaPaintEnginePrivate::addPenWidth(), QGraphicsPathItem::boundingRect(), QGraphicsEllipseItem::boundingRect(), QGraphicsPolygonItem::boundingRect(), QGraphicsLineItem::boundingRect(), QPathClipper::contains(), contains(), contains(), QSvgArc::fastBounds(), QSvgPath::fastBounds(), QPathClipper::intersect(), intersects(), and QGraphicsSceneIndexPrivate::recursive_items_helper().
Adds a cubic Bezier curve between the current position and the given endPoint using the control points specified by c1, and c2.
After the curve is added, the current position is updated to be at the end point of the curve.
\table 100% \row
Definition at line 782 of file qpainterpath.cpp.
References c2, CurveToDataElement, CurveToElement, d, e, hasValidCoords(), Q_ASSERT, qWarning, QPointF::x(), and QPointF::y().
Referenced by addEllipse(), arcTo(), convertCGPathToQPainterPath(), quadTo(), toReversed(), and src_gui_painting_qpainterpath::Wrapper::wrapper1().
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Adds a cubic Bezier curve between the current position and the end point ({endPointX}, {endPointY}) with control points specified by ({c1X}, {c1Y}) and ({c2X}, {c2Y}).
Definition at line 255 of file qpainterpath.h.
QPointF QPainterPath::currentPosition | ( | ) | const |
Returns the current position of the path.
Definition at line 983 of file qpainterpath.cpp.
References elements, and QList< T >::isEmpty().
QPainterPath::Element QPainterPath::elementAt | ( | int | index | ) | const |
Returns the element at the given index in the painter path.
Definition at line 464 of file qpainterpath.cpp.
References QList< T >::at(), elementCount(), i, and Q_ASSERT.
Referenced by QPathClipper::contains(), QPathClipper::intersect(), intersects(), and operator==().
int QPainterPath::elementCount | ( | ) | const |
Returns the number of path elements in the painter path.
Definition at line 451 of file qpainterpath.cpp.
References QList< T >::size().
Referenced by QPathClipper::contains(), elementAt(), QPathClipper::intersect(), intersects(), quadTo(), setElementPositionAt(), and toSubpathPolygons().
Qt::FillRule QPainterPath::fillRule | ( | ) | const |
Returns the painter path's currently set fill rule.
Definition at line 1309 of file qpainterpath.cpp.
References Qt::OddEvenFill.
Referenced by QPathClipper::QPathClipper(), QPathClipper::clip(), contains(), setFillRule(), and QX11PaintEngine::updateState().
QPainterPath QPainterPath::intersected | ( | const QPainterPath & | p | ) | const |
Returns a path which is the intersection of this path's fill area and p's fill area. Bezier curves may be flattened to line segments due to numerical instability of doing bezier curve intersections.
Definition at line 3205 of file qpainterpath.cpp.
References QPainterPath(), QPathClipper::BoolAnd, QPathClipper::clip(), and isEmpty().
Referenced by QQuickContext2D::clip(), QOutlineMapper::clipElements(), QGraphicsItem::clipPath(), QX11PaintEnginePrivate::fillPath(), QPolygon::intersected(), QPolygonF::intersected(), and operator&().
bool QPainterPath::intersects | ( | const QPainterPath & | p | ) | const |
Returns true
if the current path intersects at any point the given path p. Also returns true
if the current path contains or is contained by any part of p.
Set operations on paths will treat the paths as areas. Non-closed paths will be treated as implicitly closed.
Definition at line 3259 of file qpainterpath.cpp.
References contains(), QPathClipper::intersect(), and isEmpty().
bool QPainterPath::intersects | ( | const QRectF & | rectangle | ) | const |
Returns true
if any point in the given rectangle intersects the path; otherwise returns false
.
There is an intersection if any of the lines making up the rectangle crosses a part of the path or if any part of the rectangle overlaps with any area enclosed by the path. This function respects the current fillRule to determine what is considered inside the path.
Definition at line 2069 of file qpainterpath.cpp.
References QRectF::bottom(), contains(), controlPointRect(), d, e, elementAt(), elementCount(), i, isEmpty(), QRectF::left(), MoveToElement, qMax(), qMin(), qt_painterpath_check_crossing(), rect, QRectF::right(), and QRectF::top().
Referenced by QPathClipper::intersect(), QtPrivate::intersect_path(), QPolygon::intersects(), and QPolygonF::intersects().
bool QPainterPath::isEmpty | ( | ) | const |
Returns true
if either there are no elements in this path, or if the only element is a MoveToElement; otherwise returns false
.
Definition at line 1492 of file qpainterpath.cpp.
References QList< T >::first(), MoveToElement, QList< T >::size(), and QPainterPath::Element::type.
Referenced by QOutlineMapper::clipElements(), QGraphicsItem::clipPath(), closeSubpath(), contains(), contains(), contains(), QTextLayout::draw(), QPainterPrivate::draw_helper(), QX11PaintEngine::drawPath(), intersected(), intersects(), intersects(), length(), operator==(), percentAtLength(), simplified(), QWin32PrintEnginePrivate::strokePath(), subtracted(), toReversed(), toSubpathPolygons(), united(), and QWin32PrintEngine::updateClipPath().
qreal QPainterPath::length | ( | ) | const |
Returns the length of the current path.
Definition at line 2840 of file qpainterpath.cpp.
References CurveToElement, d, e, QBezier::fromPoints(), i, isEmpty(), QLineF::length(), LineToElement, and MoveToElement.
Referenced by angleAtPercent(), percentAtLength(), pointAtPercent(), and slopeAtPercent().
Adds a straight line from the current position to the given endPoint.
After the line is drawn, the current position is updated to be at the end point of the line.
Definition at line 724 of file qpainterpath.cpp.
References d, hasValidCoords(), LineToElement, Q_ASSERT, qWarning, and QPainterPath::Element::x.
Referenced by arcTo(), convertCGPathToQPainterPath(), QPainter::drawConvexPolygon(), QPainter::drawConvexPolygon(), QPainter::drawLines(), QPainter::drawLines(), QPainter::drawPolygon(), QPainter::drawPolygon(), QPainter::drawPolyline(), QPainter::drawPolyline(), QQC2::QCommonStyle::drawPrimitive(), QCommonStyle::drawPrimitive(), QDeclarativeGeoMapItemUtils::projectBbox(), toReversed(), QGeoMapPolylineGeometry::updateSourcePoints(), and QGeoMapPolygonGeometry::updateSourcePoints().
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Draws a line from the current position to the point ({x}, {y}).
Definition at line 240 of file qpainterpath.h.
Moves the current point to the given point, implicitly starting a new subpath and closing the previous one.
Definition at line 674 of file qpainterpath.cpp.
References d, hasValidCoords(), MoveToElement, Q_ASSERT, qWarning, and QPainterPath::Element::x.
Referenced by addEllipse(), addPolygon(), addRect(), arcMoveTo(), convertCGPathToQPainterPath(), QPainter::drawLines(), QPainter::drawLines(), QQC2::QCommonStyle::drawPrimitive(), QCommonStyle::drawPrimitive(), QDeclarativeGeoMapItemUtils::projectBbox(), toReversed(), QGeoMapPolylineGeometry::updateSourcePoints(), QGeoMapPolygonGeometry::updateSourcePoints(), and src_gui_painting_qpainterpath::Wrapper::wrapper2().
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Moves the current position to ({x}, {y}) and starts a new subpath, implicitly closing the previous path.
Definition at line 235 of file qpainterpath.h.
bool QPainterPath::operator!= | ( | const QPainterPath & | path | ) | const |
Returns true
if this painter path differs from the given path.
Note that comparing paths may involve a per element comparison which can be slow for complex paths.
Definition at line 2300 of file qpainterpath.cpp.
QPainterPath QPainterPath::operator& | ( | const QPainterPath & | other | ) | const |
Returns the intersection of this path and the other path.
Definition at line 2312 of file qpainterpath.cpp.
References intersected(), and other().
QPainterPath & QPainterPath::operator&= | ( | const QPainterPath & | other | ) |
Intersects this path with other and returns a reference to this path.
Definition at line 2361 of file qpainterpath.cpp.
References other().
QPainterPath QPainterPath::operator+ | ( | const QPainterPath & | other | ) | const |
Returns the union of this path and the other path. This function is equivalent to operator|().
Definition at line 2337 of file qpainterpath.cpp.
References other(), and united().
QPainterPath & QPainterPath::operator+= | ( | const QPainterPath & | other | ) |
Unites this path with other, and returns a reference to this path. This is equivalent to operator|=().
Definition at line 2386 of file qpainterpath.cpp.
References other().
QPainterPath QPainterPath::operator- | ( | const QPainterPath & | other | ) | const |
Subtracts the other path from a copy of this path, and returns the copy.
Definition at line 2349 of file qpainterpath.cpp.
References other(), and subtracted().
QPainterPath & QPainterPath::operator-= | ( | const QPainterPath & | other | ) |
Subtracts other from this path, and returns a reference to this path.
Definition at line 2399 of file qpainterpath.cpp.
References other().
QPainterPath & QPainterPath::operator= | ( | const QPainterPath & | path | ) |
Assigns the given path to this painter path.
Move-assigns other to this QPainterPath instance.
Definition at line 552 of file qpainterpath.cpp.
References copy(), other(), and swap().
bool QPainterPath::operator== | ( | const QPainterPath & | path | ) | const |
Returns true
if this painterpath is equal to the given path.
Note that comparing paths may involve a per element comparison which can be slow for complex paths.
Definition at line 2259 of file qpainterpath.cpp.
References QList< T >::at(), boundingRect(), d, e, elementAt(), epsilon, epsilonCompare(), i, isEmpty(), Qt::OddEvenFill, QList< T >::size(), QRectF::size(), and QPainterPath::Element::type.
QPainterPath QPainterPath::operator| | ( | const QPainterPath & | other | ) | const |
Returns the union of this path and the other path.
Definition at line 2324 of file qpainterpath.cpp.
References other(), and united().
QPainterPath & QPainterPath::operator|= | ( | const QPainterPath & | other | ) |
Unites this path with other and returns a reference to this path.
Definition at line 2373 of file qpainterpath.cpp.
References other().
Returns percentage of the whole path at the specified length len.
Note that similarly to other percent methods, the percentage measurement is not linear with regards to the length, if curves are present in the path. When curves are present the percentage argument is mapped to the t parameter of the Bezier equations.
Definition at line 2883 of file qpainterpath.cpp.
References CurveToElement, d, e, QBezier::fromPoints(), i, isEmpty(), QString::length(), length(), line, LineToElement, and MoveToElement.
Returns the point at at the percentage t of the current path.
The argument t has to be between 0 and 1.
Note that similarly to other percent methods, the percentage measurement is not linear with regards to the length, if curves are present in the path. When curves are present the percentage argument is mapped to the t parameter of the Bezier equations.
Definition at line 3000 of file qpainterpath.cpp.
References QList< T >::at(), bezierAtT(), length(), qBound(), qWarning, and QList< T >::size().
Adds a quadratic Bezier curve between the current position and the given endPoint with the control point specified by c.
After the curve is added, the current point is updated to be at the end point of the curve.
Definition at line 838 of file qpainterpath.cpp.
References c2, cubicTo(), d, e, elementCount(), hasValidCoords(), Q_ASSERT, qWarning, QPointF::x(), QPainterPath::Element::x, QPointF::y(), and QPainterPath::Element::y.
Referenced by convertCGPathToQPainterPath().
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Adds a quadratic Bezier curve between the current point and the endpoint ({endPointX}, {endPointY}) with the control point specified by ({cx}, {cy}).
Definition at line 262 of file qpainterpath.h.
void QPainterPath::reserve | ( | int | size | ) |
Reserves a given amount of elements in QPainterPath's internal memory.
Attempts to allocate memory for at least size elements.
Definition at line 608 of file qpainterpath.cpp.
References d, and QList< T >::reserve().
Sets the x and y coordinate of the element at index index to x and y.
Definition at line 479 of file qpainterpath.cpp.
References e, elementCount(), i, and Q_ASSERT.
void QPainterPath::setFillRule | ( | Qt::FillRule | fillRule | ) |
Sets the fill rule of the painter path to the given fillRule.
Qt provides two methods for filling paths:
\table \header
Definition at line 1331 of file qpainterpath.cpp.
References fillRule().
Referenced by QDistanceField::QDistanceField(), createPathNode(), QPainterPathStroker::createStroke(), QTextLayout::draw(), QSvgPath::draw(), QPainter::drawConvexPolygon(), QPainter::drawConvexPolygon(), QMacStylePrivate::drawFocusRing(), QX11PaintEngine::drawPath(), QPainter::drawPolygon(), and QPainter::drawPolygon().
QPainterPath QPainterPath::simplified | ( | ) | const |
Returns a simplified version of this path. This implies merging all subpaths that intersect, and returning a path containing no intersecting edges. Consecutive parallel lines will also be merged. The simplified path will always use the default fill rule, Qt::OddEvenFill. Bezier curves may be flattened to line segments due to numerical instability of doing bezier curve intersections.
Definition at line 3240 of file qpainterpath.cpp.
References QPainterPath(), QPathClipper::clip(), isEmpty(), and QPathClipper::Simplify.
Referenced by QPathClipper::clip(), and QGeoMapPolygonGeometry::updateSourcePoints().
Returns the slope of the path at the percentage t.
The argument t has to be between 0 and 1.
Note that similarly to other percent methods, the percentage measurement is not linear with regards to the length, if curves are present in the path. When curves are present the percentage argument is mapped to the t parameter of the Bezier equations.
Definition at line 3063 of file qpainterpath.cpp.
References bezierAtT(), length(), qWarning, slopeAt(), QBezier::x1, QBezier::x2, QBezier::x3, QBezier::x4, QBezier::y1, QBezier::y2, QBezier::y3, and QBezier::y4.
QPainterPath QPainterPath::subtracted | ( | const QPainterPath & | p | ) | const |
Returns a path which is p's fill area subtracted from this path's fill area.
Set operations on paths will treat the paths as areas. Non-closed paths will be treated as implicitly closed. Bezier curves may be flattened to line segments due to numerical instability of doing bezier curve intersections.
Definition at line 3223 of file qpainterpath.cpp.
References QPathClipper::BoolSub, QPathClipper::clip(), and isEmpty().
Referenced by operator-(), QPolygon::subtracted(), and QPolygonF::subtracted().
|
inlinenoexcept |
Swaps painter path other with this painter path. This operation is very fast and never fails.
Definition at line 62 of file qpainterpath.h.
References other(), and swap().
Referenced by operator=(), and swap().
QPolygonF QPainterPath::toFillPolygon | ( | const QTransform & | matrix = QTransform() | ) | const |
Converts the path into a polygon using the QTransform matrix, and returns the polygon.
The polygon is created by first converting all subpaths to polygons, then using a rewinding technique to make sure that overlapping subpaths can be filled using the correct fill rule.
Note that rewinding inserts addition lines in the polygon so the outline of the fill polygon does not match the outline of the path.
Definition at line 2814 of file qpainterpath.cpp.
References QList< T >::at(), QList< T >::first(), i, QList< T >::isEmpty(), QList< T >::size(), and toSubpathPolygons().
Referenced by QPolygon::intersected(), QPolygonF::intersected(), QPolygon::subtracted(), QPolygonF::subtracted(), QX11PaintEnginePrivate::systemStateChanged(), QPolygon::united(), QPolygonF::united(), and QX11PaintEngine::updateState().
QList< QPolygonF > QPainterPath::toFillPolygons | ( | const QTransform & | matrix = QTransform() | ) | const |
Converts the path into a list of polygons using the QTransform matrix, and returns the list.
The function differs from the toFillPolygon() function in that it creates several polygons. It is provided because it is usually faster to draw several small polygons than to draw one large polygon, even though the total number of points drawn is the same.
The toFillPolygons() function differs from the toSubpathPolygons() function in that it create only polygon for subpaths that have overlapping bounding rectangles.
Like the toFillPolygon() function, this function uses a rewinding technique to make sure that overlapping subpaths can be filled using the correct fill rule. Note that rewinding inserts addition lines in the polygons so the outline of the fill polygon does not match the outline of the path.
Definition at line 1626 of file qpainterpath.cpp.
References QList< T >::at(), QList< T >::clear(), QList< T >::constFirst(), QList< T >::first(), i, QRectF::intersects(), QPolygonF::isClosed(), QList< T >::isEmpty(), j, qDebug, QList< T >::reserve(), QList< T >::resize(), QList< T >::size(), and toSubpathPolygons().
Referenced by QX11PaintEnginePrivate::fillPath().
QPainterPath QPainterPath::toReversed | ( | ) | const |
Creates and returns a reversed copy of the path.
It is the order of the elements that is reversed: If a QPainterPath is composed by calling the moveTo(), lineTo() and cubicTo() functions in the specified order, the reversed copy is composed by calling cubicTo(), lineTo() and moveTo().
Definition at line 1505 of file qpainterpath.cpp.
References cubicTo(), CurveToDataElement, CurveToElement, d, i, isEmpty(), lineTo(), LineToElement, moveTo(), MoveToElement, Q_ASSERT, sp, QPainterPath::Element::type, QPainterPath::Element::x, and QPainterPath::Element::y.
QList< QPolygonF > QPainterPath::toSubpathPolygons | ( | const QTransform & | matrix = QTransform() | ) | const |
Converts the path into a list of polygons using the QTransform matrix, and returns the list.
This function creates one polygon for each subpath regardless of intersecting subpaths (i.e. overlapping bounding rectangles). To make sure that such overlapping subpaths are filled correctly, use the toFillPolygons() function instead.
Definition at line 1559 of file qpainterpath.cpp.
References QBezier::addToPolygon(), QList< T >::clear(), CurveToDataElement, CurveToElement, d, e, elementCount(), QBezier::fromPoints(), i, isEmpty(), LineToElement, MoveToElement, Q_ASSERT, QList< T >::reserve(), and QList< T >::size().
Referenced by toFillPolygon(), and toFillPolygons().
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Translates all elements in the path by the given offset.
Definition at line 294 of file qpainterpath.h.
References translate().
Translates all elements in the path by ({dx}, {dy}).
Definition at line 2112 of file qpainterpath.cpp.
References QList< T >::data(), Q_ASSERT, QList< T >::size(), QPainterPath::Element::x, and QPainterPath::Element::y.
Referenced by QDistanceField::QDistanceField(), QGraphicsView::fitInView(), QtPrivate::intersect_rect(), QDistanceField::setGlyph(), QDeclarativeCircleMapItemPrivateCPU::updatePolish(), QDeclarativePolygonMapItemPrivateCPU::updatePolish(), QDeclarativePolylineMapItemPrivateCPU::updatePolish(), and QDeclarativeRectangleMapItemPrivateCPU::updatePolish().
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Returns a copy of the path that is translated by the given offset.
Definition at line 297 of file qpainterpath.h.
QPainterPath QPainterPath::translated | ( | qreal | dx, |
qreal | dy | ||
) | const |
Returns a copy of the path that is translated by ({dx}, {dy}).
Definition at line 2147 of file qpainterpath.cpp.
References copy().
Referenced by QtPrivate::intersect_path(), and QGraphicsSceneIndexPrivate::recursive_items_helper().
QPainterPath QPainterPath::united | ( | const QPainterPath & | p | ) | const |
Returns a path which is the union of this path's fill area and p's fill area.
Set operations on paths will treat the paths as areas. Non-closed paths will be treated as implicitly closed. Bezier curves may be flattened to line segments due to numerical instability of doing bezier curve intersections.
Definition at line 3190 of file qpainterpath.cpp.
References QPathClipper::BoolOr, QPathClipper::clip(), and isEmpty().
Referenced by operator+(), operator|(), QPolygon::united(), and QPolygonF::united().
|
friend |
Writes the given painter path to the given stream, and returns a reference to the stream.
Definition at line 2414 of file qpainterpath.cpp.
|
related |
Writes the given painter path to the given stream, and returns a reference to the stream.
Definition at line 2414 of file qpainterpath.cpp.
|
friend |
Reads a painter path from the given stream into the specified path, and returns a reference to the stream.
Definition at line 2441 of file qpainterpath.cpp.
|
related |
Reads a painter path from the given stream into the specified path, and returns a reference to the stream.
Definition at line 2441 of file qpainterpath.cpp.
|
friend |
Definition at line 175 of file qpainterpath.h.
|
friend |
Definition at line 176 of file qpainterpath.h.
|
friend |
Definition at line 177 of file qpainterpath.h.
|
friend |
Definition at line 95 of file qpaintengineex.cpp.
|
friend |
Definition at line 178 of file qpainterpath.h.