HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
VOP_Parameter.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: VOP Library (C++)
7  *
8  */
9 
10 #ifndef __VOP_Parameter_h__
11 #define __VOP_Parameter_h__
12 
13 #include "VOP_API.h"
14 #include "VOP_ParameterBase.h"
15 #include <CH/CH_ExprLanguage.h>
16 
18 
20 {
21 public:
22  static OP_Node *myConstructor(OP_Network *net,
23  const char *name,
24  OP_Operator *entry);
25  static PRM_Template *buildTemplates(const VOP_Language *language);
26  static PRM_Template *getObsolete(const VOP_Language *language);
27 
28  void initializeNode() override;
29 
30  // Get the parm block information that will go in the dialog script
31  // for our VOPNET.
33  UT_String &parmdecl,
34  const VOP_Language *language,
35  const VOP_CodeGenContext &context
36  ) override;
38  UT_String &parm_comment,
39  const VOP_Language *language,
40  const VOP_CodeGenContext &context
41  ) override;
42  void getParameterBlock(
43  UT_String &parmstr,
44  const char *shader_contexts) override;
45  // Get the pragmas that define the UI for the parameter.
46  void getPragmas(
47  UT_String &pragmastr,
48  const VOP_CodeGenContext &context
49  ) override;
50 
52  const char *parmname,
53  const VOP_TypeInfo &type_info,
54  UT_String &str,
55  bool expand_string,
56  const VOP_Language *language = nullptr
57  ) override;
58 
59  const char *inputLabel(unsigned idx) const override;
60 
61  void setPARMNAME(const UT_String &str) override;
62  void setPARMLABEL(const UT_String &str);
63  void setPARMTYPEINDEX(int type) override;
64  void setPARMTYPENAME(const UT_StringRef &type_name) override;
65  void setPARMSCOPE(const char *scope) override;
66  void setPARMSTORAGE(int type) override;
67  void setPARMSTRINGTYPE(const char *style);
68  void setPARMOPFILTER(const char *filter);
69 
70  void PARMSCOPE(UT_String &str) const override;
71  void PARMACCESS(UT_String &str) const override;
72  void PARMNAME(UT_String &str) const override;
73  void PARMPREFIX(UT_String &str) const override;
74  void PARMPOSTFIX(UT_String &str) const override;
75  void PARMLABEL(UT_String &str) const override;
76  void PARMCOMMENT(UT_String &str) const override;
77  int PARMTYPEINDEX() const override;
78  void PARMTYPENAME(
79  UT_String &type_name) const override;
80  void PARMMENUOPTION(
81  UT_String &menu_option) const override;
82 
83  void TAGS(UT_JSONValueMap &map) const;
84  void setTAGS(UT_StringMap<UT_StringHolder> &tags);
85 
86  bool isParmVisible() const override;
87  void copySettingsFrom(
88  VOP_ParmGenerator *pvop) override;
90  const PI_EditScriptedParm *parm
91  ) override;
92 
93  /// Parameter VOP represents USD inputs and output. It can be translated
94  /// directly to an input/output attribute of a USD material primitive.
95  bool translatesDirectlyToUSD() const override
96  { return true; }
97 
98 protected:
99  VOP_Parameter(OP_Network *parent, const char *name,
100  OP_Operator *entry);
101  ~VOP_Parameter() override;
102 
103  bool updateParmsFlags() override;
104 
105  // Override cook method just so we can set our warnings properly.
106  bool USEASPARMDEFINER() const override;
107  bool USEOWNEXPORTCONTEXT() const override;
109  ) const override;
110  int UNIFORM() const override;
111  int USEBOUND() const override;
112  int EXPORTPARM() const override;
114  UT_StringArray &context_names
115  ) const override;
117  void MENUCHOICES(UT_String &str) const override;
118  void MENUSCRIPT(UT_String &str) const override;
119  CH_ScriptLanguage MENUSCRIPTLANGUAGE() const override;
120  void CALLBACKSTR(UT_String &str) const;
121  void HELPTEXTSTR(UT_String &str) const;
122  int INVISIBLE() const;
123  int JOINNEXT() const;
124  int SHOWLABEL() const;
125  int IRANGE(int index) const;
126  float FRANGE(int index) const;
127 
128  bool needsInput() override;
129 
130  // True if the node defines a node parameter UI (eg, on a SHOP);
131  // otherwise, returns false (eg, if this parm node refers to a method arg).
132  bool definesParmUI() const;
133 
134  // Build the code to be output when useBound() is true but the parameter
135  // is not actually bound:
136  void getUnboundCode(
137  UT_String &codestr,
138  const VOP_CodeGenContext &context
139  ) override;
140 
142  UT_String &parm_decl,
143  const VOP_CodeGenContext &codegen_ctx,
144  const VOP_Language *language = nullptr,
145  bool export_parms = false) override;
146 
147  // Determines based on the parm index if the PARMNAME may be changed
148  // when this parm is changed.
150  int pidx) const override;
151 
153  VOP_TypeInfo &type_info,
154  int idx) override;
156  unsigned idx,
157  VOP_VopTypeArray &voptypes) override;
158  bool shouldCheckTimeDependence() const override;
159 
160 private:
161  bool allowMenu(int parmtype) const;
162 
163  // Store the indices of the parameters that can affect the cached parameter
164  // name.
165  static int theParmNameParmIndex;
166  static int theParmPrefixParmIndex;
167  static int theParmPostfixParmIndex;
168  static int theParmTypeParmIndex;
169 };
170 
171 #endif
Reprsents a language for which VOPs can generate source code.
Definition: VOP_Language.h:29
virtual bool needsInput()=0
virtual bool isParmVisible() const =0
bool translatesDirectlyToUSD() const override
Definition: VOP_Parameter.h:95
virtual int UNIFORM() const =0
UT_JSONValueMap stores a map/dictionary of UT_JSONValue objects.
virtual void PARMNAME(UT_String &str) const =0
virtual void getParameterComment(UT_String &parm_comment, const VOP_Language *language, const VOP_CodeGenContext &context)
virtual void copySettingsFrom(VOP_ParmGenerator *pvop)
Copy settings from a source parameter generator.
virtual void getAllowedInputTypesSubclass(unsigned idx, VOP_VopTypeArray &voptypes)
virtual bool getParmConstantString(const char *parmname, const VOP_TypeInfo &type_info, UT_String &str, bool expand_string, const VOP_Language *l=0)
Get the constant code that encodes the value of the node parameter.
virtual void PARMSCOPE(UT_String &str) const
virtual void PARMACCESS(UT_String &str) const
bool updateParmsFlags() override
virtual const char * inputLabel(unsigned idx) const
virtual void copyDefaultValuesFrom(const PI_EditScriptedParm *parm)
void initializeNode() override
virtual CH_ScriptLanguage MENUSCRIPTLANGUAGE() const
virtual void getParameterBlock(UT_String &parmstr, const char *shader_contexts)
virtual bool SHOULDHAVECORRESPONDINGCONNECTOR() const
virtual bool USEOWNEXPORTCONTEXT() const
virtual bool shouldCheckTimeDependence() const
virtual void getInputTypeInfoSubclass(VOP_TypeInfo &type_info, int idx)
virtual void PARMLABEL(UT_String &str) const =0
virtual void PARMPREFIX(UT_String &str) const
virtual void EXPORTSHADERCONTEXTS(UT_StringArray &context_names) const
virtual void setPARMTYPEINDEX(int type)
#define VOP_API
Definition: VOP_API.h:10
virtual void PARMCOMMENT(UT_String &str) const
virtual int PARMTYPEINDEX() const =0
virtual void MENUSCRIPT(UT_String &str) const
virtual void getParameterDeclaration(UT_String &parmdecl, const VOP_Language *language, const VOP_CodeGenContext &context)
The parameter variable declaration using the syntax of a given language.
constexpr std::enable_if< I< type_count_base< T >::value, int >::type tuple_type_size(){return subtype_count< typename std::tuple_element< I, T >::type >::value+tuple_type_size< T, I+1 >);}template< typename T > struct type_count< T, typename std::enable_if< is_tuple_like< T >::value >::type >{static constexpr int value{tuple_type_size< T, 0 >)};};template< typename T > struct subtype_count{static constexpr int value{is_mutable_container< T >::value?expected_max_vector_size:type_count< T >::value};};template< typename T, typename Enable=void > struct type_count_min{static const int value{0};};template< typename T >struct type_count_min< T, typename std::enable_if<!is_mutable_container< T >::value &&!is_tuple_like< T >::value &&!is_wrapper< T >::value &&!is_complex< T >::value &&!std::is_void< T >::value >::type >{static constexpr int value{type_count< T >::value};};template< typename T > struct type_count_min< T, typename std::enable_if< is_complex< T >::value >::type >{static constexpr int value{1};};template< typename T >struct type_count_min< T, typename std::enable_if< is_wrapper< T >::value &&!is_complex< T >::value &&!is_tuple_like< T >::value >::type >{static constexpr int value{subtype_count_min< typename T::value_type >::value};};template< typename T, std::size_t I >constexpr typename std::enable_if< I==type_count_base< T >::value, int >::type tuple_type_size_min(){return 0;}template< typename T, std::size_t I > constexpr typename std::enable_if< I< type_count_base< T >::value, int >::type tuple_type_size_min(){return subtype_count_min< typename std::tuple_element< I, T >::type >::value+tuple_type_size_min< T, I+1 >);}template< typename T > struct type_count_min< T, typename std::enable_if< is_tuple_like< T >::value >::type >{static constexpr int value{tuple_type_size_min< T, 0 >)};};template< typename T > struct subtype_count_min{static constexpr int value{is_mutable_container< T >::value?((type_count< T >::value< expected_max_vector_size)?type_count< T >::value:0):type_count_min< T >::value};};template< typename T, typename Enable=void > struct expected_count{static const int value{0};};template< typename T >struct expected_count< T, typename std::enable_if<!is_mutable_container< T >::value &&!is_wrapper< T >::value &&!std::is_void< T >::value >::type >{static constexpr int value{1};};template< typename T > struct expected_count< T, typename std::enable_if< is_mutable_container< T >::value >::type >{static constexpr int value{expected_max_vector_size};};template< typename T >struct expected_count< T, typename std::enable_if<!is_mutable_container< T >::value &&is_wrapper< T >::value >::type >{static constexpr int value{expected_count< typename T::value_type >::value};};enum class object_category:int{char_value=1, integral_value=2, unsigned_integral=4, enumeration=6, boolean_value=8, floating_point=10, number_constructible=12, double_constructible=14, integer_constructible=16, string_assignable=23, string_constructible=24, other=45, wrapper_value=50, complex_number=60, tuple_value=70, container_value=80,};template< typename T, typename Enable=void > struct classify_object{static constexpr object_category value{object_category::other};};template< typename T >struct classify_object< T, typename std::enable_if< std::is_integral< T >::value &&!std::is_same< T, char >::value &&std::is_signed< T >::value &&!is_bool< T >::value &&!std::is_enum< T >::value >::type >{static constexpr object_category value{object_category::integral_value};};template< typename T >struct classify_object< T, typename std::enable_if< std::is_integral< T >::value &&std::is_unsigned< T >::value &&!std::is_same< T, char >::value &&!is_bool< T >::value >::type >{static constexpr object_category value{object_category::unsigned_integral};};template< typename T >struct classify_object< T, typename std::enable_if< std::is_same< T, char >::value &&!std::is_enum< T >::value >::type >{static constexpr object_category value{object_category::char_value};};template< typename T > struct classify_object< T, typename std::enable_if< is_bool< T >::value >::type >{static constexpr object_category value{object_category::boolean_value};};template< typename T > struct classify_object< T, typename std::enable_if< std::is_floating_point< T >::value >::type >{static constexpr object_category value{object_category::floating_point};};template< typename T >struct classify_object< T, typename std::enable_if<!std::is_floating_point< T >::value &&!std::is_integral< T >::value &&std::is_assignable< T &, std::string >::value >::type >{static constexpr object_category value{object_category::string_assignable};};template< typename T >struct classify_object< T, typename std::enable_if<!std::is_floating_point< T >::value &&!std::is_integral< T >::value &&!std::is_assignable< T &, std::string >::value &&(type_count< T >::value==1)&&std::is_constructible< T, std::string >::value >::type >{static constexpr object_category value{object_category::string_constructible};};template< typename T > struct classify_object< T, typename std::enable_if< std::is_enum< T >::value >::type >{static constexpr object_category value{object_category::enumeration};};template< typename T > struct classify_object< T, typename std::enable_if< is_complex< T >::value >::type >{static constexpr object_category value{object_category::complex_number};};template< typename T > struct uncommon_type{using type=typename std::conditional<!std::is_floating_point< T >::value &&!std::is_integral< T >::value &&!std::is_assignable< T &, std::string >::value &&!std::is_constructible< T, std::string >::value &&!is_complex< T >::value &&!is_mutable_container< T >::value &&!std::is_enum< T >::value, std::true_type, std::false_type >::type;static constexpr bool value=type::value;};template< typename T >struct classify_object< T, typename std::enable_if<(!is_mutable_container< T >::value &&is_wrapper< T >::value &&!is_tuple_like< T >::value &&uncommon_type< T >::value)>::type >{static constexpr object_category value{object_category::wrapper_value};};template< typename T >struct classify_object< T, typename std::enable_if< uncommon_type< T >::value &&type_count< T >::value==1 &&!is_wrapper< T >::value &&is_direct_constructible< T, double >::value &&is_direct_constructible< T, int >::value >::type >{static constexpr object_category value{object_category::number_constructible};};template< typename T >struct classify_object< T, typename std::enable_if< uncommon_type< T >::value &&type_count< T >::value==1 &&!is_wrapper< T >::value &&!is_direct_constructible< T, double >::value &&is_direct_constructible< T, int >::value >::type >{static constexpr object_category value{object_category::integer_constructible};};template< typename T >struct classify_object< T, typename std::enable_if< uncommon_type< T >::value &&type_count< T >::value==1 &&!is_wrapper< T >::value &&is_direct_constructible< T, double >::value &&!is_direct_constructible< T, int >::value >::type >{static constexpr object_category value{object_category::double_constructible};};template< typename T >struct classify_object< T, typename std::enable_if< is_tuple_like< T >::value &&((type_count< T >::value >=2 &&!is_wrapper< T >::value)||(uncommon_type< T >::value &&!is_direct_constructible< T, double >::value &&!is_direct_constructible< T, int >::value)||(uncommon_type< T >::value &&type_count< T >::value >=2))>::type >{static constexpr object_category value{object_category::tuple_value};};template< typename T > struct classify_object< T, typename std::enable_if< is_mutable_container< T >::value >::type >{static constexpr object_category value{object_category::container_value};};template< typename T, enable_if_t< classify_object< T >::value==object_category::char_value, detail::enabler >=detail::dummy >constexpr const char *type_name(){return"CHAR";}template< typename T, enable_if_t< classify_object< T >::value==object_category::integral_value||classify_object< T >::value==object_category::integer_constructible, detail::enabler >=detail::dummy >constexpr const char *type_name(){return"INT";}template< typename T, enable_if_t< classify_object< T >::value==object_category::unsigned_integral, detail::enabler >=detail::dummy >constexpr const char *type_name(){return"UINT";}template< typename T, enable_if_t< classify_object< T >::value==object_category::floating_point||classify_object< T >::value==object_category::number_constructible||classify_object< T >::value==object_category::double_constructible, detail::enabler >=detail::dummy >constexpr const char *type_name(){return"FLOAT";}template< typename T, enable_if_t< classify_object< T >::value==object_category::enumeration, detail::enabler >=detail::dummy >constexpr const char *type_name(){return"ENUM";}template< typename T, enable_if_t< classify_object< T >::value==object_category::boolean_value, detail::enabler >=detail::dummy >constexpr const char *type_name(){return"BOOLEAN";}template< typename T, enable_if_t< classify_object< T >::value==object_category::complex_number, detail::enabler >=detail::dummy >constexpr const char *type_name(){return"COMPLEX";}template< typename T, enable_if_t< classify_object< T >::value >=object_category::string_assignable &&classify_object< T >::value<=object_category::other, detail::enabler >=detail::dummy >constexpr const char *type_name(){return"TEXT";}template< typename T, enable_if_t< classify_object< T >::value==object_category::tuple_value &&type_count_base< T >::value >=2, detail::enabler >=detail::dummy >std::string type_name();template< typename T, enable_if_t< classify_object< T >::value==object_category::container_value||classify_object< T >::value==object_category::wrapper_value, detail::enabler >=detail::dummy >std::string type_name();template< typename T, enable_if_t< classify_object< T >::value==object_category::tuple_value &&type_count_base< T >::value==1, detail::enabler >=detail::dummy >inline std::string type_name(){return type_name< typename std::decay< typename std::tuple_element< 0, T >::type >::type >);}template< typename T, std::size_t I >inline typename std::enable_if< I==type_count_base< T >::value, std::string >::type tuple_name(){return std::string{};}template< typename T, std::size_t I >inline typename std::enable_if<(I< type_count_base< T >::value), std::string >::type tuple_name(){auto str=std::string{type_name< typename std::decay< typename std::tuple_element< I, T >::type >::type >)}+ ','+tuple_name< T, I+1 >);if(str.back()== ',') str.pop_back();return str;}template< typename T, enable_if_t< classify_object< T >::value==object_category::tuple_value &&type_count_base< T >::value >=2, detail::enabler > > std::string type_name()
Recursively generate the tuple type name.
Definition: CLI11.h:1729
virtual void getPragmas(UT_String &pragmastr, const VOP_CodeGenContext &context)
Get compiler pragmas for thi snode.
virtual void PARMMENUOPTION(UT_String &str) const
virtual int USEBOUND() const
virtual void MENUCHOICES(UT_String &str) const
virtual void getUnboundCode(UT_String &codestr, const VOP_CodeGenContext &context)
GLuint const GLchar * name
Definition: glcorearb.h:786
virtual void setPARMSCOPE(const char *str)
virtual void PARMPOSTFIX(UT_String &str) const
virtual bool USEASPARMDEFINER() const =0
virtual void setPARMSTORAGE(int type)
virtual void setPARMTYPENAME(const UT_StringRef &type_name)
GLuint index
Definition: glcorearb.h:786
virtual void getParmDeclarationCode(UT_String &parm_decl, const VOP_CodeGenContext &codegen_ctx, const VOP_Language *language=NULL, bool export_parms=false)
virtual void PARMTYPENAME(UT_String &type_name) const
virtual void setPARMNAME(const UT_String &str)
type
Definition: core.h:1059
virtual bool getParmCanAffectParmName(int pidx) const =0
CH_ScriptLanguage
virtual int EXPORTPARM() const
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glcorearb.h:1297