35 using namespace HDK_Sample;
62 static const char *theInputRoot =
"input";
63 static const char *theOutputName =
"result";
64 static PRM_Name theSwitcherName(
"switcher",
"Switcher Index");
65 static PRM_Name theOutOfBoundsName(
"outofbounds",
66 "Out Of Bounds Behavior");
67 static PRM_Name theOutOfBoundsChoices[] =
69 PRM_Name(
"last",
"Output Last Input Value"),
79 theOutOfBoundsChoices);
127 int i,
j, next,
first = 1;
158 os <<
"if( $" << theSwitcherName.
getToken();
159 os <<
" == " << j <<
" )\n";
164 os <<
"else\n" <<
" ";
166 os <<
"$" << outputName <<
" = $" << inputName <<
";\n";
181 os <<
"else\n" <<
" ";
182 os <<
"$" << outputName <<
" = ";
183 os << const_val.
buffer() <<
";\n";
198 theLabel =
"Input Number ";
213 return "Chosen Value";
238 if( in == theSwitcherName.
getToken() )
242 if( !strncmp(in, theInputRoot, strlen(theInputRoot)) )
243 inputnum = ::atoi((
const char *)in + strlen(theInputRoot));
275 vop = CAST_VOPNODE(input->
getNode());
281 type_infos.
append(type_info);
289 type_infos.
append(type_info);
298 name = theOutputName;
335 return evalInt(theOutOfBoundsName, 0, 0.0
f);
void getOutputNameSubclass(UT_String &out, int idx) const override
void newVopOperator(OP_OperatorTable *table)
#define VOP_VARIABLE_INOUT_MAX
bool updateParmsFlags() override
PRM_API const PRM_Type PRM_ORD
SYS_FORCE_INLINE const char * buffer() const
virtual void getEmptyConstantCode(UT_String &code, const VOP_TypeInfo &type_info) const =0
An output stream object that owns its own string buffer storage.
void setType(VOP_Type type, VOP_Type raw_type=VOP_TYPE_UNDEF, const char *type_name=NULL)
void conditionType(const VOP_Language &language)
VOP_Switch(OP_Network *net, const char *name, OP_Operator *entry)
void getInputNameSubclass(UT_String &in, int idx) const override
void getInputName(UT_String &in, int idx) const override
const char * outputLabel(unsigned idx) const override
bool addOperator(OP_Operator *op, std::ostream *err=nullptr)
const char * getLabel() const
void getAllowedInputTypeInfosSubclass(unsigned idx, VOP_VopTypeInfoArray &type_infos) override
const UT_WorkBuffer & str()
Returns a read-only reference to the underlying UT_WorkBuffer.
void getOutputName(UT_String &out, int idx) const override
void getOutputTypeInfo(VOP_TypeInfo &type_info, int idx) const
virtual unsigned nInputs() const
void getOutputTypeInfoSubclass(VOP_TypeInfo &type_info, int idx) override
Fills out the info about the data type of each output connector.
PRM_API const PRM_Type PRM_INT
unsigned getNumVisibleInputs() const override
Controls the number of input buttons visible on the node tile.
const char * buffer() const
static OP_Node * myConstructor(OP_Network *net, const char *name, OP_Operator *entry)
Creates an instance of this node with the given name in the given network.
const VOP_Language * myLanguage
void getInputTypeInfoSubclass(VOP_TypeInfo &type_info, int idx) override
Fills in the info about the vop type connected to the idx-th input.
bool enableParm(int pi, int state, int v=-1)
bool updateParmsFlags() override
Disable our parameters based on which inputs are connected.
OP_Node * getInput(unsigned idx, bool mark_used=false) const
Returns the node connected to a particular input (may be null).
void harden()
Take shallow copy and make it deep.
void getCode(UT_String &codestr, const VOP_CodeGenContext &context) override
Generate the code for this operator.
unsigned orderedInputs() const override
GLuint const GLchar * name
GLenum GLenum GLsizei void * table
static int itoa(char *str, int64 i)
virtual VOP_Type conditionType(VOP_Type type) const =0
Take an arbitrary type and return the type supported by the language.
#define OP_FLAG_UNORDERED
bool getInputTypeInfoFromInputNode(VOP_TypeInfo &type_info, int idx, bool grow_inputs_to_idx=false) const
const char * inputLabel(unsigned idx) const override
Provides the labels to appear on input and output buttons.
ImageBuf OIIO_API max(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
void getInputTypeInfo(VOP_TypeInfo &type_info, int idx) const
virtual OP_Input * getInputReference(unsigned idx, bool grow)
exint evalInt(int pi, int vi, fpreal t) const
int getConnectedInputIndex(int startAt=-1) const
static PRM_Template myTemplateList[]
Our parameter templates.
PRM_API PRM_Default PRMzeroDefaults[]
static const char * theChildTableName
int getInputFromNameSubclass(const UT_String &in) const override
Reverse mapping of internal input names to an input index.
const char * getToken() const