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
pymsc
Commits
865f0c0a
Commit
865f0c0a
authored
Nov 21, 2014
by
Maxime Perrotin
Browse files
Improve support for condition boxes
parent
50944e65
Changes
3
Hide whitespace changes
Inline
Side-by-side
mscgraphics/basicmscgraph/mscGraphBasicMSCScene.py
View file @
865f0c0a
...
...
@@ -228,14 +228,15 @@ class MscGraphBasicMSCScene(QGraphicsScene):
self
.
removeItem
(
comment
)
#--------------- Conditions
def
addCondition
(
self
,
instance
,
pos
=
None
,
label
=
''
):
def
addCondition
(
self
,
instance
,
y
=
None
,
label
=
''
):
u
"""
Add new "condition" to the scene and position it in
"
pos
"
if any
Add new "condition" to the scene and position it in
y
pos if any
"""
condition
=
MscGraphCondition
(
label
=
label
,
parent
=
self
.
bmsc
())
condition
=
MscGraphCondition
(
label
=
label
,
y
=
y
,
parent
=
self
.
bmsc
(),
instance
=
instance
)
instance
.
addEvent
(
condition
)
if
pos
is
not
None
:
condition
.
set
Pos
(
pos
)
if
y
is
not
None
:
condition
.
set
Y
(
instance
.
mapFromScene
(
0
,
y
).
y
()
)
condition
.
itemSelected
.
connect
(
self
.
itemSelected
)
self
.
itemInserted
.
emit
(
condition
)
return
condition
...
...
mscgraphics/basicmscgraph/mscGraphCondition.py
View file @
865f0c0a
...
...
@@ -41,12 +41,10 @@ class MscGraphCondition(MscGraphItem):
DefaultWidth
=
150
DefaultHeight
=
30
def
__init__
(
self
,
data
=
None
,
y
=
0
,
label
=
None
,
parent
=
None
):
u
"""
Initize
"""
def
__init__
(
self
,
data
=
None
,
y
=
0
,
label
=
None
,
parent
=
None
,
instance
=
None
):
super
(
MscGraphCondition
,
self
).
__init__
(
parent
)
self
.
setFlag
(
super
(
MscGraphCondition
,
self
).
ItemIsMovable
,
True
)
self
.
instance
=
instance
if
label
is
None
:
label
=
"Condition"
...
...
@@ -63,6 +61,7 @@ class MscGraphCondition(MscGraphItem):
# Create Path
self
.
createPath
()
self
.
setPos
(
self
.
pos
().
x
(),
y
or
0
)
#**************************************************************************
# Data Functions
...
...
@@ -100,30 +99,27 @@ class MscGraphCondition(MscGraphItem):
def
updateLabelPosition
(
self
):
self
.
label
.
setCenterPos
(
QPointF
(
0
,
15
))
#self.label.setPos(self.x() + 10,
# -self.label.boundingRect().height() / 2)
#**************************************************************************
# Item Change
#**************************************************************************
def
limitsOfItem
(
self
,
value
):
u
""" Check the limits of the event area of parent """
parent
=
self
.
parentItem
()
parent
=
self
.
instance
if
parent
==
None
:
return
value
upperY
=
parent
.
upperLimit
().
y
()
bottomY
=
parent
.
bottomLimit
().
y
()
#
bottomY = parent.bottomLimit().y()
valueY
=
value
.
y
()
if
valueY
<
upperY
:
valueY
=
upperY
value
.
setX
(
self
.
pos
().
x
())
value
.
setY
(
valueY
)
return
value
new_pos
=
QPointF
(
self
.
pos
().
x
(),
valueY
)
return
new_pos
def
itemChange
(
self
,
change
,
value
):
''' On position change, check that item stays in an allowed area '''
if
(
change
==
super
(
MscGraphCondition
,
self
).
ItemPositionChange
):
value
=
self
.
limitsOfItem
(
value
)
...
...
@@ -131,7 +127,7 @@ class MscGraphCondition(MscGraphItem):
self
.
mscData
().
setAbsPos
(
self
.
mapToScene
(
0
,
0
).
y
())
self
.
yHasChanged
.
emit
(
self
)
return
MscGraphItem
.
itemChange
(
self
,
change
,
value
)
return
value
#
MscGraphItem.itemChange(self, change, value)
#**************************************************************************
# Paint Functions
...
...
mscgraphics/basicmscgraph/mscGraphMessage.py
View file @
865f0c0a
...
...
@@ -206,11 +206,6 @@ class MscGraphMessage(MscGraphItem):
if
value
.
y
()
<
recvStart
.
y
():
value
.
setY
(
recvStart
.
y
())
# # Message are not below the instances
# if value.y() > sendEnd.y():
# value.setY(sendEnd.y())
# if value.y() > recvEnd.y():
# value.setY(recvEnd.y())
value
.
setX
(
self
.
pos
().
x
())
return
value
...
...
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