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

The KisScalarKeyframe class is a concrete subclass of KisKeyframe that wraps a scalar value and interpolation parameters. More...

#include <kis_scalar_keyframe_channel.h>

+ Inheritance diagram for KisScalarKeyframe:

Public Types

enum  InterpolationMode { Constant , Linear , Bezier }
 Controls the type of interpolation between this KisScalarKeyframe and the next. More...
 
enum  TangentsMode { Sharp , Smooth }
 Controls the behavior of the left and right tangents on a given keyframe for different curve shapes. More...
 

Signals

void sigChanged (const KisScalarKeyframe *scalarKey)
 

Public Member Functions

KisKeyframeSP duplicate (KisKeyframeChannel *newChannel=0) override
 
InterpolationMode interpolationMode () const
 
 KisScalarKeyframe (qreal value, InterpolationMode interpMode, TangentsMode tangentMode, QPointF leftTangent, QPointF rightTangent, QSharedPointer< ScalarKeyframeLimits > limits)
 
 KisScalarKeyframe (qreal value, QSharedPointer< ScalarKeyframeLimits > limits)
 
QPointF leftTangent () const
 
QPointF rightTangent () const
 
void setInterpolationMode (InterpolationMode mode, KUndo2Command *parentUndoCmd=nullptr)
 
void setInterpolationTangents (QPointF leftTangent, QPointF rightTangent, KUndo2Command *parentUndoCmd=nullptr)
 
void setLimits (QSharedPointer< ScalarKeyframeLimits > limits)
 
void setTangentsMode (TangentsMode mode, KUndo2Command *parentUndoCmd=nullptr)
 
void setValue (qreal val, KUndo2Command *parentUndoCmd=nullptr)
 
TangentsMode tangentsMode () const
 
qreal value () const
 
- Public Member Functions inherited from KisKeyframe
int colorLabel () const
 
 KisKeyframe ()
 
void setColorLabel (int colorIndex)
 
virtual ~KisKeyframe ()
 

Public Attributes

QMetaObject::Connection valueChangedChannelConnection
 For now, scalar keyframes have a callback connection to the channel that owns them in order to signal that their internal state has changed. Created by the channel.
 

Private Attributes

QWeakPointer< ScalarKeyframeLimitsm_channelLimits
 
InterpolationMode m_interpolationMode
 
QPointF m_leftTangent
 
QPointF m_rightTangent
 
TangentsMode m_tangentsMode
 
qreal m_value
 

Friends

class KisScalarKeyframeUpdateCommand
 

Detailed Description

The KisScalarKeyframe class is a concrete subclass of KisKeyframe that wraps a scalar value and interpolation parameters.

Definition at line 39 of file kis_scalar_keyframe_channel.h.

Member Enumeration Documentation

◆ InterpolationMode

Controls the type of interpolation between this KisScalarKeyframe and the next.

Enumerator
Constant 

Constant value until the next keyframe.

Linear 

Linear interpolation between this keyframe and the next.

Bezier 

Bezier curve between this keyframe and the next, controlled by individual tangent handles on each.

Definition at line 45 of file kis_scalar_keyframe_channel.h.

◆ TangentsMode

Controls the behavior of the left and right tangents on a given keyframe for different curve shapes.

Enumerator
Sharp 

Independent control of each tangent for sudden, sharp curve changes.

Smooth 

Tangents are locked inline for smooth transitions across key values.

Definition at line 54 of file kis_scalar_keyframe_channel.h.

Constructor & Destructor Documentation

◆ KisScalarKeyframe() [1/2]

KisScalarKeyframe::KisScalarKeyframe ( qreal value,
QSharedPointer< ScalarKeyframeLimits > limits )

◆ KisScalarKeyframe() [2/2]

KisScalarKeyframe::KisScalarKeyframe ( qreal value,
InterpolationMode interpMode,
TangentsMode tangentMode,
QPointF leftTangent,
QPointF rightTangent,
QSharedPointer< ScalarKeyframeLimits > limits )

Member Function Documentation

◆ duplicate()

