示例#1
0
文件: glplot.py 项目: essar/pySki
 def draw(self):
     # Adjust for margin
     gl.glTranslatef(self.cfg.window_margin_x, self.cfg.window_margin_y, 0.0)
     # Adjust for axis bar
     gl.glTranslatef((20.0 if self.cfg.show_axis else 0), (20.0 if self.cfg.show_axis else 0), 0.0)
     # Adjust for status bar
     gl.glTranslatef(0.0, (self.cfg.status_height if self.cfg.show_status_bar else 0), 0.0)
         
     # Draw base plane
     self._draw_background()
         
     # Adjust for view
     gl.glTranslatef(self.live_tx, self.live_ty, self.live_tz)
     # Scale to fit window
     gl.glScalef(*self.cfg._update_scaling())
     
     # Compute centre point
     cx = float((self.cfg.plot_width / 2.0) - (self.live_tx / self.cfg.scale_x))
     cy = float((self.cfg.plot_height / 2.0) - (self.live_ty / self.cfg.scale_y))
     #cz = float(glCfg.plot_depth / 2.0)
         
     # Scale according to zoom factors about centre point
     gl.glTranslatef(cx, cy, 0.0)
     gl.glScalef(self.live_zoom_x, self.live_zoom_y, self.live_zoom_z)
     gl.glTranslatef(-cx, -cy, 0.0)
             
     # Rotate about X axis
     #glRotatef(-90.0, 10.0, 0.0, 0.0)
     
     # Draw axis
     if self.cfg.show_axis:
         self._draw_axis()
         
     # Draw plot elements as lines
     self._draw_plot()
     
     if self.cfg.show_marker:
         self._draw_marker()
     
     if self.cfg.show_status_bar:
         self._draw_status_bar()
示例#2
0
文件: glplot.py 项目: essar/pySki
 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()