コード例 #1
0
ファイル: gl.py プロジェクト: roderickmackenzie/gpvdm
		def __init__(self, parent):
			self.ray_fast=fast_data()
			self.failed=True
			self.graph_path="./snapshots/159/Jn.dat"
			self.graph_z_max=1.0
			self.graph_z_min=1.0
			self.xRot =25.0
			self.yRot =-20.0
			self.zRot =0.0
			self.x_pos=-0.5
			self.y_pos=-0.5
			self.zoom=-12.0
			self.timer=None
			self.zoom_timer=None
			self.suns=0.0
			self.selected_layer=-1
			self.graph_data=dat_file()
			QGLWidget.__init__(self, parent)
			self.lastPos=None
			#glClearDepth(1.0)              
			#glDepthFunc(GL_LESS)
			#glEnable(GL_DEPTH_TEST)
			#glShadeModel(GL_SMOOTH)
		
			self.setMinimumSize(650, 500)
コード例 #2
0
 def __init__(self, parent):
     QGLWidget.__init__(self, parent)
     self.parent = parent
     self.worker = parent.worker
     self.setAttribute(Qt.WA_NativeWindow, True)
     self.setContentsMargins(QMargins())
     self.setFocusPolicy(Qt.StrongFocus)
     self.setFocus(True)
     self.toggle_fs.connect(self.toggle_fullscreen)
コード例 #3
0
ファイル: gltest.py プロジェクト: ProfHoekstra/bluesky
    def __init__(self, parent=None):
        self.first = True
        f = QGLFormat()
        f.setVersion(3, 3)
        f.setProfile(QGLFormat.CoreProfile)
        f.setDoubleBuffer(True)
        QGLWidget.__init__(self, QGLContext(f), parent)

        print(('QGLWidget initialized for OpenGL version %d.%d' % (f.majorVersion(), f.minorVersion())))

        print("This script creates a file called 'opengl-test.txt', containing information about the opengl support of your computer. Useful when debugging problems with the opengl version of BlueSky.")
コード例 #4
0
ファイル: graphics.py プロジェクト: WendyHanzer/7c
    def __init__(self, engine):
        QGLWidget.__init__(self)
        self.engine = engine

        self.pos = np.array([0.0, 50.0, 200.0], np.float32)
        self.direction = np.array([0.0,-50.0,-200.0], np.float32)
        self.up = np.array([0.0, 1.0, 0.0], np.float32)

        self.cameraRotateX = self.cameraRotateY = 0.0

        self.programs = {}
        self.shaders = {}
コード例 #5
0
ファイル: GLView.py プロジェクト: iclosure/jcoolkits
 def __init__(self, parent = None):
     '''
     Constructor
     '''
     super(JGLView, self).__init__(parent)
     self.setObjectName("JGLView")
     self.setMouseTracking(True)
     self.setRenderHints(QPainter.Antialiasing |
                         QPainter.SmoothPixmapTransform |
                         QPainter.HighQualityAntialiasing |
                         QPainter.TextAntialiasing)
     self.setTransformationAnchor(QGraphicsView.AnchorViewCenter)
     glWidget = QGLWidget(QGLFormat(QGL.SampleBuffers), self)
     glWidget.makeCurrent()
     self.setViewport(glWidget)
     self.setViewportUpdateMode(QGraphicsView.FullViewportUpdate)
コード例 #6
0
    def __init__(self, voronoi_data, parent=None):
        QGLWidget.__init__(self, parent)
        self.voronoi = voronoi_data

        # points will need to view points
        points = []
        lines = []
        triangles = []

        for p in self.voronoi.points:
            # points
            points.append([p.x, p.y])

            # lines
            for border in p.borders:
                for p1, p2 in border.lines():
                    lines.append([p1.x, p1.y])
                    lines.append([p2.x, p2.y])

        self.__vertex_buffer = lines + points
        self.__lines_count = len(lines)
        self.__points_count = len(points)
コード例 #7
0
    def __init__(self, parent):
        QGLWidget.__init__(self, parent)

        self.vertexShader = """
                #version 130

                attribute vec3 vert;
                uniform mat4 MVP;


                void main() {
                   gl_Position = MVP * vec4(vert, 1.0);
                }
        """

        # fragment shader program
        self.fragmentShader = """
                #version 130
                uniform vec4 fragmentColor;
                out vec4 color;

                void main()
                {
                   // Output color = red
                   color = fragmentColor;
                }
        """
        self.polar = vec3(0, 0, 0)
        self.center = vec3(0, 0, 0)
        self.eye = vec3(0, 0, 0)
        self.startX = 0
        self.startY = 0

        self.program = None
        self.mvp_id = 0
        self.vert_id = 0
        self.color_id = 0
        self.vertices = None
コード例 #8
0
ファイル: gl.py プロジェクト: xj361685640/gpvdm
        def __init__(self, parent):
            QGLWidget.__init__(self, parent)
            self.setAutoBufferSwap(False)

            self.failed = True
            self.graph_path = "./snapshots/159/Jn.dat"
            self.graph_z_max = 1.0
            self.graph_z_min = 1.0
            #view pos
            self.view = view_point()
            self.view.xRot = 25.0
            self.view.yRot = -20.0
            self.view.zRot = 0.0
            self.view.x_pos = -0.5
            self.view.y_pos = -0.5
            self.view.zoom = -12.0

            self.viewtarget = view_point()
            #self.viewtarget.set_value(self.view)
            self.viewtarget.xRot = 0.0
            self.viewtarget.yRot = 0.0
            self.viewtarget.zRot = 0.0
            self.viewtarget.x_pos = -2.0
            self.viewtarget.y_pos = -1.7
            self.viewtarget.zoom = -8.0

            self.timer = None

            self.suns = 0.0
            self.selected_layer = -1
            self.graph_data = dat_file()
            self.lastPos = None
            self.ray_file = ""
            self.mouse_click_time = 0.0

            self.tab_active_layers = True
            self.gl_device_height = 1.4
            self.dy_layer_offset = 0.05
コード例 #9
0
    def __init__(self):
        super().__init__()

        self.setViewport(QGLWidget(QGLFormat(QGL.SampleBuffers)))
        scene = QGraphicsScene(self)
        self.setScene(scene)
        self.setSceneRect(0, 0, 600, 600)
        # self.setStyleSheet('background-color: rgba(255, 0, 0, 255)')

        for _ in range(10):
            pos = random.sample(range(0, 600), 2)
            circle = Circle(*pos, 100)
            circle.create_random_point()
            self.scene().addItem(circle)
コード例 #10
0
    def __init__(self, parent) -> None:
        """
        CONSTRUCTOR
        """
        super().__init__(parent)
        self.ui = frm_lego_designer.Ui_Dialog(self)
        self.setWindowTitle("Lego Diagram Editor")

        #
        # Graphics view
        #
        self.ctrl_graphics_view = InteractiveGraphicsView()
        v = self.ctrl_graphics_view
        sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        sizePolicy.setHeightForWidth(v.sizePolicy().hasHeightForWidth())
        v.setSizePolicy(sizePolicy)
        v.setObjectName("graphicsView")
        v.setBackgroundBrush(QBrush(QColor(255, 255, 255)))
        v.setInteractive(True)
        layout = QGridLayout()
        self.ui.FRA_MAIN.setLayout(layout)
        layout.addWidget(v)

        # Open GL rendering
        if groot.data.config.options().opengl:
            v.setViewport(QGLWidget(QGLFormat(QGL.SampleBuffers)))

        # Default (empty) scene
        scene = QGraphicsScene()
        scene.addRect(QRectF(-10, -10, 20, 20))

        v.setScene(scene)

        #
        # Create our model view!
        #
        self.model_view: ModelView = None
        self.update_view()

        self.toggle_show_edit(False)

        # Button clicks
        for x in (self.ui.BTN_S_EDGES_, self.ui.BTN_S_COMPS_,
                  self.ui.BTN_S_GENES_, self.ui.BTN_S_MINCOMPS_,
                  self.ui.BTN_S_DOMAINS_):
            x.clicked[bool].connect(self.on_btn_click)
コード例 #11
0
    def __init__(self, parent=None):
        """
        On initialization, we need to bind the Ctrl/command key to
        enable manipulation of the view.
        """
        QGraphicsView.__init__(self, parent)
        self.setTransformationAnchor(QGraphicsView.AnchorUnderMouse)
        self.setRubberBandSelectionMode(Qt.IntersectsItemShape)
        self.setStyleSheet(
            "QGraphicsView { background-color: rgb(96.5%, 96.5%, 96.5%); }")
        self._no_drag = QGraphicsView.RubberBandDrag
        self._yes_drag = QGraphicsView.ScrollHandDrag

        # reset things that are state dependent
        self.clearGraphicsView()

        self._x0 = 0
        self._y0 = 0
        self._scale_size = 1.0
        self._scale_limit_max = 3.0
        self._scale_limit_min = 0.41
        self._scale_up_rate = 0.01
        self._scale_down_rate = 0.01
        self._scale_fit_factor = 1  # sets initial zoom level
        self._show_details = True
        self._last_scale_factor = 0.0
        self.scene_root_item = None  # the item to transform
        # Keyboard panning
        self._key_pan_delta_x = styles.PATH_BASE_WIDTH * 21
        self._key_pan_delta_y = styles.PATH_HELIX_HEIGHT + styles.PATH_HELIX_PADDING / 2
        # Modifier keys and buttons
        self._key_mod = Qt.Key_Control
        self._button_pan = Qt.LeftButton
        self._button_pan_alt = Qt.MidButton
        self._button_zoom = Qt.RightButton

        self.toolbar = None  # custom hack for the paint tool palette
        self._name = None

        if GL:
            self.setViewport(QGLWidget(QGLFormat(QGL.SampleBuffers)))
            self.setViewportUpdateMode(QGraphicsView.FullViewportUpdate)
        else:
            self.setViewportUpdateMode(QGraphicsView.MinimalViewportUpdate)
コード例 #12
0
    def setUseOpenGL(self, useOpenGL):
        if not QT_NO_OPENGL:
            if (useOpenGL and QGLFormat.hasOpenGL()):
                if (not self.viewport()):
                    format = QGLFormat.defaultFormat()
                    format.setDepth(False)  # No need for a depth buffer
                    format.setSampleBuffers(True)  # Enable anti-aliasing
                    self.setViewport(QGLWidget(format))

            else:
                if self.viewport():
                    self.setViewport(None)

            v = self.viewport()
            if (self.mMode == MapViewMode.StaticContents):
                v.setAttribute(Qt.WA_StaticContents)
            v.setMouseTracking(True)
        else:
            pass
コード例 #13
0
ファイル: splat.py プロジェクト: thuskey/Splat3D
 def __init__(self,parent):
     QGLWidget.__init__(self,parent)
コード例 #14
0
    def __init_ui(self):
        # set up the scene
        self.scene = QGraphicsScene()
        self.scene.setSceneRect(0, 0, 650, 560)
        self.scene.setBackgroundBrush(Qt.darkGray)

        # set up the view
        self.setScene(self.scene)
        # these 10 additional pixels are for the margin
        self.setFixedSize(660, 570)
        # optimization
        self.setOptimizationFlag(QGraphicsView.DontAdjustForAntialiasing)
        self.setOptimizationFlag(QGraphicsView.DontSavePainterState)
        self.setCacheMode(QGraphicsView.CacheBackground)
        self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.setInteractive(False)
        self.setViewport(QGLWidget(QGLFormat()))
        self.setViewportUpdateMode(QGraphicsView.FullViewportUpdate)

        # set the background
        backgroundPixmap = QPixmap(self.texture)
        background = QGraphicsPixmapItem(backgroundPixmap)
        self.scene.addItem(background)

        self.hudCurrentStage = HudEndOfStageCurrentStageContainer(
            self.config, self.currentStage)
        self.hudCurrentStage.setPos(370, 80)
        self.scene.addItem(self.hudCurrentStage)

        # FIRST PLAYER
        self.hudFirstPlayerTotalPoints = HudEndOfStageTotalPlayerPointsContainer(
            self.config, self.firstPlayerTotalPoints)
        self.hudFirstPlayerTotalPoints.setPos(85, 160)
        self.scene.addItem(self.hudFirstPlayerTotalPoints)

        self.firstPlayerBasicTankSeparatePoints = HudEndOfStageSeparateTankPointsContainer(
            self.config, self.firstPlayerSeparateTankDetails.details["basic"])
        self.firstPlayerBasicTankSeparatePoints.setPos(65, 220)
        self.firstPlayerBasicTankSeparatePoints.hide()
        self.scene.addItem(self.firstPlayerBasicTankSeparatePoints)
        self.firstPlayerBasicTankSeparateCount = HudEndOfStageSeparateTankCount(
            self.config,
            self.firstPlayerSeparateTankDetails.details["basic"]["count"])
        self.firstPlayerBasicTankSeparateCount.setPos(240, 220)
        self.firstPlayerBasicTankSeparateCount.hide()
        self.scene.addItem(self.firstPlayerBasicTankSeparateCount)

        self.firstPlayerFastTankSeparatePoints = HudEndOfStageSeparateTankPointsContainer(
            self.config, self.firstPlayerSeparateTankDetails.details["fast"])
        self.firstPlayerFastTankSeparatePoints.setPos(65, 280)
        self.firstPlayerFastTankSeparatePoints.hide()
        self.scene.addItem(self.firstPlayerFastTankSeparatePoints)
        self.firstPlayerFastTankSeparateCount = HudEndOfStageSeparateTankCount(
            self.config,
            self.firstPlayerSeparateTankDetails.details["fast"]["count"])
        self.firstPlayerFastTankSeparateCount.setPos(240, 280)
        self.firstPlayerFastTankSeparateCount.hide()
        self.scene.addItem(self.firstPlayerFastTankSeparateCount)

        self.firstPlayerPowerTankSeparatePoints = HudEndOfStageSeparateTankPointsContainer(
            self.config, self.firstPlayerSeparateTankDetails.details["power"])
        self.firstPlayerPowerTankSeparatePoints.setPos(65, 340)
        self.firstPlayerPowerTankSeparatePoints.hide()
        self.scene.addItem(self.firstPlayerPowerTankSeparatePoints)
        self.firstPlayerPowerTankSeparateCount = HudEndOfStageSeparateTankCount(
            self.config,
            self.firstPlayerSeparateTankDetails.details["power"]["count"])
        self.firstPlayerPowerTankSeparateCount.setPos(240, 340)
        self.firstPlayerPowerTankSeparateCount.hide()
        self.scene.addItem(self.firstPlayerPowerTankSeparateCount)

        self.firstPlayerArmorTankSeparatePoints = HudEndOfStageSeparateTankPointsContainer(
            self.config, self.firstPlayerSeparateTankDetails.details["armor"])
        self.firstPlayerArmorTankSeparatePoints.setPos(65, 400)
        self.firstPlayerArmorTankSeparatePoints.hide()
        self.scene.addItem(self.firstPlayerArmorTankSeparatePoints)
        self.firstPlayerArmorTankSeparateCount = HudEndOfStageSeparateTankCount(
            self.config,
            self.firstPlayerSeparateTankDetails.details["armor"]["count"])
        self.firstPlayerArmorTankSeparateCount.setPos(240, 400)
        self.firstPlayerArmorTankSeparateCount.hide()
        self.scene.addItem(self.firstPlayerArmorTankSeparateCount)

        self.hudFirstPlayerTotalTanksPerPlayer = HudEndOfStageTotalTanksPerPlayerContainer(
            self.config, self.firstPlayerTotalTanksPerPlayer)
        self.hudFirstPlayerTotalTanksPerPlayer.setPos(240, 440)
        self.hudFirstPlayerTotalTanksPerPlayer.hide()
        self.scene.addItem(self.hudFirstPlayerTotalTanksPerPlayer)

        # SECOND PLAYER
        self.hudSecondPlayerTotalPoints = HudEndOfStageTotalPlayerPointsContainer(
            self.config, self.secondPlayerTotalPoints)
        self.hudSecondPlayerTotalPoints.setPos(450, 160)
        self.scene.addItem(self.hudSecondPlayerTotalPoints)

        self.secondPlayerBasicTankSeparatePoints = HudEndOfStageSeparateTankPointsContainer(
            self.config, self.secondPlayerSeparateTankDetails.details["basic"])
        self.secondPlayerBasicTankSeparatePoints.setPos(430, 220)
        self.secondPlayerBasicTankSeparatePoints.hide()
        self.scene.addItem(self.secondPlayerBasicTankSeparatePoints)
        self.secondPlayerBasicTankSeparateCount = HudEndOfStageSeparateTankCount(
            self.config,
            self.secondPlayerSeparateTankDetails.details["basic"]["count"])
        self.secondPlayerBasicTankSeparateCount.setPos(370, 220)
        self.secondPlayerBasicTankSeparateCount.hide()
        self.scene.addItem(self.secondPlayerBasicTankSeparateCount)

        self.secondPlayerFastTankSeparatePoints = HudEndOfStageSeparateTankPointsContainer(
            self.config, self.secondPlayerSeparateTankDetails.details["fast"])
        self.secondPlayerFastTankSeparatePoints.setPos(430, 280)
        self.secondPlayerFastTankSeparatePoints.hide()
        self.scene.addItem(self.secondPlayerFastTankSeparatePoints)
        self.secondPlayerFastTankSeparateCount = HudEndOfStageSeparateTankCount(
            self.config,
            self.secondPlayerSeparateTankDetails.details["fast"]["count"])
        self.secondPlayerFastTankSeparateCount.setPos(370, 280)
        self.secondPlayerFastTankSeparateCount.hide()
        self.scene.addItem(self.secondPlayerFastTankSeparateCount)

        self.secondPlayerPowerTankSeparatePoints = HudEndOfStageSeparateTankPointsContainer(
            self.config, self.secondPlayerSeparateTankDetails.details["power"])
        self.secondPlayerPowerTankSeparatePoints.setPos(430, 340)
        self.secondPlayerPowerTankSeparatePoints.hide()
        self.scene.addItem(self.secondPlayerPowerTankSeparatePoints)
        self.secondPlayerPowerTankSeparateCount = HudEndOfStageSeparateTankCount(
            self.config,
            self.secondPlayerSeparateTankDetails.details["power"]["count"])
        self.secondPlayerPowerTankSeparateCount.setPos(370, 340)
        self.secondPlayerPowerTankSeparateCount.hide()
        self.scene.addItem(self.secondPlayerPowerTankSeparateCount)

        self.secondPlayerArmorTankSeparatePoints = HudEndOfStageSeparateTankPointsContainer(
            self.config, self.secondPlayerSeparateTankDetails.details["armor"])
        self.secondPlayerArmorTankSeparatePoints.setPos(430, 400)
        self.secondPlayerArmorTankSeparatePoints.hide()
        self.scene.addItem(self.secondPlayerArmorTankSeparatePoints)
        self.secondPlayerArmorTankSeparateCount = HudEndOfStageSeparateTankCount(
            self.config,
            self.secondPlayerSeparateTankDetails.details["armor"]["count"])
        self.secondPlayerArmorTankSeparateCount.setPos(370, 400)
        self.secondPlayerArmorTankSeparateCount.hide()
        self.scene.addItem(self.secondPlayerArmorTankSeparateCount)

        self.hudSecondPlayerTotalTanksPerPlayer = HudEndOfStageTotalTanksPerPlayerContainer(
            self.config, self.secondPlayerTotalTanksPerPlayer)
        self.hudSecondPlayerTotalTanksPerPlayer.setPos(370, 440)
        self.hudSecondPlayerTotalTanksPerPlayer.hide()
        self.scene.addItem(self.hudSecondPlayerTotalTanksPerPlayer)
コード例 #15
0
ファイル: gui.py プロジェクト: elihusela/Robotics_Proj
    def setupUi(self, MainWindow):
        self.MainWindow = MainWindow
        self.sequence = QSequentialAnimationGroup()
        self.sequence.finished.connect(self.animation_finished)
        self.scene = QGraphicsScene()

        MainWindow.setObjectName("MainWindow")
        #MainWindow.setWindowIcon(QtGui.QIcon("icon.png"))
        MainWindow.resize(self.width, self.height)

        #qt designer generated code
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.gridLayout = QtWidgets.QGridLayout(self.centralwidget)
        self.gridLayout.setObjectName("gridLayout")
        self.graphicsView = QtWidgets.QGraphicsView(self.centralwidget)
        self.graphicsView.setEnabled(True)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding,
                                           QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(1)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.graphicsView.sizePolicy().hasHeightForWidth())
        self.graphicsView.setSizePolicy(sizePolicy)
        self.graphicsView.setObjectName("graphicsView")
        self.gridLayout.addWidget(self.graphicsView, 3, 1, 1, 1)
        self.gridLayout_2 = QtWidgets.QGridLayout()
        self.gridLayout_2.setObjectName("gridLayout_2")
        self.pushButton_1 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_1.setObjectName("pushButton_1")
        self.gridLayout_2.addWidget(self.pushButton_1, 3, 0, 1, 1)
        self.pushButton_2 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_2.setObjectName("pushButton_2")
        self.gridLayout_2.addWidget(self.pushButton_2, 5, 0, 1, 1)
        self.pushButton_4 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_4.setObjectName("pushButton_4")
        self.gridLayout_2.addWidget(self.pushButton_4, 9, 0, 1, 1)
        self.lineEdit_3 = QtWidgets.QLineEdit(self.centralwidget)
        self.lineEdit_3.setObjectName("lineEdit_3")
        self.gridLayout_2.addWidget(self.lineEdit_3, 6, 0, 1, 1)
        self.pushButton_0 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_0.setObjectName("pushButton_0")
        self.gridLayout_2.addWidget(self.pushButton_0, 1, 0, 1, 1)
        self.lineEdit_1 = QtWidgets.QLineEdit(self.centralwidget)
        self.lineEdit_1.setObjectName("lineEdit_1")
        self.gridLayout_2.addWidget(self.lineEdit_1, 2, 0, 1, 1)
        self.pushButton_3 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_3.setObjectName("pushButton_3")
        self.gridLayout_2.addWidget(self.pushButton_3, 7, 0, 1, 1)
        self.pushButton_6 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_6.setObjectName("pushButton_6")
        self.gridLayout_2.addWidget(self.pushButton_6, 14, 0, 1, 1)
        self.pushButton_7 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_7.setObjectName("pushButton_7")
        self.gridLayout_2.addWidget(self.pushButton_7, 19, 0, 1, 1)
        self.lineEdit_4 = QtWidgets.QLineEdit(self.centralwidget)
        self.lineEdit_4.setObjectName("lineEdit_4")
        self.gridLayout_2.addWidget(self.lineEdit_4, 8, 0, 1, 1)
        self.lineEdit_0 = QtWidgets.QLineEdit(self.centralwidget)
        self.lineEdit_0.setObjectName("lineEdit_0")
        self.gridLayout_2.addWidget(self.lineEdit_0, 0, 0, 1, 1)
        self.lineEdit_2 = QtWidgets.QLineEdit(self.centralwidget)
        self.lineEdit_2.setObjectName("lineEdit_2")
        self.gridLayout_2.addWidget(self.lineEdit_2, 4, 0, 1, 1)
        self.pushButton_5 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_5.setObjectName("pushButton_5")
        self.gridLayout_2.addWidget(self.pushButton_5, 11, 0, 1, 1)
        self.lineEdit_7 = QtWidgets.QLineEdit(self.centralwidget)
        self.lineEdit_7.setObjectName("lineEdit_7")
        self.gridLayout_2.addWidget(self.lineEdit_7, 17, 0, 1, 1)
        self.lineEdit_5 = QtWidgets.QLineEdit(self.centralwidget)
        self.lineEdit_5.setObjectName("lineEdit_5")
        self.gridLayout_2.addWidget(self.lineEdit_5, 10, 0, 1, 1)
        self.lineEdit_6 = QtWidgets.QLineEdit(self.centralwidget)
        self.lineEdit_6.setObjectName("lineEdit_6")
        self.gridLayout_2.addWidget(self.lineEdit_6, 12, 0, 1, 1)
        self.gridLayout.addLayout(self.gridLayout_2, 3, 0, 1, 1)
        MainWindow.setCentralWidget(self.centralwidget)
        self.statusbar = QtWidgets.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

        #end of eq designer generated code

        self.lineEdits = []
        self.lineEdits.append(self.lineEdit_0)
        self.lineEdits.append(self.lineEdit_1)
        self.lineEdits.append(self.lineEdit_2)
        self.lineEdits.append(self.lineEdit_3)
        self.lineEdits.append(self.lineEdit_4)
        self.lineEdits.append(self.lineEdit_5)
        self.lineEdits.append(self.lineEdit_6)
        self.lineEdits.append(self.lineEdit_7)
        self.pushButtons = []
        self.pushButtons.append(self.pushButton_0)
        self.pushButtons.append(self.pushButton_1)
        self.pushButtons.append(self.pushButton_2)
        self.pushButtons.append(self.pushButton_3)
        self.pushButtons.append(self.pushButton_4)
        self.pushButtons.append(self.pushButton_5)
        self.pushButtons.append(self.pushButton_6)
        self.pushButtons.append(self.pushButton_7)
        self.graphicsView.setScene(self.scene)
        self.graphicsView.setSceneRect(0, 0, 0, 0)
        self.graphicsView.setRenderHints(QPainter.Antialiasing)
        # self.graphicsView.fitInView(self.scene.sceneRect(), Qt.KeepAspectRatio)
        self.graphicsView.setViewport(QGLWidget(QGLFormat(QGL.SampleBuffers)))
        self.graphicsView.scale(self.zoom, -self.zoom)
        self.graphicsView.setDragMode(1)
コード例 #16
0
    def __init__(self, parent=None, **kw):
        # the current button
        self._ActiveButton = MouseButton.NoButton

        # private attributes
        self.__saveX = 0
        self.__saveY = 0
        self.__saveModifiers = KeyboardModifier.NoModifier
        self.__saveButtons = MouseButton.NoButton
        self.__wheelDelta = 0

        # do special handling of some keywords:
        # stereo, rw

        try:
            stereo = bool(kw['stereo'])
        except KeyError:
            stereo = False

        try:
            rw = kw['rw']
        except KeyError:
            rw = None

        # create base qt-level widget
        if QVTKRWIBase == "QWidget":
            if "wflags" in kw:
                wflags = kw['wflags']
            else:
                wflags = WindowType.Widget  # what Qt.WindowFlags() returns (0)
            QWidget.__init__(self, parent, wflags | WindowType.MSWindowsOwnDC)
        elif QVTKRWIBase == "QGLWidget":
            QGLWidget.__init__(self, parent)
        elif QVTKRWIBase == "QOpenGLWidget":
            QOpenGLWidget.__init__(self, parent)

        if rw:  # user-supplied render window
            self._RenderWindow = rw
        else:
            self._RenderWindow = vtkRenderWindow()

        WId = self.winId()

        # Python2
        if type(WId).__name__ == 'PyCObject':
            from ctypes import pythonapi, c_void_p, py_object

            pythonapi.PyCObject_AsVoidPtr.restype = c_void_p
            pythonapi.PyCObject_AsVoidPtr.argtypes = [py_object]

            WId = pythonapi.PyCObject_AsVoidPtr(WId)

        # Python3
        elif type(WId).__name__ == 'PyCapsule':
            from ctypes import pythonapi, c_void_p, py_object, c_char_p

            pythonapi.PyCapsule_GetName.restype = c_char_p
            pythonapi.PyCapsule_GetName.argtypes = [py_object]

            name = pythonapi.PyCapsule_GetName(WId)

            pythonapi.PyCapsule_GetPointer.restype = c_void_p
            pythonapi.PyCapsule_GetPointer.argtypes = [py_object, c_char_p]

            WId = pythonapi.PyCapsule_GetPointer(WId, name)

        self._RenderWindow.SetWindowInfo(str(int(WId)))

        if stereo:  # stereo mode
            self._RenderWindow.StereoCapableWindowOn()
            self._RenderWindow.SetStereoTypeToCrystalEyes()

        try:
            self._Iren = kw['iren']
        except KeyError:
            self._Iren = vtkGenericRenderWindowInteractor()
            self._Iren.SetRenderWindow(self._RenderWindow)

        # do all the necessary qt setup
        self.setAttribute(WidgetAttribute.WA_OpaquePaintEvent)
        self.setAttribute(WidgetAttribute.WA_PaintOnScreen)
        self.setMouseTracking(True)  # get all mouse events
        self.setFocusPolicy(FocusPolicy.WheelFocus)
        self.setSizePolicy(
            QSizePolicy(SizePolicy.Expanding, SizePolicy.Expanding))

        self._Timer = QTimer(self)
        self._Timer.timeout.connect(self.TimerEvent)

        self._Iren.AddObserver('CreateTimerEvent', self.CreateTimer)
        self._Iren.AddObserver('DestroyTimerEvent', self.DestroyTimer)
        self._Iren.GetRenderWindow().AddObserver('CursorChangedEvent',
                                                 self.CursorChangedEvent)

        # If we've a parent, it does not close the child when closed.
        # Connect the parent's destroyed signal to this widget's close
        # slot for proper cleanup of VTK objects.
        if self.parent():
            self.parent().destroyed.connect(self.close,
                                            ConnectionType.DirectConnection)
コード例 #17
0
 def __init__(self, parent):
     QGLWidget.__init__(self, parent)
     self.setMinimumSize(WIDTH, HEIGHT)
コード例 #18
0
ファイル: main.py プロジェクト: zhenchan98/pyqt-opengl
 def __init__(self, parent):
     QGLWidget.__init__(self, parent)
コード例 #19
0
    def __init__(self, *args, **kwdargs):
        QOpenGLWidget.__init__(self, *args, **kwdargs)

        self.viewer = None
コード例 #20
0
    def __init__(self, parent=None):
        AbstractCanvasJackClass.__init__(self, "Catia", ui_catia.Ui_CatiaMainW,
                                         parent)

        self.fGroupList = []
        self.fGroupSplitList = []
        self.fPortList = []
        self.fConnectionList = []

        self.fLastGroupId = 1
        self.fLastPortId = 1
        self.fLastConnectionId = 1

        self.loadSettings(True)

        # -------------------------------------------------------------
        # Set-up GUI

        self.ui.act_canvas_arrange.setIcon(getIcon("view-sort-ascending"))
        self.ui.act_canvas_refresh.setIcon(getIcon("view-refresh"))
        self.ui.act_canvas_zoom_fit.setIcon(getIcon("zoom-fit-best"))
        self.ui.act_canvas_zoom_in.setIcon(getIcon("zoom-in"))
        self.ui.act_canvas_zoom_out.setIcon(getIcon("zoom-out"))
        self.ui.act_canvas_zoom_100.setIcon(getIcon("zoom-original"))
        self.ui.b_canvas_zoom_fit.setIcon(getIcon("zoom-fit-best"))
        self.ui.b_canvas_zoom_in.setIcon(getIcon("zoom-in"))
        self.ui.b_canvas_zoom_out.setIcon(getIcon("zoom-out"))
        self.ui.b_canvas_zoom_100.setIcon(getIcon("zoom-original"))

        self.ui.act_jack_clear_xruns.setIcon(getIcon("edit-clear"))

        self.ui.act_transport_play.setIcon(getIcon("media-playback-start"))
        self.ui.act_transport_stop.setIcon(getIcon("media-playback-stop"))
        self.ui.act_transport_backwards.setIcon(getIcon("media-seek-backward"))
        self.ui.act_transport_forwards.setIcon(getIcon("media-seek-forward"))
        self.ui.b_transport_play.setIcon(getIcon("media-playback-start"))
        self.ui.b_transport_stop.setIcon(getIcon("media-playback-stop"))
        self.ui.b_transport_backwards.setIcon(getIcon("media-seek-backward"))
        self.ui.b_transport_forwards.setIcon(getIcon("media-seek-forward"))

        self.ui.act_quit.setIcon(getIcon("application-exit"))
        self.ui.act_configure.setIcon(getIcon("configure"))

        self.ui.cb_buffer_size.clear()
        self.ui.cb_sample_rate.clear()

        for bufferSize in BUFFER_SIZE_LIST:
            self.ui.cb_buffer_size.addItem(str(bufferSize))

        # -------------------------------------------------------------
        # Set-up Canvas

        self.scene = patchcanvas.PatchScene(self, self.ui.graphicsView)
        self.ui.graphicsView.setScene(self.scene)
        self.ui.graphicsView.setRenderHint(
            QPainter.Antialiasing,
            bool(self.fSavedSettings["Canvas/Antialiasing"] ==
                 patchcanvas.ANTIALIASING_FULL))
        if self.fSavedSettings["Canvas/UseOpenGL"] and hasGL:
            self.ui.graphicsView.setViewport(QGLWidget(self.ui.graphicsView))
            self.ui.graphicsView.setRenderHint(
                QPainter.HighQualityAntialiasing,
                self.fSavedSettings["Canvas/HighQualityAntialiasing"])

        pOptions = patchcanvas.options_t()
        pOptions.theme_name = self.fSavedSettings["Canvas/Theme"]
        pOptions.auto_hide_groups = self.fSavedSettings[
            "Canvas/AutoHideGroups"]
        pOptions.use_bezier_lines = self.fSavedSettings[
            "Canvas/UseBezierLines"]
        pOptions.antialiasing = self.fSavedSettings["Canvas/Antialiasing"]
        pOptions.eyecandy = self.fSavedSettings["Canvas/EyeCandy"]
        pOptions.auto_select_items = False  # TODO
        pOptions.inline_displays = False

        pFeatures = patchcanvas.features_t()
        pFeatures.group_info = False
        pFeatures.group_rename = False
        pFeatures.port_info = True
        pFeatures.port_rename = bool(
            self.fSavedSettings["Main/JackPortAlias"] > 0)
        pFeatures.handle_group_pos = True

        patchcanvas.setOptions(pOptions)
        patchcanvas.setFeatures(pFeatures)
        patchcanvas.init("Catia", self.scene, self.canvasCallback, DEBUG)

        # -------------------------------------------------------------
        # Try to connect to jack

        self.jackStarted()

        # -------------------------------------------------------------
        # Set-up Timers

        self.fTimer120 = self.startTimer(
            self.fSavedSettings["Main/RefreshInterval"])
        self.fTimer600 = self.startTimer(
            self.fSavedSettings["Main/RefreshInterval"] * 5)

        # -------------------------------------------------------------
        # Set-up Connections

        self.ui.act_canvas_arrange.setEnabled(False)  # TODO, later
        self.ui.act_canvas_arrange.triggered.connect(self.slot_canvasArrange)
        self.ui.act_canvas_refresh.triggered.connect(self.slot_canvasRefresh)
        self.ui.act_canvas_zoom_fit.triggered.connect(self.slot_canvasZoomFit)
        self.ui.act_canvas_zoom_in.triggered.connect(self.slot_canvasZoomIn)
        self.ui.act_canvas_zoom_out.triggered.connect(self.slot_canvasZoomOut)
        self.ui.act_canvas_zoom_100.triggered.connect(
            self.slot_canvasZoomReset)
        self.ui.act_canvas_save_image.triggered.connect(
            self.slot_canvasSaveImage)
        self.ui.b_canvas_zoom_fit.clicked.connect(self.slot_canvasZoomFit)
        self.ui.b_canvas_zoom_in.clicked.connect(self.slot_canvasZoomIn)
        self.ui.b_canvas_zoom_out.clicked.connect(self.slot_canvasZoomOut)
        self.ui.b_canvas_zoom_100.clicked.connect(self.slot_canvasZoomReset)

        self.ui.act_jack_clear_xruns.triggered.connect(
            self.slot_JackClearXruns)
        self.ui.cb_buffer_size.currentIndexChanged[str].connect(
            self.slot_jackBufferSize_ComboBox)
        self.ui.b_xruns.clicked.connect(self.slot_JackClearXruns)

        self.ui.act_transport_play.triggered.connect(
            self.slot_transportPlayPause)
        self.ui.act_transport_stop.triggered.connect(self.slot_transportStop)
        self.ui.act_transport_backwards.triggered.connect(
            self.slot_transportBackwards)
        self.ui.act_transport_forwards.triggered.connect(
            self.slot_transportForwards)
        self.ui.b_transport_play.clicked.connect(self.slot_transportPlayPause)
        self.ui.b_transport_stop.clicked.connect(self.slot_transportStop)
        self.ui.b_transport_backwards.clicked.connect(
            self.slot_transportBackwards)
        self.ui.b_transport_forwards.clicked.connect(
            self.slot_transportForwards)
        self.ui.label_time.customContextMenuRequested.connect(
            self.slot_transportViewMenu)

        self.ui.act_configure.triggered.connect(self.slot_configureCatia)

        self.ui.act_help_about.triggered.connect(self.slot_aboutCatia)
        self.ui.act_help_about_qt.triggered.connect(app.aboutQt)

        self.XRunCallback.connect(self.slot_XRunCallback)
        self.BufferSizeCallback.connect(self.slot_BufferSizeCallback)
        self.SampleRateCallback.connect(self.slot_SampleRateCallback)
        self.ClientRenameCallback.connect(self.slot_ClientRenameCallback)
        self.PortRegistrationCallback.connect(
            self.slot_PortRegistrationCallback)
        self.PortConnectCallback.connect(self.slot_PortConnectCallback)
        self.PortRenameCallback.connect(self.slot_PortRenameCallback)
        self.PropertyChangeCallback.connect(self.slot_PropertyChangeCallback)
        self.ShutdownCallback.connect(self.slot_ShutdownCallback)
コード例 #21
0
    def __init_ui(self):
        # set up the scene
        self.scene = QGraphicsScene()
        self.scene.setSceneRect(0, 0, 650, 560)
        self.scene.setBackgroundBrush(Qt.darkGray)

        # set up the view
        self.setScene(self.scene)
        # these 10 additional pixels are for the margin
        self.setFixedSize(660, 570)
        # optimization
        self.setOptimizationFlag(QGraphicsView.DontAdjustForAntialiasing)
        self.setOptimizationFlag(QGraphicsView.DontSavePainterState)
        self.setCacheMode(QGraphicsView.CacheBackground)
        self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.setInteractive(False)
        self.setViewport(QGLWidget(QGLFormat()))
        self.setViewportUpdateMode(QGraphicsView.FullViewportUpdate)

        for imgUrl in self.config.hiscoreAnimation:
            pixmap = QPixmap(imgUrl)
            pixmapItem = QGraphicsPixmapItem(pixmap)
            pixmapItem.setZValue(-1)
            pixmapItem.hide()
            self.scene.addItem(pixmapItem)
            self.hiscoreAnimationItems.append(pixmapItem)
        for imgUrl in self.config.winnerScreenTieAnimation:
            pixmap = QPixmap(imgUrl)
            pixmapItem = QGraphicsPixmapItem(pixmap)
            pixmapItem.setZValue(-1)
            pixmapItem.hide()
            self.scene.addItem(pixmapItem)
            self.winnerScreenTieAnimationItems.append(pixmapItem)
        for imgUrl in self.config.winnerScreenPlayer1Animation:
            pixmap = QPixmap(imgUrl)
            pixmapItem = QGraphicsPixmapItem(pixmap)
            pixmapItem.setZValue(-1)
            pixmapItem.hide()
            self.scene.addItem(pixmapItem)
            self.player1AnimationItems.append(pixmapItem)
        for imgUrl in self.config.winnerScreenPlayer2Animation:
            pixmap = QPixmap(imgUrl)
            pixmapItem = QGraphicsPixmapItem(pixmap)
            pixmapItem.setZValue(-1)
            pixmapItem.hide()
            self.scene.addItem(pixmapItem)
            self.player2AnimationItems.append(pixmapItem)

        # points animation used when single player is played
        self.hudHiscorePlayerTotalPointsWhite = HudHiscoreTotalPlayerPointsContainer(
            self.config, "white", self.firstPlayerTotalPoints)
        self.hudHiscorePlayerTotalPointsWhite.setPos(45, 235)
        self.hudHiscorePlayerTotalPointsWhite.hide()
        self.scene.addItem(self.hudHiscorePlayerTotalPointsWhite)
        self.hudHiscorePlayerTotalPointsList.append(
            self.hudHiscorePlayerTotalPointsWhite)

        self.hudHiscorePlayerTotalPointsGray = HudHiscoreTotalPlayerPointsContainer(
            self.config, "gray", self.firstPlayerTotalPoints)
        self.hudHiscorePlayerTotalPointsGray.setPos(45, 235)
        self.hudHiscorePlayerTotalPointsGray.hide()
        self.scene.addItem(self.hudHiscorePlayerTotalPointsGray)
        self.hudHiscorePlayerTotalPointsList.append(
            self.hudHiscorePlayerTotalPointsGray)

        self.hudHiscorePlayerTotalPointsDarkGray = HudHiscoreTotalPlayerPointsContainer(
            self.config, "darkGray", self.firstPlayerTotalPoints)
        self.hudHiscorePlayerTotalPointsDarkGray.setPos(45, 235)
        self.hudHiscorePlayerTotalPointsDarkGray.hide()
        self.scene.addItem(self.hudHiscorePlayerTotalPointsDarkGray)
        self.hudHiscorePlayerTotalPointsList.append(
            self.hudHiscorePlayerTotalPointsDarkGray)

        self.hudHiscorePlayerTotalPointsBlue = HudHiscoreTotalPlayerPointsContainer(
            self.config, "blue", self.firstPlayerTotalPoints)
        self.hudHiscorePlayerTotalPointsBlue.setPos(45, 235)
        self.hudHiscorePlayerTotalPointsBlue.hide()
        self.scene.addItem(self.hudHiscorePlayerTotalPointsBlue)
        self.hudHiscorePlayerTotalPointsList.append(
            self.hudHiscorePlayerTotalPointsBlue)

        self.hudHiscorePlayerTotalPointsDarkBlue = HudHiscoreTotalPlayerPointsContainer(
            self.config, "darkBlue", self.firstPlayerTotalPoints)
        self.hudHiscorePlayerTotalPointsDarkBlue.setPos(45, 235)
        self.hudHiscorePlayerTotalPointsDarkBlue.hide()
        self.scene.addItem(self.hudHiscorePlayerTotalPointsDarkBlue)
        self.hudHiscorePlayerTotalPointsList.append(
            self.hudHiscorePlayerTotalPointsDarkBlue)

        # used when there are two players playing
        self.hudFirstPlayerTotalPoints = HudEndOfStageTotalPlayerPointsContainer(
            self.config, self.firstPlayerTotalPoints)
        self.hudFirstPlayerTotalPoints.setPos(85, 205)
        self.hudFirstPlayerTotalPoints.hide()
        self.scene.addItem(self.hudFirstPlayerTotalPoints)

        self.hudSecondPlayerTotalPoints = HudEndOfStageTotalPlayerPointsContainer(
            self.config, self.secondPlayerTotalPoints)
        self.hudSecondPlayerTotalPoints.setPos(450, 205)
        self.hudSecondPlayerTotalPoints.hide()
        self.scene.addItem(self.hudSecondPlayerTotalPoints)
コード例 #22
0
 def __init__(self, parent=None):
     QGLWidget.__init__(self, parent)
     self.yRotDeg = 0.0
     self.xRotDeg = 0.0
     self.offsets = [0., -1., 0]
コード例 #23
0
    def __init__(self,
                 parent,
                 host,
                 doSetup=True,
                 onlyPatchbay=True,
                 is3D=False):
        QFrame.__init__(self, parent)
        self.host = host

        if False:
            # kdevelop likes this :)
            host = CarlaHostMeta()
            self.host = host

        # -------------------------------------------------------------

        self.fLayout = QGridLayout(self)
        self.fLayout.setContentsMargins(0, 0, 0, 0)
        self.fLayout.setSpacing(1)
        self.setLayout(self.fLayout)

        self.fView = QGraphicsView(self)
        self.fKeys = PixmapKeyboardHArea(self)

        self.fPeaksIn = DigitalPeakMeter(self)
        self.fPeaksOut = DigitalPeakMeter(self)
        self.fPeaksCleared = True

        self.fPeaksIn.setColor(DigitalPeakMeter.BLUE)
        self.fPeaksIn.setChannels(2)
        self.fPeaksIn.setOrientation(DigitalPeakMeter.VERTICAL)
        self.fPeaksIn.setFixedWidth(25)

        self.fPeaksOut.setColor(DigitalPeakMeter.GREEN)
        self.fPeaksOut.setChannels(2)
        self.fPeaksOut.setOrientation(DigitalPeakMeter.VERTICAL)
        self.fPeaksOut.setFixedWidth(25)

        self.fLayout.addWidget(self.fPeaksIn, 0, 0)
        self.fLayout.addWidget(self.fView, 0,
                               1)  # self.fViewWidget if is3D else
        self.fLayout.addWidget(self.fPeaksOut, 0, 2)
        self.fLayout.addWidget(self.fKeys, 1, 0, 1, 0)

        # -------------------------------------------------------------
        # Internal stuff

        self.fParent = parent
        self.fPluginCount = 0
        self.fPluginList = []

        self.fExternalPatchbay = False
        self.fIsOnlyPatchbay = onlyPatchbay
        self.fSelectedPlugins = []

        self.fCanvasWidth = 0
        self.fCanvasHeight = 0

        # -------------------------------------------------------------
        # Set-up Canvas Preview

        self.fMiniCanvasPreview = self.fParent.ui.miniCanvasPreview
        self.fMiniCanvasPreview.setRealParent(self)
        self.fMovingViaMiniCanvas = False

        # -------------------------------------------------------------
        # Set-up Canvas

        self.scene = patchcanvas.PatchScene(self, self.fView)
        self.fView.setScene(self.scene)
        self.fView.setRenderHint(
            QPainter.Antialiasing,
            bool(parent.fSavedSettings[CARLA_KEY_CANVAS_ANTIALIASING] ==
                 patchcanvas.ANTIALIASING_FULL))

        if parent.fSavedSettings[
                CARLA_KEY_CANVAS_USE_OPENGL] and hasGL:  # and not is3D:
            self.fViewWidget = QGLWidget(self)
            self.fView.setViewport(self.fViewWidget)
            self.fView.setRenderHint(
                QPainter.HighQualityAntialiasing,
                parent.fSavedSettings[CARLA_KEY_CANVAS_HQ_ANTIALIASING])

        self.setupCanvas()

        QTimer.singleShot(100, self.slot_restoreScrollbarValues)

        # -------------------------------------------------------------
        # Connect actions to functions

        parent.ui.act_settings_show_meters.toggled.connect(
            self.slot_showCanvasMeters)
        parent.ui.act_settings_show_keyboard.toggled.connect(
            self.slot_showCanvasKeyboard)

        self.fView.horizontalScrollBar().valueChanged.connect(
            self.slot_horizontalScrollBarChanged)
        self.fView.verticalScrollBar().valueChanged.connect(
            self.slot_verticalScrollBarChanged)

        self.scene.scaleChanged.connect(self.slot_canvasScaleChanged)
        self.scene.sceneGroupMoved.connect(self.slot_canvasItemMoved)
        self.scene.pluginSelected.connect(self.slot_canvasPluginSelected)

        self.fMiniCanvasPreview.miniCanvasMoved.connect(
            self.slot_miniCanvasMoved)

        self.fKeys.keyboard.noteOn.connect(self.slot_noteOn)
        self.fKeys.keyboard.noteOff.connect(self.slot_noteOff)

        # -------------------------------------------------------------
        # Load Settings

        settings = QSettings()

        showMeters = settings.value("ShowMeters", False, type=bool)
        self.fParent.ui.act_settings_show_meters.setChecked(showMeters)
        self.fPeaksIn.setVisible(showMeters)
        self.fPeaksOut.setVisible(showMeters)

        showKeyboard = settings.value("ShowKeyboard",
                                      not (MACOS or WINDOWS),
                                      type=bool)
        self.fParent.ui.act_settings_show_keyboard.setChecked(showKeyboard)
        self.fKeys.setVisible(showKeyboard)

        # -------------------------------------------------------------
        # Connect actions to functions (part 2)

        host.PluginAddedCallback.connect(self.slot_handlePluginAddedCallback)
        host.PluginRemovedCallback.connect(
            self.slot_handlePluginRemovedCallback)
        host.NoteOnCallback.connect(self.slot_handleNoteOnCallback)
        host.NoteOffCallback.connect(self.slot_handleNoteOffCallback)
        host.PatchbayClientAddedCallback.connect(
            self.slot_handlePatchbayClientAddedCallback)
        host.PatchbayClientRemovedCallback.connect(
            self.slot_handlePatchbayClientRemovedCallback)
        host.PatchbayClientRenamedCallback.connect(
            self.slot_handlePatchbayClientRenamedCallback)
        host.PatchbayClientDataChangedCallback.connect(
            self.slot_handlePatchbayClientDataChangedCallback)
        host.PatchbayPortAddedCallback.connect(
            self.slot_handlePatchbayPortAddedCallback)
        host.PatchbayPortRemovedCallback.connect(
            self.slot_handlePatchbayPortRemovedCallback)
        host.PatchbayPortRenamedCallback.connect(
            self.slot_handlePatchbayPortRenamedCallback)
        host.PatchbayConnectionAddedCallback.connect(
            self.slot_handlePatchbayConnectionAddedCallback)
        host.PatchbayConnectionRemovedCallback.connect(
            self.slot_handlePatchbayConnectionRemovedCallback)

        if not doSetup: return

        parent.ui.act_plugins_enable.triggered.connect(self.slot_pluginsEnable)
        parent.ui.act_plugins_disable.triggered.connect(
            self.slot_pluginsDisable)
        parent.ui.act_plugins_volume100.triggered.connect(
            self.slot_pluginsVolume100)
        parent.ui.act_plugins_mute.triggered.connect(self.slot_pluginsMute)
        parent.ui.act_plugins_wet100.triggered.connect(self.slot_pluginsWet100)
        parent.ui.act_plugins_bypass.triggered.connect(self.slot_pluginsBypass)
        parent.ui.act_plugins_center.triggered.connect(self.slot_pluginsCenter)
        parent.ui.act_plugins_panic.triggered.connect(self.slot_pluginsDisable)

        parent.ui.act_canvas_show_internal.triggered.connect(
            self.slot_canvasShowInternal)
        parent.ui.act_canvas_show_external.triggered.connect(
            self.slot_canvasShowExternal)
        parent.ui.act_canvas_arrange.setEnabled(False)  # TODO, later
        parent.ui.act_canvas_arrange.triggered.connect(self.slot_canvasArrange)
        parent.ui.act_canvas_refresh.triggered.connect(self.slot_canvasRefresh)
        parent.ui.act_canvas_zoom_fit.triggered.connect(
            self.slot_canvasZoomFit)
        parent.ui.act_canvas_zoom_in.triggered.connect(self.slot_canvasZoomIn)
        parent.ui.act_canvas_zoom_out.triggered.connect(
            self.slot_canvasZoomOut)
        parent.ui.act_canvas_zoom_100.triggered.connect(
            self.slot_canvasZoomReset)
        parent.ui.act_canvas_print.triggered.connect(self.slot_canvasPrint)
        parent.ui.act_canvas_save_image.triggered.connect(
            self.slot_canvasSaveImage)

        parent.ui.act_settings_configure.triggered.connect(
            self.slot_configureCarla)
コード例 #24
0
ファイル: main.py プロジェクト: MRFaria/shooter
    health = gui.Health(scene)

    player = game.Player(scene, score, health)
    player.setPixmap(QPixmap("./res/images/DurrrSpaceShip.png"))
    # player.setRect(0, 0, 100, 100)
    # Item needs to focused to see keyevents
    player.setFlag(QGraphicsItem.ItemIsFocusable, True)
    player.setFocus()

    # Show the scene
    # First the view widget gets the event, which sends it to the scene
    # The scene sends the event to the item in focus
    view = QGraphicsView(scene)
    view.setBackgroundBrush(QBrush(QImage("./res/images/background.png")))
    view.setAttribute(Qt.WA_DeleteOnClose)
    view.setViewport(QGLWidget())
    view.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
    view.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
    view.setFixedSize(800, 600)
    scene.setSceneRect(0, 0, 800, 600)

    # set the end condition
    health.dead.connect(functools.partial(gameOver, app, view, scene))
    # set the player position
    player.setPos(view.width() / 2, view.height() - player.pixmap().height())

    # play the background music
    url = QUrl.fromLocalFile("./res/sounds/background.wav")
    media = M.QMediaContent(url)
    playlist = M.QMediaPlaylist()
    playlist.addMedia(media)
コード例 #25
0
ファイル: imageView2D.py プロジェクト: wolny/volumina
    def __init__(self, parent, cropModel, imagescene2d):
        """
        Constructs a view upon a ImageScene2D

        imagescene2d -- a ImgeScene2D instance
        """

        QGraphicsView.__init__(self, parent)

        # We can't use OpenGL because the HUD doesn't render properly on top.
        # Maybe this will be fixed in Qt5?
        if False:
            self.setViewport(QGLWidget())

        self.setScene(imagescene2d)
        self.mousePos = QPointF(0, 0)
        # FIXME: These int members shadow QWidget.x() and QWidget.y(), which can lead to confusion when debugging...
        self.x, self.y = (0, 0)

        self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)

        self._isRubberBandZoom = False
        self._cursorBackup = None

        # these attributes are exposed as public properties above
        self._sliceShape = None  # 2D shape of this view's shown image
        self._slices = None  # number of slices that are stacked
        self._hud = None

        self._crossHairCursor = None
        self._sliceIntersectionMarker = None

        self._ticker = QTimer(self)
        self._ticker.timeout.connect(self._tickerEvent)

        #
        # Setup the Viewport for fast painting
        #
        # With these flags turned on we could handle the drawing of the
        # white background ourselves thus removing the flicker
        # when scrolling fast through the slices
        # self.viewport().setAttribute(Qt.WA_OpaquePaintEvent)
        # self.viewport().setAttribute(Qt.WA_NoSystemBackground)
        # self.viewport().setAttribute(Qt.WA_PaintOnScreen)
        # self.viewport().setAutoFillBackground(False)

        self.setViewportUpdateMode(QGraphicsView.MinimalViewportUpdate)
        # as rescaling images is slow if done in software,
        # we use Qt's built-in background caching mode so that the cached
        # image need only be blitted on the screen when we only move
        # the cursor
        self.setCacheMode(QGraphicsView.CacheBackground)
        self.setRenderHint(QPainter.Antialiasing, False)

        self._crossHairCursor = CrossHairCursor()
        self.scene().addItem(self._crossHairCursor)
        self._crossHairCursor.setZValue(99)

        self.posModel = self.scene()._posModel
        self.axis = self.scene()._along[1] - 1  # axis is 0,1,2 for X,Y,Z
        self._sliceIntersectionMarker = SliceIntersectionMarker(
            self.axis, self.posModel)
        self.scene().addItem(self._sliceIntersectionMarker)
        self._sliceIntersectionMarker.setZValue(100)

        self._sliceIntersectionMarker.setVisible(True)

        self._croppingMarkers = CroppingMarkers(self.axis, cropModel)
        self.scene().addItem(self._croppingMarkers)

        # FIXME: this should be private, but is currently used from
        #       within the image scene renderer
        self.tempImageItems = []

        self._zoomFactor = 1.0

        # for panning
        self._lastPanPoint = QPoint()
        self._dragMode = False
        self._deltaPan = QPointF(0, 0)

        # FIXME: Is there are more elegant way to handle this?

        self.setMouseTracking(True)

        # invisible cursor to enable custom cursor
        self._hiddenCursor = QCursor(Qt.BlankCursor)
コード例 #26
0
    def __init__(self, *args, **kwdargs):
        QOpenGLWidget.__init__(self, *args, **kwdargs)

        self.viewer = None
コード例 #27
0
    def __init__(self, size, parent=None):
        super(PadNavigator, self).__init__(parent)

        self.form = Ui_Form()

        splash = SplashItem()
        splash.setZValue(1)

        pad = FlippablePad(size)
        flipRotation = QGraphicsRotation(pad)
        xRotation = QGraphicsRotation(pad)
        yRotation = QGraphicsRotation(pad)
        flipRotation.setAxis(Qt.YAxis)
        xRotation.setAxis(Qt.YAxis)
        yRotation.setAxis(Qt.XAxis)
        pad.setTransformations([flipRotation, xRotation, yRotation])

        backItem = QGraphicsProxyWidget(pad)
        widget = QWidget()
        self.form.setupUi(widget)
        self.form.hostName.setFocus()
        backItem.setWidget(widget)
        backItem.setVisible(False)
        backItem.setFocus()
        backItem.setCacheMode(QGraphicsItem.ItemCoordinateCache)
        r = backItem.rect()
        backItem.setTransform(QTransform().rotate(180, Qt.YAxis).translate(
            -r.width() / 2, -r.height() / 2))

        selectionItem = RoundRectItem(QRectF(-60, -60, 120, 120),
                                      QColor(Qt.gray), pad)
        selectionItem.setZValue(0.5)

        smoothSplashMove = QPropertyAnimation(splash)
        smoothSplashOpacity = QPropertyAnimation(splash)
        smoothSplashMove.setEasingCurve(QEasingCurve.InQuad)
        smoothSplashMove.setDuration(250)
        smoothSplashOpacity.setDuration(250)

        smoothXSelection = QPropertyAnimation(selectionItem)
        smoothYSelection = QPropertyAnimation(selectionItem)
        smoothXRotation = QPropertyAnimation(xRotation)
        smoothYRotation = QPropertyAnimation(yRotation)
        smoothXSelection.setDuration(125)
        smoothYSelection.setDuration(125)
        smoothXRotation.setDuration(125)
        smoothYRotation.setDuration(125)
        smoothXSelection.setEasingCurve(QEasingCurve.InOutQuad)
        smoothYSelection.setEasingCurve(QEasingCurve.InOutQuad)
        smoothXRotation.setEasingCurve(QEasingCurve.InOutQuad)
        smoothYRotation.setEasingCurve(QEasingCurve.InOutQuad)

        smoothFlipRotation = QPropertyAnimation(flipRotation)
        smoothFlipScale = QPropertyAnimation(pad)
        smoothFlipXRotation = QPropertyAnimation(xRotation)
        smoothFlipYRotation = QPropertyAnimation(yRotation)
        flipAnimation = QParallelAnimationGroup(self)
        smoothFlipScale.setDuration(500)
        smoothFlipRotation.setDuration(500)
        smoothFlipXRotation.setDuration(500)
        smoothFlipYRotation.setDuration(500)
        smoothFlipScale.setEasingCurve(QEasingCurve.InOutQuad)
        smoothFlipRotation.setEasingCurve(QEasingCurve.InOutQuad)
        smoothFlipXRotation.setEasingCurve(QEasingCurve.InOutQuad)
        smoothFlipYRotation.setEasingCurve(QEasingCurve.InOutQuad)
        smoothFlipScale.setKeyValueAt(0, 1.0)
        smoothFlipScale.setKeyValueAt(0.5, 0.7)
        smoothFlipScale.setKeyValueAt(1, 1.0)
        flipAnimation.addAnimation(smoothFlipRotation)
        flipAnimation.addAnimation(smoothFlipScale)
        flipAnimation.addAnimation(smoothFlipXRotation)
        flipAnimation.addAnimation(smoothFlipYRotation)

        setVariablesSequence = QSequentialAnimationGroup()
        setFillAnimation = QPropertyAnimation(pad)
        setBackItemVisibleAnimation = QPropertyAnimation(backItem)
        setSelectionItemVisibleAnimation = QPropertyAnimation(selectionItem)
        setFillAnimation.setDuration(0)
        setBackItemVisibleAnimation.setDuration(0)
        setSelectionItemVisibleAnimation.setDuration(0)
        setVariablesSequence.addPause(250)
        setVariablesSequence.addAnimation(setBackItemVisibleAnimation)
        setVariablesSequence.addAnimation(setSelectionItemVisibleAnimation)
        setVariablesSequence.addAnimation(setFillAnimation)
        flipAnimation.addAnimation(setVariablesSequence)

        stateMachine = QStateMachine(self)
        splashState = QState(stateMachine)
        frontState = QState(stateMachine)
        historyState = QHistoryState(frontState)
        backState = QState(stateMachine)

        frontState.assignProperty(pad, "fill", False)
        frontState.assignProperty(splash, "opacity", 0.0)
        frontState.assignProperty(backItem, "visible", False)
        frontState.assignProperty(flipRotation, "angle", 0.0)
        frontState.assignProperty(selectionItem, "visible", True)

        backState.assignProperty(pad, "fill", True)
        backState.assignProperty(backItem, "visible", True)
        backState.assignProperty(xRotation, "angle", 0.0)
        backState.assignProperty(yRotation, "angle", 0.0)
        backState.assignProperty(flipRotation, "angle", 180.0)
        backState.assignProperty(selectionItem, "visible", False)

        stateMachine.addDefaultAnimation(smoothXRotation)
        stateMachine.addDefaultAnimation(smoothYRotation)
        stateMachine.addDefaultAnimation(smoothXSelection)
        stateMachine.addDefaultAnimation(smoothYSelection)
        stateMachine.setInitialState(splashState)

        anyKeyTransition = QEventTransition(self, QEvent.KeyPress, splashState)
        anyKeyTransition.setTargetState(frontState)
        anyKeyTransition.addAnimation(smoothSplashMove)
        anyKeyTransition.addAnimation(smoothSplashOpacity)

        enterTransition = QKeyEventTransition(self, QEvent.KeyPress,
                                              Qt.Key_Enter, backState)
        returnTransition = QKeyEventTransition(self, QEvent.KeyPress,
                                               Qt.Key_Return, backState)
        backEnterTransition = QKeyEventTransition(self, QEvent.KeyPress,
                                                  Qt.Key_Enter, frontState)
        backReturnTransition = QKeyEventTransition(self, QEvent.KeyPress,
                                                   Qt.Key_Return, frontState)
        enterTransition.setTargetState(historyState)
        returnTransition.setTargetState(historyState)
        backEnterTransition.setTargetState(backState)
        backReturnTransition.setTargetState(backState)
        enterTransition.addAnimation(flipAnimation)
        returnTransition.addAnimation(flipAnimation)
        backEnterTransition.addAnimation(flipAnimation)
        backReturnTransition.addAnimation(flipAnimation)

        columns = size.width()
        rows = size.height()
        stateGrid = []
        for y in range(rows):
            stateGrid.append([QState(frontState) for _ in range(columns)])

        frontState.setInitialState(stateGrid[0][0])
        selectionItem.setPos(pad.iconAt(0, 0).pos())

        for y in range(rows):
            for x in range(columns):
                state = stateGrid[y][x]

                rightTransition = QKeyEventTransition(self, QEvent.KeyPress,
                                                      Qt.Key_Right, state)
                leftTransition = QKeyEventTransition(self, QEvent.KeyPress,
                                                     Qt.Key_Left, state)
                downTransition = QKeyEventTransition(self, QEvent.KeyPress,
                                                     Qt.Key_Down, state)
                upTransition = QKeyEventTransition(self, QEvent.KeyPress,
                                                   Qt.Key_Up, state)

                rightTransition.setTargetState(stateGrid[y][(x + 1) % columns])
                leftTransition.setTargetState(
                    stateGrid[y][((x - 1) + columns) % columns])
                downTransition.setTargetState(stateGrid[(y + 1) % rows][x])
                upTransition.setTargetState(stateGrid[((y - 1) + rows) %
                                                      rows][x])

                icon = pad.iconAt(x, y)
                state.assignProperty(xRotation, "angle", -icon.x() / 6.0)
                state.assignProperty(yRotation, "angle", icon.y() / 6.0)
                state.assignProperty(selectionItem, "x", icon.x())
                state.assignProperty(selectionItem, "y", icon.y())
                frontState.assignProperty(icon, "visible", True)
                backState.assignProperty(icon, "visible", False)

                setIconVisibleAnimation = QPropertyAnimation(icon)
                setIconVisibleAnimation.setDuration(0)
                setVariablesSequence.addAnimation(setIconVisibleAnimation)

        scene = QGraphicsScene(self)
        scene.setBackgroundBrush(
            QBrush(QPixmap(":/images/blue_angle_swirl.jpg")))
        scene.setItemIndexMethod(QGraphicsScene.NoIndex)
        scene.addItem(pad)
        scene.setSceneRect(scene.itemsBoundingRect())
        self.setScene(scene)

        sbr = splash.boundingRect()
        splash.setPos(-sbr.width() / 2, scene.sceneRect().top() - 2)
        frontState.assignProperty(splash, "y", splash.y() - 100.0)
        scene.addItem(splash)

        self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.setMinimumSize(50, 50)
        self.setViewportUpdateMode(QGraphicsView.FullViewportUpdate)
        self.setCacheMode(QGraphicsView.CacheBackground)
        self.setRenderHints(QPainter.Antialiasing
                            | QPainter.SmoothPixmapTransform
                            | QPainter.TextAntialiasing)

        if QGLFormat.hasOpenGL():
            self.setViewport(QGLWidget(QGLFormat(QGL.SampleBuffers)))

        stateMachine.start()
