Krita Source Code Documentation
Loading...
Searching...
No Matches
KoPathCombineCommand Class Reference

The undo / redo command for combining two or more paths into one. More...

#include <KoPathCombineCommand.h>

+ Inheritance diagram for KoPathCombineCommand:

Public Member Functions

KoPathShape * combinedPath () const
 
 KoPathCombineCommand (KoShapeControllerBase *controller, const QList< KoPathShape * > &paths, KUndo2Command *parent=0)
 
KoPathPointData originalToCombined (KoPathPointData pd) const
 
 Private (KoShapeControllerBase *c, const QList< KoPathShape * > &p)
 
void redo () override
 redo the command
 
void undo () override
 revert the actions done in redo
 
 ~KoPathCombineCommand () override
 
 ~Private ()
 
- Public Member Functions inherited from KUndo2Command
QString actionText () const
 
virtual bool canAnnihilateWith (const KUndo2Command *other) const
 
const KUndo2Command * child (int index) const
 
int childCount () const
 
virtual QTime endTime () const
 
KUndo2CommandExtraData * extraData () const
 
bool hasParent () const
 
virtual int id () const
 
virtual bool isMerged () const
 
 KUndo2Command (const KUndo2MagicString &text, KUndo2Command *parent=0)
 
 KUndo2Command (KUndo2Command *parent=0)
 
virtual QVector< KUndo2Command * > mergeCommandsVector () const
 
virtual bool mergeWith (const KUndo2Command *other)
 
virtual void redoMergedCommands ()
 
void setEndTime ()
 
virtual void setEndTime (const QTime &time)
 
void setExtraData (KUndo2CommandExtraData *data)
 
void setText (const KUndo2MagicString &text)
 
void setTime ()
 
virtual void setTime (const QTime &time)
 
virtual void setTimedID (int timedID)
 
KUndo2MagicString text () const
 
virtual QTime time () const
 
virtual int timedId () const
 
virtual bool timedMergeWith (KUndo2Command *other)
 
virtual void undoMergedCommands ()
 
virtual ~KUndo2Command ()
 

Public Attributes

KoPathShape * combinedPath
 
KoShapeContainer * combinedPathParent
 
KoShapeControllerBase * controller
 
bool isCombined
 
QList< KoShapeContainer * > oldParents
 
QList< KoPathShape * > paths
 
QHash< KoPathShape *, int > shapeStartSegmentIndex
 

Private Attributes

Private *const d
 
- Private Attributes inherited from Private
KisCanvas2 * canvas
 
int displayedFrame
 
int intendedFrame
 

Additional Inherited Members

- Private Member Functions inherited from Private
 Private (KisCanvas2 *c)
 

Detailed Description

The undo / redo command for combining two or more paths into one.

Definition at line 18 of file KoPathCombineCommand.cpp.

Constructor & Destructor Documentation

◆ ~Private()

KoPathCombineCommand::~Private ( )
inline

Definition at line 31 of file KoPathCombineCommand.cpp.

31 {
32 if (isCombined && controller) {
33 Q_FOREACH (KoPathShape* path, paths) {
34 delete path;
35 }
36 } else {
37 delete combinedPath;
38 }
39 }
QList< KoPathShape * > paths
KoShapeControllerBase * controller
The position of a path point within a path shape.
Definition KoPathShape.h:63

◆ KoPathCombineCommand()

KoPathCombineCommand::KoPathCombineCommand ( KoShapeControllerBase * controller,
const QList< KoPathShape * > & paths,
KUndo2Command * parent = 0 )

Command for combining a list of paths into one single path.

Parameters
controllerthe controller to used for removing/inserting.
pathsthe list of paths to combine
parentthe parent command used for macro commands

Definition at line 52 of file KoPathCombineCommand.cpp.

54 : KUndo2Command(kundo2_i18n("Combine paths"), parent)
55 , d(new Private(controller, paths))
56{
58
59 Q_FOREACH (KoPathShape* path, d->paths) {
60 if (!d->combinedPath) {
61 KoPathShape *clone = dynamic_cast<KoPathShape*>(path->cloneShape());
63
64 d->combinedPath = clone;
65 d->combinedPathParent = path->parent();
66 d->shapeStartSegmentIndex[path] = 0;
67 } else {
68 const int startSegmentIndex = d->combinedPath->combine(path);
69 d->shapeStartSegmentIndex[path] = startSegmentIndex;
70 }
71 }
72}
KUndo2Command(KUndo2Command *parent=0)
#define KIS_SAFE_ASSERT_RECOVER_RETURN(cond)
Definition kis_assert.h:128
#define KIS_ASSERT_RECOVER_BREAK(cond)
Definition kis_assert.h:65
KUndo2MagicString kundo2_i18n(const char *text)

References d, KIS_ASSERT_RECOVER_BREAK, KIS_SAFE_ASSERT_RECOVER_RETURN, and paths.

◆ ~KoPathCombineCommand()

KoPathCombineCommand::~KoPathCombineCommand ( )
override

Definition at line 74 of file KoPathCombineCommand.cpp.

75{
76 delete d;
77}

References d.

Member Function Documentation

◆ combinedPath()

KoPathShape * KoPathCombineCommand::combinedPath ( ) const

◆ originalToCombined()

KoPathPointData KoPathCombineCommand::originalToCombined ( KoPathPointData pd) const

Definition at line 118 of file KoPathCombineCommand.cpp.

119{
120 KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(d->shapeStartSegmentIndex.contains(pd.pathShape), pd);
121
122 const int segmentOffset = d->shapeStartSegmentIndex[pd.pathShape];
123
124 KoPathPointIndex newIndex(segmentOffset + pd.pointIndex.first, pd.pointIndex.second);
125 return KoPathPointData(d->combinedPath, newIndex);
126}
QPair< int, int > KoPathPointIndex
Definition KoPathShape.h:28
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
#define KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(cond, val)
Definition kis_assert.h:129

References d, KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE, KoPathPointData::pathShape, and KoPathPointData::pointIndex.

◆ Private()

KoPathCombineCommand::Private ( KoShapeControllerBase * c,
const QList< KoPathShape * > & p )
inline

Definition at line 21 of file KoPathCombineCommand.cpp.

22 : controller(c), paths(p)
23 , combinedPath(0)
25 , isCombined(false)
26 {
27 foreach (KoPathShape * path, paths) {
28 oldParents.append(path->parent());
29 }
30 }
const Params2D p
KoShapeContainer * combinedPathParent
QList< KoShapeContainer * > oldParents

◆ redo()

void KoPathCombineCommand::redo ( )
overridevirtual

redo the command

Reimplemented from KUndo2Command.

Definition at line 79 of file KoPathCombineCommand.cpp.

80{
82 if (d->paths.isEmpty()) return;
83
84 d->isCombined = true;
85
86 if (d->controller) {
87 Q_FOREACH (KoPathShape* p, d->paths) {
88 p->setParent(0);
89 }
90 d->combinedPath->setParent(d->combinedPathParent);
91 }
92}
virtual void redo()

References d, p, and KUndo2Command::redo().

◆ undo()

void KoPathCombineCommand::undo ( )
overridevirtual

revert the actions done in redo

Reimplemented from KUndo2Command.

Definition at line 94 of file KoPathCombineCommand.cpp.

95{
96 if (! d->paths.size())
97 return;
98
99 d->isCombined = false;
100
101 if (d->controller) {
102 d->combinedPath->setParent(0);
103
104 auto parentIt = d->oldParents.begin();
105 Q_FOREACH (KoPathShape* p, d->paths) {
106 p->setParent(*parentIt);
107 ++parentIt;
108 }
109 }
111}
virtual void undo()

References d, p, and KUndo2Command::undo().

Member Data Documentation

◆ combinedPath

KoPathShape * KoPathCombineCommand::combinedPath

Definition at line 44 of file KoPathCombineCommand.cpp.

◆ combinedPathParent

KoShapeContainer* KoPathCombineCommand::combinedPathParent

Definition at line 45 of file KoPathCombineCommand.cpp.

◆ controller

KoShapeControllerBase* KoPathCombineCommand::controller

Definition at line 41 of file KoPathCombineCommand.cpp.

◆ d

Private* const KoPathCombineCommand::d
private

Definition at line 41 of file KoPathCombineCommand.h.

◆ isCombined

bool KoPathCombineCommand::isCombined

Definition at line 49 of file KoPathCombineCommand.cpp.

◆ oldParents

QList<KoShapeContainer*> KoPathCombineCommand::oldParents

Definition at line 43 of file KoPathCombineCommand.cpp.

◆ paths

QList<KoPathShape*> KoPathCombineCommand::paths

Definition at line 42 of file KoPathCombineCommand.cpp.

◆ shapeStartSegmentIndex

QHash<KoPathShape*, int> KoPathCombineCommand::shapeStartSegmentIndex

Definition at line 47 of file KoPathCombineCommand.cpp.


The documentation for this class was generated from the following files: