Commit d1428672 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Update states in data dictionary

parent df19fa28
......@@ -369,6 +369,7 @@ class SDL_Scene(QtGui.QGraphicsScene, object):
''' Main graphic scene (canvas) where the user can place SDL symbols '''
# Signal to be emitted when the scene is left (e.g. UP button)
scene_left = QtCore.Signal()
context_change = QtCore.Signal()
def __init__(self, context='process'):
''' Create a Scene for a given context:
......@@ -820,6 +821,7 @@ class SDL_Scene(QtGui.QGraphicsScene, object):
recursive=False,
nextstate=False, cpy=True))
symbol.update_completion_list(pr_text=pr_text)
self.context_change.emit()
def highlight(self, item):
......@@ -1135,6 +1137,7 @@ class SDL_Scene(QtGui.QGraphicsScene, object):
subscene = SDL_Scene(context=context)
subscene.messages_window = self.messages_window
subscene.parent_scene = parent
subscene.context_change.connect(self.context_change.emit)
return subscene
......@@ -2035,6 +2038,7 @@ class OG_MainWindow(QtGui.QMainWindow, object):
self.view.refresh()
scene.undo_stack.cleanChanged.connect(
lambda x: self.view.wrapping_window.setWindowModified(not x))
scene.context_change.connect(self.update_datadict_window)
def start(self, file_name):
''' Initializes all objects to start the application '''
......@@ -2226,18 +2230,24 @@ class OG_MainWindow(QtGui.QMainWindow, object):
# it should be attached to the current scene instead TODO
in_sig, out_sig, states, dcl, timers = [self.datadict.topLevelItem(i)
for i in range(2, 7)]
context = sdlSymbols.CONTEXT
def change_state(item, state):
item.setDisabled(state)
item.takeChildren()
if self.view.scene().context == 'block':
map(lambda elem: elem.setDisabled(True),
map(lambda elem: change_state(elem, True),
(in_sig, out_sig, states, dcl, timers))
elif self.view.scene().context == 'process':
map(lambda elem: elem.setDisabled(False),
map(lambda elem: change_state(elem, False),
(in_sig, out_sig, states, dcl, timers))
for each in sorted(context.mapping.viewkeys()):
QtGui.QTreeWidgetItem(states, [each,])
elif self.view.scene().context == 'procedure':
map(lambda elem: elem.setDisabled(False), (dcl, timers, out_sig))
map(lambda elem: elem.setDisabled(True), (in_sig, states))
map(lambda elem: change_state(elem, False), (dcl, timers, out_sig))
map(lambda elem: change_state(elem, True), (in_sig, states))
self.datadict.resizeColumnToContents(0)
def vi_command(self):
# type: () -> None
'''
......
......@@ -1090,7 +1090,7 @@ class Procedure(Process):
self.setPath(path)
super(Process, self).set_shape(width, height)
def update_completion_list(self, **kwargs):
def update_completion_list(self, _):
''' When text was entered, update completion list of ProcedureCall '''
for each in CONTEXT.procedures:
if unicode(self.text).lower() == each.inputString:
......
/* CIF PROCESS (142, 159), (146, 75) */
/* CIF PROCESS (163, 140), (146, 75) */
PROCESS operators;
/* CIF TEXT (286, 21), (303, 152) */
/* CIF TEXT (355, 21), (303, 152) */
DCL i Integer := 2;
DCL f Real := 2.0;
DCL b Boolean := true;
......@@ -10,47 +10,47 @@ DCL fixSeqOf FixSeqof := {1, 2, 3};
DCL varSeqOf varSeqOf := {1, 2, 3};
DCL c Choice := i:2;
/* CIF ENDTEXT */
/* CIF START (73, 24), (100, 50) */
/* CIF START (163, 48), (100, 50) */
START;
/* CIF NEXTSTATE (73, 89), (100, 50) */
/* CIF NEXTSTATE (163, 113), (100, 50) */
NEXTSTATE Wait;
/* CIF STATE (73, 89), (100, 50) */
/* CIF STATE (163, 113), (100, 50) */
STATE Wait;
/* CIF INPUT (74, 159), (100, 50) */
/* CIF INPUT (164, 183), (100, 50) */
INPUT run;
/* CIF PROCEDURECALL (13, 224), (221, 35) */
/* CIF PROCEDURECALL (104, 248), (221, 35) */
CALL assert(abs(-i) = i, 'abs(-i) = i');
/* CIF PROCEDURECALL (-8, 274), (264, 35) */
/* CIF PROCEDURECALL (82, 298), (264, 35) */
CALL assert(abs(-f) = f, 'abs(-f) = f');
/* CIF PROCEDURECALL (-22, 324), (293, 35) */
/* CIF PROCEDURECALL (68, 348), (293, 35) */
CALL assert(ceil(f + 0.5) = 3.0, 'ceil(f + 0.5) = 3.0');
/* CIF PROCEDURECALL (-90, 374), (429, 35) */
/* CIF PROCEDURECALL (0, 398), (429, 35) */
CALL assert(round(cos(pi)) = -1.0, 'round(cos(pi)) = -1.0');
/* CIF PROCEDURECALL (12, 424), (224, 35) */
/* CIF PROCEDURECALL (102, 448), (224, 35) */
CALL assert(fix(f) = i, 'fix(f) = i');
/* CIF PROCEDURECALL (-1, 474), (251, 35) */
/* CIF PROCEDURECALL (89, 498), (251, 35) */
CALL assert(float(i) = f, 'float(i) = f');
/* CIF PROCEDURECALL (-18, 524), (284, 35) */
/* CIF PROCEDURECALL (72, 548), (284, 35) */
CALL assert(floor(f + 0.5) = f, 'floor(f + 0.5) = f');
/* CIF PROCEDURECALL (-47, 574), (343, 35) */
/* CIF PROCEDURECALL (43, 598), (343, 35) */
CALL assert(length(fixSeqOf) = 3, 'length(fixSeqOf) = 3');
/* CIF PROCEDURECALL (-51, 624), (350, 35) */
/* CIF PROCEDURECALL (39, 648), (350, 35) */
CALL assert(length(varSeqOf) = 3, 'length(varSeqOf) = 3');
/* CIF PROCEDURECALL (3, 674), (240, 35) */
/* CIF PROCEDURECALL (94, 698), (240, 35) */
CALL assert(num(e) = 12, 'num(e) = 12');
/* CIF PROCEDURECALL (-14, 724), (276, 35) */
/* CIF PROCEDURECALL (76, 748), (276, 35) */
CALL assert(power(i, 3) = 8, 'power(i, 3) = 8');
/* CIF PROCEDURECALL (-90, 774), (429, 35) */
/* CIF PROCEDURECALL (0, 798), (429, 35) */
CALL assert(round(sin(pi)) = 0.0, 'round(sin(pi)) = 0.0');
/* CIF PROCEDURECALL (-15, 824), (278, 35) */
/* CIF PROCEDURECALL (75, 848), (278, 35) */
CALL assert(sqrt(16.0) = 4.0, 'sqrt(16.0) = 4.0');
/* CIF PROCEDURECALL (-26, 874), (301, 35) */
/* CIF PROCEDURECALL (64, 898), (301, 35) */
CALL assert(trunc(f + 0.1) = f, 'trunc(f + 0.1) = f');
/* CIF PROCEDURECALL (24, 924), (200, 35) */
/* CIF PROCEDURECALL (114, 948), (200, 35) */
CALL writeln(i, f, b, s);
/* CIF PROCEDURECALL (24, 974), (200, 35) */
/* CIF PROCEDURECALL (114, 998), (200, 35) */
CALL write(i, f, b, s);
/* CIF NEXTSTATE (74, 1024), (100, 50) */
/* CIF NEXTSTATE (164, 1048), (100, 50) */
NEXTSTATE Wait;
ENDSTATE;
ENDPROCESS operators;
\ No newline at end of file
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