KisKeyframeSP KisScalarKeyframe::duplicate ( KisKeyframeChannel * newChannel = 0)
overridevirtual

Creates a copy of this keyframe.

Parameters
newChannel(Optional) The channel that will hold this duplicate. This is used when some action must be taken to insert a frame into a new channel, for example, the registration of a KisRasterKeyframe with the new channel's paint device.

Implements KisKeyframe.

Definition at line 37 of file kis_scalar_keyframe_channel.cpp.

38{
39 if (newChannel) {
40 KisScalarKeyframeChannel *scalarChannel = dynamic_cast<KisScalarKeyframeChannel*>(newChannel);
41 KIS_ASSERT(scalarChannel);
42 // When transitioning between channels, set limits to those of the new channel.
43 KisScalarKeyframeSP scalarKey = toQShared(new KisScalarKeyframe(m_value, scalarChannel->limits()));
44 scalarKey->setInterpolationMode(m_interpolationMode);
45 scalarKey->setTangentsMode(m_tangentsMode);
46 scalarKey->setInterpolationTangents(leftTangent(), rightTangent());
47 return scalarKey;
48 } else {
51 m_channelLimits.toStrongRef()));
52 }
53}
The KisScalarKeyframeChannel is a concrete KisKeyframeChannel subclass that stores and manages KisSca...
QSharedPointer< ScalarKeyframeLimits > limits() const
KisScalarKeyframe(qreal value, QSharedPointer< ScalarKeyframeLimits > limits)
InterpolationMode interpolationMode() const
TangentsMode tangentsMode() const
#define KIS_ASSERT(cond)
Definition kis_assert.h:33
QSharedPointer< T > toQShared(T *ptr)

References interpolationMode(), KIS_ASSERT, KisScalarKeyframe(), leftTangent(), KisScalarKeyframeChannel::limits(), m_channelLimits, m_interpolationMode, m_tangentsMode, m_value, rightTangent(), tangentsMode(), toQShared(), and value().

◆ interpolationMode()

KisScalarKeyframe::InterpolationMode KisScalarKeyframe::interpolationMode ( ) const

Definition at line 88 of file kis_scalar_keyframe_channel.cpp.

89{
91}

References m_interpolationMode.

◆ leftTangent()

QPointF KisScalarKeyframe::leftTangent ( ) const

Definition at line 121 of file kis_scalar_keyframe_channel.cpp.

122{
123 return m_leftTangent;
124}

References m_leftTangent.

◆ rightTangent()

QPointF KisScalarKeyframe::rightTangent ( ) const

Definition at line 126 of file kis_scalar_keyframe_channel.cpp.

127{
128 return m_rightTangent;
129}

References m_rightTangent.

◆ setInterpolationMode()

void KisScalarKeyframe::setInterpolationMode ( InterpolationMode mode,
KUndo2Command * parentUndoCmd = nullptr )

Definition at line 77 of file kis_scalar_keyframe_channel.cpp.

78{
79 if (parentUndoCmd) {
80 KUndo2Command* cmd = new KisScalarKeyframeUpdateCommand(this, mode, parentUndoCmd);
81 cmd->redo();
82 } else {
84 Q_EMIT sigChanged(this);
85 }
86}
virtual void redo()
friend class KisScalarKeyframeUpdateCommand
void sigChanged(const KisScalarKeyframe *scalarKey)

References KisScalarKeyframeUpdateCommand, m_interpolationMode, KUndo2Command::redo(), and sigChanged().

◆ setInterpolationTangents()

void KisScalarKeyframe::setInterpolationTangents ( QPointF leftTangent,
QPointF rightTangent,
KUndo2Command * parentUndoCmd = nullptr )

Definition at line 109 of file kis_scalar_keyframe_channel.cpp.

110{
111 if (parentUndoCmd) {
113 cmd->redo();
114 } else {
117 Q_EMIT sigChanged(this);
118 }
119}

References KisScalarKeyframeUpdateCommand, leftTangent(), m_leftTangent, m_rightTangent, KUndo2Command::redo(), rightTangent(), and sigChanged().

◆ setLimits()

void KisScalarKeyframe::setLimits ( QSharedPointer< ScalarKeyframeLimits > limits)

