1import pytest
2
3from  grandalf.graphs  import *
4from  grandalf.layouts import *
5from  grandalf.routing import *
6
7def test_splines(capsys,sample_G02):
8    gr  = graph_core(*sample_G02)
9    for  v in gr.V(): v.view = VertexViewer(10,10)
10    sug  = SugiyamaLayout(gr)
11    sug.init_all(roots=[gr.sV[0]],inverted_edges=[])
12    i=0
13    for  s in sug.draw_step():
14        print ('--- step %d '%i +'-'*20)
15        for v,x in sug.grx.items():
16            print (x, v.view.xy)
17        i+=1
18    for  e in gr.E():
19        e.view = EdgeViewer()
20    sug.route_edge  = route_with_splines
21    sug.draw_edges()
22    for  e in sug.g.E():
23        print ('edge (%s -> %s) :'%e.v)
24        print (e.view._pts)
25        print (e.view.splines)
26
27    dig  = DigcoLayout(gr)
28    dig.init_all()
29    dig.draw()
30    for  v in gr.sV: print (v,v.view.xy)
31
32def test_rounded_corners(capsys,sample_G02):
33    gr  = graph_core(*sample_G02)
34    for  v in gr.V(): v.view = VertexViewer(10,10)
35    sug  = SugiyamaLayout(gr)
36    sug.init_all(roots=[gr.sV[0]],inverted_edges=[])
37    i=0
38    for  s in sug.draw_step():
39        print ('--- step %d '%i +'-'*20)
40        for v,x in sug.grx.items():
41            print (x, v.view.xy)
42        i+=1
43    for  e in gr.E():
44        e.view = EdgeViewer()
45    sug.route_edge  = route_with_rounded_corners
46    sug.draw_edges()
47    for  e in sug.g.E():
48        print ('edge (%s -> %s) :'%e.v)
49        print (e.view._pts)
50
51    dig  = DigcoLayout(gr)
52    dig.init_all()
53    dig.draw()
54    for  v in gr.sV: print (v,v.view.xy)
55