HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CHOP_Stair.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2024
3  * Side Effects Software Inc. All rights reserved.
4  *
5  * Redistribution and use of Houdini Development Kit samples in source and
6  * binary forms, with or without modification, are permitted provided that the
7  * following conditions are met:
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  * 2. The name of Side Effects Software may not be used to endorse or
11  * promote products derived from this software without specific prior
12  * written permission.
13  *
14  * THIS SOFTWARE IS PROVIDED BY SIDE EFFECTS SOFTWARE `AS IS' AND ANY EXPRESS
15  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
17  * NO EVENT SHALL SIDE EFFECTS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
18  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
19  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
20  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
21  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
23  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  *
25  *----------------------------------------------------------------------------
26  */
27 
28 #ifndef __CHOP_Stair__
29 #define __CHOP_Stair__
30 
31 #include <CHOP/CHOP_Node.h>
32 #include <UT/UT_ExpandArray.h>
33 
34 namespace HDK_Sample {
35 
36 #define ARG_STAIR_NUMBER "number"
37 #define ARG_STAIR_HEIGHT "height"
38 #define ARG_STAIR_OFFSET "offset"
39 #define ARG_STAIR_DIRECTION "direction"
40 
41 #define ARG_STAIR_NAME "channelname"
42 #define ARG_STAIR_RANGE CHOP_RangeName.getToken()
43 #define ARG_STAIR_START "start"
44 #define ARG_STAIR_END "end"
45 #define ARG_STAIR_RATE CHOP_SampleRateName.getToken()
46 #define ARG_STAIR_LEFT CHOP_ExtendLeftName.getToken()
47 #define ARG_STAIR_RIGHT CHOP_ExtendRightName.getToken()
48 #define ARG_STAIR_DEFAULT CHOP_DefaultValueName.getToken()
49 
50 class CHOP_Stair : public CHOP_Node
51 {
52 public:
53 
54 
55  static OP_Node *myConstructor(OP_Network*, const char *,
56  OP_Operator *);
61 
62  /// Overridden to generate our channel data
63  OP_ERROR cookMyChop(OP_Context &context) override;
64 
65  /// Places the handles along the channels
66  void cookMyHandles(OP_Context &context) override;
67 
68  bool updateParmsFlags() override;
69 
70  /// Responds to user changes in any handle
72  CHOP_HandleData *hdata) override;
73 
74  fpreal shiftStart(fpreal new_offset,
75  fpreal t) override;
76 
77 protected:
78 
79  CHOP_Stair(OP_Network *net,
80  const char *name, OP_Operator *op);
81  ~CHOP_Stair() override;
82 
83  /// Returns true because we use the Units parameter.
84  int usesUnits() override { return 1; }
85 
86  /// Returns true because we want to use the Scope parameter
87  int usesScope() const override { return 0; }
88 
89  /// Stair has some local variables defined, this returns their value.
90  bool evalVariableValue(fpreal &v, int index,
91  int thread) override;
92  // Add virtual overload that delegates to the super class to avoid
93  // shadow warnings.
95  int thread) override
96  {
98  v, i, thread);
99  }
100 
101 private:
102 
103  /// @{
104  /// Convenience parameter evaluation functions
105  int NUMBER(fpreal t)
106  { return evalInt(ARG_STAIR_NUMBER, 0, t); }
107 
108  void SET_NUMBER(fpreal t, int v)
109  { setInt(ARG_STAIR_NUMBER, 0, t, v); }
110 
111  fpreal HEIGHT(fpreal t)
112  { return evalFloat(ARG_STAIR_HEIGHT, 0, t); }
113 
114  void SET_HEIGHT(fpreal t, fpreal v)
115  { setFloat(ARG_STAIR_HEIGHT, 0, t, v); }
116 
117  fpreal OFFSET(fpreal t)
118  { return evalFloat(ARG_STAIR_OFFSET, 0, t); }
119 
120  void SET_OFFSET(fpreal t, fpreal v)
121  { setFloat(ARG_STAIR_OFFSET, 0, t, v); }
122 
123  int DIRECTION()
124  { return evalInt(ARG_STAIR_DIRECTION, 0, 0); }
125 
126  void CHAN_NAME(UT_String &label, fpreal t)
127  { evalString(label, ARG_STAIR_NAME, 0, t); }
128 
129  int RANGE(fpreal t)
130  { return evalInt(ARG_STAIR_RANGE, 0, t); }
131 
132  void SET_START(fpreal t, fpreal f)
133  { setFloat(ARG_STAIR_START, 0, t, toUnit(f)); }
134 
135  void SET_END(fpreal t, fpreal f)
136  { setFloat(ARG_STAIR_END, 0, t, toUnit(f, UNITS(), 1)); }
137 
138  fpreal RATE(fpreal t) { return evalFloat(ARG_STAIR_RATE, 0, t); }
139 
140  void SET_RATE(fpreal t, fpreal v)
141  { setFloat(ARG_STAIR_RATE, 0, t, v); }
142 
143  int LEXTEND() { return evalInt(ARG_STAIR_LEFT, 0, 0); }
144  int REXTEND() { return evalInt(ARG_STAIR_RIGHT, 0, 0); }
145  fpreal DEFAULT(fpreal t) { return evalFloat(ARG_STAIR_DEFAULT,0,t); }
146  /// @}
147 
148  void getInterval(fpreal t, fpreal *start, fpreal *end);
149 
150  /// Our local variable for "currently cooking channel"
151  int my_C;
152  /// Our local variable for "number of channels"
153  int my_NC;
154 
155  UT_ExpandArray myExpandArray;
156 };
157 
158 } // End of HDK_Sample namespace
159 
160 #endif
161 
void cookMyHandles(OP_Context &context) override
Places the handles along the channels.
Definition: CHOP_Stair.C:190
#define ARG_STAIR_DIRECTION
Definition: CHOP_Stair.h:39
GLuint GLsizei const GLchar * label
Definition: glcorearb.h:2545
int usesUnits() override
Returns true because we use the Units parameter.
Definition: CHOP_Stair.h:84
static CH_LocalVariable myVariableList[]
Definition: CHOP_Stair.h:60
static OP_TemplatePair myTemplatePair
Definition: CHOP_Stair.h:57
static OP_VariablePair myVariablePair
Definition: CHOP_Stair.h:58
const GLdouble * v
Definition: glcorearb.h:837
GLuint start
Definition: glcorearb.h:475
OP_ERROR cookMyChop(OP_Context &context) override
Overridden to generate our channel data.
Definition: CHOP_Stair.C:286
CL_Unit UNITS() const
Definition: CHOP_Node.h:570
#define ARG_STAIR_OFFSET
Definition: CHOP_Stair.h:38
fpreal evalFloat(int pi, int vi, fpreal t) const
UT_ErrorSeverity
Definition: UT_Error.h:25
#define ARG_STAIR_END
Definition: CHOP_Stair.h:44
int usesScope() const override
Returns true because we want to use the Scope parameter.
Definition: CHOP_Stair.h:87
#define ARG_STAIR_START
Definition: CHOP_Stair.h:43
#define ARG_STAIR_DEFAULT
Definition: CHOP_Stair.h:48
bool evalVariableValue(fpreal &v, int index, int thread) override
Stair has some local variables defined, this returns their value.
Definition: CHOP_Stair.C:128
fpreal shiftStart(fpreal new_offset, fpreal t) override
Definition: CHOP_Stair.C:279
#define ARG_STAIR_NUMBER
Definition: CHOP_Stair.h:36
GLfloat f
Definition: glcorearb.h:1926
#define ARG_STAIR_RIGHT
Definition: CHOP_Stair.h:47
fpreal handleChanged(CHOP_Handle *handle, CHOP_HandleData *hdata) override
Responds to user changes in any handle.
Definition: CHOP_Stair.C:238
void evalString(UT_String &val, int pi, int vi, fpreal t) const
#define ARG_STAIR_RANGE
Definition: CHOP_Stair.h:42
GLuint GLuint end
Definition: glcorearb.h:475
#define ARG_STAIR_NAME
Definition: CHOP_Stair.h:41
GLuint const GLchar * name
Definition: glcorearb.h:786
#define ARG_STAIR_RATE
Definition: CHOP_Stair.h:45
bool updateParmsFlags() override
Definition: CHOP_Stair.C:168
GLdouble t
Definition: glad.h:2397
~CHOP_Stair() override
Definition: CHOP_Stair.C:163
**Note that the tasks the is the thread number *for the or if it s being executed by a non pool thread(this *can happen in cases where the whole pool is occupied and the calling *thread contributes to running the work load).**Thread pool.Have fun
void setFloat(int parmi, int vectori, fpreal t, fpreal value, PRM_AddKeyType add_key=PRM_AK_MARK_PENDING)
fpreal64 fpreal
Definition: SYS_Types.h:277
void setInt(int parmi, int vectori, fpreal t, exint value)
static OP_Node * myConstructor(OP_Network *, const char *, OP_Operator *)
Definition: CHOP_Stair.C:145
GLuint index
Definition: glcorearb.h:786
virtual bool evalVariableValue(UT_String &val, int index, int thread)
CHOP_Stair(OP_Network *net, const char *name, OP_Operator *op)
Definition: CHOP_Stair.C:152
#define ARG_STAIR_HEIGHT
Definition: CHOP_Stair.h:37
exint evalInt(int pi, int vi, fpreal t) const
bool evalVariableValue(UT_String &v, int i, int thread) override
Definition: CHOP_Stair.h:94
#define ARG_STAIR_LEFT
Definition: CHOP_Stair.h:46
static PRM_Template myTemplateList[]
Definition: CHOP_Stair.h:59
fpreal toUnit(fpreal index, CL_Unit unit=UNIT_NONE, int end_width=0) const