OpenVDB  6.2.1
Public Types | Public Member Functions | List of all members
ParmFactory Class Reference

Helper class to simplify construction of PRM_Templates and dynamic user interfaces. More...

#include <ParmFactory.h>

Public Types

using AttrFilterFunc = std::function< bool(const GA_Attribute &, const PRM_Parm &, const SOP_Node &)>
 Functor to filter a list of attributes from a SOP's input. More...
 

Public Member Functions

 ParmFactory (PRM_Type, const std::string &token, const std::string &label)
 
 ParmFactory (PRM_MultiType, const std::string &token, const std::string &label)
 
ParmFactorysetCallbackFunc (const PRM_Callback &)
 
ParmFactorysetChoiceList (const PRM_ChoiceList *)
 Specify a menu of values for this parameter. More...
 
ParmFactorysetChoiceListItems (PRM_ChoiceListType typ, const std::vector< std::string > &items)
 Specify a menu type and a list of token, label, token, label,... pairs for this parameter. More...
 
ParmFactorysetChoiceListItems (PRM_ChoiceListType typ, const char *const *items)
 Specify a menu type and a list of token, label, token, label,... pairs for this parameter. More...
 
ParmFactorysetGroupChoiceList (size_t inputIndex, PRM_ChoiceListType typ=PRM_CHOICELIST_TOGGLE)
 Specify a menu of primitive group names for this parameter. More...
 
ParmFactorysetAttrChoiceList (size_t inputIndex, GA_AttributeOwner attrOwner, PRM_ChoiceListType typ=PRM_CHOICELIST_TOGGLE, AttrFilterFunc attrFilter=AttrFilterFunc{})
 Specify a menu of attribute names for this parameter. More...
 
ParmFactorysetChoiceList (PRM_ChoiceListType typ, const std::vector< std::string > &items, bool paired=false)
 Specify a menu type and either a list of menu item labels or a list of token, label, token, label,... pairs for this parameter. More...
 
ParmFactorysetChoiceList (PRM_ChoiceListType typ, const char *const *items, bool paired=false)
 Specify a menu type and either a list of menu item labels or a list of token, label, token, label,... pairs for this parameter. More...
 
ParmFactorysetConditional (const PRM_ConditionalBase *)
 
ParmFactorysetDefault (fpreal, const char *=nullptr, CH_StringMeaning=CH_STRING_LITERAL)
 Specify a default value for this parameter. More...
 
ParmFactorysetDefault (const std::string &, CH_StringMeaning=CH_STRING_LITERAL)
 Specify a default string value for this parameter. More...
 
ParmFactorysetDefault (const std::vector< fpreal > &)
 Specify default numeric values for the vector elements of this parameter (assuming its vector size is > 1). More...
 
ParmFactorysetDefault (const std::vector< PRM_Default > &)
 Specify default values for the vector elements of this parameter (assuming its vector size is > 1). More...
 
ParmFactorysetDefault (const PRM_Default *)
 Specify a default value or values for this parameter. More...
 
ParmFactorysetHelpText (const char *)
 Specify a plain text tooltip for this parameter. More...
 
ParmFactorysetTooltip (const char *)
 Specify a plain text tooltip for this parameter. More...
 
ParmFactorysetDocumentation (const char *)
 Add documentation for this parameter. More...
 
ParmFactorysetParmGroup (int)
 
ParmFactorysetRange (PRM_RangeFlag minFlag, fpreal minVal, PRM_RangeFlag maxFlag, fpreal maxVal)
 Specify a range for this parameter's values. More...
 
ParmFactorysetRange (const std::vector< PRM_Range > &)
 Specify range for the values of this parameter's vector elements (assuming its vector size is > 1). More...
 
ParmFactorysetRange (const PRM_Range *)
 Specify a range or ranges for this parameter's values. More...
 
ParmFactorysetSpareData (const SpareDataMap &)
 Specify (key, value) pairs of spare data for this parameter. More...
 
ParmFactorysetSpareData (const PRM_SpareData *)
 Specify spare data for this parameter. More...
 
ParmFactorysetMultiparms (const ParmList &)
 Specify the list of parameters for each instance of a multiparm. More...
 
ParmFactorysetTypeExtended (PRM_TypeExtended)
 Specify an extended type for this parameter. More...
 
ParmFactorysetVectorSize (int)
 Specify the number of vector elements for this parameter. More...
 
