def __init__(self, parent): self._parent = parent self._vbo = gloo.VertexBuffer() self._pos = None self._color = None self._da = visuals.line.dash_atlas.DashAtlas() dash_index, dash_period = self._da['dashed'] joins = visuals.line.line.joins caps = visuals.line.line.caps self._U = dict(dash_index=dash_index, dash_period=dash_period, linejoin=joins['round'], linecaps=(caps['|'], caps['|']), dash_caps=(caps['='], caps['=']), antialias=1.0) self._dash_atlas = gloo.Texture2D(self._da._data) Visual.__init__(self, vcode=self.VERTEX_SHADER, fcode=self.FRAGMENT_SHADER) self._index_buffer = gloo.IndexBuffer() self.set_gl_state('translucent', depth_test=False) self._draw_mode = 'triangles'
def __init__(self, vertices=None, faces=None, vertex_colors=None, face_colors=None, color=(0.5, 0.5, 1, 1), vertex_values=None, meshdata=None, shading=None, mode='triangles', **kwargs): Visual.__init__(self, vcode=vertex_template, fcode=fragment_template, **kwargs) self.set_gl_state('translucent', depth_test=True, cull_face=False) self.events.add(data_updated=Event) # Define buffers self._vertices = VertexBuffer(np.zeros((0, 3), dtype=np.float32)) self._cmap = get_colormap('cubehelix') self._clim = 'auto' # Uniform color self._color = Color(color) # add filters for various modifiers self.shading_filter = None self.shading = shading # Init self._bounds = None # Note we do not call subclass set_data -- often the signatures # do no match. MeshVisual.set_data( self, vertices=vertices, faces=faces, vertex_colors=vertex_colors, face_colors=face_colors, vertex_values=vertex_values, meshdata=meshdata, color=color) # primitive mode self._draw_mode = mode self.freeze()
def __init__(self, radius, **kwargs): self._vbo = VertexBuffer() # self._v_size_var = Variable('varying float v_size') self._data = None Visual.__init__(self, vcode=vert, fcode=frag) # m_window_h / tanf(m_fov * 0.5f * (float)M_PI / 180.0) self.view_program["pointScale"] = 600 / np.tan(60 * 0.5 * np.pi / 180) self.view_program["pointRadius"] = radius self.set_gl_state(depth_test=True, blend=False) self._draw_mode = 'points' if len(kwargs) > 0: self.set_data(**kwargs) self.freeze()
def __init__(self, **kwargs): self._vbo = VertexBuffer() self._v_size_var = Variable('varying float v_size') self._marker_fun = None self._data = None Visual.__init__(self, vcode=vert, fcode=frag) self.shared_program.vert['v_size'] = self._v_size_var self.shared_program.frag['v_size'] = self._v_size_var self.set_gl_state(depth_test=True, blend=True, blend_func=('src_alpha', 'one_minus_src_alpha')) self._draw_mode = 'points' if len(kwargs) > 0: self.set_data(**kwargs) self.freeze()
def __init__(self, **kwargs): self._vbo = VertexBuffer() self._v_size_var = Variable('varying float v_size') self._symbol = None self._marker_fun = None self._data = None self.antialias = 1 self.scaling = False Visual.__init__(self, vcode=vert, fcode=frag) self.shared_program.vert['v_size'] = self._v_size_var self.shared_program.frag['v_size'] = self._v_size_var self.set_gl_state(depth_test=True, blend=True, blend_func=('src_alpha', 'one_minus_src_alpha')) self._draw_mode = 'points' if len(kwargs) > 0: self.set_data(**kwargs) self.freeze()
def __init__(self, text=None, color='black', bold=False, italic=False, face='OpenSans', font_size=12, pos=[0, 0, 0], rotation=0., anchor_x='center', anchor_y='center', method='cpu', font_manager=None): Visual.__init__(self, vcode=self.VERTEX_SHADER, fcode=self.FRAGMENT_SHADER) # Check input valid_keys = ('top', 'center', 'middle', 'baseline', 'bottom') _check_valid('anchor_y', anchor_y, valid_keys) valid_keys = ('left', 'center', 'right') _check_valid('anchor_x', anchor_x, valid_keys) # Init font handling stuff # _font_manager is a temporary solution to use global mananger self._font_manager = font_manager or FontManager(method=method) self._face = face self._bold = bold self._italic = italic self._update_font() self._vertices = None self._color_vbo = None self._anchors = (anchor_x, anchor_y) # Init text properties self.color = color self.text = text self.font_size = font_size self.pos = pos self.rotation = rotation self._text_scale = STTransform() self._draw_mode = 'triangles' self.set_gl_state(blend=True, depth_test=False, cull_face=False, blend_func=('src_alpha', 'one_minus_src_alpha')) self.freeze()
def view(self): v = Visual.view(self) self._init_view(v) return v
def __init__(self, nb_boxes, vertices=None, faces=None, vertex_colors=None, face_colors=None, color=(0.5, 0.5, 1, 1), vertex_values=None, meshdata=None, shading=None, mode='triangles', variable_vis=False, **kwargs): # Visual.__init__ -> prepare_transforms() -> uses shading if shading is not None: raise ValueError('"shading" must be "None"') self.shading = shading self._variable_vis = variable_vis if variable_vis: Visual.__init__(self, vcode=vertex_template_vis, fcode=fragment_template_vis, **kwargs) else: Visual.__init__(self, vcode=vertex_template, fcode=fragment_template, **kwargs) self.set_gl_state('translucent', depth_test=True, cull_face=False) # Define buffers self._vertices = VertexBuffer(np.zeros((0, 3), dtype=np.float32)) self._normals = None self._faces = IndexBuffer() self._normals = VertexBuffer(np.zeros((0, 3), dtype=np.float32)) self._ambient_light_color = Color((0.3, 0.3, 0.3, 1.0)) self._light_dir = (10, 5, -5) self._shininess = 1. / 200. self._cmap = get_colormap('cubehelix') self._clim = 'auto' self._mode = mode # Uniform color self._color = Color(color) # primitive mode self._draw_mode = mode # Init self._bounds = None # Note we do not call subclass set_data -- often the signatures # do no match. VarVisMeshVisual.set_data(self, vertices=vertices, faces=faces, vertex_colors=vertex_colors, face_colors=face_colors, color=color, vertex_values=vertex_values, meshdata=meshdata) self.freeze()
def draw(self, *args, **kwds): Visual.draw(self, *args, **kwds)