From 97828397499bcd489061d17d3fca830c10b4a2c8 Mon Sep 17 00:00:00 2001 From: ykeara Date: Sun, 16 Dec 2018 13:58:00 -0600 Subject: [PATCH] added apply button to rotate playspace instead of automatically rotating --- src/res/qml/PlayspacePage.qml | 12 ++++++++++++ src/tabcontrollers/MoveCenterTabController.cpp | 14 +++++++++++--- src/tabcontrollers/MoveCenterTabController.h | 6 ++++-- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/res/qml/PlayspacePage.qml b/src/res/qml/PlayspacePage.qml index 9795983..49cb301 100644 --- a/src/res/qml/PlayspacePage.qml +++ b/src/res/qml/PlayspacePage.qml @@ -92,6 +92,7 @@ MyStackViewPage { } MyToggleButton { + Layout.preferredWidth: 240 id: lockXToggle text: "Lock X" onCheckedChanged: { @@ -141,6 +142,7 @@ MyStackViewPage { MyToggleButton { + Layout.preferredWidth: 240 id: lockYToggle text: "Lock Y" onCheckedChanged: { @@ -190,6 +192,7 @@ MyStackViewPage { MyToggleButton { + Layout.preferredWidth: 240 id: lockZToggle text: "Lock Z" onCheckedChanged: { @@ -286,6 +289,15 @@ MyStackViewPage { } } } + MyPushButton { + id: playSpaceRotationApplyButton + Layout.preferredWidth: 145 + text:"Apply" + onClicked: { + MoveCenterTabController.applyRotation() + } + + } } } } diff --git a/src/tabcontrollers/MoveCenterTabController.cpp b/src/tabcontrollers/MoveCenterTabController.cpp index f1f5ec6..8641185 100644 --- a/src/tabcontrollers/MoveCenterTabController.cpp +++ b/src/tabcontrollers/MoveCenterTabController.cpp @@ -113,15 +113,23 @@ int MoveCenterTabController::rotation() const { void MoveCenterTabController::setRotation(int value, bool notify) { if (m_rotation != value) { - float angle = (value - m_rotation) * 2 * M_PI / 360.0; - parent->RotateUniverseCenter((vr::TrackingUniverseOrigin)m_trackingUniverse, angle, m_adjustChaperone); + //float angle = (value - m_rotation) * 2 * M_PI / 360.0; + //parent->RotateUniverseCenter((vr::TrackingUniverseOrigin)m_trackingUniverse, angle, m_adjustChaperone); m_rotation = value; - if (notify) { + if (notify) { emit rotationChanged(m_rotation); } } } +void MoveCenterTabController::applyRotation() { + if (m_rotation != m_rotationOld) { + float angle = (m_rotationOld - m_rotation) * 2 * M_PI / 360.0; + parent->RotateUniverseCenter((vr::TrackingUniverseOrigin)m_trackingUniverse, angle, m_adjustChaperone); + m_rotationOld = m_rotation; + } +} + bool MoveCenterTabController::adjustChaperone() const { return m_adjustChaperone; } diff --git a/src/tabcontrollers/MoveCenterTabController.h b/src/tabcontrollers/MoveCenterTabController.h index 1d39007..0768e51 100644 --- a/src/tabcontrollers/MoveCenterTabController.h +++ b/src/tabcontrollers/MoveCenterTabController.h @@ -19,7 +19,7 @@ class MoveCenterTabController : public QObject { Q_PROPERTY(float offsetX READ offsetX WRITE setOffsetX NOTIFY offsetXChanged) Q_PROPERTY(float offsetY READ offsetY WRITE setOffsetY NOTIFY offsetYChanged) Q_PROPERTY(float offsetZ READ offsetZ WRITE setOffsetZ NOTIFY offsetZChanged) - Q_PROPERTY(int rotation READ rotation WRITE setRotation NOTIFY rotationChanged) + Q_PROPERTY(int rotation READ rotation WRITE setRotation NOTIFY rotationChanged ) Q_PROPERTY(bool adjustChaperone READ adjustChaperone WRITE setAdjustChaperone NOTIFY adjustChaperoneChanged) Q_PROPERTY(bool moveShortcutRight READ moveShortcutRight WRITE setMoveShortcutRight NOTIFY moveShortcutRightChanged) Q_PROPERTY(bool moveShortcutLeft READ moveShortcutLeft WRITE setMoveShortcutLeft NOTIFY moveShortcutLeftChanged) @@ -37,6 +37,7 @@ private: float m_offsetY = 0.0f; float m_offsetZ = 0.0f; int m_rotation = 0; + int m_rotationOld = 0; bool m_adjustChaperone = true; bool m_moveShortcutRightPressed = false; bool m_moveShortcutLeftPressed = false; @@ -80,7 +81,7 @@ public slots: void setOffsetY(float value, bool notify = true); void setOffsetZ(float value, bool notify = true); - void setRotation(int value, bool notify = true); + void setRotation(int value , bool notify = true); void setAdjustChaperone(bool value, bool notify = true); @@ -96,6 +97,7 @@ public slots: void setLockY(bool value, bool notify = true); void setLockZ(bool value, bool notify = true); + void applyRotation(); void reset(); signals: