--- a/spheres.py Thu May 05 09:24:41 2011 -0700
+++ b/spheres.py Thu May 05 11:11:04 2011 -0700
@@ -1,7 +1,7 @@
from OpenGL.GL import glGenLists, glNewList, GL_COMPILE, glEndList, glCallList, \
glBegin, glEnd, GL_LINES, glVertex3f, glColor3f, \
glEnable, glDisable, GL_LIGHTING, GL_POINTS, glTranslatef
-from OpenGL.GLUT import glutInit, glutWireSphere
+from OpenGL.GLUT import glutInit, glutWireSphere, glutSolidSphere
from points import Point, centerMinMax
from ViewerItem import ViewerItem
@@ -19,24 +19,46 @@
self.create_display_list()
self.center, self.min, self.max = centerMinMax(self.vertices())
+ self.wireframe = True
+
+ def createMenu(self):
+ menu = super(Spheres, self).createMenu()
+ wireframeAction = menu.addAction("Wireframe")
+ wireframeAction.setCheckable(True)
+ wireframeAction.setChecked(self.wireframe)
+ wireframeAction.command = lambda: self.wireframeCommand()
+ return menu
+
+ def wireframeCommand(self):
+ self.wireframe = not self.wireframe
def create_display_list(self):
- self.display_list = glGenLists(1)
- glNewList(self.display_list, GL_COMPILE)
- self.draw_spheres()
+ self.solid_display_list = glGenLists(1)
+ glNewList(self.solid_display_list, GL_COMPILE)
+ self.draw_spheres(wireframe = False)
+ glEndList()
+ self.wireframe_display_list = glGenLists(1)
+ glNewList(self.wireframe_display_list, GL_COMPILE)
+ self.draw_spheres(wireframe = True)
glEndList()
- def draw_spheres(self):
+ def draw_spheres(self, wireframe = True):
for (c,r) in self.spheres:
glTranslatef(c.x,c.y,c.z)
- glutWireSphere(r, 20, 20)
+ if wireframe:
+ glutWireSphere(r, 20, 20)
+ else:
+ glutSolidSphere(r, 20, 20)
glTranslatef(-c.x,-c.y,-c.z)
def draw(self):
if not self.visible: return
r,g,b,a = self.color.getRgb()
glColor3f(r,g,b)
- glCallList(self.display_list)
+ if self.wireframe:
+ glCallList(self.wireframe_display_list)
+ else:
+ glCallList(self.solid_display_list)
def vertices(self):
for (c,r) in self.spheres:
--- a/triangles.py Thu May 05 09:24:41 2011 -0700
+++ b/triangles.py Thu May 05 11:11:04 2011 -0700
@@ -71,7 +71,7 @@
glCallList(self.wireframe_display_list)
else:
glCallList(self.triangles_display_list)
-
+
def vertices(self):
for (u,v,w) in self.triangles: