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


C++ KoPathShape类代码示例

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


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

示例1: undo

void KoPathPointInsertCommand::undo()
{
    QUndoCommand::undo();
    for (int i = 0; i < m_pointDataList.size(); ++i) {
        const KoPathPointData &pdBefore = m_pointDataList.at(i);
        KoPathShape * pathShape = pdBefore.pathShape;
        KoPathPointIndex piAfter = pdBefore.pointIndex;
        ++piAfter.second;

        KoPathPoint * before = pathShape->pointByIndex(pdBefore.pointIndex);

        m_points[i] = pathShape->removePoint(piAfter);

        if (m_points[i]->properties() & KoPathPoint::CloseSubpath) {
            piAfter.second = 0;
        }

        KoPathPoint * after = pathShape->pointByIndex(piAfter);

        if (before->activeControlPoint2()) {
            QPointF controlPoint2 = before->controlPoint2();
            qSwap(controlPoint2, m_controlPoints[i].first);
            before->setControlPoint2(controlPoint2);
        }

        if (after->activeControlPoint1()) {
            QPointF controlPoint1 = after->controlPoint1();
            qSwap(controlPoint1, m_controlPoints[i].second);
            after->setControlPoint1(controlPoint1);
        }
        pathShape->update();
    }
    m_deletePoints = true;
}
开发者ID:,项目名称:,代码行数:34,代码来源:

示例2: it

void KoPathSegmentTypeCommand::redo()
{
    KUndo2Command::redo();
    QList<KoPathPointData>::const_iterator it(m_pointDataList.constBegin());
    for (; it != m_pointDataList.constEnd(); ++it) {
        KoPathShape * pathShape = it->pathShape;
        pathShape->update();

        KoPathSegment segment = pathShape->segmentByIndex(it->pointIndex);

        if (m_segmentType == Curve) {
            // we change type to curve -> set control point positions
            QPointF pointDiff = segment.second()->point() - segment.first()->point();
            segment.first()->setControlPoint2(segment.first()->point() + pointDiff / 3.0);
            segment.second()->setControlPoint1(segment.first()->point() + pointDiff * 2.0 / 3.0);
        } else {
            // we are changing type to line -> remove control points
            segment.first()->removeControlPoint2();
            segment.second()->removeControlPoint1();
        }

        pathShape->normalize();
        pathShape->update();
    }
}
开发者ID:abhishekmurthy,项目名称:Calligra,代码行数:25,代码来源:KoPathSegmentTypeCommand.cpp

示例3: saveSvgClipping

void SvgStyleWriter::saveSvgClipping(KoShape *shape, SvgSavingContext &context)
{
    KoClipPath *clipPath = shape->clipPath();
    if (!clipPath)
        return;

    const QSizeF shapeSize = shape->outlineRect().size();
    KoPathShape *path = KoPathShape::createShapeFromPainterPath(clipPath->pathForSize(shapeSize));
    if (!path)
        return;

    path->close();

    const QString uid = context.createUID("clippath");

    context.styleWriter().startElement("clipPath");
    context.styleWriter().addAttribute("id", uid);
    context.styleWriter().addAttribute("clipPathUnits", "userSpaceOnUse");

    context.styleWriter().startElement("path");
    context.styleWriter().addAttribute("d", path->toString(path->absoluteTransformation(0)*context.userSpaceTransform()));
    context.styleWriter().endElement(); // path

    context.styleWriter().endElement(); // clipPath

    context.shapeWriter().addAttribute("clip-path", "url(#" + uid + ")");
    if (clipPath->clipRule() != Qt::WindingFill)
        context.shapeWriter().addAttribute("clip-rule", "evenodd");
}
开发者ID:ChrisJong,项目名称:krita,代码行数:29,代码来源:SvgStyleWriter.cpp

示例4: fill

void SvgStyleWriter::saveSvgFill(KoShape *shape, SvgSavingContext &context)
{
    if (! shape->background()) {
        context.shapeWriter().addAttribute("fill", "none");
    }

    QBrush fill(Qt::NoBrush);
    QSharedPointer<KoColorBackground>  cbg = qSharedPointerDynamicCast<KoColorBackground>(shape->background());
    if (cbg) {
        context.shapeWriter().addAttribute("fill", cbg->color().name());
        if (cbg->color().alphaF() < 1.0)
            context.shapeWriter().addAttribute("fill-opacity", cbg->color().alphaF());
    }
    QSharedPointer<KoGradientBackground>  gbg = qSharedPointerDynamicCast<KoGradientBackground>(shape->background());
    if (gbg) {
        QString gradientId = saveSvgGradient(gbg->gradient(), gbg->transform(), context);
        context.shapeWriter().addAttribute("fill", "url(#" + gradientId + ")");
    }
    QSharedPointer<KoPatternBackground>  pbg = qSharedPointerDynamicCast<KoPatternBackground>(shape->background());
    if (pbg) {
        const QString patternId = saveSvgPattern(pbg, shape, context);
        context.shapeWriter().addAttribute("fill", "url(#" + patternId + ")");
    }

    KoPathShape * path = dynamic_cast<KoPathShape*>(shape);
    if (path && shape->background()) {
        // non-zero is default, so only write fillrule if evenodd is set
        if (path->fillRule() == Qt::OddEvenFill)
            context.shapeWriter().addAttribute("fill-rule", "evenodd");
    }
}
开发者ID:ChrisJong,项目名称:krita,代码行数:31,代码来源:SvgStyleWriter.cpp

