comparison flax/Node.py @ 166:7ccf1d10804b

lots more notes
author drewp
date Tue, 08 Jul 2003 09:19:10 +0000
parents 490843093506
children
comparison
equal deleted inserted replaced
165:1fe54442db38 166:7ccf1d10804b
4 NoChange = "NoChange" 4 NoChange = "NoChange"
5 5
6 class NodeType: 6 class NodeType:
7 def __init__(self, iports=None, oports=None): 7 def __init__(self, iports=None, oports=None):
8 make_attributes_from_args('iports', 'oports') 8 make_attributes_from_args('iports', 'oports')
9 def process(self): 9 def process(self,iports,oports):
10 pass 10 pass
11 # TODO: handle NoChange stuff 11 # TODO: handle NoChange stuff
12 12
13 class AddNode(NodeType): 13 class AddNode(NodeType):
14 """Adds two nodes together""" 14 """Adds two nodes together"""
32 ports.out1 = val 32 ports.out1 = val
33 33
34 class FadeNode(NodeType): 34 class FadeNode(NodeType):
35 """Provides a UI scaler to let you fade a value""" 35 """Provides a UI scaler to let you fade a value"""
36 def __init__(self): 36 def __init__(self):
37 NodeType.__init__(self, iports={'in1' : Port, 37 NodeType.__init__(self, iports={'in1' : Port(),
38 'scale1' : Port}, 38 'scale1' : Port()},
39 oports={'out1' : Port}, 39 oports={'out1' : Port()},
40 def process(self, ports): 40 def process(self, iports, oports):
41 ports.out1 = ports.in1 * ports.scale1 41 ports.out1 = ports.in1 * ports.scale1
42 42
43 class FadeConstellation(Constellation): 43 class FadeConstellation(Constellation):
44 """This somehow describes the following: 44 """This somehow describes the following:
45 45
73 \ - - - - - - - - - - - -- - - / 73 \ - - - - - - - - - - - -- - - /
74 | 74 |
75 | out 75 | out
76 | 76 |
77 """ 77 """
78
79 Persistence
80 node instance saves:
81 node name, id, and such
82 input ports:
83 any port details
84 what the port connects to
85 values:
86 maybe UI.Scale level
87 maybe group contents
88
89
90 p=InputPort(node=self,minconns=1,maxconns=2) # an input port to this node
91 p.connect(othernode)
92 print p.connections()
93 p.connect(yetanother)
94
95 op=OutputPort(node=self) # an output port
96 print op.connections() # lists all the nodes that call us an input node
97 op.connect(n) # calls n.connect(self)
98
99
100
101
102 Ports
103 Port: "scalar"
104 MultiPort: "array of Port"
105 ^ all wrong
106
107 Ports II:
108 min/max number of connections
109 (failure to fit these numbers means port is "deactivated")
110 "Normal" ports are min=1, max=1
111 "Multiports" are min=0, max=None
112 "Binary" ports are min=2, max=2
113 oh yeah, there are two totally different types of ports
114
115 Input ports: min/max numbers of connections
116 store current connections
117 Output ports: nothing
118 store nothing!
119
120 fake node persistence for subtract node
121
122 <!-- "my subtract" is a unique id -->
123 <!-- drew: there is no such thing as a subtract group -->
124 <node name="my subtract" type="math.Add">
125 <inputs>
126 <port name="in1">
127 <noderef name="node I"/>
128 <noderef name="node II"/>
129 </port>
130 </inputs>
131 <state>
132 </state>
133
134 </node>
135
136
137 <node name="the group" type="group">
138
139 <!-- all of the port names of the group are being made up right
140 here- a group has no preset inputs or outputs-->
141
142 <inputs>
143 <port name="group-in 1">
144 <noderef name="node5"/>
145 <noderef name="node6"/>
146 </port>
147 </inputs>
148
149 <state>
150 <children>
151 <noderef name="node3">
152 <connect localPort="in1" groupPort="group-in1"/>
153 </noderef>
154 <noderef name="node4">
155 <connect localPort="in1" groupPort="group-in1"/>
156 <connect localPort="out1" groupPort="theoutput"/>
157 </noderef>
158 </children>
159
160 </state>
161 </node>
162
163 <node name="preset value" type="source.Scalar">
164 <!-- no inputs, node has output only -->
165 <state>
166 <value>8.3</value>
167
168 <minvalue>0</minvalue>
169 <maxvalue>100</maxvalue>
170
171 <gui>
172 <slider res=".1" height="200" bgcolor="red"/>
173 <priority>very high</priority>
174 <xpos>395</xpos>
175 <ypos>21</ypos>
176 </gui>
177
178 </state>
179
180 </node>