Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
OpenGEODE
Commits
4643d9a9
Commit
4643d9a9
authored
Sep 10, 2016
by
Maxime Perrotin
Browse files
Emit a signal when a connection child needs refresh
parent
4e10d4ea
Changes
2
Hide whitespace changes
Inline
Side-by-side
opengeode/Connectors.py
View file @
4643d9a9
...
...
@@ -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 '''
...
...
opengeode/genericSymbols.py
View file @
4643d9a9
...
...
@@ -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
):
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment