10#ifndef HOUDINI_UTILS_PARM_FACTORY_HAS_BEEN_INCLUDED 
   11#define HOUDINI_UTILS_PARM_FACTORY_HAS_BEEN_INCLUDED 
   13#include <GA/GA_Attribute.h> 
   14#include <OP/OP_AutoLockInputs.h> 
   15#include <OP/OP_Operator.h> 
   16#include <PRM/PRM_Include.h> 
   17#include <PRM/PRM_SpareData.h> 
   18#include <SOP/SOP_Node.h> 
   19#include <SOP/SOP_NodeVerb.h> 
   20#if defined(PRODDEV_BUILD) || defined(DWREAL_IS_DOUBLE) 
   25  #ifndef OPENVDB_HOUDINI_API 
   26    #define OPENVDB_HOUDINI_API 
   29  #include <openvdb/version.h> 
   40  #ifdef OPENVDB_HOUDINI_API 
   41    #undef OPENVDB_HOUDINI_API 
   42    #define OPENVDB_HOUDINI_API 
   48class OP_OperatorTable;
 
   81    bool empty()
 const { 
return mParmVec.empty(); }
 
   85    size_t size()
 const { 
return mParmVec.size(); }
 
   88    void clear() { mParmVec.clear(); mSwitchers.clear(); }
 
  114    PRM_Template* 
get() 
const;
 
  117    struct SwitcherInfo { 
size_t parmIdx; std::vector<PRM_Default> folders; 
bool exclusive; };
 
  118    using SwitcherStack = std::vector<SwitcherInfo>;
 
  120    void incFolderParmCount();
 
  121    SwitcherInfo* getCurrentSwitcher();
 
  123    PrmTemplateVec mParmVec;
 
  124    SwitcherStack mSwitchers;
 
 
  150    ParmFactory(PRM_Type, 
const std::string& token, 
const std::string& label);
 
  151    ParmFactory(PRM_MultiType, 
const std::string& token, 
const std::string& label);
 
  191        PRM_ChoiceListType typ = PRM_CHOICELIST_TOGGLE);
 
  199        std::function<bool (
const GA_Attribute&, 
const PRM_Parm&, 
const SOP_Node&)>;
 
  227        PRM_ChoiceListType typ = PRM_CHOICELIST_TOGGLE,
 
  232    #define IS_DEPRECATED __attribute__ ((deprecated)) 
  233#elif defined(_MSC_VER) 
  234    #define IS_DEPRECATED __declspec(deprecated) 
  236    #define IS_DEPRECATED 
  249        const std::vector<std::string>& items, 
bool paired = 
false);
 
  261        const char* 
const* items, 
bool paired = 
false);
 
  302        PRM_RangeFlag minFlag, fpreal minVal,
 
  303        PRM_RangeFlag maxFlag, fpreal maxVal);
 
  338    std::shared_ptr<Impl> mImpl;
 
  341    ParmFactory& doSetChoiceList(PRM_ChoiceListType, 
const std::vector<std::string>&, 
bool);
 
  342    ParmFactory& doSetChoiceList(PRM_ChoiceListType, 
const char* 
const* items, 
bool);
 
 
  395    template<
typename OpPolicyType>
 
 
  420    const std::string& 
name() 
const;
 
  423    const std::string& 
english() 
const;
 
  426    const std::string& 
iconName() 
const;
 
  431    const std::string& 
helpURL() 
const;
 
  438    const OP_OperatorTable& 
table() 
const;
 
  501    OP_OperatorTable& 
table();
 
  508    std::shared_ptr<Impl> mImpl;
 
 
  533    virtual std::string 
