本文整理汇总了C++中QPainterPathStroker::setWidth方法的典型用法代码示例。如果您正苦于以下问题:C++ QPainterPathStroker::setWidth方法的具体用法?C++ QPainterPathStroker::setWidth怎么用?C++ QPainterPathStroker::setWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPainterPathStroker
的用法示例。
在下文中一共展示了QPainterPathStroker::setWidth方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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();
}
示例3: 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);
}
示例4: 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;
}
示例5: 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);
}
示例6: shape
QPainterPath ArrowLinkItem::shape() const
{
QPainterPath path = originalShape();
QPainterPathStroker pathStroker;
pathStroker.setWidth(10);
return pathStroker.createStroke(path);
}
示例7: 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;
}
示例8: 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;
}
示例9: 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());
}
示例10: shape
QPainterPath Line::shape() const
{
// sets the shape of the line for selection
QPainterPathStroker stroker;
stroker.setWidth(10);
return stroker.createStroke(path);
}
示例11: paint
void LineObject::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* /*widget*/)
{
QGraphicsScene* objScene = scene();
if(!objScene) return;
QPen paintPen = pen();
painter->setPen(paintPen);
updateRubber(painter);
if(option->state & QStyle::State_Selected) { paintPen.setStyle(Qt::DashLine); }
if(objScene->property(ENABLE_LWT).toBool()) { paintPen = lineWeightPen(); }
painter->setPen(paintPen);
if(objectRubberMode() != OBJ_RUBBER_LINE) painter->drawLine(line());
//TODO: This is the initial concept for what realistic rendering be like. It's somewhat decent but needs improvement.
if(objScene->property(ENABLE_LWT).toBool() && objScene->property(ENABLE_REAL).toBool())
{
painter->setPen(objectColor().darker(150)); //TODO: Improve this for black and dark colors
QPainterPathStroker stroker;
stroker.setWidth(0.35);
stroker.setCapStyle(Qt::RoundCap);
stroker.setJoinStyle(Qt::RoundJoin);
QPainterPath realPath = stroker.createStroke(path());
painter->drawPath(realPath);
QLinearGradient grad(mapFromScene(objectMidPoint()), mapFromScene(objectEndPoint1()));
grad.setColorAt(0, objectColor());
grad.setColorAt(1, objectColor().darker(150)); //TODO: Improve this for black and dark colors
grad.setSpread(QGradient::ReflectSpread);
painter->fillPath(realPath, QBrush(grad));
}
}
示例12: 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;
}
示例13: 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();
}
示例14: shape
QPainterPath GEdge::shape() const {
QPainterPath path(sourcePoint);
QPainterPathStroker stroker;
path.lineTo(destPoint);
stroker.setWidth(20);
return stroker.createStroke(path);
}
示例15: 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);
}