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
87e58fdb
Commit
87e58fdb
authored
Oct 30, 2015
by
Maxime Perrotin
Browse files
Statecharts: harmonize sizes and forbid moves
parent
9d167a85
Changes
1
Hide whitespace changes
Inline
Side-by-side
opengeode/Statechart.py
View file @
87e58fdb
...
...
@@ -89,6 +89,10 @@ class Record(genericSymbols.HorizontalSymbol, object):
# Discard mouse release default action (CAM, UndoCommand)
pass
def
mouse_move
(
self
,
event
):
''' Disallow moving the symbols - this scene is auto-generated '''
pass
# pylint: disable=R0904
class
Point
(
genericSymbols
.
HorizontalSymbol
,
object
):
...
...
@@ -131,6 +135,10 @@ class Point(genericSymbols.HorizontalSymbol, object):
#self.scene().refresh()
update
(
self
.
scene
())
def
mouse_move
(
self
,
event
):
''' Disallow moving the symbols - this scene is auto-generated '''
pass
# pylint: disable=R0904
class
Diamond
(
genericSymbols
.
HorizontalSymbol
,
object
):
...
...
@@ -174,6 +182,10 @@ class Diamond(genericSymbols.HorizontalSymbol, object):
#update(self.scene())
pass
def
mouse_move
(
self
,
event
):
''' Disallow moving the symbols - this scene is auto-generated '''
pass
# pylint: disable=R0904
class
Stop
(
genericSymbols
.
HorizontalSymbol
,
object
):
...
...
@@ -217,6 +229,10 @@ class Stop(genericSymbols.HorizontalSymbol, object):
''' After moving item, ask dot to recompute the edges '''
pass
def
mouse_move
(
self
,
event
):
''' Disallow moving the symbols - this scene is auto-generated '''
pass
def
edges
(
scene
,
node
):
''' Return all edges of a given node '''
...
...
@@ -346,8 +362,10 @@ def update(scene):
'''
Parse the graph symbols and create a graphviz graph
Used to update the edges in case user moves nodes.
This function is disabled because move of symbols is not possible
anymore.
'''
print
'update'
return
nodes
=
[{
'name'
:
node
.
name
,
'pos'
:
node
.
mapToScene
(
node
.
boundingRect
().
center
()),
'shape'
:
type
(
node
),
'width'
:
node
.
boundingRect
().
width
(),
...
...
@@ -420,6 +438,22 @@ def render_statechart(scene, graphtree=None, keep_pos=False, dump_gfx=''):
/
RENDER_DPI
[
'Y'
])
graphtree
[
'children'
][
aname
][
'scene'
]
=
temp_scene
break
# Harmonize the size of states to avoid having huge composite state(s)
# next to single, small states. Rule: there can't be a state with a size
# that is less than a third of the biggest state.
min_width
=
float
(
max
(
node
.
attr
.
get
(
'width'
,
0.0
)
or
0.0
for
node
in
graphtree
[
'graph'
].
iternodes
()))
min_height
=
float
(
max
(
node
.
attr
.
get
(
'height'
,
0.0
)
or
0.0
for
node
in
graphtree
[
'graph'
].
iternodes
()))
if
min_width
and
min_height
:
for
node
in
graphtree
[
'graph'
].
iternodes
():
if
node
.
attr
[
'shape'
]
!=
'record'
:
continue
node
.
attr
[
'width'
]
=
node
.
attr
.
get
(
'width'
)
or
min_width
/
3.0
node
.
attr
[
'height'
]
=
node
.
attr
.
get
(
'height'
)
or
min_height
/
3.0
# Statechart symbols lookup table
lookup
=
{
'point'
:
Point
,
'record'
:
Record
,
'diamond'
:
Diamond
,
'plaintext'
:
Stop
}
...
...
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