HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CL_SimpleChannel Class Reference

#include <CL_SimpleChannel.h>

Public Member Functions

 CL_SimpleChannel ()
 
 CL_SimpleChannel (fpreal start, int num_segments, fpreal length, CL_ChannelBehavior left_type, CL_ChannelBehavior right_type, fpreal default_value, fpreal default_slope)
 
 CL_SimpleChannel (fpreal start, int num_segments, fpreal length, CL_ChannelBehavior left_type, CL_ChannelBehavior right_type, fpreal default_value, fpreal default_slope, fpreal tolerance)
 
 ~CL_SimpleChannel ()=default
 
 CL_SimpleChannel (const CL_SimpleChannel &other)=default
 
 CL_SimpleChannel (CL_SimpleChannel &&other)=default
 
CL_SimpleChanneloperator= (const CL_SimpleChannel &other)=default
 
CL_SimpleChanneloperator= (CL_SimpleChannel &&other)=default
 
bool canEval () const
 
fpreal eval (fpreal gtime) const
 
fpreal eval (fpreal gtime, int &segment_idx_hint) const
 
fpreal eval (const CL_SimpleSegment &seg, fpreal ltime) const
 
fpreal evalSlope (fpreal gtime) const
 
fpreal evalSlope (const CL_SimpleSegment &seg, fpreal ltime) const
 
fpreal evalAccel (fpreal gtime) const
 
fpreal evalAccel (const CL_SimpleSegment &seg, fpreal ltime) const
 
bool isAtHardKey (fpreal gtime) const
 
int getSegmentIdx (fpreal ltime) const
 
CL_SimpleSegmentgetSegment (int index)
 
const CL_SimpleSegmentgetSegment (int index) const
 
const UT_Array
< CL_SimpleSegment > & 
getSegments () const
 
UT_StringHolder getSegmentExpression (int index) const
 
const UT_Array< UT_StringHolder > & getSegmentExpressions () const
 
void setSegmentExpression (int index, const UT_StringHolder &expr)
 
int getSegmentInSlopeAuto (int index) const
 
int getSegmentOutSlopeAuto (int index) const
 
void setSegmentInSlopeAuto (int index, bool value)
 
void setSegmentOutSlopeAuto (int index, bool value)
 
void setSegmentInSlope (int index, fpreal slope)
 
void setSegmentOutSlope (int index, fpreal slope)
 
void setSegmentInAccel (int index, fpreal accel, bool ratio=false)
 
void setSegmentOutAccel (int index, fpreal accel, bool ratio=false)
 
void setSegmentType (int index, CL_SimpleSegmentType type)
 
CL_SimpleSegmentType getSegmentType (int index) const
 
bool insertKeyFrame (fpreal global_time, bool auto_slope=true)
 
bool destroyKeyFrame (fpreal global_time)
 
bool destroyKeyFrames (fpreal gtime_start, fpreal gtime_end)
 
bool destroySegments (int start_idx, int end_idx)
 
bool setKeyValue (fpreal gtime, fpreal value, CL_KeyHalf half=CL_KeyHalf::InOut)
 
bool setKeySlope (fpreal gtime, fpreal slope, CL_KeyHalf half=CL_KeyHalf::InOut)
 
bool setKeyAccel (fpreal gtime, fpreal accel, CL_KeyHalf half=CL_KeyHalf::InOut)
 
fpreal getKeyValue (fpreal gtime, CL_KeyHalf half=CL_KeyHalf::InOut) const
 
fpreal getKeySlope (fpreal gtime, CL_KeyHalf half=CL_KeyHalf::InOut) const
 
fpreal getKeyAccel (fpreal gtime, CL_KeyHalf half=CL_KeyHalf::InOut) const
 
bool setKeyAutoSlope (fpreal gtime, bool auto_slope, CL_KeyHalf half=CL_KeyHalf::InOut)
 
bool setRawValues (fpreal from, fpreal to, fpreal *data, int num_samples, bool auto_slope=true)
 Sets data evenly spaced between from and to. More...
 
