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();
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);
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,
404 ParmList& parms, OP_OperatorTable& table, OpFlavor flavor = SOP);
407 #if OPENVDB_ABI_VERSION_NUMBER >= 7
418 OpFlavor flavor()
const;
421 std::string flavorString()
const;
424 const std::string& name()
const;
427 const std::string& english()
const;
430 const std::string& iconName()
const;
435 const std::string& helpURL()
const;
439 const std::string& documentation()
const;
442 const OP_OperatorTable& table()
const;
448 OpFactory& addAlias(
const std::string& english);
453 OpFactory& addAliasVerbatim(
const std::string& name);
458 OpFactory& setDocumentation(
const std::string&);
460 OpFactory& addInput(
const std::string& name);
462 OpFactory& addOptionalInput(
const std::string& name);
466 OpFactory& setMaxInputs(
unsigned = 9999);
470 OpFactory& setLocalVariables(CH_LocalVariable*);
472 OpFactory& setInternalName(
const std::string& name);
473 OpFactory& setOperatorTable(
const std::string& name);
505 OP_OperatorTable& table();
508 void init(
OpPolicyPtr,
const std::string& english, OP_Constructor,
512 std::shared_ptr<Impl> mImpl;
537 virtual std::string getName(
const OpFactory& factory,
const std::string& english);
549 virtual std::string getLabelName(
const OpFactory&);
570 mLock.setNode(&node);
571 if (mLock.lock(context) >= UT_ERROR_ABORT) {
572 throw std::runtime_error(
"failed to lock inputs");
580 OP_AutoLockInputs mLock;
602 #endif // HOUDINI_UTILS_PARM_FACTORY_HAS_BEEN_INCLUDED