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

#include <kis_time_span.h>

+ Inheritance diagram for KisTimeSpan:

Public Member Functions

bool contains (int time) const
 
int duration () const
 
int end () const
 
void include (int time)
 
bool isInfinite () const
 
bool isValid () const
 
 KisTimeSpan ()
 
KisTimeSpan operator& (const KisTimeSpan &rhs) const
 
const KisTimeSpanoperator&= (const KisTimeSpan &rhs)
 
bool operator== (const KisTimeSpan &rhs) const
 
KisTimeSpan operator| (const KisTimeSpan &rhs) const
 
const KisTimeSpanoperator|= (const KisTimeSpan &rhs)
 
bool overlaps (const KisTimeSpan &other) const
 
int start () const
 

Static Public Member Functions

static KisTimeSpan calculateAffectedFramesRecursive (const KisNode *node, int time)
 
static KisTimeSpan calculateIdenticalFramesRecursive (const KisNode *node, int time)
 
static KisTimeSpan calculateNodeAffectedFrames (const KisNode *node, int time)
 
static KisTimeSpan calculateNodeIdenticalFrames (const KisNode *node, int time)
 
static KisTimeSpan fromTimeToTime (int start, int end)
 
static KisTimeSpan fromTimeWithDuration (int start, int duration)
 
static KisTimeSpan infinite (int start)
 

Private Member Functions

 KisTimeSpan (int start, int end)
 

Private Attributes

int m_end
 
int m_start
 

Detailed Description

Definition at line 19 of file kis_time_span.h.

Constructor & Destructor Documentation

◆ KisTimeSpan() [1/2]

KisTimeSpan::KisTimeSpan ( int start,
int end )
inlineprivate

Definition at line 22 of file kis_time_span.h.

23 : m_start(start),
24 m_end(end)
25 {
26 }
int start() const

◆ KisTimeSpan() [2/2]

KisTimeSpan::KisTimeSpan ( )
inline

Definition at line 29 of file kis_time_span.h.

30 : m_start(0),
31 m_end(-1)
32 {
33 }

Member Function Documentation

◆ calculateAffectedFramesRecursive()

KisTimeSpan KisTimeSpan::calculateAffectedFramesRecursive ( const KisNode * node,
int time )
static

Definition at line 40 of file kis_time_span.cpp.

41{
42 KisTimeSpan range;
43
45 [&range, time] (const KisNode *node) {
46 if (node->visible()) {
47 range |= calculateNodeIdenticalFrames(node, time);
48 }
49 });
50
51 return range;
52}
void recursiveApplyNodes(NodePointer node, Functor func)
virtual bool visible(bool recursive=false) const

References KisLayerUtils::recursiveApplyNodes(), and KisBaseNode::visible().

◆ calculateIdenticalFramesRecursive()

KisTimeSpan KisTimeSpan::calculateIdenticalFramesRecursive ( const KisNode * node,
int time )
static

Definition at line 26 of file kis_time_span.cpp.

27{
29
31 [&range, time] (const KisNode *node) {
32 if (node->visible()) {
33 range &= calculateNodeIdenticalFrames(node, time);
34 }
35 });
36
37 return range;
38}
static KisTimeSpan infinite(int start)

References infinite(), KisLayerUtils::recursiveApplyNodes(), and KisBaseNode::visible().

◆ calculateNodeAffectedFrames()

KisTimeSpan KisTimeSpan::calculateNodeAffectedFrames ( const KisNode * node,
int time )
static

Definition at line 69 of file kis_time_span.cpp.

