⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qpainterpath.cpp

📁 奇趣公司比较新的qt/emd版本
💻 CPP
📖 第 1 页 / 共 5 页
字号:
    \fn void QPainterPath::arcMoveTo(qreal x, qreal y, qreal width, qreal height, qreal angle)    \overload    \since 4.2    Creates a move to that lies on the arc that occupies the    QRectF(\a x, \a y, \a width, \a height) at \a angle.*//*!    \fn void QPainterPath::arcMoveTo(const QRectF &rectangle, qreal angle)    \since 4.2    Creates a move to that lies on the arc that occupies the given \a    rectangle at \a angle.    Angles are specified in degrees. Clockwise arcs can be specified    using negative angles.    \sa moveTo(), arcTo()*/void QPainterPath::arcMoveTo(const QRectF &rect, qreal angle){    if (rect.isNull())        return;    QPointF pt;    qt_find_ellipse_coords(rect, angle, 0, &pt, 0);    moveTo(pt);}/*!    \fn QPointF QPainterPath::currentPosition() const    Returns the current position of the path.*/QPointF QPainterPath::currentPosition() const{    return !d_ptr || d_func()->elements.isEmpty()        ? QPointF()        : QPointF(d_func()->elements.last().x, d_func()->elements.last().y);}/*!    \fn void QPainterPath::addRect(qreal x, qreal y, qreal width, qreal height)    \overload    Adds a rectangle at position (\a{x}, \a{y}), with the given \a    width and \a height, as a closed subpath.*//*!    \fn void QPainterPath::addRect(const QRectF &rectangle)    Adds the given \a rectangle to this path as a closed subpath.    The \a rectangle is added as a clockwise set of lines. The painter    path's current position after the \a rectangle has been added is    at the top-left corner of the rectangle.    \table 100%    \row    \o \inlineimage qpainterpath-addrectangle.png    \o    \code        QLinearGradient myGradient;        QPen myPen;        QRectF myRectangle;        QPainterPath myPath;        myPath.addRect(myRectangle);        QPainter painter(this);        painter.setBrush(myGradient);        painter.setPen(myPen);        painter.drawPath(myPath);    \endcode    \endtable    \sa addRegion(), lineTo(), {QPainterPath#Composing a    QPainterPath}{Composing a QPainterPath}*/void QPainterPath::addRect(const QRectF &r){#ifndef QT_NO_DEBUG    if (qt_is_nan(r.x()) || qt_is_nan(r.y()) || qt_is_nan(r.width()) || qt_is_nan(r.height()))        qWarning("QPainterPath::addRect: Adding rect where a parameter is NaN, results are undefined");#endif    if (r.isNull())        return;    ensureData();    detach();    d_func()->elements.reserve(d_func()->elements.size() + 5);    moveTo(r.x(), r.y());    Element l1 = { r.x() + r.width(), r.y(), LineToElement };    Element l2 = { r.x() + r.width(), r.y() + r.height(), LineToElement };    Element l3 = { r.x(), r.y() + r.height(), LineToElement };    Element l4 = { r.x(), r.y(), LineToElement };    d_func()->elements << l1 << l2 << l3 << l4;    d_func()->require_moveTo = true;}/*!    Adds the given \a polygon to the path as an (unclosed) subpath.    Note that the current position after the polygon has been added,    is the last point in \a polygon. To draw a line back to the first    point, use the closeSubpath() function.    \table 100%    \row    \o \inlineimage qpainterpath-addpolygon.png    \o    \code        QLinearGradient myGradient;        QPen myPen;        QPolygonF myPolygon;        QPainterPath myPath;        myPath.addPolygon(myPolygon);        QPainter painter(this);        painter.setBrush(myGradient);        painter.setPen(myPen);        painter.drawPath(myPath);    \endcode    \endtable    \sa lineTo(), {QPainterPath#Composing a QPainterPath}{Composing    a QPainterPath}*/void QPainterPath::addPolygon(const QPolygonF &polygon){    if (polygon.isEmpty())        return;    ensureData();    detach();    d_func()->elements.reserve(d_func()->elements.size() + polygon.size());    moveTo(polygon.first());    for (int i=1; i<polygon.size(); ++i) {        Element elm = { polygon.at(i).x(), polygon.at(i).y(), LineToElement };        d_func()->elements << elm;    }}/*!    \fn void QPainterPath::addEllipse(const QRectF &boundingRectangle)    Creates an ellipse within the the specified \a 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    \o \inlineimage qpainterpath-addellipse.png    \o    \code        QLinearGradient myGradient;        QPen myPen;        QRectF boundingRectangle;        QPainterPath myPath;        myPath.addEllipse(boundingRectangle);        QPainter painter(this);        painter.setBrush(myGradient);        painter.setPen(myPen);        painter.drawPath(myPath);    \endcode    \endtable    \sa arcTo(), QPainter::drawEllipse(), {QPainterPath#Composing a    QPainterPath}{Composing a QPainterPath}*/void QPainterPath::addEllipse(const QRectF &boundingRect){#ifndef QT_NO_DEBUG    if (qt_is_nan(boundingRect.x()) || qt_is_nan(boundingRect.y())        || qt_is_nan(boundingRect.width()) || qt_is_nan(boundingRect.height()))        qWarning("QPainterPath::addEllipse: Adding ellipse where a parameter is NaN, results are undefined");#endif    if (boundingRect.isNull())        return;    ensureData();    detach();    Q_D(QPainterPath);    d->elements.reserve(d->elements.size() + 13);    QPointF pts[12];    int point_count;    QPointF start = qt_curves_for_arc(boundingRect, 0, 360, pts, &point_count);    moveTo(start);    cubicTo(pts[0], pts[1], pts[2]);           // 0 -> 270    cubicTo(pts[3], pts[4], pts[5]);           // 270 -> 180    cubicTo(pts[6], pts[7], pts[8]);           // 180 -> 90    cubicTo(pts[9], pts[10], pts[11]);         // 90 - >0    d_func()->require_moveTo = true;}/*!    \fn void QPainterPath::addText(const QPointF &point, const QFont &font, const QString &text)    Adds the given \a text to this path as a set of closed subpaths    created from the \a font supplied. The subpaths are positioned so    that the left end of the text's baseline lies at the specified \a    point.    \table 100%    \row    \o \inlineimage qpainterpath-addtext.png    \o    \code        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);    \endcode    \endtable    \sa QPainter::drawText(), {QPainterPath#Composing a    QPainterPath}{Composing a QPainterPath}*/void QPainterPath::addText(const QPointF &point, const QFont &f, const QString &text){    if (text.isEmpty())        return;    ensureData();    detach();    QTextLayout layout(text, f);    layout.setCacheEnabled(true);    QTextEngine *eng = layout.engine();    layout.beginLayout();    QTextLine line = layout.createLine();    layout.endLayout();    const QScriptLine &sl = eng->lines[0];    if (!sl.length || !eng->layoutData)        return;    int nItems = eng->layoutData->items.size();    qreal x(point.x());    qreal y(point.y());    QVarLengthArray<int> visualOrder(nItems);    QVarLengthArray<uchar> levels(nItems);    for (int i = 0; i < nItems; ++i)        levels[i] = eng->layoutData->items[i].analysis.bidiLevel;    QTextEngine::bidiReorder(nItems, levels.data(), visualOrder.data());    for (int i = 0; i < nItems; ++i) {        int item = visualOrder[i];        QScriptItem &si = eng->layoutData->items[item];        if (!si.isTab && !si.isObject) {            QGlyphLayout *glyphs = eng->glyphs(&si);            QFontEngine *fe = f.d->engineForScript(si.analysis.script);            Q_ASSERT(fe);            fe->addOutlineToPath(x, y, glyphs, si.num_glyphs, this,                                 si.analysis.bidiLevel % 2                                 ? QTextItem::RenderFlags(QTextItem::RightToLeft)                                 : QTextItem::RenderFlags(0));            const qreal lw = fe->lineThickness().toReal();            if (f.d->underline) {                qreal pos = fe->underlinePosition().toReal();                addRect(x, y + pos, si.width.toReal(), lw);            }            if (f.d->overline) {                qreal pos = fe->ascent().toReal() + 1;                addRect(x, y - pos, si.width.toReal(), lw);            }            if (f.d->strikeOut) {                qreal pos = fe->ascent().toReal() / 3;                addRect(x, y - pos, si.width.toReal(), lw);            }        }        x += si.width.toReal();    }}/*!    \fn void QPainterPath::addPath(const QPainterPath &path)    Adds the given \a path to \e this path as a closed subpath.    \sa connectPath(), {QPainterPath#Composing a    QPainterPath}{Composing a QPainterPath}*/void QPainterPath::addPath(const QPainterPath &other){    if (other.isEmpty())        return;    ensureData();    detach();    QPainterPathData *d = reinterpret_cast<QPainterPathData *>(d_func());    // Remove last moveto so we don't get multiple moveto's    if (d->elements.last().type == MoveToElement)        d->elements.remove(d->elements.size()-1);    // Locate where our own current subpath will start after the other path is added.    int cStart = d->elements.size() + other.d_func()->cStart;    d->elements += other.d_func()->elements;    d->cStart = cStart;    d->require_moveTo = other.d_func()->isClosed();}/*!    \fn void QPainterPath::connectPath(const QPainterPath &path)    Connects the given \a path to \e this path by adding a line from the    last element of this path to the first element of the given path.    \sa addPath(), {QPainterPath#Composing a QPainterPath}{Composing    a QPainterPath}*/void QPainterPath::connectPath(const QPainterPath &other){    if (other.isEmpty())        return;    ensureData();    detach();    QPainterPathData *d = reinterpret_cast<QPainterPathData *>(d_func());    // Remove last moveto so we don't get multiple moveto's    if (d->elements.last().type == MoveToElement)        d->elements.remove(d->elements.size()-1);    // Locate where our own current subpath will start after the other path is added.    int cStart = d->elements.size() + other.d_func()->cStart;    int first = d->elements.size();    d->elements += other.d_func()->elements;    d->elements[first].type = LineToElement;    if (cStart != first)        d->cStart = cStart;}/*!    Adds the given \a region to the path by adding each rectangle in    the region as a separate closed subpath.    \sa addRect(), {QPainterPath#Composing a QPainterPath}{Composing    a QPainterPath}*/void QPainterPath::addRegion(const QRegion &region){    ensureData();    detach();    QVector<QRect> rects = region.rects();    d_func()->elements.reserve(rects.size() * 5);    for (int i=0; i<rects.size(); ++i)        addRect(rects.at(i));}/*!    Returns the painter path's currently set fill rule.    \sa setFillRule()*/Qt::FillRule QPainterPath::fillRule() const{    return isEmpty() ? Qt::OddEvenFill : d_func()->fillRule;}/*!    \fn void QPainterPath::setFillRule(Qt::FillRule fillRule)    Sets the fill rule of the painter path to the given \a    fillRule. Qt provides two methods for filling paths:    \table    \row    \o \inlineimage qt-fillrule-oddeven.png    \o \inlineimage qt-fillrule-winding.png    \header    \o Qt::OddEvenFill (default)    \o Qt::WindingFill    \endtable    \sa fillRule()*/void QPainterPath::setFillRule(Qt::FillRule fillRule){    ensureData();    detach();    d_func()->fillRule = fillRule;}#define QT_BEZIER_A(bezier, coord) 3 * (-bezier.coord##1 \                                        + 3*bezier.coord##2 \                                        - 3*bezier.coord##3 \                                        +bezier.coord##4)#define QT_BEZIER_B(bezier, coord) 6 * (bezier.coord##1 \                                        - 2*bezier.coord##2 \                                        + bezier.coord##3)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -