About
A Description object stores information on how C4DAtom parameters are to be displayed in the GUI (Attribute Manager). It contains information on:
- the parameter type and valid parameter values.
- optional information on the (custom) GUI that is used to display the parameter in the Attribute Manager.
The information is stored using description setting IDs, see Description Settings Manual.
- Note
- A Description is displayed in a GeDialog using the DescriptionCustomGui custom GUI element.
-
User data parameters are stored in a DynamicDescription object, see DynamicDescription Manual.
Access
To add dynamic parameters to a NodeData based plugin one can implement NodeData::GetDDescription(). This function receives a given Description object that should be filled with the description of the visible parameters.
See NodeData::GetDDescription() Manual.
{
const Bool invalidNode =
node ==
nullptr;
const Bool invalidDescription = description ==
nullptr;
if (invalidNode || invalidDescription)
return false;
return false;
return SUPER::GetDDescription(
node, description,
flags);
}
PyCompilerFlags * flags
Definition: ast.h:14
Definition: lib_description.h:530
Bool LoadDescription(const BCResourceObj *bc, Bool copy)
Represents a C4DAtom that resides in a 4D list.
Definition: c4d_baselist.h:1831
maxon::Bool Bool
Definition: ge_sys_math.h:55
DESCFLAGS_DESC
Definition: ge_prepass.h:3322
@ LOADED
Set if elements have been added to the description, either by loading or manual addition.
Correspondingly it is possible to get the parameter description from a C4DAtom:
See C4DAtom Parameter Properties.
if (description == nullptr)
void* handle = description->BrowseInit();
while (description->GetNext(handle, &bc, id, gid))
{
}
description->BrowseFree(handle);
Definition: ge_autoptr.h:37
Definition: c4d_basecontainer.h:47
String GetString(Int32 id, const maxon::String &preset=maxon::String()) const
Definition: c4d_basecontainer.h:387
Definition: lib_description.h:330
@ DESC_NAME
String Name for standalone use.
Definition: lib_description.h:91
#define MAXON_SOURCE_LOCATION
Definition: memoryallocationbase.h:67
#define ApplicationOutput(formatString,...)
Definition: debugdiagnostics.h:210
Allocation/Deallocation
A Description object can be created with the usual tools:
This is needed to access the parameter description of a given object:
if (activeObject == nullptr)
if (description == nullptr)
{
}
Definition: c4d_baseobject.h:225
Bool GetDescription(Description *description, DESCFLAGS_DESC flags)
const char * doc
Definition: pyerrors.h:226
Load Description
The description of an plugin's static parameters is defined in the plugin's *.res file. This *.res file is typically registered using the "Register" function of the plugin (see General Plugin Information Manual). Such a registered description can then be loaded:
A custom data type can also define its own description. This sub-description (or sub-channels) can be loaded with:
if (elements == nullptr)
elements->Append(sweepObj);
if (resDataType == nullptr)
const Bool gotSubDescription =
desc->GetSubDescriptionWithData(
if (!gotSubDescription)
void* handle =
desc->BrowseInit();
while (
desc->GetNext(handle, &bc, loopID, gid))
desc->BrowseFree(handle);
RESOURCEDATATYPEPLUGIN * FindResourceDataTypePlugin(Int32 type)
#define CUSTOMDATATYPE_SPLINE
Spline data type ID.
Definition: customgui_splinecontrol.h:23
@ SWEEPOBJECT_SPLINESCALE
Definition: osweep.h:20
Represents a level within a DescID.
Definition: lib_description.h:289
PyStructSequence_Desc * desc
Definition: structseq.h:26
Parameter Descriptions
Edit
In certain situations NodeData::GetDDescription() is not called to get the description of all parameters but of only one specific parameter.
Existing parameter descriptions are stored in BaseContainers that can be accessed with:
- Note
- The parameter IDs are described in Description Settings Manual.
const DescID*
const singleid = description->GetSingleDescID();
if (singleid ==
nullptr || cid.
IsPartOf(*singleid,
nullptr))
{
settings = description->GetParameterI(cid, nullptr);
if (settings)
}
void SetString(Int32 id, const maxon::String &s)
Definition: c4d_basecontainer.h:569
Bool IsPartOf(const DescID &cmp, Int32 *pos) const
@ DESC_SHORT_NAME
String Short name, for attributes dialog.
Definition: lib_description.h:92
@ DTYPE_BUTTON
Button.
Definition: lib_description.h:61
Also a new parameter description can be added:
const DescID*
const singleid = description->GetSingleDescID();
if (singleid ==
nullptr || cid.
IsPartOf(*singleid,
nullptr))
{
return;
}
BaseContainer GetCustomDataTypeDefault(Int32 type)
@ DTYPE_REAL
Float
Definition: lib_description.h:68
@ ID_OBJECTPROPERTIES
Definition: obase.h:56
Iterate
There are two ways to iterate over all elements stored in a Description object. The first way is to loop over all stored parameters in a list:
if (tempDesc && tempDesc->LoadDescription("Mpreview"))
{
void* handle = tempDesc->BrowseInit();
while (tempDesc->GetNext(handle, &settings, id, gid))
{
description->SetParameter(id, *settings, gid);
}
tempDesc->BrowseFree(handle);
}
The other way to iterate over all elements is to navigate down the tree hierarchy defined by parameter groups:
if (object == nullptr)
if (description == nullptr)
if (ar == nullptr)
DescEntry* entry = description->GetFirst(ar);
while (entry != nullptr)
{
description->GetDescEntry(entry, &bc, descid);
if (bc != nullptr)
DescEntry* const subEntries = description->GetDown(entry);
HandleSubEntries(subEntries);
entry = description->GetNext(entry);
}
Miscellaneous
This convenience function allows to fill the BaseContainer for a pop-up menu based on the content of the Description:
if (!description->CreatePopupMenu(descriptionPopUp))
Int32 ShowPopupMenu(CDialog *cd, Int32 screenx, Int32 screeny, const BaseContainer &bc, Int32 flags=POPUP_RIGHT|POPUP_EXECUTECOMMANDS, Int32 *res_mainid=nullptr)
#define MOUSEPOS
Mouse position constant for ShowPopupMenu().
Definition: c4d_gui.h:3234
This function allows to complete a given DescID:
if (arr == nullptr)
if (description->CheckDescID(incompleteID, arr, &completeID))
{
}
Further Reading