Commit 9a446880 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Work in progress

parent a1b55582
...@@ -276,9 +276,9 @@ class Signalroute(Connection): ...@@ -276,9 +276,9 @@ class Signalroute(Connection):
in_sig = out_sig = None in_sig = out_sig = None
completion_list = set() completion_list = set()
def __init__(self, process): def __init__(self, parent, child=None):
''' Set generic parameters from Connection class ''' ''' Set generic parameters from Connection class '''
super(Signalroute, self).__init__(process, process) super(Signalroute, self).__init__(parent, child or parent)
self.parser = ogParser self.parser = ogParser
self.blackbold = () self.blackbold = ()
self.redbold = () self.redbold = ()
...@@ -292,16 +292,15 @@ class Signalroute(Connection): ...@@ -292,16 +292,15 @@ class Signalroute(Connection):
# Needed for the image exporter, that copies the scene to a # Needed for the image exporter, that copies the scene to a
# temporary one # temporary one
Signalroute.in_sig = '{}'.format(',\n'.join(sig['name'] Signalroute.in_sig = '{}'.format(',\n'.join(sig['name']
for sig in process.input_signals)) for sig in parent.input_signals))
Signalroute.out_sig = '{}'.format(',\n'.join(sig['name'] Signalroute.out_sig = '{}'.format(',\n'.join(sig['name']
for sig in process.output_signals)) for sig in parent.output_signals))
self.label_in.setPlainText('[{}]'.format(self.in_sig)) self.label_in.setPlainText('[{}]'.format(self.in_sig))
self.label_out.setPlainText('[{}]'.format(self.out_sig)) self.label_out.setPlainText('[{}]'.format(self.out_sig))
self.label_in.document().contentsChanged.connect(self.change_siglist) self.label_in.document().contentsChanged.connect(self.change_siglist)
self.label_out.document().contentsChanged.connect(self.change_siglist) self.label_out.document().contentsChanged.connect(self.change_siglist)
for each in (self.label_in, self.label_out): for each in (self.label_in, self.label_out):
each.show() each.show()
self.process = process
self.reshape() self.reshape()
@Slot() @Slot()
...@@ -320,7 +319,7 @@ class Signalroute(Connection): ...@@ -320,7 +319,7 @@ class Signalroute(Connection):
@property @property
def start_point(self): def start_point(self):
''' Compute connection origin - redefined function ''' ''' Compute connection origin - redefined function '''
parent_rect = self.process.boundingRect() parent_rect = self.parent.boundingRect()
return QPointF(parent_rect.x(), parent_rect.height() / 2) return QPointF(parent_rect.x(), parent_rect.height() / 2)
@property @property
...@@ -406,6 +405,47 @@ class Signalroute(Connection): ...@@ -406,6 +405,47 @@ class Signalroute(Connection):
pass pass
class Channel(Signalroute):
''' Connection between two processes. Signalroute handles connections
between a function and the environment (edge of the screen). Here the
start, middle and end point are redefined. They are stored with
scene coordinates '''
@property
def start_point(self):
''' Compute connection origin - redefined function '''
return self.parent.mapFromScene(self._start_point)
@start_point.setter
def start_point(self, scene_coord): # type: QPointF
''' value is in scene coordinates '''
print 'set start point'
self._start_point = scene_coord
@property
def end_point(self):
''' Compute connection end point - redefined function '''
return self.parent.mapFromScene(self._end_point)
@end_point.setter
def end_point(self, scene_coord): # type: QPointF
''' value is in scene coordinates '''
self._end_point = scene_coord
@property
def middle_points(self):
''' Compute connection intermediate points - redefined function '''
for each in self._middle_points:
yield self.parent.mapFromScene(each)
@middle_points.setter
def middle_points(self, points_scene_coord):
self._middle_points = points_scene_coord
def add_point(self, scene_coord):
self._middle_points.append(scene_coord)
class Controlpoint(QGraphicsPathItem, object): class Controlpoint(QGraphicsPathItem, object):
''' Class handling one edge control point (to change bezier curves) ''' ''' Class handling one edge control point (to change bezier curves) '''
def __init__(self, pos, edge): def __init__(self, pos, edge):
......
...@@ -65,7 +65,7 @@ import undoCommands ...@@ -65,7 +65,7 @@ import undoCommands
import ogAST import ogAST
import ogParser import ogParser
from Connectors import Connection, VerticalConnection, CommentConnection, \ from Connectors import Connection, VerticalConnection, CommentConnection, \
RakeConnection, JoinConnection RakeConnection, JoinConnection, Channel
from TextInteraction import EditableText from TextInteraction import EditableText
......
...@@ -89,7 +89,7 @@ from PySide.QtCore import (Qt, QSize, QFile, QIODevice, QRectF, QTimer, QPoint, ...@@ -89,7 +89,7 @@ from PySide.QtCore import (Qt, QSize, QFile, QIODevice, QRectF, QTimer, QPoint,
from PySide.QtUiTools import QUiLoader from PySide.QtUiTools import QUiLoader
from PySide import QtSvg from PySide import QtSvg
from genericSymbols import(Symbol, Comment, Cornergrabber, Connection) from genericSymbols import(Symbol, Comment, Cornergrabber, Connection, Channel)
from sdlSymbols import(Input, Output, Decision, DecisionAnswer, Task, from sdlSymbols import(Input, Output, Decision, DecisionAnswer, Task,
ProcedureCall, TextSymbol, State, Start, Join, Label, Procedure, ProcedureCall, TextSymbol, State, Start, Join, Label, Procedure,
ProcedureStart, ProcedureStop, StateStart, Connect, Process, ProcedureStart, ProcedureStop, StateStart, Connect, Process,
...@@ -1380,14 +1380,18 @@ class SDL_Scene(QtGui.QGraphicsScene, object): ...@@ -1380,14 +1380,18 @@ class SDL_Scene(QtGui.QGraphicsScene, object):
symb = self.symbol_near(point, dist=1) symb = self.symbol_near(point, dist=1)
if symb: if symb:
# Clicked on a symbol: create the actual connector # Clicked on a symbol: create the actual connector
connector = Connection(parent=self.connection_start, connector = Channel(parent=self.connection_start, child=symb)
child=symb) connector.start_point = self.edge_points[0]
connector._start_point = \ connector.middle_points = self.edge_points[1:]
connector.mapFromScene(self.edge_points[0]) connector.end_point = self.border_point(symb, point)
connector._middle_points = [connector.mapFromScene(p) # connector = Connection(parent=self.connection_start,
for p in self.edge_points[1:]] # child=symb)
connector._end_point = \ # connector._start_point = \
connector.mapFromScene(self.border_point(symb, point)) # connector.mapFromScene(self.edge_points[0])
# connector._middle_points = [connector.mapFromScene(p)
# for p in self.edge_points[1:]]
# connector._end_point = \
# connector.mapFromScene(self.border_point(symb, point))
for each in self.temp_lines: for each in self.temp_lines:
# Just hide to avoid pyside segfaults # Just hide to avoid pyside segfaults
each.setVisible(False) each.setVisible(False)
......
...@@ -1003,7 +1003,7 @@ class Process(HorizontalSymbol): ...@@ -1003,7 +1003,7 @@ class Process(HorizontalSymbol):
blackbold = SDL_BLACKBOLD blackbold = SDL_BLACKBOLD
redbold = SDL_REDBOLD redbold = SDL_REDBOLD
completion_list = set() completion_list = set()
is_singleton = True #is_singleton = True
arrow_head = 'angle' arrow_head = 'angle'
arrow_tail = 'angle' arrow_tail = 'angle'
# Process can be connected to other processes by the user # Process can be connected to other processes by the user
......
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