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


C++ QPainterPathStroker::createStroke方法代码示例

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


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

示例1: qwtStrokedPathRect

static QRectF qwtStrokedPathRect( 
    const QPainter *painter, const QPainterPath &path )
{
    QPainterPathStroker stroker;
    stroker.setWidth( painter->pen().widthF() );
    stroker.setCapStyle( painter->pen().capStyle() );
    stroker.setJoinStyle( painter->pen().joinStyle() );
    stroker.setMiterLimit( painter->pen().miterLimit() );

    QRectF rect;
    if ( qwtHasScalablePen( painter ) )
    {
        QPainterPath stroke = stroker.createStroke(path);
        rect = painter->transform().map(stroke).boundingRect();
    }
    else
    {
        QPainterPath mappedPath = painter->transform().map(path);
        mappedPath = stroker.createStroke( mappedPath );

        rect = mappedPath.boundingRect();
    }

    return rect;
}
开发者ID:0vermind,项目名称:NeoLoader,代码行数:25,代码来源:qwt_graphic.cpp

示例2: shape

QPainterPath ArrowLinkItem::shape() const
{
    QPainterPath path = originalShape();
    QPainterPathStroker pathStroker;
    pathStroker.setWidth(10);
    return pathStroker.createStroke(path);
}
开发者ID:Daylie,项目名称:Totem,代码行数:7,代码来源:arrowlinkitem.cpp

示例3: circularPortId

qreal PortHandler::circularPortId(const QPointF &location, const QStringList &types) const
{
	for (int circularPortNumber = 0; circularPortNumber < mCircularPorts.count(); circularPortNumber++) {
		const StatCircular * const circularPort = mCircularPorts.at(circularPortNumber);
		if (!types.contains(circularPort->type())) {
			continue;
		}

		QPainterPathStroker ps;
		ps.setWidth(kvadratik);

		QPainterPath path;
		StatCircular::CircularPort circular = transformPortForNodeSize(circularPort);

		path.addEllipse({circular.x, circular.y}, circular.rx, circular.ry);

		path = ps.createStroke(path);
		if (path.contains(location)) {
			return circularPortNumber + mPointPorts.size() + mLinePorts.size()
				+ (pointByCircularPortAngle(circularPortNumber, location) / 360.0);
		}
	}

	return nonexistentPortId;
}
开发者ID:Antropovi,项目名称:qreal,代码行数:25,代码来源:portHandler.cpp

示例4: linePortId

qreal PortHandler::linePortId(const QPointF &location, const QStringList &types) const
{
	for (int linePortNumber = 0; linePortNumber < mLinePorts.count(); linePortNumber++) {
		const StatLine * const linePort = mLinePorts.at(linePortNumber);
		if (!types.contains(linePort->type())) {
			continue;
		}

		QPainterPathStroker ps;
		ps.setWidth(kvadratik - 5);

		QPainterPath path;
		const QLineF line = transformPortForNodeSize(linePort);
		path.moveTo(line.p1());
		path.lineTo(line.p2());

		path = ps.createStroke(path);
		if (path.contains(location)) {
			return linePortNumber + mPointPorts.size()
				+ qMin(QLineF(line.p1(), location).length() / line.length()
					, mMaximumFractionPartValue);
		}
	}

	return nonexistentPortId;
}
开发者ID:Antropovi,项目名称:qreal,代码行数:26,代码来源:portHandler.cpp

示例5: shape

/**
 * @return The shape of the AssociationLine.
 */
QPainterPath AssociationLine::shape() const
{
    QPainterPathStroker stroker;
    stroker.setWidth(qMax<qreal>(2*SelectedPointDiameter, pen().widthF()) + 2.0);  // allow delta region
    stroker.setCapStyle(Qt::FlatCap);
    return stroker.createStroke(path());
}
开发者ID:behlingc,项目名称:umbrello-behlingc,代码行数:10,代码来源:associationline.cpp

示例6: shape

QPainterPath TournamentArcDraw::shape() const
{
	QPainterPath path;

	QPointF p1 = mapFromItem(_tail, 0, 0);
	QPointF p2 = mapFromItem(_head, 0, 0);

	double x1 = p1.x();
	double x2 = p2.x();

	if(x1 > x2)
	{
		qSwap(p1, p2);
		qSwap(x1, x2);
	}

	// TODO: Fix this, then make it selectable
	path.moveTo(p2);
	//path.lineTo(x1-2, 10);

	//path.addRect(0, 0, 20, 20);

	int height = (x2 - x1) / 4;

	int startAngle = 0;
	int spanAngle = 180;

	path.arcTo(QRectF(QPointF(x1, -height), QPointF(x2, height)), startAngle, spanAngle);
	path.arcTo(QRectF(QPointF(x1, -height), QPointF(x2, height)), spanAngle, -spanAngle);

	QPainterPathStroker stroker;
	stroker.setWidth(6);

	return stroker.createStroke(path);
}
开发者ID:stringoftheseus,项目名称:graphshop,代码行数:35,代码来源:tournamentarcdraw.cpp

示例7: fnt

QGraphicsItemGroup *ProfileGraphicsView::plot_text(text_render_options_t *tro,const QPointF& pos, const QString& text, QGraphicsItem *parent)
{
    QFont fnt(font());
    QFontMetrics fm(fnt);

    if (printMode)
        fnt.setPixelSize(tro->size);

    QPointF point(SCALEGC(pos.x(), pos.y())); // This is neded because of the SCALE macro.
    double dx = tro->hpos * (fm.width(text));
    double dy = tro->vpos * (fm.height());

    QGraphicsItemGroup *group = new QGraphicsItemGroup(parent);
    QPainterPath textPath;
    /* addText() uses bottom-left text baseline and the -3 offset is probably slightly off
     * for different font sizes. */
    textPath.addText(0, fm.height() - 3, fnt, text);
    QPainterPathStroker stroker;
    stroker.setWidth(3);
    QGraphicsPathItem *strokedItem = new QGraphicsPathItem(stroker.createStroke(textPath), group);
    strokedItem->setBrush(QBrush(getColor(TEXT_BACKGROUND)));
    strokedItem->setPen(Qt::NoPen);

    QGraphicsPathItem *textItem = new QGraphicsPathItem(textPath, group);
    textItem->setBrush(QBrush(getColor(tro->color)));
    textItem->setPen(Qt::NoPen);

    group->setPos(point.x() + dx, point.y() + dy);
    if (!printMode)
        group->setFlag(QGraphicsItem::ItemIgnoresTransformations);

    if (!parent)
        scene()->addItem(group);
    return group;
}
开发者ID:hide5stm,项目名称:subsurface,代码行数:35,代码来源:profilegraphics.cpp

示例8: shape

QPainterPath Line::shape() const
{
    // sets the shape of the line for selection
    QPainterPathStroker stroker;
    stroker.setWidth(10);
    return stroker.createStroke(path);
}
开发者ID:GreatDevelopers,项目名称:eCAD,代码行数:7,代码来源:line.cpp

示例9: getPathStroke

static QPainterPath getPathStroke(const QPainterPath &path, const RenderObject* object, const RenderStyle* style)
{ 
    QPainterPathStroker s;
    s.setWidth(KSVGPainterFactory::cssPrimitiveToLength(object, style->svgStyle()->strokeWidth(), 1.0));

    if (style->svgStyle()->capStyle() == ButtCap)
        s.setCapStyle(Qt::FlatCap);
    else if (style->svgStyle()->capStyle() == RoundCap)
        s.setCapStyle(Qt::RoundCap);

    if (style->svgStyle()->joinStyle() == MiterJoin) {
        s.setJoinStyle(Qt::MiterJoin);
        s.setMiterLimit((qreal) style->svgStyle()->strokeMiterLimit());
    } else if(style->svgStyle()->joinStyle() == RoundJoin)
        s.setJoinStyle(Qt::RoundJoin);

    const KCDashArray& dashes = KSVGPainterFactory::dashArrayFromRenderingStyle(style);
    double dashOffset = KSVGPainterFactory::cssPrimitiveToLength(object, style->svgStyle()->strokeDashOffset(), 0.0);

    unsigned int dashLength = !dashes.isEmpty() ? dashes.size() : 0;
    if(dashLength) {
        QVector<qreal> pattern;
        unsigned int count = (dashLength % 2) == 0 ? dashLength : dashLength * 2;

        for(unsigned int i = 0; i < count; i++)
            pattern.append(dashes[i % dashLength] / (float)s.width());

        s.setDashPattern(pattern);
    
        Q_UNUSED(dashOffset);
        // TODO: dash-offset, does/will qt4 API allow it? (Rob)
    }

    return s.createStroke(path);
}
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:35,代码来源:RenderPathQt.cpp

示例10: addPenWidth

