Esempio n. 1
0
    def _draw_marker(self):
        gl.glPushMatrix()

        ws = [50.0, 25.0, 25.0, 25.0]
        hs = [100.0, -50.0, 50.0, -50.0]
        
        for i in range(len(self.plot_data)):
            # Calculate dimensions of marker
            mkr_width = int(ws[i] * self.cfg.scale_x)
            mkr_height = int(hs[i] * self.cfg.scale_y)
            
            # Get last plotted x/y
            mkr_x = self.plot_data[i].x_data[self.draw_idx]
            mkr_y = self.plot_data[i].y_data[self.draw_idx]
        
            # Get last plotted colour
            (cr, cg, cb) = self.plot_data[i].c_data[self.draw_idx]

            gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_FILL)
            gl.glColor4f(cr, cg, cb, 0.5)
            
            # Draw marker triangle
            gl.glBegin(gl.GL_TRIANGLES)
            gl.glVertex3i(mkr_x, mkr_y, 0)
            gl.glVertex3i((mkr_x - mkr_width), (mkr_y + mkr_height), 0)
            gl.glVertex3i((mkr_x + mkr_width), (mkr_y + mkr_height), 0)
            gl.glEnd()
        
        gl.glPopMatrix()
Esempio n. 2
0
 def draw(self, status_text):
     gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_FILL)
 
     # Clear transforms
     gl.glLoadIdentity()
     
     # Update status label
     if status_text is not None:
         self.lbl_status.text = status_text
     self.lbl_status.draw()
     
     # Update FPS label
     py_fps = pyglet.app.clock.get_fps()
     self.lbl_fps.text =  '[{0:3.3f}fps]'.format(py_fps)
     self.lbl_fps.draw()
Esempio n. 3
0
 def show(self, plotData, plotIndex=None):
     self.plot_data = plotData
     self.index_data = plotIndex
     self.vlists = [self._build_vertex_list(d) for d in plotData]
     
     #self._init_window()
     
     # One-time GL setup functions
     gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_LINE)
     gl.glEnable(gl.GL_DEPTH_TEST)
     
     # If in animate mode, call update function
     if self.cfg.animate:
         log.info('Starting animation')
         self.reset()
         pyglet.clock.schedule_interval(self.update, 1.0 / self.cfg.animate_fps)
Esempio n. 4
0
 def _draw_axis(self):
     gl.glPushMatrix()
     
     # Scale to fit window
     self.cfg._update_scaling()
     
     width = int(self.cfg.plot_width)
     height = int(self.cfg.plot_height)
     log.debug('Drawing axis; width=%d, height=%d', width, height)
     
     gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_LINE)
     gl.glColor4f(1.0, 1.0, 1.0, 1.0)
     
     gl.glBegin(gl.GL_LINES)
     gl.glVertex3i(0, 0, 0)
     gl.glVertex3i(width, 0, 0)
     
     gl.glVertex3i(0, 0, 0)
     gl.glVertex3i(0, height, 0)
     
     gl.glEnd()
     
     for (_lbl, pos) in self.plot_data[self.plot_idx].x_axis_markers:
         gl.glBegin(gl.GL_LINES)
         gl.glVertex3i(int(pos), 0, 0)
         gl.glVertex3i(int(pos), -1, 0)
         gl.glEnd()
         log.debug('Drawing x-axis marker at %d', int(pos))
         
         if _lbl is not None:
             gl.glPushMatrix()
             gl.glLoadIdentity()
             pyglet.text.Label(str(_lbl), font_name='Arial', font_size=8, x=pos, y=-0.5).draw()
             gl.glPopMatrix()
         
     for (_lbl, pos) in self.plot_data[self.plot_idx].y_axis_markers:
         gl.glBegin(gl.GL_LINES)
         gl.glVertex3i(0, int(pos), 0)
         gl.glVertex3i(-1, int(pos), 0)
         gl.glEnd()
         log.debug('Drawing y-axis marker at %d', int(pos))
     
     gl.glPopMatrix()
Esempio n. 5
0
 def _draw_background(self):
     gl.glPushMatrix()
     
     # Scale to fit window
     gl.glScalef(*self.cfg._update_scaling())
     
     width = int(self.cfg.plot_width)
     height = int(self.cfg.plot_height)
     depth = -1
     log.debug('Drawing background; width=%d, height=%d, depth=%d', width, height, depth)
     
     gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_FILL)
     gl.glColor4f(*self.cfg.bg_colour_4f)
     
     gl.glBegin(gl.GL_QUADS)
     gl.glVertex3i(0, 0, depth)
     gl.glVertex3i(0, height, depth)
     gl.glVertex3i(width, height, depth)
     gl.glVertex3i(width, 0, depth)
     gl.glEnd()
     
     gl.glPopMatrix()
Esempio n. 6
0
 def _draw_plot(self):
     gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_LINE)
     self.vx_dom.draw(gl.GL_LINE_STRIP)
Esempio n. 7
0
 def unset_state(self):
     gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_FILL)
     gl.glLineWidth(1)
Esempio n. 8
0
 def set_state(self):
     gl.glLineWidth(self.thickness)
     gl.glColor3d(0, 0, 0)
     gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_LINE)
Esempio n. 9
0
 def unset_state(self):
     gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_FILL)
     gl.glLineWidth(1)
Esempio n. 10
0
 def set_state(self):
     gl.glLineWidth(self.thickness)
     gl.glColor3d(0, 0, 0)
     gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_LINE)