Commit f8efa9ba authored by VIGNET Pierre's avatar VIGNET Pierre
Browse files

[gui][lib] A copy of an item (node/transition) now inherits of the note attribute of its parent

parent 7d7dd6c3
......@@ -500,13 +500,13 @@ class CNode(object):
hmin = 0.1
depth_max = 3
def __init__(self, x_coord, y_coord, model):
def __init__(self, x_coord, y_coord, model, note=""):
"""
The coordinates of a node are always in the space of its father.
"""
self.model = model
self.name = "$$"
self.note = ""
self.note = note
self.xloc = x_coord
self.yloc = y_coord
self.father = None
......@@ -652,8 +652,8 @@ class CStartNode(CNode):
Start node show macro-states initialisation
"""
def __init__(self, x_coord, y_coord, model):
CNode.__init__(self, x_coord, y_coord, model)
def __init__(self, x_coord, y_coord, model, **kwargs):
CNode.__init__(self, x_coord, y_coord, model, **kwargs)
self.name = "__start__"
self.wloc = 1.0
self.hloc = 1.0 # for compatibility with find
......@@ -664,7 +664,7 @@ class CStartNode(CNode):
"""
if not model:
model = self.model
return CStartNode(self.xloc, self.yloc, model)
return CStartNode(self.xloc, self.yloc, model, note=self.note)
def is_start(self):
"""
......@@ -778,8 +778,8 @@ class CTrapNode(CStartNode):
Dead end node
"""
def __init__(self, xcoord, ycoord, model):
CStartNode.__init__(self, xcoord, ycoord, model)
def __init__(self, xcoord, ycoord, model, **kwargs):
CStartNode.__init__(self, xcoord, ycoord, model, **kwargs)
self.name = "__trap__"
def is_trap(self):
......@@ -791,7 +791,7 @@ class CTrapNode(CStartNode):
def copy(self, model=None):
if not model:
model = self.model
return CTrapNode(self.xloc, self.yloc, model)
return CTrapNode(self.xloc, self.yloc, model, note=self.note)
def is_for_origin(self):
return False
......@@ -819,8 +819,8 @@ class CSimpleNode(CNode):
Simple nodes have constant screen dimensions
"""
def __init__(self, xcoord, ycoord, name, model):
CNode.__init__(self, xcoord, ycoord, model)
def __init__(self, xcoord, ycoord, name, model, **kwargs):
CNode.__init__(self, xcoord, ycoord, model, **kwargs)
self.name = name.encode("ascii")
self.father = None # double linkage for coordinate computations
self.hloc = 1.0
......@@ -833,7 +833,7 @@ class CSimpleNode(CNode):
"""
if not model:
model = self.model
return CSimpleNode(self.xloc, self.yloc, self.name, model)
return CSimpleNode(self.xloc, self.yloc, self.name, model, note=self.note)
def is_simple(self):
return True
......@@ -954,13 +954,13 @@ class CPermNode(CSimpleNode):
permanent node are never unactivated
"""
def __init__(self, xcoord, ycoord, name, model):
CSimpleNode.__init__(self, xcoord, ycoord, name, model)
def __init__(self, xcoord, ycoord, name, model, **kwargs):
CSimpleNode.__init__(self, xcoord, ycoord, name, model, **kwargs)
def copy(self, model=None):
if not model:
model = self.model
return CPermNode(self.xloc, self.yloc, self.name, model)
return CPermNode(self.xloc, self.yloc, self.name, model, note=self.note)
def is_perm(self):
return True
......@@ -988,8 +988,8 @@ class CInputNode(CSimpleNode):
An input node cannot have an in-transition
"""
def __init__(self, xcoord, ycoord, name, model):
CSimpleNode.__init__(self, xcoord, ycoord, name, model)
def __init__(self, xcoord, ycoord, name, model, **kwargs):
CSimpleNode.__init__(self, xcoord, ycoord, name, model, **kwargs)
self.father = None # double linkage for coordinate computations
self.hloc = 1.0
self.activated = False
......@@ -1003,7 +1003,7 @@ class CInputNode(CSimpleNode):
def copy(self, model=None):
if not model:
model = self.model
return CInputNode(self.xloc, self.yloc, self.name, model)
return CInputNode(self.xloc, self.yloc, self.name, model, note=self.note)
def is_for_extremity(self):
return False
......@@ -1130,8 +1130,8 @@ class CMacroNode(CSimpleNode):
that they contain.
"""
def __init__(self, xcoord, ycoord, width, height, name, model):
CSimpleNode.__init__(self, xcoord, ycoord, name, model)
def __init__(self, xcoord, ycoord, width, height, name, model, **kwargs):
CSimpleNode.__init__(self, xcoord, ycoord, name, model, **kwargs)
self.start_trap_nodes_count = 0 # for start and trap nodes naming
self.wloc = width
self.hloc = height
......@@ -1182,7 +1182,7 @@ class CMacroNode(CSimpleNode):
if not model:
model = self.model
child_node = CMacroNode(
self.xloc, self.yloc, self.wloc, self.hloc, self.name, model
self.xloc, self.yloc, self.wloc, self.hloc, self.name, model, note=self.note
)
# copy subnodes
self.copy_subnodes(child_node, model)
......@@ -1235,6 +1235,7 @@ class CMacroNode(CSimpleNode):
transition_c.event = trans.event
transition_c.condition = trans.condition
transition_c.action = trans.action
transition_c.note = str(trans.note)
transitions_group.append(transition_c)
# Append new transition to the concerned ori and ext nodes
......@@ -1393,6 +1394,7 @@ class CMacroNode(CSimpleNode):
add a node of the same type
"""
nnode = node.copy(self.model)
nnode.note = str(node.note)
self.model.node_dict[nnode.name] = nnode
nnode.father = self
if nnode.is_simple():
......@@ -1846,8 +1848,8 @@ class CTopNode(CMacroNode):
it represents the virtual drawing window.
"""
def __init__(self, name, model):
CMacroNode.__init__(self, 0.0, 0.0, 1.0, 1.0, name, model)
def __init__(self, name, model, **kwargs):
CMacroNode.__init__(self, 0.0, 0.0, 1.0, 1.0, name, model, **kwargs)
self.submodel = False
self.env_node = None # for environment interaction in tests
# nb no father node
......@@ -1860,7 +1862,7 @@ class CTopNode(CMacroNode):
- The env_node (if any) is not copied.
"""
LOGGER.debug("CMacroNode::copy")
child_node = CMacroNode(self.xloc, self.yloc, 0.3, 0.3, self.name, self.model)
child_node = CMacroNode(self.xloc, self.yloc, 0.3, 0.3, self.name, self.model, note=self.note)
# copy subnodes
self.copy_subnodes(child_node)
# copy transitions
......@@ -2030,7 +2032,7 @@ class CTransition(object):
"""
@param note: string
"""
self.note = note
self.note = str(note)
def get_key(self):
"""
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment