Attention une mise à jour du service Gitlab va être effectuée le mardi 30 novembre entre 17h30 et 18h00. Cette mise à jour va générer une interruption du service dont nous ne maîtrisons pas complètement la durée mais qui ne devrait pas excéder quelques minutes. Cette mise à jour intermédiaire en version 14.0.12 nous permettra de rapidement pouvoir mettre à votre disposition une version plus récente.

Commit 1973f368 authored by VIGNET Pierre's avatar VIGNET Pierre
Browse files

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

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