bool setRawValues (fpreal *times, fpreal *data, int num_samples)
 Sets data at the specified times. More...
 
void clear ()
 clears the channel, erasing all segments More...
 
void setDefaultValue (fpreal value)
 
void setPreValue (fpreal value)
 
void setPreSlope (fpreal slope)
 
void setPreType (CL_ChannelBehavior type)
 
void setPostValue (fpreal value)
 
void setPostSlope (fpreal slope)
 
void setPostType (CL_ChannelBehavior type)
 
fpreal getDefaultValue () const
 
fpreal getPreValue () const
 
fpreal getPreSlope () const
 
CL_ChannelBehavior getPreType () const
 
fpreal getPostValue () const
 
fpreal getPostSlope () const
 
CL_ChannelBehavior getPostType () const
 
fpreal getTolerance () const
 
void setTolerance (fpreal tolerance)
 
fpreal localTime (fpreal t) const
 
fpreal globalTime (fpreal t) const
 
fpreal getStart () const
 
fpreal getEnd () const
 
fpreal getLength () const
 
void setStart (fpreal start)
 
int getNSegments () const
 Returns the number of segments including the end segment. More...
 
UT_Array< fprealgetKeyTimes () const
 
UT_Array< fprealgetKeyValues (CL_KeyHalf half=CL_KeyHalf::InOut) const
 
UT_Array< fprealgetKeySlopes (CL_KeyHalf half=CL_KeyHalf::InOut) const
 
UT_Array< fprealgetKeyAccels (CL_KeyHalf half=CL_KeyHalf::InOut) const
 
bool getKeyTimeRange (fpreal &start, fpreal &end) const
 
void setKeys (const UT_Array< fpreal > *values=nullptr, const UT_Array< fpreal > *slopes=nullptr, const UT_Array< fpreal > *accels=nullptr, CL_KeyHalf half=CL_KeyHalf::InOut)
 
void setKeyValues (const UT_Array< fpreal > &values, CL_KeyHalf half=CL_KeyHalf::InOut)
 
void setKeySlopes (const UT_Array< fpreal > &slopes, CL_KeyHalf half=CL_KeyHalf::InOut)
 
void setKeyAccels (const UT_Array< fpreal > &accels, CL_KeyHalf half=CL_KeyHalf::InOut)
 
bool getSurroundingSegs (fpreal gtime, CL_SimpleSegment *&left, CL_SimpleSegment *&right)
 
bool getSurroundingSegs (fpreal gtime, const CL_SimpleSegment *&left, const CL_SimpleSegment *&right) const
 
bool moveKeysWithDeltas (const UT_IntArray &indices, const UT_Array< fpreal > &time_offsets)
 
void moveKeysWithDeltas (const UT_Array< fpreal > &key_times, const UT_Array< fpreal > &time_offsets, const UT_Array< fpreal > &value_offsets)
 
void smoothAutoSlopesForSegments (UT_RLEBitArray &slope_flags, bool force=false, fpreal max_delta=-1)
 
void smoothAutoSlopes (bool force=false)
 
void trimStart (float gtime)
 
void trimEnd (float gtime)
 

Static Public Member Functions

static void setChannelTolerance (fpreal tol)
 
static void setDefaultSegmentType (CL_SimpleSegmentType type)
 Set the segment type used for the first key in a channel. More...
 
static void setDefaultSegmentSplitType (CL_SimpleSegmentType type)
 
static void setAutoSplit (bool onoff)
 
static fpreal getChannelTolerance ()
 
static CL_SimpleSegmentType getDefaultSegmentType ()
 
static CL_SimpleSegmentType getDefaultSegmentSplitType ()
 
static bool getAutoSplit ()
 

Detailed Description

A specialized channel for fast evaluation. Should be created from an existing CH_Channel using CH_Channel->asSimpleChannel(). Can be copied using the copy constructor. Doesn't store the in/out value/slope/accel directly. It stores precomputed bezier coefficient to avoid doing the conversion at each evaluation. Also uses UT_BezierRootFinder with precomputed coefficients to speed up CL_Cubic::reverseEvalP.

