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

The undo / redo command for setting the shape clip path. More...

#include <KoShapeClipCommand.h>

+ Inheritance diagram for KoShapeClipCommand:

Public Member Functions

 KoShapeClipCommand (KoShapeControllerBase *controller, const QList< KoShape * > &shapes, const QList< KoPathShape * > &clipPathShapes, KUndo2Command *parent=0)
 
 KoShapeClipCommand (KoShapeControllerBase *controller, KoShape *shape, const QList< KoPathShape * > &clipPathShapes, KUndo2Command *parent=0)
 
 Private (KoShapeControllerBase *c)
 
void redo () override
 redo the command
 
void undo () override
 revert the actions done in redo
 
 ~KoShapeClipCommand () override
 Destroys the command.
 
 ~Private ()
 
- Public Member Functions inherited from KUndo2Command
QString actionText () const
 
virtual bool canAnnihilateWith (const KUndo2Command *other) const
 
const KUndo2Commandchild (int index) const
 
int childCount () const
 
virtual QTime endTime () const
 
KUndo2CommandExtraDataextraData () 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

QList< KoPathShape * > clipPathShapes
 
KoShapeControllerBasecontroller
 
bool executed
 
QList< KoClipPath * > newClipPaths
 
QList< KoClipPath * > oldClipPaths
 
QList< KoShapeContainer * > oldParents
 
QList< KoShape * > shapesToClip
 

Private Attributes

Private *const d
 
- Private Attributes inherited from Private
KisCanvas2canvas
 
int displayedFrame
 
int intendedFrame
 

Additional Inherited Members

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

Detailed Description

The undo / redo command for setting the shape clip path.

Definition at line 18 of file KoShapeClipCommand.cpp.

Constructor & Destructor Documentation

◆ ~Private()

KoShapeClipCommand::~Private ( )
inline

Definition at line 25 of file KoShapeClipCommand.cpp.

25 {
26 if (executed) {
27 qDeleteAll(oldClipPaths);
28 } else {
29 qDeleteAll(newClipPaths);
30 }
31 }
QList< KoClipPath * > oldClipPaths
QList< KoClipPath * > newClipPaths

◆ KoShapeClipCommand() [1/2]

KoShapeClipCommand::KoShapeClipCommand ( KoShapeControllerBase * controller,
const QList< KoShape * > & shapes,
const QList< KoPathShape * > & clipPathShapes,
KUndo2Command * parent = 0 )

Command to set a new shape clipping path for multiple shape.

Parameters
controllerthe controller to used for deleting.
shapesa set of all the shapes that should get the clipping path.
clipPathShapesthe path shapes to be used a clipping path
parentthe parent command used for macro commands

Definition at line 42 of file KoShapeClipCommand.cpp.

43 : KUndo2Command(parent), d(new Private(controller))
44{
45 d->shapesToClip = shapes;
46 d->clipPathShapes = clipPathShapes;
47
48 Q_FOREACH (KoShape *shape, d->shapesToClip) {
49 d->oldClipPaths.append(shape->clipPath());
50 d->newClipPaths.append(new KoClipPath(implicitCastList<KoShape*>(clipPathShapes), KoFlake::UserSpaceOnUse));
51 }
52
53 Q_FOREACH (KoPathShape *path, clipPathShapes) {
54 d->oldParents.append(path->parent());
55 }
56
57 setText(kundo2_i18n("Clip Shape"));
58}
void setText(const KUndo2MagicString &text)
KUndo2Command(KUndo2Command *parent=0)
Clip path used to clip shapes.
The position of a path point within a path shape.
Definition KoPathShape.h:63
QList< KoPathShape * > clipPathShapes
KoShapeControllerBase * controller
KoClipPath * clipPath() const
Returns the currently set clip path or 0 if there is no clip path set.
Definition KoShape.cpp:1128
KUndo2MagicString kundo2_i18n(const char *text)

References KoShape::clipPath(), clipPathShapes, d, kundo2_i18n(), KUndo2Command::setText(), and KoFlake::UserSpaceOnUse.

◆ KoShapeClipCommand() [2/2]

KoShapeClipCommand::KoShapeClipCommand ( KoShapeControllerBase * controller,
KoShape * shape,
const QList< KoPathShape * > & clipPathShapes,
KUndo2Command * parent = 0 )

Command to set a new shape clipping path for a single shape

Parameters
controllerthe controller to used for deleting.
shapea single shape that should get the new shadow.
clipPathShapesthe path shapes to be used a clipping path
parentthe parent command used for macro commands

Definition at line 60 of file KoShapeClipCommand.cpp.

61 : KUndo2Command(parent), d(new Private(controller))
62{
63 d->shapesToClip.append(shape);
64 d->clipPathShapes = clipPathShapes;
65 d->oldClipPaths.append(shape->clipPath());
66 d->newClipPaths.append(new KoClipPath(implicitCastList<KoShape*>(clipPathShapes), KoFlake::UserSpaceOnUse));
67
68 Q_FOREACH (KoPathShape *path, clipPathShapes) {
69 d->oldParents.append(path->parent());
70 }
71
72 setText(kundo2_i18n("Clip Shape"));
73}

References KoShape::clipPath(), clipPathShapes, d, kundo2_i18n(), KUndo2Command::setText(), and KoFlake::UserSpaceOnUse.

◆ ~KoShapeClipCommand()

KoShapeClipCommand::~KoShapeClipCommand ( )
override

Destroys the command.

Definition at line 75 of file KoShapeClipCommand.cpp.

76{
77 delete d;
78}

References d.

Member Function Documentation

◆ Private()

KoShapeClipCommand::Private ( KoShapeControllerBase * c)
inline

Definition at line 21 of file KoShapeClipCommand.cpp.

22 : controller(c), executed(false) {
23 }

◆ redo()

void KoShapeClipCommand::redo ( )
overridevirtual

redo the command

Reimplemented from KUndo2Command.

Definition at line 80 of file KoShapeClipCommand.cpp.

81{
82 const uint shapeCount = d->shapesToClip.count();
83 for (uint i = 0; i < shapeCount; ++i) {
84 d->shapesToClip[i]->setClipPath(d->newClipPaths[i]);
85 d->shapesToClip[i]->update();
86 }
87
88 const uint clipPathCount = d->clipPathShapes.count();
89 for (uint i = 0; i < clipPathCount; ++i) {
90 if (d->oldParents.at(i)) {
91 d->oldParents.at(i)->removeShape(d->clipPathShapes[i]);
92 }
93 }
94
95 d->executed = true;
96
98}
unsigned int uint
virtual void redo()

References d, and KUndo2Command::redo().

◆ undo()

void KoShapeClipCommand::undo ( )
overridevirtual

revert the actions done in redo

Reimplemented from KUndo2Command.

Definition at line 100 of file KoShapeClipCommand.cpp.

101{
103
104 const uint shapeCount = d->shapesToClip.count();
105 for (uint i = 0; i < shapeCount; ++i) {
106 d->shapesToClip[i]->setClipPath(d->oldClipPaths[i]);
107 d->shapesToClip[i]->update();
108 }
109
110 const uint clipPathCount = d->clipPathShapes.count();
111 for (uint i = 0; i < clipPathCount; ++i) {
112 if (d->oldParents.at(i)) {
113 d->oldParents.at(i)->addShape(d->clipPathShapes[i]);
114 }
115 }
116
117 d->executed = false;
118}
virtual void undo()

References d, and KUndo2Command::undo().

Member Data Documentation

◆ clipPathShapes

QList<KoPathShape*> KoShapeClipCommand::clipPathShapes

Definition at line 35 of file KoShapeClipCommand.cpp.

◆ controller

KoShapeControllerBase* KoShapeClipCommand::controller

Definition at line 38 of file KoShapeClipCommand.cpp.

◆ d

Private* const KoShapeClipCommand::d
private

Definition at line 50 of file KoShapeClipCommand.h.

◆ executed

bool KoShapeClipCommand::executed

Definition at line 39 of file KoShapeClipCommand.cpp.

◆ newClipPaths

QList<KoClipPath*> KoShapeClipCommand::newClipPaths

Definition at line 36 of file KoShapeClipCommand.cpp.

◆ oldClipPaths

QList<KoClipPath*> KoShapeClipCommand::oldClipPaths

Definition at line 34 of file KoShapeClipCommand.cpp.

◆ oldParents

QList<KoShapeContainer*> KoShapeClipCommand::oldParents

Definition at line 37 of file KoShapeClipCommand.cpp.

◆ shapesToClip

QList<KoShape*> KoShapeClipCommand::shapesToClip

Definition at line 33 of file KoShapeClipCommand.cpp.


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