本文整理汇总了Python中openalea.core.node.Node类的典型用法代码示例。如果您正苦于以下问题:Python Node类的具体用法?Python Node怎么用?Python Node使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Node类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: set_io
def set_io(self, inputs, outputs):
"""
Define inputs and outputs
Inputs and outputs are list of dict(name='', interface='', value='')
"""
# I/O ports
# Remove node if nb of input has changed
if(self.id_in is not None
and len(inputs) != self.node(self.id_in).get_nb_output()):
self.remove_node(self.id_in)
self.id_in = None
if(self.id_out is not None
and len(outputs) != self.node(self.id_out).get_nb_input()):
self.remove_node(self.id_out)
self.id_out = None
# Create new io node if necessary
if(self.id_in is None):
self.id_in = self.add_node(CompositeNodeInput(inputs))
else:
self.node(self.id_in).set_io((), inputs)
if(self.id_out is None):
self.id_out = self.add_node(CompositeNodeOutput(outputs))
else:
self.node(self.id_out).set_io(outputs, ())
Node.set_io(self, inputs, outputs)
示例2: simulate_destruction_notifications
def simulate_destruction_notifications(self):
"""emits messages as if we were adding elements to
the composite node"""
Node.simulate_destruction_notifications(self)
ids = self.vertices()
for eltid in ids:
node = self.node(eltid)
self.notify_vertex_removal(node)
for eid in self.edges():
(src_id, dst_id) = self.source(eid), self.target(eid)
etype=None
src_port_id = self.local_id(self.source_port(eid))
dst_port_id = self.local_id(self.target_port(eid))
nodeSrc = self.node(src_id)
nodeDst = self.node(dst_id)
src_port = nodeSrc.output_desc[src_port_id]
dst_port = nodeDst.input_desc[dst_port_id]
#don't notify if the edge is connected to the input or
#output nodes.
# if(src_id == self.id_in or dst_id == self.id_out):
# continue
edgedata = "default", eid
self.notify_listeners(("edge_removed", edgedata))
示例3: __init__
def __init__(self, inputs):
"""
inputs : list of dict(name='', interface='', value'',...)
"""
Node.__init__(self, outputs=inputs)
self.internal_data['caption'] = "In"
示例4: reset
def reset(self):
""" Reset nodes """
Node.reset(self)
for vid in set(self.vertices()):
node = self.actor(vid)
node.reset()
示例5: invalidate
def invalidate(self):
""" Invalidate nodes """
Node.invalidate(self)
for vid in set(self.vertices()):
node = self.actor(vid)
node.invalidate()
示例6: _init_internal_data
def _init_internal_data(self, d):
"""This method is called after the node has been instantiated, to
fill in the internal_data dictionnary."""
Node._init_internal_data(self, d)
inputs = d.get("methodSig")
methodName = d.get("methodName")
if inputs and methodName:
self.internal_data["methodName"] = methodName
self.internal_data["methodSig"] = inputs
self.build_ports(inputs)
示例7: __init__
def __init__(self, packagedata, editors=None, includes=[]):
"""
@packagedata : A file contained in a defined package.
@editors : A dictionary of commands which act on the file.
@includes : Other files that are included in the data file.
"""
Node.__init__(self, inputs=(dict(name='data', interface=IData, value=packagedata),
dict(name='editors', interface=None, value=editors),
dict(name='includes', interface=None, value=includes)),
outputs=(dict(name='data', interface=IData), ), )
self.caption = '%s' % (packagedata.name)
self.watch = None
self.monitor_file(str(packagedata))
if not includes:
self.set_port_hidden(2, True)
示例8: create_fake_node
def create_fake_node(self, vid):
""" Return an empty node with the correct number of inputs
and output """
# Count in and out needed
ins = 0
outs = 0
for eid, link in self.connections.iteritems():
(source_vid, source_port, target_vid, target_port) = link
if(source_vid == vid):
outs = max(outs, source_port)
elif(target_vid == vid):
ins = max(ins, target_port)
node = Node()
attributes = copy.deepcopy(self.elt_data[vid])
ad_hoc = copy.deepcopy(self.elt_ad_hoc.get(vid, None))
self.load_ad_hoc_data(node, attributes, ad_hoc)
# copy node input data if any
values = copy.deepcopy(self.elt_value.get(vid, ()))
for p in range(ins+1):
port = node.add_input(name="In"+str(p))
for p in range(outs+1):
port = node.add_output(name="Out"+str(p))
for vs in values:
try:
#the two first elements are the historical
#values : port Id and port value
#beyond that are extensions added by gengraph:
#the ad_hoc_dict representation is third.
port, v = vs[:2]
node.set_input(port, eval(v))
if(len(vs)>2):
d = MetaDataDict(vs[2])
node.input_desc[port].get_ad_hoc_dict().update(d)
except:
continue
return node
示例9: test_dataflow_state_get_data
def test_dataflow_state_get_data():
df = DataFlow()
vid1 = df.add_vertex()
pid10 = df.add_in_port(vid1, "in")
pid11 = df.add_out_port(vid1, "out")
vid2 = df.add_vertex()
pid21 = df.add_out_port(vid2, "out")
vid5 = df.add_vertex()
pid51 = df.add_out_port(vid5, "out")
vid3 = df.add_vertex()
pid31 = df.add_in_port(vid3, "in1")
pid32 = df.add_in_port(vid3, "in2")
pid33 = df.add_out_port(vid3, "res")
vid4 = df.add_vertex()
pid41 = df.add_in_port(vid4, "in")
df.connect(pid11, pid31)
df.connect(pid21, pid32)
df.connect(pid33, pid41)
df.connect(pid51, pid32)
dfs = DataflowState(df)
for pid in df.ports():
assert_raises(KeyError, lambda: dfs.get_data(pid))
for i, pid in enumerate([pid11, pid21, pid33, pid51]):
dfs.set_data(pid, i)
assert_raises(KeyError, lambda: dfs.get_data(pid10))
dfs.set_data(pid10, 'a')
assert dfs.get_data(pid10) == 'a'
for i, pid in enumerate([pid11, pid21, pid33, pid51]):
assert dfs.get_data(pid) == i
assert dfs.get_data(pid31) == 0
assert tuple(dfs.get_data(pid32)) == (1, 3)
assert dfs.get_data(pid41) == 2
n2 = Node()
df.set_actor(vid2, n2)
assert tuple(dfs.get_data(pid32)) == (1, 3)
n5 = Node()
df.set_actor(vid5, n5)
assert tuple(dfs.get_data(pid32)) == (1, 3)
n2.get_ad_hoc_dict().set_metadata('position', [10, 0])
n5.get_ad_hoc_dict().set_metadata('position', [0, 0])
assert tuple(dfs.get_data(pid32)) == (3, 1)
示例10: __init__
def __init__(self, inputs, outputs):
Node.__init__(self, inputs, outputs)
self.world = World()
示例11: __init__
def __init__(self,*args):
Node.__init__(self,*args)
self.widget = None
self.enabled = not (QtCore.QCoreApplication .instance() is None)
示例12: __init__
def __init__(self, inputs, outputs):
Node.__init__(self, inputs, outputs)
self.state = True
示例13: close
def close(self):
for vid in set(self.vertices()):
node = self.actor(vid)
node.close()
Node.close(self)
示例14: reset
def reset(self):
Node.reset(self)
self.state = True
示例15: __init__
def __init__(self):
Node.__init__(self)
self.add_input(name="geom", interface=None)
self.add_output(name="scene", interface=None)