getName(
const OpFactory& factory, 
const std::string& english);
 
 
  566        mLock.setNode(&node);
 
  567        if (mLock.lock(context) >= UT_ERROR_ABORT) {
 
  568            throw std::runtime_error(
"failed to lock inputs");
 
 
  576    OP_AutoLockInputs mLock;
 
 
 
#define IS_DEPRECATED
Definition ParmFactory.h:236
Helper class to simplify operator registration.
Definition ParmFactory.h:376
std::function< SOP_NodeCache *(void)> CacheAllocFunc
Functor that returns newly-allocated node caches for instances of this operator.
Definition ParmFactory.h:474
OpFactory & setVerb(SOP_NodeVerb::CookMode cookMode, const CacheAllocFunc &allocator)
Register this operator as a compilable SOP.
OpFactory & setMaxInputs(unsigned=9999)
Set the maximum number of inputs allowed by this operator.
OpFactory & addAliasVerbatim(const std::string &name)
Add an alias for this operator.
OpFactory & addSpareData(const SpareDataMap &)
Specify (key, value) pairs of spare data for this operator.
static std::string flavorToString(OpFlavor)
Return "SOP" for the SOP flavor, "POP" for the POP flavor, etc.
const std::string & name() const
Return the new operator's type name.
OpFactory & setLocalVariables(CH_LocalVariable *)
Add one or more local variables to this operator.
OpFactory & setDocumentation(const std::string &)
Add documentation for this operator.
const std::string & english() const
Return the new operator's UI name.
const std::string & helpURL() const
Return the new operator's help URL.
std::string flavorString() const
Return the new operator's flavor as a string ("SOP", "POP", etc.).
OpFactory & addAlias(const std::string &english)
Construct a type name for this operator from the given English name and add it as an alias.
OpFactory & addOptionalInput(const std::string &name)
Add an optional input with the given name.
OpFlavor
Definition ParmFactory.h:378
@ POP
Definition ParmFactory.h:378
@ VOP
Definition ParmFactory.h:378
@ ROP
Definition ParmFactory.h:378
@ SOP
Definition ParmFactory.h:378
@ HDA
Definition ParmFactory.h:378
OpFlavor flavor() const
Return the new operator's flavor (SOP, POP, etc.).
OpFactory & addInput(const std::string &name)
Add a required input with the given name.
OpFactory & setFlags(unsigned)
OpFactory & setInvisible()
Mark this node as hidden from the UI tab menu.
OpFactory & operator=(const OpFactory &)=delete
OpFactory & setOperatorTable(const std::string &name)
OpFactory & setObsoleteParms(const ParmList &)
Specify obsolete parameters to this operator.
OpFactory(const OpPolicyType &, const std::string &english, OP_Constructor ctor, ParmList &parms, OP_OperatorTable &table, OpFlavor flavor=SOP)
Construct a factory that on destruction registers a new operator type.
Definition ParmFactory.h:395
const OP_OperatorTable & table() const
Return the operator table with which this factory is associated.
const std::string & documentation() const
Return the new operator's documentation.
const std::string & iconName() const
Return the new operator's icon name.
OpFactory & setInternalName(const std::string &name)
An OpPolicy customizes the behavior of an OpFactory. This base class specifies the required interface...
Definition ParmFactory.h:517
virtual std::string getIconName(const OpFactory &)
Return an icon name for the operator defined by the given factory.
Definition ParmFactory.h:536
virtual std::string getTabSubMenuPath(const OpFactory &)
Return the tab sub-menu path of the op.
Definition ParmFactory.h:552
std::string getName(const OpFactory &factory)
Return a type name for the operator defined by the given factory.
Definition ParmFactory.h:523
virtual std::string getHelpURL(const OpFactory &)
Return a help URL for the operator defined by the given factory.
Definition ParmFactory.h:539
OpPolicy()
Definition ParmFactory.h:519
virtual std::string getLabelName(const OpFactory &)
Return a label name for the operator defined by the given factory.
virtual std::string getFirstName(const OpFactory &)
Return the inital default name of the operator.
Definition ParmFactory.h:548
Helper class to simplify construction of PRM_Templates and dynamic user interfaces.
Definition ParmFactory.h:148
PRM_Template get() const
Construct and return the parameter template.
ParmFactory & setInvisible()
Mark this parameter as hidden from the UI.
ParmFactory & setConditional(const PRM_ConditionalBase *)
ParmFactory & setDefault(const std::string &, CH_StringMeaning=CH_STRING_LITERAL)
Specify a default string value for this parameter.
ParmFactory & setSpareData(const PRM_SpareData *)
Specify spare data for this parameter.
ParmFactory & setDefault(fpreal, const char *=nullptr, CH_StringMeaning=CH_STRING_LITERAL)
Specify a default value for this parameter.
ParmFactory & setVectorSize(int)
Specify the number of vector elements for this parameter.
ParmFactory & setParmGroup(int)
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.
ParmFactory & setDefault(const PRM_Default *)
Specify a default value or values for this parameter.
ParmFactory(PRM_Type, const std::string &token, const std::string &label)
ParmFactory & setRange(PRM_RangeFlag minFlag, fpreal minVal, PRM_RangeFlag maxFlag, fpreal maxVal)
Specify a range for this parameter's values.
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.
ParmFactory & setTooltip(const char *)
Specify a plain text tooltip for this parameter.
ParmFactory & setDocumentation(const char *)
Add documentation for this parameter.
ParmFactory & setTypeExtended(PRM_TypeExtended)
Specify an extended type 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,...
ParmFactory & setDefault(const std::vector< PRM_Default > &)
Specify default values for the vector elements of this parameter (assuming its vector size is > 1).
ParmFactory & setChoiceList(const PRM_ChoiceList *)
Specify a menu of values for this parameter.
std::function< bool(const GA_Attribute &, const PRM_Parm &, const SOP_Node &)> AttrFilterFunc
Functor to filter a list of attributes from a SOP's input.
Definition ParmFactory.h:198
ParmFactory & setDefault(const std::vector< fpreal > &)
Specify default numeric values for the vector elements of this parameter (assuming its vector size is...
ParmFactory & setGroupChoiceList(size_t inputIndex, PRM_ChoiceListType typ=PRM_CHOICELIST_TOGGLE)
Specify a menu of primitive group names for this parameter.
ParmFactory & setHelpText(const char *)
Specify a plain text tooltip for this parameter.
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.
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 & 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,...
ParmFactory & setCallbackFunc(const PRM_Callback &)
ParmFactory & setSpareData(const SpareDataMap &)
Specify (key, value) pairs of spare data for this parameter.
ParmFactory(PRM_MultiType, const std::string &token, const std::string &label)
ParmFactory & setRange(const PRM_Range *)
Specify a range or ranges for this parameter's values.
ParmFactory & setMultiparms(const ParmList &)
Specify the list of parameters for each instance of a multiparm.
Parameter template list that is always terminated.
Definition ParmFactory.h:74
size_t size() const
Return the number of parameters in this list.
Definition ParmFactory.h:85
ParmList & addFolder(const std::string &label)
Add a tab with the given label to the current tab collection.
ParmList()
Definition ParmFactory.h:78
bool empty() const
Return true if this list contains no parameters.
Definition ParmFactory.h:81
ParmList & beginExclusiveSwitcher(const std::string &token, const std::string &label="")
Begin an exclusive collection of tabs. Only one tab is "active" at a time.
ParmList & endSwitcher()
End a collection of tabs.
ParmList & add(const PRM_Template &)
Add a parameter to this list.
PRM_Template * get() const
Return a heap-allocated copy of this list's array of parameters.
void clear()
Remove all parameters from this list.
Definition ParmFactory.h:88
std::vector< PRM_Template > PrmTemplateVec
Definition ParmFactory.h:76
ParmList & add(const ParmFactory &)
Add a parameter to this list.
ParmList & beginSwitcher(const std::string &token, const std::string &label="")
Begin a collection of tabs.
Definition ParmFactory.h:51
OPENVDB_HOUDINI_API const PRM_ChoiceList PrimGroupMenuInput3
void addOperatorSpareData(OP_Operator &, const SpareDataMap &)
Specify (key, value) pairs of spare data for the given operator.
std::shared_ptr< OpPolicy > OpPolicyPtr
Definition ParmFactory.h:350
const SpareDataMap & getOperatorSpareData(const OP_Operator &)
Return the spare data associated with the given operator.
OPENVDB_HOUDINI_API const PRM_ChoiceList PrimGroupMenuInput4
std::map< std::string, std::string > SpareDataMap
Definition ParmFactory.h:55
OPENVDB_HOUDINI_API const PRM_ChoiceList PrimGroupMenuInput1
OPENVDB_HOUDINI_API const PRM_ChoiceList PrimGroupMenuInput2
OPENVDB_HOUDINI_API const PRM_ChoiceList PrimGroupMenu