Commit 6b4aba86 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Scene creation bugfix

parent 635d40cd
......@@ -284,6 +284,8 @@ class SDL_Scene(QtGui.QGraphicsScene, object):
process, procedure or composite state
'''
super(SDL_Scene, self).__init__()
# Reference to the parent scene
self.parent_scene = None
self.mode = 'idle'
self.context = context
self.allowed_symbols = ACTIONS[context]
......@@ -401,6 +403,7 @@ class SDL_Scene(QtGui.QGraphicsScene, object):
def render_everything(self, ast):
''' Render a process and its children scenes, recursively '''
already_created = []
def recursive_render(content, dest_scene):
''' Process the rendering in scenes and nested scenes '''
if isinstance(content, ogAST.Process):
......@@ -417,11 +420,16 @@ class SDL_Scene(QtGui.QGraphicsScene, object):
# Render nested scenes, recursively:
for each in (item for item in dest_scene.visible_symb
if item.nested_scene):
if isinstance(each.nested_scene, ogAST.CompositeState) \
and (not each.nested_scene.statename
or each.nested_scene in already_created):
# Ignore nested state scenes that already exist
continue
subscene = \
self.create_subscene(each.__class__.__name__.lower())
#subscene = SDL_Scene(context=each.__class__.__name__.lower())
#subscene.messages_window = self.messages_window
already_created.append(each.nested_scene)
subscene.name = unicode(each)
LOG.debug('Created scene: {}'.format(subscene.name))
recursive_render(each.nested_scene.content, subscene)
each.nested_scene = subscene
......@@ -429,8 +437,7 @@ class SDL_Scene(QtGui.QGraphicsScene, object):
# (Needed for the symbol shape to have dashed lines)
for each in dest_scene.states:
if unicode(each).lower() in \
dest_scene.composite_states.viewkeys() and not \
each.nested_scene:
dest_scene.composite_states.viewkeys():
each.nested_scene = dest_scene.composite_states[
unicode(each).lower()]
......@@ -986,6 +993,7 @@ class SDL_Scene(QtGui.QGraphicsScene, object):
''' Create a new SDL scene, e.g. for nested symbols '''
subscene = SDL_Scene(context=context)
subscene.messages_window = self.messages_window
subscene.parent_scene = self
return subscene
......
/* CIF PROCESS (288, 143), (150, 75) */
PROCESS trafficlight;
STATE Maintenance;
SUBSTRUCTURE
STATE YellowOff;
SUBSTRUCTURE
STATE Maintenance;
SUBSTRUCTURE
STATE YellowOff;
SUBSTRUCTURE
/* CIF PROCEDURE (239, 367), (73, 35) */
PROCEDURE entry;
/* CIF START (180, 35), (70, 35) */
......@@ -23,8 +23,8 @@ SUBSTRUCTURE
STATE idle;
ENDSTATE;
ENDSUBSTRUCTURE;
STATE YellowOn;
SUBSTRUCTURE
STATE YellowOn;
SUBSTRUCTURE
/* CIF PROCEDURE (291, 312), (73, 35) */
PROCEDURE entry;
/* CIF START (292, 124), (70, 35) */
......@@ -65,13 +65,13 @@ SUBSTRUCTURE
NEXTSTATE YellowOff;
ENDSTATE;
ENDSUBSTRUCTURE;
STATE on;
SUBSTRUCTURE
STATE PedWaiting;
SUBSTRUCTURE
STATE on;
SUBSTRUCTURE
STATE PedWaiting;
SUBSTRUCTURE
out (counter_expired);
STATE waitOn;
SUBSTRUCTURE
STATE waitOn;
SUBSTRUCTURE
/* CIF PROCEDURE (548, 222), (73, 35) */
PROCEDURE entry;
/* CIF START (185, 47), (70, 35) */
......@@ -81,7 +81,7 @@ SUBSTRUCTURE
/* CIF RETURN (202, 147), (35, 35) */
RETURN ;
ENDPROCEDURE;
/* CIF PROCEDURE (560, 288), (70, 35) */
/* CIF PROCEDURE (560, 289), (70, 35) */
PROCEDURE exit;
/* CIF START (280, 159), (70, 35) */
START;
......
Supports Markdown
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