def add_lines_to_scene(self): if self.mayavi_win is None: return if self.x_lines: print 'find intersection' x_pts = self._get_intersection() tracks = [self.tracks[i] for i in x_pts] ## colors = np.hstack( (self.colors[x_pts], np.ones((len(x_pts), 1)) )) colors = self.colors[x_pts] else: tracks = self.tracks ## colors = np.hstack((self.colors, np.ones((len(self.colors), 1)) )) colors = self.colors if self.track_lines: self.track_lines.remove() track_lines, lut = xipy_fos.tvtk_line(tracks, colors, opacity=.5) ## colors = (colors*255).astype('B') ## print colors ## ## colors = np.ones_like(colors) ## print colors.shape, len(tracks) ## rgba_colors = tvtk.UnsignedCharArray() ## rgba_colors.from_array(colors) ## print rgba_colors ## track_lines.point_data.scalars = rgba_colors ## track_lines.point_data.scalars.name = 'lines' self.track_lines = mlab.pipeline.add_dataset(track_lines, figure=self.mayavi_win.fig) self.lsurf = mlab.pipeline.surface(self.track_lines, figure=self.mayavi_win.fig) self.lsurf.module_manager.scalar_lut_manager.lut_mode = 'file' self.lsurf.module_manager.scalar_lut_manager.lut = lut self.lsurf.actor.set_lut(lut) self.lsurf.actor.property.line_width = 1 self.lsurf.actor.property.opacity = .5
def highlight_track(self, cell_id): p = self.mwin.scene.camera.position trk = self.tman.tracks[cell_id] rgb = self.tman.colors[cell_id] pd, lut = xipy_fos.tvtk_line([trk], [rgb]) pline = mlab.pipeline.add_dataset(pd, figure=self.mwin.fig) self.picked_lines.append( pline ) lsurf = mlab.pipeline.surface(pline, figure=self.mwin.fig) lsurf.module_manager.scalar_lut_manager.lut_mode = 'file' lsurf.module_manager.scalar_lut_manager.lut = lut lsurf.actor.set_lut(lut) lsurf.actor.property.line_width = 2 lsurf.actor.property.opacity = 1 self.tman.lsurf.actor.property.opacity = .01 #self.mwin.scene.camera.position = p lsurf.render() self.mwin.scene.render()