HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OP_Utils.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: OP Library (C++)
7  *
8  * COMMENTS: Some utility functions for operators.
9  *
10  */
11 
12 #ifndef __OP_Utils_h__
13 #define __OP_Utils_h__
14 
15 #include "OP_API.h"
16 #include "OP_Node.h"
17 #include <UT/UT_Error.h>
18 #include <UT/UT_Matrix2.h>
19 #include <UT/UT_Matrix3.h>
20 #include <UT/UT_Matrix4.h>
21 #include <UT/UT_Ramp.h>
22 #include <UT/UT_Vector2.h>
23 #include <UT/UT_Vector3.h>
24 #include <UT/UT_Vector4.h>
25 #include <UT/UT_WeakPtr.h>
26 
27 class OP_NetworkBoxItem;
28 class PY_Result;
29 class UT_BitArray;
30 class UT_WorkBuffer;
31 class UT_StringArray;
32 
34  const UT_StringArray &badrefs);
36  bool checktoplevelnode,
37  UT_WorkBuffer &err);
39  bool checktoplevelnode,
40  UT_WorkBuffer &err);
41 
42 /// Looks for any nodes inside the specified operator that are defined by
43 /// VOP Networks outside the provided node. REtrns true if no such nodes
44 /// are found. Otherwise it puts an error message in the err buffer and
45 /// returns false.
47  UT_WorkBuffer &err);
49  UT_String &vopnetmask);
50 /// Adds a new vopnet mask string to the list of known vopnet context types.
51 /// This list is used to generate a VopNet Mask value when creating an HDA
52 /// from an existing subnet VOP.
54 
55 /// @{ Functions for testing whether a node parameter is used as a shader
56 /// parameter, when the node represents a shader. Some node parameters may
57 /// belong to only certain contexts (eg, surface shader), while other ones
58 /// may be just true spare parameters that are not shader parameters at all.
60 OP_API bool OPisStandInShaderParm(const PRM_Template &parm);
62  const char *context_name);
63 OP_API bool OPisLegacyShaderParm(const PRM_Template &parm, OP_Node *owner);
64 OP_API bool OPhasShaderContextTag(const PRM_Template *list,
65  int start = 0, int end = -1);
67  bool check_time_dependent = true);
68 /// @}
69 
70 /// Display UI message dialog only when inside graphical Houdini.
71 /// This is provided to avoid link dependencies against HOM.
73  const char *message,
75  bool print_when_non_graphical = true);
76 
77 OP_API OP_Node *OPfindOpInput(OP_Node *op, const char *find_op_type,
78  bool include_me = true);
79 OP_API OP_Node *OPfindOpInput(OP_Node *op, const char **find_op_types,
80  bool include_me = true);
81 
82 /// Returns coordinates specifying the smallest possible bounding box
83 /// around the items in 'items'. Takes each item's height and width into
84 /// consideration.
86  const OP_NetworkBoxItemList &items);
87 
88 /// Looks for any VOP Networks inside the specified node which define operator
89 /// types that are instantiated outside the node. If it returns false, the
90 /// badvopnets array will be filled with the VOP Networks that are used
91 /// outside the root node.
93  OP_NodeList *badvopnets);
94 
95 /// Creates a sticky note about the lack of vops inside synced HDAs, since the
96 /// children have been removed because the subnet is using cached code.
98 
99 /// Given a set of unique nodes, compute a topological ordering using only the
100 /// connectivity amongst the given nodes. If the roots are not known, then it
101 /// will be internally computed using OPmarkNodeRoots(only_picked=false).
102 /// Otherwise, the nodes will only be sorted by traversing from the given root
103 /// nodes.
106  const OP_NodeList &nodes,
107  const UT_BitArray *roots = nullptr);
108 
109 /// Given a set of nodes return a bit array indicating the nodes which are
110 /// roots WITHIN THE SET. If assume_picked is true, then it's assumed that the
111 /// node is in the set if and only if it's in the set.
113  UT_BitArray &roots,
114  const OP_NodeList &nodes,
115  bool assume_picked);
116 
117 /// Get/set/clear a default slider range override for the given parm.
118 /// Stored in node user data as a JSON dict under "sidefx::default_ranges",
119 /// e.g. {"amp": [0, 2000], "elementsize": [10, 1000]}.
121  const OP_Node &node,
122  const char *parm_token,
123  fpreal &min, fpreal &max);
125  OP_Node &node,
126  const char *parm_token,
127  fpreal min, fpreal max);
129  OP_Node &node,
130  const char *parm_token);
131 
132 namespace OP_Utils
133 {
134  // Boiler plate to load individual types from op.
135  static inline void evalOpParm(
136  int64 &v, const OP_Node *node, const char *parmname, fpreal time,
137  DEP_MicroNode *depnode)
138  {
139  if (depnode) depnode->addExplicitInput(SYSconst_cast(node)->getParm(parmname).microNode(0));
140  v = node->evalInt(parmname, 0, time);
141  }
142  static inline void evalOpParm(
143  bool &v, const OP_Node *node, const char *parmname, fpreal time,
144  DEP_MicroNode *depnode)
145  {
146  if (depnode) depnode->addExplicitInput(SYSconst_cast(node)->getParm(parmname).microNode(0));
147  v = node->evalInt(parmname, 0, time);
148  }
149  static inline void evalOpParm(
150  fpreal64 &v, const OP_Node *node, const char *parmname, fpreal time,
151  DEP_MicroNode *depnode)
152  {
153  if (depnode) depnode->addExplicitInput(SYSconst_cast(node)->getParm(parmname).microNode(0));
154  v = node->evalFloat(parmname, 0, time);
155  }
156  static inline void evalOpParm(
157  UT_Vector2D &v, const OP_Node *node, const char *parmname, fpreal time,
158  DEP_MicroNode *depnode)
159  {
160  if (depnode) depnode->addExplicitInput(SYSconst_cast(node)->getParm(parmname).microNode(0));
161  if (depnode) depnode->addExplicitInput(SYSconst_cast(node)->getParm(parmname).microNode(1));
162  v.x() = node->evalFloat(parmname, 0, time);
163  v.y() = node->evalFloat(parmname, 1, time);
164  }
165  static inline void evalOpParm(
166  UT_Vector3D &v, const OP_Node *node, const char *parmname, fpreal time,
167  DEP_MicroNode *depnode)
168  {
169  if (depnode) depnode->addExplicitInput(SYSconst_cast(node)->getParm(parmname).microNode(0));
170  if (depnode) depnode->addExplicitInput(SYSconst_cast(node)->getParm(parmname).microNode(1));
171  if (depnode) depnode->addExplicitInput(SYSconst_cast(node)->getParm(parmname).microNode(2));
172  v.x() = node->evalFloat(parmname, 0, time);
173  v.y() = node->evalFloat(parmname, 1, time);
174  v.z() = node->evalFloat(parmname, 2, time);
175  }
176  static inline void evalOpParm(
177  UT_Vector4D &v, const OP_Node *node, const char *parmname, fpreal time,
178  DEP_MicroNode *depnode)
179  {
180  if (depnode) depnode->addExplicitInput(SYSconst_cast(node)->getParm(parmname).microNode(0));
181  if (depnode) depnode->addExplicitInput(SYSconst_cast(node)->getParm(parmname).microNode(1));
182  if (depnode) depnode->addExplicitInput(SYSconst_cast(node)->getParm(parmname).microNode(2));
183  if (depnode) depnode->addExplicitInput(SYSconst_cast(node)->getParm(parmname).microNode(3));
184  v.x() = node->evalFloat(parmname, 0, time);
185  v.y() = node->evalFloat(parmname, 1, time);
186  v.z() = node->evalFloat(parmname, 2, time);
187  v.w() = node->evalFloat(parmname, 3, time);
188  }
189 
190  static inline void evalOpParm(
191  UT_Matrix2D &v, const OP_Node *node, const char *parmname, fpreal time,
192  DEP_MicroNode *depnode)
193  { for (int r = 0; r < 2; r++)
194  {
195  for (int c = 0; c < 2; c++)
196  {
197  if (depnode) depnode->addExplicitInput(SYSconst_cast(node)->getParm(parmname).microNode(r * 2 + c));
198  v(r, c) = node->evalFloat(parmname, r * 2 + c, time);
199  }
200  }
201  }
202  static inline void evalOpParm(
203  UT_Matrix3D &v, const OP_Node *node, const char *parmname, fpreal time,
204  DEP_MicroNode *depnode)
205  { for (int r = 0; r < 3; r++)
206  {
207  for (int c = 0; c < 3; c++)
208  {
209  if (depnode) depnode->addExplicitInput(SYSconst_cast(node)->getParm(parmname).microNode(r * 3 + c));
210  v(r, c) = node->evalFloat(parmname, r * 3 + c, time);
211  }
212  }
213  }
214  static inline void evalOpParm(
215  UT_Matrix4D &v, const OP_Node *node, const char *parmname, fpreal time,
216  DEP_MicroNode *depnode)
217  { for (int r = 0; r < 4; r++)
218  {
219  for (int c = 0; c < 4; c++)
220  {
221  if (depnode) depnode->addExplicitInput(SYSconst_cast(node)->getParm(parmname).microNode(r * 4 + c));
222  v(r, c) = node->evalFloat(parmname, r * 4 + c, time);
223  }
224  }
225  }
226 
227  static void inline evalOpParm(
228  UT_Vector2I &v, const OP_Node *node, const char *parmname, fpreal time,
229  DEP_MicroNode *depnode)
230  {
231  if (depnode) depnode->addExplicitInput(SYSconst_cast(node)->getParm(parmname).microNode(0));
232  if (depnode) depnode->addExplicitInput(SYSconst_cast(node)->getParm(parmname).microNode(1));
233  v.x() = node->evalInt(parmname, 0, time);
234  v.y() = node->evalInt(parmname, 1, time);
235  }
236  static void inline evalOpParm(
237  UT_Vector3I &v, const OP_Node *node, const char *parmname, fpreal time,
238  DEP_MicroNode *depnode)
239  {
240  if (depnode) depnode->addExplicitInput(SYSconst_cast(node)->getParm(parmname).microNode(0));
241  if (depnode) depnode->addExplicitInput(SYSconst_cast(node)->getParm(parmname).microNode(1));
242  if (depnode) depnode->addExplicitInput(SYSconst_cast(node)->getParm(parmname).microNode(2));
243  v.x() = node->evalInt(parmname, 0, time);
244  v.y() = node->evalInt(parmname, 1, time);
245  v.z() = node->evalInt(parmname, 2, time);
246  }
247  static void inline evalOpParm(
248  UT_Vector4I &v, const OP_Node *node, const char *parmname, fpreal time,
249  DEP_MicroNode *depnode)
250  {
251  if (depnode) depnode->addExplicitInput(SYSconst_cast(node)->getParm(parmname).microNode(0));
252  if (depnode) depnode->addExplicitInput(SYSconst_cast(node)->getParm(parmname).microNode(1));
253  if (depnode) depnode->addExplicitInput(SYSconst_cast(node)->getParm(parmname).microNode(2));
254  if (depnode) depnode->addExplicitInput(SYSconst_cast(node)->getParm(parmname).microNode(3));
255  v.x() = node->evalInt(parmname, 0, time);
256  v.y() = node->evalInt(parmname, 1, time);
257  v.z() = node->evalInt(parmname, 2, time);
258  v.w() = node->evalInt(parmname, 3, time);
259  }
260  static void inline evalOpParm(
261  UT_StringHolder &v, const OP_Node *node, const char *parmname, fpreal time,
262  DEP_MicroNode *depnode)
263  {
264  if (depnode) depnode->addExplicitInput(SYSconst_cast(node)->getParm(parmname).microNode(0));
265  UT_String result; node->evalString(result, parmname, 0, time); v.adoptFromString(result);
266  }
267  static void inline evalOpParmRaw(
268  UT_StringHolder &v, const OP_Node *node, const char *parmname, fpreal time,
269  DEP_MicroNode *depnode)
270  {
271  if (depnode) depnode->addExplicitInput(SYSconst_cast(node)->getParm(parmname).microNode(0));
272  UT_String result; node->evalStringRaw(result, parmname, 0, time); v.adoptFromString(result);
273  }
274  static void inline evalOpParm(
275  UT_SharedPtr<UT_Ramp> &v, const OP_Node *node, const char *parmname, fpreal time,
276  DEP_MicroNode *depnode)
277  {
278  v.reset(new UT_Ramp());
279 
280  if (node->hasParm(parmname))
281  node->updateRampFromMultiParm(time, node->getParm(parmname), *v, 0, depnode);
282  }
283  static void inline evalOpParm(
284  PRM_DataItemHandle &v, const OP_Node *node, const char *parmname, fpreal time,
285  DEP_MicroNode *depnode)
286  {
287  if (depnode) depnode->addExplicitInput(SYSconst_cast(node)->getParm(parmname).microNode(0));
288  v = node->evalData(parmname, 0, time);
289  }
290 
291 
292  static void inline evalOpParmInst(
293  int64 &v, const OP_Node *node, const char *parmname,
294  const int *inst, fpreal time,
295  DEP_MicroNode *depnode,
296  int nestlevel=1)
297  {
298  if (depnode) depnode->addExplicitInput(SYSconst_cast(node)->getParmPtrInst(parmname, inst, nestlevel)->microNode(0));
299  v = node->evalIntInst(parmname, inst, 0, time, nestlevel);
300  }
301  static void inline evalOpParmInst(
302  bool &v, const OP_Node *node, const char *parmname,
303  const int *inst, fpreal time,
304  DEP_MicroNode *depnode,
305  int nestlevel=1)
306  {
307  if (depnode) depnode->addExplicitInput(SYSconst_cast(node)->getParmPtrInst(parmname, inst, nestlevel)->microNode(0));
308  v = node->evalIntInst(parmname, inst, 0, time, nestlevel);
309  }
310  static void inline evalOpParmInst(
311  fpreal64 &v, const OP_Node *node, const char *parmname,
312  const int *inst, fpreal time,
313  DEP_MicroNode *depnode,
314  int nestlevel=1)
315  {
316  if (depnode) depnode->addExplicitInput(SYSconst_cast(node)->getParmPtrInst(parmname, inst, nestlevel)->microNode(0));
317  v = node->evalFloatInst(parmname, inst, 0, time, nestlevel);
318  }
319  static void inline evalOpParmInst(
320  UT_Vector2D &v, const OP_Node *node, const char *parmname,
321  const int *inst, fpreal time,
322  DEP_MicroNode *depnode,
323  int nestlevel=1)
324  {
325  if (depnode) depnode->addExplicitInput(SYSconst_cast(node)->getParmPtrInst(parmname, inst, nestlevel)->microNode(0));
326  if (depnode) depnode->addExplicitInput(SYSconst_cast(node)->getParmPtrInst(parmname, inst, nestlevel)->microNode(1));
327  v.x() = node->evalFloatInst(parmname, inst, 0, time, nestlevel);
328  v.y() = node->evalFloatInst(parmname, inst, 1, time, nestlevel);
329  }
330  static void inline evalOpParmInst(
331  UT_Vector3D &v, const OP_Node *node, const char *parmname,
332  const int *inst, fpreal time,
333  DEP_MicroNode *depnode,
334  int nestlevel=1)
335  {
336  if (depnode) depnode->addExplicitInput(SYSconst_cast(node)->getParmPtrInst(parmname, inst, nestlevel)->microNode(0));
337  if (depnode) depnode->addExplicitInput(SYSconst_cast(node)->getParmPtrInst(parmname, inst, nestlevel)->microNode(1));
338  if (depnode) depnode->addExplicitInput(SYSconst_cast(node)->getParmPtrInst(parmname, inst, nestlevel)->microNode(2));
339  v.x() = node->evalFloatInst(parmname, inst, 0, time, nestlevel);
340  v.y() = node->evalFloatInst(parmname, inst, 1, time, nestlevel);
341  v.z() = node->evalFloatInst(parmname, inst, 2, time, nestlevel);
342  }
343  static void inline evalOpParmInst(
344  UT_Vector4D &v, const OP_Node *node, const char *parmname,
345  const int *inst, fpreal time,
346  DEP_MicroNode *depnode,
347  int nestlevel=1)
348  {
349  if (depnode) depnode->addExplicitInput(SYSconst_cast(node)->getParmPtrInst(parmname, inst, nestlevel)->microNode(0));
350  if (depnode) depnode->addExplicitInput(SYSconst_cast(node)->getParmPtrInst(parmname, inst, nestlevel)->microNode(1));
351  if (depnode) depnode->addExplicitInput(SYSconst_cast(node)->getParmPtrInst(parmname, inst, nestlevel)->microNode(2));
352  if (depnode) depnode->addExplicitInput(SYSconst_cast(node)->getParmPtrInst(parmname, inst, nestlevel)->microNode(3));
353  v.x() = node->evalFloatInst(parmname, inst, 0, time, nestlevel);
354  v.y() = node->evalFloatInst(parmname, inst, 1, time, nestlevel);
355  v.z() = node->evalFloatInst(parmname, inst, 2, time, nestlevel);
356  v.w() = node->evalFloatInst(parmname, inst, 3, time, nestlevel);
357  }
358 
359  static void inline evalOpParmInst(
360  UT_Matrix2D &v, const OP_Node *node, const char *parmname,
361  const int *inst, fpreal time,
362  DEP_MicroNode *depnode,
363  int nestlevel=1)
364  { for (int r = 0; r < 2; r++)
365  {
366  for (int c = 0; c < 2; c++)
367  {
368  if (depnode) depnode->addExplicitInput(SYSconst_cast(node)->getParmPtrInst(parmname, inst, nestlevel)->microNode(r * 2 + c));
369  v(r, c) = node->evalFloatInst(parmname, inst, r * 2 + c, time, nestlevel);
370  }
371  }
372  }
373  static void inline evalOpParmInst(
374  UT_Matrix3D &v, const OP_Node *node, const char *parmname,
375  const int *inst, fpreal time,
376  DEP_MicroNode *depnode,
377  int nestlevel=1)
378  { for (int r = 0; r < 3; r++)
379  {
380  for (int c = 0; c < 3; c++)
381  {
382  if (depnode) depnode->addExplicitInput(SYSconst_cast(node)->getParmPtrInst(parmname, inst, nestlevel)->microNode(r * 3 + c));
383  v(r, c) = node->evalFloatInst(parmname, inst, r * 3 + c, time, nestlevel);
384  }
385  }
386  }
387  static void inline evalOpParmInst(
388  UT_Matrix4D &v, const OP_Node *node, const char *parmname,
389  const int *inst, fpreal time,
390  DEP_MicroNode *depnode,
391  int nestlevel=1)
392  { for (int r = 0; r < 4; r++)
393  {
394  for (int c = 0; c < 4; c++)
395  {
396  if (depnode) depnode->addExplicitInput(SYSconst_cast(node)->getParmPtrInst(parmname, inst, nestlevel)->microNode(r * 4 + c));
397  v(r, c) = node->evalFloatInst(parmname, inst, r * 4 + c, time, nestlevel);
398  }
399  }
400  }
401 
402  static void inline evalOpParmInst(
403  UT_Vector2I &v, const OP_Node *node, const char *parmname,
404  const int *inst, fpreal time,
405  DEP_MicroNode *depnode,
406  int nestlevel=1)
407  {
408  if (depnode) depnode->addExplicitInput(SYSconst_cast(node)->getParmPtrInst(parmname, inst, nestlevel)->microNode(0));
409  if (depnode) depnode->addExplicitInput(SYSconst_cast(node)->getParmPtrInst(parmname, inst, nestlevel)->microNode(1));
410  v.x() = node->evalIntInst(parmname, inst, 0, time, nestlevel);
411  v.y() = node->evalIntInst(parmname, inst, 1, time, nestlevel);
412  }
413  static void inline evalOpParmInst(
414  UT_Vector3I &v, const OP_Node *node, const char *parmname,
415  const int *inst, fpreal time,
416  DEP_MicroNode *depnode,
417  int nestlevel=1)
418  {
419  if (depnode) depnode->addExplicitInput(SYSconst_cast(node)->getParmPtrInst(parmname, inst, nestlevel)->microNode(0));
420  if (depnode) depnode->addExplicitInput(SYSconst_cast(node)->getParmPtrInst(parmname, inst, nestlevel)->microNode(1));
421  if (depnode) depnode->addExplicitInput(SYSconst_cast(node)->getParmPtrInst(parmname, inst, nestlevel)->microNode(2));
422  v.x() = node->evalIntInst(parmname, inst, 0, time, nestlevel);
423  v.y() = node->evalIntInst(parmname, inst, 1, time, nestlevel);
424  v.z() = node->evalIntInst(parmname, inst, 2, time, nestlevel);
425  }
426  static void inline evalOpParmInst(
427  UT_Vector4I &v, const OP_Node *node, const char *parmname,
428  const int *inst, fpreal time,
429  DEP_MicroNode *depnode,
430  int nestlevel=1)
431  {
432  if (depnode) depnode->addExplicitInput(SYSconst_cast(node)->getParmPtrInst(parmname, inst, nestlevel)->microNode(0));
433  if (depnode) depnode->addExplicitInput(SYSconst_cast(node)->getParmPtrInst(parmname, inst, nestlevel)->microNode(1));
434  if (depnode) depnode->addExplicitInput(SYSconst_cast(node)->getParmPtrInst(parmname, inst, nestlevel)->microNode(2));
435  if (depnode) depnode->addExplicitInput(SYSconst_cast(node)->getParmPtrInst(parmname, inst, nestlevel)->microNode(3));
436  v.x() = node->evalIntInst(parmname, inst, 0, time, nestlevel);
437  v.y() = node->evalIntInst(parmname, inst, 1, time, nestlevel);
438  v.z() = node->evalIntInst(parmname, inst, 2, time, nestlevel);
439  v.w() = node->evalIntInst(parmname, inst, 3, time, nestlevel);
440  }
441 
442  static void inline evalOpParmInst(
443  UT_StringHolder &v, const OP_Node *node, const char *parmname,
444  const int *inst, fpreal time,
445  DEP_MicroNode *depnode,
446  int nestlevel=1)
447  {
448  UT_String result; node->evalStringInst(parmname, inst, result, 0, time, nestlevel); v.adoptFromString(result);
449  if (depnode) depnode->addExplicitInput(SYSconst_cast(node)->getParmPtrInst(parmname, inst, nestlevel)->microNode(0));
450  }
451  static void inline evalOpParmInst(
452  UT_SharedPtr<UT_Ramp> &v, const OP_Node *node, const char *parmname,
453  const int *inst, fpreal time,
454  DEP_MicroNode *depnode,
455  int nestlevel=1)
456  {
457  v.reset(new UT_Ramp());
458 
459  const PRM_Parm *rampparm = node->getParmList()->getParmPtrInst(parmname, inst, nestlevel);
460  if (rampparm)
461  node->updateRampFromMultiParm(time, *rampparm, *v, 0, depnode);
462  }
463  static void inline evalOpParmInst(
464  PRM_DataItemHandle &v, const OP_Node *node, const char *parmname,
465  const int *inst, fpreal time,
466  DEP_MicroNode *depnode,
467  int nestlevel=1)
468  {
469  if (depnode) depnode->addExplicitInput(SYSconst_cast(node)->getParmPtrInst(parmname, inst, nestlevel)->microNode(0));
470  v = node->evalDataInst(parmname, inst, 0, time, nestlevel);
471  }
472 
473  // Callback class to receive the results of an OP python callback
474  // or script evaluation. Clients must implement this interface and
475  // register with registerPythonResultClient to be notified.
476  // See registerPythonResultClient, notifyPythonResultClients
478  {
479  public:
481 
482  PythonResultClient() = default;
483  virtual ~PythonResultClient() = default;
484 
485  // results: Python result structure.
486  // script_source: The script source e.g. OpInstall
487  // script_path: The script file path or a reference to the
488  // embedded node e.g. opdef:/Object/mynode?OnInstall
489  virtual void onNotifyOPPythonResult(PY_Result const & result, char const * script_source, char const * script_path) = 0;
490  };
491 
492  // Registers a client interested in the OP python script evaluation results.
494 
495  // Notifies registered PythonResultClient objects about the result of a
496  // OP python script evaluation.
497  OP_API void notifyPythonResultClients(PY_Result const & result, char const * script_source, char const * script_path);
498 }
499 
500 // Templated function to follow channel references using parameter names
501 // and call an fn() lambda on the new parameter, or the original one.
502 // Unlike OP_Parameters::followChannelReferences, the arguments owner and pn
503 // are read-only.
504 // Returns true if a channel was followed or false if it wasn't.
505 // fn(bool followed, T* newowner, const UT_StringHolder &pn)
506 template <typename FN, typename T>
507 bool
509  T *owner, const UT_StringHolder &pn, FN &&fn)
510 {
511  auto op = dynamic_cast<OP_Node*>(owner);
512 
513  // Not an OP_Node, can't have channel references.
514  if (!op)
515  {
516  fn(false, owner, pn);
517  return false;
518  }
519 
520  PRM_ParmList *plist = op->getParmList();
521  int vi = -1;
522  int pi = plist->getParmIndex(pn, vi);
523  UT_ASSERT(pi>=0 && vi>=0);
524  PRM_Parm *parm = plist->getParmPtr(pi);
525  if (!parm)
526  {
527  fn(false, owner, pn);
528  return false;
529  }
530 
531  OP_Node *newop = op;
532  PRM_Parm *newparm = parm;
533  int newvecidx = vi;
534  OP_Parameters::followChannelReferences(opt, newop, newparm, newvecidx);
535  if (newop==op && newparm==parm && newvecidx==vi)
536  {
537  fn(false, owner, pn);
538  return false;
539  }
540 
541  UT_StringHolder newpn = newparm->getChannelToken(newvecidx);
542  T *newowner = (T*)newop;
543  fn(true, newowner, newpn);
544  return true;
545 }
546 
547 #endif
GLuint GLsizei const GLchar * message
Definition: glcorearb.h:2543
void adoptFromString(UT_String &str)
OP_API void OPmarkRootNodes(UT_BitArray &roots, const OP_NodeList &nodes, bool assume_picked)
PRM_Parm * getParmPtr(const UT_StringRef &theparmname, int &theparmidx)
OP_API bool OPconvertOrWarnExternalReferences(OP_Node *node, bool checktoplevelnode, UT_WorkBuffer &err)
OP_API OP_Node * OPfindOpInput(OP_Node *op, const char *find_op_type, bool include_me=true)
OP_API void OPaddVopSubnetMask(const UT_StringRef &name)
GT_API const UT_StringHolder time
constexpr SYS_FORCE_INLINE T & y() noexcept
Definition: UT_Vector4.h:495
const GLdouble * v
Definition: glcorearb.h:837
void addExplicitInput(DEP_MicroNode &inp, bool check_dup)
Methods for manipulating explicit edges.
GLuint start
Definition: glcorearb.h:475
SYS_FORCE_INLINE T * SYSconst_cast(const T *foo)
Definition: SYS_Types.h:136
constexpr SYS_FORCE_INLINE T & z() noexcept
Definition: UT_Vector3.h:669
fpreal evalFloat(int pi, int vi, fpreal t) const
UT_ErrorSeverity
Definition: UT_Error.h:25
OP_API void OPclearDefaultParmRange(OP_Node &node, const char *parm_token)
void getChannelToken(UT_String &thestrref, int index=0) const
ImageBuf OIIO_API min(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
**But if you need a result
Definition: thread.h:622
OP_API void OPdisplayUIMessage(const char *message, UT_ErrorSeverity severity=UT_ERROR_MESSAGE, bool print_when_non_graphical=true)
bool OPfollowChannelRefFn(const OP_FollowChanRefsOptions &opt, T *owner, const UT_StringHolder &pn, FN &&fn)
Definition: OP_Utils.h:508
OP_API bool OPconvertOrWarnExternalOverrides(OP_Node *node, bool checktoplevelnode, UT_WorkBuffer &err)
GLdouble GLdouble x2
Definition: glad.h:2349
constexpr SYS_FORCE_INLINE T & x() noexcept
Definition: UT_Vector4.h:493
OP_API bool OPisStandInShaderParm(const PRM_Template &parm)
double fpreal64
Definition: SYS_Types.h:201
UT_SharedPtr< const PRM_DataItem > PRM_DataItemHandle
Definition: APEX_Include.h:55
constexpr SYS_FORCE_INLINE T & x() noexcept
Definition: UT_Vector2.h:426
PRM_Parm & getParm(int i)
OP_API bool OPmatchesShaderContextTag(const PRM_Template &parm, const char *context_name)
std::shared_ptr< T > UT_SharedPtr
Wrapper around std::shared_ptr.
Definition: UT_SharedPtr.h:36
constexpr SYS_FORCE_INLINE T & z() noexcept
Definition: UT_Vector4.h:497
void evalString(UT_String &val, int pi, int vi, fpreal t) const
OP_API void OPgetVopSubnetMask(OP_Node *node, UT_String &vopnetmask)
PRM_DataItemHandle evalDataInst(const UT_StringRef &name, const int *inst, int vi, fpreal t, int nestlevel=1) const
GLuint GLuint end
Definition: glcorearb.h:475
OP_API void OPtopologicalSort(UT_IntArray &order, const OP_NodeList &nodes, const UT_BitArray *roots=nullptr)
GLdouble y1
Definition: glad.h:2349
OP_API bool OPgetDefaultParmRange(const OP_Node &node, const char *parm_token, fpreal &min, fpreal &max)
GLdouble GLdouble GLint GLint order
Definition: glad.h:2676
long long int64
Definition: SYS_Types.h:116
OP_API bool OPhasShaderContextTag(const PRM_Template *list, int start=0, int end=-1)
OP_API bool OPisPotentialShaderParm(const PRM_Template &parm)
OP_API void notifyPythonResultClients(PY_Result const &result, char const *script_source, char const *script_path)
fpreal evalFloatInst(const UT_StringRef &name, const int *inst, int vi, fpreal t, int nestlevel=1) const
GLenum GLenum severity
Definition: glcorearb.h:2539
GLuint const GLchar * name
Definition: glcorearb.h:786
PRM_DataItemHandle evalData(int pi, int vi, fpreal t) const
OP_API bool OPcheckForVopnetDefinedNodes(OP_Node *node, UT_WorkBuffer &err)
void evalStringRaw(UT_String &val, int pi, int vi, fpreal t) const
static void followChannelReferences(const OP_FollowChanRefsOptions &opt, OP_Node *&newop, PRM_Parm *&newparm, int &newvecidx)
OP_API void OPcreateStickyNoteAboutCachedCode(OP_Network *subnet)
void evalStringInst(const UT_StringRef &name, const int *inst, UT_String &val, int vi, fpreal t, int nestlevel=1) const
OP_API bool OPisLegacyShaderParm(const PRM_Template &parm, OP_Node *owner)
__hostdev__ constexpr T pi()
Pi constant taken from Boost to match old behaviour.
Definition: NanoVDB.h:976
fpreal64 fpreal
Definition: SYS_Types.h:283
OP_API bool OPisShaderParmAtDefaultValue(const PRM_Parm &parm, bool check_time_dependent=true)
Utility class for containing a color ramp.
Definition: UT_Ramp.h:96
#define OP_API
Definition: OP_API.h:10
void updateRampFromMultiParm(fpreal t, const PRM_Parm &m, UT_Ramp &ramp, bool *time_dep=nullptr, DEP_MicroNode *depnode=nullptr) const
constexpr SYS_FORCE_INLINE T & w() noexcept
Definition: UT_Vector4.h:499
ImageBuf OIIO_API max(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
OP_API void OPwarnBadRefs(UT_WorkBuffer &msg, const UT_StringArray &badrefs)
UT_WeakPtr< PythonResultClient > WPtr
Definition: OP_Utils.h:480
OP_API void registerPythonResultClient(PythonResultClient::WPtr result_client)
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:165
exint evalInt(int pi, int vi, fpreal t) const
GLboolean r
Definition: glcorearb.h:1222
exint evalIntInst(const UT_StringRef &name, const int *inst, int vi, fpreal t, int nestlevel=1) const
int getParmIndex(const PRM_Parm *parm) const
GLdouble GLdouble GLdouble y2
Definition: glad.h:2349
OP_API void OPsetDefaultParmRange(OP_Node &node, const char *parm_token, fpreal min, fpreal max)
PRM_Parm * getParmPtrInst(const UT_StringRef &parm_name, const int *instance, int nest_level)
Definition: PRM_ParmList.h:468
constexpr SYS_FORCE_INLINE T & y() noexcept
Definition: UT_Vector3.h:667
SYS_FORCE_INLINE PRM_ParmList * getParmList()
Definition: PRM_ParmOwner.h:73
OP_API void OPgetItemBounds(fpreal &x1, fpreal &y1, fpreal &x2, fpreal &y2, const OP_NetworkBoxItemList &items)
OP_API bool OPcheckForVopnetsUsedOutside(OP_Node *node, OP_NodeList *badvopnets)
std::weak_ptr< T > UT_WeakPtr
Definition: UT_SharedPtr.h:49
constexpr SYS_FORCE_INLINE T & y() noexcept
Definition: UT_Vector2.h:428
bool hasParm(const UT_StringRef &name) const
constexpr SYS_FORCE_INLINE T & x() noexcept
Definition: UT_Vector3.h:665