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

The undo / redo command for breaking a subpath by removing the segment. More...

#include <KoPathSegmentBreakCommand.h>

+ Inheritance diagram for KoPathSegmentBreakCommand:

Public Member Functions

 KoPathSegmentBreakCommand (const KoPathPointData &pointData, KUndo2Command *parent=0)
 
void redo () override
 redo the command
 
void undo () override
 revert the actions done in redo
 
 ~KoPathSegmentBreakCommand () override
 
- 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 ()
 

Private Attributes

bool m_broken
 
KoPathPointData m_pointData
 
KoPathPointIndex m_startIndex
 

Detailed Description

The undo / redo command for breaking a subpath by removing the segment.

Definition at line 15 of file KoPathSegmentBreakCommand.h.

Constructor & Destructor Documentation

◆ KoPathSegmentBreakCommand()

KoPathSegmentBreakCommand::KoPathSegmentBreakCommand ( const KoPathPointData & pointData,
KUndo2Command * parent = 0 )
explicit

Command to break a subpath by removing the segment

The segment following the given point will be removed.

Parameters
pointDatadescribing the point
parentthe parent command used for macro commands

Definition at line 13 of file KoPathSegmentBreakCommand.cpp.

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}
void setText(const KUndo2MagicString &text)
KUndo2Command(KUndo2Command *parent=0)
KoPathPointIndex pointIndex
position of the point in the path shape
KoPathShape * pathShape
path shape the path point belongs too
int subpathPointCount(int subpathIndex) const
Returns the number of points in a subpath.
bool isClosedSubpath(int subpathIndex) const
Checks if a subpath is closed.
KUndo2MagicString kundo2_i18n(const char *text)

References KoPathShape::isClosedSubpath(), kundo2_i18n(), m_pointData, m_startIndex, KoPathPointData::pathShape, KoPathPointData::pointIndex, KUndo2Command::setText(), and KoPathShape::subpathPointCount().

◆ ~KoPathSegmentBreakCommand()

KoPathSegmentBreakCommand::~KoPathSegmentBreakCommand ( )
override

Definition at line 28 of file KoPathSegmentBreakCommand.cpp.

29{
30}

Member Function Documentation

◆ redo()

void KoPathSegmentBreakCommand::redo ( )
overridevirtual

redo the command

Reimplemented from KUndo2Command.

Definition at line 32 of file KoPathSegmentBreakCommand.cpp.

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}
virtual void redo()
bool breakAfter(const KoPathPointIndex &pointIndex)
Breaks the path after the point index.
virtual QPointF normalize()
Normalizes the path data.
KoPathPointIndex openSubpath(const KoPathPointIndex &pointIndex)
Opens a closed subpath.
void update() const override
reimplemented

References KoPathShape::breakAfter(), m_broken, m_pointData, m_startIndex, KoPathShape::normalize(), KoPathShape::openSubpath(), KoPathPointData::pathShape, KoPathPointData::pointIndex, KUndo2Command::redo(), and KoShapeContainer::update().

◆ undo()

void KoPathSegmentBreakCommand::undo ( )
overridevirtual

revert the actions done in redo

Reimplemented from KUndo2Command.

Definition at line 50 of file KoPathSegmentBreakCommand.cpp.

51{
53 if (m_startIndex.first != -1) {
57 } else if (m_broken) {
61 }
62}
virtual void undo()
bool join(int subpathIndex)
Joins the given subpath with the following one.
KoPathPointIndex closeSubpath(const KoPathPointIndex &pointIndex)
Close a open subpath.

References KoPathShape::closeSubpath(), KoPathShape::join(), m_broken, m_pointData, m_startIndex, KoPathShape::normalize(), KoPathPointData::pathShape, KoPathPointData::pointIndex, KUndo2Command::undo(), and KoShapeContainer::update().

Member Data Documentation

◆ m_broken

bool KoPathSegmentBreakCommand::m_broken
private

Definition at line 36 of file KoPathSegmentBreakCommand.h.

◆ m_pointData

KoPathPointData KoPathSegmentBreakCommand::m_pointData
private

Definition at line 34 of file KoPathSegmentBreakCommand.h.

◆ m_startIndex

KoPathPointIndex KoPathSegmentBreakCommand::m_startIndex
private

Definition at line 35 of file KoPathSegmentBreakCommand.h.


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