def __init__(self, document: Optional[vp.Document] = None, parent=None): """Constructor. Args: document: the document to display parent: QWidget parent """ fmt = QGLFormat() fmt.setVersion(3, 3) fmt.setProfile(QGLFormat.CoreProfile) fmt.setSampleBuffers(True) super().__init__(fmt, parent=parent) self.setMouseTracking(True) self._document = document self._last_mouse_x = 0.0 self._last_mouse_y = 0.0 self._mouse_drag = False # deferred initialization in initializeGL() self._ctx: Optional[mgl.Context] = None self._screen = None self.engine = Engine(view_mode=ViewMode.OUTLINE, show_pen_up=False, render_cb=self.update) # adjust default scale based on hidpi self.engine.scale = self.window().devicePixelRatio()
def __init__(self, renderer, title): QApplication.__init__(self, sys.argv) self.window = QMainWindow() self.window.setWindowTitle(title) self.window.resize(800,600) # Get OpenGL 4.1 context glformat = QGLFormat() glformat.setVersion(4, 1) glformat.setProfile(QGLFormat.CoreProfile) glformat.setDoubleBuffer(False) self.glwidget = MyGlWidget(renderer, glformat, self) self.window.setCentralWidget(self.glwidget) self.window.show()
def __init__(self, document: Optional[vp.Document] = None, parent=None): """Constructor. Args: document: the document to display parent: QWidget parent """ fmt = QGLFormat() fmt.setVersion(3, 3) fmt.setProfile(QGLFormat.CoreProfile) fmt.setSampleBuffers(True) super().__init__(fmt, parent=parent) self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.setMouseTracking(True) self._document = document self._last_mouse_x = 0.0 self._last_mouse_y = 0.0 self._mouse_drag = False self._factor = 1.0 # deferred initialization in initializeGL() self._ctx: Optional[mgl.Context] = None self._screen = None self.engine = Engine(view_mode=ViewMode.OUTLINE, show_pen_up=False, render_cb=self.update) self.windowHandle().screenChanged.connect(self.on_screen_changed) # print diagnostic information screen = self.screen() logging.info(f"QScreen info: pixelRatio={screen.devicePixelRatio()}, " f"physicalSize={screen.physicalSize().toTuple()}, " f"physicalDotsPerInch={screen.physicalDotsPerInch()}, " f"virtualSize={screen.virtualSize().toTuple()}, " f"size={screen.size().toTuple()}, " f"logicalDotsPerInch={screen.logicalDotsPerInch()}, ")
# -*- coding: utf-8 -*- """ Created on Mon Jun 3 15:20:33 2019 @author: aluo """ import mainGUI from PySide2.QtWidgets import QApplication from PySide2.QtOpenGL import QGLFormat import sys if __name__ == "__main__": app = QApplication(sys.argv) gl_format = QGLFormat() gl_format.setVersion(3, 3) gl_format.setProfile(QGLFormat.CoreProfile) gl_format.setSampleBuffers(True) main_gui = mainGUI.MainGui() main_gui.show() sys.exit(app.exec_())