9f9f1788
Pavel Govyadinov
clead up version ...
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Jan 31 15:29:40 2019
@author: pavel
`"""
from vispy import app
import network_dep as nwt
from pyqtgraph.Qt import QtCore, QtGui, QtWidgets
import pyqtgraph as pg
import numpy as np
import math
from mpl_toolkits.mplot3d import Axes3D
import matplotlib
import matplotlib.pyplot as plt
matplotlib.use('Qt5Agg')
from GraphWidget import GraphWidget
from TubeWidget import TubeWidget
|
9f9f1788
Pavel Govyadinov
clead up version ...
|
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
#initialize the layout
layout.addWidget(graph, 0, 0, 2, 3)
layout.addWidget(fibers, 0, 2, 2, 3)
layout.setColumnStretch(0, 2)
layout.setRowStretch(0, 2)
layout.setColumnStretch(2, 1)
layout.setRowStretch(0, 1)
top.setLayout(layout)
top.show()
def draw_histogram(G, value):
vals = G.edge_properties[value].get_array()
y, x = np.histogram(vals,40)
hist.plot(x,y, stepMode=True, fillLevel=0, brush=(0,0,255,150))
def load_nwt(filepath):
net = nwt.Network(filepath)
G = net.createFullGraph_gt()
G = net.filterDisconnected(G)
#G = net.filterFullGraph_gt(G, erode=True)
#G = net.filterFullGraph_gt(G, erode=True)
#G = net.gen_new_fd_layout(G)
#G = net.filterBorder(G)
#nwt.Network.saveGraph_gt(nwt, G, "FilteredNetwork_JACK_3.nwt")
color = np.zeros(4, dtype = np.double)
color = [0.0, 1.0, 0.0, 1.0]
G.edge_properties["RGBA"] = G.new_edge_property("vector<double>", val=color)
color = [1.0, 0.0, 0.0, 0.9]
G.vertex_properties["RGBA"] = G.new_vertex_property("vector<double>", val=color)
bbl, bbu = net.aabb()
return G, bbl, bbu
G, bbl, bbu = load_nwt("/home/pavel/Documents/Python/GraphGuiQt/network_4.nwt")
#nwt.Network.write_vtk(G)
|
9f9f1788
Pavel Govyadinov
clead up version ...
|
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
center = (bbu-bbl)/2.0
#fibers.opts['distance'] = 5
# item = NodeItem(G)
# graph.addItem(item)
draw_histogram(G, "length")
graph.canvas.set_data(G, bbl, bbu)
fibers.canvas.set_data(G, bbl, bbu, 16)
#fibers.draw_all(G, center, fibers, graph, node_tex)
graph.set_g_view(fibers)
## Start Qt event loop unless running in interactive mode.
if __name__ == '__main__':
import sys
if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
QtGui.QApplication.instance().exec_()
|