00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef _OP_InputIndirect_h_
00026 #define _OP_InputIndirect_h_
00027
00028 #include "OP_API.h"
00029 #include <iostream.h>
00030 #include <UT/UT_PtrArray.h>
00031 #include <UT/UT_String.h>
00032
00033 #include "OP_PropagateData.h"
00034 #include "OP_Value.h"
00035 #include "OP_NetworkBoxItem.h"
00036
00037 #define OP_INVALID_INDIRECT_ID -999
00038
00039 class OP_Input;
00040 class OP_Node;
00041 class OP_Network;
00042
00043 class OP_API OP_InputIndirect : public OP_NetworkBoxItem
00044 {
00045 public:
00046 OP_InputIndirect(OP_Network *net, int input_index,
00047 float x=0.0F, float y=0.0F);
00048 virtual ~OP_InputIndirect();
00049
00050 virtual int save(ostream &os, int bin) const;
00051 virtual bool load(UT_IStream &is);
00052
00053 virtual int setPicked(int on_off,
00054 bool propagate_parent_event = true);
00055 virtual int getPicked() const;
00056
00057
00058
00059
00060
00061 virtual OP_Node *getNode();
00062
00063
00064 virtual void setOwner(OP_Network *net, int input_index);
00065 OP_Network *getOwner() const { return myOwner; }
00066 int getInputIndex() const { return myInputIndex; }
00067
00068
00069 virtual OP_Network *getParentNetwork() const;
00070
00071
00072
00073
00074
00075 unsigned getNOutputs() const { return myOutputs.entries(); }
00076 OP_Node *getOutput(unsigned idx) const
00077 {
00078 return (idx < getNOutputs()) ? myOutputs(idx) : 0;
00079 }
00080
00081
00082
00083
00084 void disconnect();
00085
00086
00087
00088
00089 virtual void setXY(fpreal x, fpreal y);
00090 virtual fpreal getX() const { return myPosX; }
00091 virtual fpreal getY() const { return myPosY; }
00092
00093
00094 virtual fpreal getW() const;
00095 virtual fpreal getH() const;
00096
00097 OP_InputIndirect &operator=(const OP_InputIndirect &from);
00098
00099 virtual OP_ItemType getItemType() const;
00100
00101
00102
00103 virtual const UT_String &getItemName() const;
00104
00105 protected:
00106 void addOutput(OP_Node *);
00107 void delOutput(OP_Node *);
00108 void propagateChange(OP_EventType type, void *data=0);
00109 void propagateModification(OP_Node *by_whom,
00110 OP_EventType reason,
00111 int parm_index,
00112 OP_PropagateData &prop_data);
00113 unsigned int getUniqueId();
00114 unsigned int getUniqueId() const { return myUniqueId; }
00115
00116 OP_Network *myOwner;
00117 UT_PtrArray<OP_Node *> myOutputs;
00118 float myPosX;
00119 float myPosY;
00120 short myInputIndex;
00121 short myFlags;
00122
00123 private:
00124
00125 void onlySetXY(float x, float y);
00126 void clearId() { myUniqueId = 0; }
00127
00128 UT_String myName;
00129
00130 unsigned int myUniqueId;
00131
00132 friend ostream &operator<<(ostream &os, const OP_InputIndirect &d)
00133 {
00134 d.save(os, 0);
00135 return os;
00136 }
00137 friend class OP_Input;
00138 friend class OP_Network;
00139 };
00140
00141 #endif