70{
71 KisTimeSpan range;
72
73 if (!node->visible()) return range;
74
75 const QMap<QString, KisKeyframeChannel*> channels =
76 node->keyframeChannels();
77
78 // TODO: channels should report to the image which channel exactly has changed
79 // to avoid the dirty range to be stretched into infinity!
80
81 if (channels.isEmpty() ||
82 !channels.contains(KisKeyframeChannel::Raster.id())) {
83 range = KisTimeSpan::infinite(0);
84 return range;
85 }
86
87 Q_FOREACH (const KisKeyframeChannel *channel, channels) {
88 // Union
89 range |= channel->affectedFrames(time);
90 }
91
92 return range;
93}
KisKeyframeChannel stores and manages KisKeyframes. Maps units of time to virtual keyframe values....
static const KoID Raster
virtual KisTimeSpan affectedFrames(int time) const
Get the set of frames affected by any changes to the value or content of the active keyframe at the g...
QString id() const
Definition KoID.cpp:63
QMap< QString, KisKeyframeChannel * > keyframeChannels

References KisKeyframeChannel::affectedFrames(), KoID::id(), infinite(), KisBaseNode::keyframeChannels, KisKeyframeChannel::Raster, and KisBaseNode::visible().

◆ calculateNodeIdenticalFrames()

KisTimeSpan KisTimeSpan::calculateNodeIdenticalFrames ( const KisNode * node,
int time )
static

Definition at line 54 of file kis_time_span.cpp.

55{
57
58 const QMap<QString, KisKeyframeChannel*> channels =
59 node->keyframeChannels();
60
61 Q_FOREACH (const KisKeyframeChannel *channel, channels) {
62 // Intersection
63 range &= channel->identicalFrames(time);
64 }
65
66 return range;
67}
virtual KisTimeSpan identicalFrames(int time) const
Get a span of times for which the channel gives identical results compared to frame at a given time....

References KisKeyframeChannel::identicalFrames(), infinite(), and KisBaseNode::keyframeChannels.

◆ contains()

bool KisTimeSpan::contains ( int time) const
inline

Definition at line 55 of file kis_time_span.h.

55 {
56 if (m_end == std::numeric_limits<int>::min()) {
57 return m_start <= time;
58 }
59
60 return m_start <= time && time <= m_end;
61 }

◆ duration()

int KisTimeSpan::duration ( ) const
inline

Definition at line 43 of file kis_time_span.h.

43 {
44 return m_end >= m_start ? m_end - m_start + 1 : 0;
45 }

◆ end()

int KisTimeSpan::end ( ) const
inline

Definition at line 39 of file kis_time_span.h.

39 {
40 return m_end;
41 }

◆ fromTimeToTime()

static KisTimeSpan KisTimeSpan::fromTimeToTime ( int start,
int end )
inlinestatic

Definition at line 88 of file kis_time_span.h.

88 {
89 return KisTimeSpan(start, end);
90 }

◆ fromTimeWithDuration()

static KisTimeSpan KisTimeSpan::fromTimeWithDuration ( int start,
int duration )
inlinestatic

Definition at line 92 of file kis_time_span.h.

92 {
93 return KisTimeSpan( start, start + duration - 1);
94 }
int duration() const

◆ include()

void KisTimeSpan::include ( int time)
inline

Definition at line 63 of file kis_time_span.h.

63 {
64 m_start = qMin(time, m_start);
65 m_end = qMax(time, m_end);
66 }

◆ infinite()

static KisTimeSpan KisTimeSpan::infinite ( int start)
inlinestatic

Definition at line 96 of file kis_time_span.h.

96 {
97 return KisTimeSpan(start, std::numeric_limits<int>::min());
98 }

◆ isInfinite()

bool KisTimeSpan::isInfinite ( ) const
inline

Definition at line 47 of file kis_time_span.h.

47 {
48 return m_end == std::numeric_limits<int>::min();
49 }

◆ isValid()

bool KisTimeSpan::isValid ( ) const
inline

Definition at line 51 of file kis_time_span.h.

51 {
52 return (m_end >= m_start) || (m_end == std::numeric_limits<int>::min() && m_start >= 0);
53 }

◆ operator&()

KisTimeSpan KisTimeSpan::operator& ( const KisTimeSpan & rhs) const
inline

