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()
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()
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()
def set_state(self): gl.glPushMatrix() gl.glTranslatef(0, 0, -60) gl.glRotatef(45, 1, 0, 0) gl.glRotatef(45, 0, 1, 0)
def set_state(self): gl.glPushMatrix() gl.glTranslatef(*self.translate)