Python PyQt5.QtGui.QVector3D() Examples

The following are 5 code examples for showing how to use PyQt5.QtGui.QVector3D(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.

You may check out the related API usage on the sidebar.

You may also want to check out all available functions/classes of the module PyQt5.QtGui , or try the search function .

Example 1
Project: Uranium   Author: Ultimaker   File: ShaderProgram.py    License: GNU Lesser General Public License v3.0 6 votes vote down vote up
def _setUniformValueDirect(self, uniform, value):
        if type(value) is Vector:
            self._shader_program.setUniformValue(uniform, QVector3D(value.x, value.y, value.z))
        elif type(value) is Matrix:
            self._shader_program.setUniformValue(uniform, self._matrixToQMatrix4x4(value))
        elif type(value) is Color:
            self._shader_program.setUniformValue(uniform,
                QColor(value.r * 255, value.g * 255, value.b * 255, value.a * 255))
        elif type(value) is list and type(value[0]) is list and len(value[0]) == 4:
            self._shader_program.setUniformValue(uniform, self._matrixToQMatrix4x4(Matrix(value)))
        elif type(value) is list and len(value) == 2:
            self._shader_program.setUniformValue(uniform, QVector2D(value[0], value[1]))
        elif type(value) is list and len(value) == 3:
            self._shader_program.setUniformValue(uniform, QVector3D(value[0], value[1], value[2]))
        elif type(value) is list and len(value) == 4:
            self._shader_program.setUniformValue(uniform, QVector4D(value[0], value[1], value[2], value[3]))
        elif type(value) is list and type(value[0]) is list and len(value[0]) == 2:
            self._shader_program.setUniformValueArray(uniform, [QVector2D(i[0], i[1]) for i in value])
        else:
            self._shader_program.setUniformValue(uniform, value) 
Example 2
Project: Cura   Author: Ultimaker   File: CameraAnimation.py    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
def setStart(self, start):
        self.setStartValue(QVector3D(start.x, start.y, start.z)) 
Example 3
Project: Cura   Author: Ultimaker   File: CameraAnimation.py    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
def setTarget(self, target):
        self.setEndValue(QVector3D(target.x, target.y, target.z)) 
Example 4
Project: Mastering-GUI-Programming-with-Python   Author: PacktPublishing   File: wedge_animation.py    License: MIT License 5 votes vote down vote up
def qcolor_to_glvec(self, qcolor):
        return qtg.QVector3D(
            qcolor.red() / 255,
            qcolor.green() / 255,
            qcolor.blue() / 255
        ) 
Example 5
Project: PyQt   Author: PyQt5   File: MagneticOfSun.py    License: GNU General Public License v3.0 4 votes vote down vote up
def generateData(self):
        # 生成模拟数据
        magneticFieldArray = []

        for i in range(self.m_fieldLines):
            horizontalAngle = (self.doublePi * i) / self.m_fieldLines
            xCenter = self.ellipse_a * math.cos(horizontalAngle)
            zCenter = self.ellipse_a * math.sin(horizontalAngle)

            # Rotate - arrow is always tangential to the origin.
            # 旋转-箭头始终与原点相切。
            yRotation = QQuaternion.fromAxisAndAngle(0.0, 1.0, 0.0,
                                                     horizontalAngle * self.radiansToDegrees)

            for j in range(self.m_arrowsPerLine):
                # Calculate the point on the ellipse centered on the origin and
                # 计算椭圆上以原点为中心的点
                # parallel to the x-axis.
                # 平行于X轴。
                verticalAngle = ((self.doublePi * j) / self.m_arrowsPerLine) + self.m_angleOffset
                xUnrotated = self.ellipse_a * math.cos(verticalAngle)
                y = self.ellipse_b * math.sin(verticalAngle)

                # Rotate the ellipse around the y-axis.
                # 围绕Y轴旋转椭圆。
                xRotated = xUnrotated * math.cos(horizontalAngle)
                zRotated = xUnrotated * math.sin(horizontalAngle)

                # Add the offset.
                # 添加偏移量。
                x = xCenter + xRotated
                z = zCenter + zRotated

                zRotation = QQuaternion.fromAxisAndAngle(0.0, 0.0, 1.0,
                                                         verticalAngle * self.radiansToDegrees)
                totalRotation = yRotation * zRotation

                itm = QScatterDataItem(QVector3D(x, y, z), totalRotation)
                magneticFieldArray.append(itm)

        if self.m_graph.selectedSeries() is self.m_magneticField:
            self.m_graph.clearSelection()

        self.m_magneticField.dataProxy().resetArray(magneticFieldArray)