def keyPressed(self, key, x, y): keycode = ord(key) key = key.decode('utf-8') # print("key = [%s] = [%d]" % (key, ord(key))) # n = sim.num_frames() if keycode == 27: GLUT.glutDestroyWindow(self.window) sys.exit() elif key == ' ': self.is_simulating = not self.is_simulating self.is_animating = False print("self.is_simulating = %s" % self.is_simulating) elif key == 'a': self.is_animating = not self.is_animating self.is_simulating = False print("self.is_animating = %s" % self.is_animating) elif key == ']': self.frame_index = (self.frame_index + 1) % self.sim.num_frames() print("frame = %d/%d" % (self.frame_index, self.sim.num_frames())) if hasattr(self.sim, "set_frame"): self.sim.set_frame(self.frame_index) elif key == '[': self.frame_index = (self.frame_index - 1) % self.sim.num_frames() print("frame = %d/%d" % (self.frame_index, self.sim.num_frames())) if hasattr(self.sim, "set_frame"): self.sim.set_frame(self.frame_index) elif key == 'c': self.capture()
def keyboard_press_event(self, key, x, y): if key == chr(27): glut.glutDestroyWindow(self.window) sys.exit(0) self.key_state[ord(key)] = True
def keyPressed(self, key, x, y): keycode = ord(key) key = key.decode('utf-8') if keycode == 27: GLUT.glutDestroyWindow(self.window) sys.exit() elif key == ' ': self.is_simulating = not self.is_simulating self.is_animating = False print("Simulating....") elif key == 'w': self.mForce = np.array([-500.0, 0.0, 0.0]) self.mImpulseDuration=100 print("push Backward") elif key == 's': self.mForce = np.array([500.0, 0.0, 0.0]) self.mImpulseDuration=100 print("push Forward") elif key == '[' : self.frame_index = (self.frame_index + 1) % self.sim.num_frames() print("frame = %d/%d" % (self.frame_index, self.sim.num_frames())) self.sim.set_frame(self.frame_index) elif key == '1': input() self.mController.changeStateMachine(self.mController.mStateMachines[0],self.mController.mCurrentStateMachine.mBeginTime + self.mController.mCurrentStateMachine.mElapsedTime) elif key == '2': self.mController.changeStateMachine(self.mController.mStateMachines[1],self.mController.mCurrentStateMachine.mBeginTime + self.mController.mCurrentStateMachine.mElapsedTime) elif key == '3': self.mController.changeStateMachine(self.mController.mStateMachines[2],self.mController.mCurrentStateMachine.mBeginTime + self.mController.mCurrentStateMachine.mElapsedTime) elif key == '4': self.mController.changeStateMachine(self.mController.mStateMachines[3],self.mController.mCurrentStateMachine.mBeginTime + self.mController.mCurrentStateMachine.mElapsedTime)
def keyPressed(self, key, x, y): keycode = ord(key) key = key.decode('utf-8') # print("key = [%s] = [%d]" % (key, ord(key))) # n = sim.num_frames() if keycode == 27: GLUT.glutDestroyWindow(self.window) sys.exit() elif key == ' ': self.is_simulating = not self.is_simulating self.is_animating = False print("self.is_simulating = %s" % self.is_simulating) elif key == 'a': self.is_animating = not self.is_animating self.is_simulating = False print("self.is_animating = %s" % self.is_animating) elif key == ']': self.frame_index = (self.frame_index + 1) % self.world.num_frames() print("frame = %d/%d" % (self.frame_index, self.world.num_frames())) if hasattr(self.world, "set_frame"): self.world.set_frame(self.frame_index) elif key == '[': self.frame_index = (self.frame_index - 1) % self.world.num_frames() print("frame = %d/%d" % (self.frame_index, self.world.num_frames())) if hasattr(self.world, "set_frame"): self.world.set_frame(self.frame_index) elif key == 'c': self.capture()
def keyPressed(self, key, x, y): keycode = ord(key) key = key.decode('utf-8') if keycode == 27: GLUT.glutDestroyWindow(self.window) elif key == 'q': GLUT.glutDestroyWindow(self.window) elif key == 'r': self.env.reset() elif key == ' ': self.env.is_sim_on = not self.env.is_sim_on
def quit(self): print('close window') # glut displayfunc seems to mess up stdout in pytest # GLUT.glutDisplayFunc(None) GLUT.glutIdleFunc(None) # Hide the window, glut destroy does not instantly remove the window # it adds the window to a list to be removed later # GLUT.glutHideWindow(self.window) GLUT.glutDestroyWindow(self.window) # handle remaining events so the window is closed correctly GLUT.glutMainLoopEvent() # self.window = None # time.sleep(0.1) super(context, self).quit()
def main(self, neuronObject, displaysize=(800, 600), radius=5, poly=True, fast=False, multisample=True, graph=True): self.poly = poly self.displaysize = displaysize self.graph = graph title = 'btmorph OpenGL Viewer' GLUT.glutInit(sys.argv) if multisample: GLUT.glutInitDisplayMode(GLUT.GLUT_RGBA | GLUT.GLUT_DOUBLE) else: GLUT.glutInitDisplayMode(GLUT.GLUT_RGBA | GLUT.GLUT_DOUBLE | GLUT.GLUT_MULTISAMPLE) GLUT.glutInitWindowSize(self.displaysize[0], self.displaysize[1]) GLUT.glutInitWindowPosition(50, 50) GLUT.glutCreateWindow(title) GLUT.glutDisplayFunc(self.display) GLUT.glutReshapeFunc(self.reshape) GLUT.glutMouseFunc(self.mouse) GLUT.glutMotionFunc(self.mouseMove) GLUT.glutMouseWheelFunc(self.mouseWheel) GLUT.glutKeyboardFunc(self.keyDown) GLUT.glutKeyboardUpFunc(self.keyUp) mb = modelbuilder() self.root, self.vertices_gl, self.colors_gl, self.Neuron = \ mb.build(neuronObject, self.poly, 100, fast) if graph: self.gb = graphbuilder() self.Graph, mid = \ self.gb.build(neuronObject, scalefactor=100) self.initGL(multisample) self.camera.rad = radius self.camera.focus = mid while self.running: GLUT.glutMainLoopEvent() GLUT.glutDestroyWindow(GLUT.glutGetWindow())
def _vispy_close(self): # Force the window or widget to shut down if self._closed: return # sometimes the context is already destroyed try: # prevent segfaults during garbage col _set_close_fun(self._id, None) except Exception: pass self._closed = True self._vispy_set_visible(False) # Try destroying the widget. Not in close event, because it isnt called try: glut.glutDestroyWindow(self._id) except Exception: pass
def _vispy_close(self): # Force the window or widget to shut down if self._closed: return self._vispy_canvas = None # sometimes the context is already destroyed try: # prevent segfaults during garbage col _set_close_fun(self._id, None) except Exception: pass self._closed = True self._vispy_set_visible(False) # Try destroying the widget. Not in close event, because it isnt called try: glut.glutDestroyWindow(self._id) except Exception: pass
def main(): """Show the current OpenGL connection strings.""" GLUT.glutInit(sys.argv) GLUT.glutInitContextVersion(3, 3) GLUT.glutInitContextProfile(GLUT.GLUT_CORE_PROFILE) GLUT.glutInitDisplayMode( GLUT.GLUT_DOUBLE | GLUT.GLUT_RGBA | GLUT.GLUT_DEPTH) win = GLUT.glutCreateWindow(b'NO TITLE') aspects = {'Vendor':GL.GL_VENDOR, 'Renderer':GL.GL_RENDERER, 'Version':GL.GL_VERSION,} if GL.glCreateShader: aspects['GLSL'] = GL.GL_SHADING_LANGUAGE_VERSION print('\n'.join('{}: {}'.format(key, GL.glGetString(val).decode()) for key, val in aspects.items())) GLUT.glutDestroyWindow(win)
def main(): """Show the current OpenGL connection strings.""" GLUT.glutInit(sys.argv) GLUT.glutInitContextVersion(3, 3) GLUT.glutInitContextProfile(GLUT.GLUT_CORE_PROFILE) GLUT.glutInitDisplayMode(GLUT.GLUT_DOUBLE | GLUT.GLUT_RGBA | GLUT.GLUT_DEPTH) win = GLUT.glutCreateWindow(b'NO TITLE') aspects = { 'Vendor': GL.GL_VENDOR, 'Renderer': GL.GL_RENDERER, 'Version': GL.GL_VERSION, } if GL.glCreateShader: aspects['GLSL'] = GL.GL_SHADING_LANGUAGE_VERSION print('\n'.join(f'{key}: {GL.glGetString(val).decode()}' for key, val in aspects.items())) GLUT.glutDestroyWindow(win)
def close(): glut.glutDestroyWindow(glut.glutGetWindow())
def keyPressed(*args): # If escape is pressed, kill everything. if args[0] == ESCAPE: GLUT.glutDestroyWindow(window) sys.exit()
def tearDown(self): glut.glutDestroyWindow(self.window_id)
def on_exit(): global EVENT_MNGR print('='*10 + 'END' + '='*10) time.sleep(0.8) glut.glutDestroyWindow(WIN_ID)
def close(self): GLUT.glutDestroyWindow(self.window) GLUT.glutMainLoopEvent()
def __del__(self): del(self.infoScreen) GLUT.glutDestroyWindow(self.window) self._end()
def tearDownModule(): global window GLUT.glutDestroyWindow(window) window = None
def close(self): glut.glutDestroyWindow(self.window)
def keyboard(self, key, x, y): glut.glutDestroyWindow(self.win) sys.exit(0)
def tearDown(self): GLUT.glutDestroyWindow(self.window)
def _vispy_close(self): # Force the window or widget to shut down glut.glutDestroyWindow(self._id)