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.
// 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;
// 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); }
A TriState object stores multiple values:
The stored values can be accessed and analysed with:
// 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)); }