示例5: KoPathPointIndex

QList<KoSubpath *> KarbonSimplifyPath::split( const KoPathShape &path )
{
    QList<KoSubpath *> res;
    KoSubpath *subpath = new KoSubpath;
    res.append( subpath );

    for ( int i = 0; i < path.pointCount(); ++i )
    {
        KoPathPoint *p = path.pointByIndex( KoPathPointIndex(0, i) );
        // if the path separates two subpaths
        // (if it isn't smooth nor the first or last point)
        if ( i != 0  &&  i != path.pointCount()-1 )
        {
            KoPathPoint *prev = path.pointByIndex( KoPathPointIndex(0, i-1) );
            KoPathPoint *next = path.pointByIndex( KoPathPointIndex(0, i+1) );
            if ( ! p->isSmooth(prev, next) )
            {
                // create a new subpath
                subpath->append( new KoPathPoint(*p) );
                subpath = new KoSubpath;
                res.append( subpath );
            }
        }
        subpath->append( new KoPathPoint(*p) );
    }

    return res;
}
开发者ID:JeremiasE,项目名称:KFormula,代码行数:28,代码来源:KarbonSimplifyPath.cpp

示例6: redo

void KoPathPointInsertCommand::redo()
{
    QUndoCommand::redo();
    for (int i = m_pointDataList.size() - 1; i >= 0; --i) {
        KoPathPointData pointData = m_pointDataList.at(i);
        KoPathShape * pathShape = pointData.pathShape;

        KoPathSegment segment = pathShape->segmentByIndex(pointData.pointIndex);

        ++pointData.pointIndex.second;

        if (segment.first()->activeControlPoint2()) {
            QPointF controlPoint2 = segment.first()->controlPoint2();
            qSwap(controlPoint2, m_controlPoints[i].first);
            segment.first()->setControlPoint2(controlPoint2);
        }

        if (segment.second()->activeControlPoint1()) {
            QPointF controlPoint1 = segment.second()->controlPoint1();
            qSwap(controlPoint1, m_controlPoints[i].second);
            segment.second()->setControlPoint1(controlPoint1);
        }

        pathShape->insertPoint(m_points.at(i), pointData.pointIndex);
        pathShape->update();
    }
    m_deletePoints = false;
}
开发者ID:,项目名称:,代码行数:28,代码来源:

示例7: changeToLine

void TestSegmentTypeCommand::changeToLine()
{
    KoPathShape path;
    path.moveTo( QPointF(0,0) );
    path.curveTo( QPointF(25,25), QPointF(75,25), QPointF(100,0) );

    KoPathPointData segment(&path, KoPathPointIndex(0,0));
    QList<KoPathPointData> segments;
    segments.append(segment);

    // get first segment
    KoPathSegment s = path.segmentByIndex(KoPathPointIndex(0,0));

    KoPathSegmentTypeCommand cmd(segments, KoPathSegmentTypeCommand::Line);

    QVERIFY(s.first()->activeControlPoint2());
    QVERIFY(s.second()->activeControlPoint1());

    cmd.redo();

    QVERIFY(!s.first()->activeControlPoint2());
    QVERIFY(!s.second()->activeControlPoint1());

    cmd.undo();

    QVERIFY(s.first()->activeControlPoint2());
    QVERIFY(s.second()->activeControlPoint1());
}
开发者ID:KDE,项目名称:calligra-history,代码行数:28,代码来源:TestSegmentTypeCommand.cpp

示例8: PointData

 PointData( KoPathPoint * p )
 {
     KoPathShape * shape = p->parent();
     // save points in document coordinates
     oldNode = shape->shapeToDocument( p->point() );
     oldControlPoint1 = shape->shapeToDocument( p->controlPoint1() );
     oldControlPoint2 = shape->shapeToDocument( p->controlPoint2() );
 }
开发者ID:JeremiasE,项目名称:KFormula,代码行数:8,代码来源:KarbonWhirlPinchCommand.cpp

