Commit f326c2a3 authored by VIGNET Pierre's avatar VIGNET Pierre

Names of nodes are now incremented when creating a new nodes with the buttons from the interface

parent ddff1db1
......@@ -44,7 +44,8 @@
"""
Main gui controler with auxiliary classes
"""
import itertools as it
from string import ascii_uppercase
from math import sqrt
from gtk.gdk import Cursor, ARROW, BOTTOM_LEFT_CORNER, BOTTOM_RIGHT_CORNER,\
TOP_LEFT_CORNER, TOP_RIGHT_CORNER, LINE_ON_OFF_DASH
......@@ -124,6 +125,8 @@ class ChartControler(object):
self.signal_dict[sig] = []
self.edit_window = None
self.gen_name = self.nodes_names_generator()
def attach(self, signal, obs):
"""
Register an observer on a signal list
......@@ -353,27 +356,32 @@ class ChartControler(object):
xnode = self.m_vscreen_coord[0]
ynode = self.m_vscreen_coord[1]
if type == 'simple':
self.current_node = self.current_node.add_simple_node("...",
xnode, ynode)
self.current_node = self.current_node.add_simple_node(
next(self.gen_name),
xnode, ynode)
elif type == 'macro':
self.current_node = self.current_node.add_macro_subnode("...",
xnode,
ynode,
0.25, 0.25)
self.current_node = self.current_node.add_macro_subnode(
next(self.gen_name),
xnode,
ynode,
0.25, 0.25)
elif type == 'start':
self.current_node = self.current_node.add_start_node(xnode, ynode)
elif type == 'trap':
self.current_node = self.current_node.add_trap_node(xnode, ynode)
elif type == 'perm':
self.current_node = self.current_node.add_perm_node("...",
xnode, ynode)
self.current_node = self.current_node.add_perm_node(
next(self.gen_name),
xnode, ynode)
elif type == 'input':
self.current_node = self.current_node.add_input_node("...",
xnode, ynode)
self.current_node = self.current_node.add_input_node(
next(self.gen_name),
xnode, ynode)
elif type == 'env':
self.current_node = self.current_node.add_env_node("...",
xnode, ynode,
0.25, 0.25)
self.current_node = self.current_node.add_env_node(
next(self.gen_name),
xnode, ynode,
0.25, 0.25)
else: # bug!
print ' new_node:UNKNOWN TYPE:', type
return
......@@ -384,6 +392,15 @@ class ChartControler(object):
self.view.window.set_cursor(ChartControler.cursors[0])
self.mouse_role = "select"
def nodes_names_generator(self):
"""Return a generator of names for new nodes.
Names are generated in lexicographic order.
"""
for size in it.count(start=1):
for tpl in it.combinations(ascii_uppercase, size):
yield "".join(tpl)
def new_transition(self, xmo, ymo):
"""
@param xmo, ymo: int mouse screen coordinates
......
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