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 .

Access

RangeData data is typically accessed from a LodObject 。见 LodObject Manual .

// This example reads the range data from the given LOD object.
GeData rangeData; if (!lodObject-> GetParameter ( LOD_BAR , rangeData, DESCFLAGS_GET::NONE )) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION );
CustomDataType * const customData = rangeData. GetCustomDataType ( CUSTOMDATATYPE_RANGE ); RangeData * const rangeCustomData = static_cast< RangeData * > (customData); if (rangeCustomData == nullptr ) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION ); const Float currentValue = rangeCustomData-> GetCurrentValue (); ApplicationOutput ( "Value: " + String::FloatToString (currentValue));

Allocation/Deallocation

RangeData objects are created with the usual tools, see Entity Creation and Destruction Manual (Classic) .

A RangeData object must be initialized:

// This example configures the given LOD object and defines the // number of manual groups using the RangeData data.

// 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 :

// This example sets the current, user defined value of the range slider.

// 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 );

Knots

Multiple knots can be added to a RangeData object. These knots define the borders of the ranges.

// This example clears the given RangeData and // adds two new knots.

// clear rangeCustomData-> 重置 ();

// add knots rangeCustomData-> AddValue (0.33); rangeCustomData-> AddValue (0.66);

// set selection rangeCustomData-> SetSelectedKnot (0);

A single knot can be selected:

// This example deletes the currently selected knot. const Int knotIndex = rangeCustomData-> GetSelectedKnot (); rangeCustomData-> DeleteKnot (knotIndex);

Ranges

Value ranges are defined as the space confined by knots:

// This example sets the color of the range containing the current value.

// 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);

Color Modes

The ranges between knots can be colored in different ways:

// This example assigns a new color to each range.

// 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); }

RangePair

The dimensions of a range are stored with a RangePair object:

The RangePair class includes:

// This example sets the current value to the center // of the current range.

// 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);

延伸阅读

String::FloatToString
static String FloatToString(Float32 v, Int32 vvk=-1, Int32 nnk=-3)
定义: c4d_string.h:529
RangeData::GetCurrentValue
Float GetCurrentValue() const
Int
maxon::Int Int
定义: ge_sys_math.h:62
GeData::SetCustomDataType
void SetCustomDataType(Int32 datatype, const CustomDataType &v)
定义: c4d_gedata.h:664
RangeData
定义: customgui_range.h:145
LOD_CRITERIA_MANUAL_SLIDER
@ LOD_CRITERIA_MANUAL_SLIDER
定义: olod.h:29
RangeData::AddValue
Bool AddValue(Float value)
LOD_CRITERIA
@ LOD_CRITERIA
定义: olod.h:7
Float
maxon::Float Float
定义: ge_sys_math.h:64
LOD_CRITERIA_SCREEN_H
@ LOD_CRITERIA_SCREEN_H
定义: olod.h:30
MAXON_SOURCE_LOCATION
#define MAXON_SOURCE_LOCATION
定义: memoryallocationbase.h:66
HSVToRGB
Vector HSVToRGB(const Vector &col)
DESCFLAGS_SET::NONE
@ NONE
None.
RangeData::SetSelectedKnot
void SetSelectedKnot(Int knotIndex)
RangeData::GetSelectedKnot
Int GetSelectedKnot() const
RangeData::SetCurrentValue
void SetCurrentValue(Float value)
RangeData::SetColorMode
void SetColorMode(Bool perRange)
RangePair::GetCenter
Float GetCenter() const
定义: customgui_range.h:131
C4DAtom::SetParameter
Bool SetParameter(const DescID &id, const GeData &t_data, DESCFLAGS_SET flags)
maxon::Vec3< maxon::Float64, 1 >
RangeData::Init
Bool Init(Int rangeNumber)
CUSTOMDATATYPE_RANGE
static const Int32 CUSTOMDATATYPE_RANGE
RangeData ID.
定义: customgui_range.h:23
RangeData::SetRandomColorMode
void SetRandomColorMode(Bool random)
RangeData::GetRangeIndex
Int GetRangeIndex(Float value) const
GeData
定义: c4d_gedata.h:82
RangePair
定义: customgui_range.h:84
ApplicationOutput
#define ApplicationOutput(formatString,...)
定义: debugdiagnostics.h:207
RangeData::DeleteKnot
void DeleteKnot(Int knotIndex)
CustomDataType
Base class for custom data types.
定义: c4d_customdatatype.h:50
AutoAlloc
定义: ge_autoptr.h:36
RangeData::SetRangeColor
void SetRangeColor(Int index, const Vector &color)
DESCFLAGS_GET::NONE
@ NONE
None.
GeData::GetCustomDataType
CustomDataType * GetCustomDataType(Int32 datatype) const
定义: c4d_gedata.h:507
LOD_MODE
@ LOD_MODE
定义: olod.h:6
RangeData::Reset
void Reset(Bool invalidateObject=false)
LOD_BAR
@ LOD_BAR
定义: olod.h:8
LOD_MODE_MANUAL_GROUPS
@ LOD_MODE_MANUAL_GROUPS
定义: olod.h:25
RangeData::GetRange
RangePair GetRange(Int index) const
C4DAtom::GetParameter
Bool GetParameter(const DescID &id, GeData &t_data, DESCFLAGS_GET flags)
RangeData::GetRangesCount
Int GetRangesCount() const

Copyright  © 2014-2025 乐数软件    

工业和信息化部: 粤ICP备14079481号-1