Exemplo n.º 1
0
    def __init__(self, scatter):
        super(ScatterDataModifier, self).__init__()

        mesh_dir = QFileInfo(__file__).absolutePath() + '/mesh'

        self.m_graph = scatter
        self.m_rotationTimer = QTimer()
        self.m_fieldLines = 12
        self.m_arrowsPerLine = 16
        self.m_magneticField = QScatter3DSeries()
        self.m_sun = QScatter3DSeries()
        self.m_angleOffset = 0.0
        self.m_angleStep = self.doublePi / self.m_arrowsPerLine / self.animationFrames

        self.m_graph.setShadowQuality(QAbstract3DGraph.ShadowQualityNone)
        self.m_graph.scene().activeCamera().setCameraPreset(
            Q3DCamera.CameraPresetFront)

        # Magnetic field lines use custom narrow arrow.
        self.m_magneticField.setItemSize(0.2)
        self.m_magneticField.setMesh(QAbstract3DSeries.MeshUserDefined)
        self.m_magneticField.setUserDefinedMesh(mesh_dir + '/narrowarrow.obj')
        fieldGradient = QLinearGradient(0, 0, 16, 1024)
        fieldGradient.setColorAt(0.0, Qt.black)
        fieldGradient.setColorAt(1.0, Qt.white)
        self.m_magneticField.setBaseGradient(fieldGradient)
        self.m_magneticField.setColorStyle(Q3DTheme.ColorStyleRangeGradient)

        # For 'sun' we use a custom large sphere.
        self.m_sun.setItemSize(0.2)
        self.m_sun.setName("Sun")
        self.m_sun.setItemLabelFormat("@seriesName")
        self.m_sun.setMesh(QAbstract3DSeries.MeshUserDefined)
        self.m_sun.setUserDefinedMesh(mesh_dir + '/largesphere.obj')
        self.m_sun.setBaseColor(QColor(0xff, 0xbb, 0x00))
        self.m_sun.dataProxy().addItem(QScatterDataItem(QVector3D()))

        self.m_graph.addSeries(self.m_magneticField)
        self.m_graph.addSeries(self.m_sun)

        # Configure the axes according to the data.
        self.m_graph.axisX().setRange(-self.horizontalRange,
                                      self.horizontalRange)
        self.m_graph.axisY().setRange(-self.verticalRange, self.verticalRange)
        self.m_graph.axisZ().setRange(-self.horizontalRange,
                                      self.horizontalRange)
        self.m_graph.axisX().setSegmentCount(self.horizontalRange)
        self.m_graph.axisZ().setSegmentCount(self.horizontalRange)

        self.m_rotationTimer.timeout.connect(self.triggerRotation)

        self.toggleRotation()
        self.generateData()
Exemplo n.º 2
0
    def __init__(self, scatter):
        super(ScatterDataModifier, self).__init__()

        self.m_graph = scatter  # Q3DScatter实例
        self.m_fontSize = 40.0
        self.m_style = QAbstract3DSeries.MeshSphere
        self.m_smooth = True
        self.m_itemCount = self.lowerNumberOfItems
        self.m_curveDivider = self.lowerCurveDivider

        # 设置当前主题类型
        self.m_graph.activeTheme().setType(Q3DTheme.ThemeEbony)
        # 设置当前主题的字体
        font = self.m_graph.activeTheme().font()
        font.setPointSize(self.m_fontSize)
        self.m_graph.activeTheme().setFont(font)
        # 设置阴影质量
        self.m_graph.setShadowQuality(QAbstract3DGraph.ShadowQualitySoftLow)
        self.m_graph.scene().activeCamera().setCameraPreset(
            Q3DCamera.CameraPresetFront)

        proxy = QScatterDataProxy()
        series = QScatter3DSeries(proxy)
        series.setItemLabelFormat(
            "@xTitle: @xLabel @yTitle: @yLabel @zTitle: @zLabel")
        series.setMeshSmooth(self.m_smooth)
        self.m_graph.addSeries(series)

        self.addData()