ParmFactorysetInvisible ()
 Mark this parameter as hidden from the UI. More...
 
PRM_Template get () const
 Construct and return the parameter template. More...
 

Detailed Description

Helper class to simplify construction of PRM_Templates and dynamic user interfaces.

Example
parms.add(houdini_utils::ParmFactory(PRM_STRING, "group", "Group")
.setHelpText("Specify a subset of the input VDB grids to be processed.")
parms.add(houdini_utils::ParmFactory(PRM_FLT_J, "tolerance", "Pruning Tolerance")
.setDefault(PRMzeroDefaults)
.setRange(PRM_RANGE_RESTRICTED, 0, PRM_RANGE_UI, 1));

Member Typedef Documentation

using AttrFilterFunc = std::function<bool (const GA_Attribute&, const PRM_Parm&, const SOP_Node&)>

Functor to filter a list of attributes from a SOP's input.

Arguments to the functor are an attribute to be filtered and the parameter and SOP for which the filter is being called. The functor should return true for attributes that should be added to the list and false for attributes that should be ignored.

Constructor & Destructor Documentation

ParmFactory ( PRM_Type  ,
const std::string &  token,
const std::string &  label 
)
ParmFactory ( PRM_MultiType  ,
const std::string &  token,
const std::string &  label 
)

Member Function Documentation

PRM_Template get ( ) const

Construct and return the parameter template.

ParmFactory& setAttrChoiceList ( size_t  inputIndex,
GA_AttributeOwner  attrOwner,
PRM_ChoiceListType  typ = PRM_CHOICELIST_TOGGLE,
AttrFilterFunc  attrFilter = AttrFilterFunc{} 
)

Specify a menu of attribute names for this parameter.

Parameters
inputIndexthe zero-based index of the input from which to get attributes
attrOwnerthe class of attribute with which to populate the menu: either per-vertex (GA_ATTRIB_VERTEX), per-point (GA_ATTRIB_POINT), per-primitive (GA_ATTRIB_PRIMITIVE), global (GA_ATTRIB_GLOBAL), or all of the above (GA_ATTRIB_INVALID or any other value)
typthe menu behavior (toggle, replace, etc.)
attrFilteran optional filter functor that returns true for each attribute that should appear in the menu; the functor will be moved, if possible, or else copied
Note
This method is supported only for SOPs.
Example
Create a menu that allows multiple selection from among all the string attributes on a SOP's first input:
parms.add(houdini_utils::ParmFactory(PRM_STRING, "stringattr", "String Attribute")
.setAttrChoiceList(/*input=*/0, GA_ATTRIB_INVALID, PRM_CHOICELIST_TOGGLE,
[](const GA_Attribute& attr, const PRM_Parm&, const SOP_Node&) {
return (attr.getStorageClass() == GA_STORECLASS_STRING);
}));
ParmFactory& setCallbackFunc ( const PRM_Callback &  )
ParmFactory& setChoiceList ( const PRM_ChoiceList *  )

Specify a menu of values for this parameter.

ParmFactory& setChoiceList ( PRM_ChoiceListType  typ,
const std::vector< std::string > &  items,
bool  paired = false 
)

Specify a menu type and either a list of menu item labels or a list of token, label, token, label,... pairs for this parameter.

Parameters
typspecifies the menu behavior (toggle, replace, etc.)
itemsa list of menu item labels or token, label, token, label,... pairs
pairedif false, treat all the elements of items as labels and assign them numeric tokens starting from zero; otherwise, treat the elements of items as token, label, token, label,... pairs
Deprecated:
Use setChoiceListItems() instead. Using unpaired items may mean less typing now, but it prevents you from reordering or deleting entries later.
ParmFactory& setChoiceList ( PRM_ChoiceListType  typ,
const char *const *  items,
bool  paired = false 
)

Specify a menu type and either a list of menu item labels or a list of token, label, token, label,... pairs for this parameter.

Parameters
typspecifies the menu behavior (toggle, replace, etc.)
itemsa list of menu item labels or token, label, token, label,... pairs
pairedif false, treat all the elements of items as labels and assign them numeric tokens starting from zero; otherwise, treat the elements of items as token, label, token, label,... pairs
Note
The items array must be null-terminated.
Deprecated:
Use setChoiceListItems() instead. Using unpaired items may mean less typing now, but it prevents you from reordering or deleting entries later.
ParmFactory& setChoiceListItems ( PRM_ChoiceListType  typ,
const std::vector< std::string > &  items 
)

Specify a menu type and a list of token, label, token, label,... pairs for this parameter.

Parameters
typspecifies the menu behavior (toggle, replace, etc.)
itemsa list of token, label, token, label,... string pairs
ParmFactory& setChoiceListItems ( PRM_ChoiceListType  typ,
const char *const *  items 
)

Specify a menu type and a list of token, label, token, label,... pairs for this parameter.

Parameters
typspecifies the menu behavior (toggle, replace, etc.)
itemsa list of token, label, token, label,... string pairs
Note
The items array must be null-terminated.
ParmFactory& setConditional ( const PRM_ConditionalBase *  )
ParmFactory& setDefault ( fpreal  ,
const char *  = nullptr,
CH_StringMeaning  = CH_STRING_LITERAL 
)

Specify a default value for this parameter.

If the string is null, the floating-point value will be used (but rounded if this parameter is integer-valued).

Note
The string pointer must not point to a temporary.
ParmFactory& setDefault ( const std::string &  ,
CH_StringMeaning  = CH_STRING_LITERAL 
)

Specify a default string value for this parameter.

ParmFactory& setDefault ( const std::vector< fpreal > &  )

Specify default numeric values for the vector elements of this parameter (assuming its vector size is > 1).

Floating-point values will be rounded if this parameter is integer-valued.

ParmFactory& setDefault ( const std::vector< PRM_Default > &  )

Specify default values for the vector elements of this parameter (assuming its vector size is > 1).

ParmFactory& setDefault ( const PRM_Default *  )

Specify a default value or values for this parameter.

ParmFactory& setDocumentation ( const char *  )

Add documentation for this parameter.

Pass a null pointer or an empty string to inhibit the generation of documentation for this parameter.

The text is parsed as wiki markup. See the Houdini Wiki Markup Reference for the syntax.

ParmFactory& setGroupChoiceList ( size_t  inputIndex,
PRM_ChoiceListType  typ = PRM_CHOICELIST_TOGGLE 
)

Specify a menu of primitive group names for this parameter.

Parameters
inputIndexthe zero-based index of the input from which to get primitive groups
typthe menu behavior (toggle, replace, etc.)

Calling this method with the default (toggle) behavior is equivalent to calling setChoiceList(&houdini_utils::PrimGroupMenuInput1), setChoiceList(&houdini_utils::PrimGroupMenuInput2), etc.

Example
To limit the user to choosing a single primitive group, replace
parms.add(houdini_utils::ParmFactory(PRM_STRING, "reference", "Reference")
with
parms.add(houdini_utils::ParmFactory(PRM_STRING, "reference", "Reference")
.setGroupChoiceList(1, PRM_CHOICELIST_REPLACE); // input index is zero based
ParmFactory& setHelpText ( const char *  )

Specify a plain text tooltip for this parameter.

This method is equivalent to setTooltip()

ParmFactory& setInvisible ( )

Mark this parameter as hidden from the UI.

Note
Marking parameters as obsolete is preferable to making them invisible as changing invisible parameter values will still trigger a re-cook, however this is not possible when using multi-parms.
ParmFactory& setMultiparms ( const ParmList )

Specify the list of parameters for each instance of a multiparm.

Note
This setting is ignored for non-multiparm parameters.
Parameter name tokens should include a '#' character.
ParmFactory& setParmGroup ( int  )
ParmFactory& setRange ( PRM_RangeFlag  minFlag,
fpreal  minVal,
PRM_RangeFlag  maxFlag,
fpreal  maxVal 
)

Specify a range for this parameter's values.

ParmFactory& setRange ( const std::vector< PRM_Range > &  )

Specify range for the values of this parameter's vector elements (assuming its vector size is > 1).

ParmFactory& setRange ( const PRM_Range *  )

Specify a range or ranges for this parameter's values.

ParmFactory& setSpareData ( const SpareDataMap )

Specify (key, value) pairs of spare data for this parameter.

ParmFactory& setSpareData ( const PRM_SpareData *  )

Specify spare data for this parameter.

ParmFactory& setTooltip ( const char *  )

Specify a plain text tooltip for this parameter.

This method is equivalent to setHelpText()

ParmFactory& setTypeExtended ( PRM_TypeExtended  )

Specify an extended type for this parameter.

ParmFactory& setVectorSize ( int  )

Specify the number of vector elements for this parameter.

(The default vector size is one element.)


The documentation for this class was generated from the following file: