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
2c285cb5
Commit
2c285cb5
authored
Mar 20, 2017
by
Maxime Perrotin
Browse files
Add Process type symbol (incomplete)
parent
2236effb
Changes
4
Hide whitespace changes
Inline
Side-by-side
opengeode/Renderer.py
View file @
2c285cb5
...
...
@@ -68,6 +68,8 @@ def _block(ast, scene):
top_level
=
[]
for
each
in
ast
.
processes
:
top_level
.
append
(
render
(
each
,
scene
))
if
each
.
instance_of_ref
:
top_level
.
append
(
render
(
each
.
instance_of_ref
,
scene
))
for
each
in
ast
.
parent
.
text_areas
:
# Sytem level may contain text areas with signal definitions, etc.
top_level
.
append
(
render
(
each
,
scene
))
...
...
@@ -104,7 +106,10 @@ def _block(ast, scene):
@
render
.
register
(
ogAST
.
Process
)
def
_process
(
ast
,
scene
,
**
_
):
''' Render a Process symbol (in a BLOCK diagram) '''
symbol
=
sdlSymbols
.
Process
(
ast
,
ast
)
if
ast
.
process_type
:
symbol
=
sdlSymbols
.
ProcessType
(
ast
,
ast
)
else
:
symbol
=
sdlSymbols
.
Process
(
ast
,
ast
)
add_to_scene
(
symbol
,
scene
)
return
symbol
...
...
opengeode/genericSymbols.py
View file @
2c285cb5
...
...
@@ -118,6 +118,8 @@ class Symbol(QObject, QGraphicsPathItem, object):
# (e.g. a subscene that appears when double-clicking on the item)
_allow_nesting
=
False
_nested_scene
=
None
# name used to discriminate the scene context
context_name
=
''
# keywords for the syntax highlighter
blackbold
=
()
redbold
=
()
...
...
opengeode/opengeode.py
View file @
2c285cb5
...
...
@@ -93,7 +93,7 @@ from genericSymbols import(Symbol, Comment, Cornergrabber, Connection, Channel)
from
sdlSymbols
import
(
Input
,
Output
,
Decision
,
DecisionAnswer
,
Task
,
ProcedureCall
,
TextSymbol
,
State
,
Start
,
Join
,
Label
,
Procedure
,
ProcedureStart
,
ProcedureStop
,
StateStart
,
Connect
,
Process
,
ContinuousSignal
)
ContinuousSignal
,
ProcessType
)
from
TextInteraction
import
EditableText
# Icons and png files generated from the resource file:
...
...
@@ -174,7 +174,7 @@ G_SYMBOLS = set()
# Lookup table used to configure the context-dependent toolbars
ACTIONS
=
{
'block'
:
[
Process
,
Comment
,
TextSymbol
],
'block'
:
[
Process
,
ProcessType
,
Comment
,
TextSymbol
],
'process'
:
[
Start
,
State
,
Input
,
Connect
,
ContinuousSignal
,
Task
,
Decision
,
DecisionAnswer
,
Output
,
ProcedureCall
,
TextSymbol
,
Comment
,
Label
,
Join
,
Procedure
],
...
...
@@ -625,9 +625,10 @@ class SDL_Scene(QtGui.QGraphicsScene, object):
symbol
.
boundingRect
()
|
symbol
.
childrenBoundingRect
())
symbol
.
pos_x
+=
(
sc_br
.
width
()
-
sy_br
.
x
())
except
AttributeError
:
except
AttributeError
as
err
:
# no AST, ignore (e.g. Connections, Cornergrabbers)
pass
#LOG.debug("[render everything] " + str(err))
else
:
# Recursively fix pos of sub branches and followers
for
branch
in
(
elm
for
elm
in
symbol
.
childSymbols
()
...
...
@@ -651,8 +652,11 @@ class SDL_Scene(QtGui.QGraphicsScene, object):
LOG
.
debug
(
'Subscene "{}" ignored'
.
format
(
unicode
(
each
)))
continue
subscene
=
\
self
.
create_subscene
(
each
.
__class__
.
__name__
.
lower
()
,
self
.
create_subscene
(
each
.
context_name
,
dest_scene
)
# self.create_subscene(each.__class__.__name__.lower(),
# dest_scene)
already_created
.
append
(
each
.
nested_scene
)
subscene
.
name
=
unicode
(
each
)
LOG
.
debug
(
'Created scene: {}'
.
format
(
subscene
.
name
))
...
...
@@ -1776,6 +1780,8 @@ class SDL_View(QtGui.QGraphicsView, object):
new_context
.
processName
=
subname
.
lower
()
sdlSymbols
.
CONTEXT
.
processes
.
append
(
new_context
)
sdlSymbols
.
CONTEXT
=
new_context
else
:
LOG
.
error
(
"Please report BUG: miss support for "
+
subtype
)
horpos
=
self
.
horizontalScrollBar
().
value
()
verpos
=
self
.
verticalScrollBar
().
value
()
...
...
@@ -1802,7 +1808,7 @@ class SDL_View(QtGui.QGraphicsView, object):
try
:
if
item
.
allow_nesting
:
item
.
double_click
()
ctx
=
unicode
(
item
.
__class__
.
__name__
.
lower
())
ctx
=
unicode
(
item
.
context_name
)
#
__class__.__name__.lower())
if
not
isinstance
(
item
.
nested_scene
,
SDL_Scene
):
item
.
nested_scene
=
\
self
.
scene
().
create_subscene
(
ctx
,
self
.
scene
())
...
...
@@ -1976,8 +1982,8 @@ class SDL_View(QtGui.QGraphicsView, object):
log_errors
(
self
.
messages_window
,
errors
,
warnings
)
try
:
self
.
scene
().
render_everything
(
block
)
except
AttributeError
:
pass
except
AttributeError
as
err
:
LOG
.
debug
(
"[Rendering] "
+
str
(
err
))
self
.
toolbar
.
update_menu
(
self
.
scene
())
self
.
scene
().
name
=
'block {}[*]'
.
format
(
process
.
processName
)
self
.
wrapping_window
.
setWindowTitle
(
self
.
scene
().
name
)
...
...
opengeode/sdlSymbols.py
View file @
2c285cb5
...
...
@@ -19,7 +19,7 @@
__all__
=
[
'Input'
,
'Output'
,
'State'
,
'Task'
,
'ProcedureCall'
,
'Label'
,
'Decision'
,
'DecisionAnswer'
,
'Join'
,
'Start'
,
'TextSymbol'
,
'Procedure'
,
'ProcedureStart'
,
'ProcedureStop'
,
'Procedure'
,
'ProcedureStart'
,
'ProcedureStop'
,
'ProcessType'
,
'StateStart'
,
'Process'
,
'ContinuousSignal'
]
#import traceback
...
...
@@ -892,6 +892,7 @@ class State(VerticalSymbol):
# Define reserved keywords for the syntax highlighter
blackbold
=
SDL_BLACKBOLD
redbold
=
SDL_REDBOLD
context_name
=
"state"
def
__init__
(
self
,
parent
=
None
,
ast
=
None
):
ast
=
ast
or
ogAST
.
State
()
...
...
@@ -1010,6 +1011,7 @@ class Process(HorizontalSymbol):
user_can_connect
=
True
_conn_sources
=
[
'Process'
]
_conn_targets
=
[
'Process'
]
context_name
=
"process"
def
__init__
(
self
,
ast
=
None
,
subscene
=
None
):
ast
=
ast
or
ogAST
.
Process
()
...
...
@@ -1098,6 +1100,7 @@ class Procedure(Process):
completion_list
=
set
()
is_singleton
=
False
user_can_connect
=
False
context_name
=
"procedure"
def
__init__
(
self
,
ast
=
None
,
subscene
=
None
):
ast
=
ast
or
ogAST
.
Procedure
()
...
...
@@ -1143,7 +1146,66 @@ class Procedure(Process):
new_proc
.
inputString
=
unicode
(
self
.
text
).
lower
()
CONTEXT
.
procedures
.
append
(
new_proc
)
class
ProcessType
(
Procedure
):
''' PROCESS TYPE (floating symbol with no connections '''
_unique_followers
=
[
'Comment'
]
_allow_nesting
=
True
common_name
=
'process_definition'
context_name
=
'process'
needs_parent
=
False
# Define reserved keywords for the syntax highlighter
blackbold
=
SDL_BLACKBOLD
redbold
=
SDL_REDBOLD
completion_list
=
set
()
is_singleton
=
False
user_can_connect
=
False
def
__init__
(
self
,
ast
=
None
,
subscene
=
None
):
ast
=
ast
or
ogAST
.
Process
()
ast
.
process_type
=
True
self
.
ast
=
ast
super
(
Process
,
self
).
__init__
(
parent
=
None
,
text
=
ast
.
processName
,
x
=
ast
.
pos_x
or
0
,
y
=
ast
.
pos_y
or
0
,
hyperlink
=
ast
.
hyperlink
)
self
.
set_shape
(
ast
.
width
,
ast
.
height
)
self
.
setBrush
(
QBrush
(
QColor
(
255
,
255
,
202
)))
self
.
parser
=
ogParser
if
ast
.
comment
:
Comment
(
parent
=
self
,
ast
=
ast
.
comment
)
self
.
nested_scene
=
subscene
def
set_shape
(
self
,
width
,
height
):
''' Compute the polygon to fit in width, height '''
path
=
QPainterPath
()
path
.
moveTo
(
7
,
0
)
path
.
lineTo
(
0
,
7
)
path
.
lineTo
(
0
,
height
-
7
)
path
.
lineTo
(
7
,
height
)
path
.
lineTo
(
width
-
7
,
height
)
path
.
lineTo
(
width
,
height
-
7
)
path
.
lineTo
(
width
,
7
)
path
.
lineTo
(
width
-
7
,
0
)
path
.
lineTo
(
7
,
0
)
# inner shape
path
.
moveTo
(
12
,
7
)
path
.
lineTo
(
7
,
12
)
path
.
lineTo
(
7
,
height
-
12
)
path
.
lineTo
(
12
,
height
-
7
)
path
.
lineTo
(
width
-
12
,
height
-
7
)
path
.
lineTo
(
width
-
7
,
height
-
12
)
path
.
lineTo
(
width
-
7
,
12
)
path
.
lineTo
(
width
-
12
,
7
)
path
.
lineTo
(
12
,
7
)
self
.
setPath
(
path
)
super
(
Process
,
self
).
set_shape
(
width
,
height
)
def
update_completion_list
(
self
,
pr_text
):
''' After text is entered in process type, don't update any context '''
# Todo perhaps later for autocompletion of process instances
pass
# pylint: disable=R0904
class
Start
(
HorizontalSymbol
):
...
...
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