示例9: restorePoint

 void restorePoint( KoPathPoint * p )
 {
     KoPathShape * shape = p->parent();
     p->setPoint( shape->documentToShape( oldNode ) );
     if( p->activeControlPoint1() )
         p->setControlPoint1( shape->documentToShape( oldControlPoint1 ) );
     if( p->activeControlPoint2() )
         p->setControlPoint2( shape->documentToShape( oldControlPoint2 ) );
 }
开发者ID:JeremiasE,项目名称:KFormula,代码行数:9,代码来源:KarbonWhirlPinchCommand.cpp

示例10:

void KoShapeStroke::Private::paintBorder(KoShape *shape, QPainter &painter, const QPen &pen) const
{
    if (!pen.isCosmetic()) {
        KoPathShape *pathShape = dynamic_cast<KoPathShape *>(shape);
        if (pathShape) {
            QPainterPath path = pathShape->pathStroke(pen);
            painter.fillPath(path, pen.brush());
            return;
        }
        painter.strokePath(shape->outline(), pen);
    }
}
开发者ID:NavyZhao1978,项目名称:QCalligra,代码行数:12,代码来源:KoShapeStroke.cpp

示例11: QTransform

KoClipPath *PictureShape::generateClipPath()
{
    QPainterPath path = _Private::generateOutline(imageData()->image());
    path = path * QTransform().scale(size().width(), size().height());

    KoPathShape *pathShape = KoPathShape::createShapeFromPainterPath(path);

    //createShapeFromPainterPath converts the path topleft into a shape topleft
    //and the pathShape needs to be on top of us. So to preserve both we do:
    pathShape->setTransformation(pathShape->transformation() * transformation());

    return new KoClipPath(this, new KoClipData(pathShape));
}
开发者ID:,项目名称:,代码行数:13,代码来源:

示例12: KoPathShape

void TestPACopyPastePage::addShape( KoPAPageBase * page )
{
    KoPathShape * path = new KoPathShape();
    path->lineTo( QPointF( 10, 0 ) );
    path->lineTo( QPointF( 10, 10 ) );
    path->setPosition( m_pos );
    m_pos += QPointF( 1.0, 1.0 );

    QList<KoShape*> shapes = page->shapes();
    if ( !shapes.isEmpty() ) {
        KoShapeLayer* layer = dynamic_cast<KoShapeLayer*>( shapes.last() );
        layer->addShape( path );
    }
}
开发者ID:TheTypoMaster,项目名称:calligra,代码行数:14,代码来源:TestPACopyPastePage.cpp

示例13: paintPath

void KoCreatePathTool::paintPath(KoPathShape& pathShape, QPainter &painter, const KoViewConverter &converter)
{
    Q_D(KoCreatePathTool);
    painter.setTransform(pathShape.absoluteTransformation(&converter) * painter.transform());
    painter.save();

    KoShapePaintingContext paintContext; //FIXME
    pathShape.paint(painter, converter, paintContext);
    painter.restore();
    if (pathShape.stroke()) {
        painter.save();
        pathShape.stroke()->paint(d->shape, painter, converter);
        painter.restore();
    }
}
开发者ID:KDE,项目名称:calligra,代码行数:15,代码来源:KoCreatePathTool.cpp

示例14: svgMoveTo

void KoPathShapeLoaderPrivate::svgMoveTo(qreal x1, qreal y1, bool abs)
{
    if (abs)
        lastPoint = QPointF(x1, y1);
    else
        lastPoint += QPointF(x1, y1);
    path->moveTo(lastPoint);
}
开发者ID:abhishekmurthy,项目名称:Calligra,代码行数:8,代码来源:KoPathShapeLoader.cpp

示例15: undo

void KoPathBreakAtPointCommand::undo()
{
    KUndo2Command::undo();
    KoPathShape * lastPathShape = 0;

    for (int i = 0; i < m_pointDataList.size(); ++i) {
        const KoPathPointData & pd = m_pointDataList.at(i);
        KoPathShape * pathShape = pd.pathShape;
        KoPathPointIndex pointIndex = pd.pointIndex;
        ++pointIndex.second;
        if (m_closedIndex.at(i).first != -1) {
            m_closedIndex[i] = pathShape->closeSubpath(m_closedIndex.at(i));
        } else {
            pointIndex.second = pointIndex.second + m_closedIndex.at(i).second;
            pathShape->join(pd.pointIndex.first);
        }
        m_points[i] = pathShape->removePoint(pointIndex);

        if (lastPathShape != pathShape) {
            if (lastPathShape) {
                lastPathShape->update();
            }
            lastPathShape = pathShape;
        }
    }
    if (lastPathShape) {
        lastPathShape->update();
    }

    m_deletePoints = true;
}
开发者ID:abhishekmurthy,项目名称:Calligra,代码行数:31,代码来源:KoPathBreakAtPointCommand.cpp


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