RangeData Manual
The
RangeData
stores data on ranges and on the current value within these ranges. It is typically used with the
LodObject
。
RangeData
class is defined in the
customgui_range.h
header file. The ID is
CUSTOMDATATYPE_RANGE
.
RangeData data is typically accessed from a LodObject 。见 LodObject Manual .
// This example reads the range data from the given LOD object.RangeData objects are created with the usual tools, see Entity Creation and Destruction Manual (Classic) .
A RangeData object must be initialized:
// create custom data AutoAlloc<RangeData> rangeCustomData; if (rangeCustomData == nullptr ) return maxon::OutOfMemoryError( MAXON_SOURCE_LOCATION );
// configure LodObject lodObject-> SetParameter ( LOD_MODE , LOD_MODE_MANUAL_GROUPS , DESCFLAGS_SET::NONE ); lodObject-> SetParameter ( LOD_CRITERIA , LOD_CRITERIA_SCREEN_H , DESCFLAGS_SET::NONE );
// configure range data if (!rangeCustomData-> Init (10)) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION );
// store to LodObject GeData rangeGeData; rangeGeData. SetCustomDataType ( CUSTOMDATATYPE_RANGE , rangeCustomData); lodObject-> SetParameter ( LOD_BAR , rangeGeData, DESCFLAGS_SET::NONE );
A RangeData stores a value between 0.0 and 1.0 :
// get range data GeData rangeData; lodObject-> GetParameter ( LOD_BAR , rangeData, DESCFLAGS_GET::NONE ); CustomDataType * const customData = rangeData. GetCustomDataType ( CUSTOMDATATYPE_RANGE ); RangeData * const rangeCustomData = static_cast< RangeData * > (customData); if (rangeCustomData == nullptr ) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION );
// User LOD Value lodObject-> SetParameter ( LOD_CRITERIA , LOD_CRITERIA_MANUAL_SLIDER , DESCFLAGS_SET::NONE );
// set value rangeCustomData-> SetCurrentValue (0.5); lodObject-> SetParameter ( LOD_BAR , rangeData, DESCFLAGS_SET::NONE );
Multiple knots can be added to a RangeData object. These knots define the borders of the ranges.
// clear rangeCustomData-> 重置 ();
// add knots rangeCustomData-> AddValue (0.33); rangeCustomData-> AddValue (0.66);
// set selection rangeCustomData-> SetSelectedKnot (0);
A single knot can be selected:
Value ranges are defined as the space confined by knots:
// get current range const Float currentValue = rangeCustomData-> GetCurrentValue (); const Int currentRange = rangeCustomData-> GetRangeIndex (currentValue);
// set color const 向量 color { 1.0, 0.0, 0.0 }; rangeCustomData-> SetRangeColor (currentRange, color);
The ranges between knots can be colored in different ways:
// set mode rangeCustomData-> SetRandomColorMode ( false ); rangeCustomData-> SetColorMode ( true );
// get number of ranges const Int rangeCount = rangeCustomData-> GetRangesCount (); const Float colorStep = 1.0 / Float (rangeCount);
// set color of each range for ( Int i = 0; i < rangeCount; ++i) { const 向量 hsv { Float (i) * colorStep, 1.0, 1.0 }; const 向量 rgb = HSVToRGB (hsv); rangeCustomData-> SetRangeColor (i, rgb); }
The dimensions of a range are stored with a RangePair object:
The RangePair class includes:
// get current value and range const Float currentValue = rangeCustomData-> GetCurrentValue (); const Int currentRange = rangeCustomData-> GetRangeIndex (currentValue);
// get range center const RangePair rData = rangeCustomData-> GetRange (currentRange); const Float centerValue = rData. GetCenter ();
// set value rangeCustomData-> SetCurrentValue (centerValue);