Solved iCustomGui with multiple input fields and TriState

Greetings to all.

I'm trying to implement a custom GUI similar to the one-line Vector data type in C4D (where you've got 3x real values on a single row), except with 4x values instead (X, Y, Z, and W).

I'm a bit lost with the iCustomGui class at the moment, since I'm not really sure how the TriState stuff is supposed to work with multiple input fields. The example on plugincafe (customgui_string.cpp) only has a single element in it and I think it's only tracking the tristate for that singular thing.

How can I handle 4x real values on a single custom GUI? All I'm trying to do here is replicate the behavior of the Vector data type, but with 4 values instead of 3.



Please mark your posts as a question. Thanks.

"TriState stuff" doesn't work with "multiple input fields".

A custom GUI just displays a (custom) parameter. A custom GUI does not present four float values. It presents a single four-component vector. Thus, a TriState must track the state of such a singular vector object.

A vector type has not three or four values. It has one value, composed of several sub-components. Just like a string contains a variable number of characters. The customdata_customgui.cpp example shows a data type with a variable number of components.

Cinema 4D R20 actually includes a four-component vector type which you could use: DTYPE_VECTOR4D.

Best wishes,

Thanks for the reply.

Sorry, I might be a bit confused terminology wise here. I wish to create the equivalent of R20's Vector4D datatype, but for versions < R20. What I've noticed with the 3-component vector is that it only says "<< MULTIPLE VALUES >>" on a per-component basis, ie, if two vector components are identical and multiple items are displayed, then those two will be displayed as usual while the components that differ will say "<< MULTIPLE VALUES>>" instead.

What I'm confused about is how this should be handled on a per-component basis under iCustomGui. It seems simple enough to create four float fields, but what I don't get is how I'd track the tristate between those so the entire thing behaves similar to DTYPE_VECTOR (and presumably DTYPE_VECTOR4D).

Is there any chance you might have some examples of how Vector (or Vector 4D) is implemented in this regard?



actually, three-component vectors (DTYPE_VECTOR) and four-component vectors (DTYPE_VECTOR4D) behave differently. DTYPE_VECTOR shows <<Multiple>> component-based while DTYPE_VECTOR4D shows <<Multiple>> for all components if only one component is different.

DTYPE_VECTOR and CUSTOMGUI_VECTOR are very old parts of Cinema 4D, so they are not implemented as iCustomGui plugins. DTYPE_VECTOR4D displays <<Multiple>> for all components if one component is different. So I'm afraid there isn't any source code within Cinema that does what you want to do.

The typical procedure is to obtain the '"tristate" using

_isTristate = tristate.GetTri();

and then using this value with the GeDialog functions. E.g. the last argument of GeDialog::SetFloat() is a "tristate" argument.

If your custom data type should behave like DTYPE_VECTOR4D, then it must display <<Multiple>> for all components if only one component is different.

best wishes,

Right, that's kinda what I thought. I guess showing "<< MULTIPLE VALUES >>" for all four values will have to do (it's not that big of a deal, it just kinda looks ugly on the UI).

Anyways, thanks for your help!