def handle_camera_action(self, action): """ New camera menu handler. """ action_name = str(action.text().toAscii()) if action_name == "New": text, ok = QtGui.QInputDialog.getText(self, "New Camera", "Camera Name:", QtGui.QLineEdit.Normal) if ok and not text.isEmpty(): name = str(text.toAscii()) camera = GLCamera(self, name) self.add_camera(camera) self.set_camera(name)
def __init__(self, parent=None, fps=24, state=None): """ :param parent: parent Qt object :param fps: frames per second (default 24) :param state: GLState object (for shared states) """ self.camera = None format = QtOpenGL.QGLFormat() format.setDirectRendering(True) format.setSampleBuffers(True) self.state = state or GLState() self.state.signal_state_change.connect(self.handle_state_change) super(GLWidget, self).__init__(format, parent) self.setAutoBufferSwap(True) self.setMouseTracking(True) self.setFocusPolicy(QtCore.Qt.StrongFocus) self.setCursor(QtCore.Qt.OpenHandCursor) # save the parent object self._main = parent # frames per second value self.__time = 0 self.__frame = 0 self.__fps = fps self.__playing = False # various matrices and vectors self.__bounds_default = imath.Box3d((-5, -5, -5), (5, 5, 5)) self.__bounds = None self.__radius = 5.0 self.__last_pok = False self.__last_p2d = QtCore.QPoint() self.__last_p3d = [1.0, 0.0, 0.0] self.__rotating = False # for animated scenes self.timer = QtCore.QTimer(self) # default camera self.camera = GLCamera(self) self.state.add_camera(self.camera) self.frame()