当前位置: 首页>>代码示例>>C++>>正文


C++ QPainterPath::translated方法代码示例

本文整理汇总了C++中QPainterPath::translated方法的典型用法代码示例。如果您正苦于以下问题:C++ QPainterPath::translated方法的具体用法?C++ QPainterPath::translated怎么用?C++ QPainterPath::translated使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QPainterPath的用法示例。


在下文中一共展示了QPainterPath::translated方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: brushOutline

QPainterPath KisDuplicateOpSettings::brushOutline(const QPointF& pos, KisPaintOpSettings::OutlineMode mode, qreal scale, qreal rotation) const
{
    QPainterPath path; 
    path = KisBrushBasedPaintOpSettings::brushOutline(QPointF(0.0,0.0),KisPaintOpSettings::CursorIsOutline, scale, rotation);
    
    QPainterPath copy(path);
    QRectF rect2 = copy.boundingRect();
    if (m_isOffsetNotUptodate) {
        copy.translate(m_position - pos);
    } else {
        copy.translate(-m_offset);
    }
    
    path.addPath(copy);
    
    QTransform m;
    m.scale(0.5,0.5);
    rect2 = m.mapRect(rect2);
    
    path.moveTo(rect2.topLeft());
    path.lineTo(rect2.bottomRight());
    
    path.moveTo(rect2.topRight());
    path.lineTo(rect2.bottomLeft());
    
    if (mode == CursorIsOutline){
        return path.translated(pos);
    } else {
        // workaround?
        //copy.addEllipse(QRectF(0,0,1,1));
        return copy.translated(pos);
    }
}
开发者ID:KDE,项目名称:calligra-history,代码行数:33,代码来源:kis_duplicateop_settings.cpp

示例2: translate

void tst_QPainterPath::translate()
{
    QPainterPath path;

    // Path with no elements.
    QCOMPARE(path.currentPosition(), QPointF());
    path.translate(50.5, 50.5);
    QCOMPARE(path.currentPosition(), QPointF());
    QCOMPARE(path.translated(50.5, 50.5).currentPosition(), QPointF());

    // path.isEmpty(), but we have one MoveTo element that should be translated.
    path.moveTo(50, 50);
    QCOMPARE(path.currentPosition(), QPointF(50, 50));
    path.translate(99.9, 99.9);
    QCOMPARE(path.currentPosition(), QPointF(149.9, 149.9));
    path.translate(-99.9, -99.9);
    QCOMPARE(path.currentPosition(), QPointF(50, 50));
    QCOMPARE(path.translated(-50, -50).currentPosition(), QPointF(0, 0));

    // Complex path.
    QRegion shape(100, 100, 300, 200, QRegion::Ellipse);
    shape -= QRect(225, 175, 50, 50);
    QPainterPath complexPath;
    complexPath.addRegion(shape);
    QVector<QPointF> untranslatedElements;
    for (int i = 0; i < complexPath.elementCount(); ++i)
        untranslatedElements.append(QPointF(complexPath.elementAt(i)));

    const QPainterPath untranslatedComplexPath(complexPath);
    const QPointF offset(100, 100);
    complexPath.translate(offset);

    for (int i = 0; i < complexPath.elementCount(); ++i)
        QCOMPARE(QPointF(complexPath.elementAt(i)) - offset, untranslatedElements.at(i));

    QCOMPARE(complexPath.translated(-offset), untranslatedComplexPath);
}
开发者ID:kuailexs,项目名称:symbiandump-mw3,代码行数:37,代码来源:tst_qpainterpath.cpp

示例3: intersect_path

    static bool intersect_path(const QGraphicsItem *item, const QRectF &exposeRect, Qt::ItemSelectionMode mode,
                               const QTransform &deviceTransform, const void *intersectData)
    {
        const QPainterPath scenePath = *static_cast<const QPainterPath *>(intersectData);

        QRectF brect = item->boundingRect();
        _q_adjustRect(&brect);

        // ### Add test for this (without making things slower?)
        Q_UNUSED(exposeRect);

        bool keep = true;
        const QGraphicsItemPrivate *itemd = QGraphicsItemPrivate::get(item);
        if (itemd->itemIsUntransformable()) {
            // Untransformable items; map the scene rect to item coordinates.
            const QTransform transform = item->deviceTransform(deviceTransform);
            QPainterPath itemPath = (deviceTransform * transform.inverted()).map(scenePath);
            if (mode == Qt::ContainsItemShape || mode == Qt::ContainsItemBoundingRect)
                keep = itemPath.contains(brect);
            else
                keep = itemPath.intersects(brect);
            if (keep && (mode == Qt::ContainsItemShape || mode == Qt::IntersectsItemShape))
                keep = QGraphicsSceneIndexPrivate::itemCollidesWithPath(item, itemPath, mode);
        } else {
            Q_ASSERT(!itemd->dirtySceneTransform);
            const QRectF itemSceneBoundingRect = itemd->sceneTransformTranslateOnly
                                               ? brect.translated(itemd->sceneTransform.dx(),
                                                                  itemd->sceneTransform.dy())
                                               : itemd->sceneTransform.mapRect(brect);
            if (mode == Qt::ContainsItemShape || mode == Qt::ContainsItemBoundingRect)
                keep = scenePath.contains(itemSceneBoundingRect);
            else
                keep = scenePath.intersects(itemSceneBoundingRect);
            if (keep && (mode == Qt::ContainsItemShape || mode == Qt::IntersectsItemShape)) {
                QPainterPath itemPath = itemd->sceneTransformTranslateOnly
                                      ? scenePath.translated(-itemd->sceneTransform.dx(),
                                                             -itemd->sceneTransform.dy())
                                      : itemd->sceneTransform.inverted().map(scenePath);
                keep = QGraphicsSceneIndexPrivate::itemCollidesWithPath(item, itemPath, mode);
            }
        }
        return keep;
    }
开发者ID:3163504123,项目名称:phantomjs,代码行数:43,代码来源:qgraphicssceneindex.cpp

示例4: strokeImage

QImage
StrokeTool::paintStroke(PaintCanvas *canvas) {
    QPainterPath path;
    path = strokePathCubic(m_pStrokePoints);
    mRefreshRect = path.controlPointRect().toRect()
                   .adjusted(-mPen.width(), -mPen.width(), mPen.width(), mPen.width());

    QImage strokeImage(mRefreshRect.size(), QImage::Format_ARGB32_Premultiplied);
    strokeImage.setOffset(mRefreshRect.topLeft());
    strokeImage.fill(0);

    mPainter.begin(&strokeImage);
    mPainter.setRenderHint(QPainter::Antialiasing, true);
    mPainter.setPen(mPen);
    mPainter.drawPath(path.translated(-mRefreshRect.topLeft()));
    mPainter.end();

    mPainter.begin(canvas->editImage());
    mPainter.drawImage(mRefreshRect, strokeImage);
    mPainter.end();

    refreshCanvas(canvas);
    return strokeImage;
}
开发者ID:hadesain,项目名称:kelir,代码行数:24,代码来源:stroketool.cpp

示例5: paintEvent


//.........这里部分代码省略.........
      HistoryFailed,

      UsageCount,
    };

    const QColor colors[UsageCount] = {
        // read
        QColor(Qt::red),
        // write
        QColor(Qt::green),
        // read/write
        QColor(Qt::yellow),
        // clear
        QColor(Qt::blue),
        // barrier
        QColor(Qt::magenta),

        // pass
        QColor(Qt::green),
        // fail
        QColor(Qt::red),
    };

    // draw the key
    if(m_HistoryTarget.isEmpty())
    {
      // advance past the first text to draw the key
      highlightLabel.setLeft(highlightLabel.left() + fm.width(text));

      text = lit(" Reads ( ");
      p.drawText(highlightLabel, text, to);
      highlightLabel.setLeft(highlightLabel.left() + fm.width(text));

      QPainterPath path = triangle.translated(aliasAlign(highlightLabel.topLeft()));
      p.fillPath(path, colors[ReadUsage]);
      p.drawPath(path);
      highlightLabel.setLeft(highlightLabel.left() + triRadius * 2);

      text = lit(" ), Writes ( ");
      p.drawText(highlightLabel, text, to);
      highlightLabel.setLeft(highlightLabel.left() + fm.width(text));

      path = triangle.translated(aliasAlign(highlightLabel.topLeft()));
      p.fillPath(path, colors[WriteUsage]);
      p.drawPath(path);
      highlightLabel.setLeft(highlightLabel.left() + triRadius * 2);

      text = lit(" ), Read/Write ( ");
      p.drawText(highlightLabel, text, to);
      highlightLabel.setLeft(highlightLabel.left() + fm.width(text));

      path = triangle.translated(aliasAlign(highlightLabel.topLeft()));
      p.fillPath(path, colors[ReadWriteUsage]);
      p.drawPath(path);
      highlightLabel.setLeft(highlightLabel.left() + triRadius * 2);

      if(m_Ctx.CurPipelineState().SupportsBarriers())
      {
        text = lit(" ) Barriers ( ");
        p.drawText(highlightLabel, text, to);
        highlightLabel.setLeft(highlightLabel.left() + fm.width(text));

        path = triangle.translated(aliasAlign(highlightLabel.topLeft()));
        p.fillPath(path, colors[BarrierUsage]);
        p.drawPath(path);
        highlightLabel.setLeft(highlightLabel.left() + triRadius * 2);
开发者ID:etnlGD,项目名称:renderdoc,代码行数:67,代码来源:TimelineBar.cpp


注:本文中的QPainterPath::translated方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。