本文整理汇总了C++中QPainterPathStroker::setMiterLimit方法的典型用法代码示例。如果您正苦于以下问题:C++ QPainterPathStroker::setMiterLimit方法的具体用法?C++ QPainterPathStroker::setMiterLimit怎么用?C++ QPainterPathStroker::setMiterLimit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPainterPathStroker
的用法示例。
在下文中一共展示了QPainterPathStroker::setMiterLimit方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
示例2: 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;
}
示例3: 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;
}
示例4: shape
QPainterPath QGVEdge::shape() const
{
QPainterPathStroker ps;
ps.setCapStyle(_pen.capStyle());
ps.setWidth(_pen.widthF() + 10);
ps.setJoinStyle(_pen.joinStyle());
ps.setMiterLimit(_pen.miterLimit());
return ps.createStroke(_path);
}
示例5: strokeBoundingRect
FloatRect Path::strokeBoundingRect(StrokeStyleApplier* applier)
{
GraphicsContext* gc = scratchContext();
QPainterPathStroker stroke;
if (applier) {
applier->strokeStyle(gc);
QPen pen = gc->pen();
stroke.setWidth(pen.widthF());
stroke.setCapStyle(pen.capStyle());
stroke.setJoinStyle(pen.joinStyle());
stroke.setMiterLimit(pen.miterLimit());
stroke.setDashPattern(pen.dashPattern());
stroke.setDashOffset(pen.dashOffset());
}
return stroke.createStroke(m_path).boundingRect();
}
示例6: strokeContains
bool Path::strokeContains(StrokeStyleApplier* applier, const FloatPoint& point) const
{
ASSERT(applier);
QPainterPathStroker stroke;
GraphicsContext* gc = scratchContext();
applier->strokeStyle(gc);
QPen pen = gc->pen();
stroke.setWidth(pen.widthF());
stroke.setCapStyle(pen.capStyle());
stroke.setJoinStyle(pen.joinStyle());
stroke.setMiterLimit(pen.miterLimit());
stroke.setDashPattern(pen.dashPattern());
stroke.setDashOffset(pen.dashOffset());
return stroke.createStroke(m_path).contains(point);
}
示例7: testStroker
void tst_QPainterPath::testStroker()
{
QFETCH(QPainterPath, path);
QFETCH(QPen, pen);
QFETCH(QPainterPath, stroke);
QPainterPathStroker stroker;
stroker.setWidth(pen.widthF());
stroker.setCapStyle(pen.capStyle());
stroker.setJoinStyle(pen.joinStyle());
stroker.setMiterLimit(pen.miterLimit());
stroker.setDashPattern(pen.style());
stroker.setDashOffset(pen.dashOffset());
QPainterPath result = stroker.createStroke(path);
// check if stroke == result
QVERIFY(result.subtracted(stroke).isEmpty());
QVERIFY(stroke.subtracted(result).isEmpty());
}
示例8: strokeBoundingRect
FloatRect Path::strokeBoundingRect(StrokeStyleApplier* applier)
{
// FIXME: We should try to use a 'shared Context' instead of creating a new ImageBuffer
// on each call.
OwnPtr<ImageBuffer> scratchImage = ImageBuffer::create(IntSize(1, 1));
GraphicsContext* gc = scratchImage->context();
QPainterPathStroker stroke;
if (applier) {
applier->strokeStyle(gc);
QPen pen = gc->pen();
stroke.setWidth(pen.widthF());
stroke.setCapStyle(pen.capStyle());
stroke.setJoinStyle(pen.joinStyle());
stroke.setMiterLimit(pen.miterLimit());
stroke.setDashPattern(pen.dashPattern());
stroke.setDashOffset(pen.dashOffset());
}
return stroke.createStroke(m_path).boundingRect();
}
示例9: strokeContains
bool Path::strokeContains(StrokeStyleApplier* applier, const FloatPoint& point) const
{
ASSERT(applier);
// FIXME: We should try to use a 'shared Context' instead of creating a new ImageBuffer
// on each call.
OwnPtr<ImageBuffer> scratchImage = ImageBuffer::create(IntSize(1, 1));
GraphicsContext* gc = scratchImage->context();
QPainterPathStroker stroke;
applier->strokeStyle(gc);
QPen pen = gc->pen();
stroke.setWidth(pen.widthF());
stroke.setCapStyle(pen.capStyle());
stroke.setJoinStyle(pen.joinStyle());
stroke.setMiterLimit(pen.miterLimit());
stroke.setDashPattern(pen.dashPattern());
stroke.setDashOffset(pen.dashOffset());
return stroke.createStroke(m_path).contains(point);
}
示例10: shapeFromPath
QPainterPath Toolbox::shapeFromPath(const QPainterPath& path, const QPen& pen,
const QBrush& brush,
const UnsignedLength& minWidth) noexcept {
// http://code.qt.io/cgit/qt/qtbase.git/tree/src/widgets/graphicsview/qgraphicsitem.cpp
// Function: qt_graphicsItem_shapeFromPath()
if (path == QPainterPath() || pen == Qt::NoPen) {
return path;
} else {
QPainterPathStroker ps;
ps.setCapStyle(pen.capStyle());
ps.setWidth(qMax(qMax(pen.widthF(), qreal(0.00000001)), minWidth->toPx()));
ps.setJoinStyle(pen.joinStyle());
ps.setMiterLimit(pen.miterLimit());
QPainterPath p = ps.createStroke(path);
if (brush != Qt::NoBrush) {
p.addPath(path);
}
return p;
}
}
示例11: shape
QPainterPath ArrowItem::shape() const
{
QPainterPath path;
path.setFillRule(Qt::WindingFill);
if (m_shaftItem &&m_shaftItem->path() != QPainterPath()) {
QPainterPathStroker ps;
QPen pen = m_shaftItem->pen();
ps.setCapStyle(pen.capStyle());
ps.setJoinStyle(pen.joinStyle());
ps.setMiterLimit(pen.miterLimit());
// overwrite pen width to make selection more lazy
ps.setWidth(16.0);
QPainterPath p = ps.createStroke(m_shaftItem->path());
path.addPath(p);
}
if (m_startHeadItem)
path.addRect(mapRectFromItem(m_startHeadItem, m_startHeadItem->boundingRect()));
if (m_endHeadItem)
path.addRect(mapRectFromItem(m_endHeadItem, m_endHeadItem->boundingRect()));
return path;
}