def run(self, ips, imgs, para = None): balls, ids, rs, graph = [], [], [], ips.data for idx in graph.nodes(): ids.append(idx) balls.append(graph.node[idx]['o']) xs, ys, zs = [], [], [] lxs, lys, lzs = [], [], [] for (s, e) in graph.edges(): eds = graph[s][e] st, ed = graph.node[s]['o'], graph.node[e]['o'] lxs.append([st[0],ed[0]]) lys.append([st[1],ed[1]]) lzs.append([st[2],ed[2]]) for i in eds: pts = eds[i]['pts'] xs.append(pts[:,0]) ys.append(pts[:,1]) zs.append(pts[:,2]) rs = [para['r']] * len(balls) cs = tuple(np.array(para['ncolor'])/255.0) vts, fs, ns, cs = myvi.build_balls(balls, rs, cs) self.frame.viewer.add_surf_asyn('balls', vts, fs, ns, cs) vts, fs, pos, h, color = myvi.build_marks(['ID:%s'%i for i in ids], balls, para['r'], para['r'], (1,1,1)) self.frame.viewer.add_mark_asyn('txt', vts, fs, pos, h, color) cs = tuple(np.array(para['lcolor'])/255.0) vts, fs, ns, cs = myvi.build_lines(xs, ys, zs, cs) self.frame.viewer.add_surf_asyn('paths', vts, fs, ns, cs, mode='grid') vts, fs, ns, cs = myvi.build_lines(lxs, lys, lzs, (0,1,0)) self.frame.viewer.add_surf_asyn('lines', vts, fs, ns, cs, mode='grid') self.frame = None
def run(self, ips, imgs, para=None): dis = ImageManager.get(para['dis']).imgs balls, ids, rs, graph = [], [], [], ips.data for idx in graph.nodes(): ids.append(idx) balls.append(graph.node[idx]['o']) xs, ys, zs = [], [], [] v1s, v2s = [], [] for (s, e) in graph.edges(): eds = graph[s][e] st, ed = graph.node[s]['o'], graph.node[e]['o'] v1s.append(st) v2s.append(ed) for i in eds: pts = eds[i]['pts'] xs.append(pts[:, 0]) ys.append(pts[:, 1]) zs.append(pts[:, 2]) rs1 = dis[list(np.array(v1s).astype(np.int16).T)] rs2 = dis[list(np.array(v2s).astype(np.int16).T)] rs1 = list(np.clip(rs1, 2, 1e4) * 0.5) rs2 = list(np.clip(rs2, 2, 1e4) * 0.5) rs = dis[list(np.array(balls).astype(np.int16).T)] rs = list(np.clip(rs, 2, 1e4)) cs = tuple(np.array(para['ncolor']) / 255.0) vts, fs, ns, cs = myvi.build_balls(balls, rs, cs) self.frame.viewer.add_surf_asyn('balls', vts, fs, ns, cs) meansize = sum(rs) / len(rs) vts, fs, pos, h, color = myvi.build_marks(['ID:%s' % i for i in ids], balls, rs, meansize, (1, 1, 1)) self.frame.viewer.add_mark_asyn('txt', vts, fs, pos, h, color) css = tuple(np.array(para['lcolor']) / 255.0) vts, fs, ns, cs = myvi.build_lines(xs, ys, zs, css) self.frame.viewer.add_surf_asyn('paths', vts, fs, ns, cs, mode='grid') #vts, fs, ns, cs = myvi.build_lines(lxs, lys, lzs, (0,1,0)) vts, fs, ns, cs = myvi.build_arrows(v1s, v2s, rs1, rs2, 0, 0, css) self.frame.viewer.add_surf_asyn('lines', vts, fs, ns, cs) self.frame.Raise() self.frame = None