HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
OP_Input.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_Input.h (C++)
7  *
8  * COMMENTS:
9  *
10  */
11 
12 #ifndef _OP_Input_h_
13 #define _OP_Input_h_
14 
15 #include "OP_API.h"
16 #include "OP_ConnectorId.h"
17 #include <UT/UT_Defines.h>
18 #include <UT/UT_String.h>
19 #include <UT/UT_Array.h>
20 #include <iosfwd>
21 #include <string>
22 
23 class OP_Node;
24 class OP_Network;
25 class OP_IndirectInput;
26 class OP_NetworkBoxItem;
27 
28 #ifdef UT_DEBUG
29 //#define OP_DEBUG_TRACE_NAME_RESOLUTION
30 //#define OP_DEBUG_CHECK_INPUT_CONSISTENCY
31 #endif
32 
34 {
35 public:
37  ~OP_Input();
38 
39  int save(std::ostream &os, int bin,
40  const char* input_name);
41  bool load(UT_IStream &is, const char *path,
42  std::string *input_name_out);
43 
44  // Returns the node that we are an input to.
46  { return myOwner; }
47 
48  // Convert our input string to an actual pointer again
49  void resolveReference();
50  const char *getNodeReference() const
51  { return myNodeReference.isstring()
52  ? myNodeReference.buffer() : ""; }
53 
54  // Get the Node that this input refers to. May return NULL
55  OP_Node *getNode();
56  unsigned getNodeOutputIndex();
57  OP_ConnectorId getNodeOutputName(void);
58 
59  // Dirty the cached output index of the input node.
60  void dirtyCachedOutputIndex();
61 
62  // Check if there is a Node at the other end of the connection.
63  // Indirect inputs don't count unless they are actually connected
64  // to a node.
65  bool isConnectedToNode() const;
66  // Check if either a node or indirect input (with or without a node
67  // connected indirectly) is connected.
68  bool isConnected() const
69  { return isIndirect() || isConnectedToNode(); }
70 
71  bool isIndirect() const
72  { return myIndirectFlag; }
73  OP_IndirectInput *getIndirect();
74 
75  // Returns the subnet indirect input if there is one, otherwise return
76  // the input node.
77  OP_NetworkBoxItem *getInputItem();
78  unsigned getInputItemOutputIndex();
79 
80  int64 getMemoryUsage(bool inclusive) const;
81 
82  void setIsVisible(bool value)
83  { myVisibleFlag = value; }
84  bool getIsVisible() const
85  { return myVisibleFlag; }
86 
87  void copyFrom(OP_Input* other);
88 
89  void getId(int &id);
90  void setId(int id);
92  { return myId; }
93 
94  void clearIndirectInput();
95 
96  bool getPicked() const;
97  bool getOnPickedPath(bool through_pinned_dots = true) const;
98  int setPicked(bool picked,
99  bool send_change_event = true,
100  bool save_undo = true);
101 
102 private:
103  // Wire the input
104  void setInput(OP_Node *node, unsigned outputIdx);
105  void setNamedInput(OP_Node *node,
106  const OP_ConnectorId* output_name);
107  void setInputReference(const char *label,
108  unsigned outputIdx);
109  void setNamedInputReference(const char *label,
110  const OP_ConnectorId* output_name);
111 
112  // Take care of the input's forward link when attaching inputs
113  void setMyNode(OP_Node *input_node, unsigned outputIdx);
114  void setMyNodeNamed(OP_Node *input_node,
115  const OP_ConnectorId* outputName,
116  bool allow_soft_fail = false);
117 
118  void resolveLegacyOutputIndex(OP_Node* using_node);
119 
120  void setIndirectInput(OP_IndirectInput *input);
121 
122  // Utility functions used by getOnPickedPath.
123  bool inputPathPicked(bool through_pinned_dots) const;
124  bool outputPathPicked(bool through_pinned_dots) const;
125 
126  OP_NetworkBoxItem *myOwner;
127  OP_Node *myNode;
128  int myUnresolvedLegacyOutputIndex;
129  OP_ConnectorId myNodeOutputName;
130 
131  OP_IndirectInput *myIndirectInput;
132  UT_String myNodeReference;
133 
134  OP_ConnectorId myId;
135 
136  // Temporary, for transition purposes only. OP_Node::getOutputFromName() is
137  // currently very slow for nodes with, say, 2048 outputs. So we cache this
138  // for now, but we should really get rid of indices altogether.
139  int myCachedNodeOutputIdx;
140 
141  // Flag indicating we are in the middle of resolving our reference.
142  bool myResolvingReference;
143  // Flag indicating this is an indirect input.
144  bool myIndirectFlag;
145  // Controls the visibility of this input (in VOPs only).
146  bool myVisibleFlag;
147  // Holds whether or not this connection is selected.
148  bool myPicked;
149 
150  friend class OP_Node;
151  friend class OP_Dot;
152 };
153 
154 #endif
155 
OP_NetworkBoxItem * getOwnerItem() const
Definition: OP_Input.h:45
GLuint GLsizei const GLchar * label
Definition: glcorearb.h:2544
GLsizei const GLchar *const * string
Definition: glcorearb.h:813
GLsizei const GLchar *const * path
Definition: glcorearb.h:3340
bool isConnected() const
Definition: OP_Input.h:68
OP_ConnectorId getId() const
Definition: OP_Input.h:91
long long int64
Definition: SYS_Types.h:100
bool getIsVisible() const
Definition: OP_Input.h:84
Definition: OP_Dot.h:24
const char * getNodeReference() const
Definition: OP_Input.h:50
GLsizei const GLfloat * value
Definition: glcorearb.h:823
#define OP_API
Definition: OP_API.h:10
bool isIndirect() const
Definition: OP_Input.h:71
void setIsVisible(bool value)
Definition: OP_Input.h:82