diff options
-rw-r--r-- | src/plugins/sensors/blackberry/bbrotationsensor.cpp | 6 | ||||
-rw-r--r-- | src/plugins/sensors/generic/genericrotationsensor.cpp | 4 | ||||
-rw-r--r-- | src/sensors/qrotationsensor.cpp | 31 | ||||
-rw-r--r-- | src/sensors/qrotationsensor.h | 7 | ||||
-rw-r--r-- | tests/auto/qsensor/test_backends.h | 4 |
5 files changed, 19 insertions, 33 deletions
diff --git a/src/plugins/sensors/blackberry/bbrotationsensor.cpp b/src/plugins/sensors/blackberry/bbrotationsensor.cpp index 28dc49c9..e6d038d2 100644 --- a/src/plugins/sensors/blackberry/bbrotationsensor.cpp +++ b/src/plugins/sensors/blackberry/bbrotationsensor.cpp @@ -137,9 +137,9 @@ bool BbRotationSensor::updateReadingFromEvent(const sensor_event_t &event, QRota matrixToEulerZXY(event.rotation_matrix, xRad, yRad, zRad); } - reading->setX(radiansToDegrees(xRad)); - reading->setY(radiansToDegrees(yRad)); - reading->setZ(radiansToDegrees(zRad)); + reading->setFromEuler(radiansToDegrees(xRad), + radiansToDegrees(yRad), + radiansToDegrees(zRad)); return true; } diff --git a/src/plugins/sensors/generic/genericrotationsensor.cpp b/src/plugins/sensors/generic/genericrotationsensor.cpp index 7142227c..dddacb24 100644 --- a/src/plugins/sensors/generic/genericrotationsensor.cpp +++ b/src/plugins/sensors/generic/genericrotationsensor.cpp @@ -107,9 +107,7 @@ bool genericrotationsensor::filter(QSensorReading *reading) } m_reading.setTimestamp(ar->timestamp()); - m_reading.setX(pitch); - m_reading.setY(roll); - m_reading.setZ(0); + m_reading.setFromEuler(pitch, roll, 0); newReadingAvailable(); return false; } diff --git a/src/sensors/qrotationsensor.cpp b/src/sensors/qrotationsensor.cpp index 6adbf6a2..120723c7 100644 --- a/src/sensors/qrotationsensor.cpp +++ b/src/sensors/qrotationsensor.cpp @@ -116,14 +116,6 @@ qreal QRotationReading::x() const } /*! - Sets the rotation around the x axis to \a x. -*/ -void QRotationReading::setX(qreal x) -{ - d->x = x; -} - -/*! \property QRotationReading::y \brief the rotation around the y axis. @@ -137,14 +129,6 @@ qreal QRotationReading::y() const } /*! - Sets the rotation around the y axis to \a y. -*/ -void QRotationReading::setY(qreal y) -{ - d->y = y; -} - -/*! \property QRotationReading::z \brief the rotation around the z axis. @@ -158,10 +142,19 @@ qreal QRotationReading::z() const } /*! - Sets the rotation around the z axis to \a z. -*/ -void QRotationReading::setZ(qreal z) + \brief Sets the rotation from three euler angles. + + This is to be called from the backend. + + The angles are measured in degrees. The order of the rotations matters, as first the \a z rotation + is applied, then the \a x rotation and finally the \a y rotation. + + \since 5.0 + */ +void QRotationReading::setFromEuler(qreal x, qreal y, qreal z) { + d->x = x; + d->y = y; d->z = z; } diff --git a/src/sensors/qrotationsensor.h b/src/sensors/qrotationsensor.h index 9e022803..7021f355 100644 --- a/src/sensors/qrotationsensor.h +++ b/src/sensors/qrotationsensor.h @@ -60,13 +60,10 @@ class Q_SENSORS_EXPORT QRotationReading : public QSensorReading DECLARE_READING(QRotationReading) public: qreal x() const; - void setX(qreal x); - qreal y() const; - void setY(qreal y); - qreal z() const; - void setZ(qreal z); + + void setFromEuler(qreal x, qreal y, qreal z); }; class Q_SENSORS_EXPORT QRotationFilter : public QSensorFilter diff --git a/tests/auto/qsensor/test_backends.h b/tests/auto/qsensor/test_backends.h index 21f02355..1dc9dc3a 100644 --- a/tests/auto/qsensor/test_backends.h +++ b/tests/auto/qsensor/test_backends.h @@ -123,9 +123,7 @@ PREPARE_SENSORINTERFACE(QProximitySensor, QProximityReading, QProximityFilter, { reading->setClose(true); }) PREPARE_SENSORINTERFACE(QRotationSensor, QRotationReading, QRotationFilter, { - reading->setX(1.0); - reading->setY(1.0); - reading->setZ(1.0); + reading->setFromEuler(1.0, 1.0, 1.0); }) PREPARE_SENSORINTERFACE(QTapSensor, QTapReading, QTapFilter, { reading->setTapDirection(QTapReading::Z_Both); |