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

#include <KoShapeResizeCommand.h>

+ Inheritance diagram for KoShapeResizeCommand:

Public Member Functions

int id () const override
 
 KoShapeResizeCommand (const QList< KoShape * > &shapes, qreal scaleX, qreal scaleY, const QPointF &absoluteStillPoint, bool useGLobalMode, bool usePostScaling, const QTransform &postScalingCoveringTransform, KUndo2Command *parent=0)
 
bool mergeWith (const KUndo2Command *command) override
 
void redoImpl () override
 
void replaceResizeAction (qreal scaleX, qreal scaleY, const QPointF &absoluteStillPoint)
 
void undoImpl () override
 
 ~KoShapeResizeCommand () override
 
- Public Member Functions inherited from Private
 Private (KisCanvas2 *c)
 
- Public Member Functions inherited from KisCommandUtils::SkipFirstRedoBase
void redo () override final
 
void setSkipOneRedo (bool value)
 
 SkipFirstRedoBase (bool skipFirstRedo, const KUndo2MagicString &text, KUndo2Command *parent=0)
 
 SkipFirstRedoBase (bool skipFirstRedo, KUndo2Command *parent=0)
 
void undo () override final
 
- 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 bool isMerged () const
 
 KUndo2Command (const KUndo2MagicString &text, KUndo2Command *parent=0)
 
 KUndo2Command (KUndo2Command *parent=0)
 
virtual QVector< KUndo2Command * > mergeCommandsVector () const
 
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

QPointF absoluteStillPoint
 
QList< QSizeF > oldSizes
 
QList< QTransform > oldTransforms
 
QTransform postScalingCoveringTransform
 
qreal scaleX
 
qreal scaleY
 
QList< KoShape * > shapes
 
bool useGlobalMode
 
bool usePostScaling
 
- Public Attributes inherited from Private
KisCanvas2canvas
 
int displayedFrame
 
int intendedFrame
 

Private Member Functions

void redoNoUpdate ()
 
void undoNoUpdate ()
 

Private Attributes

QScopedPointer< Private > const m_d
 

Additional Inherited Members

Detailed Description

Definition at line 14 of file KoShapeResizeCommand.cpp.

Constructor & Destructor Documentation

◆ KoShapeResizeCommand()

KoShapeResizeCommand::KoShapeResizeCommand ( const QList< KoShape * > & shapes,
qreal scaleX,
qreal scaleY,
const QPointF & absoluteStillPoint,
bool useGLobalMode,
bool usePostScaling,
const QTransform & postScalingCoveringTransform,
KUndo2Command * parent = 0 )

Definition at line 29 of file KoShapeResizeCommand.cpp.

36 : SkipFirstRedoBase(false, kundo2_i18n("Resize"), parent),
37 m_d(new Private)
38{
39 m_d->shapes = shapes;
40 m_d->scaleX = scaleX;
41 m_d->scaleY = scaleY;
42 m_d->absoluteStillPoint = absoluteStillPoint;
43 m_d->useGlobalMode = useGLobalMode;
44 m_d->usePostScaling = usePostScaling;
45 m_d->postScalingCoveringTransform = postScalingCoveringTransform;
46
47 Q_FOREACH (KoShape *shape, m_d->shapes) {
48 m_d->oldSizes << shape->size();
49 m_d->oldTransforms << shape->transformation();
50 }
51}
virtual QSizeF size() const
Get the size of the shape in pt.
Definition KoShape.cpp:740
QTransform transformation() const
Returns the shapes local transformation matrix.
Definition KoShape.cpp:383
KUndo2MagicString kundo2_i18n(const char *text)
SkipFirstRedoBase(bool skipFirstRedo, KUndo2Command *parent=0)
QScopedPointer< Private > const m_d

References absoluteStillPoint, m_d, postScalingCoveringTransform, scaleX, scaleY, shapes, KoShape::size(), KoShape::transformation(), and usePostScaling.

◆ ~KoShapeResizeCommand()

KoShapeResizeCommand::~KoShapeResizeCommand ( )
override

Definition at line 53 of file KoShapeResizeCommand.cpp.

54{
55}

Member Function Documentation

◆ id()

int KoShapeResizeCommand::id ( ) const
overridevirtual

Returns the ID of this command.

A command ID is used in command compression. It must be an integer unique to this command's class, or -1 if the command doesn't support compression.

If the command supports compression this function must be overridden in the derived class to return the correct ID. The base implementation returns -1.

KUndo2QStack::push() will only try to merge two commands if they have the same ID, and the ID is not -1.

See also
mergeWith(), KUndo2QStack::push()

Reimplemented from KUndo2Command.

Definition at line 97 of file KoShapeResizeCommand.cpp.

References KisCommandUtils::ResizeShapeId.

◆ mergeWith()

bool KoShapeResizeCommand::mergeWith ( const KUndo2Command * command)
overridevirtual

Attempts to merge this command with command. Returns true on success; otherwise returns false.

If this function returns true, calling this command's redo() must have the same effect as redoing both this command and command. Similarly, calling this command's undo() must have the same effect as undoing command and this command.

KUndo2QStack will only try to merge two commands if they have the same id, and the id is not -1.

The default implementation returns false.

See also
id() KUndo2QStack::push()

Reimplemented from KUndo2Command.

Definition at line 102 of file KoShapeResizeCommand.cpp.

