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

#include <KoMultiPathPointMergeCommand.h>

+ Inheritance diagram for KoMultiPathPointMergeCommand:

Public Member Functions

 KoMultiPathPointMergeCommand (const KoPathPointData &pointData1, const KoPathPointData &pointData2, KoShapeControllerBase *controller, KoSelection *selection, KUndo2Command *parent=0)
 
 Private (const KoPathPointData &_pointData1, const KoPathPointData &_pointData2, KoShapeControllerBase *_controller, KoSelection *_selection)
 
void redo () override
 
KoPathShapetestingCombinedPath () const
 
void undo () override
 
 ~KoMultiPathPointMergeCommand () override
 
- Public Member Functions inherited from Private
 Private (KisCanvas2 *c)
 
- 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

QScopedPointer< KoPathCombineCommandcombineCommand
 
KoShapeControllerBasecontroller
 
QScopedPointer< KUndo2CommandmergeCommand
 
KoPathPointData pointData1
 
KoPathPointData pointData2
 
KoSelectionselection
 
- Public Attributes inherited from Private
KisCanvas2canvas
 
int displayedFrame
 
int intendedFrame
 

Protected Member Functions

virtual KUndo2CommandcreateMergeCommand (const KoPathPointData &pointData1, const KoPathPointData &pointData2)
 

Private Attributes

const QScopedPointer< Privatem_d
 

Detailed Description

Definition at line 17 of file KoMultiPathPointMergeCommand.cpp.

Constructor & Destructor Documentation

◆ KoMultiPathPointMergeCommand()

KoMultiPathPointMergeCommand::KoMultiPathPointMergeCommand ( const KoPathPointData & pointData1,
const KoPathPointData & pointData2,
KoShapeControllerBase * controller,
KoSelection * selection,
KUndo2Command * parent = 0 )

Definition at line 37 of file KoMultiPathPointMergeCommand.cpp.

38 : KUndo2Command(kundo2_i18n("Merge points"), parent),
40{
41}
KUndo2Command(KUndo2Command *parent=0)
KUndo2MagicString kundo2_i18n(const char *text)
const QScopedPointer< Private > m_d

◆ ~KoMultiPathPointMergeCommand()

KoMultiPathPointMergeCommand::~KoMultiPathPointMergeCommand ( )
override

Definition at line 43 of file KoMultiPathPointMergeCommand.cpp.

44{
45}

Member Function Documentation

◆ createMergeCommand()

KUndo2Command * KoMultiPathPointMergeCommand::createMergeCommand ( const KoPathPointData & pointData1,
const KoPathPointData & pointData2 )
protectedvirtual

Reimplemented in KoMultiPathPointJoinCommand.

Definition at line 47 of file KoMultiPathPointMergeCommand.cpp.

48{
50}
The undo / redo command for merging two subpath end points.

References pointData1, and pointData2.

◆ Private()

KoMultiPathPointMergeCommand::Private ( const KoPathPointData & _pointData1,
const KoPathPointData & _pointData2,
KoShapeControllerBase * _controller,
KoSelection * _selection )
inline

Definition at line 19 of file KoMultiPathPointMergeCommand.cpp.

20 : pointData1(_pointData1),
21 pointData2(_pointData2),
22 controller(_controller),
23 selection(_selection)
24 {
25 }

◆ redo()

void KoMultiPathPointMergeCommand::redo ( )
overridevirtual

Applies a change to the document. This function must be implemented in the derived class. Calling KUndo2QStack::push(), KUndo2QStack::undo() or KUndo2QStack::redo() from this function leads to undefined behavior.

The default implementation calls redo() on all child commands.

See also
undo()

Reimplemented from KUndo2Command.

Definition at line 52 of file KoMultiPathPointMergeCommand.cpp.

53{
54 KoShape *mergedShape = 0;
55
56 if (m_d->pointData1.pathShape != m_d->pointData2.pathShape) {
58
59 QList<KoPathShape*> shapes = {m_d->pointData1.pathShape, m_d->pointData2.pathShape};
60 m_d->combineCommand.reset(new KoPathCombineCommand(m_d->controller, shapes));
61 m_d->combineCommand->redo();
62
63 KoPathPointData newPD1 = m_d->combineCommand->originalToCombined(m_d->pointData1);
64 KoPathPointData newPD2 = m_d->combineCommand->originalToCombined(m_d->pointData2);
65
66 m_d->mergeCommand.reset(createMergeCommand(newPD1, newPD2));
67 m_d->mergeCommand->redo();
68
69 mergedShape = m_d->combineCommand->combinedPath();
70
71 } else {
72 m_d->mergeCommand.reset(createMergeCommand(m_d->pointData1, m_d->pointData2));
73 m_d->mergeCommand->redo();
74
75 mergedShape = m_d->pointData1.pathShape;
76 }
77
78 if (m_d->selection) {
79 m_d->selection->select(mergedShape);
80 }
81
83}
virtual void redo()
The undo / redo command for combining two or more paths into one.
Describe a KoPathPoint by a KoPathShape and its indices.
#define KIS_SAFE_ASSERT_RECOVER_RETURN(cond)
Definition kis_assert.h:128
virtual KUndo2Command * createMergeCommand(const KoPathPointData &pointData1, const KoPathPointData &pointData2)

References createMergeCommand(), KIS_SAFE_ASSERT_RECOVER_RETURN, m_d, and KUndo2Command::redo().

◆ testingCombinedPath()

KoPathShape * KoMultiPathPointMergeCommand::testingCombinedPath ( ) const

Definition at line 85 of file KoMultiPathPointMergeCommand.cpp.

86{
87 return m_d->combineCommand ? m_d->combineCommand->combinedPath() : 0;
88}

References m_d.

◆ undo()

void KoMultiPathPointMergeCommand::undo ( )
overridevirtual

Reverts a change to the document. After undo() is called, the state of the document should be the same as before redo() was called. This function must be implemented in the derived class. Calling KUndo2QStack::push(), KUndo2QStack::undo() or KUndo2QStack::redo() from this function leads to undefined behavior.

The default implementation calls undo() on all child commands in reverse order.

See also
redo()

Reimplemented from KUndo2Command.

Definition at line 90 of file KoMultiPathPointMergeCommand.cpp.

91{
93
94 if (m_d->mergeCommand) {
95 m_d->mergeCommand->undo();
96 m_d->mergeCommand.reset();
97 }
98
99 if (m_d->combineCommand) {
100 m_d->combineCommand->undo();
101 m_d->combineCommand.reset();
102 }
103
104 if (m_d->selection) {
105 m_d->selection->select(m_d->pointData1.pathShape);
106 if (m_d->pointData1.pathShape != m_d->pointData2.pathShape) {
107 m_d->selection->select(m_d->pointData2.pathShape);
108 }
109 }
110}
virtual void undo()

References m_d, and KUndo2Command::undo().

Member Data Documentation

◆ combineCommand

QScopedPointer<KoPathCombineCommand> KoMultiPathPointMergeCommand::combineCommand

Definition at line 33 of file KoMultiPathPointMergeCommand.cpp.

◆ controller

KoShapeControllerBase* KoMultiPathPointMergeCommand::controller

Definition at line 29 of file KoMultiPathPointMergeCommand.cpp.

◆ m_d

const QScopedPointer<Private> KoMultiPathPointMergeCommand::m_d
private

Definition at line 41 of file KoMultiPathPointMergeCommand.h.

◆ mergeCommand

QScopedPointer<KUndo2Command> KoMultiPathPointMergeCommand::mergeCommand

Definition at line 34 of file KoMultiPathPointMergeCommand.cpp.

◆ pointData1

KoPathPointData KoMultiPathPointMergeCommand::pointData1

Definition at line 27 of file KoMultiPathPointMergeCommand.cpp.

◆ pointData2

KoPathPointData KoMultiPathPointMergeCommand::pointData2

Definition at line 28 of file KoMultiPathPointMergeCommand.cpp.

◆ selection

KoSelection* KoMultiPathPointMergeCommand::selection

Definition at line 30 of file KoMultiPathPointMergeCommand.cpp.


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