Commit 4643d9a9 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Emit a signal when a connection child needs refresh

parent 4e10d4ea
......@@ -53,6 +53,13 @@ class Connection(QGraphicsPathItem, object):
self.childRect = child.sceneBoundingRect()
# Activate cache mode to boost rendering by calling paint less often
self.setCacheMode(QGraphicsItem.DeviceCoordinateCache)
# When the child moves, the connection may need to adjust the end point
self.child.moved.connect(self.child_moved)
@Slot(float, float)
def child_moved(self, delta_x, delta_y):
''' When the connection child moves - redefine in subclasses '''
pass
@property
def start_point(self):
......@@ -411,6 +418,12 @@ class Channel(Signalroute):
start, middle and end point are redefined. They are stored with
scene coordinates '''
@Slot(float, float)
def child_moved(self, delta_x, delta_y):
''' When the connection child moves - redefined function '''
self._end_point.setX(self._end_point.x() - delta_x)
self._end_point.setY(self._end_point.y() - delta_y)
@property
def start_point(self):
''' Compute connection origin - redefined function '''
......
......@@ -52,7 +52,8 @@ __all__ = ['Symbol', 'VerticalSymbol', 'HorizontalSymbol', 'Comment']
import os
import logging
from PySide.QtCore import Qt, QPoint, QPointF, QRect, QFile, QObject, Property
from PySide.QtCore import (Qt, QPoint, QPointF, QRect, QFile, QObject,
Signal, Property)
from PySide.QtGui import(QGraphicsPathItem, QGraphicsPolygonItem, QPainterPath,
QGraphicsItem, QPen, QColor, QMenu, QFileDialog,
......@@ -78,6 +79,9 @@ class Symbol(QObject, QGraphicsPathItem, object):
Top-level class used to handle all SDL symbols
Inherits from QObject to allow animations
'''
# Emit a signal when the symbol moved - can be caught by connectors to
# adjust connection points if the symbol is not the connection parent
moved = Signal(float, float)
# Symbols of a given type share a text-autocompletion list:
completion_list = set()
# Flexible lists of symbol types that can be set as child of this symbol
......@@ -582,6 +586,10 @@ class Symbol(QObject, QGraphicsPathItem, object):
self, self.coord, self.position)
self.scene().undo_stack.push(undo_cmd)
self.cam(self.coord, self.position)
# Emit signal to indicate that the symbol moved
# typically caught by connectors
self.moved.emit(self.coord.x() - self.pos_x,
self.coord.y() - self.pos_y)
self.mode = ''
def updateConnectionPoints(self):
......
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