Definition at line 251 of file CL_SimpleChannel.h.

Constructor & Destructor Documentation

CL_SimpleChannel::CL_SimpleChannel ( )
CL_SimpleChannel::CL_SimpleChannel ( fpreal  start,
int  num_segments,
fpreal  length,
CL_ChannelBehavior  left_type,
CL_ChannelBehavior  right_type,
fpreal  default_value,
fpreal  default_slope 
)
CL_SimpleChannel::CL_SimpleChannel ( fpreal  start,
int  num_segments,
fpreal  length,
CL_ChannelBehavior  left_type,
CL_ChannelBehavior  right_type,
fpreal  default_value,
fpreal  default_slope,
fpreal  tolerance 
)
CL_SimpleChannel::~CL_SimpleChannel ( )
default
CL_SimpleChannel::CL_SimpleChannel ( const CL_SimpleChannel other)
default
CL_SimpleChannel::CL_SimpleChannel ( CL_SimpleChannel &&  other)
default

Member Function Documentation

bool CL_SimpleChannel::canEval ( ) const

Simple channels can only evaluate certain types of segments. This scans the channel to see if there is anything that can't be eval'ed and returns true if everything is safe for eval()

void CL_SimpleChannel::clear ( )

clears the channel, erasing all segments

bool CL_SimpleChannel::destroyKeyFrame ( fpreal  global_time)

Destroy the key frame at the given global time Returns true if a key was deleted, or false if there was no key at this time

bool CL_SimpleChannel::destroyKeyFrames ( fpreal  gtime_start,
fpreal  gtime_end 
)

Destroys all key frames in the given global time range, inclusive. Returns true if a key was deleted, or false if there were no keys in this range

bool CL_SimpleChannel::destroySegments ( int  start_idx,
int  end_idx 
)

Destroys all segments from start_idx to end_idx. Returns true if a key was deleted, or false if there were no keys in this range This keeps all the values/times in sync. start_idx and end_idx are inclusive end_idx of -1 means the last segment.

fpreal CL_SimpleChannel::eval ( fpreal  gtime) const
fpreal CL_SimpleChannel::eval ( fpreal  gtime,
int segment_idx_hint 
) const
fpreal CL_SimpleChannel::eval ( const CL_SimpleSegment seg,
fpreal  ltime 
) const
fpreal CL_SimpleChannel::evalAccel ( fpreal  gtime) const
fpreal CL_SimpleChannel::evalAccel ( const CL_SimpleSegment seg,
fpreal  ltime 
) const
fpreal CL_SimpleChannel::evalSlope ( fpreal  gtime) const
fpreal CL_SimpleChannel::evalSlope ( const CL_SimpleSegment seg,
fpreal  ltime 
) const
static bool CL_SimpleChannel::getAutoSplit ( )
inlinestatic

Definition at line 538 of file CL_SimpleChannel.h.

static fpreal CL_SimpleChannel::getChannelTolerance ( )
inlinestatic

Definition at line 530 of file CL_SimpleChannel.h.

static CL_SimpleSegmentType CL_SimpleChannel::getDefaultSegmentSplitType ( )
inlinestatic

Definition at line 535 of file CL_SimpleChannel.h.

static CL_SimpleSegmentType CL_SimpleChannel::getDefaultSegmentType ( )
inlinestatic

Definition at line 532 of file CL_SimpleChannel.h.

fpreal CL_SimpleChannel::getDefaultValue ( ) const
inline

Definition at line 429 of file CL_SimpleChannel.h.

fpreal CL_SimpleChannel::getEnd ( ) const
inline

Definition at line 453 of file CL_SimpleChannel.h.

