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 );
331 void saveKeyFrameForUndo(
fpreal global_t );
344 bool set_pending =
false,
345 bool commit_keys =
true,
346 bool propagate =
true);
348 bool set_pending =
false,
349 bool commit_keys =
true,
350 bool propagate =
true);
353 bool set_pending =
false,
354 bool commit_keys =
true,
355 bool propagate =
true);
363 bool error_frames_only);
369 bool error_frames_only);
373 int minframe,
int maxframe);
377 const char *getExpression(
fpreal gtime )
const;
378 bool changeExpression(
fpreal gtime,
381 bool convert_accels );
394 void clearSegments();
401 void deleteKeys(
const UT_Array<int> &ascending_sorted_key_indices);
418 bool apply_auto_slope =
true);
442 SnapType
type=SNAP_SNAP,
443 std::ostream *os=
nullptr );
446 void scroll (
fpreal new_start,
bool update =
true);
450 bool increaseKeyValues(
fpreal delta );
453 bool isAllDisabled()
const;
454 bool isAllEnabled()
const;
455 bool isDisabled(
fpreal gtime)
const;
456 void disableAll(
fpreal gtime);
464 {
return myPending; }
465 bool isPending(
fpreal gtime)
const;
466 bool isPendingLocal(
fpreal ltime)
const;
468 void updatePending(
fpreal gtime );
470 {
return globalTime(myPendingEvalTime); }
473 {
return myPendingHold; }
474 void setPendingHold(
bool state );
477 void save(std::ostream &os,
bool binary,
bool compiled,
478 bool pending_state)
const;
479 template <
typename FPREAL_TYPE>
481 void display()
const;
482 void displayAsKeys()
const;
488 { myDefString = dv; }
518 void setLocked(
bool f);
522 void setChanged(
bool on,
524 void dirtyExprCache();
529 return myParent->canAccessChannel(mask,
this);
546 void unresolveLocalVars(
int thread);
549 void buildOpDependencies(
void *ref_id,
int thread);
550 void changeOpRef(
const char *new_fullpath,
551 const char *old_fullpath,
553 const char *chan_name,
554 const char *old_chan_name,
558 void cook(
int state);
565 void setScope(
bool on_off);
566 bool isScoped()
const;
575 bool no_disabling,
bool use_cache,
int thread);
580 fpreal localtime,
bool extend,
583 int findString(
const char *str,
bool fullword,
584 bool usewildcards)
const;
585 int changeString(
const char *from,
const char *to,
586 bool fullword,
bool update ,
593 static inline void getGlueTime(
596 static inline void getGlueSlope(
603 return getManager()->evalContext(thread).segment();
607 return getManager()->evalContext(thread).segment();
623 int match(
const char *
pattern)
const;
648 bool preserve_extrema,
650 bool delete_old_segments =
false);
657 void refit(
fpreal tolerance,
bool preserve_extrema );
658 void refit(
fpreal tolerance,
bool preserve_extrema,
660 bool delete_old_segments);
675 bool setKeys(
fpreal *new_key_values,
int num_keys,
677 bool smooth_slopes =
true,
678 bool clear =
false,
bool notify =
true);
681 bool isEmpty()
const;
682 int getNSegments()
const;
683 int getNKeys()
const;
684 int getNKeysBefore(
fpreal gtime )
const;
685 int getNKeysBeforeOrAt(
fpreal gtime )
const;
687 fpreal getKeyTime(
unsigned idx )
const;
689 unsigned getSegmentIdx(
fpreal local_time)
const;
693 CH_Segment *getNextSegment(
unsigned idx)
const;
694 CH_Segment *getPrevSegment(
unsigned idx)
const;
702 ?
nullptr : getSegment( (
unsigned)0 );
712 ?
nullptr : getSegment( (
unsigned)mySegments.entries()-1 );
715 int64 getMemoryUsage(
bool inclusive)
const;
720 bool adjust_and_update =
true);
722 bool getHaveCompiledExpressions()
const;
725 bool verify(
bool verify_tied_values);
732 void undoSnapshot(
CH_Channel *previous,
bool previous_snapshot_cleared);
735 bool clearSnapshot();
746 void smoothAutoSlopesForSegments(
751 void smoothAutoSlopes();
756 void smoothAutoSlopes(
fpreal global_time,
fpreal delta = -1,
bool value_changed =
true );
761 void setLayerScope(
bool on_off);
762 bool isLayerScoped()
const;
768 void putChFullKey(
fpreal gtime,
CH_FullKey const& key,
bool accel_ratios =
true );
786 bool isSimpleChannel()
const;
797 void clear(
bool clear_defaults);
801 void ensureEndSegmentCreated();
802 void updateEndSegment();
803 void destroyEndSegment();
805 bool isTwoSegChannelTimeDep()
const;
807 template <
typename T>
808 bool isTimeDependentSlowImpl(
int thread)
const;
814 friend class CH_BatchModifyScope;
816 void moveKeyInternal(
fpreal old_gtime,
fpreal new_gtime,
817 CH_BatchModifyScope &scope);
818 void splitSegment(
fpreal gtime,
bool accel_ratio =
true);
819 void destroyKeyInternal(
unsigned seg_i, CH_BatchModifyScope &scope);
827 void deleteSegment(
unsigned idx);
829 int getNDisableSegments()
const
830 {
return myDisableSegments.entries(); }
831 CH_Segment *getDisableSegment(
unsigned idx)
const
833 return (idx < myDisableSegments.entries()) ?
834 myDisableSegments(idx) : 0;
841 int getDisableSegmentIndex(
fpreal ltime,
bool closest_prev)
const;
845 return (myDisableSegments.entries() > 0) ?
846 myDisableSegments(0) : 0;
850 return (myDisableSegments.entries() > 0)
851 ? myDisableSegments(myDisableSegments.entries()-1)
862 void removeDisableSegment(
int idx);
865 void deleteDisableSegment(
int idx);
867 void setPending(
bool on_off,
fpreal ltime );
868 void updatePendingStateToManager();
872 int isCooking()
const
876 void setCooking(
bool on_off)
882 void adjustSegments(
int begin_i,
int end_i,
886 CH_Segment *getFirstSegment(
bool no_disabling )
const;
887 CH_Segment *getLastSegment(
bool no_disabling )
const;
888 CH_Segment *getEndSegment(
bool no_disabling )
const;
891 enum chGetOrSampleReturn
893 Sampled, Get, FirstLast
895 chGetOrSampleReturn getOrSampleKey(
fpreal ltime,
CH_Key &key,
bool accel_ratio,
int thread );
906 bool setAllKeys(
fpreal *new_key_values,
int num_keys,
908 bool smooth_slopes,
bool notify);
941 unsigned char myFlags;
948 bool mySnapshotCleared;
957 if( idx<mySegments.entries() )
958 return mySegments(idx);
959 if( idx==(
unsigned)-1 || idx==mySegments.entries() )
961 UT_ASSERT(myEndSegment || mySegments.entries() == 0);
971 return myEndSegment ? 1 + mySegments.
entries() : 0;
977 return mySegments.
isEmpty() && !myEndSegment;
990 if( idx == mySegments.
entries() )
1011 return myName ==
"rx" || myName ==
"ry" || myName ==
"rz";
1020 : myChannel(nullptr)
1043 SYSisLessOrEqual(lt, myRange.
max, myTol)
1044 : SYSisLess(lt, myRange.
max, myTol));
1052 SYSisGreaterOrEqual(lt, myRange.
min, myTol)
1053 : SYSisGreater(lt, myRange.
min, myTol));
1058 return (
unsigned)myI;
1063 return *(myChannel->
getSegment((
unsigned)myI));
1077 const bool ascending)
1096 if (SYSisLess(lt, myRange.
min, myTol))
1101 if (SYSisLessOrEqual(lt, myRange.
min, myTol))
1120 if (SYSisGreater(lt, myRange.
max, myTol))
1125 if (SYSisGreaterOrEqual(lt, myRange.
max, myTol))
1282 t1 = eval_channel->
getEnd();
1333 return isTwoSegChannelTimeDep();
1342 static inline size_t
1352 ::memcpy(buffer, s.
c_str(), len);
1357 #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)
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
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.