Esempio n. 1
0
    def __init__(self, parent=None):
        QOpenGLWidget.__init__(self, parent)
        QOpenGLFunctions.__init__(self)

        self.core = "--coreprofile" in QCoreApplication.arguments()
        self.xRot = 0
        self.yRot = 0
        self.zRot = 0
        self.lastPos = 0
        self.logo = Logo()
        self.vao = QOpenGLVertexArrayObject()
        self.logoVbo = QOpenGLBuffer()
        self.program = QOpenGLShaderProgram()
        self.projMatrixLoc = 0
        self.mvMatrixLoc = 0
        self.normalMatrixLoc = 0
        self.lightPosLoc = 0
        self.proj = QMatrix4x4()
        self.camera = QMatrix4x4()
        self.world = QMatrix4x4()
        self.transparent = "--transparent" in QCoreApplication.arguments()
        if self.transparent:
            fmt = self.format()
            fmt.setAlphaBufferSize(8)
            self.setFormat(fmt)
Esempio n. 2
0
    def __init__(self, parent=None):
        QOpenGLWidget.__init__(self, parent)
        QOpenGLFunctions.__init__(self)

        self.core = "--coreprofile" in QCoreApplication.arguments()
        self.xRot = 0
        self.yRot = 0
        self.zRot = 0
        self.lastPos = 0
        self.logo = Logo()
        self.vao = QOpenGLVertexArrayObject()
        self.logoVbo = QOpenGLBuffer()
        self.program = QOpenGLShaderProgram()
        self.projMatrixLoc = 0
        self.mvMatrixLoc = 0
        self.normalMatrixLoc = 0
        self.lightPosLoc = 0
        self.proj = QMatrix4x4()
        self.camera = QMatrix4x4()
        self.world = QMatrix4x4()
        self.transparent = "--transparent" in QCoreApplication.arguments()
        if self.transparent:
            fmt = self.format()
            fmt.setAlphaBufferSize(8)
            self.setFormat(fmt)
Esempio n. 3
0
    def __init__(self, window, project):
        super(View, self).__init__(window)
        QOpenGLFunctions.__init__(self)

        self.setFocusPolicy(Qt.StrongFocus)
        self.aspectRatio = 0.0
        self.shiftKey = False
        self.ctrlKey = False
        self.lastMousePos = QPoint()

        self.project = project
        self.project.redraw.connect(self.update, type=Qt.QueuedConnection)
        self.project.aspectRatio.connect(self.setAspectRatio,
                                         type=Qt.QueuedConnection)
        self.cameraMode.connect(self.project.setCameraMode,
                                type=Qt.QueuedConnection)
        self.cameraOrigin.connect(self.project.setCameraAtOrigin,
                                  type=Qt.QueuedConnection)
        self.cameraMove.connect(self.project.moveCamera,
                                type=Qt.QueuedConnection)
        self.cameraOrient.connect(self.project.orientCamera,
                                  type=Qt.QueuedConnection)
        self.cameraZoom.connect(self.project.zoomCamera,
                                type=Qt.QueuedConnection)
        self.cameraView.connect(self.project.setCameraView,
                                type=Qt.QueuedConnection)
        self.displayRatio.connect(self.project.setDisplayRatio,
                                  type=Qt.QueuedConnection)
        self.togglePicture.connect(self.project.togglePicture,
                                   type=Qt.QueuedConnection)
        self.removeView.connect(self.project.removeCurrentView,
                                type=Qt.QueuedConnection)
        self.selected.connect(self.project.select, type=Qt.QueuedConnection)
Esempio n. 4
0
    def __init__(self, parent=None):
        QOpenGLWidget.__init__(self, parent)
        QOpenGLFunctions.__init__(self)
        self.setMinimumSize(32, 32)

        self.info = ""
        self._supported_images = [
            "TGA", "PNG", "JPG", "JPEG", "TIF", "TIFF", "BMP", "DDS"
        ]

        # indices
        indices = [0, 1, 3, 1, 2, 3]
        self._indices = array('I', indices)

        # vertices
        # 3 position | 2 texture coord
        vertex = [
            1.0,
            1.0,
            0.0,
            1.0,
            1.0,  # top right
            1.0,
            -1.0,
            0.0,
            1.0,
            0.0,  # bottom right
            -1.0,
            -1.0,
            0.0,
            0.0,
            0.0,  # bottom left
            -1.0,
            1.0,
            0.0,
            0.0,
            1.0  # top left
        ]
        self._vertex = array('f', vertex)

        # opengl data related
        self._program = QOpenGLShaderProgram()
        self._program_bg = QOpenGLShaderProgram()
        self._vao = QOpenGLVertexArrayObject()
        self._vbo = QOpenGLBuffer(QOpenGLBuffer.VertexBuffer)
        self._texture = None
        self._texture_size = (1, 1)
        self._location = ()

        self._colors_default = (QColor.fromRgbF(0.65, 0.65, 0.65, 1.0),
                                QColor.fromRgbF(0.90, 0.90, 0.90, 1.0))
        self._u_colors = self._colors_default
        self._height = QVector4D(0, self.height(), 0, 0)

        self._u_channels = QMatrix4x4(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0,
                                      0, 0)