12 #ifndef __CH_Channel_h__
13 #define __CH_Channel_h__
45 class CH_BatchModifyScope;
86 bool accel_ratio = true );
89 bool accel_ratio =
true,
bool update_fake_slope_accel_handles =
true )
const;
91 void stretch(
fpreal xscale,
fpreal yscale,
bool accel_ratio );
93 void changeAccelsToRatios(
fpreal left_seg_len,
fpreal right_seg_len );
97 void opscript( std::ostream &os,
bool use_time,
98 bool only_valid=
true )
const;
100 bool verify(
bool check_tied_slopes=
true )
const;
112 myUseExpression =
false;
131 myUseRevExpression =
false;
157 bool end() {
return myNoMoreChannels; }
166 bool myNoMoreChannels;
183 const char *default_string =
nullptr,
bool temporary=
false);
190 void initializeFirstSegment(const
char *expr,
194 void initializeSegmentParents();
205 if (myAlias.isstring())
213 getCollection()->getFullPath(
this, path);
217 getCollection()->getFullPath(
this, path);
227 {
return getManager()->getTolerance(); }
231 bool isTimeDependent()
const;
235 bool isTimeDependentSlow(
int thread)
const;
236 bool isStringTimeDependentSlow(
int thread)
const;
238 bool hasNonIntegerKeys()
const;
239 bool isDataDependent(
fpreal gtime)
const;
242 bool hasOnlyOneSegment()
const;
244 bool isRotationChannel()
const;
247 bool getSurroundingSegs(
fpreal gtime,
255 bool isAtKey(
fpreal gtime)
const;
259 bool isAtHardKey(
fpreal gtime)
const;
260 bool isAtHardKeyframe(
int frame)
const;
263 int findKeyframe(
int frame,
int direction)
const;
274 const bool ascending=
true)
const;
277 const bool ascending=
true)
const;
289 bool accel_ratios =
true,
293 bool accel_ratios =
true,
298 bool accel_ratios,
bool apply_auto_slope,
299 bool update_fake_slope_accel_handles);
301 bool accel_ratios,
bool apply_auto_slope,
302 bool update_fake_slope_accel_handles);
305 bool accel_ratios =
true,
bool apply_auto_slope =
true )
307 putKey(gtime, key, accel_ratios, apply_auto_slope,
true);
310 bool accel_ratios =
true,
bool apply_auto_slope =
true )
312 putFullKey(gtime, key, accel_ratios, apply_auto_slope,
true);
315 void transferKey(
fpreal to_time,
319 void applyDefaultSlopeToKey(
CH_Key &key );
322 void insertKeyFrame(
fpreal global_t,
bool use_auto_slope_pref=
true);
325 void destroyKeyFrame(
fpreal global_t);
329 void moveKeyFrame(
fpreal old_gtime,
fpreal new_gtime );
330 void moveKeyFrame(
fpreal old_gtime,
fpreal new_gtime, CH_BatchModifyScope &scope );
332 void saveKeyFrameForUndo(
fpreal global_t );
345 bool set_pending =
false,
346 bool commit_keys =
true,
347 bool propagate =
true);
349 bool set_pending =
false,
350 bool commit_keys =
true,
351 bool propagate =
true);
354 bool set_pending =
false,
355 bool commit_keys =
true,
356 bool propagate =
true);
364 bool error_frames_only);
370 bool error_frames_only);
374 int minframe,
int maxframe);
378 const char *getExpression(
fpreal gtime )
const;
379 bool changeExpression(
fpreal gtime,
382 bool convert_accels );
395 void clearSegments();
402 void deleteKeys(
const UT_Array<int> &ascending_sorted_key_indices);
419 bool apply_auto_slope =
true);
443 SnapType
type=SNAP_SNAP,
444 std::ostream *os=
nullptr );
447 void scroll (
fpreal new_start,
bool update =
true);
451 bool increaseKeyValues(
fpreal delta );
454 bool isAllDisabled()
const;
455 bool isAllEnabled()
const;
456 bool isDisabled(
fpreal gtime)
const;
457 void disableAll(
fpreal gtime);
465 {
return myPending; }
466 bool isPending(
fpreal gtime)
const;
467 bool isPendingLocal(
fpreal ltime)
const;
469 void updatePending(
fpreal gtime );
471 {
return globalTime(myPendingEvalTime); }
474 {
return myPendingHold; }
475 void setPendingHold(
bool state );
478 void save(std::ostream &os,
bool binary,
bool compiled,
479 bool pending_state)
const;
480 template <
typename FPREAL_TYPE>
482 void display()
const;
483 void displayAsKeys()
const;
489 { myDefString = dv; }
519 void setLocked(
bool f);
523 void setChanged(
bool on,
525 void dirtyExprCache();
530 return myParent->canAccessChannel(mask,
this);
547 void unresolveLocalVars(
int thread);
550 void buildOpDependencies(
void *ref_id,
int thread);
551 void changeOpRef(
const char *new_fullpath,
552 const char *old_fullpath,
554 const char *chan_name,
555 const char *old_chan_name,
559 void cook(
int state);
566 void setScope(
bool on_off);
567 bool isScoped()
const;
576 bool no_disabling,
bool use_cache,
int thread);
584 int findString(
const char *str,
bool fullword,
585 bool usewildcards)
const;
586 int changeString(
const char *from,
const char *to,
587 bool fullword,
bool update ,
594 static inline void getGlueTime(
597 static inline void getGlueSlope(
604 return getManager()->evalContext(thread).segment();
608 return getManager()->evalContext(thread).segment();
624 int match(
const char *
pattern)
const;
649 bool preserve_extrema,
651 bool delete_old_segments =
false);
658 void refit(
fpreal tolerance,
bool preserve_extrema );
659 void refit(
fpreal tolerance,
bool preserve_extrema,
661 bool delete_old_segments);
676 bool setKeys(
fpreal *new_key_values,
int num_keys,
678 bool smooth_slopes =
true,
679 bool clear =
false,
bool notify =
true);
682 bool isEmpty()
const;
683 int getNSegments()
const;
684 int getNKeys()
const;
685 int getNKeysBefore(
fpreal gtime )
const;
686 int getNKeysBeforeOrAt(
fpreal gtime )
const;
688 fpreal getKeyTime(
unsigned idx )
const;
690 unsigned getSegmentIdx(
fpreal local_time)
const;
694 CH_Segment *getNextSegment(
unsigned idx)
const;
695 CH_Segment *getPrevSegment(
unsigned idx)
const;
703 ?
nullptr : getSegment( (
unsigned)0 );
713 ?
nullptr : getSegment( (
unsigned)mySegments.entries()-1 );
716 int64 getMemoryUsage(
bool inclusive)
const;
721 bool adjust_and_update =
true);
723 bool getHaveCompiledExpressions()
const;
726 bool verify(
bool verify_tied_values);
733 void undoSnapshot(
CH_Channel *previous,
bool previous_snapshot_cleared);
736 bool clearSnapshot();
748 void smoothAutoSlopesForSegments(
754 void smoothAutoSlopesForSegments(
759 void smoothAutoSlopes();
764 void smoothAutoSlopes(
fpreal global_time,
fpreal delta = -1,
bool value_changed =
true );
772 bool value_changed)
const;
775 void setLayerScope(
bool on_off);
776 bool isLayerScoped()
const;
782 void putChFullKey(
fpreal gtime,
CH_FullKey const& key,
bool accel_ratios =
true );
800 bool isSimpleChannel()
const;
811 void clear(
bool clear_defaults);
815 void ensureEndSegmentCreated();
816 void updateEndSegment();
817 void destroyEndSegment();
819 bool isTwoSegChannelTimeDep()
const;
821 template <
typename T>
822 bool isTimeDependentSlowImpl(
int thread)
const;
828 friend class CH_BatchModifyScope;
830 void moveKeyInternal(
fpreal old_gtime,
fpreal new_gtime,
831 CH_BatchModifyScope &scope);
832 void splitSegment(
fpreal gtime,
bool accel_ratio =
true);
833 void destroyKeyInternal(
unsigned seg_i, CH_BatchModifyScope &scope);
841 void deleteSegment(
unsigned idx);
843 int getNDisableSegments()
const
844 {
return myDisableSegments.entries(); }
845 CH_Segment *getDisableSegment(
unsigned idx)
const
847 return (idx < myDisableSegments.entries()) ?
848 myDisableSegments(idx) : 0;
855 int getDisableSegmentIndex(
fpreal ltime,
bool closest_prev)
const;
859 return (myDisableSegments.entries() > 0) ?
860 myDisableSegments(0) : 0;
864 return (myDisableSegments.entries() > 0)
865 ? myDisableSegments(myDisableSegments.entries()-1)
876 void removeDisableSegment(
int idx);
879 void deleteDisableSegment(
int idx);
881 void setPending(
bool on_off,
fpreal ltime );
882 void updatePendingStateToManager();
886 int isCooking()
const
890 void setCooking(
bool on_off)
896 void adjustSegments(
int begin_i,
int end_i,
900 CH_Segment *getFirstSegment(
bool no_disabling )
const;
901 CH_Segment *getLastSegment(
bool no_disabling )
const;
902 CH_Segment *getEndSegment(
bool no_disabling )
const;
905 enum chGetOrSampleReturn
907 Sampled, Get, FirstLast
909 chGetOrSampleReturn getOrSampleKey(
fpreal ltime,
CH_Key &key,
bool accel_ratio,
int thread );
920 bool setAllKeys(
fpreal *new_key_values,
int num_keys,
922 bool smooth_slopes,
bool notify);
955 unsigned char myFlags;
962 bool mySnapshotCleared;
971 if( idx<mySegments.entries() )
972 return mySegments(idx);
973 if( idx==(
unsigned)-1 || idx==mySegments.entries() )
975 UT_ASSERT(myEndSegment || mySegments.entries() == 0);
985 return myEndSegment ? 1 + mySegments.
entries() : 0;
991 return mySegments.
isEmpty() && !myEndSegment;
1004 if( idx == mySegments.
entries() )
1006 segp = myEndSegment;
1025 return myName ==
"rx" || myName ==
"ry" || myName ==
"rz";
1034 : myChannel(nullptr)
1057 SYSisLessOrEqual(lt, myRange.
max, myTol)
1058 : SYSisLess(lt, myRange.
max, myTol));
1066 SYSisGreaterOrEqual(lt, myRange.
min, myTol)
1067 : SYSisGreater(lt, myRange.
min, myTol));
1072 return (
unsigned)myI;
1077 return *(myChannel->
getSegment((
unsigned)myI));
1091 const bool ascending)
1110 if (SYSisLess(lt, myRange.
min, myTol))
1115 if (SYSisLessOrEqual(lt, myRange.
min, myTol))
1134 if (SYSisGreater(lt, myRange.
max, myTol))
1139 if (SYSisGreaterOrEqual(lt, myRange.
max, myTol))
1296 t1 = eval_channel->
getEnd();
1347 return isTwoSegChannelTimeDep();
1356 static inline size_t
1366 ::memcpy(buffer, s.
c_str(), len);
1371 #endif // __CH_Channel_h__
const UT_StringHolder & getAlias() const
Iterator over an interval.
CH_ExprLanguage myRevExprLanguage
fpreal localTime(fpreal t) const
CH_ChannelBehavior getChannelRightType() const
unsigned getSegmentIdx(fpreal local_time) const
static void getGlueTime(fpreal &t, fpreal &t0, fpreal &t1, fpreal &v0, fpreal &v1, int thread)
const UT_StringHolder & getDefaultString() const
CH_Segment * getEvaluationSegment(int thread)
bool isEndSegment() const
IntervalIter intervalIter(const UT_SuperIntervalR &range, const bool ascending=true) const
Const iterator over an interval.
GT_API const UT_StringHolder time
IMF_EXPORT IMATH_NAMESPACE::V3f direction(const IMATH_NAMESPACE::Box2i &dataWindow, const IMATH_NAMESPACE::V2f &pixelPosition)
GLsizei const GLfloat * value
fpreal globalTime(fpreal t) const
const GLuint GLenum const void * binary
void getFullPath(UT_StringHolder &path) const
bool isRotationChannel() const
GLsizei const GLchar *const * path
const CH_Segment * segment() const
CH_API void CHmoveKeysWithDelta(CH_Channel *chp, const UT_Array< fpreal > &orig_keys, fpreal old_accepted_dt, fpreal new_accepted_dt)
GLboolean GLboolean GLboolean GLboolean a
void swap(T &lhs, T &rhs)
void setIsTemporary(bool temp)
PUGI__FN void reverse(I begin, I end)
fpreal getInValue() const
CH_FullKey & operator=(CH_FullKey const &other)
ImageBuf OIIO_API min(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
const CH_Segment & segment() const
**But if you need a result
CH_Segment & segment() const
fpreal getInSlope() const
const CH_EvalContext & evalContext(int thread) const
fpreal getOutValue() const
const char * c_str() const
bool isChangeActive() const
class CH_API IntervalIter
bool hasOnlyOneSegment() const
unsigned length() const
Return length of string.
void putKey(fpreal gtime, CH_Key const &key, bool accel_ratios=true, bool apply_auto_slope=true)
bool isTimeDependent() const
int canAccess(uint mask) const
static fpreal getGlueIV(int thread)
CH_API void CHmoveKeysWithDeltas(CH_Channel *chp, const UT_Array< fpreal > &orig_keys, const UT_Array< fpreal > &time_offsets, const UT_Array< fpreal > &value_offsets)
IntervalIter & operator--()
bool isPendingLocal(fpreal ltime) const
fpreal getDefaultValue() const
GA_API const UT_StringHolder scale
class CH_API ConstIntervalIter
ConstIntervalIter constIntervalIter(const UT_SuperIntervalR &range, const bool ascending=true) const
ConstIntervalIter & operator--()
GLint GLint GLsizei GLint GLenum GLenum type
UT_String myRevExpression
CH_Manager * CHgetManager()
ConstIntervalIter & operator++()
void setCollection(CH_Collection *chp)
const CH_Segment * getEvaluationSegment(int thread) const
CH_API void CHfindMoveKeysDelta(const CH_Channel *chp, bool snap_to_frame, fpreal base_time, const UT_Array< fpreal > &sorted_orig_keys, fpreal accepted_dt, fpreal &attempted_dt)
PXL_API const char * getName(const ColorSpace *space)
Return the name of the color space.
constexpr auto set(type rhs) -> int
fpreal getKeyTime(unsigned idx) const
GLint GLint GLsizei GLint GLenum format
void setDefaultValue(fpreal dv)
#define UT_NON_COPYABLE(CLASS)
Define deleted copy constructor and assignment operator inside a class.
void putFullKey(fpreal gtime, CH_FullKey const &key, bool accel_ratios=true, bool apply_auto_slope=true)
IntervalIter(const CH_Channel &ch, const UT_SuperIntervalR &range, bool reverse)
CH_Segment * getLastSegment() const
HUSD_API bool eval(VtValue &val, T &ret_val)
GLuint const GLchar * name
CH_Segment * getSegment(unsigned idx) const
void reverse(fpreal gstart=0, fpreal gend=0, bool whole_chan=true)
void setName(const UT_StringHolder &s)
IntervalIter & operator++()
void setChangeActive(int state)
exint entries() const
Alias of size(). size() is preferred.
SYS_FORCE_INLINE bool isPending() const
CH_Collection * getCollection()
CH_ExprLanguage myExprLanguage
**Note that the tasks the is the thread number *for the or if it s being executed by a non pool thread(this *can happen in cases where the whole pool is occupied and the calling *thread contributes to running the work load).**Thread pool.Have fun
void stretch(fpreal xscale, fpreal yscale, bool accel_ratio)
SIM_API const UT_StringHolder force
CH_Segment * getFirstSegment() const
CH_Manager * getManager() const
void setAlias(const UT_StringHolder &s)
LeafData & operator=(const LeafData &)=delete
const CH_Collection * getCollection() const
bool isTimeDependent() const
fpreal getOutSlope() const
void setDefaultString(const UT_StringHolder &dv)
fpreal getPendingEvalTime() const
#define UT_SWAPPER_CLASS(T)
fpreal getTolerance() const
fpreal getOutAccel() const
fpreal getInAccel() const
void getFullPath(UT_String &path) const
static void getGlueSlope(fpreal *m0, fpreal *m1, fpreal *a0, fpreal *a1, int thread)
CH_ChannelBehavior getChannelLeftType() const
ConstIntervalIter(const CH_Channel &ch, const UT_SuperIntervalR &range, const bool ascending)
SYS_FORCE_INLINE bool isPendingHold() const
bool contains(T arg, T tol=T(SYS_FTOLERANCE)) const
fpreal getTolerance() const
FMT_BEGIN_EXPORT std::tm localtime(std::time_t time)
const CH_Channel * channel() const
bool isEmpty() const
Returns true iff there are no occupied elements in the array.
PcpNodeRef_ChildrenIterator begin(const PcpNodeRef::child_const_range &r)
Support for range-based for loops for PcpNodeRef children ranges.