Exemplo n.º 1
0
 def draw_axis(self, axis, label):
     if self.minimum_covering_sphere is None:
         self.update_minimum_covering_sphere()
     s = self.minimum_covering_sphere
     scale = max(max(s.box_max()), abs(min(s.box_min())))
     gltbx.fonts.ucs_bitmap_8x13.setup_call_lists()
     gl.glDisable(gl.GL_LIGHTING)
     if self.settings.black_background:
         gl.glColor3f(1.0, 1.0, 1.0)
     else:
         gl.glColor3f(0.0, 0.0, 0.0)
     gl.glLineWidth(1.0)
     gl.glBegin(gl.GL_LINES)
     gl.glVertex3f(0.0, 0.0, 0.0)
     gl.glVertex3f(axis[0] * scale, axis[1] * scale, axis[2] * scale)
     gl.glEnd()
     gl.glRasterPos3f(0.5 + axis[0] * scale, 0.2 + axis[1] * scale,
                      0.2 + axis[2] * scale)
     gltbx.fonts.ucs_bitmap_8x13.render_string(label)
     gl.glEnable(gl.GL_LINE_STIPPLE)
     gl.glLineStipple(4, 0xAAAA)
     gl.glBegin(gl.GL_LINES)
     gl.glVertex3f(0.0, 0.0, 0.0)
     gl.glVertex3f(-axis[0] * scale, -axis[1] * scale, -axis[2] * scale)
     gl.glEnd()
     gl.glDisable(gl.GL_LINE_STIPPLE)
Exemplo n.º 2
0
 def draw_cross_at(self, position_tuple, color=(1, 1, 1), f=0.1):
     (x, y, z) = position_tuple
     gl.glBegin(gl.GL_LINES)
     gl.glColor3f(*color)
     gl.glVertex3f(x - f, y, z)
     gl.glVertex3f(x + f, y, z)
     gl.glVertex3f(x, y - f, z)
     gl.glVertex3f(x, y + f, z)
     gl.glVertex3f(x, y, z - f)
     gl.glVertex3f(x, y, z + f)
     gl.glEnd()
Exemplo n.º 3
0
 def draw_lab_axis(self, start, end, label):
     mid = tuple([0.5 * (s + e) for s, e in zip(start, end)])
     gltbx.fonts.ucs_bitmap_8x13.setup_call_lists()
     gl.glDisable(gl.GL_LIGHTING)
     gl.glColor3f(1.0, 1.0, 0.0)
     gl.glLineWidth(1.0)
     gl.glBegin(gl.GL_LINES)
     gl.glVertex3f(*start)
     gl.glVertex3f(*end)
     gl.glEnd()
     gl.glRasterPos3f(*mid)
     gltbx.fonts.ucs_bitmap_8x13.render_string(label)
Exemplo n.º 4
0
 def draw_lines(self):
     if self.lines_display_list is None:
         self.lines_display_list = gltbx.gl_managed.display_list()
         self.lines_display_list.compile()
         assert self.line_width > 0
         for i_seqs in self.line_i_seqs:
             color = self.line_colors.get(tuple(i_seqs))
             if color is None:
                 color = self.line_colors.get(tuple(reversed(i_seqs)))
                 if color is None:
                     color = (1, 0, 1)
             gl.glColor3f(*color)
             gl.glLineWidth(self.line_width)
             gl.glBegin(gl.GL_LINES)
             gl.glVertex3f(*self.points[i_seqs[0]])
             gl.glVertex3f(*self.points[i_seqs[1]])
             gl.glEnd()
         self.lines_display_list.end()
     self.lines_display_list.call()
Exemplo n.º 5
0
 def draw_minimum_covering_sphere(self):
     if self.minimum_covering_sphere_display_list is None:
         self.minimum_covering_sphere_display_list = gltbx.gl_managed.display_list()
         self.minimum_covering_sphere_display_list.compile()
         s = self.minimum_covering_sphere
         c = s.center()
         r = s.radius()
         gray = 0.3
         gl.glColor3f(gray, gray, gray)
         gl.glBegin(gl.GL_POLYGON)
         for i in range(360):
             a = i * math.pi / 180
             rs = r * math.sin(a)
             rc = r * math.cos(a)
             gl.glVertex3f(c[0], c[1] + rs, c[2] + rc)
         gl.glEnd()
         self.draw_cross_at(c, color=(1, 0, 0))
         self.minimum_covering_sphere_display_list.end()
     self.minimum_covering_sphere_display_list.call()
Exemplo n.º 6
0
 def draw_cell(self, axes, color):
     astar, bstar, cstar = axes[0], axes[1], axes[2]
     gltbx.fonts.ucs_bitmap_8x13.setup_call_lists()
     gl.glDisable(gl.GL_LIGHTING)
     gl.glColor3f(*color)
     gl.glLineWidth(2.0)
     gl.glBegin(gl.GL_LINES)
     gl.glVertex3f(0.0, 0.0, 0.0)
     gl.glVertex3f(*astar.elems)
     gl.glVertex3f(0.0, 0.0, 0.0)
     gl.glVertex3f(*bstar.elems)
     gl.glVertex3f(0.0, 0.0, 0.0)
     gl.glVertex3f(*cstar.elems)
     gl.glEnd()
     gl.glRasterPos3f(*(1.01 * astar).elems)
     gltbx.fonts.ucs_bitmap_8x13.render_string("a*")
     gl.glRasterPos3f(*(1.01 * bstar).elems)
     gltbx.fonts.ucs_bitmap_8x13.render_string("b*")
     gl.glRasterPos3f(*(1.01 * cstar).elems)
     gltbx.fonts.ucs_bitmap_8x13.render_string("c*")
     gl.glEnable(gl.GL_LINE_STIPPLE)
     gl.glLineStipple(4, 0xAAAA)
     farpoint = astar + bstar + cstar
     # a* face
     gl.glBegin(gl.GL_LINE_LOOP)
     gl.glVertex3f(*farpoint.elems)
     gl.glVertex3f(*(farpoint - bstar).elems)
     gl.glVertex3f(*(farpoint - bstar - cstar).elems)
     gl.glVertex3f(*(farpoint - cstar).elems)
     gl.glEnd()
     # b* face
     gl.glBegin(gl.GL_LINE_LOOP)
     gl.glVertex3f(*farpoint.elems)
     gl.glVertex3f(*(farpoint - astar).elems)
     gl.glVertex3f(*(farpoint - astar - cstar).elems)
     gl.glVertex3f(*(farpoint - cstar).elems)
     gl.glEnd()
     # c* face
     gl.glBegin(gl.GL_LINE_LOOP)
     gl.glVertex3f(*farpoint.elems)
     gl.glVertex3f(*(farpoint - bstar).elems)
     gl.glVertex3f(*(farpoint - bstar - astar).elems)
     gl.glVertex3f(*(farpoint - astar).elems)
     gl.glEnd()
     gl.glDisable(gl.GL_LINE_STIPPLE)