Krita Source Code Documentation
Loading...
Searching...
No Matches
KisLazyCreateTransformMaskKeyframesCommand.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2023 Dmitry Kazakov <dimula73@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
8
11
17
36
38{
39 QScopedPointer<KUndo2Command> parentCommand(new KUndo2Command);
40
42
43 const int time = m_mask->parent()->original()->defaultBounds()->currentTime();
44
45 auto addKeyframe = [this, time] (const KoID &channelId, KUndo2Command *parentCommand)
46 {
47 KisScalarKeyframeChannel *channel = dynamic_cast<KisScalarKeyframeChannel*>(m_mask->getKeyframeChannel(channelId.id()));
49
50 if (!channel->keyframeAt(time)) {
51 channel->addScalarKeyframe(time, channel->valueAt(time), parentCommand);
52 }
53 };
54
55 addKeyframe(KisKeyframeChannel::PositionX, parentCommand.data());
56 addKeyframe(KisKeyframeChannel::PositionY, parentCommand.data());
57
58 addKeyframe(KisKeyframeChannel::ScaleX, parentCommand.data());
59 addKeyframe(KisKeyframeChannel::ScaleY, parentCommand.data());
60
61 addKeyframe(KisKeyframeChannel::ShearX, parentCommand.data());
62 addKeyframe(KisKeyframeChannel::ShearY, parentCommand.data());
63
64 addKeyframe(KisKeyframeChannel::RotationX, parentCommand.data());
65 addKeyframe(KisKeyframeChannel::RotationY, parentCommand.data());
66 addKeyframe(KisKeyframeChannel::RotationZ, parentCommand.data());
67
68 addCommand(parentCommand.take());
69}
virtual QTime time() const
virtual int currentTime() const =0
static const KoID RotationY
static const KoID ScaleY
KisKeyframeSP keyframeAt(int time) const
Get a keyframe at specified time. Used primarily when the value of a given keyframe is needed.
static const KoID RotationZ
static const KoID ScaleX
static const KoID RotationX
static const KoID PositionX
static const KoID PositionY
static const KoID ShearX
static const KoID ShearY
KisLazyCreateTransformMaskKeyframesCommand(KisTransformMaskSP mask, KUndo2Command *parent=nullptr)
KisDefaultBoundsBaseSP defaultBounds() const
The KisScalarKeyframeChannel is a concrete KisKeyframeChannel subclass that stores and manages KisSca...
qreal valueAt(int time) const
Quickly get the interpolated value at the given time.
void addScalarKeyframe(int time, qreal value, KUndo2Command *parentUndoCmd=nullptr)
Definition KoID.h:30
QString id() const
Definition KoID.cpp:63
#define KIS_SAFE_ASSERT_RECOVER_RETURN(cond)
Definition kis_assert.h:128
KisKeyframeChannel * getKeyframeChannel(const QString &id, bool create)
virtual KisPaintDeviceSP original() const =0
void addCommand(KUndo2Command *cmd)
KisNodeWSP parent
Definition kis_node.cpp:86