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 48 class OP_OperatorTable;
81 bool empty()
const {
return mParmVec.empty(); }
85 size_t size()
const {
return mParmVec.size(); }
88 void clear() { mParmVec.clear(); mSwitchers.clear(); }
98 ParmList& beginSwitcher(
const std::string& token,
const std::string& label =
"");
101 ParmList& beginExclusiveSwitcher(
const std::string& token,
const std::string& label =
"");
111 ParmList& addFolder(
const std::string& label);
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();
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);
162 ParmFactory& setChoiceListItems(PRM_ChoiceListType typ,
const std::vector<std::string>& items);
168 ParmFactory& setChoiceListItems(PRM_ChoiceListType typ,
const char*
const* items);
191 PRM_ChoiceListType typ = PRM_CHOICELIST_TOGGLE);
199 std::function<bool (const GA_Attribute&, const PRM_Parm&, const SOP_Node&)>;
226 ParmFactory& setAttrChoiceList(
size_t inputIndex, GA_AttributeOwner attrOwner,
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 248 IS_DEPRECATED ParmFactory& setChoiceList(PRM_ChoiceListType typ,
249 const std::vector<std::string>& items,
bool paired =
false);
260 IS_DEPRECATED ParmFactory& setChoiceList(PRM_ChoiceListType typ,
261 const char*
const* items,
bool paired =
false);
265 ParmFactory& setConditional(
const PRM_ConditionalBase*);
271 ParmFactory& setDefault(fpreal,
const char* =
nullptr, CH_StringMeaning = CH_STRING_LITERAL);
273 ParmFactory& setDefault(
const std::string&, CH_StringMeaning = CH_STRING_LITERAL);
277 ParmFactory& setDefault(
const std::vector<fpreal>&);
280 ParmFactory& setDefault(
const std::vector<PRM_Default>&);
282 ParmFactory& setDefault(
const PRM_Default*);
286 ParmFactory& setHelpText(
const char*);
289 ParmFactory& setTooltip(
const char*);
296 ParmFactory& setDocumentation(
const char*);
298 ParmFactory& setParmGroup(
int);
301 ParmFactory& setRange(
302 PRM_RangeFlag minFlag, fpreal minVal,
303 PRM_RangeFlag maxFlag, fpreal maxVal);
306 ParmFactory& setRange(
const std::vector<PRM_Range>&);
308 ParmFactory& setRange(
const PRM_Range*);
313 ParmFactory& setSpareData(
const PRM_SpareData*);
318 ParmFactory& setMultiparms(
const ParmList&);
321 ParmFactory& setTypeExtended(PRM_TypeExtended);
325 ParmFactory& setVectorSize(
int);
331 ParmFactory& setInvisible();
334 PRM_Template
get()
const;
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);
383 static std::string flavorToString(
OpFlavor);
395 template<
typename OpPolicyType>
396 OpFactory(
const OpPolicyType& ,
const std::string& english,
397 OP_Constructor ctor,
ParmList& parms, OP_OperatorTable& table,
OpFlavor flavor = SOP)
399 this->init(
OpPolicyPtr(
new OpPolicyType), english, ctor, parms, table, flavor);
403 OpFactory(
const std::string& english, OP_Constructor ctor,
417 std::string flavorString()
const;
420 const std::string& name()
const;
423 const std::string& english()
const;
426 const std::string& iconName()
const;
431 const std::string& helpURL()
const;
435 const std::string& documentation()
const;
438 const OP_OperatorTable& table()
const;
444 OpFactory& addAlias(
const std::string& english);
449 OpFactory& addAliasVerbatim(
const std::string& name);
454 OpFactory& setDocumentation(
const std::string&);
456 OpFactory& addInput(
const std::string& name);
458 OpFactory& addOptionalInput(
const std::string& name);
462 OpFactory& setMaxInputs(
unsigned = 9999);
466 OpFactory& setLocalVariables(CH_LocalVariable*);
468 OpFactory& setInternalName(
const std::string& name);
469 OpFactory& setOperatorTable(
const std::string& name);
501 OP_OperatorTable& table();
504 void init(
OpPolicyPtr,
const std::string& english, OP_Constructor,
508 std::shared_ptr<Impl> mImpl;
533 virtual std::string getName(
const OpFactory& factory,
const std::string& english);
545 virtual std::string getLabelName(
const OpFactory&);
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;
598 #endif // HOUDINI_UTILS_PARM_FACTORY_HAS_BEEN_INCLUDED OPENVDB_HOUDINI_API const PRM_ChoiceList PrimGroupMenuInput3
ParmList()
Definition: ParmFactory.h:78
OPENVDB_HOUDINI_API const PRM_ChoiceList PrimGroupMenuInput1
virtual std::string getTabSubMenuPath(const OpFactory &)
Return the tab sub-menu path of the op.
Definition: ParmFactory.h:553
OpFlavor
Definition: ParmFactory.h:379
virtual std::string getFirstName(const OpFactory &)
Return the inital default name of the operator.
Definition: ParmFactory.h:549
virtual std::string getIconName(const OpFactory &)
Return an icon name for the operator defined by the given factory.
Definition: ParmFactory.h:537
Definition: ParmFactory.h:51
std::map< std::string, std::string > SpareDataMap
Definition: ParmFactory.h:55
Helper class to simplify construction of PRM_Templates and dynamic user interfaces.
Definition: ParmFactory.h:147
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:199
const std::string & english() const
Return the new operator's UI name.
std::vector< PRM_Template > PrmTemplateVec
Definition: ParmFactory.h:76
Parameter template list that is always terminated.
Definition: ParmFactory.h:73
std::function< SOP_NodeCache *(void)> CacheAllocFunc
Functor that returns newly-allocated node caches for instances of this operator.
Definition: ParmFactory.h:475
OpPolicy()
Definition: ParmFactory.h:520
bool empty() const
Return true if this list contains no parameters.
Definition: ParmFactory.h:81
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:396
std::string getName(const OpFactory &factory)
Return a type name for the operator defined by the given factory.
Definition: ParmFactory.h:524
#define IS_DEPRECATED
Definition: ParmFactory.h:236
virtual std::string getHelpURL(const OpFactory &)
Return a help URL for the operator defined by the given factory.
Definition: ParmFactory.h:540
size_t size() const
Return the number of parameters in this list.
Definition: ParmFactory.h:85
OPENVDB_HOUDINI_API const PRM_ChoiceList PrimGroupMenuInput2
void clear()
Remove all parameters from this list.
Definition: ParmFactory.h:88
const SpareDataMap & getOperatorSpareData(const OP_Operator &)
Return the spare data associated with the given operator.
std::shared_ptr< OpPolicy > OpPolicyPtr
Definition: ParmFactory.h:350
An OpPolicy customizes the behavior of an OpFactory. This base class specifies the required interface...
Definition: ParmFactory.h:517
void addOperatorSpareData(OP_Operator &, const SpareDataMap &)
Specify (key, value) pairs of spare data for the given operator.
Helper class to simplify operator registration.
Definition: ParmFactory.h:376
Definition: ParmFactory.h:379
virtual ~OpPolicy()
Definition: ParmFactory.h:521
OPENVDB_HOUDINI_API const PRM_ChoiceList PrimGroupMenuInput4
OPENVDB_HOUDINI_API const PRM_ChoiceList PrimGroupMenu