本文整理汇总了C++中QPainterPathStroker类的典型用法代码示例。如果您正苦于以下问题:C++ QPainterPathStroker类的具体用法?C++ QPainterPathStroker怎么用?C++ QPainterPathStroker使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QPainterPathStroker类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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());
}
示例2: path
QPainterPath GEdge::shape() const {
QPainterPath path(sourcePoint);
QPainterPathStroker stroker;
path.lineTo(destPoint);
stroker.setWidth(20);
return stroker.createStroke(path);
}
示例3: shape
QPainterPath Line::shape() const
{
// sets the shape of the line for selection
QPainterPathStroker stroker;
stroker.setWidth(10);
return stroker.createStroke(path);
}
示例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;
}
示例5: scene
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));
}
}
示例6: mapFromItem
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);
}
示例7: 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);
}
示例8: 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();
}
示例9: originalShape
QPainterPath ArrowLinkItem::shape() const
{
QPainterPath path = originalShape();
QPainterPathStroker pathStroker;
pathStroker.setWidth(10);
return pathStroker.createStroke(path);
}
示例10: 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;
}
示例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);
}
示例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: shape
/**
* Shape
*/
QPainterPath GuiEdge::shape() const
{
// QPainterPath path( edge_start_point_priv);
QPainterPathStroker stroker;
// path.lineTo( edge_end_point_priv.x(), edge_end_point_priv.y());
stroker.setWidth( 10);
return stroker.createStroke( edge_curve_priv);
}
示例14: shape
QPainterPath GraphicsItemEdge::shape() const
{
QPainterPathStroker stroker;
stroker.setWidth(g_settings->edgeWidth);
stroker.setCapStyle(Qt::RoundCap);
stroker.setJoinStyle(Qt::RoundJoin);
return stroker.createStroke(path());
}
示例15: strokeEmptyPath
void tst_QPainterPathStroker::strokeEmptyPath()
{
QPainterPath path;
path.moveTo(10, 10);
path.lineTo(10, 10);
QPainterPathStroker stroker;
QCOMPARE(stroker.createStroke(path), path);
}