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

Add comments and reformat code

parent b416a072
......@@ -84,6 +84,8 @@ class Symbol(QObject, QGraphicsPathItem, object):
_unique_followers = [] # unique : e.g. comment symbol
_insertable_followers = [] # no limit to insert below current symbol
_terminal_followers = [] # cannot be inserted between two symbols
# List of symbols that can be connected, but without parent-child relation
_connectable_siblings = []
# By default a symbol is resizeable
resizeable = True
# By default symbol size may expand when inner text exceeds border
......@@ -93,6 +95,8 @@ class Symbol(QObject, QGraphicsPathItem, object):
# By default connections between symbols are lines, not arrows
arrow_head = None
arrow_tail = None
# Define if a symbol can be manually connected to another one by user
user_can_connect = False
# Default mouse cursor
default_cursor = Qt.SizeAllCursor
# Decide if a symbol can be copy-pasted several times
......@@ -124,6 +128,7 @@ class Symbol(QObject, QGraphicsPathItem, object):
'''
super(Symbol, self).__init__(parent)
QGraphicsPathItem.__init__(self, parent)
# Current mode, can be empty string, "Resize", or "Move"
self.mode = ''
self.comment = None
self.text = None
......
......@@ -381,6 +381,8 @@ class SDL_Scene(QtGui.QGraphicsScene, object):
super(SDL_Scene, self).__init__()
# Reference to the parent scene
self.parent_scene = None
# mode can be "idle", "wait_connection_source", "select_items",
# "wait_next_connection_point", "wait_placement"
self.mode = 'idle'
self.context = context
self.allowed_symbols = ACTIONS[context]
......@@ -1247,8 +1249,8 @@ class SDL_Scene(QtGui.QGraphicsScene, object):
elif self.mode == 'wait_placement':
try:
parent = \
self.can_insert(event.scenePos(), self.button_selected)
parent = self.can_insert(event.scenePos(),
self.button_selected)
except TypeError as err:
self.messages_window.addItem(str(err))
else:
......@@ -1318,6 +1320,7 @@ class SDL_Scene(QtGui.QGraphicsScene, object):
else:
found = True
if not found and rect.width() > 20 and rect.height() > 20:
# No items to select, so propose a context dependent menu
self.quick_menu(event.screenPos(), rect)
#self.removeItem(self.select_rect)
# XXX stop with removeItem, it provokes segfault
......
......@@ -1006,6 +1006,9 @@ class Process(HorizontalSymbol):
is_singleton = True
arrow_head = 'angle'
arrow_tail = 'angle'
# Process can be connected to other processes by the user
user_can_connect = True
_connectable_siblings = ['Process']
def __init__(self, ast=None, subscene=None):
ast = ast or ogAST.Process()
......
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