(self)
| 127 | self.generateData() |
| 128 | |
| 129 | def generateData(self): |
| 130 | # 生成模拟数据 |
| 131 | magneticFieldArray = [] |
| 132 | |
| 133 | for i in range(self.m_fieldLines): |
| 134 | horizontalAngle = (self.doublePi * i) / self.m_fieldLines |
| 135 | xCenter = self.ellipse_a * math.cos(horizontalAngle) |
| 136 | zCenter = self.ellipse_a * math.sin(horizontalAngle) |
| 137 | |
| 138 | # Rotate - arrow is always tangential to the origin. |
| 139 | # 旋转-箭头始终与原点相切。 |
| 140 | yRotation = QQuaternion.fromAxisAndAngle(0.0, 1.0, 0.0, |
| 141 | horizontalAngle * self.radiansToDegrees) |
| 142 | |
| 143 | for j in range(self.m_arrowsPerLine): |
| 144 | # Calculate the point on the ellipse centered on the origin and |
| 145 | # 计算椭圆上以原点为中心的点 |
| 146 | # parallel to the x-axis. |
| 147 | # 平行于X轴。 |
| 148 | verticalAngle = ((self.doublePi * j) / self.m_arrowsPerLine) + self.m_angleOffset |
| 149 | xUnrotated = self.ellipse_a * math.cos(verticalAngle) |
| 150 | y = self.ellipse_b * math.sin(verticalAngle) |
| 151 | |
| 152 | # Rotate the ellipse around the y-axis. |
| 153 | # 围绕Y轴旋转椭圆。 |
| 154 | xRotated = xUnrotated * math.cos(horizontalAngle) |
| 155 | zRotated = xUnrotated * math.sin(horizontalAngle) |
| 156 | |
| 157 | # Add the offset. |
| 158 | # 添加偏移量。 |
| 159 | x = xCenter + xRotated |
| 160 | z = zCenter + zRotated |
| 161 | |
| 162 | zRotation = QQuaternion.fromAxisAndAngle(0.0, 0.0, 1.0, |
| 163 | verticalAngle * self.radiansToDegrees) |
| 164 | totalRotation = yRotation * zRotation |
| 165 | |
| 166 | itm = QScatterDataItem(QVector3D(x, y, z), totalRotation) |
| 167 | magneticFieldArray.append(itm) |
| 168 | |
| 169 | if self.m_graph.selectedSeries() is self.m_magneticField: |
| 170 | self.m_graph.clearSelection() |
| 171 | |
| 172 | self.m_magneticField.dataProxy().resetArray(magneticFieldArray) |
| 173 | |
| 174 | def setFieldLines(self, lines): |
| 175 | self.m_fieldLines = lines |
no outgoing calls
no test coverage detected