Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
dream
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
dream
Commits
47b1476d
Commit
47b1476d
authored
Jul 11, 2013
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use pydot to layout the graph
parent
0d5d6bd7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
0 deletions
+36
-0
dream/platform/__init__.py
dream/platform/__init__.py
+34
-0
setup.py
setup.py
+2
-0
No files found.
dream/platform/__init__.py
View file @
47b1476d
import
json
import
traceback
import
multiprocessing
import
pydot
from
flask
import
Flask
,
jsonify
,
redirect
,
url_for
from
flask
import
request
...
...
@@ -16,6 +17,39 @@ def front_page():
return
redirect
(
url_for
(
'static'
,
filename
=
'index.html'
))
@
app
.
route
(
"/positionGraph"
,
methods
=
[
"POST"
,
"OPTIONS"
])
def
positionGraph
():
"""Uses graphviz to position nodes of the graph.
"""
graph
=
pydot
.
Dot
()
for
node
in
request
.
json
[
'element'
].
itervalues
():
graph
.
add_node
(
pydot
.
Node
(
node
[
'id'
]))
for
successor
in
node
.
get
(
'successorList'
,
[]):
graph
.
add_edge
(
pydot
.
Edge
(
node
[
'id'
],
successor
))
new_graph
=
pydot
.
graph_from_dot_data
(
graph
.
create_dot
())
# calulate the ratio from the size of the bounding box
ratio
=
new_graph
.
get_bb
()
origin_left
,
origin_top
,
max_left
,
max_top
=
[
float
(
p
)
for
p
in
new_graph
.
get_bb
()[
1
:
-
1
].
split
(
','
)]
ratio_top
=
max_top
-
origin_top
ratio_left
=
max_left
-
origin_left
preference_dict
=
dict
()
for
node
in
new_graph
.
get_nodes
():
# skip technical nodes
if
node
.
get_name
()
in
(
'graph'
,
'node'
,
'edge'
):
continue
left
,
top
=
[
float
(
p
)
for
p
in
node
.
get_pos
()[
1
:
-
1
].
split
(
","
)]
preference_dict
[
node
.
get_name
()[
1
:
-
1
]]
=
dict
(
top
=
1
-
(
top
/
ratio_top
),
left
=
1
-
(
left
/
ratio_left
),)
return
jsonify
(
preference_dict
)
@
app
.
route
(
"/runSimulation"
,
methods
=
[
"POST"
,
"OPTIONS"
])
def
runSimulation
():
parameter_dict
=
request
.
json
[
'json'
]
...
...
setup.py
View file @
47b1476d
...
...
@@ -12,6 +12,8 @@ setup(
'SimPy>=2,<3'
,
'xlrd'
,
'xlwt'
,
'pyparsing==1.5.7'
,
'pydot'
,
],
entry_points
=
(
"""
[console_scripts]
...
...
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