本文整理汇总了C++中KoPathShape::segmentByIndex方法的典型用法代码示例。如果您正苦于以下问题:C++ KoPathShape::segmentByIndex方法的具体用法?C++ KoPathShape::segmentByIndex怎么用?C++ KoPathShape::segmentByIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KoPathShape
的用法示例。
在下文中一共展示了KoPathShape::segmentByIndex方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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());
}
示例3: redo
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();
}
}
示例4: QUndoCommand
KoPathPointInsertCommand::KoPathPointInsertCommand(const QList<KoPathPointData> & pointDataList, qreal insertPosition, QUndoCommand *parent)
: QUndoCommand(parent)
, m_deletePoints(true)
{
if (insertPosition < 0)
insertPosition = 0;
if (insertPosition > 1)
insertPosition = 1;
//TODO the list needs to be sorted
QList<KoPathPointData>::const_iterator it(pointDataList.begin());
for (; it != pointDataList.end(); ++it) {
KoPathShape * pathShape = it->pathShape;
KoPathSegment segment = pathShape->segmentByIndex(it->pointIndex);
// should not happen but to be sure
if (! segment.isValid())
continue;
m_pointDataList.append(*it);
QPair<KoPathSegment, KoPathSegment> splitSegments = segment.splitAt( insertPosition );
KoPathPoint * split1 = splitSegments.first.second();
KoPathPoint * split2 = splitSegments.second.first();
KoPathPoint * splitPoint = new KoPathPoint( pathShape, split1->point() );
if( split1->activeControlPoint1() )
splitPoint->setControlPoint1(split1->controlPoint1());
if( split2->activeControlPoint2() )
splitPoint->setControlPoint2(split2->controlPoint2());
m_points.append(splitPoint);
QPointF cp1 = splitSegments.first.first()->controlPoint2();
QPointF cp2 = splitSegments.second.second()->controlPoint1();
m_controlPoints.append(QPair<QPointF, QPointF>(cp1, cp2));
}
}