File indexing completed on 2024-06-09 04:21:53

0001 /*
0002  *  SPDX-FileCopyrightText: 2010 Sven Langkamp <sven.langkamp@gmail.com>
0003  *
0004  *  SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 #ifndef KIS_IMAGE_SET_RESOLUTION_COMMAND_H
0008 #define KIS_IMAGE_SET_RESOLUTION_COMMAND_H
0009 
0010 #include "kritaimage_export.h"
0011 #include "kis_types.h"
0012 
0013 #include <kundo2command.h>
0014 
0015 
0016 class KRITAIMAGE_EXPORT KisImageSetResolutionCommand : public KUndo2Command
0017 {
0018 public:
0019     KisImageSetResolutionCommand(KisImageWSP image, qreal newXRes, qreal newYRes, KUndo2Command *parent = 0);
0020     void undo() override;
0021     void redo() override;
0022 
0023 private:
0024     KisImageWSP m_image;
0025 
0026     qreal m_newXRes;
0027     qreal m_newYRes;
0028     qreal m_oldXRes;
0029     qreal m_oldYRes;
0030 };
0031 
0032 /**
0033  * A special workaround command for updating the shapes.  It resets
0034  * shapes always (for both undo() and redo() actions) after all the
0035  * child commands are finished. Usually, it should have the only child
0036  * KisImageSetResolutionCommand.
0037  *
0038  * Usecase: When you change the resolution of the image, the
0039  * projection of the vector layer is still rendered in old
0040  * resolution. So you should reset it and render again.
0041  */
0042 class KRITAIMAGE_EXPORT KisResetShapesCommand : public KUndo2Command
0043 {
0044 public:
0045     KisResetShapesCommand(KisNodeSP rootNode);
0046 
0047     void undo() override;
0048     void redo() override;
0049 
0050 private:
0051     void resetNode(KisNodeSP node);
0052 
0053 private:
0054     KisNodeSP m_rootNode;
0055 };
0056 
0057 #endif // KIS_IMAGE_SET_RESOLUTION_COMMAND_H