def __init__(self): super().__init__(show_axis=False) self.arrow1 = visuals.Arrow(arrow_size=10, arrow_type='angle_30', arrow_color=(0.5,0.5,1,1), parent=self.view.scene) self.agents1 = Agents(256,dim=2,boundary=0.5) self.arrow2 = visuals.Arrow(arrow_size=15, arrow_type='angle_30', arrow_color=(1,0.1,0.1,1), parent=self.view.scene) self.agents2 = Agents(5,dim=2,boundary=0.5,cohesion_force=0.001,cohesion_dist=0.1,separation_dist=0.5,max_speed=0.045)
def test_arrow_transform_draw(): """Tests the ArrowVisual when a transform is applied""" # TODO: fix AppVeyor - error comes up with bollu/vispy:cassowary-constaints # commit SHA: 29303009a76d5c6931b1991aa7bdf5192ace9c4f if os.getenv('APPVEYOR', '').lower() == 'true': raise SkipTest('AppVeyor has unknown failure') old_numpy = LooseVersion(np.__version__) < '1.8' if os.getenv('TRAVIS', 'false') == 'true' and (sys.version[:3] == '2.6' or old_numpy): # TODO: Fix this (issue #1042 raise SkipTest('Travis fails due to FB stack problem') with TestingCanvas() as c: for arrow_type in ARROW_TYPES: arrow = visuals.Arrow(pos=vertices, arrow_type=arrow_type, arrows=arrows, arrow_size=10, color='red', connect="segments", parent=c.scene) arrow.transform = transforms.STTransform(scale=(0.5, 0.75), translate=(-20, -20)) assert_image_approved( c.render(), 'visuals/arrow_transform_type_%s.png' % arrow_type) arrow.parent = None
def __init__(self): super().__init__(show_axis=False) self.arrow1 = visuals.Arrow(arrow_size=10, arrow_type='angle_30', arrow_color=(0.5, 0.5, 1, 1), parent=self.view.scene) self.agents1 = Agents(512, dim=3, boundary=0.5)
def reset(self, sem_color_dict=None): """ Reset. """ # new canvas prepared for visualizing data self.map_color(sem_color_dict=sem_color_dict) self.canvas = SceneCanvas(keys='interactive', show=True) # grid self.grid = self.canvas.central_widget.add_grid() # laserscan part self.scan_view = vispy.scene.widgets.ViewBox(border_color='white', parent=self.canvas.scene) self.grid.add_widget(self.scan_view, 0, 0) self.scan_view.camera = 'turntable' self.scan_vis = visuals.Markers() self.scan_view.add(self.scan_vis) if self.viz_joint: self.joint_vis = visuals.Arrow(connect='segments', arrow_size=18, color='blue', width=10, arrow_type='angle_60') self.arrow_length = 10 self.scan_view.add(self.joint_vis) if self.viz_box: vertices, faces, outline = create_box(width=1, height=1, depth=1, width_segments=1, height_segments=1, depth_segments=1) vertices['color'][:, 3] = 0.2 # breakpoint() self.box = visuals.Box(vertex_colors=vertices['color'], edge_color='b') self.box.transform = STTransform(translate=[-2.5, 0, 0]) self.theta = 0 self.phi = 0 self.scan_view.add(self.box) visuals.XYZAxis(parent=self.scan_view.scene) # add nocs if self.viz_label: print("Using nocs in visualizer") self.nocs_view = vispy.scene.widgets.ViewBox( border_color='white', parent=self.canvas.scene) self.grid.add_widget(self.nocs_view, 0, 1) self.label_vis = visuals.Markers() self.nocs_view.camera = 'turntable' self.nocs_view.add(self.label_vis) visuals.XYZAxis(parent=self.nocs_view.scene) self.nocs_view.camera.link(self.scan_view.camera)
def add_trajectory(points, color='white', strip=1, show_lines=True, show_arrows=True): arrows = np.hstack( (points[:-1:strip], points[1::strip])) if show_arrows else None visuals.Arrow(points if show_lines else None, arrows=arrows, arrow_size=5, arrow_color=color, parent=view.scene)
def test_arrow_reactive(): """Tests the reactive behaviour of the ArrowVisual properties.""" with TestingCanvas() as c: arrow = visuals.Arrow(pos=vertices, arrows=arrows, connect="segments", parent=c.scene) arrow.arrow_type = "stealth" assert_image_approved(c.render(), 'visuals/arrow_reactive1.png') arrow.arrow_size = 20 assert_image_approved(c.render(), 'visuals/arrow_reactive2.png')
def get_visual(self, parent=None): #return visuals.Text("bird", anchor_x="left", color="red", pos=np.array(self.position), parent=parent) return visuals.Arrow( # points **self.get_location(), color=np.stack([self.get_color()] * 2), # for arrowhead arrow_color = self.get_color(), arrow_type="angle_60", arrow_size=10, # add to scene parent=parent, )
def update(self, position, direction): assert position.ndim is 2 and position.shape[1] in (2, 3) assert direction.ndim is 2 and direction.shape[1] in (2, 3) assert position.shape[0] == direction.shape[0] if self._arrows is None: self._arrows = visuals.Arrow(arrow_size=self.ARROW_SIZE, arrow_type='triangle_30', parent=self._view.scene) # arrow_coordinate[0::2] is position of arrow and # arrow_coordinate[1::2] is direction of tail (length is ignored) arrow_coordinate = np.repeat(position, 2, axis=0) arrow_coordinate[::2] -= direction self._arrows.set_data(arrows=arrow_coordinate.reshape((-1, 6))) self._canvas.update() vispy.app.process_events()
def test_arrow_reactive(): """Tests the reactive behaviour of the ArrowVisual properties""" # TODO: fix AppVeyor - error comes up with bollu/vispy:cassowary-constaints # commit SHA: 29303009a76d5c6931b1991aa7bdf5192ace9c4f if os.getenv('APPVEYOR', '').lower() == 'true': raise SkipTest('AppVeyor has unknown failure') with TestingCanvas() as c: arrow = visuals.Arrow(pos=vertices, arrows=arrows, connect="segments", parent=c.scene) arrow.arrow_type = "stealth" assert_image_approved(c.render(), 'visuals/arrow_reactive1.png') arrow.arrow_size = 20 assert_image_approved(c.render(), 'visuals/arrow_reactive2.png')
def test_arrow_draw(): """Test drawing arrows without transforms""" if os.getenv('TRAVIS', 'false') == 'true' and sys.version[:3] == '2.6': # TODO: Fix this (issue #1042) raise SkipTest('Travis fails due to FB stack problem') with TestingCanvas() as c: for arrow_type in ARROW_TYPES: arrow = visuals.Arrow(pos=vertices, arrow_type=arrow_type, arrows=arrows, arrow_size=10, color='red', connect="segments", parent=c.scene) assert_image_approved(c.render(), 'visuals/arrow_type_%s.png' % arrow_type) arrow.parent = None
def test_arrow_draw(): """Test drawing arrows without transforms""" with TestingCanvas() as c: if IS_TRAVIS_CI and c.app.backend_name.lower() == 'pyqt4': # TODO: Fix this (issue #1042 raise SkipTest('Travis fails due to FB stack problem') for arrow_type in ARROW_TYPES: arrow = visuals.Arrow(pos=vertices, arrow_type=arrow_type, arrows=arrows, arrow_size=10, color='red', connect="segments", parent=c.scene) assert_image_approved(c.render(), 'visuals/arrow_type_%s.png' % arrow_type) arrow.parent = None
def test_arrow_attributes(): """Tests if the ArrowVisual performs the required checks for attributes.""" with TestingCanvas() as c: arrow = visuals.Arrow(pos=vertices, arrow_type="stealth", arrows=arrows, arrow_size=10, color='red', connect="segments", parent=c.scene) def size_test(): arrow.arrow_size = 0.0 def type_test(): arrow.arrow_type = "random_non_existent" assert_raises(ValueError, size_test) assert_raises(ValueError, type_test)
def test_arrow_transform_draw(): """Tests the ArrowVisual when a transform is applied""" with TestingCanvas() as c: if IS_TRAVIS_CI and c.app.backend_name.lower() == 'pyqt4': # TODO: Fix this (issue #1042 raise SkipTest('Travis fails due to FB stack problem') for arrow_type in ARROW_TYPES: arrow = visuals.Arrow(pos=vertices, arrow_type=arrow_type, arrows=arrows, arrow_size=10, color='red', connect="segments", parent=c.scene) arrow.transform = transforms.STTransform(scale=(0.5, 0.75), translate=(-20, -20)) assert_image_approved( c.render(), 'visuals/arrow_transform_type_%s.png' % arrow_type) arrow.parent = None
def test_arrow_transform_draw(): """Tests the ArrowVisual when a transform is applied""" old_numpy = LooseVersion(np.__version__) < '1.8' if os.getenv('TRAVIS', 'false') == 'true' and (sys.version[:3] == '2.6' or old_numpy): # TODO: Fix this (issue #1042 raise SkipTest('Travis fails due to FB stack problem') with TestingCanvas() as c: for arrow_type in ARROW_TYPES: arrow = visuals.Arrow(pos=vertices, arrow_type=arrow_type, arrows=arrows, arrow_size=10, color='red', connect="segments", parent=c.scene) arrow.transform = transforms.STTransform(scale=(0.5, 0.75), translate=(-20, -20)) assert_image_approved( c.render(), 'visuals/arrow_transform_type_%s.png' % arrow_type) arrow.parent = None