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();
203 if (myAlias.isstring())
211 getCollection()->getFullPath(
this, path);
215 getCollection()->getFullPath(
this, path);
225 {
return getManager()->getTolerance(); }
229 bool isTimeDependent()
const;
233 bool isTimeDependentSlow(
int thread)
const;
234 bool isStringTimeDependentSlow(
int thread)
const;
236 bool hasNonIntegerKeys()
const;
237 bool isDataDependent(
fpreal gtime)
const;
240 bool hasOnlyOneSegment()
const;
242 bool isRotationChannel()
const;
245 bool getSurroundingSegs(
fpreal gtime,
253 bool isAtKey(
fpreal gtime)
const;
257 bool isAtHardKey(
fpreal gtime)
const;
258 bool isAtHardKeyframe(
int frame)
const;
261 int findKeyframe(
int frame,
int direction)
const;
272 const bool ascending=
true)
const;
275 const bool ascending=
true)
const;
287 bool accel_ratios =
true,
291 bool accel_ratios =
true,
296 bool accel_ratios,
bool apply_auto_slope,
297 bool update_fake_slope_accel_handles);
299 bool accel_ratios,
bool apply_auto_slope,
300 bool update_fake_slope_accel_handles);
303 bool accel_ratios =
true,
bool apply_auto_slope =
true )
305 putKey(gtime, key, accel_ratios, apply_auto_slope,
true);
308 bool accel_ratios =
true,
bool apply_auto_slope =
true )
310 putFullKey(gtime, key, accel_ratios, apply_auto_slope,
true);
313 void transferKey(
fpreal to_time,
317 void applyDefaultSlopeToKey(
CH_Key &key );
320 void insertKeyFrame(
fpreal global_t,
bool use_auto_slope_pref=
true);
323 void destroyKeyFrame(
fpreal global_t);
327 void moveKeyFrame(
fpreal old_gtime,
fpreal new_gtime );
329 void saveKeyFrameForUndo(
fpreal global_t );
342 bool set_pending =
false,
343 bool commit_keys =
true,
344 bool propagate =
true);
346 bool set_pending =
false,
347 bool commit_keys =
true,
348 bool propagate =
true);
351 bool set_pending =
false,
352 bool commit_keys =
true,
353 bool propagate =
true);
361 bool error_frames_only);
367 bool error_frames_only);
371 int minframe,
int maxframe);
375 const char *getExpression(
fpreal gtime )
const;
376 bool changeExpression(
fpreal gtime,
379 bool convert_accels );
392 void clearSegments();
399 void deleteKeys(
const UT_Array<int> &ascending_sorted_key_indices);
416 bool apply_auto_slope =
true);
440 SnapType
type=SNAP_SNAP,
441 std::ostream *os=
nullptr );
444 void scroll (
fpreal new_start,
bool update =
true);
448 bool increaseKeyValues(
fpreal delta );
451 bool isAllDisabled()
const;
452 bool isAllEnabled()
const;
453 bool isDisabled(
fpreal gtime)
const;
454 void disableAll(
fpreal gtime);
462 {
return myPending; }
463 bool isPending(
fpreal gtime)
const;
464 bool isPendingLocal(
fpreal ltime)
const;
466 void updatePending(
fpreal gtime );
468 {
return globalTime(myPendingEvalTime); }
471 {
return myPendingHold; }
472 void setPendingHold(
bool state );
475 void save(std::ostream &os,
bool binary,
bool compiled,
476 bool pending_state)
const;
477 template <
typename FPREAL_TYPE>
479 void display()
const;
480 void displayAsKeys()
const;
486 { myDefString = dv; }
516 void setLocked(
bool f);
520 void setChanged(
bool on,
522 void dirtyExprCache();
527 return myParent->canAccessChannel(mask,
this);
544 void unresolveLocalVars(
int thread);
547 void buildOpDependencies(
void *ref_id,
int thread);
548 void changeOpRef(
const char *new_fullpath,
549 const char *old_fullpath,
551 const char *chan_name,
552 const char *old_chan_name,
556 void cook(
int state);
563 void setScope(
bool on_off);
564 bool isScoped()
const;
573 bool no_disabling,
bool use_cache,
int thread);
578 fpreal localtime,
bool extend,
581 int findString(
const char *str,
bool fullword,
582 bool usewildcards)
const;
583 int changeString(
const char *from,
const char *to,
584 bool fullword,
bool update ,
591 static inline void getGlueTime(
594 static inline void getGlueSlope(
601 return getManager()->evalContext(thread).segment();
605 return getManager()->evalContext(thread).segment();
621 int match(
const char *
pattern)
const;
646 bool preserve_extrema,
648 bool delete_old_segments =
false);
655 void refit(
fpreal tolerance,
bool preserve_extrema );
656 void refit(
fpreal tolerance,
bool preserve_extrema,
658 bool delete_old_segments);
673 bool setKeys(
fpreal *new_key_values,
int num_keys,
675 bool smooth_slopes =
true,
676 bool clear =
false,
bool notify =
true);
679 bool isEmpty()
const;
680 int getNSegments()
const;
681 int getNKeys()
const;
682 int getNKeysBefore(
fpreal gtime )
const;
683 int getNKeysBeforeOrAt(
fpreal gtime )
const;
685 fpreal getKeyTime(
unsigned idx )
const;
687 unsigned getSegmentIdx(
fpreal local_time)
const;
691 CH_Segment *getNextSegment(
unsigned idx)
const;
692 CH_Segment *getPrevSegment(
unsigned idx)
const;
700 ?
nullptr : getSegment( (
unsigned)0 );
710 ?
nullptr : getSegment( (
unsigned)mySegments.entries()-1 );
713 int64 getMemoryUsage(
bool inclusive)
const;
718 bool adjust_and_update =
true);
720 bool getHaveCompiledExpressions()
const;
723 bool verify(
bool verify_tied_values);
730 void undoSnapshot(
CH_Channel *previous,
bool previous_snapshot_cleared);
733 bool clearSnapshot();
744 void smoothAutoSlopesForSegments(
749 void smoothAutoSlopes();
754 void smoothAutoSlopes(
fpreal global_time,
fpreal delta = -1,
bool value_changed =
true );
759 void setLayerScope(
bool on_off);
760 bool isLayerScoped()
const;
766 void putChFullKey(
fpreal gtime,
CH_FullKey const& key,
bool accel_ratios =
true );
784 bool isSimpleChannel()
const;
794 void ensureEndSegmentCreated();
795 void updateEndSegment();
796 void destroyEndSegment();
798 bool isTwoSegChannelTimeDep()
const;
800 template <
typename T>
801 bool isTimeDependentSlowImpl(
int thread)
const;
807 friend class CH_BatchModifyScope;
809 void moveKeyInternal(
fpreal old_gtime,
fpreal new_gtime,
810 CH_BatchModifyScope &scope);
811 void splitSegment(
fpreal gtime,
bool accel_ratio =
true);
812 void destroyKeyInternal(
unsigned seg_i, CH_BatchModifyScope &scope);
820 void deleteSegment(
unsigned idx);
822 int getNDisableSegments()
const
823 {
return myDisableSegments.entries(); }
824 CH_Segment *getDisableSegment(
unsigned idx)
const
826 return (idx < myDisableSegments.entries()) ?
827 myDisableSegments(idx) : 0;
834 int getDisableSegmentIndex(
fpreal ltime,
bool closest_prev)
const;
838 return (myDisableSegments.entries() > 0) ?
839 myDisableSegments(0) : 0;
843 return (myDisableSegments.entries() > 0)
844 ? myDisableSegments(myDisableSegments.entries()-1)
855 void removeDisableSegment(
int idx);
858 void deleteDisableSegment(
int idx);
860 void setPending(
bool on_off,
fpreal ltime );
861 void updatePendingStateToManager();
865 int isCooking()
const
869 void setCooking(
bool on_off)
875 void adjustSegments(
int begin_i,
int end_i,
879 CH_Segment *getFirstSegment(
bool no_disabling )
const;
880 CH_Segment *getLastSegment(
bool no_disabling )
const;
881 CH_Segment *getEndSegment(
bool no_disabling )
const;
884 enum chGetOrSampleReturn
886 Sampled, Get, FirstLast
888 chGetOrSampleReturn getOrSampleKey(
fpreal ltime,
CH_Key &key,
bool accel_ratio,
int thread );
899 bool setAllKeys(
fpreal *new_key_values,
int num_keys,
901 bool smooth_slopes,
bool notify);
934 unsigned char myFlags;
941 bool mySnapshotCleared;
950 if( idx<mySegments.entries() )
951 return mySegments(idx);
952 if( idx==(
unsigned)-1 || idx==mySegments.entries() )
954 UT_ASSERT(myEndSegment || mySegments.entries() == 0);
964 return myEndSegment ? 1 + mySegments.
entries() : 0;
970 return mySegments.
isEmpty() && !myEndSegment;
983 if( idx == mySegments.
entries() )
1004 return myName ==
"rx" || myName ==
"ry" || myName ==
"rz";
1013 : myChannel(nullptr)
1036 SYSisLessOrEqual(lt, myRange.
max, myTol)
1037 : SYSisLess(lt, myRange.
max, myTol));
1045 SYSisGreaterOrEqual(lt, myRange.
min, myTol)
1046 : SYSisGreater(lt, myRange.
min, myTol));
1051 return (
unsigned)myI;
1056 return *(myChannel->
getSegment((
unsigned)myI));
1070 const bool ascending)
1089 if (SYSisLess(lt, myRange.
min, myTol))
1094 if (SYSisLessOrEqual(lt, myRange.
min, myTol))
1113 if (SYSisGreater(lt, myRange.
max, myTol))
1118 if (SYSisGreaterOrEqual(lt, myRange.
max, myTol))
1275 t1 = eval_channel->
getEnd();
1326 return isTwoSegChannelTimeDep();
1335 static inline size_t
1345 ::memcpy(buffer, s.
c_str(), len);
1350 #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)
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 reverse(I begin, I end)
void swap(T &lhs, T &rhs)
void setIsTemporary(bool temp)
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--()
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.
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)
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
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.