Exemplo n.º 3
0
    def instantiateLED(self):
        self.matrixLEDserie.clear()
        count = 0
        for i in range(self.cubeSize.getSize(Axis.X)):
            self.matrixLEDserie.append([])
            for j in range(self.cubeSize.getSize(Axis.Y)):
                self.matrixLEDserie[i].append([])
                for k in range(self.cubeSize.getSize(Axis.Z)):

                    item = QScatterDataItem(
                        QVector3D(i + 1, k + 1, j + 1)
                    )  # z-axis and y-axis reversed to match representations, purely graphic

                    self.matrixLEDserie[i][j].append(
                        QScatter3DSeries(QScatterDataProxy()))

                    #self.matrixLEDserie[i][j][k].setItemLabelFormat("@xTitle: @xLabel @yTitle: @yLabel @zTitle: @zLabel")
                    self.matrixLEDserie[i][j][k].setMeshSmooth(True)
                    self.matrixLEDserie[i][j][k].setName(
                        str(i) + " " + str(j) + " " + str(k))

                    self.m_graph.addSeries(self.matrixLEDserie[i][j][k])

                    self.m_graph.seriesList()[count].dataProxy().addItem(item)
                    self.m_graph.seriesList()[count].setBaseColor(
                        self.nullColor)
                    self.m_graph.seriesList()[count].setItemSize(
                        1.2 / self.cubeSize.max())

                    count = count + 1
Exemplo n.º 4
0
    def __init__(self, scatter):
        super(ScatterDataModifier, self).__init__()

        self.m_graph = scatter
        self.m_inputHandler = CustomInputHandler()

        self.m_graph.activeTheme().setType(Q3DTheme.ThemeDigia)
        self.m_graph.setShadowQuality(QAbstract3DGraph.ShadowQualityMedium)
        self.m_graph.scene().activeCamera().setCameraPreset(
            Q3DCamera.CameraPresetFront)

        self.m_graph.setAxisX(QValue3DAxis())
        self.m_graph.setAxisY(QValue3DAxis())
        self.m_graph.setAxisZ(QValue3DAxis())

        self.m_graph.axisX().setRange(-10.0, 10.0)
        self.m_graph.axisY().setRange(-5.0, 5.0)
        self.m_graph.axisZ().setRange(-5.0, 5.0)

        series = QScatter3DSeries()
        series.setItemLabelFormat("@xLabel, @yLabel, @zLabel")
        series.setMesh(QAbstract3DSeries.MeshCube)
        series.setItemSize(0.15)
        self.m_graph.addSeries(series)

        self.m_animationCameraX = QPropertyAnimation(
            self.m_graph.scene().activeCamera(), 'xRotation')
        self.m_animationCameraX.setDuration(20000)
        self.m_animationCameraX.setStartValue(0.0)
        self.m_animationCameraX.setEndValue(360.0)
        self.m_animationCameraX.setLoopCount(-1)

        upAnimation = QPropertyAnimation(self.m_graph.scene().activeCamera(),
                                         'yRotation')
        upAnimation.setDuration(9000)
        upAnimation.setStartValue(5.0)
        upAnimation.setEndValue(45.0)

        downAnimation = QPropertyAnimation(self.m_graph.scene().activeCamera(),
                                           'yRotation')
        downAnimation.setDuration(9000)
        downAnimation.setStartValue(45.0)
        downAnimation.setEndValue(5.0)

        self.m_animationCameraY = QSequentialAnimationGroup()
        self.m_animationCameraY.setLoopCount(-1)
        self.m_animationCameraY.addAnimation(upAnimation)
        self.m_animationCameraY.addAnimation(downAnimation)

        self.m_animationCameraX.start()
        self.m_animationCameraY.start()

        self.m_graph.setActiveInputHandler(self.m_inputHandler)

        self.m_selectionTimer = QTimer()
        self.m_selectionTimer.setInterval(10)
        self.m_selectionTimer.timeout.connect(self.triggerSelection)
        self.m_selectionTimer.start()
