Commit 69f25064 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Improve statechart rendering

parent f7818c68
...@@ -148,8 +148,9 @@ The fonts are the fonts from Ubuntu, check licence in file FONT-LICENSE.TXT ...@@ -148,8 +148,9 @@ The fonts are the fonts from Ubuntu, check licence in file FONT-LICENSE.TXT
Changelog Changelog
========= =========
1.3.2 (11/2015) 1.3.3 (11/2015)
- Better support of platform-dependent screen resolution and dpi - Better support of platform-dependent screen resolution and dpi
- Minor fixes in statechart scenes (no negative coordinates)
1.3.1 (11/2015) 1.3.1 (11/2015)
- Support for State Aggregations (parallel states) - Support for State Aggregations (parallel states)
......
...@@ -427,6 +427,7 @@ def render_statechart(scene, graphtree=None, keep_pos=False, dump_gfx=''): ...@@ -427,6 +427,7 @@ def render_statechart(scene, graphtree=None, keep_pos=False, dump_gfx=''):
for view in scene.views(): for view in scene.views():
RENDER_DPI['X'] = view.physicalDpiX() RENDER_DPI['X'] = view.physicalDpiX()
RENDER_DPI['Y'] = view.physicalDpiY() RENDER_DPI['Y'] = view.physicalDpiY()
break
# Go recursive first: render children # Go recursive first: render children
for aname, agraph in graphtree['children'].viewitems(): for aname, agraph in graphtree['children'].viewitems():
...@@ -438,7 +439,7 @@ def render_statechart(scene, graphtree=None, keep_pos=False, dump_gfx=''): ...@@ -438,7 +439,7 @@ def render_statechart(scene, graphtree=None, keep_pos=False, dump_gfx=''):
for node in graphtree['graph'].iternodes(): for node in graphtree['graph'].iternodes():
if node == aname: if node == aname:
size = temp_scene.itemsBoundingRect() size = temp_scene.itemsBoundingRect()
node.attr['width'] = ((temp_scene.width() + 30) node.attr['width'] = ((temp_scene.width() + 35)
/ RENDER_DPI['X']) / RENDER_DPI['X'])
node.attr['height'] = ((temp_scene.height() + 35) node.attr['height'] = ((temp_scene.height() + 35)
/ RENDER_DPI['Y']) / RENDER_DPI['Y'])
...@@ -460,8 +461,8 @@ def render_statechart(scene, graphtree=None, keep_pos=False, dump_gfx=''): ...@@ -460,8 +461,8 @@ def render_statechart(scene, graphtree=None, keep_pos=False, dump_gfx=''):
for node in graphtree['graph'].iternodes(): for node in graphtree['graph'].iternodes():
if node.attr['shape'] != 'record': if node.attr['shape'] != 'record':
continue continue
node.attr['width'] = node.attr.get('width') or min_width/3.0 node.attr['width'] = node.attr.get('width') or (min_width / 3.0)
node.attr['height'] = node.attr.get('height') or min_height/3.0 node.attr['height'] = node.attr.get('height') or (min_height / 3.0)
# Statechart symbols lookup table # Statechart symbols lookup table
...@@ -491,7 +492,7 @@ def render_statechart(scene, graphtree=None, keep_pos=False, dump_gfx=''): ...@@ -491,7 +492,7 @@ def render_statechart(scene, graphtree=None, keep_pos=False, dump_gfx=''):
dump_gfx += '.png' dump_gfx += '.png'
graph.layout(prog='neato', args='-Nfontsize=12, -Efontsize=8 ' graph.layout(prog='neato', args='-Nfontsize=12, -Efontsize=8 '
'-Gsplines=curved -Gsep=1 ' '-Gsplines=curved -Gsep=1 -Gdpi=72 '
'-Gstart=random10 -Goverlap=scale ' '-Gstart=random10 -Goverlap=scale '
'-Nstyle=rounded -Nshape=record -Elen=1 {kp} {dump}' '-Nstyle=rounded -Nshape=record -Elen=1 {kp} {dump}'
.format(kp='-n1' if keep_pos else '', .format(kp='-n1' if keep_pos else '',
...@@ -512,7 +513,9 @@ def render_statechart(scene, graphtree=None, keep_pos=False, dump_gfx=''): ...@@ -512,7 +513,9 @@ def render_statechart(scene, graphtree=None, keep_pos=False, dump_gfx=''):
shape = node.get('shape') shape = node.get('shape')
try: try:
node_symbol = lookup[shape](node, graph) node_symbol = lookup[shape](node, graph)
if graphtree['children'] and shape == 'record': if unicode(node_symbol) in graphtree['children'] \
and shape == 'record':
# Use a different color for non-terminal states
node_symbol.setBrush(QtGui.QBrush(QtGui.QColor(249, 249, 249))) node_symbol.setBrush(QtGui.QBrush(QtGui.QColor(249, 249, 249)))
G_SYMBOLS.add(node_symbol) G_SYMBOLS.add(node_symbol)
node_symbols.append(node_symbol) node_symbols.append(node_symbol)
...@@ -524,6 +527,9 @@ def render_statechart(scene, graphtree=None, keep_pos=False, dump_gfx=''): ...@@ -524,6 +527,9 @@ def render_statechart(scene, graphtree=None, keep_pos=False, dump_gfx=''):
for edge in edges: for edge in edges:
Edge(edge, graph) Edge(edge, graph)
# Make sure the scene has no negative coordinates
scene.translate_to_origin()
for aname, agraph in graphtree['children'].viewitems(): for aname, agraph in graphtree['children'].viewitems():
# At the end, place the content of the scene of the composite states # At the end, place the content of the scene of the composite states
# in the symbol by moving them from their temporary scene # in the symbol by moving them from their temporary scene
......
...@@ -116,7 +116,7 @@ except ImportError: ...@@ -116,7 +116,7 @@ except ImportError:
__all__ = ['opengeode', 'SDL_Scene', 'SDL_View', 'parse'] __all__ = ['opengeode', 'SDL_Scene', 'SDL_View', 'parse']
__version__ = '1.3.2' __version__ = '1.3.3'
if hasattr(sys, 'frozen'): if hasattr(sys, 'frozen'):
# Detect if we are running on Windows (py2exe-generated) # Detect if we are running on Windows (py2exe-generated)
...@@ -1371,10 +1371,9 @@ class SDL_View(QtGui.QGraphicsView, object): ...@@ -1371,10 +1371,9 @@ class SDL_View(QtGui.QGraphicsView, object):
''' Display the About dialog ''' ''' Display the About dialog '''
QtGui.QMessageBox.about(self, 'About OpenGEODE', QtGui.QMessageBox.about(self, 'About OpenGEODE',
'OpenGEODE - a tiny SDL editor for TASTE\n\n' 'OpenGEODE - a tiny SDL editor for TASTE\n\n'
'Author: \nMaxime Perrotin' 'Version {}\n\n'
'\n\nContact: maxime.perrotin@esa.int\n\n' 'Copyright (c) 2012-2015 European Space Agency\n\n'
'Coded with Pyside (Python + Qt)\n' 'Contact: Maxime.Perrotin@esa.int\n\n'.format(__version__))
'and ANTLR 3.1.3 for Python (parser)')
# pylint: disable=C0103 # pylint: disable=C0103
def wheelEvent(self, wheelEvent): def wheelEvent(self, wheelEvent):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment