def __init__(self, parent: Optional[QtWidgets.QWidget] = None) -> None: super(BaseViewWidget, self).__init__(parent) if hasattr(QtOpenGL.QGLFormat, 'setVersion'): f = QtOpenGL.QGLFormat() f.setVersion(3, 2) f.setProfile(QtOpenGL.QGLFormat.CoreProfile) c = QtOpenGL.QGLContext(f) QtOpenGL.QGLWidget.__init__(self, c, parent) else: QtOpenGL.QGLWidget.__init__(self, parent) self.__gl_initialized = False self.viewState = ViewPort(self.width(), self.height()) self.viewState.changed.connect(self.update) self.lastPoint = QtCore.QPoint(0, 0) # Nav Handling self.active_drag = None self.mouse_wheel_emu = None self.action_log_cb: 'Optional[Callable[[VarArg(Any)], None]]' = None self.interactionDelegate = None self.setMouseTracking(True) # TODO refine type self.selectionList: Set[Any] = set() self.open_time = time.time() # OpenGL shared resources object. Initialized during initializeGL self.gls = GLShared() # self.local_actions_map = { (EventID.Mouse_B2_DragStart, Modifier(0)): EVT_START_FIELD_DRAG, (EventID.Mouse_B2, Modifier(0)): EVT_STOP_FIELD_DRAG, } self.id_actions_map = {} self.notify_changed_actions = []
def setUp(self): # Ensure we have a qapplication - another testcase might have created it though try: app = QtWidgets.QApplication([]) except RuntimeError: pass if self.ctx is None: f = QtOpenGL.QGLFormat() f.setVersion(3, 2) f.setProfile(QtOpenGL.QGLFormat.CoreProfile) self.ctx = QtOpenGL.QGLContext(f) self.mockWidget = QtOpenGL.QGLWidget(self.ctx) self.assertTrue(self.ctx.isValid()) self.ctx.makeCurrent() # Compile the two shaders individually s1 = S.compileShader(VERT_1, GL.GL_VERTEX_SHADER) s2 = S.compileShader(FRAG_1, GL.GL_FRAGMENT_SHADER) # now build the whole program self.prog = S.compileProgram(s1, s2)
def __init__(self) -> None: f = QtOpenGL.QGLFormat() f.setVersion(3, 3) f.setProfile(QtOpenGL.QGLFormat.CoreProfile) c = QtOpenGL.QGLContext(f) QtOpenGL.QGLWidget.__init__(self, c)