10#include <klocalizedstring.h>
20 , m_pointType(pointType)
23 for (; it != pointDataList.end(); ++it) {
24 KoPathPoint *point = it->pathShape->pointByIndex(it->pointIndex);
51 KoPathPoint *point = it->m_pointData.pathShape->pointByIndex(it->m_pointData.pointIndex);
52 KoPathPoint::PointProperties properties = point->
properties();
66 if (pointIndex.second > 0)
68 else if (pointIndex.second == 0 && path->isClosedSubpath(pointIndex.first))
69 prevIndex =
KoPathPointIndex(pointIndex.first, path->subpathPointCount(pointIndex.first) - 1);
71 if (pointIndex.second < path->subpathPointCount(pointIndex.first) - 1)
73 else if (pointIndex.second < path->subpathPointCount(pointIndex.first) - 1
74 && path->isClosedSubpath(pointIndex.first))
77 KoPathPoint * prevPoint = path->pointByIndex(prevIndex);
78 KoPathPoint * nextPoint = path->pointByIndex(nextIndex);
105 qreal dirLengthC1 = sqrt(directionC1.x() * directionC1.x() + directionC1.y() * directionC1.y());
106 directionC1 /= dirLengthC1;
109 qreal dirLengthC2 = sqrt(directionC2.x() * directionC2.x() + directionC2.y() * directionC2.y());
110 directionC2 /= dirLengthC2;
112 qreal averageLength = 0.5 * (dirLengthC1 + dirLengthC2);
166 KoPathPoint::PointProperties properties = point->
properties();
173 qreal dirLengthC1 = sqrt(directionC1.x() * directionC1.x() + directionC1.y() * directionC1.y());
174 directionC1 /= dirLengthC1;
177 qreal dirLengthC2 = sqrt(directionC2.x() * directionC2.x() + directionC2.y() * directionC2.y());
178 directionC2 /= dirLengthC2;
190 for (; it != data.end(); ++it) {
191 KoPathShape *pathShape = it->m_pointData.pathShape;
195 if (it->m_hadControlPoint1)
199 if (it->m_hadControlPoint2)
QPair< int, int > KoPathPointIndex
void setText(const KUndo2MagicString &text)
the base command for commands altering a path shape
QSet< KoPathShape * > m_shapes
the shapes the command operates on
void repaint(bool normalizeShapes)
Describe a KoPathPoint by a KoPathShape and its indices.
KoPathPointIndex pointIndex
position of the point in the path shape
KoPathShape * pathShape
path shape the path point belongs too
void undo() override
revert the actions done in redo
static void makeCubicPointSmooth(KoPathPoint *point)
QList< PointData > m_additionalPointData
~KoPathPointTypeCommand() override
void redo() override
redo the command
PointType
The type of the point.
QList< PointData > m_oldPointData
bool appendPointData(KoPathPointData data)
KoPathPointTypeCommand(const QList< KoPathPointData > &pointDataList, PointType pointType, KUndo2Command *parent=0)
void undoChanges(const QList< PointData > &data)
A KoPathPoint represents a point in a path.
PointProperties properties
void setProperties(PointProperties properties)
Set the properties of a point.
void setControlPoint1(const QPointF &point)
Set the control point 1.
void setControlPoint2(const QPointF &point)
Set the control point 2.
void removeControlPoint1()
Removes the first control point.
@ IsSmooth
it is smooth, both control points on a line through the point
@ IsSymmetric
it is symmetric, like smooth but control points have same distance to point
void removeControlPoint2()
Removes the second control point.
A KoPathSegment consist of two neighboring KoPathPoints.
KoPathSegment toCubic() const
Returns cubic bezier curve segment of this segment.
The position of a path point within a path shape.
KoPathPoint * pointByIndex(const KoPathPointIndex &pointIndex) const
Returns the path point specified by a path point index.
QPointF shapeToDocument(const QPointF &point) const
Transforms point from shape coordinates to document coordinates.
QPointF documentToShape(const QPointF &point) const
Transforms point from document coordinates to shape coordinates.
KUndo2MagicString kundo2_i18n(const char *text)
KoPathPoint::PointProperties m_oldProperties
QPointF m_oldControlPoint2
QPointF m_oldControlPoint1