Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
VIGNET Pierre
cadbiom
Commits
1973f368
Commit
1973f368
authored
Sep 16, 2017
by
VIGNET Pierre
Browse files
Names of nodes are now incremented when creating a new nodes with the buttons from the interface
parent
327d3b7f
Changes
1
Hide whitespace changes
Inline
Side-by-side
gui/cadbiom_gui/gt_gui/chart_controler.py
View file @
1973f368
...
...
@@ -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
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment