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):
self
.
text_label
.
setY
(
pos
.
y
()
-
height
/
2
)
self
.
text_label
.
setFont
(
font
)
# 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
.
setAlignment
(
Qt
.
AlignHCenter
)
cursor
=
self
.
text_label
.
textCursor
()
...
...
opengeode/Statechart.py
View file @
6db01ee9
...
...
@@ -57,7 +57,7 @@ class Record(genericSymbols.HorizontalSymbol, object):
super
(
Record
,
self
).
__init__
(
x
=
node
[
'pos'
][
0
],
y
=
node
[
'pos'
][
1
],
text
=
self
.
name
)
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
if
'properties'
in
node
:
property_box
=
QtGui
.
QGraphicsTextItem
(
self
)
...
...
@@ -365,12 +365,11 @@ def render_statechart(scene, graphtree=None, keep_pos=False, dump_gfx=''):
# in order to resize the parent node accordingly
temp_scene
=
type
(
scene
)()
render_statechart
(
temp_scene
,
agraph
,
keep_pos
,
dump_gfx
)
print
'rendering'
,
aname
for
node
in
graphtree
[
'graph'
].
iternodes
():
if
node
==
aname
:
size
=
temp_scene
.
itemsBoundingRect
()
node
.
attr
[
'width'
]
=
siz
e
.
width
()
/
72.0
node
.
attr
[
'height'
]
=
siz
e
.
height
()
/
72.0
node
.
attr
[
'width'
]
=
(
temp_scen
e
.
width
()
+
30
)
/
72.0
node
.
attr
[
'height'
]
=
(
temp_scen
e
.
height
()
+
30
)
/
72.0
graphtree
[
'children'
][
aname
][
'scene'
]
=
temp_scene
break
# Statechart symbols lookup table
...
...
@@ -422,7 +421,6 @@ def render_statechart(scene, graphtree=None, keep_pos=False, dump_gfx=''):
nodes
=
preprocess_nodes
(
graph
,
bounding_rect
,
dot_dpi
)
node_symbols
=
[]
for
node
in
nodes
:
#print node
shape
=
node
.
get
(
'shape'
)
try
:
node_symbol
=
lookup
[
shape
](
node
,
graph
)
...
...
@@ -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
for
symb
in
scene
.
visible_symb
:
if
unicode
(
symb
)
==
aname
:
deltapos
=
symb
.
scenePos
()
+
QtCore
.
QPointF
(
30.0
,
30.0
)
for
each
in
agraph
[
'scene'
].
floating_symb
:
print
'changing scene of'
,
unicode
(
each
)
each
.
setParent
(
symb
)
# In principle we should change the parentItem to make sure
# 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
)
each
.
position
+=
symb
.
scenePos
()
each
.
position
+=
deltapos
each
.
setZValue
(
each
.
zValue
()
+
symb
.
zValue
()
+
1
)
def
create_dot_graph
(
root_ast
,
basic
=
False
):
...
...
opengeode/TextInteraction.py
View file @
6db01ee9
...
...
@@ -142,6 +142,7 @@ class EditableText(QGraphicsTextItem, object):
def
__init__
(
self
,
parent
,
text
=
'...'
,
hyperlink
=
None
):
super
(
EditableText
,
self
).
__init__
(
parent
)
self
.
parent
=
parent
self
.
setFont
(
QFont
(
'Ubuntu'
,
10
))
self
.
completer
=
Completer
(
self
)
self
.
completer
.
widget
().
itemActivated
.
connect
(
...
...
@@ -177,7 +178,7 @@ class EditableText(QGraphicsTextItem, object):
def
set_text_alignment
(
self
):
''' 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
())
fmt
=
QTextBlockFormat
()
fmt
.
setAlignment
(
alignment
)
...
...
@@ -189,11 +190,11 @@ class EditableText(QGraphicsTextItem, object):
def
set_textbox_position
(
self
):
''' Compute the textbox position '''
parent_rect
=
self
.
parent
Item
()
.
boundingRect
()
parent_rect
=
self
.
parent
.
boundingRect
()
rect
=
self
.
boundingRect
()
# Use parent symbol alignment requirement
# 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
()
if
alignment
&
Qt
.
AlignLeft
:
x_pos
=
0
...
...
@@ -215,14 +216,14 @@ class EditableText(QGraphicsTextItem, object):
If needed, request a resizing of the parent item
(when text size expands)
'''
if
self
.
parent
Item
()
.
auto_expand
:
if
self
.
parent
.
auto_expand
:
self
.
setTextWidth
(
-
1
)
parent_rect
=
self
.
parent
Item
()
.
boundingRect
()
parent_rect
=
self
.
parent
.
boundingRect
()
rect
=
self
.
boundingRect
()
if
rect
.
width
()
+
30
>
parent_rect
.
width
():
parent_rect
.
setWidth
(
rect
.
width
()
+
30
)
parent_rect
.
setHeight
(
max
(
rect
.
height
(),
parent_rect
.
height
()))
self
.
parent
Item
()
.
resize_item
(
parent_rect
)
self
.
parent
.
resize_item
(
parent_rect
)
@
Slot
(
QListWidgetItem
)
def
completion_selected
(
self
,
item
):
...
...
@@ -317,7 +318,7 @@ class EditableText(QGraphicsTextItem, object):
self
.
completer
.
show
()
# Make sure parent item has higher visibility than its siblings
# (useful in decision branches)
self
.
parent
Item
()
.
setZValue
(
1
)
self
.
parent
.
setZValue
(
1
)
self
.
completer
.
setFocusProxy
(
self
)
self
.
setTabChangesFocus
(
True
)
else
:
...
...
@@ -342,7 +343,7 @@ class EditableText(QGraphicsTextItem, object):
if
not
self
.
completer
or
not
self
.
completer
.
isVisible
():
# Trigger a select - side effect makes the toolbar update
try
:
self
.
parent
Item
()
.
select
(
True
)
self
.
parent
.
select
(
True
)
except
AttributeError
:
# Some parents may not be selectable (e.g. Signalroute)
pass
...
...
@@ -352,21 +353,21 @@ class EditableText(QGraphicsTextItem, object):
text_cursor
.
clearSelection
()
self
.
setTextCursor
(
text_cursor
)
# 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
)):
# 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
self
.
scene
().
update_completion_list
(
self
.
parentItem
())
# Create undo command, including possible CAM
with
undoCommands
.
UndoMacro
(
self
.
scene
().
undo_stack
,
'Text'
):
undo_cmd
=
undoCommands
.
ResizeSymbol
(
self
.
parent
Item
()
,
self
.
oldSize
,
self
.
parent
Item
()
.
boundingRect
())
self
.
parent
,
self
.
oldSize
,
self
.
parent
.
boundingRect
())
self
.
scene
().
undo_stack
.
push
(
undo_cmd
)
try
:
self
.
parent
Item
()
.
cam
(
self
.
parent
Item
()
.
pos
(),
self
.
parent
Item
()
.
pos
())
self
.
parent
.
cam
(
self
.
parent
.
pos
(),
self
.
parent
.
pos
())
except
AttributeError
:
# Some parents may not have CAM function (e.g. Channel)
pass
...
...
@@ -376,10 +377,9 @@ class EditableText(QGraphicsTextItem, object):
self
.
scene
().
undo_stack
.
push
(
undo_cmd
)
self
.
set_text_alignment
()
# Reset Z-Values that were increased when getting focus
parent
=
self
.
parentItem
()
top_level
=
parent
.
top_level
()
top_level
=
self
.
parent
.
top_level
()
top_level
.
setZValue
(
top_level
.
zValue
()
-
1
)
parent
.
setZValue
(
parent
.
zValue
()
-
1
)
self
.
parent
.
setZValue
(
self
.
parent
.
zValue
()
-
1
)
super
(
EditableText
,
self
).
focusOutEvent
(
event
)
# pylint: disable=C0103
...
...
@@ -388,14 +388,13 @@ class EditableText(QGraphicsTextItem, object):
super
(
EditableText
,
self
).
focusInEvent
(
event
)
# Change the Z-value of items to make sure the
# completer is always be on top of other symbols
parent
=
self
.
parentItem
()
top_level
=
parent
.
top_level
()
top_level
=
self
.
parent
.
top_level
()
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
try
:
parent
.
select
(
True
)
self
.
parent
.
select
(
True
)
except
AttributeError
:
# Some parents may not be selectable (e.g. Signalroute)
pass
...
...
@@ -408,7 +407,7 @@ class EditableText(QGraphicsTextItem, object):
self
.
setTextWidth
(
-
1
)
if
not
self
.
editing
:
self
.
oldText
=
unicode
(
self
)
self
.
oldSize
=
parent
.
boundingRect
()
self
.
oldSize
=
self
.
parent
.
boundingRect
()
self
.
editing
=
True
def
__str__
(
self
):
...
...
Write
Preview
Markdown
is supported
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