Krita Source Code Documentation
Loading...
Searching...
No Matches
KoParameterToPathCommand.cpp
Go to the documentation of this file.
1/* This file is part of the KDE project
2 * SPDX-FileCopyrightText: 2006, 2008 Jan Hambrecht <jaham@gmx.net>
3 * SPDX-FileCopyrightText: 2006, 2007 Thorsten Zachmann <zachmann@kde.org>
4 *
5 * SPDX-License-Identifier: LGPL-2.0-or-later
6 */
7
9#include "KoPathPoint.h"
10#include "KoParameterShape.h"
11#include <klocalizedstring.h>
12
24
26 : KUndo2Command(parent),
28{
29 d->shapes.append(shape);
30 d->initialize();
31 setText(kundo2_i18n("Convert to Path"));
32}
33
35 : KUndo2Command(parent),
37{
38 d->shapes = shapes;
39 d->initialize();
40 setText(kundo2_i18n("Convert to Path"));
41}
42
47
49{
51 for (int i = 0; i < d->shapes.size(); ++i) {
52 KoParameterShape *parameterShape = d->shapes.at(i);
53 parameterShape->update();
54 parameterShape->setParametricShape(false);
55 parameterShape->update();
56 }
57}
58
60{
62 for (int i = 0; i < d->shapes.size(); ++i) {
63 KoParameterShape * parameterShape = d->shapes.at(i);
64 parameterShape->update();
65 parameterShape->setParametricShape(true);
66 d->copyPath(parameterShape, d->copies[i]);
67 parameterShape->update();
68 }
69}
70
72{
73 Q_FOREACH (KoParameterShape *shape, shapes) {
74 KoPathShape *p = new KoPathShape();
75 copyPath(p, shape);
76 copies.append(p);
77 }
78}
79
81{
82 destination->clear();
83
84 int subpathCount = source->subpathCount();
85 for (int subpathIndex = 0; subpathIndex < subpathCount; ++subpathIndex) {
86 int pointCount = source->subpathPointCount(subpathIndex);
87 if (! pointCount)
88 continue;
89
90 KoSubpath * subpath = new KoSubpath;
91 for (int pointIndex = 0; pointIndex < pointCount; ++pointIndex) {
92 KoPathPoint * p = source->pointByIndex(KoPathPointIndex(subpathIndex, pointIndex));
93 KoPathPoint * c = new KoPathPoint(*p, destination);
94 subpath->append(c);
95 }
96 destination->addSubpath(subpath, subpathIndex);
97 }
98 destination->setTransformation(source->transformation());
99}
const Params2D p
KisMagneticGraph::vertex_descriptor source(typename KisMagneticGraph::edge_descriptor e, KisMagneticGraph g)
QList< KoPathPoint * > KoSubpath
a KoSubpath contains a path from a moveTo until a close or a new moveTo
Definition KoPathShape.h:31
QPair< int, int > KoPathPointIndex
Definition KoPathShape.h:28
virtual void undo()
void setText(const KUndo2MagicString &text)
virtual void redo()
void setParametricShape(bool parametric)
Set if the shape can be modified using parameters.
void copyPath(KoPathShape *destination, KoPathShape *source)
KoParameterToPathCommandPrivate *const d
KoParameterToPathCommand(KoParameterShape *shape, KUndo2Command *parent=0)
void undo() override
revert the actions done in redo
void redo() override
redo the command
A KoPathPoint represents a point in a path.
The position of a path point within a path shape.
Definition KoPathShape.h:63
bool addSubpath(KoSubpath *subpath, int subpathIndex)
Adds a subpath at the given index to the path.
void clear()
Removes all subpaths and their points from the path.
void update() const override
reimplemented
void setTransformation(const QTransform &matrix)
Definition KoShape.cpp:417
KUndo2MagicString kundo2_i18n(const char *text)