def draw(self): """ Draw all the objects represented in this shape list. """ # ICK - SLOW - Probably no big deal in a display list. if len(self.sphere_radii) > 0: if not self.memoized: self._memoize() quux.shapeRendererDrawSpheres(len(self.sphere_radii), self.sphere_centers_array, self.sphere_radii_array, self.sphere_colors_array, self.sphere_names_array) if len(self.cylinder_radii) > 0: if not self.memoized: self._memoize() quux.shapeRendererDrawCylinders(len(self.cylinder_radii), self.cylinder_pos1_array, self.cylinder_pos2_array, self.cylinder_radii_array, self.cylinder_cappings_array, self.cylinder_colors_array, self.cylinder_names_array)
def draw(self): """ Draw all the objects represented in this shape list. """ # ICK - SLOW - Probably no big deal in a display list. if len(self.sphere_radii) > 0: if not self.memoized: self._memoize() quux.shapeRendererDrawSpheres(len(self.sphere_radii), self.sphere_centers_array, self.sphere_radii_array, self.sphere_colors_array, self.sphere_names_array) if len(self.cylinder_radii) > 0: if not self.memoized: self._memoize() quux.shapeRendererDrawCylinders( len(self.cylinder_radii), self.cylinder_pos1_array, self.cylinder_pos2_array, self.cylinder_radii_array, self.cylinder_cappings_array, self.cylinder_colors_array, self.cylinder_names_array)
def test_pyrex_opengl(test_type): # not tested since major refactoring try: print_compact_stack("selectMode Draw: " )### ### BUG: if import quux fails, we get into some sort of infinite ### loop of Draw calls. [bruce 070917 comment] #self.w.win_update() ## sys.path.append("./experimental/pyrex-opengl") # no longer ##needed here -- always done in drawer.py binPath = os.path.normpath(os.path.dirname( os.path.abspath(sys.argv[0])) + '/../bin') if binPath not in sys.path: sys.path.append(binPath) import quux if "experimental" in os.path.dirname(quux.__file__): print "WARNING: Using experimental version of quux module" # quux.test() quux.shapeRendererInit() quux.shapeRendererSetUseDynamicLOD(0) quux.shapeRendererStartDrawing() if test_type == 1: center = Numeric.array((Numeric.array((0, 0, 0), 'f'), Numeric.array((0, 0, 1), 'f'), Numeric.array((0, 1, 0), 'f'), Numeric.array((0, 1, 1), 'f'), Numeric.array((1, 0, 0), 'f'), Numeric.array((1, 0, 1), 'f'), Numeric.array((1, 1, 0), 'f'), Numeric.array((1, 1, 1), 'f')), 'f') radius = Numeric.array((0.2, 0.4, 0.6, 0.8, 1.2, 1.4, 1.6, 1.8), 'f') color = Numeric.array((Numeric.array((0, 0, 0, 0.5), 'f'), Numeric.array((0, 0, 1, 0.5), 'f'), Numeric.array((0, 1, 0, 0.5), 'f'), Numeric.array((0, 1, 1, 0.5), 'f'), Numeric.array((1, 0, 0, 0.5), 'f'), Numeric.array((1, 0, 1, 0.5), 'f'), Numeric.array((1, 1, 0, 0.5), 'f'), Numeric.array((1, 1, 1, 0.5), 'f')), 'f') result = quux.shapeRendererDrawSpheres(8, center, radius, color) elif test_type == 2: # grantham - I'm pretty sure the actual compilation, init, # etc happens once from bearing_data import sphereCenters, sphereRadii from bearing_data import sphereColors, cylinderPos1 from bearing_data import cylinderPos2, cylinderRadii from bearing_data import cylinderCapped, cylinderColors glPushMatrix() glTranslate(-0.001500, -0.000501, 151.873627) result = quux.shapeRendererDrawSpheres(1848, sphereCenters, sphereRadii, sphereColors) result = quux.shapeRendererDrawCylinders(5290, cylinderPos1, cylinderPos2, cylinderRadii, cylinderCapped, cylinderColors) glPopMatrix() quux.shapeRendererFinishDrawing() except ImportError: env.history.message(redmsg( "Can't import Pyrex OpenGL or maybe bearing_data.py, rebuild it")) return
def test_pyrex_opengl(test_type): # not tested since major refactoring try: print_compact_stack("selectMode Draw: ") ### ### BUG: if import quux fails, we get into some sort of infinite ### loop of Draw calls. [bruce 070917 comment] #self.w.win_update() ## sys.path.append("./experimental/pyrex-opengl") # no longer ##needed here -- always done in drawer.py binPath = os.path.normpath( os.path.dirname(os.path.abspath(sys.argv[0])) + '/../bin') if binPath not in sys.path: sys.path.append(binPath) import quux if "experimental" in os.path.dirname(quux.__file__): print "WARNING: Using experimental version of quux module" # quux.test() quux.shapeRendererInit() quux.shapeRendererSetUseDynamicLOD(0) quux.shapeRendererStartDrawing() if test_type == 1: center = Numeric.array( (Numeric.array((0, 0, 0), 'f'), Numeric.array( (0, 0, 1), 'f'), Numeric.array( (0, 1, 0), 'f'), Numeric.array((0, 1, 1), 'f'), Numeric.array((1, 0, 0), 'f'), Numeric.array( (1, 0, 1), 'f'), Numeric.array( (1, 1, 0), 'f'), Numeric.array((1, 1, 1), 'f')), 'f') radius = Numeric.array((0.2, 0.4, 0.6, 0.8, 1.2, 1.4, 1.6, 1.8), 'f') color = Numeric.array( (Numeric.array( (0, 0, 0, 0.5), 'f'), Numeric.array((0, 0, 1, 0.5), 'f'), Numeric.array( (0, 1, 0, 0.5), 'f'), Numeric.array((0, 1, 1, 0.5), 'f'), Numeric.array( (1, 0, 0, 0.5), 'f'), Numeric.array((1, 0, 1, 0.5), 'f'), Numeric.array( (1, 1, 0, 0.5), 'f'), Numeric.array( (1, 1, 1, 0.5), 'f')), 'f') result = quux.shapeRendererDrawSpheres(8, center, radius, color) elif test_type == 2: # grantham - I'm pretty sure the actual compilation, init, # etc happens once from bearing_data import sphereCenters, sphereRadii from bearing_data import sphereColors, cylinderPos1 from bearing_data import cylinderPos2, cylinderRadii from bearing_data import cylinderCapped, cylinderColors glPushMatrix() glTranslate(-0.001500, -0.000501, 151.873627) result = quux.shapeRendererDrawSpheres(1848, sphereCenters, sphereRadii, sphereColors) result = quux.shapeRendererDrawCylinders(5290, cylinderPos1, cylinderPos2, cylinderRadii, cylinderCapped, cylinderColors) glPopMatrix() quux.shapeRendererFinishDrawing() except ImportError: env.history.message( redmsg( "Can't import Pyrex OpenGL or maybe bearing_data.py, rebuild it" )) return
def Draw(self): if 1: # TODO: move this test code into a specific test mode just for it, # so it doesn't clutter up or slow down this general-use mode. # # wware 060124 Embed Pyrex/OpenGL unit tests into the cad code # grantham 060207: # Set to 1 to see a small array of eight spheres. # Set to 2 to see the Large-Bearing model, but this is most effective if # the Large-Bearing has already been loaded normally into rotate mode #bruce 060209 set this from a debug_pref menu item, not a hardcoded flag TEST_PYREX_OPENGL = debug_pref("TEST_PYREX_OPENGL", Choice([0, 1, 2])) # uncomment this line to set it in the old way: ## TEST_PYREX_OPENGL = 1 if TEST_PYREX_OPENGL: try: print_compact_stack("selectMode Draw: ") ### ### BUG: if import quux fails, we get into some sort of infinite ### loop of Draw calls. [bruce 070917 comment] #self.w.win_update() ## sys.path.append("./experimental/pyrex-opengl") # no longer ##needed here -- always done in drawer.py binPath = os.path.normpath( os.path.dirname(os.path.abspath(sys.argv[0])) + '/../bin') if binPath not in sys.path: sys.path.append(binPath) import quux if "experimental" in os.path.dirname(quux.__file__): print "WARNING: Using experimental version of quux module" # quux.test() quux.shapeRendererInit() quux.shapeRendererSetUseDynamicLOD(0) quux.shapeRendererStartDrawing() if TEST_PYREX_OPENGL == 1: center = Numeric.array( (Numeric.array( (0, 0, 0), 'f'), Numeric.array( (0, 0, 1), 'f'), Numeric.array((0, 1, 0), 'f'), Numeric.array( (0, 1, 1), 'f'), Numeric.array((1, 0, 0), 'f'), Numeric.array( (1, 0, 1), 'f'), Numeric.array( (1, 1, 0), 'f'), Numeric.array( (1, 1, 1), 'f')), 'f') radius = Numeric.array( (0.2, 0.4, 0.6, 0.8, 1.2, 1.4, 1.6, 1.8), 'f') color = Numeric.array((Numeric.array( (0, 0, 0, 0.5), 'f'), Numeric.array( (0, 0, 1, 0.5), 'f'), Numeric.array((0, 1, 0, 0.5), 'f'), Numeric.array((0, 1, 1, 0.5), 'f'), Numeric.array((1, 0, 0, 0.5), 'f'), Numeric.array((1, 0, 1, 0.5), 'f'), Numeric.array((1, 1, 0, 0.5), 'f'), Numeric.array((1, 1, 1, 0.5), 'f')), 'f') result = quux.shapeRendererDrawSpheres( 8, center, radius, color) elif TEST_PYREX_OPENGL == 2: # grantham - I'm pretty sure the actual compilation, init, # etc happens once from bearing_data import sphereCenters, sphereRadii from bearing_data import sphereColors, cylinderPos1 from bearing_data import cylinderPos2, cylinderRadii from bearing_data import cylinderCapped, cylinderColors glPushMatrix() glTranslate(-0.001500, -0.000501, 151.873627) result = quux.shapeRendererDrawSpheres( 1848, sphereCenters, sphereRadii, sphereColors) result = quux.shapeRendererDrawCylinders( 5290, cylinderPos1, cylinderPos2, cylinderRadii, cylinderCapped, cylinderColors) glPopMatrix() quux.shapeRendererFinishDrawing() except ImportError: env.history.message( redmsg( "Can't import Pyrex OpenGL or maybe bearing_data.py, rebuild it" )) else: if self.bc_in_use is not None: #bruce 060414 self.bc_in_use.draw(self.o, 'fake dispdef kluge') # bruce comment 040922: code is almost identical with modifyMode.Draw; # the difference (no check for self.o.assy existing) might be a bug # in this version, or might have no effect. commonGraphicsMode.Draw(self) #self.griddraw() if self.selCurve_List: self.draw_selection_curve() self.o.assy.draw(self.o)
def Draw(self): if 1: # TODO: move this test code into a specific test mode just for it, # so it doesn't clutter up or slow down this general-use mode. # # wware 060124 Embed Pyrex/OpenGL unit tests into the cad code # grantham 060207: # Set to 1 to see a small array of eight spheres. # Set to 2 to see the Large-Bearing model, but this is most effective if # the Large-Bearing has already been loaded normally into rotate mode #bruce 060209 set this from a debug_pref menu item, not a hardcoded flag TEST_PYREX_OPENGL = debug_pref("TEST_PYREX_OPENGL", Choice([0,1,2])) # uncomment this line to set it in the old way: ## TEST_PYREX_OPENGL = 1 if TEST_PYREX_OPENGL: try: print_compact_stack("selectMode Draw: " )### ### BUG: if import quux fails, we get into some sort of infinite ### loop of Draw calls. [bruce 070917 comment] #self.w.win_update() ## sys.path.append("./experimental/pyrex-opengl") # no longer ##needed here -- always done in drawer.py binPath = os.path.normpath(os.path.dirname( os.path.abspath(sys.argv[0])) + '/../bin') if binPath not in sys.path: sys.path.append(binPath) import quux if "experimental" in os.path.dirname(quux.__file__): print "WARNING: Using experimental version of quux module" # quux.test() quux.shapeRendererInit() quux.shapeRendererSetUseDynamicLOD(0) quux.shapeRendererStartDrawing() if TEST_PYREX_OPENGL == 1: center = Numeric.array((Numeric.array((0, 0, 0), 'f'), Numeric.array((0, 0, 1), 'f'), Numeric.array((0, 1, 0), 'f'), Numeric.array((0, 1, 1), 'f'), Numeric.array((1, 0, 0), 'f'), Numeric.array((1, 0, 1), 'f'), Numeric.array((1, 1, 0), 'f'), Numeric.array((1, 1, 1), 'f')), 'f') radius = Numeric.array((0.2, 0.4, 0.6, 0.8, 1.2, 1.4, 1.6, 1.8), 'f') color = Numeric.array((Numeric.array((0, 0, 0, 0.5), 'f'), Numeric.array((0, 0, 1, 0.5), 'f'), Numeric.array((0, 1, 0, 0.5), 'f'), Numeric.array((0, 1, 1, 0.5), 'f'), Numeric.array((1, 0, 0, 0.5), 'f'), Numeric.array((1, 0, 1, 0.5), 'f'), Numeric.array((1, 1, 0, 0.5), 'f'), Numeric.array((1, 1, 1, 0.5), 'f')), 'f') result = quux.shapeRendererDrawSpheres(8, center, radius, color) elif TEST_PYREX_OPENGL == 2: # grantham - I'm pretty sure the actual compilation, init, # etc happens once from bearing_data import sphereCenters, sphereRadii from bearing_data import sphereColors, cylinderPos1 from bearing_data import cylinderPos2, cylinderRadii from bearing_data import cylinderCapped, cylinderColors glPushMatrix() glTranslate(-0.001500, -0.000501, 151.873627) result = quux.shapeRendererDrawSpheres(1848, sphereCenters, sphereRadii, sphereColors) result = quux.shapeRendererDrawCylinders(5290, cylinderPos1, cylinderPos2, cylinderRadii, cylinderCapped, cylinderColors) glPopMatrix() quux.shapeRendererFinishDrawing() except ImportError: env.history.message(redmsg( "Can't import Pyrex OpenGL or maybe bearing_data.py, rebuild it")) else: if self.bc_in_use is not None: #bruce 060414 self.bc_in_use.draw(self.o, 'fake dispdef kluge') # bruce comment 040922: code is almost identical with modifyMode.Draw; # the difference (no check for self.o.assy existing) might be a bug # in this version, or might have no effect. commonGraphicsMode.Draw(self) #self.griddraw() if self.selCurve_List: self.draw_selection_curve() self.o.assy.draw(self.o)