Definition at line 137 of file kis_time_span.h.

137 {
138 KisTimeSpan result = *this;
139
140 if (!isValid()) {
141 return result;
142 } else if (!rhs.isValid()) {
143 result.m_start = rhs.start();
144 result.m_end = rhs.m_end;
145 return result;
146 } else {
147 result.m_start = std::max(result.m_start, rhs.start());
148 }
149
150 if (isInfinite()) {
151 result.m_end = rhs.m_end;
152 } else if (!rhs.isInfinite()) {
153 result.m_end = std::min(result.m_end, rhs.m_end);
154 }
155
156 return result;
157 }
bool isInfinite() const
bool isValid() const

References isInfinite(), isValid(), m_end, m_start, and start().

◆ operator&=()

const KisTimeSpan & KisTimeSpan::operator&= ( const KisTimeSpan & rhs)
inline

Definition at line 159 of file kis_time_span.h.

159 {
160 KisTimeSpan result = (*this & rhs);
161 this->m_start = result.m_start;
162 this->m_end = result.m_end;
163 return *this;
164 }

References m_end, and m_start.

◆ operator==()

bool KisTimeSpan::operator== ( const KisTimeSpan & rhs) const
inline

Definition at line 106 of file kis_time_span.h.

106 {
107 return rhs.m_start == m_start && rhs.m_end == m_end;
108 }

References m_end, and m_start.

◆ operator|()

KisTimeSpan KisTimeSpan::operator| ( const KisTimeSpan & rhs) const
inline

Definition at line 110 of file kis_time_span.h.

110 {
111 KisTimeSpan result = *this;
112
113 if (!result.isValid()) {
114 result.m_start = rhs.start();
115 } else if (rhs.isValid()) {
116 result.m_start = std::min(result.m_start, rhs.start());
117 }
118
119 if (rhs.isInfinite() || result.isInfinite()) {
120 result.m_end = std::numeric_limits<int>::min();
121 } else if (!isValid()) {
122 result.m_end = rhs.m_end;
123 } else {
124 result.m_end = std::max(m_end, rhs.m_end);
125 }
126
127 return result;
128 }

References isInfinite(), isValid(), m_end, m_start, and start().

◆ operator|=()

const KisTimeSpan & KisTimeSpan::operator|= ( const KisTimeSpan & rhs)
inline

Definition at line 130 of file kis_time_span.h.

130 {
131 KisTimeSpan result = (*this | rhs);
132 this->m_start = result.m_start;
133 this->m_end = result.m_end;
134 return *this;
135 }

References m_end, and m_start.

◆ overlaps()

bool KisTimeSpan::overlaps ( const KisTimeSpan & other) const
inline

Definition at line 68 of file kis_time_span.h.

68 {
69 // If either are "invalid", we should probably return false.
70 if (!isValid() || !other.isValid()) {
71 return false;
72 }
73
74 // Handle infinite cases...
75 if (other.isInfinite()) {
76 return (other.contains(start()) || other.contains(end()));
77 } else if (isInfinite()) {
78 return (contains(other.start()) || contains(other.end()));
79 }
80
81 const int selfMin = qMin(start(), end());
82 const int selfMax = qMax(start(), end());
83 const int otherMin = qMin(other.start(), other.end());
84 const int otherMax = qMax(other.start(), other.end());
85 return (selfMax >= otherMin) && (selfMin <= otherMax );
86 }
bool contains(int time) const
int end() const

References contains(), end(), isInfinite(), isValid(), and start().

◆ start()

int KisTimeSpan::start ( ) const
inline

Definition at line 35 of file kis_time_span.h.

35 {
36 return m_start;
37 }

Member Data Documentation

◆ m_end

int KisTimeSpan::m_end
private

Definition at line 168 of file kis_time_span.h.

◆ m_start

int KisTimeSpan::m_start
private

Definition at line 167 of file kis_time_span.h.


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