osdag_gui.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:Osdag 作者: osdag-admin 项目源码 文件源码
def init_display(self, backend_str=None, size=(1024, 768)):

        global display, start_display, app, _, USED_BACKEND

        if not backend_str:
            USED_BACKEND = self.get_backend()
        elif backend_str in [ 'pyside', 'pyqt4']:
            USED_BACKEND = backend_str
        else:
            raise ValueError("You should pass either 'qt' or 'tkinter' to the init_display function.")
            sys.exit(1)

        # Qt based simple GUI
        if USED_BACKEND in ['pyqt4', 'pyside']:
            if USED_BACKEND == 'pyqt4':
                from PyQt4 import QtCore, QtGui, QtOpenGL
                from OCC.Display.pyqt4Display import qtViewer3d
            elif USED_BACKEND == 'pyside':
                from PySide import QtCore, QtGui, QtOpenGL
                from OCC.Display.pysideDisplay import qtViewer3d

        self.ui.modelTab = qtViewer3d(self)
        # self.ui.model2dTab = qtViewer3d(self)

        self.setWindowTitle("Osdag-%s 3d viewer ('%s' backend)" % (VERSION, USED_BACKEND))
        self.ui.mytabWidget.resize(size[0], size[1])
        self.ui.mytabWidget.addTab(self.ui.modelTab, "")
        # self.ui.mytabWidget.addTab(self.ui.model2dTab,"")

        self.ui.modelTab.InitDriver()
        display = self.ui.modelTab._display
        # display_2d = self.ui.model2dTab._display


        # background gradient
        display.set_bg_gradient_color(23, 1, 32, 23, 1, 32)
        # display_2d.set_bg_gradient_color(255,255,255,255,255,255)
        # display black trihedron
        display.display_trihedron()
        display.View.SetProj(1, 1, 1)
        def centerOnScreen(self):
                    '''Centers the window on the screen.'''
                    resolution = QtGui.QDesktopWidget().screenGeometry()
                    self.move((resolution.width() / 2) - (self.frameSize().width() / 2),
                              (resolution.height() / 2) - (self.frameSize().height() / 2))
        def start_display():

            self.ui.modelTab.raise_()
            # self.ui.model2dTab.raise_()   # make the application float to the top

        return display, start_display
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号