fpreal CL_SimpleChannel::getKeyAccel ( fpreal  gtime,
CL_KeyHalf  half = CL_KeyHalf::InOut 
) const
UT_Array<fpreal> CL_SimpleChannel::getKeyAccels ( CL_KeyHalf  half = CL_KeyHalf::InOut) const
fpreal CL_SimpleChannel::getKeySlope ( fpreal  gtime,
CL_KeyHalf  half = CL_KeyHalf::InOut 
) const
UT_Array<fpreal> CL_SimpleChannel::getKeySlopes ( CL_KeyHalf  half = CL_KeyHalf::InOut) const
bool CL_SimpleChannel::getKeyTimeRange ( fpreal start,
fpreal end 
) const

Returns the start and end global times of the first and last keys. This is different than myStart and myStart+myLength because myStart is set to 0.0 almost all the time. Returns true and a valid range if there is at least one key. Returns false if there is no key and start and end get the myStart value.

UT_Array<fpreal> CL_SimpleChannel::getKeyTimes ( ) const
fpreal CL_SimpleChannel::getKeyValue ( fpreal  gtime,
CL_KeyHalf  half = CL_KeyHalf::InOut 
) const
UT_Array<fpreal> CL_SimpleChannel::getKeyValues ( CL_KeyHalf  half = CL_KeyHalf::InOut) const
fpreal CL_SimpleChannel::getLength ( ) const
inline

Definition at line 454 of file CL_SimpleChannel.h.

int CL_SimpleChannel::getNSegments ( ) const
inline

Returns the number of segments including the end segment.

Definition at line 458 of file CL_SimpleChannel.h.

fpreal CL_SimpleChannel::getPostSlope ( ) const
inline

Definition at line 436 of file CL_SimpleChannel.h.

CL_ChannelBehavior CL_SimpleChannel::getPostType ( ) const
inline

Definition at line 437 of file CL_SimpleChannel.h.

fpreal CL_SimpleChannel::getPostValue ( ) const
inline

Definition at line 435 of file CL_SimpleChannel.h.

fpreal CL_SimpleChannel::getPreSlope ( ) const
inline

Definition at line 432 of file CL_SimpleChannel.h.

CL_ChannelBehavior CL_SimpleChannel::getPreType ( ) const
inline

Definition at line 433 of file CL_SimpleChannel.h.

fpreal CL_SimpleChannel::getPreValue ( ) const
inline

Definition at line 431 of file CL_SimpleChannel.h.

CL_SimpleSegment& CL_SimpleChannel::getSegment ( int  index)
inline

Definition at line 312 of file CL_SimpleChannel.h.

const CL_SimpleSegment& CL_SimpleChannel::getSegment ( int  index) const
inline

Definition at line 313 of file CL_SimpleChannel.h.

UT_StringHolder CL_SimpleChannel::getSegmentExpression ( int  index) const
inline

Definition at line 316 of file CL_SimpleChannel.h.

const UT_Array<UT_StringHolder>& CL_SimpleChannel::getSegmentExpressions ( ) const
inline

Definition at line 317 of file CL_SimpleChannel.h.

int CL_SimpleChannel::getSegmentIdx ( fpreal  ltime) const
int CL_SimpleChannel::getSegmentInSlopeAuto ( int  index) const
inline

Definition at line 321 of file CL_SimpleChannel.h.

int CL_SimpleChannel::getSegmentOutSlopeAuto ( int  index) const
inline

Definition at line 323 of file CL_SimpleChannel.h.

const UT_Array<CL_SimpleSegment>& CL_SimpleChannel::getSegments ( ) const
inline

Definition at line 314 of file CL_SimpleChannel.h.

CL_SimpleSegmentType CL_SimpleChannel::getSegmentType ( int  index) const
fpreal CL_SimpleChannel::getStart ( ) const
inline

Definition at line 452 of file CL_SimpleChannel.h.

bool CL_SimpleChannel::getSurroundingSegs ( fpreal  gtime,
CL_SimpleSegment *&  left,
CL_SimpleSegment *&  right 
)
bool CL_SimpleChannel::getSurroundingSegs ( fpreal  gtime,
const CL_SimpleSegment *&  left,
const CL_SimpleSegment *&  right 
) const
fpreal CL_SimpleChannel::getTolerance ( ) const
inline

Definition at line 439 of file CL_SimpleChannel.h.

fpreal CL_SimpleChannel::globalTime ( fpreal  t) const
inline

Definition at line 450 of file CL_SimpleChannel.h.

bool CL_SimpleChannel::insertKeyFrame ( fpreal  global_time,
bool  auto_slope = true 
)

Insert a key frame at the given global time. Returns true if a key frame was added, or false if it failed, or if there was already a key frame at the given time.

bool CL_SimpleChannel::isAtHardKey ( fpreal  gtime) const
fpreal CL_SimpleChannel::localTime ( fpreal  t) const
inline

Definition at line 447 of file CL_SimpleChannel.h.

bool CL_SimpleChannel::moveKeysWithDeltas ( const UT_IntArray indices,
const UT_Array< fpreal > &  time_offsets 
)

Shift the specified keys by the given time offsets. Time offsets must either match the size of indices, or be an array of 1 element to shift all keys by the same offset.

void CL_SimpleChannel::moveKeysWithDeltas ( const UT_Array< fpreal > &  key_times,
const UT_Array< fpreal > &  time_offsets,
const UT_Array< fpreal > &  value_offsets 
)

Move a list of keys using a list of time offset and value offsets. Do the same as CHmoveKeysWithDeltas for CH_Channel

CL_SimpleChannel& CL_SimpleChannel::operator= ( const CL_SimpleChannel other)
default
CL_SimpleChannel& CL_SimpleChannel::operator= ( CL_SimpleChannel &&  other)
default
static void CL_SimpleChannel::setAutoSplit ( bool  onoff)
static

Set the segment type behaviour when splitting a segment. If true, The type of the split segment will be applied to the new segment, otherwise, theDefaultSplitSegmentType will be used

static void CL_SimpleChannel::setChannelTolerance ( fpreal  tol)
inlinestatic

Definition at line 519 of file CL_SimpleChannel.h.

static void CL_SimpleChannel::setDefaultSegmentSplitType ( CL_SimpleSegmentType  type)
static

Set the segment type used when splitting a segment if auto split is false

static void CL_SimpleChannel::setDefaultSegmentType ( CL_SimpleSegmentType  type)
static

Set the segment type used for the first key in a channel.

void CL_SimpleChannel::setDefaultValue ( fpreal  value)
inline

Set the default value. This is the value returned when evaluating an empty channel.

Definition at line 419 of file CL_SimpleChannel.h.

bool CL_SimpleChannel::setKeyAccel ( fpreal  gtime,
fpreal  accel,
CL_KeyHalf  half = CL_KeyHalf::InOut 
)

Set the accel of the key at the given time

Parameters
gtimeGlobal time of the key to change
accelNew value to set for the key
halfWhich half of the key to set. Defaults to both (tied)
Returns
true if successful, or false if there is no key at the given time
void CL_SimpleChannel::setKeyAccels ( const UT_Array< fpreal > &  accels,
CL_KeyHalf  half = CL_KeyHalf::InOut 
)
bool CL_SimpleChannel::setKeyAutoSlope ( fpreal  gtime,
bool  auto_slope,
CL_KeyHalf  half = CL_KeyHalf::InOut 
)

Set the auto_slope property of the key at the given time

Parameters
gtimeGlobal time of the key to change
auto_slopeNew auto_slope to set for the key
halfWhich half of the key to set. Defaults to both (tied)
Returns
true if successful, or false if there is no key at the given time
void CL_SimpleChannel::setKeys ( const UT_Array< fpreal > *  values = nullptr,
const UT_Array< fpreal > *  slopes = nullptr,
const UT_Array< fpreal > *  accels = nullptr,
CL_KeyHalf  half = CL_KeyHalf::InOut 
)
bool CL_SimpleChannel::setKeySlope ( fpreal  gtime,
fpreal  slope,
CL_KeyHalf  half = CL_KeyHalf::InOut 
)

Set the slope of the key at the given time

