HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
OP_IndirectInput.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_IndirectInput.h (C++)
7  *
8  * COMMENTS: OP_IndirectInput is used to represent a potential link into
9  * one or more node. It esseitnally allows an output connection to be
10  * forwarded to an input connection, which the input or output side
11  * may not exist.
12  */
13 
14 #ifndef _OP_IndirectInput_h_
15 #define _OP_IndirectInput_h_
16 
17 #include "OP_API.h"
18 #include "OP_PropagateData.h"
19 #include "OP_Value.h"
20 #include "OP_NetworkBoxItem.h"
21 #include <UT/UT_ValArray.h>
22 #include <UT/UT_String.h>
23 #include <SYS/SYS_Types.h>
24 #include <iosfwd>
25 
26 class OP_Input;
27 class OP_Node;
28 class OP_Network;
29 
31 {
32 public:
34  virtual ~OP_IndirectInput();
35 
36  // Get the item attached directly to this indirect input. May be a node,
37  // or another indirect input.
38  virtual OP_NetworkBoxItem *getInputItem() const = 0;
39  virtual int getInputItemOutputIndex() const = 0;
40 
41  // Get the Node that this input refers to. May return NULL
42  // Follows non-node inputs recursively to find a node.
43  OP_Node *getNode();
44  int getNodeOutputIndex();
45 
46  // We maintain a list of output nodes so that we can do things to
47  // them, like inform them when we're being deleted.
48  unsigned getNOutputs() const
49  { return myOutputs.entries(); }
50  OP_NetworkBoxItem *getOutput(unsigned idx) const
51  { return (idx < getNOutputs()) ? myOutputs(idx) : 0; }
52  void clearOutputs(bool for_delete = false);
53 
54  // Get all nodes connected to this indirect input. if an output is another
55  // indirect input, follow its outputs recursively to find more nodes.
56  void getOutputNodes(OP_NodeList &nodes,
57  bool into_subnets = false) const;
58  // Does a depth first search looking for the first node connected to
59  // this indirect input.
60  OP_Node *getFirstOutputNode() const;
61 
62  //Return the network this item resides in (i.e. getOwner())
63  virtual OP_Network *getParentNetwork() const;
64  OP_Network *getOwner() const;
65 
66  virtual int setPicked(int on_off,
67  bool propagate_parent_event = true);
68  virtual int getPicked() const;
69 
70  // Position is used by the UI.
71  virtual void setXY(fpreal x, fpreal y);
72  virtual fpreal getX() const
73  { return myPosX; }
74  virtual fpreal getY() const
75  { return myPosY; }
76 
77  // Flag to indicate that the color for this item should be fetched from
78  // the first output. The set function returns true if the value changed.
79  virtual bool setColor(const UT_Color &color);
80  bool setUseColorFromOutput(bool use_output_color);
81  bool getUseColorFromOutput() const;
82  bool setSymbolicColorName(const UT_StringHolder &name);
83  const UT_StringHolder &getSymbolicColorName() const;
84 
85  // The default color for indirect inputs.
86  static UT_Color getDefaultColor();
87 
88  // Return the amount of memory owned by this OP_IndirectInput
89  int64 getMemoryUsage(bool inclusive) const
90  {
91  int64 mem = inclusive ? sizeof(*this) : 0;
93  mem += myOutputs.getMemoryUsage(false);
94  mem += mySymbolicColorName.getMemoryUsage(false);
95  return mem;
96  }
97 
98 protected:
99  // Functions for saving and loading.
100  void initFromIndirect(const OP_IndirectInput &src);
101  void initFromFile(const UT_StringHolder &clrstr,
102  const UT_StringHolder &netboxname,
103  fpreal x,
104  fpreal y);
105  void saveColorString(std::ostream &os) const;
106 
107  // Send change notifications to our outputs.
108  void propagateModification(OP_Node *by_whom,
109  OP_EventType reason,
110  int parm_index,
111  OP_PropagateData &prop_data);
112 
113 private:
114  void addOutput(OP_NetworkBoxItem *item);
115  void delOutput(OP_NetworkBoxItem *item);
116 
117  OP_Network &myOwner;
118  UT_StringHolder mySymbolicColorName;
119  OP_NetworkBoxItemList myOutputs;
120  fpreal myPosX;
121  fpreal myPosY;
122  bool myPicked;
123  bool myUseColorFromOutput;
124 
125  friend class OP_Input;
126  friend class OP_Network;
127 };
128 
129 #endif
virtual bool setColor(const UT_Color &color)
virtual fpreal getY() const
int64 getMemoryUsage(bool inclusive) const
int64 getMemoryUsage(bool inclusive) const
virtual int setPicked(int on_off, bool propagate_parent_event=true)=0
GLuint color
Definition: glcorearb.h:1260
virtual void setXY(fpreal x, fpreal y)=0
GLint y
Definition: glcorearb.h:102
virtual OP_Network * getParentNetwork() const =0
Returns the network that is our parent.
virtual fpreal getX() const
long long int64
Definition: SYS_Types.h:100
GLuint const GLchar * name
Definition: glcorearb.h:785
unsigned getNOutputs() const
virtual int getPicked() const =0
double fpreal
Definition: SYS_Types.h:263
OP_NetworkBoxItem * getOutput(unsigned idx) const
#define OP_API
Definition: OP_API.h:10
GLint GLenum GLint x
Definition: glcorearb.h:408
OP_EventType
Definition: OP_Value.h:22
GLenum src
Definition: glcorearb.h:1792