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
8778e665
Commit
8778e665
authored
Mar 20, 2017
by
Maxime Perrotin
Browse files
Iterate on the rendering of process type
parent
2c285cb5
Changes
5
Hide whitespace changes
Inline
Side-by-side
opengeode/Pr.py
View file @
8778e665
...
...
@@ -47,7 +47,7 @@ def parse_scene(scene, full_model=False):
# (3) generate all the text
processes
=
list
(
scene
.
processes
)
system_name
=
unicode
(
processes
[
0
])
if
processes
else
u
'OpenGEODE'
pr_data
.
append
(
'
SYSTEM
{};'
.
format
(
system_name
))
pr_data
.
append
(
'
system
{};'
.
format
(
system_name
))
Indent
.
indent
+=
1
channels
,
routes
=
Indent
(),
Indent
()
for
each
in
scene
.
texts
:
...
...
@@ -58,40 +58,40 @@ def parse_scene(scene, full_model=False):
to_env
=
processes
[
0
].
connection
.
out_sig
from_env
=
processes
[
0
].
connection
.
in_sig
if
to_env
or
from_env
:
channels
.
append
(
'
CHANNEL
c'
)
channels
.
append
(
'
channel
c'
)
Indent
.
indent
+=
1
routes
.
append
(
'
SIGNALROUTE
r'
)
routes
.
append
(
'
signalroute
r'
)
if
from_env
:
from_txt
=
'
FROM ENV TO {} WITH
{};'
\
from_txt
=
'
from env to {} with
{};'
\
.
format
(
system_name
,
from_env
)
channels
.
append
(
from_txt
)
Indent
.
indent
+=
1
routes
.
append
(
from_txt
)
Indent
.
indent
-=
1
if
to_env
:
to_txt
=
'
FROM {} TO ENV WITH
{};'
\
to_txt
=
'
from {} to env with
{};'
\
.
format
(
system_name
,
to_env
)
channels
.
append
(
to_txt
)
Indent
.
indent
+=
1
routes
.
append
(
to_txt
)
Indent
.
indent
-=
1
Indent
.
indent
-=
1
channels
.
append
(
'
ENDCHANNEL
;'
)
channels
.
append
(
'
endchannel
;'
)
Indent
.
indent
+=
1
routes
.
append
(
'
CONNECT c AND
r;'
)
routes
.
append
(
'
connect c and
r;'
)
Indent
.
indent
-=
1
pr_data
.
extend
(
channels
)
pr_data
.
append
(
'
BLOCK
{};'
.
format
(
system_name
))
pr_data
.
append
(
'
block
{};'
.
format
(
system_name
))
Indent
.
indent
+=
1
pr_data
.
extend
(
routes
)
for
each
in
processes
:
pr_data
.
extend
(
generate
(
each
))
Indent
.
indent
-=
1
pr_data
.
append
(
'
ENDBLOCK
;'
)
pr_data
.
append
(
'
endblock
;'
)
Indent
.
indent
-=
1
pr_data
.
append
(
'
ENDSYSTEM
;'
)
pr_data
.
append
(
'
endsystem
;'
)
else
:
for
each
in
scene
.
processes
:
...
...
@@ -177,17 +177,17 @@ def generate(symbol, *args, **kwargs):
def
_comment
(
symbol
,
**
kwargs
):
''' Optional comment linked to a symbol '''
result
=
Indent
()
result
.
append
(
cif_coord
(
'
COMMENT
'
,
symbol
))
result
.
append
(
cif_coord
(
'
comment
'
,
symbol
))
if
symbol
.
text
.
hyperlink
:
result
.
append
(
hyperlink
(
symbol
))
result
.
append
(
u
'
COMMENT
\'
{}
\'
;'
.
format
(
unicode
(
symbol
.
text
)))
result
.
append
(
u
'
comment
\'
{}
\'
;'
.
format
(
unicode
(
symbol
.
text
)))
return
result
@
generate
.
register
(
sdlSymbols
.
Input
)
def
_input
(
symbol
,
recursive
=
True
,
**
kwargs
):
''' Input symbol or branch if recursive is set '''
result
=
common
(
'
INPUT
'
,
symbol
)
result
=
common
(
'
input
'
,
symbol
)
if
recursive
:
result
.
extend
(
recursive_aligned
(
symbol
))
return
result
...
...
@@ -196,7 +196,7 @@ def _input(symbol, recursive=True, **kwargs):
@
generate
.
register
(
sdlSymbols
.
ContinuousSignal
)
def
_continuous_signal
(
symbol
,
recursive
=
True
,
**
kwargs
):
''' "Provided" symbol or branch if recursive is set '''
result
=
common
(
'
PROVIDED
'
,
symbol
)
result
=
common
(
'
provided
'
,
symbol
)
if
recursive
:
result
.
extend
(
recursive_aligned
(
symbol
))
return
result
...
...
@@ -205,7 +205,7 @@ def _continuous_signal(symbol, recursive=True, **kwargs):
@
generate
.
register
(
sdlSymbols
.
Connect
)
def
_connect
(
symbol
,
recursive
=
True
,
**
kwargs
):
''' Connect symbol or branch if recursive is set '''
result
=
common
(
'
CONNECT
'
,
symbol
)
result
=
common
(
'
connect
'
,
symbol
)
if
recursive
:
result
.
extend
(
recursive_aligned
(
symbol
))
return
result
...
...
@@ -214,13 +214,13 @@ def _connect(symbol, recursive=True, **kwargs):
@
generate
.
register
(
sdlSymbols
.
Output
)
def
_output
(
symbol
,
**
kwargs
):
''' Output symbol '''
return
common
(
'
OUTPUT
'
,
symbol
)
return
common
(
'
output
'
,
symbol
)
@
generate
.
register
(
sdlSymbols
.
Decision
)
def
_decision
(
symbol
,
recursive
=
True
,
**
kwargs
):
''' Decision symbol or branch if recursive is set '''
result
=
common
(
'
DECISION
'
,
symbol
)
result
=
common
(
'
decision
'
,
symbol
)
if
recursive
:
else_branch
=
None
Indent
.
indent
+=
1
...
...
@@ -232,7 +232,7 @@ def _decision(symbol, recursive=True, **kwargs):
if
else_branch
:
result
.
extend
(
else_branch
)
Indent
.
indent
-=
1
result
.
append
(
u
'
ENDDECISION
;'
)
result
.
append
(
u
'
enddecision
;'
)
return
result
...
...
@@ -255,19 +255,19 @@ def _decisionanswer(symbol, recursive=True, **kwargs):
@
generate
.
register
(
sdlSymbols
.
Join
)
def
_join
(
symbol
,
**
kwargs
):
''' Join symbol '''
return
common
(
'
JOIN
'
,
symbol
)
return
common
(
'
join
'
,
symbol
)
@
generate
.
register
(
sdlSymbols
.
ProcedureStop
)
def
_procedurestop
(
symbol
,
**
kwargs
):
''' Procedure Stop symbol '''
return
common
(
'
RETURN
'
,
symbol
)
return
common
(
'
return
'
,
symbol
)
@
generate
.
register
(
sdlSymbols
.
Task
)
def
_task
(
symbol
,
**
kwargs
):
''' Task symbol '''
return
common
(
'
TASK
'
,
symbol
)
return
common
(
'
task
'
,
symbol
)
@
generate
.
register
(
sdlSymbols
.
ProcedureCall
)
...
...
@@ -277,7 +277,7 @@ def _procedurecall(symbol, **kwargs):
result
.
append
(
cif_coord
(
'PROCEDURECALL'
,
symbol
))
if
symbol
.
text
.
hyperlink
:
result
.
append
(
hyperlink
(
symbol
))
result
.
append
(
u
'
CALL
{}{}'
.
format
(
unicode
(
symbol
.
text
),
';'
result
.
append
(
u
'
call
{}{}'
.
format
(
unicode
(
symbol
.
text
),
';'
if
not
symbol
.
comment
else
''
))
if
symbol
.
comment
:
result
.
extend
(
generate
(
symbol
.
comment
))
...
...
@@ -302,15 +302,15 @@ def _textsymbol(symbol, **kwargs):
def
_label
(
symbol
,
recursive
=
True
,
**
kwargs
):
''' Label symbol or branch if recursive is set '''
result
=
Indent
()
result
.
append
(
cif_coord
(
'
LABEL
'
,
symbol
))
result
.
append
(
cif_coord
(
'
label
'
,
symbol
))
if
symbol
.
text
.
hyperlink
:
result
.
append
(
hyperlink
(
symbol
))
if
symbol
.
common_name
==
'floating_label'
:
result
.
append
(
u
'
CONNECTION
{}:'
.
format
(
unicode
(
symbol
)))
result
.
append
(
u
'
connection
{}:'
.
format
(
unicode
(
symbol
)))
if
recursive
:
result
.
extend
(
recursive_aligned
(
symbol
))
result
.
append
(
u
'/* CIF End Label */'
)
result
.
append
(
u
'
ENDCONNECTION
;'
)
result
.
append
(
u
'
endconnection
;'
)
else
:
result
.
append
(
u
'{}:'
.
format
(
unicode
(
symbol
)))
return
result
...
...
@@ -328,7 +328,7 @@ def _state(symbol, recursive=True, nextstate=True, composite=False, cpy=False,
# If nextstate has no child, don't generate anything
result
=
[]
elif
not
composite
:
result
=
common
(
'
STATE
'
,
symbol
)
result
=
common
(
'
state
'
,
symbol
)
if
recursive
:
Indent
.
indent
+=
1
# Generate code for INPUT and CONNECT symbols
...
...
@@ -337,13 +337,13 @@ def _state(symbol, recursive=True, nextstate=True, composite=False, cpy=False,
sdlSymbols
.
ContinuousSignal
))):
result
.
extend
(
generate
(
each
))
Indent
.
indent
-=
1
result
.
append
(
u
'
ENDSTATE
;'
)
result
.
append
(
u
'
endstate
;'
)
else
:
# Generate code for a nested state
result
=
Indent
()
agg
=
'
AGGREGATION
'
if
symbol
.
nested_scene
.
is_aggregation
()
else
''
#if not list(symbol.nested_scene.start) else ''
result
.
append
(
'
STATE
{} {};'
.
format
(
agg
,
unicode
(
symbol
).
split
()[
0
]))
result
.
append
(
'
SUBSTRUCTURE
'
)
agg
=
'
aggregation
'
if
symbol
.
nested_scene
.
is_aggregation
()
else
''
#if not list(symbol.nested_scene.start) else ''
result
.
append
(
'
state
{} {};'
.
format
(
agg
,
unicode
(
symbol
).
split
()[
0
]))
result
.
append
(
'
substructure
'
)
Indent
.
indent
+=
1
entry_points
,
exit_points
=
[],
[]
for
each
in
symbol
.
nested_scene
.
start
:
...
...
@@ -360,31 +360,42 @@ def _state(symbol, recursive=True, nextstate=True, composite=False, cpy=False,
result
.
extend
(
parse_scene
(
symbol
.
nested_scene
))
Indent
.
indent
-=
1
Indent
.
indent
-=
1
result
.
append
(
u
'
ENDSUBSTRUCTURE
;'
)
result
.
append
(
u
'
endsubstructure
;'
)
return
result
@
generate
.
register
(
sdlSymbols
.
Process
)
@
generate
.
register
(
sdlSymbols
.
ProcessType
)
def
_process
(
symbol
,
recursive
=
True
,
**
kwargs
):
''' Process symbol and inner content if recursive is set '''
result
=
common
(
'PROCESS'
,
symbol
)
name
=
"process type"
if
isinstance
(
symbol
,
sdlSymbols
.
ProcessType
)
\
else
"process"
#result = common(name, symbol)
result
=
Indent
()
result
.
append
(
cif_coord
(
'PROCESS'
,
symbol
))
result
.
append
(
u
"{} {}{}"
.
format
(
name
,
unicode
(
symbol
.
text
),
";"
if
not
symbol
.
comment
else
""
))
if
symbol
.
comment
:
result
.
extend
(
generate
(
symbol
.
comment
))
if
recursive
and
symbol
.
nested_scene
:
Indent
.
indent
+=
1
result
.
extend
(
parse_scene
(
symbol
.
nested_scene
))
Indent
.
indent
-=
1
result
.
append
(
u
'ENDPROCESS {};'
.
format
(
unicode
(
symbol
)))
if
":"
not
in
unicode
(
symbol
):
result
.
append
(
u
'endprocess {};'
.
format
(
unicode
(
symbol
)))
return
result
@
generate
.
register
(
sdlSymbols
.
Procedure
)
def
_procedure
(
symbol
,
recursive
=
True
,
**
kwargs
):
''' Procedure symbol or branch if recursive is set '''
result
=
common
(
'
PROCEDURE
'
,
symbol
)
result
=
common
(
'
procedure
'
,
symbol
)
if
recursive
and
symbol
.
nested_scene
:
Indent
.
indent
+=
1
result
.
extend
(
parse_scene
(
symbol
.
nested_scene
))
Indent
.
indent
-=
1
result
.
append
(
u
'
ENDPROCEDURE
;'
.
format
(
unicode
(
symbol
)))
result
.
append
(
u
'
endprocedure
;'
.
format
(
unicode
(
symbol
)))
return
result
...
...
@@ -408,13 +419,13 @@ def _start(symbol, recursive=True, **kwargs):
def
_channel
(
symbol
,
recursive
=
True
,
**
kwargs
):
''' Signalroute at block level '''
result
=
Indent
()
result
.
append
(
'
SIGNALROUTE
c'
)
result
.
append
(
'
signalroute
c'
)
Indent
.
indent
+=
1
if
symbol
.
out_sig
:
result
.
append
(
'
FROM {} TO ENV WITH
{};'
.
format
(
unicode
(
symbol
.
parent
),
result
.
append
(
'
from {} to env with
{};'
.
format
(
unicode
(
symbol
.
parent
),
symbol
.
out_sig
))
if
symbol
.
in_sig
:
result
.
append
(
'
FROM ENV TO {} WITH
{};'
.
format
(
unicode
(
symbol
.
parent
),
result
.
append
(
'
from env to {} with
{};'
.
format
(
unicode
(
symbol
.
parent
),
symbol
.
in_sig
))
Indent
.
indent
-=
1
return
result
...
...
opengeode/genericSymbols.py
View file @
8778e665
...
...
@@ -333,6 +333,10 @@ class Symbol(QObject, QGraphicsPathItem, object):
try
:
_
,
syntax_errors
,
_
,
_
,
_
=
self
.
parser
.
parseSingleElement
(
self
.
common_name
,
text
)
# In case of syntax errors, it would be useful to return the text
# in addition to the error from ANTLR, in order to be very clear
# about the line number and character position to fix the error
# => TODO
except
(
AssertionError
,
AttributeError
):
LOG
.
error
(
'Checker failed - no parser for this construct?'
)
else
:
...
...
opengeode/opengeode.py
View file @
8778e665
...
...
@@ -829,6 +829,7 @@ class SDL_Scene(QtGui.QGraphicsScene, object):
line_nb
=
int
(
line_nb
)
-
1
split
[
1
]
=
'{}:{}'
.
format
(
line_nb
,
col
)
pos
=
each
.
scenePos
()
split
.
append
(
u
'in "{}"'
.
format
(
unicode
(
each
)))
fmt
=
[[
' '
.
join
(
split
),
[
pos
.
x
(),
pos
.
y
()],
self
.
path
]]
log_errors
(
self
.
messages_window
,
fmt
,
[],
clearfirst
=
False
)
...
...
opengeode/sdlSymbols.py
View file @
8778e665
...
...
@@ -1179,6 +1179,8 @@ class ProcessType(Procedure):
def
set_shape
(
self
,
width
,
height
):
''' Compute the polygon to fit in width, height '''
path
=
QPainterPath
()
# Fill rule makes sure the full symbol is colored
path
.
setFillRule
(
Qt
.
WindingFill
)
path
.
moveTo
(
7
,
0
)
path
.
lineTo
(
0
,
7
)
path
.
lineTo
(
0
,
height
-
7
)
...
...
tests/regression/test-instance/og.pr
View file @
8778e665
/* CIF PROCESS (
149, 15
0), (150, 75) */
/* CIF PROCESS (
300, 40
0), (150, 75) */
PROCESS type og_type;
/* CIF TEXT (2755, 9), (298, 286) */
-- A Demo to test octet strings
...
...
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