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
29bcca73
Commit
29bcca73
authored
Oct 16, 2014
by
Maxime Perrotin
Browse files
Fix positionning of symbols when loading/rendering
parent
abfe2a93
Changes
8
Expand all
Show whitespace changes
Inline
Side-by-side
genericSymbols.py
View file @
29bcca73
...
@@ -695,15 +695,17 @@ class Comment(Symbol):
...
@@ -695,15 +695,17 @@ class Comment(Symbol):
def
__init__
(
self
,
parent
=
None
,
ast
=
None
):
def
__init__
(
self
,
parent
=
None
,
ast
=
None
):
ast
=
ast
or
ogAST
.
Comment
()
ast
=
ast
or
ogAST
.
Comment
()
self
.
ast
=
ast
super
(
Comment
,
self
).
__init__
(
parent
)
super
(
Comment
,
self
).
__init__
(
parent
)
self
.
connection
=
None
self
.
connection
=
None
if
parent
:
local_pos
=
parent
.
mapFromScene
(
ast
.
pos_x
,
ast
.
pos_y
)
self
.
insert_symbol
(
parent
,
local_pos
.
x
(),
local_pos
.
y
())
self
.
set_shape
(
ast
.
width
,
ast
.
height
)
self
.
set_shape
(
ast
.
width
,
ast
.
height
)
self
.
text
=
EditableText
(
parent
=
self
,
self
.
text
=
EditableText
(
parent
=
self
,
text
=
ast
.
inputString
,
text
=
ast
.
inputString
,
hyperlink
=
ast
.
hyperlink
)
hyperlink
=
ast
.
hyperlink
)
if
parent
:
local_pos
=
parent
.
mapFromScene
(
ast
.
pos_x
or
0
,
ast
.
pos_y
or
0
)
self
.
insert_symbol
(
parent
,
local_pos
.
x
(),
local_pos
.
y
())
#self.set_shape(ast.width, ast.height)
self
.
common_name
=
'end'
self
.
common_name
=
'end'
self
.
parser
=
ogParser
self
.
parser
=
ogParser
...
...
ogAST.py
View file @
29bcca73
...
@@ -293,8 +293,7 @@ class Decision(object):
...
@@ -293,8 +293,7 @@ class Decision(object):
self
.
inputString
=
''
self
.
inputString
=
''
self
.
line
=
None
self
.
line
=
None
self
.
charPositionInLine
=
None
self
.
charPositionInLine
=
None
self
.
pos_x
=
0
self
.
pos_x
,
self
.
pos_y
=
None
,
None
self
.
pos_y
=
0
self
.
width
=
70
self
.
width
=
70
self
.
height
=
50
self
.
height
=
50
# kind can be 'any', 'informal_text', or 'question'
# kind can be 'any', 'informal_text', or 'question'
...
@@ -325,8 +324,7 @@ class Answer(object):
...
@@ -325,8 +324,7 @@ class Answer(object):
self
.
inputString
=
''
self
.
inputString
=
''
self
.
line
=
None
self
.
line
=
None
self
.
charPositionInLine
=
None
self
.
charPositionInLine
=
None
self
.
pos_x
=
0
self
.
pos_x
,
self
.
pos_y
=
None
,
None
self
.
pos_y
=
0
self
.
width
=
70
self
.
width
=
70
self
.
height
=
10.5
self
.
height
=
10.5
# one of 'closed_range' 'constant' 'open_range' 'else' 'informal_text'
# one of 'closed_range' 'constant' 'open_range' 'else' 'informal_text'
...
@@ -360,8 +358,7 @@ class Task(object):
...
@@ -360,8 +358,7 @@ class Task(object):
self
.
inputString
=
''
self
.
inputString
=
''
self
.
line
=
None
self
.
line
=
None
self
.
charPositionInLine
=
None
self
.
charPositionInLine
=
None
self
.
pos_x
=
0
self
.
pos_x
,
self
.
pos_y
=
None
,
None
self
.
pos_y
=
0
self
.
width
=
70
self
.
width
=
70
self
.
height
=
35
self
.
height
=
35
# optional comment symbol
# optional comment symbol
...
@@ -400,8 +397,7 @@ class Output(object):
...
@@ -400,8 +397,7 @@ class Output(object):
def
__init__
(
self
,
defName
=
''
):
def
__init__
(
self
,
defName
=
''
):
''' Set of OUTPUT statements '''
''' Set of OUTPUT statements '''
self
.
inputString
=
defName
self
.
inputString
=
defName
self
.
pos_x
=
0
self
.
pos_x
,
self
.
pos_y
=
None
,
None
self
.
pos_y
=
0
self
.
width
=
70
self
.
width
=
70
self
.
height
=
35
self
.
height
=
35
self
.
line
=
None
self
.
line
=
None
...
@@ -475,7 +471,7 @@ class Label(object):
...
@@ -475,7 +471,7 @@ class Label(object):
''' Initialize the label attributes '''
''' Initialize the label attributes '''
# inputString holds the label name
# inputString holds the label name
self
.
inputString
=
''
self
.
inputString
=
''
self
.
pos_x
=
0
self
.
pos_x
,
self
.
pos_y
=
None
,
None
self
.
pos_y
=
0
self
.
pos_y
=
0
self
.
width
=
70
self
.
width
=
70
self
.
height
=
35
self
.
height
=
35
...
@@ -496,7 +492,7 @@ class Label(object):
...
@@ -496,7 +492,7 @@ class Label(object):
l
=
self
.
line
,
c
=
self
.
charPositionInLine
)
l
=
self
.
line
,
c
=
self
.
charPositionInLine
)
class
Floating_label
(
Label
,
object
):
class
Floating_label
(
Label
):
''' AST Entry for a floating label '''
''' AST Entry for a floating label '''
def
__init__
(
self
,
label
=
None
):
def
__init__
(
self
,
label
=
None
):
''' Initialize the floating label attributes '''
''' Initialize the floating label attributes '''
...
@@ -549,8 +545,7 @@ class Input(object):
...
@@ -549,8 +545,7 @@ class Input(object):
''' Initialize the Input attributes '''
''' Initialize the Input attributes '''
# inputString is the user text, it can contain several inputs
# inputString is the user text, it can contain several inputs
self
.
inputString
=
''
self
.
inputString
=
''
self
.
pos_x
=
0
self
.
pos_x
,
self
.
pos_y
=
None
,
None
self
.
pos_y
=
0
self
.
width
=
70
self
.
width
=
70
self
.
height
=
35
self
.
height
=
35
self
.
line
=
None
self
.
line
=
None
...
@@ -599,8 +594,7 @@ class Start(object):
...
@@ -599,8 +594,7 @@ class Start(object):
def
__init__
(
self
):
def
__init__
(
self
):
''' Initialize the Start symbol attributes '''
''' Initialize the Start symbol attributes '''
self
.
inputString
=
''
self
.
inputString
=
''
self
.
pos_x
=
0
self
.
pos_x
,
self
.
pos_y
=
None
,
None
self
.
pos_y
=
0
self
.
width
=
70
self
.
width
=
70
self
.
height
=
35
self
.
height
=
35
# start transition is of type Transition
# start transition is of type Transition
...
@@ -633,8 +627,8 @@ class Comment(object):
...
@@ -633,8 +627,8 @@ class Comment(object):
''' Comment symbol '''
''' Comment symbol '''
# inputString is the comment value itself
# inputString is the comment value itself
self
.
inputString
=
''
self
.
inputString
=
''
self
.
pos_x
=
0
self
.
pos_x
=
None
self
.
pos_y
=
0
self
.
pos_y
=
None
self
.
width
=
70
self
.
width
=
70
self
.
height
=
35
self
.
height
=
35
self
.
line
=
None
self
.
line
=
None
...
@@ -659,7 +653,7 @@ class State(object):
...
@@ -659,7 +653,7 @@ class State(object):
self
.
statelist
=
[]
self
.
statelist
=
[]
self
.
line
=
None
self
.
line
=
None
self
.
charPositionInLine
=
None
self
.
charPositionInLine
=
None
self
.
pos_x
=
0
self
.
pos_x
,
self
.
pos_y
=
None
,
None
self
.
pos_y
=
0
self
.
pos_y
=
0
self
.
width
=
70
self
.
width
=
70
self
.
height
=
35
self
.
height
=
35
...
@@ -690,8 +684,7 @@ class TextArea(object):
...
@@ -690,8 +684,7 @@ class TextArea(object):
self
.
line
=
None
self
.
line
=
None
self
.
charPositionInLine
=
None
self
.
charPositionInLine
=
None
# Set default coordinates and width/height
# Set default coordinates and width/height
self
.
pos_x
=
0
self
.
pos_x
,
self
.
pos_y
=
None
,
None
self
.
pos_y
=
0
self
.
width
=
170
self
.
width
=
170
self
.
height
=
140
self
.
height
=
140
# DCL variables in the text area {name: (sort, default_value), ...}
# DCL variables in the text area {name: (sort, default_value), ...}
...
@@ -731,7 +724,7 @@ class Procedure(object):
...
@@ -731,7 +724,7 @@ class Procedure(object):
self
.
line
=
None
self
.
line
=
None
self
.
charPositionInLine
=
None
self
.
charPositionInLine
=
None
# Set default coordinates and width/height
# Set default coordinates and width/height
self
.
pos_x
=
self
.
pos_y
=
0
self
.
pos_x
=
self
.
pos_y
=
None
self
.
width
=
70
self
.
width
=
70
self
.
height
=
35
self
.
height
=
35
# Optional hyperlink
# Optional hyperlink
...
...
opengeode.py
View file @
29bcca73
...
@@ -422,6 +422,25 @@ class SDL_Scene(QtGui.QGraphicsScene, object):
...
@@ -422,6 +422,25 @@ class SDL_Scene(QtGui.QGraphicsScene, object):
# Render top-level items and their children:
# Render top-level items and their children:
for
each
in
Renderer
.
render
(
content
,
dest_scene
):
for
each
in
Renderer
.
render
(
content
,
dest_scene
):
G_SYMBOLS
.
add
(
each
)
G_SYMBOLS
.
add
(
each
)
# Refreshing the scene may result in resizing some symbols
dest_scene
.
refresh
()
for
each
in
dest_scene
.
floating_symb
:
# Once everything is rendered, adjust position of each
# symbol to the value from the AST (positions may be
# slightly altered by the reshaping functions)
def
fix_pos_from_ast
(
symbol
):
try
:
if
symbol
.
ast
.
pos_x
and
symbol
.
ast
.
pos_y
:
relpos
=
symbol
.
mapFromScene
(
symbol
.
ast
.
pos_x
,
symbol
.
ast
.
pos_y
)
symbol
.
moveBy
(
relpos
.
x
(),
relpos
.
y
())
symbol
.
update_connections
()
for
child
in
symbol
.
childItems
():
fix_pos_from_ast
(
child
)
except
AttributeError
:
# no AST
pass
fix_pos_from_ast
(
each
)
except
TypeError
:
except
TypeError
:
LOG
.
error
(
traceback
.
format_exc
())
LOG
.
error
(
traceback
.
format_exc
())
...
...
sdlSymbols.py
View file @
29bcca73
...
@@ -138,12 +138,13 @@ class Input(HorizontalSymbol):
...
@@ -138,12 +138,13 @@ class Input(HorizontalSymbol):
def
__init__
(
self
,
parent
=
None
,
ast
=
None
):
def
__init__
(
self
,
parent
=
None
,
ast
=
None
):
''' Create the INPUT symbol '''
''' Create the INPUT symbol '''
ast
=
ast
or
ogAST
.
Input
()
ast
=
ast
or
ogAST
.
Input
()
self
.
ast
=
ast
self
.
branch_entrypoint
=
None
self
.
branch_entrypoint
=
None
if
not
ast
.
pos_y
and
parent
:
if
not
ast
.
pos_y
and
parent
:
# Make sure the item is placed below its parent
# Make sure the item is placed below its parent
ast
.
pos_y
=
parent
.
y
()
+
parent
.
boundingRect
().
height
()
+
10
ast
.
pos_y
=
parent
.
y
()
+
parent
.
boundingRect
().
height
()
+
10
super
(
Input
,
self
).
__init__
(
parent
,
text
=
ast
.
inputString
,
super
(
Input
,
self
).
__init__
(
parent
,
text
=
ast
.
inputString
,
x
=
ast
.
pos_x
,
y
=
ast
.
pos_y
,
hyperlink
=
ast
.
hyperlink
)
x
=
ast
.
pos_x
or
0
,
y
=
ast
.
pos_y
or
0
,
hyperlink
=
ast
.
hyperlink
)
self
.
set_shape
(
ast
.
width
,
ast
.
height
)
self
.
set_shape
(
ast
.
width
,
ast
.
height
)
gradient
=
QRadialGradient
(
50
,
50
,
50
,
50
,
50
)
gradient
=
QRadialGradient
(
50
,
50
,
50
,
50
,
50
)
gradient
.
setColorAt
(
0
,
QColor
(
255
,
240
,
170
))
gradient
.
setColorAt
(
0
,
QColor
(
255
,
240
,
170
))
...
@@ -237,8 +238,9 @@ class Output(VerticalSymbol):
...
@@ -237,8 +238,9 @@ class Output(VerticalSymbol):
def
__init__
(
self
,
parent
=
None
,
ast
=
None
):
def
__init__
(
self
,
parent
=
None
,
ast
=
None
):
ast
=
ast
or
ogAST
.
Output
()
ast
=
ast
or
ogAST
.
Output
()
self
.
ast
=
ast
super
(
Output
,
self
).
__init__
(
parent
=
parent
,
super
(
Output
,
self
).
__init__
(
parent
=
parent
,
text
=
ast
.
inputString
,
x
=
ast
.
pos_x
,
y
=
ast
.
pos_y
,
text
=
ast
.
inputString
,
x
=
ast
.
pos_x
or
0
,
y
=
ast
.
pos_y
or
0
,
hyperlink
=
ast
.
hyperlink
)
hyperlink
=
ast
.
hyperlink
)
self
.
set_shape
(
ast
.
width
,
ast
.
height
)
self
.
set_shape
(
ast
.
width
,
ast
.
height
)
...
@@ -288,10 +290,11 @@ class Decision(VerticalSymbol):
...
@@ -288,10 +290,11 @@ class Decision(VerticalSymbol):
def
__init__
(
self
,
parent
=
None
,
ast
=
None
):
def
__init__
(
self
,
parent
=
None
,
ast
=
None
):
ast
=
ast
or
ogAST
.
Decision
()
ast
=
ast
or
ogAST
.
Decision
()
self
.
ast
=
ast
# Define the point where all branches of the decision can join again
# Define the point where all branches of the decision can join again
self
.
connectionPoint
=
QPoint
(
ast
.
width
/
2
,
ast
.
height
+
30
)
self
.
connectionPoint
=
QPoint
(
ast
.
width
/
2
,
ast
.
height
+
30
)
super
(
Decision
,
self
).
__init__
(
parent
,
text
=
ast
.
inputString
,
super
(
Decision
,
self
).
__init__
(
parent
,
text
=
ast
.
inputString
,
x
=
ast
.
pos_x
,
y
=
ast
.
pos_y
,
hyperlink
=
ast
.
hyperlink
)
x
=
ast
.
pos_x
or
0
,
y
=
ast
.
pos_y
or
0
,
hyperlink
=
ast
.
hyperlink
)
self
.
set_shape
(
ast
.
width
,
ast
.
height
)
self
.
set_shape
(
ast
.
width
,
ast
.
height
)
self
.
setBrush
(
QColor
(
255
,
255
,
202
))
self
.
setBrush
(
QColor
(
255
,
255
,
202
))
self
.
minDistanceToSymbolAbove
=
0
self
.
minDistanceToSymbolAbove
=
0
...
@@ -411,7 +414,7 @@ class DecisionAnswer(HorizontalSymbol):
...
@@ -411,7 +414,7 @@ class DecisionAnswer(HorizontalSymbol):
def
__init__
(
self
,
parent
=
None
,
ast
=
None
):
def
__init__
(
self
,
parent
=
None
,
ast
=
None
):
ast
=
ast
or
ogAST
.
Answer
()
ast
=
ast
or
ogAST
.
Answer
()
# temp, FIXME
self
.
ast
=
ast
self
.
width
,
self
.
height
=
ast
.
width
,
ast
.
height
self
.
width
,
self
.
height
=
ast
.
width
,
ast
.
height
self
.
terminal_symbol
=
False
self
.
terminal_symbol
=
False
# last_branch_item is used to compute branch length
# last_branch_item is used to compute branch length
...
@@ -419,7 +422,9 @@ class DecisionAnswer(HorizontalSymbol):
...
@@ -419,7 +422,9 @@ class DecisionAnswer(HorizontalSymbol):
self
.
last_branch_item
=
self
self
.
last_branch_item
=
self
super
(
DecisionAnswer
,
self
).
__init__
(
parent
,
super
(
DecisionAnswer
,
self
).
__init__
(
parent
,
text
=
ast
.
inputString
,
text
=
ast
.
inputString
,
x
=
ast
.
pos_x
,
y
=
ast
.
pos_y
,
hyperlink
=
ast
.
hyperlink
)
x
=
ast
.
pos_x
or
0
,
y
=
ast
.
pos_y
or
0
,
hyperlink
=
ast
.
hyperlink
)
self
.
set_shape
(
ast
.
width
,
ast
.
height
)
self
.
set_shape
(
ast
.
width
,
ast
.
height
)
#self.setPen(QColor(0, 0, 0, 0))
#self.setPen(QColor(0, 0, 0, 0))
self
.
branch_entrypoint
=
self
self
.
branch_entrypoint
=
self
...
@@ -471,13 +476,17 @@ class Join(VerticalSymbol):
...
@@ -471,13 +476,17 @@ class Join(VerticalSymbol):
redbold
=
SDL_REDBOLD
redbold
=
SDL_REDBOLD
def
__init__
(
self
,
parent
=
None
,
ast
=
None
):
def
__init__
(
self
,
parent
=
None
,
ast
=
None
):
self
.
ast
=
ast
if
not
ast
:
if
not
ast
:
ast
=
ogAST
.
Terminator
(
defName
=
''
)
ast
=
ogAST
.
Terminator
(
defName
=
''
)
ast
.
pos_y
=
0
ast
.
pos_y
=
0
ast
.
width
=
35
ast
.
width
=
35
ast
.
height
=
35
ast
.
height
=
35
super
(
Join
,
self
).
__init__
(
parent
,
text
=
ast
.
inputString
,
super
(
Join
,
self
).
__init__
(
parent
,
x
=
ast
.
pos_x
,
y
=
ast
.
pos_y
,
hyperlink
=
ast
.
hyperlink
)
text
=
ast
.
inputString
,
x
=
ast
.
pos_x
,
y
=
ast
.
pos_y
,
hyperlink
=
ast
.
hyperlink
)
self
.
set_shape
(
ast
.
width
,
ast
.
height
)
self
.
set_shape
(
ast
.
width
,
ast
.
height
)
self
.
setPen
(
QPen
(
Qt
.
blue
))
self
.
setPen
(
QPen
(
Qt
.
blue
))
self
.
terminal_symbol
=
True
self
.
terminal_symbol
=
True
...
@@ -522,6 +531,7 @@ class ProcedureStop(Join):
...
@@ -522,6 +531,7 @@ class ProcedureStop(Join):
redbold
=
SDL_REDBOLD
redbold
=
SDL_REDBOLD
def
__init__
(
self
,
parent
=
None
,
ast
=
None
):
def
__init__
(
self
,
parent
=
None
,
ast
=
None
):
self
.
ast
=
ast
if
not
ast
:
if
not
ast
:
ast
=
ogAST
.
Terminator
(
defName
=
''
)
ast
=
ogAST
.
Terminator
(
defName
=
''
)
ast
.
pos_y
=
0
ast
.
pos_y
=
0
...
@@ -582,8 +592,12 @@ class Label(VerticalSymbol):
...
@@ -582,8 +592,12 @@ class Label(VerticalSymbol):
def
__init__
(
self
,
parent
=
None
,
ast
=
None
):
def
__init__
(
self
,
parent
=
None
,
ast
=
None
):
ast
=
ast
or
ogAST
.
Label
()
ast
=
ast
or
ogAST
.
Label
()
super
(
Label
,
self
).
__init__
(
parent
,
text
=
ast
.
inputString
,
self
.
ast
=
ast
x
=
ast
.
pos_x
,
y
=
ast
.
pos_y
,
hyperlink
=
ast
.
hyperlink
)
super
(
Label
,
self
).
__init__
(
parent
,
text
=
ast
.
inputString
,
x
=
ast
.
pos_x
or
0
,
y
=
ast
.
pos_y
or
0
,
hyperlink
=
ast
.
hyperlink
)
self
.
set_shape
(
ast
.
width
,
ast
.
height
)
self
.
set_shape
(
ast
.
width
,
ast
.
height
)
self
.
setPen
(
QPen
(
Qt
.
blue
))
self
.
setPen
(
QPen
(
Qt
.
blue
))
self
.
terminal_symbol
=
False
self
.
terminal_symbol
=
False
...
@@ -596,7 +610,6 @@ class Label(VerticalSymbol):
...
@@ -596,7 +610,6 @@ class Label(VerticalSymbol):
def
set_shape
(
self
,
width
,
height
):
def
set_shape
(
self
,
width
,
height
):
''' Define the shape of the LABEL symbol '''
''' Define the shape of the LABEL symbol '''
#print traceback.print_stack()
path
=
QPainterPath
()
path
=
QPainterPath
()
path
.
addEllipse
(
0
,
height
/
2
,
width
/
4
,
height
/
2
)
path
.
addEllipse
(
0
,
height
/
2
,
width
/
4
,
height
/
2
)
path
.
moveTo
(
width
/
4
,
height
*
3
/
4
)
path
.
moveTo
(
width
/
4
,
height
*
3
/
4
)
...
@@ -646,10 +659,13 @@ class Task(VerticalSymbol):
...
@@ -646,10 +659,13 @@ class Task(VerticalSymbol):
def
__init__
(
self
,
parent
=
None
,
ast
=
None
):
def
__init__
(
self
,
parent
=
None
,
ast
=
None
):
''' Initializes the TASK symbol '''
''' Initializes the TASK symbol '''
ast
=
ast
or
ogAST
.
Task
()
ast
=
ast
or
ogAST
.
Task
()
super
(
Task
,
self
).
__init__
(
parent
,
text
=
ast
.
inputString
,
self
.
ast
=
ast
x
=
ast
.
pos_x
,
y
=
ast
.
pos_y
,
hyperlink
=
ast
.
hyperlink
)
super
(
Task
,
self
).
__init__
(
parent
,
text
=
ast
.
inputString
,
x
=
ast
.
pos_x
or
0
,
y
=
ast
.
pos_y
or
0
,
hyperlink
=
ast
.
hyperlink
)
self
.
set_shape
(
ast
.
width
,
ast
.
height
)
self
.
set_shape
(
ast
.
width
,
ast
.
height
)
self
.
setBrush
(
QBrush
(
QColor
(
255
,
255
,
202
)))
self
.
setBrush
(
QBrush
(
QColor
(
255
,
255
,
202
)))
self
.
terminal_symbol
=
False
self
.
terminal_symbol
=
False
self
.
parser
=
ogParser
self
.
parser
=
ogParser
...
@@ -706,8 +722,11 @@ class ProcedureCall(VerticalSymbol):
...
@@ -706,8 +722,11 @@ class ProcedureCall(VerticalSymbol):
def
__init__
(
self
,
parent
=
None
,
ast
=
None
):
def
__init__
(
self
,
parent
=
None
,
ast
=
None
):
ast
=
ast
or
ogAST
.
Output
(
defName
=
''
)
ast
=
ast
or
ogAST
.
Output
(
defName
=
''
)
self
.
ast
=
ast
super
(
ProcedureCall
,
self
).
__init__
(
parent
,
super
(
ProcedureCall
,
self
).
__init__
(
parent
,
text
=
ast
.
inputString
,
x
=
ast
.
pos_x
,
y
=
ast
.
pos_y
,
text
=
ast
.
inputString
,
x
=
ast
.
pos_x
or
0
,
y
=
ast
.
pos_y
or
0
,
hyperlink
=
ast
.
hyperlink
)
hyperlink
=
ast
.
hyperlink
)
self
.
set_shape
(
ast
.
width
,
ast
.
height
)
self
.
set_shape
(
ast
.
width
,
ast
.
height
)
self
.
setBrush
(
QBrush
(
QColor
(
255
,
255
,
202
)))
self
.
setBrush
(
QBrush
(
QColor
(
255
,
255
,
202
)))
...
@@ -772,13 +791,16 @@ class TextSymbol(HorizontalSymbol):
...
@@ -772,13 +791,16 @@ class TextSymbol(HorizontalSymbol):
def
__init__
(
self
,
ast
=
None
):
def
__init__
(
self
,
ast
=
None
):
''' Create a Text Symbol '''
''' Create a Text Symbol '''
ast
=
ast
or
ogAST
.
TextArea
()
ast
=
ast
or
ogAST
.
TextArea
()
self
.
ast
=
ast
super
(
TextSymbol
,
self
).
__init__
(
parent
=
None
,
super
(
TextSymbol
,
self
).
__init__
(
parent
=
None
,
text
=
ast
.
inputString
,
text
=
ast
.
inputString
,
x
=
ast
.
pos_x
,
y
=
ast
.
pos_y
,
hyperlink
=
ast
.
hyperlink
)
x
=
ast
.
pos_x
or
0
,
y
=
ast
.
pos_y
or
0
,
hyperlink
=
ast
.
hyperlink
)
self
.
set_shape
(
ast
.
width
,
ast
.
height
)
self
.
set_shape
(
ast
.
width
,
ast
.
height
)
self
.
setBrush
(
QBrush
(
QColor
(
249
,
249
,
249
)))
self
.
setBrush
(
QBrush
(
QColor
(
249
,
249
,
249
)))
self
.
terminal_symbol
=
False
self
.
terminal_symbol
=
False
self
.
setPos
(
ast
.
pos_x
,
ast
.
pos_y
)
self
.
setPos
(
ast
.
pos_x
or
0
,
ast
.
pos_y
or
0
)
# Disable hyperlinks for Text symbols
# Disable hyperlinks for Text symbols
self
.
_no_hyperlink
=
True
self
.
_no_hyperlink
=
True
# Text is not centered in the box - change default alignment:
# Text is not centered in the box - change default alignment:
...
@@ -852,10 +874,12 @@ class State(VerticalSymbol):
...
@@ -852,10 +874,12 @@ class State(VerticalSymbol):
def
__init__
(
self
,
parent
=
None
,
ast
=
None
):
def
__init__
(
self
,
parent
=
None
,
ast
=
None
):
ast
=
ast
or
ogAST
.
State
()
ast
=
ast
or
ogAST
.
State
()
self
.
ast
=
ast
ast
.
inputString
=
getattr
(
ast
,
'via'
,
None
)
or
ast
.
inputString
ast
.
inputString
=
getattr
(
ast
,
'via'
,
None
)
or
ast
.
inputString
# Note: ast coordinates are in scene coordinates
super
(
State
,
self
).
__init__
(
parent
=
parent
,
super
(
State
,
self
).
__init__
(
parent
=
parent
,
text
=
ast
.
inputString
,
x
=
ast
.
pos_x
,
y
=
ast
.
pos_y
,
text
=
ast
.
inputString
,
x
=
ast
.
pos_x
or
0
,
y
=
ast
.
pos_y
or
0
,
hyperlink
=
ast
.
hyperlink
)
hyperlink
=
ast
.
hyperlink
)
self
.
set_shape
(
ast
.
width
,
ast
.
height
)
self
.
set_shape
(
ast
.
width
,
ast
.
height
)
self
.
setBrush
(
QBrush
(
QColor
(
255
,
228
,
213
)))
self
.
setBrush
(
QBrush
(
QColor
(
255
,
228
,
213
)))
...
@@ -863,13 +887,13 @@ class State(VerticalSymbol):
...
@@ -863,13 +887,13 @@ class State(VerticalSymbol):
if
parent
:
if
parent
:
try
:
try
:
# Map AST scene coordinates to get actual position
# Map AST scene coordinates to get actual position
self
.
setPos
(
self
.
pos
()
self
.
setPos
(
self
.
pos
()
+
self
.
mapFromScene
(
ast
.
pos_x
or
0
,
+
self
.
mapFromScene
(
ast
.
pos_x
,
ast
.
pos_y
))
ast
.
pos_y
or
0
))
except
TypeError
:
except
TypeError
:
self
.
update_position
()
self
.
update_position
()
else
:
else
:
# Use scene coordinates to position
# Use scene coordinates to position
self
.
setPos
(
ast
.
pos_x
,
ast
.
pos_y
)
self
.
setPos
(
ast
.
pos_x
or
0
,
ast
.
pos_y
or
0
)
self
.
parser
=
ogParser
self
.
parser
=
ogParser
if
ast
.
comment
:
if
ast
.
comment
:
Comment
(
parent
=
self
,
ast
=
ast
.
comment
)
Comment
(
parent
=
self
,
ast
=
ast
.
comment
)
...
@@ -963,6 +987,7 @@ class Process(HorizontalSymbol):
...
@@ -963,6 +987,7 @@ class Process(HorizontalSymbol):
def
__init__
(
self
,
ast
=
None
,
subscene
=
None
):
def
__init__
(
self
,
ast
=
None
,
subscene
=
None
):
ast
=
ast
or
ogAST
.
Process
()
ast
=
ast
or
ogAST
.
Process
()
self
.
ast
=
ast
super
(
Process
,
self
).
__init__
(
parent
=
None
,
super
(
Process
,
self
).
__init__
(
parent
=
None
,
text
=
ast
.
processName
,
text
=
ast
.
processName
,
x
=
ast
.
pos_x
,
x
=
ast
.
pos_x
,
...
@@ -1018,9 +1043,12 @@ class Procedure(Process):
...
@@ -1018,9 +1043,12 @@ class Procedure(Process):
def
__init__
(
self
,
ast
=
None
,
subscene
=
None
):
def
__init__
(
self
,
ast
=
None
,
subscene
=
None
):
ast
=
ast
or
ogAST
.
Procedure
()
ast
=
ast
or
ogAST
.
Procedure
()
self
.
ast
=
ast
super
(
Process
,
self
).
__init__
(
parent
=
None
,
super
(
Process
,
self
).
__init__
(
parent
=
None
,
text
=
ast
.
inputString
,
text
=
ast
.
inputString
,
x
=
ast
.
pos_x
,
y
=
ast
.
pos_y
,
hyperlink
=
ast
.
hyperlink
)
x
=
ast
.
pos_x
or
0
,
y
=
ast
.
pos_y
or
0
,
hyperlink
=
ast
.
hyperlink
)
self
.
set_shape
(
ast
.
width
,
ast
.
height
)
self
.
set_shape
(
ast
.
width
,
ast
.
height
)
self
.
setBrush
(
QBrush
(
QColor
(
255
,
255
,
202
)))
self
.
setBrush
(
QBrush
(
QColor
(
255
,
255
,
202
)))
self
.
parser
=
ogParser
self
.
parser
=
ogParser
...
@@ -1079,10 +1107,12 @@ class Start(HorizontalSymbol):
...
@@ -1079,10 +1107,12 @@ class Start(HorizontalSymbol):
def
__init__
(
self
,
ast
=
None
):
def
__init__
(
self
,
ast
=
None
):
''' Create the START symbol '''
''' Create the START symbol '''
ast
=
ast
or
ogAST
.
Start
()
ast
=
ast
or
ogAST
.
Start
()
self
.
ast
=
ast
self
.
terminal_symbol
=
False
self
.
terminal_symbol
=
False
super
(
Start
,
self
).
__init__
(
parent
=
None
,
super
(
Start
,
self
).
__init__
(
parent
=
None
,
text
=
ast
.
inputString
[
slice
(
0
,
-
6
)],
text
=
ast
.
inputString
[
slice
(
0
,
-
6
)],
x
=
ast
.
pos_x
,
y
=
ast
.
pos_y
,
x
=
ast
.
pos_x
or
0
,
y
=
ast
.
pos_y
or
0
,
hyperlink
=
ast
.
hyperlink
)
hyperlink
=
ast
.
hyperlink
)
self
.
set_shape
(
ast
.
width
,
ast
.
height
)
self
.
set_shape
(
ast
.
width
,
ast
.
height
)
self
.
setBrush
(
QBrush
(
QColor
(
255
,
228
,
213
)))
self
.
setBrush
(
QBrush
(
QColor
(
255
,
228
,
213
)))
...
...
tests/regression/test-substrings/myfunction.pr
View file @
29bcca73
/* CIF PROCESS (197, 146), (150, 75) */
/* CIF PROCESS (197, 146), (150, 75) */
PROCESS myfunction;
PROCESS myfunction;
/* CIF TEXT (7, 43), (334, 41) */
-- Test substrings in various contexts and operators
/* CIF ENDTEXT */
/* CIF TEXT (0, 133), (282, 216) */
/* CIF TEXT (0, 133), (282, 216) */
dcl str MyOctStr := 'abc';
dcl str MyOctStr := 'abc';
dcl variable_str String := 'Hello!';
dcl variable_str String := 'Hello!';
...
@@ -16,6 +13,9 @@ dcl seqbool2 seqBool2 := { true, false};
...
@@ -16,6 +13,9 @@ dcl seqbool2 seqBool2 := { true, false};
dcl iseq IntSeq := {0,1,2,3};
dcl iseq IntSeq := {0,1,2,3};
dcl fixedseq FixedIntSeq := {0,1,2,3,4};
dcl fixedseq FixedIntSeq := {0,1,2,3,4};
dcl n t_UInt8;
dcl n t_UInt8;
/* CIF ENDTEXT */
/* CIF TEXT (7, 43), (334, 41) */
-- Test substrings in various contexts and operators
/* CIF ENDTEXT */
/* CIF ENDTEXT */
/* CIF PROCEDURE (1416, 490), (91, 35) */
/* CIF PROCEDURE (1416, 490), (91, 35) */
PROCEDURE factorial;
PROCEDURE factorial;
...
@@ -36,7 +36,7 @@ endfor;
...
@@ -36,7 +36,7 @@ endfor;
ENDPROCEDURE;
ENDPROCEDURE;
/* CIF START (353, 217), (65, 37) */
/* CIF START (353, 217), (65, 37) */
START;
START;
/* CIF TASK (3
19
, 269), (131, 35) */
/* CIF TASK (3
20
, 269), (131, 35) */
TASK n := iseq(0,2)(0);
TASK n := iseq(0,2)(0);
/* CIF PROCEDURECALL (335, 319), (100, 35) */
/* CIF PROCEDURECALL (335, 319), (100, 35) */
CALL writeln(n)
CALL writeln(n)
...
@@ -48,7 +48,7 @@ endfor;
...
@@ -48,7 +48,7 @@ endfor;
TASK for x in iseq:
TASK for x in iseq:
call writeln(x);
call writeln(x);
endfor
endfor
/* CIF COMMENT (49
4
, 4
20
), (81, 72) */