Definition at line 131 of file kis_scalar_keyframe_channel.cpp.

132{
133 m_channelLimits = limits;
134}

References m_channelLimits.

◆ setTangentsMode()

void KisScalarKeyframe::setTangentsMode ( TangentsMode mode,
KUndo2Command * parentUndoCmd = nullptr )

Definition at line 93 of file kis_scalar_keyframe_channel.cpp.

94{
95 if (parentUndoCmd) {
96 KUndo2Command* cmd = new KisScalarKeyframeUpdateCommand(this, mode, parentUndoCmd);
97 cmd->redo();
98 } else {
99 m_tangentsMode = mode;
100 Q_EMIT sigChanged(this);
101 }
102}

References KisScalarKeyframeUpdateCommand, m_tangentsMode, KUndo2Command::redo(), and sigChanged().

◆ setValue()

void KisScalarKeyframe::setValue ( qreal val,
KUndo2Command * parentUndoCmd = nullptr )

Definition at line 60 of file kis_scalar_keyframe_channel.cpp.

61{
62 if (parentUndoCmd) {
63 KUndo2Command* cmd = new KisScalarKeyframeUpdateCommand(this, value, parentUndoCmd);
64 cmd->redo();
65 } else {
66 m_value = value;
67
69 if (limits) {
70 m_value = limits->clamp(m_value);
71 }
72
73 Q_EMIT sigChanged(this);
74 }
75}

References KisScalarKeyframeUpdateCommand, m_channelLimits, m_value, KUndo2Command::redo(), sigChanged(), and value().

◆ sigChanged

void KisScalarKeyframe::sigChanged ( const KisScalarKeyframe * scalarKey)
signal

◆ tangentsMode()

KisScalarKeyframe::TangentsMode KisScalarKeyframe::tangentsMode ( ) const

Definition at line 104 of file kis_scalar_keyframe_channel.cpp.

105{
106 return m_tangentsMode;
107}

References m_tangentsMode.

◆ value()

qreal KisScalarKeyframe::value ( ) const

Definition at line 55 of file kis_scalar_keyframe_channel.cpp.

56{
57 return m_value;
58}

References m_value.

Friends And Related Symbol Documentation

◆ KisScalarKeyframeUpdateCommand

friend class KisScalarKeyframeUpdateCommand
friend

Definition at line 86 of file kis_scalar_keyframe_channel.h.

Member Data Documentation

◆ m_channelLimits

QWeakPointer<ScalarKeyframeLimits> KisScalarKeyframe::m_channelLimits
private

Weak pointer back to the owning channel's limits, optionally used when setting the value of a keyframe to conform to the limited range of its current channel, Should change if keyframe is moved to a different channel.

Definition at line 103 of file kis_scalar_keyframe_channel.h.

◆ m_interpolationMode

InterpolationMode KisScalarKeyframe::m_interpolationMode
private

Definition at line 93 of file kis_scalar_keyframe_channel.h.

◆ m_leftTangent

QPointF KisScalarKeyframe::m_leftTangent
private

Controls part of between this and PREVIOUS keyframe.

Definition at line 95 of file kis_scalar_keyframe_channel.h.

◆ m_rightTangent

QPointF KisScalarKeyframe::m_rightTangent
private

Controls part of between this and NEXT keyframe.

Definition at line 96 of file kis_scalar_keyframe_channel.h.

◆ m_tangentsMode

TangentsMode KisScalarKeyframe::m_tangentsMode
private

Definition at line 94 of file kis_scalar_keyframe_channel.h.

◆ m_value

qreal KisScalarKeyframe::m_value
private

Scalar value of this keyframe. Optionally clamped to m_channelLimits.

Definition at line 92 of file kis_scalar_keyframe_channel.h.

◆ valueChangedChannelConnection

QMetaObject::Connection KisScalarKeyframe::valueChangedChannelConnection

For now, scalar keyframes have a callback connection to the channel that owns them in order to signal that their internal state has changed. Created by the channel.

Definition at line 83 of file kis_scalar_keyframe_channel.h.


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