Qt 4.8
|
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be constructed and reused. More...
#include <qpainterpath.h>
Classes | |
class | Element |
The QPainterPath::Element class specifies the position and type of a subpath. More... | |
Public Types | |
enum | ElementType { MoveToElement, LineToElement, CurveToElement, CurveToDataElement } |
This enum describes the types of elements used to connect vertices in subpaths. More... | |
Public Functions | |
void | addEllipse (const QRectF &rect) |
Creates an ellipse within the specified boundingRectangle and adds it to the painter path as a closed subpath. More... | |
void | addEllipse (qreal x, qreal y, qreal w, qreal h) |
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. More... | |
void | addEllipse (const QPointF ¢er, qreal rx, qreal ry) |
Creates an ellipse positioned at {center} with radii {rx} and {ry}, and adds it to the painter path as a closed subpath. More... | |
void | addPath (const QPainterPath &path) |
Adds the given path to this path as a closed subpath. More... | |
void | addPolygon (const QPolygonF &polygon) |
Adds the given polygon to the path as an (unclosed) subpath. More... | |
void | addRect (const QRectF &rect) |
Adds the given rectangle to this path as a closed subpath. More... | |
void | addRect (qreal x, qreal y, qreal w, qreal h) |
Adds a rectangle at position ({x}, {y}), with the given width and height, as a closed subpath. More... | |
void | addRegion (const QRegion ®ion) |
Adds the given region to the path by adding each rectangle in the region as a separate closed subpath. More... | |
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. More... | |
void | addRoundedRect (qreal x, qreal y, qreal w, qreal h, qreal xRadius, qreal yRadius, Qt::SizeMode mode=Qt::AbsoluteSize) |
Adds the given rectangle x, y, w, h with rounded corners to the path. More... | |
void | addRoundRect (const QRectF &rect, int xRnd, int yRnd) |
Adds a rectangle r with rounded corners to the path. More... | |
void | addRoundRect (qreal x, qreal y, qreal w, qreal h, int xRnd, int yRnd) |
Adds a rectangle with rounded corners to the path. More... | |
void | addRoundRect (const QRectF &rect, int roundness) |
Adds a rounded rectangle, rect, to the path. More... | |
void | addRoundRect (qreal x, qreal y, qreal w, qreal h, int roundness) |
Adds a rounded rectangle to the path, defined by the coordinates x and y with the specified width and height. More... | |
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. More... | |
void | addText (qreal x, qreal y, const QFont &f, const QString &text) |
Adds the given text to this path as a set of closed subpaths created from the font supplied. More... | |
qreal | angleAtPercent (qreal t) const |
Returns the angle of the path tangent at the percentage t. More... | |
void | arcMoveTo (const QRectF &rect, qreal angle) |
Creates a move to that lies on the arc that occupies the given rectangle at angle. More... | |
void | arcMoveTo (qreal x, qreal y, qreal w, qreal h, qreal angle) |
Creates a move to that lies on the arc that occupies the QRectF(x, y, width, height) at angle. More... | |
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. More... | |
void | arcTo (qreal x, qreal y, qreal w, qreal h, qreal startAngle, qreal arcLength) |
QRectF | boundingRect () const |
Returns the bounding rectangle of this painter path as a rectangle with floating point precision. More... | |
void | closeSubpath () |
Closes the current subpath by drawing a line to the beginning of the subpath, automatically starting a new path. More... | |
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. More... | |
bool | contains (const QPointF &pt) const |
Returns true if the given point is inside the path, otherwise returns false. More... | |
bool | contains (const QRectF &rect) const |
Returns true if the given rectangle is inside the path, otherwise returns false. More... | |
bool | contains (const QPainterPath &p) const |
Returns true if the given path p is contained within the current path. More... | |
QRectF | controlPointRect () const |
Returns the rectangle containing all the points and control points in this path. More... | |
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. More... | |
void | cubicTo (qreal ctrlPt1x, qreal ctrlPt1y, qreal ctrlPt2x, qreal ctrlPt2y, qreal endPtx, qreal endPty) |
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}). More... | |
QPointF | currentPosition () const |
Returns the current position of the path. More... | |
const QPainterPath::Element & | elementAt (int i) const |
Returns the element at the given index in the painter path. More... | |
int | elementCount () const |
Returns the number of path elements in the painter path. More... | |
Qt::FillRule | fillRule () const |
Returns the painter path's currently set fill rule. More... | |
QPainterPath | intersected (const QPainterPath &r) const |
Returns a path which is the intersection of this path's fill area and p's fill area. More... | |
bool | intersects (const QRectF &rect) const |
Returns true if any point in the given rectangle intersects the path; otherwise returns false. More... | |
bool | intersects (const QPainterPath &p) const |
Returns true if the current path intersects at any point the given path p. More... | |
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. More... | |
qreal | length () const |
Returns the length of the current path. More... | |
void | lineTo (const QPointF &p) |
Adds a straight line from the current position to the given endPoint. More... | |
void | lineTo (qreal x, qreal y) |
Draws a line from the current position to the point ({x}, {y}). More... | |
void | moveTo (const QPointF &p) |
Moves the current point to the given point, implicitly starting a new subpath and closing the previous one. More... | |
void | moveTo (qreal x, qreal y) |
Moves the current position to ({x}, {y}) and starts a new subpath, implicitly closing the previous path. More... | |
QPainterPath | operator & (const QPainterPath &other) const |
QPainterPath & | operator &= (const QPainterPath &other) |
bool | operator!= (const QPainterPath &other) const |
Returns true if this painter path differs from the given path. More... | |
QPainterPath | operator+ (const QPainterPath &other) const |
Returns the union of this path and the other path. More... | |
QPainterPath & | operator+= (const QPainterPath &other) |
Unites this path with other, and returns a reference to this path. More... | |
QPainterPath | operator- (const QPainterPath &other) const |
Subtracts the other path from a copy of this path, and returns the copy. More... | |
QPainterPath & | operator-= (const QPainterPath &other) |
Subtracts other from this path, and returns a reference to this path. More... | |
QPainterPath & | operator= (const QPainterPath &other) |
Assigns the given path to this painter path. More... | |
bool | operator== (const QPainterPath &other) const |
Returns true if this painterpath is equal to the given path. More... | |
QPainterPath | operator| (const QPainterPath &other) const |
Returns the union of this path and the other path. More... | |
QPainterPath & | operator|= (const QPainterPath &other) |
Unites this path with other and returns a reference to this path. More... | |
qreal | percentAtLength (qreal t) const |
Returns percentage of the whole path at the specified length len. More... | |
QPointF | pointAtPercent (qreal t) const |
Returns the point at at the percentage t of the current path. More... | |
QPainterPath () | |
Constructs an empty QPainterPath object. More... | |
QPainterPath (const QPointF &startPoint) | |
Creates a QPainterPath object with the given startPoint as its current position. More... | |
QPainterPath (const QPainterPath &other) | |
Creates a QPainterPath object that is a copy of the given path. More... | |
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. More... | |
void | quadTo (qreal ctrlPtx, qreal ctrlPty, qreal endPtx, qreal endPty) |
Adds a quadratic Bezier curve between the current point and the endpoint ({endPointX}, {endPointY}) with the control point specified by ({cx}, {cy}). More... | |
void | setElementPositionAt (int i, qreal x, qreal y) |
Sets the x and y coordinate of the element at index index to x and y. More... | |
void | setFillRule (Qt::FillRule fillRule) |
Sets the fill rule of the painter path to the given fillRule. More... | |
QPainterPath | simplified () const |
Returns a simplified version of this path. More... | |
qreal | slopeAtPercent (qreal t) const |
Returns the slope of the path at the percentage t. More... | |
QPainterPath | subtracted (const QPainterPath &r) const |
Returns a path which is p's fill area subtracted from this path's fill area. More... | |
QPainterPath | subtractedInverted (const QPainterPath &r) const |
Use subtracted() instead. More... | |
void | swap (QPainterPath &other) |
Swaps painter path other with this painter path. More... | |
QPolygonF | toFillPolygon (const QMatrix &matrix=QMatrix()) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
QPolygonF | toFillPolygon (const QTransform &matrix) const |
Converts the path into a polygon using the QTransform matrix, and returns the polygon. More... | |
QList< QPolygonF > | toFillPolygons (const QMatrix &matrix=QMatrix()) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
QList< QPolygonF > | toFillPolygons (const QTransform &matrix) const |
Converts the path into a list of polygons using the QTransform matrix, and returns the list. More... | |
QPainterPath | toReversed () const |
Creates and returns a reversed copy of the path. More... | |
QList< QPolygonF > | toSubpathPolygons (const QMatrix &matrix=QMatrix()) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
QList< QPolygonF > | toSubpathPolygons (const QTransform &matrix) const |
Converts the path into a list of polygons using the QTransform matrix, and returns the list. More... | |
void | translate (qreal dx, qreal dy) |
Translates all elements in the path by ({dx}, {dy}). More... | |
void | translate (const QPointF &offset) |
Translates all elements in the path by the given offset. More... | |
QPainterPath | translated (qreal dx, qreal dy) const |
Returns a copy of the path that is translated by ({dx}, {dy}). More... | |
QPainterPath | translated (const QPointF &offset) const |
Returns a copy of the path that is translated by the given offset. More... | |
QPainterPath | united (const QPainterPath &r) const |
Returns a path which is the union of this path's fill area and p's fill area. More... | |
~QPainterPath () | |
Destroys this QPainterPath object. More... | |
Private Functions | |
void | computeBoundingRect () const |
void | computeControlPointRect () const |
QPainterPathData * | d_func () const |
void | detach () |
void | detach_helper () |
void | ensureData () |
void | ensureData_helper () |
void | setDirty (bool) |
Properties | |
QScopedPointer< QPainterPathPrivate, QPainterPathPrivateDeleter > | d_ptr |
Friends | |
Q_GUI_EXPORT QDataStream & | operator<< (QDataStream &, const QPainterPath &) |
Writes the given painter path to the given stream, and returns a reference to the stream. More... | |
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. More... | |
class | QMatrix |
class | QPainterPathData |
class | QPainterPathStroker |
class | QPainterPathStrokerPrivate |
class | QTransform |
Q_GUI_EXPORT const QVectorPath & | qtVectorPathForPath (const QPainterPath &) |
class | QVectorPath |
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.
A QPainterPath object can be constructed as an empty path, with a given start point, or as a copy of another QPainterPath object. Once created, lines and curves can be added to the path using the lineTo(), arcTo(), cubicTo() and quadTo() functions. The lines and curves stretch from the currentPosition() to the position passed as argument.
The currentPosition() of the QPainterPath object is always the end position of the last subpath that was added (or the initial start point). Use the moveTo() function to move the currentPosition() without adding a component. The moveTo() function implicitly starts a new subpath, and closes the previous one. Another way of starting a new subpath is to call the closeSubpath() function which closes the current path by adding a line from the currentPosition() back to the path's start position. Note that the new path will have (0, 0) as its initial currentPosition().
QPainterPath class also provides several convenience functions to add closed subpaths to a painter path: addEllipse(), addPath(), addRect(), addRegion() and addText(). The addPolygon() function adds an unclosed subpath. In fact, these functions are all collections of moveTo(), lineTo() and cubicTo() operations.
In addition, a path can be added to the current path using the connectPath() function. But note that this function will connect the last element of the current path to the first element of given one by adding a line.
Below is a code snippet that shows how a QPainterPath object can be used:
The painter path is initially empty when constructed. We first add a rectangle, which is a closed subpath. Then we add two bezier curves which together form a closed subpath even though they are not closed individually. Finally we draw the entire path. The path is filled using the default fill rule, Qt::OddEvenFill. Qt provides two methods for filling paths:
Qt::OddEvenFill | Qt::WindingFill |
See the Qt::FillRule documentation for the definition of the rules. A painter path's currently set fill rule can be retrieved using the fillRule() function, and altered using the setFillRule() function.
The QPainterPath class provides a collection of functions that returns information about the path and its elements.
The currentPosition() function returns the end point of the last subpath that was added (or the initial start point). The elementAt() function can be used to retrieve the various subpath elements, the number of elements can be retrieved using the elementCount() function, and the isEmpty() function tells whether this QPainterPath object contains any elements at all.
The controlPointRect() function returns the rectangle containing all the points and control points in this path. This function is significantly faster to compute than the exact boundingRect() which returns the bounding rectangle of this painter path with floating point precision.
Finally, QPainterPath provides the contains() function which can be used to determine whether a given point or rectangle is inside the path, and the intersects() function which determines if any of the points inside a given rectangle also are inside this path.
For compatibility reasons, it might be required to simplify the representation of a painter path: QPainterPath provides the toFillPolygon(), toFillPolygons() and toSubpathPolygons() functions which convert the painter path into a polygon. The toFillPolygon() returns the painter path as one single polygon, while the two latter functions return a list of polygons.
The toFillPolygons() and toSubpathPolygons() functions are 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 difference between the two is the number of polygons they return: The toSubpathPolygons() creates one polygon for each subpath regardless of intersecting subpaths (i.e. overlapping bounding rectangles), while the toFillPolygons() functions creates only one polygon for overlapping subpaths.
The toFillPolygon() and toFillPolygons() functions first convert all the subpaths to polygons, then uses a rewinding technique to make sure that overlapping subpaths can be filled using the correct fill rule. Note that rewinding inserts additional lines in the polygon so the outline of the fill polygon does not match the outline of the path.
Qt provides the painting/painterpaths{Painter Paths Example} and the demos/deform{Vector Deformation Demo} which are located in Qt's example and demo directories respectively.
The painting/painterpaths{Painter Paths Example} shows how painter paths can be used to build complex shapes for rendering and lets the user experiment with the filling and stroking. The demos/deform{Vector Deformation Demo} shows how to use QPainterPath to draw text.
painting/painterpaths{Painter Paths Example} | demos/deform{Vector Deformation Demo} |
Definition at line 67 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.
Enumerator | |
---|---|
MoveToElement | |
LineToElement | |
CurveToElement | |
CurveToDataElement |
Definition at line 70 of file qpainterpath.h.
QPainterPath::QPainterPath | ( | ) |
Constructs an empty QPainterPath object.
Definition at line 560 of file qpainterpath.cpp.
|
explicit |
Creates a QPainterPath object with the given startPoint as its current position.
Definition at line 587 of file qpainterpath.cpp.
QPainterPath::QPainterPath | ( | const QPainterPath & | path | ) |
Creates a QPainterPath object that is a copy of the given path.
Definition at line 575 of file qpainterpath.cpp.
QPainterPath::~QPainterPath | ( | ) |
void QPainterPath::addEllipse | ( | const QRectF & | boundingRectangle | ) |
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).
QLinearGradient myGradient; QPen myPen; QRectF boundingRectangle; QPainterPath myPath; myPath.addEllipse(boundingRectangle); QPainter painter(this); painter.setBrush(myGradient); painter.setPen(myPen); painter.drawPath(myPath); |
Definition at line 1169 of file qpainterpath.cpp.
Referenced by QSvgEllipse::bounds(), QX11PaintEngine::drawEllipse(), QOpenGLPaintEngine::drawEllipse(), QPaintEngine::drawEllipse(), QPainter::drawEllipse(), ellipseRectToPath(), QRegion::QRegion(), qt_bitmapToRegion(), and QGraphicsEllipseItem::shape().
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.
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 335 of file qpainterpath.h.
Creates an ellipse positioned at {center} with radii {rx} and {ry}, and adds it to the painter path as a closed subpath.
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 340 of file qpainterpath.h.
void QPainterPath::addPath | ( | const QPainterPath & | path | ) |
Adds the given path to this path as a closed subpath.
Definition at line 1295 of file qpainterpath.cpp.
Referenced by QPathClipper::clip(), and qt_graphicsItem_shapeFromPath().
void QPainterPath::addPolygon | ( | const QPolygonF & | polygon | ) |
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.
QLinearGradient myGradient; QPen myPen; QPolygonF myPolygon; QPainterPath myPath; myPath.addPolygon(myPolygon); QPainter painter(this); painter.setBrush(myGradient); painter.setPen(myPen); painter.drawPath(myPath); |
Definition at line 1131 of file qpainterpath.cpp.
Referenced by QSvgPolygon::bounds(), QSvgPolyline::bounds(), QCommonStyle::drawControl(), QAlphaPaintEngine::drawPolygon(), QPolygon::intersected(), QPolygonF::intersected(), QGraphicsSceneIndex::items(), mapProjective(), QGraphicsView::mouseMoveEvent(), QGraphicsView::render(), QGraphicsPolygonItem::shape(), QPolygon::subtracted(), QPolygonF::subtracted(), QPolygon::united(), and QPolygonF::united().
void QPainterPath::addRect | ( | const QRectF & | rectangle | ) |
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.
QLinearGradient myGradient; QPen myPen; QRectF myRectangle; QPainterPath myPath; myPath.addRect(myRectangle); QPainter painter(this); painter.setBrush(myGradient); painter.setPen(myPen); painter.drawPath(myPath); |
Definition at line 1085 of file qpainterpath.cpp.
Referenced by QGraphicsTextItemPrivate::_q_mouseOnEdge(), QFontEngineBox::addOutlineToPath(), addRegion(), addSelectedRegionsToPath(), addText(), QSvgRect::bounds(), QPathClipper::clip(), QGL2PaintEngineEx::clip(), QOutlineMapper::clipElements(), QPainter::clipPath(), QGraphicsItem::clipPath(), QGraphicsItem::collidesWithPath(), QTextLayout::draw(), QTextLine::draw(), QCDEStyle::drawControl(), QRasterPaintEngine::drawImage(), QOpenGLPaintEnginePrivate::drawImageAsPath(), QMacStyle::drawPrimitive(), QX11PaintEngine::drawRects(), QOpenGLPaintEngine::drawRects(), QPaintEngine::drawRects(), QPdfBaseEngine::drawRects(), QPainter::drawRects(), QOpenGLPaintEnginePrivate::drawTiledImageAsPath(), QRasterPaintEngine::drawTiledPixmap(), QX11PaintEnginePrivate::fillPath(), QRasterPaintEngine::fillRect(), QGraphicsSceneIndexRectIntersector::intersect(), QGraphicsSceneIndexPointIntersector::intersect(), QGraphicsSceneIndexPrivate::itemCollidesWithPath(), QTransform::mapRect(), QGraphicsWidget::paintWindowFrame(), path_for_glyphs(), qt_regionToPath(), QmlJSDebugger::regionToPolygon(), QPainter::setClipRect(), QGraphicsWidget::shape(), QGraphicsItem::shape(), QGraphicsRectItem::shape(), QGraphicsTextItem::shape(), QGraphicsSimpleTextItem::shape(), QFontSubset::toTruetype(), QPdfBaseEngine::updateClipPath(), QOpenGLPaintEngine::updateClipRegion(), QGraphicsPixmapItemPrivate::updateShape(), and QPdfBaseEngine::updateState().
Adds a rectangle at position ({x}, {y}), with the given width and height, as a closed subpath.
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 qpainterpath.h.
void QPainterPath::addRegion | ( | const QRegion & | region | ) |
Adds the given region to the path by adding each rectangle in the region as a separate closed subpath.
Definition at line 1367 of file qpainterpath.cpp.
Referenced by QGL2PaintEngineEx::clip(), and QGL2PaintEngineExPrivate::systemStateChanged().
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 3209 of file qpainterpath.cpp.
Referenced by QPainter::drawRoundedRect().
|
inline |
Adds the given rectangle x, y, w, h with rounded corners to the path.
Definition at line 350 of file qpainterpath.h.
void QPainterPath::addRoundRect | ( | const QRectF & | r, |
int | xRnd, | ||
int | yRnd | ||
) |
Adds a rectangle r with rounded corners to the path.
The xRnd and yRnd arguments specify how rounded the corners should be. 0 is angled corners, 99 is maximum roundedness.
Definition at line 3291 of file qpainterpath.cpp.
Adds a rectangle with rounded corners to the path.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
The rectangle is constructed from x, y, and the width and height w and h.
The xRnd and yRnd arguments specify how rounded the corners should be. 0 is angled corners, 99 is maximum roundedness.
Definition at line 357 of file qpainterpath.h.
|
inline |
Adds a rounded rectangle, rect, to the path.
The roundness argument specifies uniform roundness for the rectangle. Vertical and horizontal roundness factors will be adjusted accordingly to act uniformly around both axes. Use this method if you want a rectangle equally rounded across both the X and Y axis.
Definition at line 363 of file qpainterpath.h.
|
inline |
Adds a rounded rectangle to the path, defined by the coordinates x and y with the specified width and height.
The roundness argument specifies uniform roundness for the rectangle. Vertical and horizontal roundness factors will be adjusted accordingly to act uniformly around both axes. Use this method if you want a rectangle equally rounded across both the X and Y axis.
Definition at line 375 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.
QLinearGradient myGradient; QPen myPen; QFont myFont; QPointF baseline(x, y); QPainterPath myPath; myPath.addText(baseline, myFont, tr("Qt")); QPainter painter(this); painter.setBrush(myGradient); painter.setPen(myPen); painter.drawPath(myPath); |
Definition at line 1223 of file qpainterpath.cpp.
Adds the given text to this path as a set of closed subpaths created from the font supplied.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
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 381 of file qpainterpath.h.
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 3124 of file qpainterpath.cpp.
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 1024 of file qpainterpath.cpp.
Referenced by QPainter::drawArc(), and QPainter::drawChord().
Creates a move to that lies on the arc that occupies the QRectF(x, y, width, height) at angle.
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 318 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.
QLinearGradient myGradient; QPen myPen; QPainterPath myPath; myPath.moveTo(center); myPath.arcTo(boundingRect, startAngle, sweepLength); QPainter painter(this); painter.setBrush(myGradient); painter.setPen(myPen); painter.drawPath(myPath); |
Definition at line 960 of file qpainterpath.cpp.
Referenced by QBalloonTip::balloon(), QRenderRule::borderClip(), QPainter::drawArc(), QPainter::drawChord(), QPainter::drawPie(), and QGraphicsEllipseItem::shape().
|
inline |
Definition at line 313 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 1528 of file qpainterpath.cpp.
Referenced by QPathClipper::clip(), QPainter::clipBoundingRect(), QPainterPrivate::draw_helper(), QWin32PrintEngine::drawPath(), QPicturePaintEngine::drawPath(), QPainter::drawPath(), QPainterPrivate::drawStretchedGradient(), QRasterPaintEngine::fillPath(), QWin32PrintEnginePrivate::fillPath_dev(), QGraphicsView::fitInView(), QBlittablePixmapData::markRasterOverlay(), operator==(), QPainter::setClipPath(), and QPicturePaintEngine::updateClipPath().
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 666 of file qpainterpath.cpp.
Referenced by QFreetypeFace::addGlyphToPath(), addGlyphToPath(), QRenderRule::borderClip(), QMacFontPath::closePath(), collectSingleContour(), QPainter::drawChord(), QPainter::drawConvexPolygon(), QPainter::drawPie(), QWin32PrintEngine::drawPolygon(), QX11PaintEngine::drawPolygon(), QSvgPaintEngine::drawPolygon(), QPdfBaseEngine::drawPolygon(), QPainter::drawPolygon(), QCommonStyle::drawPrimitive(), QGraphicsView::mouseMoveEvent(), parsePathDataFast(), and QGraphicsView::render().
|
private |
Definition at line 3548 of file qpainterpath.cpp.
Referenced by boundingRect().
|
private |
Definition at line 3595 of file qpainterpath.cpp.
Referenced by controlPointRect().
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 1329 of file qpainterpath.cpp.
bool QPainterPath::contains | ( | const QPointF & | point | ) | const |
Returns true if the given point is inside the path, otherwise returns false.
Definition at line 1891 of file qpainterpath.cpp.
Referenced by QGraphicsTextItemPrivate::_q_mouseOnEdge(), QGraphicsItem::collidesWithPath(), contains(), QGraphicsItem::contains(), QGraphicsSceneIndexPathIntersector::intersect(), intersects(), QGraphicsSceneIndexPrivate::itemCollidesWithPath(), and QOpenGLPaintEngine::updateClipRegion().
bool QPainterPath::contains | ( | const QRectF & | rect | ) | const |
Returns true if the given rectangle is inside the path, otherwise returns false.
Definition at line 2244 of file qpainterpath.cpp.
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 3529 of file qpainterpath.cpp.
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 1549 of file qpainterpath.cpp.
Referenced by QAlphaPaintEnginePrivate::addPenWidth(), QGraphicsPathItem::boundingRect(), QGraphicsEllipseItem::boundingRect(), QGraphicsPolygonItem::boundingRect(), QGraphicsLineItem::boundingRect(), QGraphicsItem::collidesWithPath(), QGLLineMaskGenerator::computeScreenRect(), QGLRectMaskGenerator::computeScreenRect(), contains(), QRasterPaintEngine::fillPath(), intersects(), QGraphicsSceneIndex::items(), QRasterizer::rasterize(), QGraphicsSceneIndexPrivate::recursive_items_helper(), and QOpenGLPaintEnginePrivate::strokePathFastPen().
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.
QLinearGradient myGradient; QPen myPen; QPainterPath myPath; myPath.cubicTo(c1, c2, endPoint); QPainter painter(this); painter.setBrush(myGradient); painter.setPen(myPen); painter.drawPath(myPath); |
Definition at line 821 of file qpainterpath.cpp.
Referenced by addEllipse(), QFreetypeFace::addGlyphToPath(), addGlyphToPath(), QDeclarativePathCubic::addToPath(), arcTo(), QOpenGLPaintEngine::clip(), QOutlineMapper::clipElements(), QMacFontPath::cubicTo(), QPicture::exec(), QPathClipper::handleCrossingEdges(), parsePathDataFast(), pathArcSegment(), qt_painterPathFromVectorPath(), quadTo(), QPainter::setViewTransformEnabled(), and toReversed().
|
inline |
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}).
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 323 of file qpainterpath.h.
QPointF QPainterPath::currentPosition | ( | ) | const |
Returns the current position of the path.
Definition at line 1044 of file qpainterpath.cpp.
|
inlineprivate |
Definition at line 221 of file qpainterpath.h.
Referenced by addEllipse(), addPath(), addPolygon(), addRect(), addRegion(), boundingRect(), closeSubpath(), connectPath(), contains(), controlPointRect(), QVectorPath::convertToPainterPath(), cubicTo(), currentPosition(), detach_helper(), fillRule(), lineTo(), moveTo(), operator<<(), operator=(), operator==(), operator>>(), QPainterPath(), qtVectorPathForPath(), setFillRule(), and translate().
|
inlineprivate |
Definition at line 420 of file qpainterpath.h.
Referenced by addEllipse(), addPath(), addPolygon(), addRect(), addRegion(), addText(), arcTo(), closeSubpath(), connectPath(), cubicTo(), lineTo(), QMatrix::map(), QTransform::map(), moveTo(), quadTo(), setFillRule(), and translate().
|
private |
Definition at line 597 of file qpainterpath.cpp.
|
inline |
Returns the element at the given index in the painter path.
Definition at line 402 of file qpainterpath.h.
Referenced by addGlyphToPath(), addLineTo(), QPathSegments::addPath(), bezierAtT(), charString(), QWin32PrintEnginePrivate::composeGdiPath(), contains(), QOutlineMapper::convertPath(), convertPath(), QX11PaintEngine::drawFreetype(), QSvgPaintEngine::drawPath(), QDirectFBPaintEngine::fill(), QPdf::generatePath(), QGLLineMaskGenerator::generateTrapezoids(), QGLRectMaskGenerator::generateTrapezoids(), QGLStrokeCache::getStrokedPath(), QPathClipper::handleCrossingEdges(), QGLMaskTextureCache::hash(), intersects(), QGraphicsSceneIndexPrivate::itemCollidesWithPath(), mapProjective(), nextBezier(), operator<<(), QVGPaintEnginePrivate::painterPathToVGPath(), pathClosed(), QPathClipper::pathToRect(), QOpenGLPaintEnginePrivate::pathToVertexArrays(), qt_find_ellipse_coords(), qt_ft_outline_cubic_to(), qt_mac_compose_path(), qt_painterpath_check_crossing(), qt_vg_pathToRect(), QRasterizer::rasterize(), QStrokerOps::strokePath(), and QOpenGLPaintEnginePrivate::strokePathFastPen().
|
inline |
Returns the number of path elements in the painter path.
Definition at line 397 of file qpainterpath.h.
Referenced by addGlyphToPath(), addLineTo(), QPathSegments::addPath(), bezierAtT(), charString(), QWin32PrintEnginePrivate::composeGdiPath(), contains(), QOutlineMapper::convertPath(), convertPath(), QX11PaintEngine::drawFreetype(), QSvgPaintEngine::drawPath(), QPainter::drawPath(), generateGlyph(), QPdf::generatePath(), QGLLineMaskGenerator::generateTrapezoids(), QGLRectMaskGenerator::generateTrapezoids(), QGLStrokeCache::getStrokedPath(), QPathClipper::handleCrossingEdges(), QGLMaskTextureCache::hash(), intersects(), QMatrix::map(), QTransform::map(), mapProjective(), nextBezier(), operator<<(), QVGPaintEnginePrivate::painterPathToVGPath(), pathClosed(), QPathClipper::pathToRect(), QOpenGLPaintEnginePrivate::pathToVertexArrays(), qt_find_ellipse_coords(), qt_ft_outline_cubic_to(), qt_mac_compose_path(), qt_painterpath_check_crossing(), qt_vg_pathToRect(), quadTo(), QRasterizer::rasterize(), QPainter::setClipPath(), QStrokerOps::strokePath(), QOpenGLPaintEnginePrivate::strokePathFastPen(), and toSubpathPolygons().
|
inlineprivate |
Definition at line 213 of file qpainterpath.h.
Referenced by addEllipse(), addPath(), addPolygon(), addRect(), addRegion(), addText(), arcTo(), connectPath(), QVectorPath::convertToPainterPath(), cubicTo(), lineTo(), moveTo(), operator>>(), quadTo(), and setFillRule().
|
private |
Definition at line 606 of file qpainterpath.cpp.
Qt::FillRule QPainterPath::fillRule | ( | ) | const |
Returns the painter path's currently set fill rule.
Definition at line 1384 of file qpainterpath.cpp.
Referenced by QPathClipper::clip(), QOpenGLPaintEngine::clip(), QPainter::clipRegion(), QWin32PrintEnginePrivate::composeGdiPath(), contains(), QOutlineMapper::convertPath(), QCoreGraphicsPaintEngine::drawPath(), QVGPaintEngine::drawPath(), QSvgPaintEngine::drawPath(), QRasterPaintEngine::fillPath(), QX11PaintEnginePrivate::fillPath(), QOpenGLPaintEnginePrivate::fillPath(), QPdf::generatePath(), QGLPathMaskGenerator::generateTrapezoids(), mapProjective(), operator>>(), QPathClipper::QPathClipper(), setFillRule(), QCoreGraphicsPaintEngine::updateClipPath(), QX11PaintEngine::updateState(), and QOpenGLPaintEngine::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 3425 of file qpainterpath.cpp.
Referenced by QOutlineMapper::clipElements(), QGraphicsItem::clipPath(), QX11PaintEnginePrivate::fillPath(), QPolygon::intersected(), QPolygonF::intersected(), operator!=(), and QPdfBaseEngine::updateClipPath().
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 2134 of file qpainterpath.cpp.
Referenced by QGraphicsItem::collidesWithPath(), QGraphicsSceneIndexPathIntersector::intersect(), and QGraphicsSceneIndexPrivate::itemCollidesWithPath().
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 3504 of file qpainterpath.cpp.
|
inline |
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 392 of file qpainterpath.h.
Referenced by addPath(), QTextureGlyphCache::calculateSubPixelPositionCount(), QPaintEngineEx::clip(), QOutlineMapper::clipElements(), QGraphicsItem::clipPath(), closeSubpath(), QGraphicsItem::collidesWithPath(), connectPath(), contains(), QOutlineMapper::convertPath(), QPainterPathStroker::createStroke(), QTextLayout::draw(), QPainterPrivate::draw_helper(), QRenderRule::drawBackground(), QX11PaintEngine::drawPath(), QOpenGLPaintEngine::drawPath(), QPaintEngineEx::drawPath(), QPaintEngine::drawRects(), QPaintEngineEx::drawStaticTextItem(), QPaintEngine::drawTextItem(), QPainter::fillPath(), QOpenGLPaintEnginePrivate::fillPath(), fillRule(), QVGFontEngineCleaner::fontEngineDestroyed(), QPathClipper::handleCrossingEdges(), intersected(), intersects(), QMatrix::map(), operator<<(), QGraphicsPathItem::QGraphicsPathItem(), qt_mac_compose_path(), QRasterizer::rasterize(), QRenderRule::setClip(), QStrokerOps::strokePath(), QWin32PrintEnginePrivate::strokePath(), QPainter::strokePath(), subtracted(), toReversed(), toSubpathPolygons(), united(), QRenderRule::unsetClip(), QWin32PrintEngine::updateClipPath(), QCoreGraphicsPaintEngine::updateClipPath(), and QPdfBaseEngine::updateClipPath().
qreal QPainterPath::length | ( | ) | const |
Returns the length of the current path.
Definition at line 2930 of file qpainterpath.cpp.
Referenced by bezierAtT().
void QPainterPath::lineTo | ( | const QPointF & | endPoint | ) |
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 758 of file qpainterpath.cpp.
Referenced by QFreetypeFace::addGlyphToPath(), addGlyphToPath(), addLineTo(), QDeclarativePathLine::addToPath(), arcTo(), QBalloonTip::balloon(), QRenderRule::borderClip(), QSvgLine::bounds(), QOpenGLPaintEngine::clip(), QOutlineMapper::clipElements(), collectSingleContour(), QPainter::drawChord(), QPlastiqueStyle::drawComplexControl(), QPainter::drawConvexPolygon(), QOpenGLPaintEnginePrivate::drawFastRect(), QX11PaintEngine::drawLines(), QOpenGLPaintEngine::drawLines(), QPdfBaseEngine::drawLines(), QPainter::drawLines(), QX11PaintEngine::drawPoints(), QPdfBaseEngine::drawPoints(), QPainter::drawPoints(), QWin32PrintEngine::drawPolygon(), QX11PaintEngine::drawPolygon(), QOpenGLPaintEngine::drawPolygon(), QSvgPaintEngine::drawPolygon(), QPdfBaseEngine::drawPolygon(), QPainter::drawPolygon(), QPainter::drawPolyline(), QWindowsCEStyle::drawPrimitive(), QCommonStyle::drawPrimitive(), QWindowsMobileStyle::drawPrimitive(), QMacStyle::drawPrimitive(), QPathClipper::handleCrossingEdges(), QRegion::intersects(), QMacFontPath::lineTo(), lineTo_clipped(), parsePathDataFast(), qt_painterPathFromVectorPath(), QGraphicsLineItem::shape(), and toReversed().
Draws a line from the current position to the point ({x}, {y}).
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 308 of file qpainterpath.h.
void QPainterPath::moveTo | ( | const QPointF & | point | ) |
Moves the current point to the given point, implicitly starting a new subpath and closing the previous one.
Definition at line 702 of file qpainterpath.cpp.
Referenced by add(), addEllipse(), QFreetypeFace::addGlyphToPath(), addGlyphToPath(), addPolygon(), addRect(), arcMoveTo(), QBalloonTip::balloon(), QRenderRule::borderClip(), QSvgLine::bounds(), QOpenGLPaintEngine::clip(), QOutlineMapper::clipElements(), collectSingleContour(), QPainter::drawChord(), QPlastiqueStyle::drawComplexControl(), QOpenGLPaintEnginePrivate::drawFastRect(), QOpenGLPaintEngine::drawLines(), QPdfBaseEngine::drawLines(), QPainter::drawLines(), QPainter::drawPie(), QX11PaintEngine::drawPoints(), QPdfBaseEngine::drawPoints(), QPainter::drawPoints(), QOpenGLPaintEngine::drawPolygon(), QPdfBaseEngine::drawPolygon(), QWindowsCEStyle::drawPrimitive(), QCommonStyle::drawPrimitive(), QWindowsMobileStyle::drawPrimitive(), QMacStyle::drawPrimitive(), QPicture::exec(), QPathClipper::handleCrossingEdges(), QRegion::intersects(), lineTo_clipped(), QMacFontPath::moveTo(), parsePathDataFast(), qt_painterPathFromVectorPath(), QPainter::setViewTransformEnabled(), QGraphicsEllipseItem::shape(), QGraphicsLineItem::shape(), and toReversed().
Moves the current position to ({x}, {y}) and starts a new subpath, implicitly closing the previous path.
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 303 of file qpainterpath.h.
QPainterPath QPainterPath::operator& | ( | const QPainterPath & | other | ) | const |
Referenced by operator!=().
QPainterPath& QPainterPath::operator&= | ( | const QPainterPath & | other | ) |
Referenced by operator-().
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 2368 of file qpainterpath.cpp.
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 2414 of file qpainterpath.cpp.
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 2475 of file qpainterpath.cpp.
QPainterPath QPainterPath::operator- | ( | const QPainterPath & | other | ) | const |
Subtracts the other path from a copy of this path, and returns the copy.
Definition at line 2429 of file qpainterpath.cpp.
QPainterPath & QPainterPath::operator-= | ( | const QPainterPath & | other | ) |
Subtracts other from this path, and returns a reference to this path.
Definition at line 2491 of file qpainterpath.cpp.
QPainterPath & QPainterPath::operator= | ( | const QPainterPath & | path | ) |
Assigns the given path to this painter path.
Definition at line 626 of file qpainterpath.cpp.
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 2333 of file qpainterpath.cpp.
QPainterPath QPainterPath::operator| | ( | const QPainterPath & | other | ) | const |
Returns the union of this path and the other path.
Definition at line 2398 of file qpainterpath.cpp.
QPainterPath & QPainterPath::operator|= | ( | const QPainterPath & | other | ) |
Unites this path with other and returns a reference to this path.
Definition at line 2459 of file qpainterpath.cpp.
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 2973 of file qpainterpath.cpp.
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 3090 of file qpainterpath.cpp.
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 884 of file qpainterpath.cpp.
Referenced by addGlyphToPath(), QDeclarativePathQuad::addToPath(), generateWavyPixmap(), and parsePathDataFast().
Adds a quadratic Bezier curve between the current point and the endpoint ({endPointX}, {endPointY}) with the control point specified by ({cx}, {cy}).
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 330 of file qpainterpath.h.
|
private |
Definition at line 3539 of file qpainterpath.cpp.
Sets the x and y coordinate of the element at index index to x and y.
Definition at line 409 of file qpainterpath.h.
Referenced by addLineTo().
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:
Qt::OddEvenFill (default) | Qt::WindingFill |
Definition at line 1409 of file qpainterpath.cpp.
Referenced by QOpenGLPaintEngine::clip(), QOutlineMapper::clipElements(), createPathNode(), QPainterPathStroker::createStroke(), createSvgGlyph(), QSvgPath::draw(), QTextLayout::draw(), QTextLine::draw(), QPainter::drawConvexPolygon(), QOpenGLPaintEnginePrivate::drawFastRect(), QOpenGLPaintEngine::drawLines(), QX11PaintEngine::drawPath(), QX11PaintEngine::drawPolygon(), QOpenGLPaintEngine::drawPolygon(), QPdfBaseEngine::drawPolygon(), QPainter::drawPolygon(), QPaintEngineEx::drawStaticTextItem(), QPaintEngine::drawTextItem(), mapProjective(), path_for_glyphs(), qt_painterPathFromVectorPath(), and strokeForPath().
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 3482 of file qpainterpath.cpp.
Referenced by QPathClipper::clip().
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 3156 of file qpainterpath.cpp.
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 3446 of file qpainterpath.cpp.
Referenced by QGraphicsTextItemPrivate::_q_mouseOnEdge(), operator-(), QPolygon::subtracted(), QPolygonF::subtracted(), subtractedInverted(), and QPdfBaseEngine::updateClipPath().
QPainterPath QPainterPath::subtractedInverted | ( | const QPainterPath & | p | ) | const |
Use subtracted() instead.
Definition at line 3465 of file qpainterpath.cpp.
|
inline |
Swaps painter path other with this painter path.
This operation is very fast and never fails.
Definition at line 103 of file qpainterpath.h.
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 2915 of file qpainterpath.cpp.
Referenced by QOpenGLPaintEngine::clip(), clipTransformIsSimple(), QGLPathMaskGenerator::computeScreenRect(), QPaintEngine::drawEllipse(), QOpenGLPaintEnginePrivate::fillPath(), QPolygon::intersected(), QPolygonF::intersected(), QMatrix::map(), QTransform::map(), QmlJSDebugger::regionToPolygon(), QPolygon::subtracted(), QPolygonF::subtracted(), QX11PaintEnginePrivate::systemStateChanged(), QPolygon::united(), QPolygonF::united(), QCoreGraphicsPaintEngine::updateClipPath(), QX11PaintEngine::updateState(), and QOpenGLPaintEngine::updateState().
QPolygonF QPainterPath::toFillPolygon | ( | const QTransform & | matrix | ) | 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 2894 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.
Definition at line 1808 of file qpainterpath.cpp.
Referenced by QX11PaintEnginePrivate::fillPath().
QList< QPolygonF > QPainterPath::toFillPolygons | ( | const QTransform & | matrix | ) | 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 1710 of file qpainterpath.cpp.
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 1581 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.
Definition at line 1683 of file qpainterpath.cpp.
Referenced by QX11PaintEngine::drawPath(), QRegion::QRegion(), qt_bitmapToRegion(), and toFillPolygons().
QList< QPolygonF > QPainterPath::toSubpathPolygons | ( | const QTransform & | matrix | ) | 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 1635 of file qpainterpath.cpp.
Translates all elements in the path by ({dx}, {dy}).
Definition at line 2177 of file qpainterpath.cpp.
Referenced by QGraphicsView::fitInView(), QGraphicsSceneIndexRectIntersector::intersect(), QTransform::map(), and translated().
|
inline |
Translates all elements in the path by the given offset.
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 386 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 2215 of file qpainterpath.cpp.
Referenced by QGraphicsItem::mapFromParent(), QGraphicsItem::mapFromScene(), QGraphicsItem::mapToParent(), QGraphicsItem::mapToScene(), and QGraphicsSceneIndexPrivate::recursive_items_helper().
|
inline |
Returns a copy of the path that is translated by the given offset.
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 389 of file qpainterpath.h.
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 3407 of file qpainterpath.cpp.
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 2509 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 2539 of file qpainterpath.cpp.
Definition at line 226 of file qpainterpath.h.
|
friend |
Definition at line 223 of file qpainterpath.h.
Referenced by detach_helper(), and ensureData_helper().
|
friend |
Definition at line 224 of file qpainterpath.h.
|
friend |
Definition at line 225 of file qpainterpath.h.
|
friend |
Definition at line 227 of file qpainterpath.h.
Referenced by toFillPolygons(), and toSubpathPolygons().
|
friend |
Definition at line 129 of file qpaintengineex.cpp.
|
friend |
Definition at line 228 of file qpainterpath.h.
|
private |
Definition at line 211 of file qpainterpath.h.
Referenced by boundingRect(), controlPointRect(), currentPosition(), detach_helper(), ensureData_helper(), QMatrix::map(), QTransform::map(), QPainterPath::Element::operator!=(), operator=(), QPainterPath(), swap(), and translate().