Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
OpenGEODE
Commits
a0fe9fb8
Commit
a0fe9fb8
authored
Dec 12, 2014
by
Maxime Perrotin
Browse files
Remove content of update_position - deprecated
parent
3d2940c8
Changes
1
Hide whitespace changes
Inline
Side-by-side
genericSymbols.py
View file @
a0fe9fb8
...
...
@@ -1019,14 +1019,11 @@ class HorizontalSymbol(Symbol, object):
return
None
def
mouse_move
(
self
,
event
):
'''
P
revent move from being above the parent '''
'''
Will p
revent move from being above the parent '''
if
self
.
mode
==
'Move'
:
event_pos
=
event
.
pos
()
new_y
=
self
.
pos_y
+
(
event_pos
.
y
()
-
event
.
lastPos
().
y
())
new_x
=
self
.
pos_x
+
(
event_pos
.
x
()
-
event
.
lastPos
().
x
())
if
self
.
hasParent
:
new_y
=
max
(
new_y
,
self
.
parent
.
boundingRect
().
height
()
+
self
.
minDistanceToSymbolAbove
)
self
.
position
=
QPointF
(
new_x
,
new_y
)
self
.
update_connections
()
super
(
HorizontalSymbol
,
self
).
mouse_move
(
event
)
...
...
@@ -1126,6 +1123,21 @@ class VerticalSymbol(Symbol, object):
''' Redefined: connect to parent item with a straight line '''
return
VerticalConnection
(
self
.
parent
,
self
)
def
set_valid_pos
(
self
,
pos
):
''' Redefined function - make sure symbol is well aligned '''
if
not
self
.
hasParent
:
super
(
VerticalSymbol
,
self
).
set_valid_pos
(
pos
)
else
:
# 'or self.parent' because of pyside/qt bug
parent
=
self
.
parentItem
()
or
self
.
parent
self
.
setX
(
-
((
self
.
boundingRect
().
width
()
-
parent
.
boundingRect
().
width
())
/
2
))
# In case of collision with parent item, move down
try
:
self
.
setY
(
max
(
pos
.
y
(),
parent
.
connectionPoint
.
y
()))
except
AttributeError
:
self
.
setY
(
max
(
pos
.
y
(),
parent
.
boundingRect
().
height
()
+
15
))
def
insert_symbol
(
self
,
parent
,
x
,
y
):
'''
Vertical symbol: place the symbol in the scene.
...
...
@@ -1205,27 +1217,30 @@ class VerticalSymbol(Symbol, object):
Update the symbol position -
always below its parent (check collisions, etc.)
'''
# 'or self.parent' because of pyside/qt bug
parent
=
self
.
parentItem
()
or
self
.
parent
self
.
pos_x
=
-
((
self
.
boundingRect
().
width
()
-
parent
.
boundingRect
().
width
())
/
2
)
# In case of collision with parent item, move down
try
:
self
.
pos_y
=
max
(
self
.
y
(),
parent
.
connectionPoint
.
y
())
except
AttributeError
:
self
.
pos_y
=
max
(
self
.
y
(),
parent
.
boundingRect
().
height
()
+
15
)
pass
# set_valid_pos does it all
# # 'or self.parent' because of pyside/qt bug
# parent = self.parentItem() or self.parent
# self.pos_x = -((self.boundingRect().width() -
# parent.boundingRect().width()) / 2)
# # In case of collision with parent item, move down
# try:
# self.pos_y = max(self.y(), parent.connectionPoint.y())
# except AttributeError:
# self.pos_y = max(self.y(), parent.boundingRect().height() + 15)
def
mouse_move
(
self
,
event
):
''' Click and move: forbid symbol to move on the x axis '''
super
(
VerticalSymbol
,
self
).
mouse_move
(
event
)
if
self
.
mode
==
'Move'
:
new_y
=
self
.
pos_y
+
(
event
.
pos
().
y
()
-
event
.
lastPos
().
y
())
if
not
self
.
parent
:
self
.
pos_x
+=
event
.
pos
().
x
()
-
event
.
lastPos
().
x
()
if
not
self
.
hasParent
or
(
new_y
>=
self
.
connection
.
start_point
.
y
()
+
self
.
parent
.
minDistanceToSymbolAbove
):
self
.
pos_y
=
new_y
new_y
=
self
.
pos_y
+
event
.
pos
().
y
()
-
event
.
lastPos
().
y
()
new_x
=
self
.
pos_x
+
event
.
pos
().
x
()
-
event
.
lastPos
().
x
()
self
.
position
=
QPointF
(
new_x
,
new_y
)
# if not self.parent:
# self.pos_x += event.pos().x() - event.lastPos().x()
# if not self.hasParent or (new_y >=
# self.connection.start_point.y() +
# self.parent.minDistanceToSymbolAbove):
# self.pos_y = new_y
self
.
update_connections
()
self
.
updateConnectionPoints
()
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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