Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
beat
beat.editor
Commits
71273670
Commit
71273670
authored
Nov 08, 2019
by
Flavio TARSETTI
Browse files
[widgets][toolchaineditor] delete connection from end pin on re-draw
parent
08718bb6
Changes
1
Hide whitespace changes
Inline
Side-by-side
beat/editor/widgets/toolchaineditor.py
View file @
71273670
...
...
@@ -56,9 +56,11 @@ from .editor import AbstractAssetEditor
from
.drawing_space
import
DrawingSpace
class
BasePin
(
QGraphics
Item
):
class
BasePin
(
QGraphics
Object
):
"""Base class for pin graphics"""
dataChanged
=
pyqtSignal
()
def
__init__
(
self
,
parent
,
pin
,
block
,
pin_brush
,
pin_pen
):
super
().
__init__
(
parent
=
parent
)
...
...
@@ -98,6 +100,18 @@ class BasePin(QGraphicsItem):
def
mouseMoveEvent
(
self
,
event
):
"""Painting connection in progress"""
# Only one single connection allowed from input pin
if
isinstance
(
self
,
InputPin
):
# Check if connection exist and remove if it does
for
connection
in
self
.
block_object
.
toolchain
.
connections
:
if
(
connection
.
end_block
==
self
.
block_object
and
connection
.
end_pin
==
self
):
self
.
block_object
.
toolchain
.
connections
.
remove
(
connection
)
self
.
block_object
.
scene
().
removeItem
(
connection
)
self
.
dataChanged
.
emit
()
mouse_position
=
self
.
mapToScene
(
event
.
pos
())
self
.
new_connection
.
set_new_connection_pins_coordinates
(
self
,
mouse_position
)
...
...
@@ -143,6 +157,9 @@ class BasePin(QGraphicsItem):
connection
.
load
(
self
.
block_object
.
toolchain
,
connection_settings
,
channel_colors
)
self
.
dataChanged
.
emit
()
self
.
block_object
.
toolchain
.
connections
.
append
(
connection
)
self
.
block_object
.
toolchain
.
scene
.
addItem
(
connection
)
...
...
@@ -290,9 +307,8 @@ class Connection(QGraphicsPathItem):
# check if end block pin is free
toolchain
=
end
.
block_object
.
toolchain
for
connection
in
toolchain
.
connections
:
if
connection
.
end_block
==
end
.
block_object
:
if
connection
.
end_pin
==
end
:
return
False
if
connection
.
end_block
==
end
.
block_object
and
connection
.
end_pin
==
end
:
return
False
return
True
...
...
@@ -394,6 +410,8 @@ class Block(QGraphicsObject):
)
self
.
pins
[
"inputs"
][
pin_name
]
=
input_pin
input_pin
.
dataChanged
.
connect
(
self
.
dataChanged
)
if
self
.
outputs
is
not
None
:
for
pin_name
in
self
.
outputs
:
output_pin
=
OutputPin
(
...
...
@@ -401,6 +419,8 @@ class Block(QGraphicsObject):
)
self
.
pins
[
"outputs"
][
pin_name
]
=
output_pin
output_pin
.
dataChanged
.
connect
(
self
.
dataChanged
)
def
set_style
(
self
,
config
):
self
.
setAcceptHoverEvents
(
True
)
...
...
Write
Preview
Markdown
is supported
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