fix setCameraPosition not setting ele and azi in euler mode
This commit is contained in:
parent
b5fc3d2a7e
commit
ce4c6d95ed
@ -284,21 +284,40 @@ class GLViewWidget(QtWidgets.QOpenGLWidget):
|
|||||||
glPopMatrix()
|
glPopMatrix()
|
||||||
|
|
||||||
def setCameraPosition(self, pos=None, distance=None, elevation=None, azimuth=None, rotation=None):
|
def setCameraPosition(self, pos=None, distance=None, elevation=None, azimuth=None, rotation=None):
|
||||||
|
if rotation is not None:
|
||||||
|
# Alternatively, we could define that rotation overrides elevation and azimuth
|
||||||
|
if elevation is not None:
|
||||||
|
raise ValueError("cannot set both rotation and elevation")
|
||||||
|
if azimuth is not None:
|
||||||
|
raise ValueError("cannot set both rotation and azimuth")
|
||||||
|
|
||||||
if pos is not None:
|
if pos is not None:
|
||||||
self.opts['center'] = pos
|
self.opts['center'] = pos
|
||||||
if distance is not None:
|
if distance is not None:
|
||||||
self.opts['distance'] = distance
|
self.opts['distance'] = distance
|
||||||
if rotation is not None:
|
|
||||||
# set with quaternion
|
if self.opts['rotationMethod'] == "quaternion":
|
||||||
self.opts['rotation'] = rotation
|
# note that "quaternion" mode modifies only opts['rotation']
|
||||||
else:
|
if elevation is not None or azimuth is not None:
|
||||||
# set with elevation-azimuth, restored for compatibility
|
|
||||||
eu = self.opts['rotation'].toEulerAngles()
|
eu = self.opts['rotation'].toEulerAngles()
|
||||||
if azimuth is not None:
|
if azimuth is not None:
|
||||||
eu.setZ(-azimuth-90)
|
eu.setZ(-azimuth-90)
|
||||||
if elevation is not None:
|
if elevation is not None:
|
||||||
eu.setX(elevation-90)
|
eu.setX(elevation-90)
|
||||||
self.opts['rotation'] = QtGui.QQuaternion.fromEulerAngles(eu)
|
self.opts['rotation'] = QtGui.QQuaternion.fromEulerAngles(eu)
|
||||||
|
if rotation is not None:
|
||||||
|
self.opts['rotation'] = rotation
|
||||||
|
else:
|
||||||
|
# note that "euler" mode modifies only opts['elevation'] and opts['azimuth']
|
||||||
|
if elevation is not None:
|
||||||
|
self.opts['elevation'] = elevation
|
||||||
|
if azimuth is not None:
|
||||||
|
self.opts['azimuth'] = azimuth
|
||||||
|
if rotation is not None:
|
||||||
|
eu = rotation.toEulerAngles()
|
||||||
|
self.opts['elevation'] = eu.x() + 90
|
||||||
|
self.opts['azimuth'] = -eu.z() - 90
|
||||||
|
|
||||||
self.update()
|
self.update()
|
||||||
|
|
||||||
def cameraPosition(self):
|
def cameraPosition(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user