Krita Source Code Documentation
Loading...
Searching...
No Matches
KoPathSegmentBreakCommand.cpp
Go to the documentation of this file.
1/* This file is part of the KDE project
2 * SPDX-FileCopyrightText: 2006 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 <klocalizedstring.h>
11#include <math.h>
12
14 : KUndo2Command(parent)
15 , m_pointData(pointData)
16 , m_startIndex(-1, -1)
17 , m_broken(false)
18{
21
22 const int numPoints = m_pointData.pathShape->subpathPointCount(m_startIndex.first);
23 m_startIndex.second = (m_startIndex.second + 1) % numPoints;
24 }
25 setText(kundo2_i18n("Break subpath"));
26}
27
31
33{
35 // a repaint before is needed as the shape can shrink during the break
37 if (m_startIndex.first != -1) {
41 } else {
43 if (m_broken) {
46 }
47 }
48}
49
virtual void undo()
void setText(const KUndo2MagicString &text)
virtual void redo()
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
KoPathSegmentBreakCommand(const KoPathPointData &pointData, KUndo2Command *parent=0)
void undo() override
revert the actions done in redo
void redo() override
redo the command
bool breakAfter(const KoPathPointIndex &pointIndex)
Breaks the path after the point index.
int subpathPointCount(int subpathIndex) const
Returns the number of points in a subpath.
bool isClosedSubpath(int subpathIndex) const
Checks if a subpath is closed.
virtual QPointF normalize()
Normalizes the path data.
bool join(int subpathIndex)
Joins the given subpath with the following one.
KoPathPointIndex closeSubpath(const KoPathPointIndex &pointIndex)
Close a open subpath.
KoPathPointIndex openSubpath(const KoPathPointIndex &pointIndex)
Opens a closed subpath.
void update() const override
reimplemented
KUndo2MagicString kundo2_i18n(const char *text)