Example #1
0
    def __init__(self, parent=None):
        QtOpenGL.QGLWidget.__init__(self, parent)
        self._display = None
        self._inited = False

        # enable Mouse Tracking
        self.setMouseTracking(True)
        # Strong focus
        self.setFocusPolicy(QtCore.Qt.WheelFocus)

        # required for overpainting the widget
        self.setAttribute(QtCore.Qt.WA_PaintOnScreen)
        self.setAttribute(QtCore.Qt.WA_NoSystemBackground)
        self.setAutoFillBackground(False)

        # Qt backend bookkeeping
        from OCC.Display.backend import get_loaded_backend, loaded_backend, load_pyqt4, load_pyqt5, load_pyside

        self._have_pyside = load_pyside()
        self._have_pyqt4 = load_pyqt4()
        self._have_pyqt5 = load_pyqt5()
        self._have_backend = loaded_backend()
        self._qt_backend = get_loaded_backend()
##
##pythonOCC is free software: you can redistribute it and/or modify
##it under the terms of the GNU Lesser General Public License as published by
##the Free Software Foundation, either version 3 of the License, or
##(at your option) any later version.
##
##pythonOCC is distributed in the hope that it will be useful,
##but WITHOUT ANY WARRANTY; without even the implied warranty of
##MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
##GNU Lesser General Public License for more details.
##
##You should have received a copy of the GNU Lesser General Public License
##along with pythonOCC.  If not, see <http://www.gnu.org/licenses/>.

from __future__ import print_function
import sys

from OCC.Display.backend import load_pyqt5
from OCC.Display.SimpleGui import init_display
from OCC.BRepPrimAPI import BRepPrimAPI_MakeBox

# check for pyqt5
if not load_pyqt5():
    print("pyqt5 required to run this test")
    sys.exit()

print('pyqt5 test')
pyqt5_display, start_display, add_menu, add_function_to_menu = init_display('qt-pyqt5')
my_box_1 = BRepPrimAPI_MakeBox(10., 20., 30.).Shape()
pyqt5_display.DisplayShape(my_box_1, update=True)
Example #3
0
##pythonOCC is free software: you can redistribute it and/or modify
##it under the terms of the GNU Lesser General Public License as published by
##the Free Software Foundation, either version 3 of the License, or
##(at your option) any later version.
##
##pythonOCC is distributed in the hope that it will be useful,
##but WITHOUT ANY WARRANTY; without even the implied warranty of
##MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
##GNU Lesser General Public License for more details.
##
##You should have received a copy of the GNU Lesser General Public License
##along with pythonOCC.  If not, see <http://www.gnu.org/licenses/>.

import sys

from OCC.Display.backend import load_pyqt5
from OCC.Display.SimpleGui import init_display
from OCC.Core.BRepPrimAPI import BRepPrimAPI_MakeBox

# check for pyqt5
if not load_pyqt5():
    print("pyqt5 required to run this test")
    sys.exit()

print('pyqt5 test running ...')
pyqt5_display, start_display, add_menu, add_function_to_menu = init_display(
    'qt-pyqt5')
my_box = BRepPrimAPI_MakeBox(10., 20., 30.).Shape()
pyqt5_display.DisplayShape(my_box, update=True)
print('pyqt5 test ok.')
# -*- coding: utf-8 -*-
from qtpy.QtWidgets import QApplication, QAction, qApp, QMainWindow
from qtpy.QtGui import QIcon

from OCC import VERSION
from OCC.Display.backend import load_backend, load_pyqt5, PYQT5

load_backend(PYQT5)
load_pyqt5()
from OCC.Display.qtDisplay import *


class ManiWindow(QMainWindow):
    def __init__(self, parent=None):
        super(ManiWindow, self).__init__(parent)
        self.canvas = qtViewer3d(self)
        # self.setWindowTitle("pythonOCC-%s 3d viewer" % VERSION)
        self.canvas.InitDriver()

        bar = self.menuBar()
        file = bar.addMenu("&File")

        _new = QAction(QIcon('icons/exit.png'), '&New', self)
        _new.setStatusTip("New application")
        _new.triggered.connect(self.my_process)
        # self.connect(_new, SIGNAL("triggered()"), self.my_process)
        file.addAction(_new)

        _exit = QAction(QIcon('icons/exit.png'), '&Exit', self)
        _exit.setShortcut('Ctrl+Q')
        _exit.setStatusTip('Exit application')