103{
104 const KoShapeResizeCommand *other = dynamic_cast<const KoShapeResizeCommand*>(command);
105
106 if (!other ||
107 other->m_d->absoluteStillPoint != m_d->absoluteStillPoint ||
108 other->m_d->shapes != m_d->shapes ||
109 other->m_d->useGlobalMode != m_d->useGlobalMode ||
110 other->m_d->usePostScaling != m_d->usePostScaling) {
111
112 return false;
113 }
114
115 // check if the significant orientations coincide
116 if (m_d->useGlobalMode && !m_d->usePostScaling) {
117 Qt::Orientation our = KoFlake::significantScaleOrientation(m_d->scaleX, m_d->scaleY);
118 Qt::Orientation their = KoFlake::significantScaleOrientation(other->m_d->scaleX, other->m_d->scaleY);
119
120 if (our != their) {
121 return false;
122 }
123 }
124
125 m_d->scaleX *= other->m_d->scaleX;
126 m_d->scaleY *= other->m_d->scaleY;
127 return true;
128}
KRITAFLAKE_EXPORT Qt::Orientation significantScaleOrientation(qreal scaleX, qreal scaleY)
Definition KoFlake.cpp:168

References m_d, and KoFlake::significantScaleOrientation().

◆ redoImpl()

void KoShapeResizeCommand::redoImpl ( )
overridevirtual

◆ redoNoUpdate()

void KoShapeResizeCommand::redoNoUpdate ( )
private

Definition at line 75 of file KoShapeResizeCommand.cpp.

76{
77 Q_FOREACH (KoShape *shape, m_d->shapes) {
79 m_d->scaleX, m_d->scaleY,
80 m_d->absoluteStillPoint,
81 m_d->useGlobalMode,
82 m_d->usePostScaling,
83 m_d->postScalingCoveringTransform);
84 }
85}
KRITAFLAKE_EXPORT void resizeShapeCommon(KoShape *shape, qreal scaleX, qreal scaleY, const QPointF &absoluteStillPoint, bool useGlobalMode, bool usePostScaling, const QTransform &postScalingCoveringTransform)
Definition KoFlake.cpp:313

References m_d, and KoFlake::resizeShapeCommon().

◆ replaceResizeAction()

void KoShapeResizeCommand::replaceResizeAction ( qreal scaleX,
qreal scaleY,
const QPointF & absoluteStillPoint )

Definition at line 130 of file KoShapeResizeCommand.cpp.

131{
132 KoShapeBulkActionLock lock(m_d->shapes);
133
134 undoNoUpdate();
135
136 m_d->scaleX = scaleX;
137 m_d->scaleY = scaleY;
138 m_d->absoluteStillPoint = absoluteStillPoint;
139
140 redoNoUpdate();
141
143}

References absoluteStillPoint, KoShapeBulkActionLock::bulkShapesUpdate(), m_d, redoNoUpdate(), scaleX, scaleY, undoNoUpdate(), and KoShapeBulkActionLock::unlock().

◆ undoImpl()

void KoShapeResizeCommand::undoImpl ( )
overridevirtual

◆ undoNoUpdate()

void KoShapeResizeCommand::undoNoUpdate ( )
private

Definition at line 87 of file KoShapeResizeCommand.cpp.

88{
89 for (int i = 0; i < m_d->shapes.size(); i++) {
90 KoShape *shape = m_d->shapes[i];
91
92 shape->setSize(m_d->oldSizes[i]);
93 shape->setTransformation(m_d->oldTransforms[i]);
94 }
95}
void setTransformation(const QTransform &matrix)
Definition KoShape.cpp:374
virtual void setSize(const QSizeF &size)
Resize the shape.
Definition KoShape.cpp:248

References m_d, KoShape::setSize(), and KoShape::setTransformation().

Member Data Documentation

◆ absoluteStillPoint

QPointF KoShapeResizeCommand::absoluteStillPoint

Definition at line 19 of file KoShapeResizeCommand.cpp.

◆ m_d

QScopedPointer<Private> const KoShapeResizeCommand::m_d
private

Definition at line 48 of file KoShapeResizeCommand.h.

◆ oldSizes

QList<QSizeF> KoShapeResizeCommand::oldSizes

Definition at line 24 of file KoShapeResizeCommand.cpp.

◆ oldTransforms

QList<QTransform> KoShapeResizeCommand::oldTransforms

Definition at line 25 of file KoShapeResizeCommand.cpp.

◆ postScalingCoveringTransform

QTransform KoShapeResizeCommand::postScalingCoveringTransform

Definition at line 22 of file KoShapeResizeCommand.cpp.

◆ scaleX

qreal KoShapeResizeCommand::scaleX

Definition at line 17 of file KoShapeResizeCommand.cpp.

◆ scaleY

qreal KoShapeResizeCommand::scaleY

Definition at line 18 of file KoShapeResizeCommand.cpp.

◆ shapes

QList<KoShape *> KoShapeResizeCommand::shapes

Definition at line 16 of file KoShapeResizeCommand.cpp.

◆ useGlobalMode

bool KoShapeResizeCommand::useGlobalMode

Definition at line 20 of file KoShapeResizeCommand.cpp.

◆ usePostScaling

bool KoShapeResizeCommand::usePostScaling

Definition at line 21 of file KoShapeResizeCommand.cpp.


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