21#include "layermanager.h"
22#include "selectionmanager.h"
24#include "layersound.h"
25#include "layerbitmap.h"
26#include "layervector.h"
29#include "undoredocommand.h"
33 qDebug() <<
"backupElement created";
37UndoRedoCommand::~UndoRedoCommand()
41BitmapReplaceCommand::BitmapReplaceCommand(
const BitmapImage* undoBitmap,
42 const int undoLayerId,
48 this->undoBitmap = *undoBitmap;
49 this->undoLayerId = undoLayerId;
51 Layer* layer = editor->layers()->currentLayer();
52 redoLayerId = layer->id();
54 getBitmapImageAtFrame(editor->currentFrame());
59void BitmapReplaceCommand::undo()
63 Layer* layer = editor()->layers()->findLayerById(undoLayerId);
64 static_cast<LayerBitmap*
>(layer)->replaceKeyFrame(&undoBitmap);
66 editor()->scrubTo(undoBitmap.pos());
69void BitmapReplaceCommand::redo()
74 if (isFirstRedo()) { setFirstRedo(
false);
return; }
76 Layer* layer = editor()->layers()->findLayerById(redoLayerId);
77 static_cast<LayerBitmap*
>(layer)->replaceKeyFrame(&redoBitmap);
79 editor()->scrubTo(redoBitmap.pos());
82VectorReplaceCommand::VectorReplaceCommand(
const VectorImage* undoVector,
83 const int undoLayerId,
89 this->undoVector = *undoVector;
90 this->undoLayerId = undoLayerId;
91 Layer* layer = editor->layers()->currentLayer();
92 redoLayerId = layer->id();
94 getVectorImageAtFrame(editor->currentFrame());
99void VectorReplaceCommand::undo()
103 Layer* layer = editor()->layers()->findLayerById(undoLayerId);
105 static_cast<LayerVector*
>(layer)->replaceKeyFrame(&undoVector);
107 editor()->scrubTo(undoVector.pos());
110void VectorReplaceCommand::redo()
115 if (isFirstRedo()) { setFirstRedo(
false);
return; }
117 Layer* layer = editor()->layers()->findLayerById(redoLayerId);
119 static_cast<LayerVector*
>(layer)->replaceKeyFrame(&redoVector);
121 editor()->scrubTo(redoVector.pos());
124TransformCommand::TransformCommand(
const QRectF& undoSelectionRect,
125 const QPointF& undoTranslation,
126 const qreal undoRotationAngle,
127 const qreal undoScaleX,
128 const qreal undoScaleY,
129 const QPointF& undoTransformAnchor,
130 const bool roundPixels,
135 this->roundPixels = roundPixels;
137 this->undoSelectionRect = undoSelectionRect;
138 this->undoAnchor = undoTransformAnchor;
139 this->undoTranslation = undoTranslation;
140 this->undoRotationAngle = undoRotationAngle;
141 this->undoScaleX = undoScaleX;
142 this->undoScaleY = undoScaleY;
144 auto selectMan = editor->select();
145 redoSelectionRect = selectMan->mySelectionRect();
146 redoAnchor = selectMan->currentTransformAnchor();
147 redoTranslation = selectMan->myTranslation();
148 redoRotationAngle = selectMan->myRotation();
149 redoScaleX = selectMan->myScaleX();
150 redoScaleY = selectMan->myScaleY();
152 setText(description);
155void TransformCommand::undo()
157 apply(undoSelectionRect,
166void TransformCommand::redo()
169 if (isFirstRedo()) { setFirstRedo(
false);
return; }
171 apply(redoSelectionRect,
180void TransformCommand::apply(
const QRectF& selectionRect,
182 const qreal rotationAngle,
185 const QPointF& selectionAnchor,
186 const bool roundPixels)
188 auto selectMan = editor()->select();
189 selectMan->setSelection(selectionRect, roundPixels);
190 selectMan->setTransformAnchor(selectionAnchor);
191 selectMan->setTranslation(translation);
192 selectMan->setRotation(rotationAngle);
193 selectMan->setScale(scaleX, scaleY);
195 selectMan->calculateSelectionTransformation();