本文整理汇总了C++中KoPathPoint::setProperties方法的典型用法代码示例。如果您正苦于以下问题:C++ KoPathPoint::setProperties方法的具体用法?C++ KoPathPoint::setProperties怎么用?C++ KoPathPoint::setProperties使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KoPathPoint
的用法示例。
在下文中一共展示了KoPathPoint::setProperties方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: undoChanges
void KoPathPointTypeCommand::undoChanges(const QList<PointData> &data)
{
QList<PointData>::const_iterator it(data.begin());
for (; it != data.end(); ++it) {
KoPathShape *pathShape = it->m_pointData.pathShape;
KoPathPoint *point = pathShape->pointByIndex(it->m_pointData.pointIndex);
point->setProperties(it->m_oldProperties);
if (it->m_hadControlPoint1)
point->setControlPoint1(pathShape->documentToShape(it->m_oldControlPoint1));
else
point->removeControlPoint1();
if (it->m_hadControlPoint2)
point->setControlPoint2(pathShape->documentToShape(it->m_oldControlPoint2));
else
point->removeControlPoint2();
}
}
示例2: redo
void KoPathPointTypeCommand::redo()
{
KUndo2Command::redo();
repaint(false);
m_additionalPointData.clear();
QList<PointData>::iterator it(m_oldPointData.begin());
for (; it != m_oldPointData.end(); ++it) {
KoPathPoint *point = it->m_pointData.pathShape->pointByIndex(it->m_pointData.pointIndex);
KoPathPoint::PointProperties properties = point->properties();
switch (m_pointType) {
case Line: {
point->removeControlPoint1();
point->removeControlPoint2();
break;
}
case Curve: {
KoPathPointIndex pointIndex = it->m_pointData.pointIndex;
KoPathPointIndex prevIndex;
KoPathPointIndex nextIndex;
KoPathShape * path = it->m_pointData.pathShape;
// get previous path node
if (pointIndex.second > 0)
prevIndex = KoPathPointIndex(pointIndex.first, pointIndex.second - 1);
else if (pointIndex.second == 0 && path->isClosedSubpath(pointIndex.first))
prevIndex = KoPathPointIndex(pointIndex.first, path->subpathPointCount(pointIndex.first) - 1);
// get next node
if (pointIndex.second < path->subpathPointCount(pointIndex.first) - 1)
nextIndex = KoPathPointIndex(pointIndex.first, pointIndex.second + 1);
else if (pointIndex.second < path->subpathPointCount(pointIndex.first) - 1
&& path->isClosedSubpath(pointIndex.first))
nextIndex = KoPathPointIndex(pointIndex.first, 0);
KoPathPoint * prevPoint = path->pointByIndex(prevIndex);
KoPathPoint * nextPoint = path->pointByIndex(nextIndex);
if (prevPoint && ! point->activeControlPoint1() && appendPointData(KoPathPointData(path, prevIndex))) {
KoPathSegment cubic = KoPathSegment(prevPoint, point).toCubic();
if (prevPoint->activeControlPoint2()) {
prevPoint->setControlPoint2(cubic.first()->controlPoint2());
point->setControlPoint1(cubic.second()->controlPoint1());
} else
point->setControlPoint1(cubic.second()->controlPoint1());
}
if (nextPoint && ! point->activeControlPoint2() && appendPointData(KoPathPointData(path, nextIndex))) {
KoPathSegment cubic = KoPathSegment(point, nextPoint).toCubic();
if (nextPoint->activeControlPoint1()) {
point->setControlPoint2(cubic.first()->controlPoint2());
nextPoint->setControlPoint1(cubic.second()->controlPoint1());
} else
point->setControlPoint2(cubic.first()->controlPoint2());
}
break;
}
case Symmetric: {
properties &= ~KoPathPoint::IsSmooth;
properties |= KoPathPoint::IsSymmetric;
// calculate vector from node point to first control point and normalize it
QPointF directionC1 = point->controlPoint1() - point->point();
qreal dirLengthC1 = sqrt(directionC1.x() * directionC1.x() + directionC1.y() * directionC1.y());
directionC1 /= dirLengthC1;
// calculate vector from node point to second control point and normalize it
QPointF directionC2 = point->controlPoint2() - point->point();
qreal dirLengthC2 = sqrt(directionC2.x() * directionC2.x() + directionC2.y() * directionC2.y());
directionC2 /= dirLengthC2;
// calculate the average distance of the control points to the node point
qreal averageLength = 0.5 * (dirLengthC1 + dirLengthC2);
// compute position of the control points so that they lie on a line going through the node point
// the new distance of the control points is the average distance to the node point
point->setControlPoint1(point->point() + 0.5 * averageLength * (directionC1 - directionC2));
point->setControlPoint2(point->point() + 0.5 * averageLength * (directionC2 - directionC1));
}
break;
case Smooth: {
properties &= ~KoPathPoint::IsSymmetric;
properties |= KoPathPoint::IsSmooth;
// calculate vector from node point to first control point and normalize it
QPointF directionC1 = point->controlPoint1() - point->point();
qreal dirLengthC1 = sqrt(directionC1.x() * directionC1.x() + directionC1.y() * directionC1.y());
directionC1 /= dirLengthC1;
// calculate vector from node point to second control point and normalize it
QPointF directionC2 = point->controlPoint2() - point->point();
qreal dirLengthC2 = sqrt(directionC2.x() * directionC2.x() + directionC2.y() * directionC2.y());
directionC2 /= dirLengthC2;
// compute position of the control points so that they lie on a line going through the node point
// the new distance of the control points is the average distance to the node point
point->setControlPoint1(point->point() + 0.5 * dirLengthC1 * (directionC1 - directionC2));
point->setControlPoint2(point->point() + 0.5 * dirLengthC2 * (directionC2 - directionC1));
}
break;
case Corner:
default:
properties &= ~KoPathPoint::IsSymmetric;
properties &= ~KoPathPoint::IsSmooth;
break;
}
point->setProperties(properties);
//.........这里部分代码省略.........