Exemplo n.º 5
0
 def __init__(self, scatter):
     super(ScatterDataModifier, self).__init__()
     self.m_graph = scatter
     self.m_graph.scene().activeCamera().setCameraPreset(
         Q3DCamera.CameraPresetFront)
     proxy = QScatterDataProxy()
     series = QScatter3DSeries(proxy)
     self.m_graph.addSeries(series)
     self.addData()
Exemplo n.º 6
0
    def __init__(self, scatter):
        super(ScatterDataModifier, self).__init__()

        mesh_dir = QFileInfo(__file__).absolutePath() + '/Data/mesh'

        self.m_graph = scatter  # Q3DScatter 对象实例
        self.m_rotationTimer = QTimer()
        self.m_fieldLines = 12  # 初始磁场线数量
        self.m_arrowsPerLine = 16  # 初始箭头数
        self.m_magneticField = QScatter3DSeries()  # 磁场线三维散点图
        self.m_sun = QScatter3DSeries()  # 太阳三维散点图
        self.m_angleOffset = 0.0  # 角度偏移
        self.m_angleStep = self.doublePi / self.m_arrowsPerLine / self.animationFrames

        # 设置阴影质量
        self.m_graph.setShadowQuality(QAbstract3DGraph.ShadowQualityNone)
        # 设置当前场景中的激活的相机预设值
        self.m_graph.scene().activeCamera().setCameraPreset(
            Q3DCamera.CameraPresetFront)

        # Magnetic field lines use custom narrow arrow.
        # 磁力线使用自定义窄箭头。
        self.m_magneticField.setItemSize(0.2)
        self.m_magneticField.setMesh(QAbstract3DSeries.MeshUserDefined)
        self.m_magneticField.setUserDefinedMesh(mesh_dir + '/narrowarrow.obj')
        # 设置渐变颜色
        fieldGradient = QLinearGradient(0, 0, 16, 1024)
        fieldGradient.setColorAt(0.0, Qt.black)
        fieldGradient.setColorAt(1.0, Qt.white)
        self.m_magneticField.setBaseGradient(fieldGradient)
        self.m_magneticField.setColorStyle(Q3DTheme.ColorStyleRangeGradient)

        # For 'sun' we use a custom large sphere.
        # 使用一个自定义的球体代表太阳
        self.m_sun.setItemSize(0.2)
        self.m_sun.setName("Sun")
        self.m_sun.setItemLabelFormat("@seriesName")
        self.m_sun.setMesh(QAbstract3DSeries.MeshUserDefined)
        self.m_sun.setUserDefinedMesh(mesh_dir + '/largesphere.obj')
        self.m_sun.setBaseColor(QColor(0xff, 0xbb, 0x00))
        self.m_sun.dataProxy().addItem(QScatterDataItem(QVector3D()))

        self.m_graph.addSeries(self.m_magneticField)
        self.m_graph.addSeries(self.m_sun)

        # Configure the axes according to the data.
        # 设置x轴的范围值
        self.m_graph.axisX().setRange(-self.horizontalRange,
                                      self.horizontalRange)
        # 设置y轴的范围值
        self.m_graph.axisY().setRange(-self.verticalRange, self.verticalRange)
        # 设置z轴的范围值
        self.m_graph.axisZ().setRange(-self.horizontalRange,
                                      self.horizontalRange)
        # x和z轴上的段数
        # 这表明绘制了多少标签。要绘制的网格线的数量使用公式计算:segments * subsegments + 1。预设默认值为5。该值不能低于1。
        self.m_graph.axisX().setSegmentCount(self.horizontalRange)
        self.m_graph.axisZ().setSegmentCount(self.horizontalRange)

        self.m_rotationTimer.timeout.connect(self.triggerRotation)

        self.toggleRotation()
        self.generateData()