12 #ifndef __CH_Channel_h__
13 #define __CH_Channel_h__
85 bool accel_ratio = true );
88 bool accel_ratio =
true,
bool update_fake_slope_accel_handles =
true )
const;
90 void stretch(
fpreal xscale,
fpreal yscale,
bool accel_ratio );
92 void changeAccelsToRatios(
fpreal left_seg_len,
fpreal right_seg_len );
96 void opscript( std::ostream &os,
bool use_time,
97 bool only_valid=
true )
const;
99 bool verify(
bool check_tied_slopes=
true )
const;
111 myUseExpression =
false;
130 myUseRevExpression =
false;
156 bool end() {
return myNoMoreChannels; }
165 bool myNoMoreChannels;
182 const char *default_string =
nullptr,
bool temporary=
false);
189 void initializeFirstSegment(const
char *expr,
193 void initializeSegmentParents();
204 if (myAlias.isstring())
212 getCollection()->getFullPath(
this, path);
216 getCollection()->getFullPath(
this, path);
226 {
return getManager()->getTolerance(); }
230 bool isTimeDependent()
const;
234 bool isTimeDependentSlow(
int thread)
const;
235 bool isStringTimeDependentSlow(
int thread)
const;
237 bool hasNonIntegerKeys()
const;
238 bool isDataDependent(
fpreal gtime)
const;
241 bool hasOnlyOneSegment()
const;
243 bool isRotationChannel()
const;
246 bool getSurroundingSegs(
fpreal gtime,
254 bool isAtKey(
fpreal gtime)
const;
259 bool isAtHardKey(
fpreal gtime,
261 bool isAtHardKey(
fpreal gtime)
const;
262 bool isAtHardKeyframe(
int frame)
const;
265 int findKeyframe(
int frame,
int direction)
const;
276 const bool ascending=
true)
const;
279 const bool ascending=
true)
const;
294 bool accel_ratios =
true,
297 bool reverse,
bool accel_ratios,
302 bool accel_ratios =
true,
307 bool accel_ratios,
bool apply_auto_slope,
308 bool update_fake_slope_accel_handles);
311 bool accel_ratios,
bool apply_auto_slope,
312 bool update_fake_slope_accel_handles);
315 bool accel_ratios =
true,
bool apply_auto_slope =
true )
317 putKey(gtime, key, accel_ratios, apply_auto_slope,
true);
320 bool accel_ratios =
true,
bool apply_auto_slope =
true )
322 return putFullKey(gtime, key, accel_ratios, apply_auto_slope,
true);
325 void transferKey(
fpreal to_time,
329 void applyDefaultSlopeToKey(
CH_Key &key );
332 void insertKeyFrame(
fpreal global_t,
bool use_auto_slope_pref=
true);
335 void destroyKeyFrame(
fpreal global_t,
336 bool smooth_auto_slopes);
337 void destroyKeyFrame(
fpreal global_t);
341 void moveKeyFrame(
fpreal old_gtime,
fpreal new_gtime );
344 void saveKeyFrameForUndo(
fpreal global_t );
357 bool set_pending =
false,
358 bool commit_keys =
true,
359 bool propagate =
true);
361 bool set_pending =
false,
362 bool commit_keys =
true,
363 bool propagate =
true);
366 bool set_pending =
false,
367 bool commit_keys =
true,
368 bool propagate =
true);
376 bool error_frames_only);
382 bool error_frames_only);
386 int minframe,
int maxframe);
390 const char *getExpression(
fpreal gtime )
const;
391 bool changeExpression(
fpreal gtime,
394 bool convert_accels );
407 void clearSegments();
414 void deleteKeys(
const UT_Array<int> &ascending_sorted_key_indices);
431 bool apply_auto_slope =
true);
455 SnapType
type=SNAP_SNAP,
456 std::ostream *os=
nullptr );
459 void scroll (
fpreal new_start,
bool update =
true);
463 bool increaseKeyValues(
fpreal delta );
466 bool isAllDisabled()
const;
467 bool isAllEnabled()
const;
468 bool isDisabled(
fpreal gtime)
const;
469 void disableAll(
fpreal gtime);
477 {
return myPending; }
478 bool isPending(
fpreal gtime)
const;
479 bool isPendingLocal(
fpreal ltime)
const;
481 void updatePending(
fpreal gtime );
483 {
return globalTime(myPendingEvalTime); }
486 {
return myPendingHold; }
487 void setPendingHold(
bool state );
490 void save(std::ostream &os,
bool binary,
bool compiled,
491 bool pending_state)
const;
492 template <
typename FPREAL_TYPE>
494 void display()
const;
495 void displayAsKeys()
const;
501 { myDefString = dv; }
531 void setLocked(
bool f);
535 void setChanged(
bool on,
537 void dirtyExprCache();
542 return myParent->canAccessChannel(mask,
this);
559 void unresolveLocalVars(
int thread);
562 void buildOpDependencies(
void *ref_id,
int thread);
563 void changeOpRef(
const char *new_fullpath,
564 const char *old_fullpath,
566 const char *chan_name,
567 const char *old_chan_name,
571 void cook(
int state);
578 void setScope(
bool on_off);
579 bool isScoped()
const;
588 bool no_disabling,
bool use_cache,
int thread);
596 int findString(
const char *str,
bool fullword,
597 bool usewildcards)
const;
598 int changeString(
const char *from,
const char *to,
599 bool fullword,
bool update ,
606 static inline void getGlueTime(
609 static inline void getGlueSlope(
616 return getManager()->evalContext(thread).segment();
620 return getManager()->evalContext(thread).segment();
636 int match(
const char *
pattern)
const;
661 bool preserve_extrema,
663 bool delete_old_segments =
false);
670 void refit(
fpreal tolerance,
bool preserve_extrema );
671 void refit(
fpreal tolerance,
bool preserve_extrema,
673 bool delete_old_segments);
688 bool setKeys(
fpreal *new_key_values,
int num_keys,
690 bool smooth_slopes =
true,
691 bool clear =
false,
bool notify =
true);
694 bool isEmpty()
const;
695 int getNSegments()
const;
696 int getNKeys()
const;
697 int getNKeysBefore(
fpreal gtime )
const;
698 int getNKeysBeforeOrAt(
fpreal gtime )
const;
700 fpreal getKeyTime(
unsigned idx )
const;
702 unsigned getSegmentIdx(
fpreal local_time)
const;
706 CH_Segment *getNextSegment(
unsigned idx)
const;
707 CH_Segment *getPrevSegment(
unsigned idx)
const;
715 ?
nullptr : getSegment( (
unsigned)0 );
725 ?
nullptr : getSegment( (
unsigned)mySegments.entries()-1 );
728 int64 getMemoryUsage(
bool inclusive)
const;
733 bool adjust_and_update =
true);
735 bool getHaveCompiledExpressions()
const;
738 bool verify(
bool verify_tied_values);
745 void undoSnapshot(
CH_Channel *previous,
bool previous_snapshot_cleared);
748 bool clearSnapshot();
760 void smoothAutoSlopesForSegments(
768 void smoothAutoSlopesForSegments(
773 void smoothAutoSlopes();
778 void smoothAutoSlopes(
fpreal global_time,
fpreal delta = -1,
bool value_changed =
true );
784 fpreal smoothAutoSlopesMaxDelta(
787 bool value_changed)
const;
790 void setLayerScope(
bool on_off);
791 bool isLayerScoped()
const;
797 void putChFullKey(
fpreal gtime,
CH_FullKey const& key,
bool accel_ratios =
true );
815 bool isSimpleChannel()
const;
826 void clear(
bool clear_defaults);
830 void ensureEndSegmentCreated();
831 void updateEndSegment();
832 void destroyEndSegment();
834 bool isTwoSegChannelTimeDep()
const;
836 template <
typename T>
837 bool isTimeDependentSlowImpl(
int thread)
const;
845 void moveKeyInternal(
fpreal old_gtime,
fpreal new_gtime,
853 void splitSegment(
fpreal gtime,
bool accel_ratio =
true,
854 bool skip_key_init =
false);
863 void deleteSegment(
unsigned idx);
865 int getNDisableSegments()
const
866 {
return myDisableSegments.entries(); }
867 CH_Segment *getDisableSegment(
unsigned idx)
const
869 return (idx < myDisableSegments.entries()) ?
870 myDisableSegments(idx) : 0;
877 int getDisableSegmentIndex(
fpreal ltime,
bool closest_prev)
const;
881 return (myDisableSegments.entries() > 0) ?
882 myDisableSegments(0) : 0;
886 return (myDisableSegments.entries() > 0)
887 ? myDisableSegments(myDisableSegments.entries()-1)
898 void removeDisableSegment(
int idx);
901 void deleteDisableSegment(
int idx);
903 void setPending(
bool on_off,
fpreal ltime );
904 void updatePendingStateToManager();
908 int isCooking()
const
912 void setCooking(
bool on_off)
918 void adjustSegments(
int begin_i,
int end_i,
922 CH_Segment *getFirstSegment(
bool no_disabling )
const;
923 CH_Segment *getLastSegment(
bool no_disabling )
const;
924 CH_Segment *getEndSegment(
bool no_disabling )
const;
927 enum chGetOrSampleReturn
929 Sampled, Get, FirstLast
931 chGetOrSampleReturn getOrSampleKey(
fpreal ltime,
CH_Key &key,
bool accel_ratio,
int thread );
942 bool setAllKeys(
fpreal *new_key_values,
int num_keys,
944 bool smooth_slopes,
bool notify);
977 unsigned char myFlags;
984 bool mySnapshotCleared;
993 if( idx<mySegments.entries() )
994 return mySegments(idx);
995 if( idx==(
unsigned)-1 || idx==mySegments.entries() )
997 UT_ASSERT(myEndSegment || mySegments.entries() == 0);
1007 return myEndSegment ? 1 + mySegments.
entries() : 0;
1013 return mySegments.
isEmpty() && !myEndSegment;
1026 if( idx == mySegments.
entries() )
1028 segp = myEndSegment;
1047 return myName ==
"rx" || myName ==
"ry" || myName ==
"rz";
1056 : myChannel(nullptr)
1079 SYSisLessOrEqual(lt, myRange.
max, myTol)
1080 : SYSisLess(lt, myRange.
max, myTol));
1088 SYSisGreaterOrEqual(lt, myRange.
min, myTol)
1089 : SYSisGreater(lt, myRange.
min, myTol));
1094 return (
unsigned)myI;
1099 return *(myChannel->
getSegment((
unsigned)myI));
1113 const bool ascending)
1132 if (SYSisLess(lt, myRange.
min, myTol))
1137 if (SYSisLessOrEqual(lt, myRange.
min, myTol))
1156 if (SYSisGreater(lt, myRange.
max, myTol))
1161 if (SYSisGreaterOrEqual(lt, myRange.
max, myTol))
1318 t1 = eval_channel->
getEnd();
1369 return isTwoSegChannelTimeDep();
1378 static inline size_t
1388 ::memcpy(buffer, s.
c_str(), len);
1393 #endif // __CH_Channel_h__
const UT_StringHolder & getAlias() const
Iterator over an interval.
CH_ExprLanguage myRevExprLanguage
fpreal localTime(fpreal t) const
CE_API bool evaluate(const CE_OSDRefinement &topo, const CE_OSDEvaluator &eval, const cl::Buffer &coarse, const CE_OSDPatchCoords &patch_coords, const CE_FloatArray *refined_data, cl::Buffer &out, cl::Buffer *du, cl::Buffer *dv)
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
void setDefaultValue(fpreal dv)
#define UT_NON_COPYABLE(CLASS)
Define deleted copy constructor and assignment operator inside a class.
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
PcpNodeRef_ChildrenIterator begin(const PcpNodeRef::child_const_range &r)
Support for range-based for loops for PcpNodeRef children ranges.
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
CH_Segment * putFullKey(fpreal gtime, CH_FullKey const &key, bool accel_ratios=true, bool apply_auto_slope=true)
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.