diff options
Diffstat (limited to 'src/datavisualization/input')
-rw-r--r-- | src/datavisualization/input/q3dinputhandler.cpp | 32 | ||||
-rw-r--r-- | src/datavisualization/input/qtouch3dinputhandler.cpp | 27 |
2 files changed, 27 insertions, 32 deletions
diff --git a/src/datavisualization/input/q3dinputhandler.cpp b/src/datavisualization/input/q3dinputhandler.cpp index 0bed3cb9..43cee84e 100644 --- a/src/datavisualization/input/q3dinputhandler.cpp +++ b/src/datavisualization/input/q3dinputhandler.cpp @@ -22,18 +22,16 @@ QT_BEGIN_NAMESPACE_DATAVISUALIZATION -const int minZoomLevel = 10; -const int halfSizeZoomLevel = 50; -const int oneToOneZoomLevel = 100; -const int maxZoomLevel = 500; -const int driftTowardCenterLevel = 175; -const float wheelZoomDrift = 0.1f; +static const int halfSizeZoomLevel = 50; +static const int oneToOneZoomLevel = 100; +static const int driftTowardCenterLevel = 175; +static const float wheelZoomDrift = 0.1f; -const int nearZoomRangeDivider = 12; -const int midZoomRangeDivider = 60; -const int farZoomRangeDivider = 120; +static const int nearZoomRangeDivider = 12; +static const int midZoomRangeDivider = 60; +static const int farZoomRangeDivider = 120; -const float rotationSpeed = 100.0f; +static const float rotationSpeed = 100.0f; /*! * \class Q3DInputHandler @@ -58,7 +56,7 @@ const float rotationSpeed = 100.0f; * \l {QAbstract3DGraph::selectionMode}{selection mode}. * \row * \li Mouse wheel - * \li Zoom in/out within default range (10...500%). + * \li Zoom in/out within the allowable zoom range set for Q3DCamera. * \row * \li Left click on the primary view when the secondary view is visible * \li Closes the secondary view. @@ -239,17 +237,17 @@ void Q3DInputHandler::wheelEvent(QWheelEvent *event) return; // Adjust zoom level based on what zoom range we're in. - int zoomLevel = scene()->activeCamera()->zoomLevel(); + Q3DCamera *camera = scene()->activeCamera(); + int zoomLevel = int(camera->zoomLevel()); + const int minZoomLevel = int(camera->minZoomLevel()); + const int maxZoomLevel = int(camera->maxZoomLevel()); if (zoomLevel > oneToOneZoomLevel) zoomLevel += event->angleDelta().y() / nearZoomRangeDivider; else if (zoomLevel > halfSizeZoomLevel) zoomLevel += event->angleDelta().y() / midZoomRangeDivider; else zoomLevel += event->angleDelta().y() / farZoomRangeDivider; - if (zoomLevel > maxZoomLevel) - zoomLevel = maxZoomLevel; - else if (zoomLevel < minZoomLevel) - zoomLevel = minZoomLevel; + zoomLevel = qBound(minZoomLevel, zoomLevel, maxZoomLevel); if (isZoomAtTargetEnabled()) { scene()->setGraphPositionQuery(event->pos()); @@ -259,7 +257,7 @@ void Q3DInputHandler::wheelEvent(QWheelEvent *event) d_ptr->m_requestedZoomLevel = zoomLevel; d_ptr->m_driftMultiplier = wheelZoomDrift; } else { - scene()->activeCamera()->setZoomLevel(zoomLevel); + camera->setZoomLevel(zoomLevel); } } } diff --git a/src/datavisualization/input/qtouch3dinputhandler.cpp b/src/datavisualization/input/qtouch3dinputhandler.cpp index b811548b..20eebb58 100644 --- a/src/datavisualization/input/qtouch3dinputhandler.cpp +++ b/src/datavisualization/input/qtouch3dinputhandler.cpp @@ -22,18 +22,16 @@ QT_BEGIN_NAMESPACE_DATAVISUALIZATION -const float maxTapAndHoldJitter = 20.0f; -const int maxPinchJitter = 10; +static const float maxTapAndHoldJitter = 20.0f; +static const int maxPinchJitter = 10; #if defined (Q_OS_ANDROID) || defined(Q_OS_IOS) -const int maxSelectionJitter = 10; +static const int maxSelectionJitter = 10; #else -const int maxSelectionJitter = 5; +static const int maxSelectionJitter = 5; #endif -const int tapAndHoldTime = 250; -const float rotationSpeed = 200.0f; -const int minZoomLevel = 10; -const int maxZoomLevel = 500; -const float touchZoomDrift = 0.02f; +static const int tapAndHoldTime = 250; +static const float rotationSpeed = 200.0f; +static const float touchZoomDrift = 0.02f; /*! * \class QTouch3DInputHandler @@ -61,7 +59,7 @@ const float touchZoomDrift = 0.02f; * \li Same as tap. * \row * \li Pinch - * \li Zoom in/out within default range (10...500%). + * \li Zoom in/out within the allowable zoom range set for Q3DCamera. * \row * \li Tap on the primary view when the secondary view is visible * \li Closes the secondary view. @@ -193,16 +191,15 @@ void QTouch3DInputHandlerPrivate::handlePinchZoom(float distance, const QPoint & return; m_inputState = QAbstract3DInputHandlerPrivate::InputStatePinching; Q3DCamera *camera = q_ptr->scene()->activeCamera(); - int zoomLevel = camera->zoomLevel(); + int zoomLevel = int(camera->zoomLevel()); + const int minZoomLevel = int(camera->minZoomLevel()); + const int maxZoomLevel = int(camera->maxZoomLevel()); float zoomRate = qSqrt(qSqrt(zoomLevel)); if (newDistance > prevDist) zoomLevel += zoomRate; else zoomLevel -= zoomRate; - if (zoomLevel > maxZoomLevel) - zoomLevel = maxZoomLevel; - else if (zoomLevel < minZoomLevel) - zoomLevel = minZoomLevel; + zoomLevel = qBound(minZoomLevel, zoomLevel, maxZoomLevel); if (q_ptr->isZoomAtTargetEnabled()) { q_ptr->scene()->setGraphPositionQuery(pos); |