Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
VIGNET Pierre
cadbiom
Commits
fbab693e
Commit
fbab693e
authored
Jan 20, 2020
by
VIGNET Pierre
Browse files
[gui] Layouts: black
parent
26069101
Changes
1
Hide whitespace changes
Inline
Side-by-side
gui/cadbiom_gui/gt_gui/layout.py
View file @
fbab693e
## Filename : layout
## Author(s) : Michel Le Borgne
## Created : 01/2012
## Revision :
## Source :
## Revision :
## Source :
##
## Copyright 2012 : IRISA/IRSET
##
...
...
@@ -33,8 +33,8 @@
## IRISA/IRSET
## Symbiose team
## IRISA Campus de Beaulieu
## 35042 RENNES Cedex, FRANCE
##
## 35042 RENNES Cedex, FRANCE
##
##
## Contributor(s):
##
...
...
@@ -76,36 +76,36 @@ class LayoutVisitor(object):
such as certain telecommunications networks.
"""
def
__init__
(
self
,
view
,
layout_style
):
self
.
view
=
view
self
.
drawing_style
=
view
.
drawing_style
self
.
layout
=
layout_style
def
visit_chart_model
(
self
,
model
):
"""
Not used
"""
model
.
get_root
().
accept
(
self
)
def
visit_cstart_node
(
self
,
node
):
"""
Not used
"""
return
def
visit_ctrap_node
(
self
,
node
):
"""
Not used
"""
return
def
visit_csimple_node
(
self
,
node
):
"""
Not used
"""
return
def
visit_cinput_node
(
self
,
node
):
"""
Not used
...
...
@@ -117,24 +117,24 @@ class LayoutVisitor(object):
Not used
"""
return
def
visit_cmacro_node
(
self
,
node
):
"""
Layouts are done on each macro place
Change the local coordinates of subnodes according to layout style
Change the local coordinates of subnodes according to layout style
"""
if
node
.
sub_nodes
==
[]:
return
agraph
=
pgv
.
AGraph
(
splines
=
'
ortho
'
)
agraph
=
pgv
.
AGraph
(
splines
=
"
ortho
"
)
node_dict
=
dict
()
# build nodes
for
snode
in
node
.
sub_nodes
:
for
snode
in
node
.
sub_nodes
:
agraph
.
add_node
(
snode
.
name
)
anode
=
agraph
.
get_node
(
snode
.
name
)
node_dict
[
snode
.
name
]
=
snode
if
snode
.
is_macro
()
and
snode
.
model
.
show_macro
:
anode
.
attr
[
'
width
'
]
=
"%s"
%
snode
.
wloc
anode
.
attr
[
'
height
'
]
=
"%s"
%
snode
.
hloc
anode
.
attr
[
"
width
"
]
=
"%s"
%
snode
.
wloc
anode
.
attr
[
"
height
"
]
=
"%s"
%
snode
.
hloc
snode
.
accept
(
self
)
# build edges
for
tgr
in
node
.
transitions
:
...
...
@@ -142,51 +142,50 @@ class LayoutVisitor(object):
agraph
.
add_edge
(
trans
.
ori
.
name
,
trans
.
ext
.
name
)
# layout
layout_style
=
self
.
layout
if
layout_style
==
'
hierarchical_LR
'
:
agraph
.
layout
(
prog
=
'
dot
'
,
args
=
'
-Grankdir=LR
'
)
elif
layout_style
==
'
hierarchical_TB
'
:
agraph
.
layout
(
prog
=
'
dot
'
,
args
=
'
-Grankdir=BT
'
)
elif
layout_style
==
'
neato
'
:
agraph
.
layout
(
prog
=
'
neato
'
)
elif
layout_style
==
'
fdp
'
:
agraph
.
layout
(
prog
=
'
fdp
'
)
elif
layout_style
==
'
twopi
'
:
agraph
.
layout
(
prog
=
'
twopi
'
)
elif
layout_style
==
'
circo
'
:
agraph
.
layout
(
prog
=
'
circo
'
)
if
layout_style
==
"
hierarchical_LR
"
:
agraph
.
layout
(
prog
=
"
dot
"
,
args
=
"
-Grankdir=LR
"
)
elif
layout_style
==
"
hierarchical_TB
"
:
agraph
.
layout
(
prog
=
"
dot
"
,
args
=
"
-Grankdir=BT
"
)
elif
layout_style
==
"
neato
"
:
agraph
.
layout
(
prog
=
"
neato
"
)
elif
layout_style
==
"
fdp
"
:
agraph
.
layout
(
prog
=
"
fdp
"
)
elif
layout_style
==
"
twopi
"
:
agraph
.
layout
(
prog
=
"
twopi
"
)
elif
layout_style
==
"
circo
"
:
agraph
.
layout
(
prog
=
"
circo
"
)
else
:
LOGGER
.
error
(
"LayoutVisitor::visit_cmacro_node: Unknow layout: %s"
,
layout_style
"LayoutVisitor::visit_cmacro_node: Unknow layout: %s"
,
layout_style
)
exit
(
1
)
# change coordinates
# bounding box for ratios
bbox
=
pgv
.
graphviz
.
agget
(
agraph
.
handle
,
'
bb
'
)
bbox
=
bbox
.
split
(
','
)
bbox
=
pgv
.
graphviz
.
agget
(
agraph
.
handle
,
"
bb
"
)
bbox
=
bbox
.
split
(
","
)
xmin
=
float
(
bbox
[
0
])
xmax
=
float
(
bbox
[
2
])
ymin
=
float
(
bbox
[
1
])
ymax
=
float
(
bbox
[
3
])
#adjust graphic window
#
adjust graphic window
view
=
self
.
view
cond
=
(
(
xmax
-
xmin
)
/
3.0
>
view
.
draw_width
)
cond
=
(
xmax
-
xmin
)
/
3.0
>
view
.
draw_width
cond
=
cond
or
((
xmax
-
xmin
)
/
3.0
<
view
.
draw_width
/
2.0
)
if
cond
:
view
.
draw_width
=
min
(
int
((
xmax
-
xmin
)
/
3.0
),
10400
)
# 31200 max
view
.
draw_width
=
min
(
int
((
xmax
-
xmin
)
/
3.0
),
10400
)
# 31200 max
view
.
draw_width
=
max
(
1300
,
view
.
draw_width
)
view
.
min_width
=
view
.
draw_width
cond
=
ymax
-
ymin
>
view
.
draw_height
cond
=
cond
or
ymax
-
ymin
<
view
.
draw_height
/
2.0
if
cond
:
view
.
draw_height
=
min
(
int
(
ymax
-
ymin
),
7200
)
# 21600 max
cond
=
cond
or
ymax
-
ymin
<
view
.
draw_height
/
2.0
if
cond
:
view
.
draw_height
=
min
(
int
(
ymax
-
ymin
),
7200
)
# 21600 max
view
.
draw_height
=
max
(
900
,
view
.
draw_height
)
view
.
min_height
=
view
.
draw_height
# reset zoom counter
view
.
zoom_count
=
0
gwidth
=
1.0
gheight
=
1.0
# virtual window for the macro node
gheight
=
1.0
# virtual window for the macro node
if
xmin
==
xmax
or
ymin
==
ymax
:
LOGGER
.
error
(
"LayoutVisitor::visit_cmacro_node: Coordinates consistency: "
...
...
@@ -196,11 +195,11 @@ class LayoutVisitor(object):
)
exit
(
1
)
x_ratio
=
gwidth
/
(
xmax
-
xmin
)
y_ratio
=
gheight
/
(
ymax
-
ymin
)
x_ratio
=
gwidth
/
(
xmax
-
xmin
)
y_ratio
=
gheight
/
(
ymax
-
ymin
)
# changing coordinates
for
node
in
agraph
.
nodes
():
pos
=
node
.
attr
[
'
pos
'
].
split
(
','
)
pos
=
node
.
attr
[
"
pos
"
].
split
(
","
)
cnn
=
node_dict
[
node
]
xcoord
=
float
(
pos
[
0
])
*
x_ratio
ycoord
=
float
(
pos
[
1
])
*
y_ratio
...
...
@@ -212,10 +211,9 @@ class LayoutVisitor(object):
"""
self
.
visit_cmacro_node
(
node
)
return
def
visit_ctransition
(
self
,
trans
):
"""
Not used
"""
return
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