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
OpenGEODE
Commits
6db01ee9
Commit
6db01ee9
authored
Oct 29, 2015
by
Maxime Perrotin
Browse files
Proper rendering of statechars with aggregations
parent
cdbaeee2
Changes
3
Show whitespace changes
Inline
Side-by-side
opengeode/Connectors.py
View file @
6db01ee9
...
@@ -540,7 +540,8 @@ class Edge(Connection):
...
@@ -540,7 +540,8 @@ class Edge(Connection):
self
.
text_label
.
setY
(
pos
.
y
()
-
height
/
2
)
self
.
text_label
.
setY
(
pos
.
y
()
-
height
/
2
)
self
.
text_label
.
setFont
(
font
)
self
.
text_label
.
setFont
(
font
)
# Make horizontal center alignment, as dot does
# Make horizontal center alignment, as dot does
self
.
text_label
.
setTextWidth
(
self
.
text_label
.
boundingRect
().
width
())
self
.
text_label
.
setTextWidth
(
self
.
text_label
.
boundingRect
().
width
())
fmt
=
QTextBlockFormat
()
fmt
=
QTextBlockFormat
()
fmt
.
setAlignment
(
Qt
.
AlignHCenter
)
fmt
.
setAlignment
(
Qt
.
AlignHCenter
)
cursor
=
self
.
text_label
.
textCursor
()
cursor
=
self
.
text_label
.
textCursor
()
...
...
opengeode/Statechart.py
View file @
6db01ee9
...
@@ -57,7 +57,7 @@ class Record(genericSymbols.HorizontalSymbol, object):
...
@@ -57,7 +57,7 @@ class Record(genericSymbols.HorizontalSymbol, object):
super
(
Record
,
self
).
__init__
(
x
=
node
[
'pos'
][
0
],
super
(
Record
,
self
).
__init__
(
x
=
node
[
'pos'
][
0
],
y
=
node
[
'pos'
][
1
],
text
=
self
.
name
)
y
=
node
[
'pos'
][
1
],
text
=
self
.
name
)
self
.
set_shape
(
node
[
'width'
],
node
[
'height'
])
self
.
set_shape
(
node
[
'width'
],
node
[
'height'
])
#
self.setBrush(QtGui.QBrush(QtGui.QColor(255, 255, 202)))
self
.
setBrush
(
QtGui
.
QBrush
(
QtGui
.
QColor
(
255
,
255
,
202
)))
self
.
graph
=
graph
self
.
graph
=
graph
if
'properties'
in
node
:
if
'properties'
in
node
:
property_box
=
QtGui
.
QGraphicsTextItem
(
self
)
property_box
=
QtGui
.
QGraphicsTextItem
(
self
)
...
@@ -365,12 +365,11 @@ def render_statechart(scene, graphtree=None, keep_pos=False, dump_gfx=''):
...
@@ -365,12 +365,11 @@ def render_statechart(scene, graphtree=None, keep_pos=False, dump_gfx=''):
# in order to resize the parent node accordingly
# in order to resize the parent node accordingly
temp_scene
=
type
(
scene
)()
temp_scene
=
type
(
scene
)()
render_statechart
(
temp_scene
,
agraph
,
keep_pos
,
dump_gfx
)
render_statechart
(
temp_scene
,
agraph
,
keep_pos
,
dump_gfx
)
print
'rendering'
,
aname
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'
]
=
siz
e
.
width
()
/
72.0
node
.
attr
[
'width'
]
=
(
temp_scen
e
.
width
()
+
30
)
/
72.0
node
.
attr
[
'height'
]
=
siz
e
.
height
()
/
72.0
node
.
attr
[
'height'
]
=
(
temp_scen
e
.
height
()
+
30
)
/
72.0
graphtree
[
'children'
][
aname
][
'scene'
]
=
temp_scene
graphtree
[
'children'
][
aname
][
'scene'
]
=
temp_scene
break
break
# Statechart symbols lookup table
# Statechart symbols lookup table
...
@@ -422,7 +421,6 @@ def render_statechart(scene, graphtree=None, keep_pos=False, dump_gfx=''):
...
@@ -422,7 +421,6 @@ def render_statechart(scene, graphtree=None, keep_pos=False, dump_gfx=''):
nodes
=
preprocess_nodes
(
graph
,
bounding_rect
,
dot_dpi
)
nodes
=
preprocess_nodes
(
graph
,
bounding_rect
,
dot_dpi
)
node_symbols
=
[]
node_symbols
=
[]
for
node
in
nodes
:
for
node
in
nodes
:
#print node
shape
=
node
.
get
(
'shape'
)
shape
=
node
.
get
(
'shape'
)
try
:
try
:
node_symbol
=
lookup
[
shape
](
node
,
graph
)
node_symbol
=
lookup
[
shape
](
node
,
graph
)
...
@@ -441,11 +439,16 @@ def render_statechart(scene, graphtree=None, keep_pos=False, dump_gfx=''):
...
@@ -441,11 +439,16 @@ def render_statechart(scene, graphtree=None, keep_pos=False, dump_gfx=''):
# in the symbol by moving them from their temporary scene
# in the symbol by moving them from their temporary scene
for
symb
in
scene
.
visible_symb
:
for
symb
in
scene
.
visible_symb
:
if
unicode
(
symb
)
==
aname
:
if
unicode
(
symb
)
==
aname
:
deltapos
=
symb
.
scenePos
()
+
QtCore
.
QPointF
(
30.0
,
30.0
)
for
each
in
agraph
[
'scene'
].
floating_symb
:
for
each
in
agraph
[
'scene'
].
floating_symb
:
print
'changing scene of'
,
unicode
(
each
)
# In principle we should change the parentItem to make sure
each
.
setParent
(
symb
)
# that all children items are moved together with their
# parent. Unfortunately calls to setParentItem provoke
# a segfault. To be tried again when PySide is fixed...
#each.setParent(symb)
scene
.
addItem
(
each
)
scene
.
addItem
(
each
)
each
.
position
+=
symb
.
scenePos
()
each
.
position
+=
deltapos
each
.
setZValue
(
each
.
zValue
()
+
symb
.
zValue
()
+
1
)
def
create_dot_graph
(
root_ast
,
basic
=
False
):
def
create_dot_graph
(
root_ast
,
basic
=
False
):
...
...
opengeode/TextInteraction.py
View file @
6db01ee9
...
@@ -142,6 +142,7 @@ class EditableText(QGraphicsTextItem, object):
...
@@ -142,6 +142,7 @@ class EditableText(QGraphicsTextItem, object):
def
__init__
(
self
,
parent
,
text
=
'...'
,
hyperlink
=
None
):
def
__init__
(
self
,
parent
,
text
=
'...'
,
hyperlink
=
None
):
super
(
EditableText
,
self
).
__init__
(
parent
)
super
(
EditableText
,
self
).
__init__
(
parent
)
self
.
parent
=
parent
self
.
setFont
(
QFont
(
'Ubuntu'
,
10
))
self
.
setFont
(
QFont
(
'Ubuntu'
,
10
))
self
.
completer
=
Completer
(
self
)
self
.
completer
=
Completer
(
self
)
self
.
completer
.
widget
().
itemActivated
.
connect
(
self
.
completer
.
widget
().
itemActivated
.
connect
(
...
@@ -177,7 +178,7 @@ class EditableText(QGraphicsTextItem, object):
...
@@ -177,7 +178,7 @@ class EditableText(QGraphicsTextItem, object):
def
set_text_alignment
(
self
):
def
set_text_alignment
(
self
):
''' Apply the required text alignment within the text box '''
''' Apply the required text alignment within the text box '''
alignment
=
self
.
parent
Item
()
.
text_alignment
alignment
=
self
.
parent
.
text_alignment
self
.
setTextWidth
(
self
.
boundingRect
().
width
())
self
.
setTextWidth
(
self
.
boundingRect
().
width
())
fmt
=
QTextBlockFormat
()
fmt
=
QTextBlockFormat
()
fmt
.
setAlignment
(
alignment
)
fmt
.
setAlignment
(
alignment
)
...
@@ -189,11 +190,11 @@ class EditableText(QGraphicsTextItem, object):
...
@@ -189,11 +190,11 @@ class EditableText(QGraphicsTextItem, object):
def
set_textbox_position
(
self
):
def
set_textbox_position
(
self
):
''' Compute the textbox position '''
''' Compute the textbox position '''
parent_rect
=
self
.
parent
Item
()
.
boundingRect
()
parent_rect
=
self
.
parent
.
boundingRect
()
rect
=
self
.
boundingRect
()
rect
=
self
.
boundingRect
()
# Use parent symbol alignment requirement
# Use parent symbol alignment requirement
# Does not support right nor bottom alignment
# Does not support right nor bottom alignment
alignment
=
self
.
parent
Item
()
.
textbox_alignment
alignment
=
self
.
parent
.
textbox_alignment
rect_center
=
parent_rect
.
center
()
-
rect
.
center
()
rect_center
=
parent_rect
.
center
()
-
rect
.
center
()
if
alignment
&
Qt
.
AlignLeft
:
if
alignment
&
Qt
.
AlignLeft
:
x_pos
=
0
x_pos
=
0
...
@@ -215,14 +216,14 @@ class EditableText(QGraphicsTextItem, object):
...
@@ -215,14 +216,14 @@ class EditableText(QGraphicsTextItem, object):
If needed, request a resizing of the parent item
If needed, request a resizing of the parent item
(when text size expands)
(when text size expands)
'''
'''
if
self
.
parent
Item
()
.
auto_expand
:
if
self
.
parent
.
auto_expand
:
self
.
setTextWidth
(
-
1
)
self
.
setTextWidth
(
-
1
)
parent_rect
=
self
.
parent
Item
()
.
boundingRect
()
parent_rect
=
self
.
parent
.
boundingRect
()
rect
=
self
.
boundingRect
()
rect
=
self
.
boundingRect
()
if
rect
.
width
()
+
30
>
parent_rect
.
width
():
if
rect
.
width
()
+
30
>
parent_rect
.
width
():
parent_rect
.
setWidth
(
rect
.
width
()
+
30
)
parent_rect
.
setWidth
(
rect
.
width
()
+
30
)
parent_rect
.
setHeight
(
max
(
rect
.
height
(),
parent_rect
.
height
()))
parent_rect
.
setHeight
(
max
(
rect
.
height
(),
parent_rect
.
height
()))
self
.
parent
Item
()
.
resize_item
(
parent_rect
)
self
.
parent
.
resize_item
(
parent_rect
)
@
Slot
(
QListWidgetItem
)
@
Slot
(
QListWidgetItem
)
def
completion_selected
(
self
,
item
):
def
completion_selected
(
self
,
item
):
...
@@ -317,7 +318,7 @@ class EditableText(QGraphicsTextItem, object):
...
@@ -317,7 +318,7 @@ class EditableText(QGraphicsTextItem, object):
self
.
completer
.
show
()
self
.
completer
.
show
()
# Make sure parent item has higher visibility than its siblings
# Make sure parent item has higher visibility than its siblings
# (useful in decision branches)
# (useful in decision branches)
self
.
parent
Item
()
.
setZValue
(
1
)
self
.
parent
.
setZValue
(
1
)
self
.
completer
.
setFocusProxy
(
self
)
self
.
completer
.
setFocusProxy
(
self
)
self
.
setTabChangesFocus
(
True
)
self
.
setTabChangesFocus
(
True
)
else
:
else
:
...
@@ -342,7 +343,7 @@ class EditableText(QGraphicsTextItem, object):
...
@@ -342,7 +343,7 @@ class EditableText(QGraphicsTextItem, object):
if
not
self
.
completer
or
not
self
.
completer
.
isVisible
():
if
not
self
.
completer
or
not
self
.
completer
.
isVisible
():
# Trigger a select - side effect makes the toolbar update
# Trigger a select - side effect makes the toolbar update
try
:
try
:
self
.
parent
Item
()
.
select
(
True
)
self
.
parent
.
select
(
True
)
except
AttributeError
:
except
AttributeError
:
# Some parents may not be selectable (e.g. Signalroute)
# Some parents may not be selectable (e.g. Signalroute)
pass
pass
...
@@ -352,21 +353,21 @@ class EditableText(QGraphicsTextItem, object):
...
@@ -352,21 +353,21 @@ class EditableText(QGraphicsTextItem, object):
text_cursor
.
clearSelection
()
text_cursor
.
clearSelection
()
self
.
setTextCursor
(
text_cursor
)
self
.
setTextCursor
(
text_cursor
)
# If something has changed, check syntax and create undo command
# If something has changed, check syntax and create undo command
if
(
self
.
oldSize
!=
self
.
parent
Item
()
.
boundingRect
()
or
if
(
self
.
oldSize
!=
self
.
parent
.
boundingRect
()
or
self
.
oldText
!=
unicode
(
self
)):
self
.
oldText
!=
unicode
(
self
)):
# Call syntax checker from item containing the text (if any)
# Call syntax checker from item containing the text (if any)
self
.
scene
().
check_syntax
(
self
.
parent
Item
()
)
self
.
scene
().
check_syntax
(
self
.
parent
)
# Update class completion list
# Update class completion list
self
.
scene
().
update_completion_list
(
self
.
parentItem
())
self
.
scene
().
update_completion_list
(
self
.
parentItem
())
# Create undo command, including possible CAM
# Create undo command, including possible CAM
with
undoCommands
.
UndoMacro
(
self
.
scene
().
undo_stack
,
'Text'
):
with
undoCommands
.
UndoMacro
(
self
.
scene
().
undo_stack
,
'Text'
):
undo_cmd
=
undoCommands
.
ResizeSymbol
(
undo_cmd
=
undoCommands
.
ResizeSymbol
(
self
.
parent
Item
()
,
self
.
oldSize
,
self
.
parent
,
self
.
oldSize
,
self
.
parent
Item
()
.
boundingRect
())
self
.
parent
.
boundingRect
())
self
.
scene
().
undo_stack
.
push
(
undo_cmd
)
self
.
scene
().
undo_stack
.
push
(
undo_cmd
)
try
:
try
:
self
.
parent
Item
()
.
cam
(
self
.
parent
Item
()
.
pos
(),
self
.
parent
.
cam
(
self
.
parent
.
pos
(),
self
.
parent
Item
()
.
pos
())
self
.
parent
.
pos
())
except
AttributeError
:
except
AttributeError
:
# Some parents may not have CAM function (e.g. Channel)
# Some parents may not have CAM function (e.g. Channel)
pass
pass
...
@@ -376,10 +377,9 @@ class EditableText(QGraphicsTextItem, object):
...
@@ -376,10 +377,9 @@ class EditableText(QGraphicsTextItem, object):
self
.
scene
().
undo_stack
.
push
(
undo_cmd
)
self
.
scene
().
undo_stack
.
push
(
undo_cmd
)
self
.
set_text_alignment
()
self
.
set_text_alignment
()
# Reset Z-Values that were increased when getting focus
# Reset Z-Values that were increased when getting focus
parent
=
self
.
parentItem
()
top_level
=
self
.
parent
.
top_level
()
top_level
=
parent
.
top_level
()
top_level
.
setZValue
(
top_level
.
zValue
()
-
1
)
top_level
.
setZValue
(
top_level
.
zValue
()
-
1
)
parent
.
setZValue
(
parent
.
zValue
()
-
1
)
self
.
parent
.
setZValue
(
self
.
parent
.
zValue
()
-
1
)
super
(
EditableText
,
self
).
focusOutEvent
(
event
)
super
(
EditableText
,
self
).
focusOutEvent
(
event
)
# pylint: disable=C0103
# pylint: disable=C0103
...
@@ -388,14 +388,13 @@ class EditableText(QGraphicsTextItem, object):
...
@@ -388,14 +388,13 @@ class EditableText(QGraphicsTextItem, object):
super
(
EditableText
,
self
).
focusInEvent
(
event
)
super
(
EditableText
,
self
).
focusInEvent
(
event
)
# Change the Z-value of items to make sure the
# Change the Z-value of items to make sure the
# completer is always be on top of other symbols
# completer is always be on top of other symbols
parent
=
self
.
parentItem
()
top_level
=
self
.
parent
.
top_level
()
top_level
=
parent
.
top_level
()
top_level
.
setZValue
(
top_level
.
zValue
()
+
1
)
top_level
.
setZValue
(
top_level
.
zValue
()
+
1
)
parent
.
setZValue
(
parent
.
zValue
()
+
1
)
self
.
parent
.
setZValue
(
self
.
parent
.
zValue
()
+
1
)
# Trigger a select - side effect makes the toolbar update
# Trigger a select - side effect makes the toolbar update
try
:
try
:
parent
.
select
(
True
)
self
.
parent
.
select
(
True
)
except
AttributeError
:
except
AttributeError
:
# Some parents may not be selectable (e.g. Signalroute)
# Some parents may not be selectable (e.g. Signalroute)
pass
pass
...
@@ -408,7 +407,7 @@ class EditableText(QGraphicsTextItem, object):
...
@@ -408,7 +407,7 @@ class EditableText(QGraphicsTextItem, object):
self
.
setTextWidth
(
-
1
)
self
.
setTextWidth
(
-
1
)
if
not
self
.
editing
:
if
not
self
.
editing
:
self
.
oldText
=
unicode
(
self
)
self
.
oldText
=
unicode
(
self
)
self
.
oldSize
=
parent
.
boundingRect
()
self
.
oldSize
=
self
.
parent
.
boundingRect
()
self
.
editing
=
True
self
.
editing
=
True
def
__str__
(
self
):
def
__str__
(
self
):
...
...
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