class GLWidget(QtOpenGL.QGLWidget): def __init__(self, parent = None): super(GLWidget, self).__init__(parent) self.manager = GLManager(self) self.coordinate = Coordinate() self.entity = None def loadobj(self, filename): self.entity = Entity() self.entity.load_obj(filename) #threading.Thread(target=self.entity.load_obj, args=(filename, ), #name='loadobj').start() def paintGL(self): self.manager.clear() self.coordinate.draw() if self.entity is not None: self.entity.draw() self.swapBuffers() def resizeGL(self, w, h): self.width, self.height = w, h self.setGeometry(QtCore.QRect(0, 0, w, h)) self.manager.resize(w, h) def initializeGL(self): self.manager.init() def update(self): self.manager.update() self.updateGL() def change(self, selected): if selected == 1: self.manager.zoom_view(0) elif selected == 2: self.manager.zoom_view(1) elif selected == 3: self.manager.move_view(0) elif selected == 4: self.manager.move_view(1) self.update() def light_toggle(self): res = self.manager.light_toggle() self.update() return res def show_line_toggle(self): res = self.entity.show_line_toggle() self.update() return res def show_texture_toggle(self): res = self.entity.show_texture_toggle() self.update() return res def loop_subdivision(self): self.entity.gen_half_edge_structure() self.entity.loop_subdivision() self.entity.display_subdivision_toggle() self.update() def paint_lists(self): if self.entity is not None: self.entity.display_lists_toggle() self.update() def rotate(self, value): if self.entity is not None: self.entity.set_rotation(value) self.update() def scale(self, axis, value): if self.entity is not None: self.entity.set_scale(axis, value) self.update() def translate(self, axis, value): if self.entity is not None: self.entity.set_translation(axis, value) self.update()