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


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

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


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

示例1: updateTextPath

void ArcItem::updateTextPath() {
	QPainterPath path;
	if((_endItem && _startItem->collidesWithItem(_endItem)) ||
	   (!_endItem && _startItem->contains(_end)))
		return;
	QPointF start(0,0),
			point = _end - pos();

	//The arrow line and reverse liune
	QLineF line(start, point);
	QLineF revline(point, start);

	//Make some text
	if(this->weight() != 1){
		QFont font;
		font.setPointSizeF(6);
		path.addText(QPointF(0,0), font, QString::number(this->weight()));
		//Move it into some reasonable position
		path.translate(-path.boundingRect().width()/2, -3);
		QTransform rotation;
		qreal angle = line.angle();
		if(angle > 90 && angle < 270)
			angle = 180 - angle;
		else
			angle = 360 - angle;
		rotation.rotate(angle);

		path = rotation.map(path);
		path.translate(point/2);
	}
	_cachedTextPath = path;
}
开发者ID:jonasfj,项目名称:PeTe,代码行数:32,代码来源:ArcItem.cpp

示例2: draw

void ChordLine::draw(QPainter* painter) const
      {
      qreal _spatium = spatium();

      if (this->isStraight()) {
            painter->scale(_spatium, _spatium);
            painter->setPen(QPen(curColor(), .15, Qt::SolidLine));
            painter->setBrush(Qt::NoBrush);

            QPainterPath pathOffset = path;
            float offset = 0.5;

            if (_chordLineType == ChordLineType::FALL)
                  pathOffset.translate(offset, -offset);
            else if (_chordLineType == ChordLineType::DOIT)
                  pathOffset.translate(offset, offset);
            else if (_chordLineType == ChordLineType::SCOOP)
                  pathOffset.translate(-offset, offset);
            else if (_chordLineType == ChordLineType::PLOP)
                  pathOffset.translate(-offset, -offset);

            painter->drawPath(pathOffset);
            painter->scale(1.0/_spatium, 1.0/_spatium);
            }
      else  {
            painter->scale(_spatium, _spatium);
            painter->setPen(QPen(curColor(), .15, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
            painter->setBrush(Qt::NoBrush);
            painter->drawPath(path);
            painter->scale(1.0/_spatium, 1.0/_spatium);
            }
      }
开发者ID:Tarkiyah,项目名称:MuseScore,代码行数:32,代码来源:chordline.cpp

示例3: metrics

    PlainTextItem(QString text, QFont font, double width, double height, QBrush brush, QColor outlineColor, double outline, int align, int lineSpacing)
    {
        m_boundingRect = QRectF(0, 0, width, height);
        m_brush = brush;
        m_outline = outline;
        m_pen = QPen(outlineColor);
        m_pen.setWidthF(outline);
        QFontMetrics metrics(font);
        lineSpacing += metrics.lineSpacing();

        // Calculate line width
        QStringList lines = text.split('\n');
        double linePos = metrics.ascent();
        foreach(const QString &line, lines)
        {
                QPainterPath linePath;
                linePath.addText(0, linePos, font, line);
                linePos += lineSpacing;
                if ( align == Qt::AlignHCenter )
                {
                        double offset = (width - metrics.width(line)) / 2;
                        linePath.translate(offset, 0);
                } else if ( align == Qt::AlignRight ) {
                        double offset = (width - metrics.width(line));
                        linePath.translate(offset, 0);
                }
                m_path = m_path.united(linePath);
        }
开发者ID:vpinon,项目名称:mlt,代码行数:28,代码来源:kdenlivetitle_wrapper.cpp

示例4: paintMeshElToBeHigh

void EditorArea::paintMeshElToBeHigh(QPainter &painter)
{
    qreal radius = size2screen(8);
    float fontSize = size2screen(12);

    qreal width = radius * 2;
    qreal height = radius * 2;

    QPainterPath path;
    QPainterPath text;
    QPainterPath circle;

    path.arcTo(QRectF(-radius, -radius, width, height), 0, 360);
    text.addText(-radius / 2.0, radius / 2.0, QFont("Arial", fontSize), meshElsType.value(meshElToBeHigh));
    circle.arcTo(QRectF(-radius * 3 / 2, -radius * 3 / 2, width * 3 / 2, height * 3 / 2), 0, 360);
    path.translate(meshElsPos.value(meshElToBeHigh));
    text.translate(meshElsPos.value(meshElToBeHigh));
    circle.translate(meshElsPos.value(meshElToBeHigh));

    painter.setPen(Qt::NoPen);
    painter.setBrush(Qt::magenta);
    painter.drawPath(circle);
    painter.setBrush(Qt::darkCyan);
    painter.drawPath(path);
    painter.setPen(Qt::yellow);
    painter.setBrush(Qt::yellow);
    painter.drawPath(text);
}
开发者ID:archTk,项目名称:arch-ne,代码行数:28,代码来源:editorarea.cpp

示例5: updateShadow

void MyTextItem::updateShadow()
{
    QString text = toPlainText();
    if (text.isEmpty()) {
        m_shadow = QImage();
        return;
    }
    QFontMetrics metrics(font());
    //ADJUST TO CURRENT SETTING
    int lineSpacing = data(TitleDocument::LineSpacing).toInt() + metrics.lineSpacing();
    QPainterPath path;

    // Calculate line width
    QStringList lines = text.split('\n');
    double linePos = metrics.ascent();
    QRectF bounding = boundingRect();
    foreach(const QString &line, lines)
    {
        QPainterPath linePath;
        linePath.addText(0, linePos, font(), line);
        linePos += lineSpacing;
        if ( m_alignment == Qt::AlignHCenter ) {
            double offset = (bounding.width() - metrics.width(line)) / 2;
            linePath.translate(offset, 0);
        } else if ( m_alignment == Qt::AlignRight ) {
            double offset = (bounding.width() - metrics.width(line));
            linePath.translate(offset, 0);
        }
        path.addPath(linePath);
    }
开发者ID:yiqideren,项目名称:kdenlive,代码行数:30,代码来源:graphicsscenerectmove.cpp

示例6: path

QPainterPath LineBand::path()
{
	//move the path so it accounts for the position of the selectionband
	QPainterPath temppath = mIntersectionPath;
	temppath.translate(getTopLeft());
	return temppath;
}
开发者ID:DoubleYouEl,项目名称:CrochetCharts,代码行数:7,代码来源:selectionband.cpp

示例7: drawArrow

void MapView::drawArrow(QPainter &painter, const QPoint &p)
{
    QPainterPath path;

    path.moveTo(0, 0);
    path.lineTo(1, 0);
    path.lineTo(7, 15);
    path.lineTo(0, 10);
    path.lineTo(-7, 15);
    path.lineTo(0, 0);

    path.translate(p);
    path.translate(0, 2);

    painter.fillPath(path, QBrush(Qt::yellow));
}
开发者ID:vkholodkov,项目名称:freestars,代码行数:16,代码来源:map_view.cpp

示例8: createArrow

static QPainterPath createArrow()
{
    const qreal arrowHeadPos = 10;
    const qreal arrowHeadLength = 4;
    const qreal arrowHeadWidth = 4;
    const qreal arcWidth = 2;
    const qreal outerArcSize = arrowHeadPos + arcWidth - arrowHeadLength;
    const qreal innerArcSize = arrowHeadPos - arcWidth - arrowHeadLength;

    QPainterPath path;
    path.moveTo(arrowHeadPos, 0);
    path.lineTo(arrowHeadPos + arrowHeadWidth, arrowHeadLength);
    path.lineTo(arrowHeadPos + arcWidth, arrowHeadLength);
    path.arcTo(QRectF(arrowHeadLength - outerArcSize,
                      arrowHeadLength - outerArcSize,
                      outerArcSize * 2,
                      outerArcSize * 2),
               0, -90);
    path.lineTo(arrowHeadLength, arrowHeadPos + arrowHeadWidth);
    path.lineTo(0, arrowHeadPos);
    path.lineTo(arrowHeadLength, arrowHeadPos - arrowHeadWidth);
    path.lineTo(arrowHeadLength, arrowHeadPos - arcWidth);
    path.arcTo(QRectF(arrowHeadLength - innerArcSize,
                      arrowHeadLength - innerArcSize,
                      innerArcSize * 2,
                      innerArcSize * 2),
               -90, 90);
    path.lineTo(arrowHeadPos - arrowHeadWidth, arrowHeadLength);
    path.closeSubpath();

    path.translate(-3, -3);

    return path;
}
开发者ID:bradley45,项目名称:tiled,代码行数:34,代码来源:objectselectiontool.cpp

示例9: updateShapeCache

void TopologyNode::updateShapeCache()
{
    QPainterPath    shapePath;
    QString         imagePath;

#ifdef PLUGIN_TARGET
    if(mNodeFlags & NF_ISCENTRALROUTER)
    {
        Q_ASSERT (m_paintStrategy);
        imagePath = m_paintStrategy->getImageName();
    }
    else
#endif
    {
#ifdef POWERLINE_REVISION
        if(m_isPowerLine)
        {
            imagePath = GENIE2_RES("map/devices/PowerLineNormal.png");
        }
        else
#endif
        {
            imagePath = getDeviceTypeImagePath(m_deviceType,DTIR_NORMAL);
        }
    }

    QPixmap pixDetecter(imagePath);
    shapePath.addRegion(QRegion(pixDetecter.mask()));
    shapePath.translate(-pixDetecter.width() / 2,-pixDetecter.height() / 2);

    m_shapePath = shapePath;
}
开发者ID:SiteView,项目名称:GenieMap-Temp-fingerpoint,代码行数:32,代码来源:topologynode.cpp

示例10: RefreshCurve

/**
 * @brief RefreshCurve refresh curve on scene.
 * @param curve curve.
 * @param curveId curve id.
 */
void VToolCutSpline::RefreshCurve(VSimpleCurve *curve, quint32 curveId, SimpleCurvePoint curvePosition,
                                  PathDirection direction)
{
    const QSharedPointer<VSpline> spl = VAbstractTool::data.GeometricObject<VSpline>(curveId);
    QPainterPath path;
    path.addPath(spl->GetPath(direction));
    path.setFillRule( Qt::WindingFill );
    if (curvePosition == SimpleCurvePoint::FirstPoint)
    {
        path.translate(-spl->GetP1().toQPointF().x(), -spl->GetP1().toQPointF().y());
    }
    else
    {
        path.translate(-spl->GetP4().toQPointF().x(), -spl->GetP4().toQPointF().y());
    }
    curve->setPath(path);
}
开发者ID:a-dilla,项目名称:Valentina,代码行数:22,代码来源:vtoolcutspline.cpp

示例11: paintEvent

void ToolButton::paintEvent(QPaintEvent *) {
  QPainter p(this);
  p.setRenderHint(QPainter::Antialiasing);
  p.setPen(Qt::black);
  p.setBrush(_flashBackground != Qt::lightGray
      ? _flashBackground
      : _mousePressPoint.isNull()
        ? (_mouseCurrentlyOver ? Qt::darkGray : Qt::lightGray)
        : Qt::white);
  p.drawRoundedRect(rect(), 20, 20, Qt::RelativeSize);
  if (_tool) {
    p.drawPixmap(2, 2, _tool->icon()
                 .pixmap(iconSize(), _currentlyTriggerable
                         ? QIcon::Normal : QIcon::Disabled));
  }
  if (!_keyLabel.isNull()) {
    QPainterPath pp;
    QFont font = this->font();
    //QFont font("Sans");
    //font.setPointSize(10);
    pp.addText(QPointF(0, 0), font, _keyLabel);
    pp.translate(width()-2-pp.boundingRect().width()-pp.boundingRect().x(),
                 height()-2-pp.boundingRect().height()-pp.boundingRect().y());
    p.setRenderHint(QPainter::Antialiasing);
    // LATER parametrize outline and main letter colors
    p.setBrush(Qt::white);
    p.setPen(Qt::white);
    p.drawPath(pp);
    p.setBrush(Qt::darkBlue);
    p.setPen(Qt::transparent);
    p.drawPath(pp);
  }
  // LATER use icon rather than text as target indicator
  QString targetIndicator("?");
  switch (_targetType) {
  case TargetManager::PrimaryTarget:
    targetIndicator = QString();
    break;
  case TargetManager::PreviousPrimaryTarget:
    targetIndicator = "p";
    break;
  case TargetManager::MouseOverTarget:
    targetIndicator = "o";
    break;
  }
  if (!targetIndicator.isEmpty()) {
    QFont font = this->font();
    //font.setPointSize(10);
    p.setFont(font);
    p.setPen(Qt::black);
    QFontMetrics fm(font);
    p.drawText(QRectF(2, height()-2-fm.height(), width()-4, fm.maxWidth()),
               Qt::AlignLeft, targetIndicator);
  }
  p.end();
}
开发者ID:g76r,项目名称:libh6ncsu,代码行数:56,代码来源:toolbutton.cpp

示例12: paintNodes

void EditorArea::paintNodes(QPainter &painter)
{
    bool firstTime = true;

    qreal radius = size2screen(6);
    qreal width = radius * 2;
    qreal height = radius * 2;

    QVector<int> nodesIds = workspace->getNodesIds();

    for (int i=0; i < nodesIds.size(); i++) {
        QPointF screenXY = graph2screen(workspace->getNodePosition(nodesIds[i]));

        if (workspace->getNodeMov(nodesIds[i])) {
            painter.setPen(Qt::NoPen);
        } else {
            painter.setPen(QPen(Qt::darkRed, size2screen(3), Qt::SolidLine,
                               Qt::RoundCap, Qt::RoundJoin));
        }

        QPainterPath path;
        path.arcTo(QRectF(-radius, -radius, width, height), 0, 360);
        path.translate(screenXY);
        painter.drawPath(path);

        QPainterPath mousePath;
        mousePath.arcTo(QRectF(-5, -5, 10, 10), 0, 360);
        mousePath.translate(mouseCurrentPos);

        if (path.intersects(mousePath)) {
            if (firstTime) {
                firstTime = false;
                hitElements.clear();
            }
            QPoint temp(1, nodesIds[i]);
            hitElements.append(temp);
        }
    }
}
开发者ID:archTk,项目名称:arch-ne,代码行数:39,代码来源:editorarea.cpp

示例13: brushOutline

QPainterPath KisChalkPaintOpSettings::brushOutline(const QPointF& pos, KisPaintOpSettings::OutlineMode mode, qreal scale, qreal rotation) const
{
    Q_UNUSED(scale);
    Q_UNUSED(rotation);
    QPainterPath path;
    if (mode == CursorIsOutline){
        qreal size = getInt(CHALK_RADIUS) * 2 + 1;
        QRectF rc(0, 0, size, size);
        rc.translate(-rc.center());
        path.addEllipse(rc);
        path.translate(pos);
    }
    return path;
}
开发者ID:KDE,项目名称:calligra-history,代码行数:14,代码来源:kis_chalk_paintop_settings.cpp

示例14: 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

示例15: shape

QPainterPath MapObjectItem::shape() const
{
    QPainterPath path = mMapDocument->renderer()->shape(mObject);
#if QT_VERSION >= 0x040600
    path.translate(-pos());
#else
    const QPointF p = pos();
    const int elementCount = path.elementCount();
    for (int i = 0; i < elementCount; i++) {
        const QPainterPath::Element &element = path.elementAt(i);
        path.setElementPositionAt(i, element.x - p.x(), element.y - p.y());
    }
#endif
    return path;
}
开发者ID:KaraJ,项目名称:conpenguum,代码行数:15,代码来源:mapobjectitem.cpp


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