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

#include <kis_image_set_resolution_command.h>

+ Inheritance diagram for KisImageSetResolutionCommand:

Public Member Functions

 KisImageSetResolutionCommand (KisImageWSP image, qreal newXRes, qreal newYRes, KUndo2Command *parent=0)
 
void redo () override
 
void undo () 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

KisImageWSP m_image
 
qreal m_newXRes
 
qreal m_newYRes
 
qreal m_oldXRes
 
qreal m_oldYRes
 

Detailed Description

Definition at line 16 of file kis_image_set_resolution_command.h.

Constructor & Destructor Documentation

◆ KisImageSetResolutionCommand()

KisImageSetResolutionCommand::KisImageSetResolutionCommand ( KisImageWSP image,
qreal newXRes,
qreal newYRes,
KUndo2Command * parent = 0 )

Definition at line 13 of file kis_image_set_resolution_command.cpp.

14 : KUndo2Command(kundo2_i18n("Set Image Resolution"), parent)
15 , m_image(image)
16 , m_newXRes(newXRes)
17 , m_newYRes(newYRes)
18 , m_oldXRes(0)
19 , m_oldYRes(0)
20{
21 KisImageSP imageSP = image.toStrongRef();
22 if (!imageSP) {
23 return;
24 }
25 m_oldXRes = imageSP->xRes();
26 m_oldYRes = imageSP->yRes();
27}
KUndo2Command(KUndo2Command *parent=0)
double xRes() const
double yRes() const
KisSharedPtr< T > toStrongRef() const
toStrongRef returns a KisSharedPtr which may be dereferenced.
KUndo2MagicString kundo2_i18n(const char *text)

References m_oldXRes, m_oldYRes, KisWeakSharedPtr< T >::toStrongRef(), KisImage::xRes(), and KisImage::yRes().

Member Function Documentation

◆ redo()

void KisImageSetResolutionCommand::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 38 of file kis_image_set_resolution_command.cpp.

39{
41 if (!image) {
42 return;
43 }
45}
void setResolution(double xres, double yres)

References m_image, m_newXRes, m_newYRes, KisImage::setResolution(), and KisWeakSharedPtr< T >::toStrongRef().

◆ undo()

void KisImageSetResolutionCommand::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 29 of file kis_image_set_resolution_command.cpp.

30{
32 if (!image) {
33 return;
34 }
36}

References m_image, m_oldXRes, m_oldYRes, KisImage::setResolution(), and KisWeakSharedPtr< T >::toStrongRef().

Member Data Documentation

◆ m_image

KisImageWSP KisImageSetResolutionCommand::m_image
private

Definition at line 24 of file kis_image_set_resolution_command.h.

◆ m_newXRes

qreal KisImageSetResolutionCommand::m_newXRes
private

Definition at line 26 of file kis_image_set_resolution_command.h.

◆ m_newYRes

qreal KisImageSetResolutionCommand::m_newYRes
private

Definition at line 27 of file kis_image_set_resolution_command.h.

◆ m_oldXRes

qreal KisImageSetResolutionCommand::m_oldXRes
private

Definition at line 28 of file kis_image_set_resolution_command.h.

◆ m_oldYRes

qreal KisImageSetResolutionCommand::m_oldYRes
private

Definition at line 29 of file kis_image_set_resolution_command.h.


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