HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
VOP_SubnetBase.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  * COMMENTS: The base class for all subnet VOP operators
9  *
10  */
11 
12 #ifndef __VOP_SubnetBase_h__
13 #define __VOP_SubnetBase_h__
14 
15 #include "VOP_API.h"
16 #include "VOP_Node.h"
18 #include <UT/UT_StringArray.h>
19 
20 class VOP_SubnetHelper;
21 
23 {
24 public:
26 
27  virtual void getCode(UT_String &codestr,
28  const VOP_CodeGenContext &context);
29 
30  virtual const char *inputLabel(unsigned idx) const;
31  virtual const char *outputLabel(unsigned idx) const;
32 
33  virtual unsigned getNumVisibleInputs() const;
34  unsigned getNumRealInputs() const;
35  virtual unsigned getNumVisibleOutputs() const;
36  virtual unsigned orderedInputs() const;
37 
38  virtual void getNodeSpecificInfoText(OP_Context &context,
39  OP_NodeInfoParms &iparms);
40 
41  // When one of our inputs changes, we may want to rearrange things on
42  // our subnet input and subnet output nodes.
43  virtual OP_ERROR setInput(unsigned idx, OP_Node *op,
44  unsigned outputIdx = 0);
45  virtual OP_ERROR setInputReference(unsigned idx, const char *label,
46  int keeppos, unsigned outputIdx = 0);
47  virtual OP_ERROR setNamedInput(const OP_ConnectorId& input_name, OP_Node *op,
48  const OP_ConnectorId* output_name = NULL);
49  virtual OP_ERROR setNamedInputReference(const OP_ConnectorId& input_name,
50  const char *label, int, const OP_ConnectorId* output_name = NULL);
51 
52 
53  virtual bool isConnected(int inputidx, bool recursive);
54 
55  virtual const VOP_SubnetBase *castToSubnetBase() const { return this; }
56  virtual VOP_SubnetBase *castToSubnetBase() { return this; }
57 
58  virtual bool forceCodeGenerationOfInputs(
59  const VOP_CodeGenContext &context,
60  bool check_shader_context) const;
61  bool getIsAdjustForInputChanged(void);
62 
64  bool create_if_needed=false);
65 
66  static const char *theChildTableName;
67 
68 protected:
69  VOP_SubnetBase(OP_Network *parent, const char *name, OP_Operator *entry);
70  virtual ~VOP_SubnetBase();
71 
72  virtual bool updateParmsFlags();
73  virtual bool shouldShowInputNext() const;
77  virtual void beginLoadingInNetwork();
78  virtual void endLoadingInNetwork();
79  virtual void loadStart();
80  virtual void finishedLoadingNetwork(bool is_child_call=false);
81  virtual void setupConnectorsAfterLoad();
82  virtual void addNode(OP_Node *node, int notify=1, int explicitly=1);
83 
84  /// Inherited from VOP_Node.
85  /// Generate the node errors.
86  /// Return true if an error was generated and false otherwise.
87  virtual bool generateErrorsSubclass();
88 
89  virtual void preOpChanged(OP_EventType reason, void *data);
90  virtual void postOpChanged(OP_EventType reason, void *data);
91 
92  /// @{ Methods for handling inputs defined by a parm vop children
93  void handleChildAdd( OP_Node *child );
94  void handleChildDelete( OP_Node *child );
95  void handleDescendentAdd( VOP_Node *descendent );
96  void handleDescendentDelete( VOP_Node *descendent );
97  static void handleParmNodeChange(OP_Node *caller, void *callee,
98  OP_EventType type, void *);
99  void updateConnectorDefiner( VOP_Node *node );
100  virtual void shaderParmGrandChildAdded(VOP_Node *grand_child);
101  virtual void shaderParmGrandChildDeleted(VOP_Node *grand_child);
102  virtual void shaderParmGrandChildChanged(VOP_Node *grand_child);
103  void setupConnectorDefinersAfterLoadIfNeeded();
104  void setupConnectorDefinersAfterLoad();
105  void addConnectorDefinerAfterLoad(VOP_ParmGenerator *pg);
106  /// @}
107 
108  virtual void getInternalInputName(UT_String &in, int idx) const;
109 
110  virtual int getNumDefinedInputs() const;
111  virtual void getDefinedInputDefault(UT_String &def, int idx) const;
112  virtual void getInputDefaultValue(UT_String &def, int idx) const;
113 
114  virtual void getInputNameSubclass(UT_String &in, int idx) const;
115  virtual int getInputFromNameSubclass(const UT_String &in) const;
116  virtual void getInputTypeInfoSubclass(
117  VOP_TypeInfo &type_info, int idx);
118  virtual void getAllowedInputTypesSubclass(unsigned idx,
119  VOP_VopTypeArray &voptypes);
120  virtual bool allowConsolidatingInput(int idx);
121 
122  /// Invalidates the cached list of contained shaders.
123  virtual void dirtyShaderList();
124 
125  /// Number of extra outputs a subnet subclass may want to provide, in
126  /// addition to outputs defined by this base class (and sub output child).
127  virtual int getNumCustomOutputs() const;
128 
129  /// Number of extra outputs on the subnet node in addition to the
130  /// outputs defined by the Subnet Output child vop inside.
131  virtual int getNumNodeDefinedOutputs() const;
132  virtual int getNumSubnetInputsForChildren() const;
133  virtual int getSubnetInputIndexForChildren(int index) const;
134  virtual void getOutputNameSubclass(UT_String &out, int idx) const;
135  virtual void getOutputTypeInfoSubclass(VOP_TypeInfo &type_info,
136  int idx);
138  VOP_Type shader_type);
139  virtual UT_StringHolder getShaderLayerExportsToAdd(int out_idx,
140  VOP_Type shader_type);
141 
142  /// Returns true if output of a given index has an input by the same name.
143  bool hasCorrespondingInput(int output_idx) const;
144 
145  virtual bool isInputConnectedInsideSubnet(int input_idx) const;
146  virtual bool isNamedInputConnectedInsideSubnet(const OP_ConnectorId& input_name) const;
147 
148  /// Subnet declares own variables, so some types may need to be defined.
150 
151  /// Virtuals for handling input order editing.
152  virtual int getInputEditorInputs();
153  virtual bool getInputEditorInputLabel( UT_String &label, int idx );
154  virtual void moveInput(int srcidx, int dstidx,
155  bool forcesubnet = false);
156  virtual void doDeleteInput(int idx);
157 
158 
160  {
163  .requiresUpdate(0.0))
164  {
167  }
168  }
169 
170 private:
171  /// inputnull is true if the input is about to become null, and false if it
172  /// is about to be connected.
173  void adjustChildrenForInputChange(int idx,
174  int child_input_idx,
175  bool inputnull, bool force,
176  bool allow_disconnection,
177  bool allow_connection);
178  int preSetSubnetInput(int idx, bool inputnull);
179  void postSetSubnetInput(int idx, bool inputnull,
180  int child_input_idx);
181  void findSafeBase(UT_String &in) const;
182  bool isConnectedInside(int idx,
183  bool include_outputs,
184  bool include_parm_definers) const;
185  // Note that this expects a subnet input name, i.e. the name not yet
186  // prefixed with VOP_SUBNET_VARIABLE_PREFIX.
187  bool isConnectedInsideNamed(
188  const OP_ConnectorId& input_name,
189  bool include_parm_definers) const;
190  void deleteArraysForLoadedInputAndOutputNames();
191 
192 private:
193  /// Forward declaration of our embedded VOP_SubnetHelper::SubnetAPI
194  /// subclass.
195  class SubnetAPI;
196 
197  friend class SubnetAPI;
198 
199  UT_StringArray myInputNames;
200  unsigned myIsAdjustingForInputChange : 1,
201  myIsAppendingDefinedInput : 1,
202  myIsSettingUpConnectorDefinersAfterLoad : 1,
203  myIsLoadingNetwork : 1,
204  myAreConnectorsSetUp : 1;
205 
206  /// Helper that factors out methods shared with regular subnetwork.
207  VOP_SubnetHelper *mySubnetHelper;
208 
209  /// Used during loading to find out input and output names.
210  UT_StringArray *myLoadedInputNames;
211  UT_StringArray *myLoadedOutputNames;
212 };
213 
214 #endif
virtual int getInputFromNameSubclass(const UT_String &in) const
virtual void endLoadingInNetwork()
virtual bool updateParmsFlags()
virtual void dirtyShaderList()
Some material vops cache a list of shader that needs to be dirtied.
GLuint GLsizei const GLchar * label
Definition: glcorearb.h:2544
virtual void getAllowedInputTypesSubclass(unsigned idx, VOP_VopTypeArray &voptypes)
virtual void shaderParmGrandChildChanged(VOP_Node *grand_child)
virtual OP_ERROR setInput(unsigned idx, OP_Node *op, unsigned outputIdx=0)
virtual void setupConnectorsAfterLoad()
virtual void doDeleteInput(int idx)
Performs actual removal from the member input array.
virtual bool forceCodeGenerationOfInputs(const VOP_CodeGenContext &context, bool check_shader_context) const
virtual unsigned getNumVisibleInputs() const
virtual VOP_ParmGeneratorMap * getSubnetVariables()
virtual void moveInput(int srcidx, int dstidx, bool forcesubnet=false)
virtual const char * inputLabel(unsigned idx) const
UT_ErrorSeverity
Definition: UT_Error.h:25
Parameters for OP_Node::getInfoText()/OP_Node::getNodeSpecificInfoText()
void updateOwnerSpareParmLayout(bool allow_update_while_loading=false)
Update the owner network's spare parameter layout.
virtual unsigned getNumVisibleOutputs() const
virtual UT_StringArray * getArrayForLoadedOutputNames()
virtual bool generateErrorsSubclass()
virtual const VOP_SubnetBase * castToSubnetBase() const
virtual void getInputTypeInfoSubclass(VOP_TypeInfo &type_info, int idx)
virtual OP_OperatorFilter * getOperatorFilter()
virtual bool isConnected(int inputidx, bool recursive)
static const char * theChildTableName
#define VOP_API
Definition: VOP_API.h:10
virtual bool isNamedInputConnectedInsideSubnet(const OP_ConnectorId &input_name) const
virtual void getNodeSpecificInfoText(OP_Context &context, OP_NodeInfoParms &iparms)
virtual UT_IntArray getShaderLayerExportsInputsToCopy(int out_idx, VOP_Type shader_type)
virtual bool allowConsolidatingInput(int idx)
virtual void preOpChanged(OP_EventType, void *)
Definition: VOP_Node.h:1362
DEP_MicroNode & eventMicroNode(OP_EventType e)
Definition: OP_Node.h:1568
virtual void shaderParmGrandChildAdded(VOP_Node *grand_child)
virtual bool getInputEditorInputLabel(UT_String &label, int idx)
virtual int getNumSubnetInputsForChildren() const
virtual VOP_ExportedParmsManager * getVopExportedParmsManager(bool create_if_needed=false)
Definition: OP_Node.h:2589
virtual unsigned orderedInputs() const
virtual OP_ERROR setInputReference(unsigned idx, const char *label, int keeppos, unsigned outputIdx=0)
Connects an input to particular node by name in the network.
GLboolean * data
Definition: glcorearb.h:130
GLuint const GLchar * name
Definition: glcorearb.h:785
virtual OP_ERROR setNamedInputReference(const OP_ConnectorId &input_name, const char *label, int, const OP_ConnectorId *output_name=NULL)
virtual void loadStart()
virtual UT_StringArray * getArrayForLoadedInputNames()
virtual int getInputEditorInputs()
virtual OP_ERROR setNamedInput(const OP_ConnectorId &input_name, OP_Node *op, const OP_ConnectorId *output_name=NULL)
New input functions that use names instead of indices.
virtual void ensureSpareParmsAreUpdatedSubclass()
virtual void getCode(UT_String &codestr, const VOP_CodeGenContext &context)
Get the code fragment to be included in the shader code.
virtual void beginLoadingInNetwork()
Called upon entering and exiting loadNetwork() method.
virtual void addNode(OP_Node *node, int notify=1, int explicitly=1)
virtual const char * outputLabel(unsigned idx) const
virtual void getOutputTypeInfoSubclass(VOP_TypeInfo &type_info, int idx)
virtual void getOutputNameSubclass(UT_String &out, int idx) const
GLuint index
Definition: glcorearb.h:785
virtual void finishedLoadingNetwork(bool is_child_call=false)
OP_EventType
Definition: OP_Value.h:22
VOP_Type
Definition: VOP_Types.h:24
virtual void getInputNameSubclass(UT_String &in, int idx) const
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:107
virtual void getExtraTypesToDefine(UT_Array< VOP_TypeInfo > &types)
virtual void getInputDefaultValue(UT_String &def, int idx) const
Gets a default value of an explicitly defined input (applies to subnets)
virtual int getSubnetInputIndexForChildren(int child_input) const
GLsizei GLenum GLenum * types
Definition: glcorearb.h:2541
virtual VOP_SubnetBase * castToSubnetBase()
virtual bool isInputConnectedInsideSubnet(int input_idx) const
virtual void shaderParmGrandChildDeleted(VOP_Node *grand_child)
virtual int getNumNodeDefinedOutputs() const
virtual UT_StringHolder getShaderLayerExportsToAdd(int out_idx, VOP_Type shader_type)
virtual void postOpChanged(OP_EventType, void *)
Definition: VOP_Node.h:1364