QRectF QAlphaPaintEnginePrivate::addPenWidth(const QPainterPath &path)
{
    Q_Q(QAlphaPaintEngine);

    QPainterPath tmp = path;

    if (m_pen.style() == Qt::NoPen)
        return (path.controlPointRect() * m_transform).boundingRect();
    bool cosmetic = qt_pen_is_cosmetic(m_pen, q->state->renderHints());
    if (cosmetic)
        tmp = path * m_transform;

    QPainterPathStroker stroker;
    if (m_pen.widthF() == 0.0f)
        stroker.setWidth(1.0);
    else
        stroker.setWidth(m_pen.widthF());
    stroker.setJoinStyle(m_pen.joinStyle());
    stroker.setCapStyle(m_pen.capStyle());
    tmp = stroker.createStroke(tmp);
    if (cosmetic)
        return tmp.controlPointRect();

    return (tmp.controlPointRect() * m_transform).boundingRect();
}
开发者ID:oneywang,项目名称:qtbase,代码行数:25,代码来源:qpaintengine_alpha.cpp

示例11: path

QPainterPath 
EdgeItem::shape() const
{
    QPainterPath path( srcP);
    QPainterPathStroker stroker;
        
    if ( srcP == dstP)
        return path;
    
    if ( edge()->isSelf())
    {
        path = selfEdgePath();
    } else
    {
        path.cubicTo( cp1, cp2, dstP);
    }
    if ( isNotNullP( edge()->style()))
    {
        stroker.setWidth( edge()->style()->pen().width() + 1);
    } else
    {
        stroker.setWidth( 2);
    }
    return stroker.createStroke( path); 
}
开发者ID:ChunHungLiu,项目名称:codequery,代码行数:25,代码来源:edge_item.cpp

示例12: shapeFromPath

QPainterPath GraphicsUtils::shapeFromPath(const QPainterPath &path, const QPen &pen, double shapeStrokeWidth, bool includeOriginalPath)
{
	// this function mostly copied from QGraphicsItem::qt_graphicsItem_shapeFromPath


    // We unfortunately need this hack as QPainterPathStroker will set a width of 1.0
    // if we pass a value of 0.0 to QPainterPathStroker::setWidth()
    static const double penWidthZero = double(0.00000001);

    if (path == QPainterPath())
        return path;
    QPainterPathStroker ps;
    ps.setCapStyle(pen.capStyle());
    //ps.setCapStyle(Qt::FlatCap);
    if (shapeStrokeWidth <= 0.0)
        ps.setWidth(penWidthZero);
    else
        ps.setWidth(shapeStrokeWidth);

    ps.setJoinStyle(pen.joinStyle());
    ps.setMiterLimit(pen.miterLimit());
    QPainterPath p = ps.createStroke(path);
	if (includeOriginalPath) {
		p.addPath(path);
	}
    return p;
}
开发者ID:DHaylock,项目名称:fritzing-app,代码行数:27,代码来源:graphicsutils.cpp

示例13: shape

QPainterPath GEdge::shape() const {
    QPainterPath path(sourcePoint);
    QPainterPathStroker stroker;
    path.lineTo(destPoint);
    stroker.setWidth(20);
    return stroker.createStroke(path);
}
开发者ID:MIPT-ILab,项目名称:ICDV,代码行数:7,代码来源:GEdge.cpp

示例14: draw

void LayoutBreak::draw(QPainter* painter) const
      {
      if (score()->printing() || !score()->showUnprintable())
            return;

      QPainterPathStroker stroker;
      stroker.setWidth(lw/2);
      stroker.setJoinStyle(Qt::MiterJoin);
      stroker.setCapStyle(Qt::SquareCap);

      QVector<qreal> dashes ;
      dashes.append(1);
      dashes.append(3);
      stroker.setDashPattern(dashes);
      QPainterPath stroke = stroker.createStroke(path);

      painter->fillPath(stroke, selected() ? MScore::selectColor[0] : MScore::layoutBreakColor);


      painter->setPen(QPen(selected() ? MScore::selectColor[0] : MScore::layoutBreakColor,
         lw, Qt::SolidLine, Qt::SquareCap, Qt::MiterJoin));
      painter->setBrush(Qt::NoBrush);
      painter->drawPath(path2);

      }
开发者ID:FryderykChopin,项目名称:MuseScore,代码行数:25,代码来源:layoutbreak.cpp

示例15: boundsOnStroke

static inline QRectF boundsOnStroke(QPainter *p, const QPainterPath &path, qreal width)
{
    QPainterPathStroker stroker;
    stroker.setWidth(width);
    QPainterPath stroke = stroker.createStroke(path);
    return p->transform().map(stroke).boundingRect();
}
开发者ID:husninazer,项目名称:qt,代码行数:7,代码来源:qsvggraphics.cpp


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