本文整理汇总了C++中KoPathShape::normalize方法的典型用法代码示例。如果您正苦于以下问题:C++ KoPathShape::normalize方法的具体用法?C++ KoPathShape::normalize怎么用?C++ KoPathShape::normalize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KoPathShape
的用法示例。
在下文中一共展示了KoPathShape::normalize方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
}
}
示例2: KoPathShape
KoShape *KoPathShapeFactory::createDefaultShape(KoDocumentResourceManager *) const
{
KoPathShape* path = new KoPathShape();
path->moveTo(QPointF(0, 50));
path->curveTo(QPointF(0, 120), QPointF(50, 120), QPointF(50, 50));
path->curveTo(QPointF(50, -20), QPointF(100, -20), QPointF(100, 50));
path->normalize();
path->setStroke(new KoShapeStroke(1.0));
return path;
}
示例3: redo
void KoPathControlPointMoveCommand::redo()
{
KUndo2Command::redo();
KoPathShape * pathShape = m_pointData.pathShape;
KoPathPoint * point = pathShape->pointByIndex(m_pointData.pointIndex);
if (point) {
pathShape->update();
if (m_pointType == KoPathPoint::ControlPoint1) {
point->setControlPoint1(point->controlPoint1() + m_offset);
if (point->properties() & KoPathPoint::IsSymmetric) {
// set the other control point so that it lies on the line between the moved
// control point and the point, with the same distance to the point as the moved point
point->setControlPoint2(2.0 * point->point() - point->controlPoint1());
} else if (point->properties() & KoPathPoint::IsSmooth) {
// move the other control point so that it lies on the line through point and control point
// keeping its distance to the point
QPointF direction = point->point() - point->controlPoint1();
direction /= sqrt(direction.x() * direction.x() + direction.y() * direction.y());
QPointF distance = point->point() - point->controlPoint2();
qreal length = sqrt(distance.x() * distance.x() + distance.y() * distance.y());
point->setControlPoint2(point->point() + length * direction);
}
} else if (m_pointType == KoPathPoint::ControlPoint2) {
point->setControlPoint2(point->controlPoint2() + m_offset);
if (point->properties() & KoPathPoint::IsSymmetric) {
// set the other control point so that it lies on the line between the moved
// control point and the point, with the same distance to the point as the moved point
point->setControlPoint1(2.0 * point->point() - point->controlPoint2());
} else if (point->properties() & KoPathPoint::IsSmooth) {
// move the other control point so that it lies on the line through point and control point
// keeping its distance to the point
QPointF direction = point->point() - point->controlPoint2();
direction /= sqrt(direction.x() * direction.x() + direction.y() * direction.y());
QPointF distance = point->point() - point->controlPoint1();
qreal length = sqrt(distance.x() * distance.x() + distance.y() * distance.y());
point->setControlPoint1(point->point() + length * direction);
}
}
pathShape->normalize();
pathShape->update();
}
}
示例4: redo
void KoSubpathJoinCommand::redo()
{
KUndo2Command::redo();
KoPathShape * pathShape = m_pointData1.pathShape;
bool closeSubpath = m_pointData1.pointIndex.first == m_pointData2.pointIndex.first;
KoPathPoint * point1 = pathShape->pointByIndex(m_pointData1.pointIndex);
KoPathPoint * point2 = pathShape->pointByIndex(m_pointData2.pointIndex);
// if the endpoint is has a control point create a contol point for the new segment to be
// at the symetric position to the exiting one
if (m_reverse & ReverseFirst || closeSubpath) {
if (point1->activeControlPoint2())
point1->setControlPoint1(2.0 * point1->point() - point1->controlPoint2());
} else if (point1->activeControlPoint1())
point1->setControlPoint2(2.0 * point1->point() - point1->controlPoint1());
if (m_reverse & ReverseSecond || closeSubpath) {
if (point2->activeControlPoint1())
point2->setControlPoint2(2.0 * point2->point() - point2->controlPoint1());
} else if (point2->activeControlPoint2())
point2->setControlPoint1(2.0 * point2->point() - point2->controlPoint2());
if (closeSubpath) {
pathShape->closeSubpath(m_pointData1.pointIndex);
} else {
if (m_reverse & ReverseFirst) {
pathShape->reverseSubpath(m_pointData1.pointIndex.first);
}
if (m_reverse & ReverseSecond) {
pathShape->reverseSubpath(m_pointData2.pointIndex.first);
}
pathShape->moveSubpath(m_pointData2.pointIndex.first, m_pointData1.pointIndex.first + 1);
m_splitIndex = m_pointData1.pointIndex;
m_splitIndex.second = pathShape->subpathPointCount(m_pointData1.pointIndex.first) - 1;
pathShape->join(m_pointData1.pointIndex.first);
}
pathShape->normalize();
pathShape->update();
}
示例5: testAddChild
void KisShapeSelectionTest::testAddChild()
{
const KoColorSpace * cs = KoColorSpaceRegistry::instance()->rgb8();
KisImageSP image = new KisImage(new KisUndoAdapter(0), 300, 300, cs, "test");
KisSelectionSP selection = new KisSelection();
QVERIFY(selection->hasPixelSelection() == false);
QVERIFY(selection->hasShapeSelection() == false);
KisPixelSelectionSP pixelSelection = selection->getOrCreatePixelSelection();
pixelSelection->select(QRect(0, 0, 100, 100));
// Selection is using the pixel selection as datamanager so no projection update
// needed
QCOMPARE(pixelSelection->selected(25, 25), MAX_SELECTED);
QCOMPARE(selection->selectedExactRect(), QRect(0, 0, 100, 100));
QRect rect(50, 50, 100, 100);
QTransform matrix;
matrix.scale(1 / image->xRes(), 1 / image->yRes());
rect = matrix.mapRect(rect);
KoPathShape* shape = new KoPathShape();
shape->setShapeId(KoPathShapeId);
shape->moveTo(rect.topLeft());
shape->lineTo(rect.topLeft() + QPointF(rect.width(), 0));
shape->lineTo(rect.bottomRight());
shape->lineTo(rect.topLeft() + QPointF(0, rect.height()));
shape->close();
shape->normalize();
KisShapeSelection * shapeSelection = new KisShapeSelection(image, selection);
selection->setShapeSelection(shapeSelection);
shapeSelection->addShape(shape);
QCOMPARE(pixelSelection->selected(25, 25), MAX_SELECTED);
QCOMPARE(selection->selectedExactRect(), QRect(0, 0, 150, 150));
selection->updateProjection();
}
示例6: undo
void KoSubpathJoinCommand::undo()
{
KUndo2Command::undo();
KoPathShape * pathShape = m_pointData1.pathShape;
pathShape->update();
if (m_pointData1.pointIndex.first == m_pointData2.pointIndex.first) {
pathShape->openSubpath(m_pointData1.pointIndex);
} else {
pathShape->breakAfter(m_splitIndex);
pathShape->moveSubpath(m_pointData1.pointIndex.first + 1, m_pointData2.pointIndex.first);
if (m_reverse & ReverseSecond) {
pathShape->reverseSubpath(m_pointData2.pointIndex.first);
}
if (m_reverse & ReverseFirst) {
pathShape->reverseSubpath(m_pointData1.pointIndex.first);
}
}
KoPathPoint * point1 = pathShape->pointByIndex(m_pointData1.pointIndex);
KoPathPoint * point2 = pathShape->pointByIndex(m_pointData2.pointIndex);
// restore the old end points
if (m_reverse & ReverseFirst)
point1->setControlPoint1(pathShape->documentToShape(m_oldControlPoint1));
else
point1->setControlPoint2(pathShape->documentToShape(m_oldControlPoint1));
point1->setProperties(m_oldProperties1);
if (m_reverse & ReverseSecond)
point2->setControlPoint1(pathShape->documentToShape(m_oldControlPoint2));
else
point2->setControlPoint2(pathShape->documentToShape(m_oldControlPoint2));
point2->setProperties(m_oldProperties2);
pathShape->normalize();
pathShape->update();
}
示例7: createEllipseShape
KoShape* KisShapeToolHelper::createEllipseShape(const QRectF& rect)
{
KoShape* shape;
KoShapeFactoryBase *rectFactory = KoShapeRegistry::instance()->value("EllipseShape");
if (rectFactory) {
shape = rectFactory->createDefaultShape();
shape->setSize(rect.size());
shape->setPosition(rect.topLeft());
} else {
//Fallback if the plugin wasn't found
KoPathShape* path = new KoPathShape();
path->setShapeId(KoPathShapeId);
QPointF rightMiddle = QPointF(rect.left() + rect.width(), rect.top() + rect.height() / 2);
path->moveTo(rightMiddle);
path->arcTo(rect.width() / 2, rect.height() / 2, 0, 360.0);
path->close();
path->normalize();
shape = path;
}
return shape;
}
示例8: createRectangleShape
KoShape* KisShapeToolHelper::createRectangleShape(const QRectF& rect)
{
KoShape* shape;
KoShapeFactoryBase *rectFactory = KoShapeRegistry::instance()->value("RectangleShape");
if (rectFactory) {
shape = rectFactory->createDefaultShape();
shape->setSize(rect.size());
shape->setPosition(rect.topLeft());
} else {
//Fallback if the plugin wasn't found
KoPathShape* path = new KoPathShape();
path->setShapeId(KoPathShapeId);
path->moveTo(rect.topLeft());
path->lineTo(rect.topLeft() + QPointF(rect.width(), 0));
path->lineTo(rect.bottomRight());
path->lineTo(rect.topLeft() + QPointF(0, rect.height()));
path->close();
path->normalize();
shape = path;
}
return shape;
}