コード例 #28
0
 def __init_ui__(self):
     # set up the scene
     self.scene = QGraphicsScene()
     # these 10 subtracted pixels are for the margin
     self.scene.setSceneRect(0, 0, self.config.mainWindowSize["width"] - 10,
                             self.config.mainWindowSize["height"] - 10)
     self.scene.setBackgroundBrush(Qt.darkGray)
     # set up the view
     self.setScene(self.scene)
     self.setFixedSize(self.config.mainWindowSize["width"],
                       self.config.mainWindowSize["height"])
     # optimization
     self.setOptimizationFlag(QGraphicsView.DontAdjustForAntialiasing)
     self.setOptimizationFlag(QGraphicsView.DontSavePainterState)
     self.setCacheMode(QGraphicsView.CacheBackground)
     self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
     self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
     self.setInteractive(False)
     self.setViewport(QGLWidget(QGLFormat()))
     self.setViewportUpdateMode(QGraphicsView.FullViewportUpdate)
     # initialize the map
     self.generateMap()
     # HUD
     # stage hud
     self.hudCurrentStage = HudCurrentStage(self.config, self.currentStage)
     self.hudCurrentStage.setX(self.field.x() +
                               self.field.boundingRect().width() + 20)
     self.hudCurrentStage.setY(self.field.y() +
                               self.field.boundingRect().height() - 100)
     self.scene.addItem(self.hudCurrentStage)
     # player lives hud
     self.hudPlayersLives = {}
     if self.isOnline:
         pass
     else:
         for i in range(self.numOfPlayers):
             if i == 0:
                 if self.playerData.firstPlayerDetails.isAlive:
                     playerLives = HudPlayerLives(
                         i, self.config,
                         self.playerData.firstPlayerDetails.lives)
                     playerLives.setX(self.field.x() +
                                      self.field.boundingRect().width() +
                                      20)
                     playerLives.setY(self.field.y() +
                                      self.field.boundingRect().height() -
                                      220 + i * 60)
                     self.scene.addItem(playerLives)
                     self.hudPlayersLives[self.playerData.firstPlayerDetails
                                          .id] = playerLives
             elif i == 1:
                 if self.playerData.secondPlayerDetails.isAlive:
                     playerLives = HudPlayerLives(
                         i, self.config,
                         self.playerData.secondPlayerDetails.lives)
                     playerLives.setX(self.field.x() +
                                      self.field.boundingRect().width() +
                                      20)
                     playerLives.setY(self.field.y() +
                                      self.field.boundingRect().height() -
                                      220 + i * 60)
                     self.scene.addItem(playerLives)
                     self.hudPlayersLives[
                         self.playerData.secondPlayerDetails.
                         id] = playerLives
     # enemies left hud
     self.enemyHud = HudEnemyContainer(self.config)
     self.enemyHud.setX(self.field.x() + self.field.boundingRect().width() +
                        20)
     self.enemyHud.setY(self.field.y() + 40)
     self.scene.addItem(self.enemyHud)
コード例 #29
0
    def __init__(self, parent=None, **kw):
        # the current button
        self._ActiveButton = Qt.NoButton

        # private attributes
        self.__saveX = 0
        self.__saveY = 0
        self.__saveModifiers = Qt.NoModifier
        self.__saveButtons = Qt.NoButton
        self.__wheelDelta = 0

        # do special handling of some keywords:
        # stereo, rw

        try:
            stereo = bool(kw['stereo'])
        except KeyError:
            stereo = False

        try:
            rw = kw['rw']
        except KeyError:
            rw = None

        # create base qt-level widget
        if QVTKRWIBase == "QWidget":
            if "wflags" in kw:
                wflags = kw['wflags']
            else:
                wflags = Qt.WindowFlags()
            QWidget.__init__(self, parent, wflags | Qt.MSWindowsOwnDC)
        elif QVTKRWIBase == "QGLWidget":
            QGLWidget.__init__(self, parent)

        if rw: # user-supplied render window
            self._RenderWindow = rw
        else:
            self._RenderWindow = vtkRenderWindow()

        WId = self.winId()

        # Python2
        if type(WId).__name__ == 'PyCObject':
            from ctypes import pythonapi, c_void_p, py_object

            pythonapi.PyCObject_AsVoidPtr.restype  = c_void_p
            pythonapi.PyCObject_AsVoidPtr.argtypes = [py_object]

            WId = pythonapi.PyCObject_AsVoidPtr(WId)

        # Python3
        elif type(WId).__name__ == 'PyCapsule':
            from ctypes import pythonapi, c_void_p, py_object, c_char_p

            pythonapi.PyCapsule_GetName.restype = c_char_p
            pythonapi.PyCapsule_GetName.argtypes = [py_object]

            name = pythonapi.PyCapsule_GetName(WId)

            pythonapi.PyCapsule_GetPointer.restype  = c_void_p
            pythonapi.PyCapsule_GetPointer.argtypes = [py_object, c_char_p]

            WId = pythonapi.PyCapsule_GetPointer(WId, name)

        self._RenderWindow.SetWindowInfo(str(int(WId)))

        if stereo: # stereo mode
            self._RenderWindow.StereoCapableWindowOn()
            self._RenderWindow.SetStereoTypeToCrystalEyes()

        try:
            self._Iren = kw['iren']
        except KeyError:
            self._Iren = vtkGenericRenderWindowInteractor()
            self._Iren.SetRenderWindow(self._RenderWindow)

        # do all the necessary qt setup
        self.setAttribute(Qt.WA_OpaquePaintEvent)
        self.setAttribute(Qt.WA_PaintOnScreen)
        self.setMouseTracking(True) # get all mouse events
        self.setFocusPolicy(Qt.WheelFocus)
        self.setSizePolicy(QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding))

        self._Timer = QTimer(self)
        self._Timer.timeout.connect(self.TimerEvent)

        self._Iren.AddObserver('CreateTimerEvent', self.CreateTimer)
        self._Iren.AddObserver('DestroyTimerEvent', self.DestroyTimer)
        self._Iren.GetRenderWindow().AddObserver('CursorChangedEvent',
                                                 self.CursorChangedEvent)

        #Create a hidden child widget and connect its destroyed signal to its
        #parent ``Finalize`` slot. The hidden children will be destroyed before
        #its parent thus allowing cleanup of VTK elements.
        self._hidden = QWidget(self)
        self._hidden.hide()
        self._hidden.destroyed.connect(self.Finalize)
コード例 #30
0
    def update(self):

        self._logger.debug('')
        self.makeCurrent()
        self.update_model_view_projection_matrix()
        QOpenGLWidget.update(self)
コード例 #31
0
    def __init__(self, parent=None, **kw):
        # the current button
        self._ActiveButton = Qt.NoButton

        # private attributes
        self.__saveX = 0
        self.__saveY = 0
        self.__saveModifiers = Qt.NoModifier
        self.__saveButtons = Qt.NoButton
        self.__wheelDelta = 0

        # do special handling of some keywords:
        # stereo, rw

        try:
            stereo = bool(kw['stereo'])
        except KeyError:
            stereo = False

        try:
            rw = kw['rw']
        except KeyError:
            rw = None

        # create base qt-level widget
        if QVTKRWIBase == "QWidget":
            if "wflags" in kw:
                wflags = kw['wflags']
            else:
                wflags = Qt.WindowFlags()
            QWidget.__init__(self, parent, wflags | Qt.MSWindowsOwnDC)
        elif QVTKRWIBase == "QGLWidget":
            QGLWidget.__init__(self, parent)

        if rw:  # user-supplied render window
            self._RenderWindow = rw
        else:
            self._RenderWindow = vtk.vtkRenderWindow()

        WId = self.winId()

        # Python2
        if type(WId).__name__ == 'PyCObject':
            from ctypes import pythonapi, c_void_p, py_object

            pythonapi.PyCObject_AsVoidPtr.restype = c_void_p
            pythonapi.PyCObject_AsVoidPtr.argtypes = [py_object]

            WId = pythonapi.PyCObject_AsVoidPtr(WId)

        # Python3
        elif type(WId).__name__ == 'PyCapsule':
            from ctypes import pythonapi, c_void_p, py_object, c_char_p

            pythonapi.PyCapsule_GetName.restype = c_char_p
            pythonapi.PyCapsule_GetName.argtypes = [py_object]

            name = pythonapi.PyCapsule_GetName(WId)

            pythonapi.PyCapsule_GetPointer.restype = c_void_p
            pythonapi.PyCapsule_GetPointer.argtypes = [py_object, c_char_p]

            WId = pythonapi.PyCapsule_GetPointer(WId, name)

        self._RenderWindow.SetWindowInfo(str(int(WId)))

        if stereo:  # stereo mode
            self._RenderWindow.StereoCapableWindowOn()
            self._RenderWindow.SetStereoTypeToCrystalEyes()

        try:
            self._Iren = kw['iren']
        except KeyError:
            self._Iren = vtk.vtkGenericRenderWindowInteractor()
            self._Iren.SetRenderWindow(self._RenderWindow)

        # do all the necessary qt setup
        self.setAttribute(Qt.WA_OpaquePaintEvent)
        self.setAttribute(Qt.WA_PaintOnScreen)
        self.setMouseTracking(True)  # get all mouse events
        self.setFocusPolicy(Qt.WheelFocus)
        self.setSizePolicy(
            QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding))

        self._Timer = QTimer(self)
        self._Timer.timeout.connect(self.TimerEvent)

        self._Iren.AddObserver('CreateTimerEvent', self.CreateTimer)
        self._Iren.AddObserver('DestroyTimerEvent', self.DestroyTimer)
        self._Iren.GetRenderWindow().AddObserver('CursorChangedEvent',
                                                 self.CursorChangedEvent)

        #Create a hidden child widget and connect its destroyed signal to its
        #parent ``Finalize`` slot. The hidden children will be destroyed before
        #its parent thus allowing cleanup of VTK elements.
        self._hidden = QWidget(self)
        self._hidden.hide()
        self._hidden.destroyed.connect(self.Finalize)
コード例 #32
0
 def toggleOpenGL(self):
     self.graphicsView.setViewport(
         QGLWidget(QGLFormat(QGL.SampleBuffers)) if self.openGlButton.
         isChecked() else QWidget())
コード例 #33
0
        def __init__(self, parent):
            QGLWidget.__init__(self, parent)
            gl_move_view.__init__(self)
            gl_base_widget.__init__(self)
            gl_objects.__init__(self)
            gl_lib_ray.__init__(self)
            gl_text.__init__(self)
            gl_color.__init__(self)
            gl_render_obj.__init__(self)
            gl_input.__init__(self)
            gl_graph.__init__(self)

            self.lit = True
            self.setAutoBufferSwap(False)

            self.lights = []

            l = open_gl_light()
            l.xyz = [0, 5, -10, 1.0]
            l.number = GL_LIGHT0
            self.lights.append(l)

            l = open_gl_light()
            l.xyz = [0, 5, 10, 1.0]
            l.number = GL_LIGHT1
            self.lights.append(l)

            l = open_gl_light()
            l.xyz = [0, -5, 10, 1.0]
            l.number = GL_LIGHT1
            self.lights.append(l)

            self.failed = True
            self.graph_path = None
            self.scene_built = False
            #view pos

            self.graph_data = dat_file()

            self.tab_active_layers = True
            self.dy_layer_offset = 0.05

            self.draw_electrical_mesh = False
            self.draw_device_cut_through = False
            self.enable_draw_ray_mesh = False
            self.enable_draw_light_source = False
            self.enable_draw_rays = True
            self.enable_cordinates = True
            self.plot_graph = False
            self.plot_circuit = False

            #For image
            #self.render_grid=False
            #self.render_text=False
            #self.tab_active_layers=False
            #self.dy_layer_offset=0.1
            self.font = QFont("Arial")
            self.font.setPointSize(15)
            self.called = False
            self.enable_light_profile = True
            self.build_main_menu()
            self.pre_built_scene = None
コード例 #34
0
ファイル: gl_test.py プロジェクト: roderickmackenzie/gpvdm
 def __init__(self, parent):
     QGLWidget.__init__(self, parent)
     self.setMinimumSize(640, 480)
コード例 #35
0
    def setupUi(self, MainWindow):
        self.MainWindow = MainWindow
        self.sequence = QSequentialAnimationGroup()
        self.sequence.finished.connect(self.animation_finished)
        self.scene = QGraphicsScene()

        MainWindow.setObjectName("MainWindow")
        #todo: icon
        # icon = QtGui.QIcon()
        # icon.addFile('icon.png', QtCore.QSize(48, 48))
        # MainWindow.setWindowIcon(icon)
        MainWindow.resize(self.width, self.height)

        # qt designer generated code
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(1118, 864)
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.gridLayout = QtWidgets.QGridLayout(self.centralwidget)
        self.gridLayout.setObjectName("gridLayout")
        self.graphicsView = QtWidgets.QGraphicsView(self.centralwidget)
        self.graphicsView.setEnabled(True)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding,
                                           QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(1)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.graphicsView.sizePolicy().hasHeightForWidth())
        self.graphicsView.setSizePolicy(sizePolicy)
        self.graphicsView.setObjectName("graphicsView")
        self.gridLayout.addWidget(self.graphicsView, 3, 1, 1, 1)
        self.gridLayout_0 = QtWidgets.QGridLayout()
        self.gridLayout_0.setObjectName("gridLayout_0")
        self.lineEdit_0 = QtWidgets.QLineEdit(self.centralwidget)
        self.lineEdit_0.setObjectName("lineEdit_0")
        self.gridLayout_0.addWidget(self.lineEdit_0, 1, 0, 1, 1)
        self.pushButton_0 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_0.setObjectName("pushButton_0")
        self.gridLayout_0.addWidget(self.pushButton_0, 4, 0, 1, 1)
        self.toolButton_0 = QtWidgets.QToolButton(self.centralwidget)
        self.toolButton_0.setObjectName("toolButton_0")
        self.gridLayout_0.addWidget(self.toolButton_0, 1, 1, 1, 1)
        self.pushButton_1 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_1.setObjectName("pushButton_1")
        self.gridLayout_0.addWidget(self.pushButton_1, 6, 0, 1, 1)
        self.toolButton_1 = QtWidgets.QToolButton(self.centralwidget)
        self.toolButton_1.setObjectName("toolButton_1")
        self.gridLayout_0.addWidget(self.toolButton_1, 3, 1, 1, 1)
        spacerItem = QtWidgets.QSpacerItem(20, 40,
                                           QtWidgets.QSizePolicy.Minimum,
                                           QtWidgets.QSizePolicy.Expanding)
        self.gridLayout_0.addItem(spacerItem, 8, 0, 1, 1)
        self.label_1 = QtWidgets.QLabel(self.centralwidget)
        self.label_1.setObjectName("label_1")
        self.gridLayout_0.addWidget(self.label_1, 2, 0, 1, 1)
        spacerItem1 = QtWidgets.QSpacerItem(
            300, 20, QtWidgets.QSizePolicy.MinimumExpanding,
            QtWidgets.QSizePolicy.Minimum)
        self.gridLayout_0.addItem(spacerItem1, 9, 0, 1, 1)
        self.label_0 = QtWidgets.QLabel(self.centralwidget)
        self.label_0.setObjectName("label_0")
        self.gridLayout_0.addWidget(self.label_0, 0, 0, 1, 1)
        self.lineEdit_1 = QtWidgets.QLineEdit(self.centralwidget)
        self.lineEdit_1.setObjectName("lineEdit_1")
        self.gridLayout_0.addWidget(self.lineEdit_1, 3, 0, 1, 1)
        self.textEdit = QtWidgets.QTextEdit(self.centralwidget)
        self.textEdit.setObjectName("textEdit")
        self.gridLayout_0.addWidget(self.textEdit, 7, 0, 1, 1)
        self.gridLayout.addLayout(self.gridLayout_0, 3, 0, 1, 1)
        MainWindow.setCentralWidget(self.centralwidget)
        self.statusbar = QtWidgets.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)

        QtCore.QMetaObject.connectSlotsByName(MainWindow)

        # end of eq designer generated code

        self.lineEdits = []
        self.lineEdits.append(self.lineEdit_0)
        self.lineEdits.append(self.lineEdit_1)
        self.pushButtons = []
        self.pushButtons.append(self.pushButton_0)
        self.pushButtons.append(self.pushButton_1)
        self.pushButtons.append(self.toolButton_0)
        self.pushButtons.append(self.toolButton_1)
        self.labels = []
        self.labels.append(self.label_0)
        self.labels.append(self.label_1)
        self.progressBars = []
        self.textEdits = []
        self.textEdits.append(self.textEdit)
        self.graphicsView.setScene(self.scene)
        self.graphicsView.setSceneRect(0, 0, 0, 0)
        self.graphicsView.setRenderHints(QPainter.Antialiasing)
        # self.graphicsView.fitInView(self.scene.sceneRect(), Qt.KeepAspectRatio)
        self.graphicsView.setViewport(QGLWidget(QGLFormat(QGL.SampleBuffers)))
        self.graphicsView.scale(self.zoom, -self.zoom)
        self.graphicsView.setDragMode(1)
コード例 #36
0
 def __init__(self, parent):
     QGLWidget.__init__(self, parent)
     # self.startTimer(100)
     self.text = 'GL_POINT'