TriState Manual

内容表

关于

Cinema 4D it is possible to select multiple scene elements at once. The Attribute Manager displays the parameters of all these selected objects. Only the parameters that are part of all selected objects are displayed. If the value of a given parameter is the same for all selected objects, this value is displayed in the Attribute Manager. But if the value of the parameter on the different objects is not the same a tristate is displayed instead, indicating that the values are not the same.

TriState is a utility class to make it easy to handle multiple parameter values and to display them using GeDialog gadgets. The TriState template class can handle Bool , Int32 , Float , 向量 , BaseTime and String values. Typically the TriState class is only relevant to create CustomGuiData / iCustomGui based custom GUI elements.

注意
TriState elements are only handled with GeDialog gadgets. Parameter descriptions ( 描述 elements) define the parameters of a C4DAtom based element and do not handle any TriState .
// This example gets the names of all selected objects in a GeDialog::InitValues() function. // The object names are stored in a TriState object. // This TriState object is used to display the names with a text field element.
BaseDocument * const doc = GetActiveDocument (); AutoAlloc<AtomArray> objects;

// check if both the BaseDocument and the AtomArray are available if (doc && objects) { // get selected objects doc-> GetActiveObjects (objects, GETACTIVEOBJECTFLAGS::NONE );

// store all names in the TriState object TriState<String> triState;

const Int32 count = objects-> GetCount (); for ( Int32 i = 0; i < count; ++i) { // get name const BaseList2D * const bl = static_cast< BaseList2D * > (objects-> GetIndex (i)); if (bl) { const String name = bl-> GetName (); // store triState. 添加 (name); } }

// the text field should display the value(s) stored in the TriState // if the string values are not the same the GUI element will display "Multiple Values" SetString(ID_OBJECTNAME, triState); }

Functionality

A TriState object stores multiple values:

The stored values can be accessed and analysed with:

// This example configures and uses a TriState object. TriState<Int32> triState; triState. 添加 (100); triState. 添加 (100);

// check if the TriState is not empty and if all values are the same const Bool isNotTriState = triState. GetTri () == false ; if (triState. HasChanged () && isNotTriState) ApplicationOutput ( "Everything is the same" );

// add a different value triState. 添加 (200);

// check again if (triState. GetTri ()) { ApplicationOutput ( "now tristate" _s); const Int32 value = triState. GetValue (); ApplicationOutput ( "Value: " + String::IntToString (value)); }

延伸阅读

BaseList2D
定义: c4d_baselist.h:2144
GetActiveDocument
BaseDocument * GetActiveDocument(void)
TriState
定义: c4d_gui.h:918
GETACTIVEOBJECTFLAGS::NONE
@ NONE
None.
AtomArray::GetCount
Int32 GetCount() const
定义: c4d_baselist.h:1619
TriState::Add
void Add(TYPE val)
定义: c4d_gui.h:964
TriState::GetTri
Bool GetTri() const
定义: c4d_gui.h:940
String
定义: c4d_string.h:38
String::IntToString
static String IntToString(Int32 v)
定义: c4d_string.h:495
BaseDocument::GetActiveObjects
void GetActiveObjects(AtomArray &selection, GETACTIVEOBJECTFLAGS flags) const
Int32
maxon::Int32 Int32
定义: ge_sys_math.h:58
TriState::GetValue
const TYPE & GetValue() const
定义: c4d_gui.h:952
ApplicationOutput
#define ApplicationOutput(formatString,...)
定义: debugdiagnostics.h:207
AutoAlloc
定义: ge_autoptr.h:36
Bool
maxon::Bool Bool
定义: ge_sys_math.h:53
BaseList2D::GetName
String GetName() const
定义: c4d_baselist.h:2318
BaseDocument
定义: c4d_basedocument.h:490
TriState::HasChanged
Bool HasChanged() const
定义: c4d_gui.h:958
AtomArray::GetIndex
C4DAtom * GetIndex(Int32 idx) const
定义: c4d_baselist.h:1634

Copyright  © 2014-2025 乐数软件    

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