Parameters
gtimeGlobal time of the key to change
slopeNew slope to set for the key
halfWhich half of the key to set. Defaults to both (tied)
Returns
true if successful, or false if there is no key at the given time
void CL_SimpleChannel::setKeySlopes ( const UT_Array< fpreal > &  slopes,
CL_KeyHalf  half = CL_KeyHalf::InOut 
)
bool CL_SimpleChannel::setKeyValue ( fpreal  gtime,
fpreal  value,
CL_KeyHalf  half = CL_KeyHalf::InOut 
)

Set the value of the key at the given time

Parameters
gtimeGlobal time of the key to change
valueNew value to set for the key
halfWhich half of the key to set. Defaults to both (tied)
Returns
true if successful, or false if there is no key at the given time
void CL_SimpleChannel::setKeyValues ( const UT_Array< fpreal > &  values,
CL_KeyHalf  half = CL_KeyHalf::InOut 
)
void CL_SimpleChannel::setPostSlope ( fpreal  slope)
inline

Definition at line 426 of file CL_SimpleChannel.h.

void CL_SimpleChannel::setPostType ( CL_ChannelBehavior  type)
inline

Definition at line 427 of file CL_SimpleChannel.h.

void CL_SimpleChannel::setPostValue ( fpreal  value)
inline

Definition at line 425 of file CL_SimpleChannel.h.

void CL_SimpleChannel::setPreSlope ( fpreal  slope)
inline

Definition at line 422 of file CL_SimpleChannel.h.

void CL_SimpleChannel::setPreType ( CL_ChannelBehavior  type)
inline

Definition at line 423 of file CL_SimpleChannel.h.

void CL_SimpleChannel::setPreValue ( fpreal  value)
inline

Definition at line 421 of file CL_SimpleChannel.h.

bool CL_SimpleChannel::setRawValues ( fpreal  from,
fpreal  to,
fpreal data,
int  num_samples,
bool  auto_slope = true 
)

Sets data evenly spaced between from and to.

bool CL_SimpleChannel::setRawValues ( fpreal times,
fpreal data,
int  num_samples 
)

Sets data at the specified times.

void CL_SimpleChannel::setSegmentExpression ( int  index,
const UT_StringHolder expr 
)
inline

Definition at line 318 of file CL_SimpleChannel.h.

void CL_SimpleChannel::setSegmentInAccel ( int  index,
fpreal  accel,
bool  ratio = false 
)
void CL_SimpleChannel::setSegmentInSlope ( int  index,
fpreal  slope 
)
void CL_SimpleChannel::setSegmentInSlopeAuto ( int  index,
bool  value 
)
inline

Definition at line 326 of file CL_SimpleChannel.h.

void CL_SimpleChannel::setSegmentOutAccel ( int  index,
fpreal  accel,
bool  ratio = false 
)
void CL_SimpleChannel::setSegmentOutSlope ( int  index,
fpreal  slope 
)
void CL_SimpleChannel::setSegmentOutSlopeAuto ( int  index,
bool  value 
)
inline

Definition at line 328 of file CL_SimpleChannel.h.

void CL_SimpleChannel::setSegmentType ( int  index,
CL_SimpleSegmentType  type 
)

Set the type of the segment Note that this differs from the setSegmentExpression, which is used only for custom expressions.

Parameters
indexThe index of the segment to modify
typeThe type to change the segment to.
void CL_SimpleChannel::setStart ( fpreal  start)
inline

Definition at line 455 of file CL_SimpleChannel.h.

void CL_SimpleChannel::setTolerance ( fpreal  tolerance)
inline

Definition at line 443 of file CL_SimpleChannel.h.

void CL_SimpleChannel::smoothAutoSlopes ( bool  force = false)
void CL_SimpleChannel::smoothAutoSlopesForSegments ( UT_RLEBitArray slope_flags,
bool  force = false,
fpreal  max_delta = -1 
)
void CL_SimpleChannel::trimEnd ( float  gtime)

inserts a key at gtime and destroys all keys after it. does nothing if gtime is after the channel end.

void CL_SimpleChannel::trimStart ( float  gtime)

inserts a key at gtime and destroys all keys before it. does nothing if gtime is before the channel start.


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