9#ifndef KOCREATEPATHTOOL_P_H
10#define KOCREATEPATHTOOL_P_H
12#include <QPainterPath>
43 if (!pathPoint || ! pathPoint->
parent()) {
46 path = pathPoint->
parent();
93 qreal dx =
p1.x() -
p2.x();
94 qreal dy =
p1.y() -
p2.y();
95 return dx * dx + dy * dy;
113 bool snap(
const QPointF &mousePosition,
KoSnapProxy * proxy, qreal maxSnapDistance)
override {
120 qreal currentAngle = line.angle();
122 int nextStep = prevStep + 1;
126 if (qAbs(currentAngle - prevAngle) <= qAbs(currentAngle - nextAngle)) {
127 line.setAngle(prevAngle);
129 line.setAngle(nextAngle);
132 qreal maxSquareSnapDistance = maxSnapDistance * maxSnapDistance;
134 if (snapDistance > maxSquareSnapDistance)
223 rect =
rect.united(QRectF(point, controlPoint).normalized());
229 rect =
rect.united(QRectF(point, controlPoint).normalized());
235 rect.adjust(-border.x(), -border.y(), border.x(), border.y());
245 qreal minDistance = HUGE_VAL;
249 Q_FOREACH(
KoShape * s, shapes) {
258 uint subpathCount = path->subpathCount();
259 for (
uint i = 0; i < subpathCount; ++i) {
260 if (path->isClosedSubpath(i))
265 if (d < minDistance && d < maxDistance) {
272 if (d < minDistance && d < maxDistance) {
290 startShape = pointAtStart.
path;
291 startPoint = pointAtStart.
point;
294 endShape = pointAtEnd.
path;
295 endPoint = pointAtEnd.
point;
299 if (!startPoint && !endPoint)
302 if (startPoint == endPoint)
318 if (startShape && startPoint) {
320 pathShape->
combine(startShape);
325 if (endShape && endPoint) {
327 if (endShape != startShape) {
333 bool connectToSingleSubpath = (startShape == endShape && startIndex.first == endIndex.first);
335 if (startIndex.second == 0 && !connectToSingleSubpath) {
339 if (endIndex.second > 0 && !connectToSingleSubpath) {
429 if (angleSnap == Qt::Checked)
float value(const T *src, size_t ch)
QPair< int, int > KoPathPointIndex
bool snap(const QPointF &mousePosition, KoSnapProxy *proxy, qreal maxSnapDistance) override
QPainterPath decoration(const KoViewConverter &converter) const override
returns the current snap strategy decoration
void setAngleStep(qreal angleStep)
AngleSnapStrategy(qreal angleStep, bool active)
void setStartPoint(const QPointF &startPoint)
bool autoSmoothBezierCurves(bool defaultValue=false) const
void setAutoSmoothBezierCurves(bool value)
virtual KoShapeManager * shapeManager() const =0
virtual const KoViewConverter * viewConverter() const =0
virtual void updateCanvas(const QRectF &rc)=0
bool isParametricShape() const
Check if object is a parametric shape.
Describe a KoPathPoint by a KoPathShape and its indices.
The undo / redo command for merging two subpath end points.
void redo() override
redo the command
A KoPathPoint represents a point in a path.
QRectF boundingRect(bool active=true) const
Get the bounding rect of the point.
KoPathShape * parent() const
Get the path shape the point belongs to.
The position of a path point within a path shape.
int subpathPointCount(int subpathIndex) const
Returns the number of points in a subpath.
bool reverseSubpath(int subpathIndex)
Reverse subpath.
int pointCount() const
Returns the number of points in the path.
bool moveSubpath(int oldSubpathIndex, int newSubpathIndex)
Moves the position of a subpath within a path.
int subpathCount() const
Returns the number of subpaths in the path.
KoPathPointIndex pathPointIndex(const KoPathPoint *point) const
Returns the path point index of a given path point.
KoPathPoint * pointByIndex(const KoPathPointIndex &pointIndex) const
Returns the path point specified by a path point index.
int combine(KoPathShape *path)
Combines two path shapes by appending the data of the specified path.
QList< KoShape * > shapes
QList< KoShape * > shapesAt(const QRectF &rect, bool omitHiddenShapes=true, bool containedMode=false)
void reset()
Resets the snap guide.
QRectF boundingRect()
returns the bounding rect of the guide
void setSnappedPosition(const QPointF &position, SnapType snapType)
sets the current snapped position
static qreal squareDistance(const QPointF &p1, const QPointF &p2)
QPointF snappedPosition() const
returns the snapped position form the last call to snapToPoints
virtual qreal viewToDocumentX(qreal viewX) const
virtual QPointF viewToDocument(const QPointF &viewPoint) const
Small helper to keep track of a path point and its parent path shape.
bool operator!=(const PathConnectionPoint &rhs) const
bool operator==(const PathConnectionPoint &rhs) const
void validate(KoCanvasBase *canvas)
PathConnectionPoint & operator=(KoPathPoint *pathPoint)