Exemplo n.º 1
0
 def on_draw(self, event):
     prof = Profiler()  # noqa
     self.context.clear()
     M, N = self.grid_size
     w, h = self.size
     for i in range(M):
         for j in range(N):
             self.context.set_viewport(w * i / M, h * j / N, w / M, h / N)
             self.visuals[i][j].draw()
Exemplo n.º 2
0
 def on_draw(self, event):
     prof = Profiler()  # noqa
     self.context.clear()
     M = len(self.cells)
     N = len(self.cells[0])
     w, h = self.size
     for i in range(M):
         for j in range(N):
             self.context.set_viewport(w * i / M, h * j / N, w / M, h / N)
             self.cells[i][j].draw()
Exemplo n.º 3
0
 def on_draw(self, event):
     prof = Profiler()  # noqa
     gloo.clear()
     M, N = self.grid_size
     w, h = self.size
     for i in range(M):
         for j in range(N):
             gloo.set_viewport(w * i / M, h * j / N, w / M, h / N)
             v = self.visuals[i][j]
             v.draw(v.tr_sys)
Exemplo n.º 4
0
 def on_mouse_wheel(self, event):
     prof = Profiler()  # noqa
     if not event.modifiers:
         dx = np.sign(event.delta[1]) * .05
         x0, y0 = self._normalize(event.pos)
         pan_x, pan_y = self._pz.pan
         zoom_x, zoom_y = self._pz.zoom
         zoom_x_new, zoom_y_new = (zoom_x * math.exp(2.5 * dx),
                                   zoom_y * math.exp(2.5 * dx))
         self._pz.zoom = (zoom_x_new, zoom_y_new)
         self._pz.pan = (pan_x - x0 * (1. / zoom_x - 1. / zoom_x_new),
                         pan_y + y0 * (1. / zoom_y - 1. / zoom_y_new))
         self.update()
Exemplo n.º 5
0
    def _prepare_draw(self, view):
        prof = Profiler()

        if self._parent._changed['pos']:
            if self._parent._pos is None or len(self._parent._pos) == 0:
                return False
            # pos = np.ascontiguousarray(self._parent._pos.astype(np.float32))
            pos = self._parent._pos
            self._pos_vbo.set_data(pos)
            self._program.vert['position'] = self._pos_vbo
            if pos.shape[-1] == 2:
                self._program.vert['to_vec4'] = vec2to4
            elif pos.shape[-1] == 3:
                self._program.vert['to_vec4'] = vec3to4
            else:
                raise TypeError("Got bad position array shape: %r" %
                                (pos.shape, ))

            self._color_vbo.set_data(self._parent._color)
            self._program.vert['color'] = self._color_vbo

        try:
            import OpenGL.GL as GL
            # Turn on line smooth and/or line width
            if GL:
                if self._parent._antialias:
                    GL.glEnable(GL.GL_LINE_SMOOTH)
                else:
                    GL.glDisable(GL.GL_LINE_SMOOTH)
                px_scale = self.transforms.pixel_scale
                width = px_scale * self._parent._border_width
                GL.glLineWidth(max(width, 1.))
        except Exception:  # can be other than ImportError sometimes
            pass

        prof('prepare')
        # Draw
        self._connect = 'segments'
        self._draw_mode = 'lines'
        prof('draw')
Exemplo n.º 6
0
 def on_draw(self, event):
     prof = Profiler()
     gloo.clear()
     for visual in self.visuals:
         visual.draw(self._tr)
         prof('draw visual')
Exemplo n.º 7
0
 def on_draw(self, event):
     prof = Profiler()
     self.context.clear()
     for visual in self.visuals:
         visual.draw()
         prof('draw visual')