summaryrefslogtreecommitdiffstats
path: root/src/datavisualization/input
diff options
context:
space:
mode:
Diffstat (limited to 'src/datavisualization/input')
-rw-r--r--src/datavisualization/input/input.pri11
-rw-r--r--src/datavisualization/input/q3dinputhandler.cpp124
-rw-r--r--src/datavisualization/input/q3dinputhandler.h60
-rw-r--r--src/datavisualization/input/q3dinputhandler_p.h51
-rw-r--r--src/datavisualization/input/qabstract3dinputhandler.cpp141
-rw-r--r--src/datavisualization/input/qabstract3dinputhandler.h82
-rw-r--r--src/datavisualization/input/qabstract3dinputhandler_p.h69
-rw-r--r--src/datavisualization/input/qtouch3dinputhandler.cpp100
-rw-r--r--src/datavisualization/input/qtouch3dinputhandler.h45
9 files changed, 683 insertions, 0 deletions
diff --git a/src/datavisualization/input/input.pri b/src/datavisualization/input/input.pri
new file mode 100644
index 00000000..8305604b
--- /dev/null
+++ b/src/datavisualization/input/input.pri
@@ -0,0 +1,11 @@
+HEADERS += \
+ $$PWD/qabstract3dinputhandler.h \
+ $$PWD/q3dinputhandler.h \
+ input/qtouch3dinputhandler.h \
+ input/qabstract3dinputhandler_p.h \
+ input/q3dinputhandler_p.h
+
+SOURCES += \
+ $$PWD/qabstract3dinputhandler.cpp \
+ $$PWD/q3dinputhandler.cpp \
+ input/qtouch3dinputhandler.cpp
diff --git a/src/datavisualization/input/q3dinputhandler.cpp b/src/datavisualization/input/q3dinputhandler.cpp
new file mode 100644
index 00000000..85583a16
--- /dev/null
+++ b/src/datavisualization/input/q3dinputhandler.cpp
@@ -0,0 +1,124 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc
+** All rights reserved.
+** For any questions to Digia, please use contact form at http://qt.digia.com
+**
+** This file is part of the QtDataVisualization module.
+**
+** Licensees holding valid Qt Enterprise licenses may use this file in
+** accordance with the Qt Enterprise License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia.
+**
+** If you have questions regarding the use of this file, please use
+** contact form at http://qt.digia.com
+**
+****************************************************************************/
+#include "q3dinputhandler.h"
+#include "q3dcamera.h"
+#include "q3dlight.h"
+
+QT_DATAVISUALIZATION_BEGIN_NAMESPACE
+
+Q3DInputHandler::Q3DInputHandler(QObject *parent) :
+ QAbstract3DInputHandler(parent)
+{
+}
+
+Q3DInputHandler::~Q3DInputHandler()
+{
+}
+
+// Input event listeners
+void Q3DInputHandler::mousePressEvent(QMouseEvent *event, const QPoint &mousePos)
+{
+ if (Qt::LeftButton == event->button()) {
+ if (scene()->isSlicingActivated()) {
+ if (scene()->isInputInsideMainView(mousePos)) {
+ setInputState(QDataVis::InputOnOverview);
+ //qDebug() << "Mouse pressed on overview";
+ } else if (scene()->isInputInsideSliceView(mousePos)) {
+ setInputState(QDataVis::InputOnSlice);
+ //qDebug() << "Mouse pressed on zoom";
+ } else {
+ setInputState(QDataVis::InputNone);
+ }
+ } else {
+ setInputState(QDataVis::InputOnScene);
+ // update mouse positions to prevent jumping when releasing or repressing a button
+ setInputPosition(mousePos);
+ emit selectionAtPoint(mousePos);
+ //qDebug() << "Mouse pressed on scene";
+
+ }
+ } else if (Qt::MiddleButton == event->button()) {
+ // reset rotations
+ setInputPosition(QPoint(0, 0));
+ } else if (Qt::RightButton == event->button()) {
+ // disable rotating when in slice view
+ setInputState(QDataVis::InputRotating);
+ // update mouse positions to prevent jumping when releasing or repressing a button
+ setInputPosition(mousePos);
+ }
+ // TODO: Call actual camera class when it's been written.
+ //m_cameraHelper->updateMousePos(m_mousePos);}
+}
+
+void Q3DInputHandler::mouseReleaseEvent(QMouseEvent *event, const QPoint &mousePos)
+{
+ Q_UNUSED(event);
+ if (QDataVis::InputRotating == inputState()) {
+ // update mouse positions to prevent jumping when releasing or repressing a button
+ setInputPosition(mousePos);
+ }
+ setInputState(QDataVis::InputNone);
+}
+
+void Q3DInputHandler::mouseMoveEvent(QMouseEvent *event, const QPoint &mousePos)
+{
+ Q_UNUSED(event);
+ if (QDataVis::InputRotating == inputState()) {
+
+ // Calculate mouse movement since last frame
+ QPointF rotations = scene()->camera()->rotations();
+ GLfloat xRotation = rotations.x();
+ GLfloat yRotation = rotations.y();
+ GLfloat mouseMoveX = GLfloat(inputPosition().x() - mousePos.x())
+ / (scene()->viewport().width() / rotationSpeed);
+ GLfloat mouseMoveY = GLfloat(inputPosition().y() - mousePos.y())
+ / (scene()->viewport().height() / rotationSpeed);
+ // Apply to rotations
+ xRotation -= mouseMoveX;
+ yRotation -= mouseMoveY;
+ scene()->camera()->setRotations(QPointF(xRotation, yRotation));
+ scene()->camera()->updateViewMatrix(1.0f);
+
+ setPreviousInputPos(inputPosition());
+ setInputPosition(mousePos);
+ }
+}
+
+void Q3DInputHandler::wheelEvent(QWheelEvent *event)
+{
+ // disable zooming if in slice view
+ if (scene()->isSlicingActivated())
+ return;
+
+ // Adjust zoom level based on what zoom range we're in.
+ int zoomLevel = scene()->camera()->zoomLevel();
+ 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;
+
+ scene()->camera()->setZoomLevel(zoomLevel);
+}
+
+QT_DATAVISUALIZATION_END_NAMESPACE
diff --git a/src/datavisualization/input/q3dinputhandler.h b/src/datavisualization/input/q3dinputhandler.h
new file mode 100644
index 00000000..2bab02d6
--- /dev/null
+++ b/src/datavisualization/input/q3dinputhandler.h
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc
+** All rights reserved.
+** For any questions to Digia, please use contact form at http://qt.digia.com
+**
+** This file is part of the QtDataVisualization module.
+**
+** Licensees holding valid Qt Enterprise licenses may use this file in
+** accordance with the Qt Enterprise License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia.
+**
+** If you have questions regarding the use of this file, please use
+** contact form at http://qt.digia.com
+**
+****************************************************************************/
+
+#ifndef QDEFAULT3DINPUTHANDLER_H
+#define QDEFAULT3DINPUTHANDLER_H
+
+const int minZoomLevel = 10;
+const int halfSizeZoomLevel = 50;
+const int oneToOneZoomLevel = 100;
+const int maxZoomLevel = 500;
+
+const int nearZoomRangeDivider = 12;
+const int midZoomRangeDivider = 60;
+const int farZoomRangeDivider = 120;
+
+const float rotationSpeed = 100.0f;
+
+#include "qabstract3dinputhandler.h"
+
+QT_DATAVISUALIZATION_BEGIN_NAMESPACE
+
+class QT_DATAVISUALIZATION_EXPORT Q3DInputHandler : public QAbstract3DInputHandler
+{
+ Q_OBJECT
+
+public:
+ explicit Q3DInputHandler(QObject *parent = 0);
+ virtual ~Q3DInputHandler();
+
+ // Input event listeners
+ virtual void mousePressEvent(QMouseEvent *event, const QPoint &mousePos);
+ virtual void mouseReleaseEvent(QMouseEvent *event, const QPoint &mousePos);
+ virtual void mouseMoveEvent(QMouseEvent *event, const QPoint &mousePos);
+ virtual void wheelEvent(QWheelEvent *event);
+
+signals:
+ void rotationSpeedChanged(int rotationSpeed);
+
+private:
+ Q_DISABLE_COPY(Q3DInputHandler)
+};
+
+QT_DATAVISUALIZATION_END_NAMESPACE
+
+#endif // QDEFAULT3DINPUTHANDLER_H
diff --git a/src/datavisualization/input/q3dinputhandler_p.h b/src/datavisualization/input/q3dinputhandler_p.h
new file mode 100644
index 00000000..af8bef5f
--- /dev/null
+++ b/src/datavisualization/input/q3dinputhandler_p.h
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc
+** All rights reserved.
+** For any questions to Digia, please use contact form at http://qt.digia.com
+**
+** This file is part of the QtDataVisualization module.
+**
+** Licensees holding valid Qt Enterprise licenses may use this file in
+** accordance with the Qt Enterprise License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia.
+**
+** If you have questions regarding the use of this file, please use
+** contact form at http://qt.digia.com
+**
+****************************************************************************/
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the QtDataVisualization API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+
+#ifndef Q3DINPUTHANDLER_P_H
+#define Q3DINPUTHANDLER_P_H
+
+#include "datavisualizationglobal_p.h"
+
+QT_DATAVISUALIZATION_BEGIN_NAMESPACE
+
+class Q3DInputHandler;
+
+class Q3DInputHandlerPrivate
+{
+public:
+ Q3DInputHandlerPrivate(Q3DInputHandler *q);
+ ~Q3DInputHandlerPrivate();
+
+public:
+ Q3DInputHandler *q_ptr;
+
+};
+
+QT_DATAVISUALIZATION_END_NAMESPACE
+
+#endif // Q3DINPUTHANDLER_P_H
diff --git a/src/datavisualization/input/qabstract3dinputhandler.cpp b/src/datavisualization/input/qabstract3dinputhandler.cpp
new file mode 100644
index 00000000..36125582
--- /dev/null
+++ b/src/datavisualization/input/qabstract3dinputhandler.cpp
@@ -0,0 +1,141 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc
+** All rights reserved.
+** For any questions to Digia, please use contact form at http://qt.digia.com
+**
+** This file is part of the QtDataVisualization module.
+**
+** Licensees holding valid Qt Enterprise licenses may use this file in
+** accordance with the Qt Enterprise License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia.
+**
+** If you have questions regarding the use of this file, please use
+** contact form at http://qt.digia.com
+**
+****************************************************************************/
+#include "qabstract3dinputhandler.h"
+
+QT_DATAVISUALIZATION_BEGIN_NAMESPACE
+
+QAbstract3DInputHandler::QAbstract3DInputHandler(QObject *parent) :
+ QObject(parent),
+ d_ptr(new QAbstract3DInputHandlerPrivate(this))
+{
+}
+
+QAbstract3DInputHandler::~QAbstract3DInputHandler()
+{
+}
+
+// Input event listeners
+void QAbstract3DInputHandler::mouseDoubleClickEvent(QMouseEvent *event)
+{
+ Q_UNUSED(event);
+}
+
+void QAbstract3DInputHandler::touchEvent(QTouchEvent *event)
+{
+ Q_UNUSED(event);
+}
+
+void QAbstract3DInputHandler::mousePressEvent(QMouseEvent *event, const QPoint &mousePos)
+{
+ Q_UNUSED(event);
+ Q_UNUSED(mousePos);
+}
+
+void QAbstract3DInputHandler::mouseReleaseEvent(QMouseEvent *event, const QPoint &mousePos)
+{
+ Q_UNUSED(event);
+ Q_UNUSED(mousePos);
+}
+
+void QAbstract3DInputHandler::mouseMoveEvent(QMouseEvent *event, const QPoint &mousePos)
+{
+ Q_UNUSED(event);
+ Q_UNUSED(mousePos);
+}
+
+void QAbstract3DInputHandler::wheelEvent(QWheelEvent *event)
+{
+ Q_UNUSED(event);
+}
+
+// Property get/set
+QDataVis::InputState QAbstract3DInputHandler::inputState()
+{
+ return d_ptr->m_inputState;
+}
+
+void QAbstract3DInputHandler::setInputState(QDataVis::InputState inputState)
+{
+ if (inputState != d_ptr->m_inputState) {
+ d_ptr->m_inputState = inputState;
+ emit inputStateChanged(inputState);
+ }
+}
+
+QPoint QAbstract3DInputHandler::inputPosition() const
+{
+ return d_ptr->m_inputPosition;
+}
+
+void QAbstract3DInputHandler::setInputPosition(const QPoint &position)
+{
+ if (position != d_ptr->m_inputPosition) {
+ d_ptr->m_inputPosition = position;
+ emit positionChanged(position);
+ }
+}
+
+void QAbstract3DInputHandler::setPrevDistance(int distance)
+{
+ d_ptr->m_prevDistance = distance;
+}
+
+int QAbstract3DInputHandler::prevDistance() const
+{
+ return d_ptr->m_prevDistance;
+}
+
+
+Q3DScene *QAbstract3DInputHandler::scene() const
+{
+ return d_ptr->m_scene;
+}
+
+void QAbstract3DInputHandler::setScene(Q3DScene *scene)
+{
+ d_ptr->m_scene = scene;
+}
+
+void QAbstract3DInputHandler::setPreviousInputPos(const QPoint &position)
+{
+ d_ptr->m_previousInputPos = position;
+}
+
+QPoint QAbstract3DInputHandler::previousInputPos() const
+{
+ return d_ptr->m_previousInputPos;
+}
+
+
+
+QAbstract3DInputHandlerPrivate::QAbstract3DInputHandlerPrivate(QAbstract3DInputHandler *q) :
+ q_ptr(q),
+ m_prevDistance(0),
+ m_inputState(QDataVis::InputNone),
+ m_inputPosition(QPoint(0,0)),
+ m_previousInputPos(QPoint(0,0)),
+ m_scene(0)
+{
+}
+
+QAbstract3DInputHandlerPrivate::~QAbstract3DInputHandlerPrivate()
+{
+
+}
+
+QT_DATAVISUALIZATION_END_NAMESPACE
diff --git a/src/datavisualization/input/qabstract3dinputhandler.h b/src/datavisualization/input/qabstract3dinputhandler.h
new file mode 100644
index 00000000..36f4ea21
--- /dev/null
+++ b/src/datavisualization/input/qabstract3dinputhandler.h
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc
+** All rights reserved.
+** For any questions to Digia, please use contact form at http://qt.digia.com
+**
+** This file is part of the QtDataVisualization module.
+**
+** Licensees holding valid Qt Enterprise licenses may use this file in
+** accordance with the Qt Enterprise License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia.
+**
+** If you have questions regarding the use of this file, please use
+** contact form at http://qt.digia.com
+**
+****************************************************************************/
+
+#ifndef QABSTRACT3DINPUTHANDLER_H
+#define QABSTRACT3DINPUTHANDLER_H
+
+#include "qdatavisualizationenums.h"
+#include "qabstract3dinputhandler_p.h"
+#include "q3dscene.h"
+#include <QObject>
+#include <QMouseEvent>
+
+QT_DATAVISUALIZATION_BEGIN_NAMESPACE
+
+class QT_DATAVISUALIZATION_EXPORT QAbstract3DInputHandler : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QtDataVisualization::QDataVis::InputState inputState READ inputState WRITE setInputState NOTIFY inputStateChanged)
+ Q_PROPERTY(QPoint inputPosition READ inputPosition WRITE setInputPosition NOTIFY positionChanged)
+ Q_PROPERTY(Q3DScene *scene READ scene WRITE setScene)
+
+public:
+ explicit QAbstract3DInputHandler(QObject *parent = 0);
+ virtual ~QAbstract3DInputHandler();
+
+ // Input event listeners
+ virtual void mouseDoubleClickEvent(QMouseEvent *event);
+ virtual void touchEvent(QTouchEvent *event);
+ virtual void mousePressEvent(QMouseEvent *event, const QPoint &mousePos);
+ virtual void mouseReleaseEvent(QMouseEvent *event, const QPoint &mousePos);
+ virtual void mouseMoveEvent(QMouseEvent *event, const QPoint &mousePos);
+ virtual void wheelEvent(QWheelEvent *event);
+
+public:
+ // Property get/set functions
+
+ // TODO: Check if the inputState needs to be visible outside of subclasses in the final architecture
+ QDataVis::InputState inputState();
+ void setInputState(QDataVis::InputState inputState);
+ void setInputPosition(const QPoint &position);
+ QPoint inputPosition() const;
+
+ Q3DScene *scene() const;
+ void setScene(Q3DScene *scene);
+
+protected:
+ void setPrevDistance(int distance);
+ int prevDistance() const;
+ void setPreviousInputPos(const QPoint &position);
+ QPoint previousInputPos() const;
+
+signals:
+ void positionChanged(const QPoint &position);
+ void inputStateChanged(QDataVis::InputState state);
+ void selectionAtPoint(const QPoint &point);
+
+private:
+ Q_DISABLE_COPY(QAbstract3DInputHandler)
+
+ QScopedPointer<QAbstract3DInputHandlerPrivate> d_ptr;
+
+ friend class Abstract3DController;
+};
+
+QT_DATAVISUALIZATION_END_NAMESPACE
+
+#endif // QABSTRACT3DINPUTHANDLER_H
diff --git a/src/datavisualization/input/qabstract3dinputhandler_p.h b/src/datavisualization/input/qabstract3dinputhandler_p.h
new file mode 100644
index 00000000..0ec6cfe9
--- /dev/null
+++ b/src/datavisualization/input/qabstract3dinputhandler_p.h
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc
+** All rights reserved.
+** For any questions to Digia, please use contact form at http://qt.digia.com
+**
+** This file is part of the QtDataVisualization module.
+**
+** Licensees holding valid Qt Enterprise licenses may use this file in
+** accordance with the Qt Enterprise License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia.
+**
+** If you have questions regarding the use of this file, please use
+** contact form at http://qt.digia.com
+**
+****************************************************************************/
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the QtDataVisualization API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+
+#ifndef QABSTRACT3DINPUTHANDLER_P_H
+#define QABSTRACT3DINPUTHANDLER_P_H
+
+#include "datavisualizationglobal_p.h"
+#include <QRect>
+
+QT_DATAVISUALIZATION_BEGIN_NAMESPACE
+
+class QAbstract3DInputHandler;
+class Q3DScene;
+
+class QAbstract3DInputHandlerPrivate
+{
+public:
+ QAbstract3DInputHandlerPrivate(QAbstract3DInputHandler *q);
+ ~QAbstract3DInputHandlerPrivate();
+
+public:
+ QAbstract3DInputHandler *q_ptr;
+ int m_prevDistance;
+ QPoint m_previousInputPos;
+
+ GLfloat m_defaultXRotation;
+ GLfloat m_defaultYRotation;
+
+private:
+ QDataVis::InputState m_inputState;
+ QPoint m_inputPosition;
+ QRect m_mainViewPort;
+
+ // TODO: Check if this could be avoided with signals/slots or some other way.
+ Q3DScene *m_scene;
+ bool m_isDefaultHandler;
+
+ friend class QAbstract3DInputHandler;
+ friend class Abstract3DController;
+};
+
+QT_DATAVISUALIZATION_END_NAMESPACE
+
+#endif // QABSTRACT3DINPUTHANDLER_P_H
diff --git a/src/datavisualization/input/qtouch3dinputhandler.cpp b/src/datavisualization/input/qtouch3dinputhandler.cpp
new file mode 100644
index 00000000..4df735a2
--- /dev/null
+++ b/src/datavisualization/input/qtouch3dinputhandler.cpp
@@ -0,0 +1,100 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc
+** All rights reserved.
+** For any questions to Digia, please use contact form at http://qt.digia.com
+**
+** This file is part of the QtDataVisualization module.
+**
+** Licensees holding valid Qt Enterprise licenses may use this file in
+** accordance with the Qt Enterprise License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia.
+**
+** If you have questions regarding the use of this file, please use
+** contact form at http://qt.digia.com
+**
+****************************************************************************/
+#include "qtouch3dinputhandler.h"
+#include "q3dcamera.h"
+
+QT_DATAVISUALIZATION_BEGIN_NAMESPACE
+
+QTouch3DInputHandler::QTouch3DInputHandler(QObject *parent) :
+ Q3DInputHandler(parent)
+{
+}
+
+QTouch3DInputHandler::~QTouch3DInputHandler()
+{
+}
+
+// Input event listeners
+void QTouch3DInputHandler::mouseDoubleClickEvent(QMouseEvent *event)
+{
+ if (!scene()->isSlicingActivated()) {
+ setInputState( QDataVis::InputOnScene );
+ // update mouse positions to prevent jumping when releasing or repressing a button
+ setInputPosition( event->pos() );
+ }
+}
+
+void QTouch3DInputHandler::touchEvent(QTouchEvent *event)
+{
+ QList<QTouchEvent::TouchPoint> points;
+ points = event->touchPoints();
+
+ if (!scene()->isSlicingActivated() && points.count() == 2) {
+ setInputState( QDataVis::InputOnPinch );
+
+ QPointF distance = points.at(0).pos() - points.at(1).pos();
+ int newDistance = distance.manhattanLength();
+ int zoomRate = 1;
+ int zoomLevel = scene()->camera()->zoomLevel();
+ if (zoomLevel > 100)
+ zoomRate = 5;
+ if (newDistance > prevDistance())
+ zoomLevel += zoomRate;
+ else
+ zoomLevel -= zoomRate;
+ if (zoomLevel > 500)
+ zoomLevel = 500;
+ else if (zoomLevel < 10)
+ zoomLevel = 10;
+ scene()->camera()->setZoomLevel(zoomLevel);
+ setPrevDistance(newDistance);
+ }
+}
+
+void QTouch3DInputHandler::mousePressEvent(QMouseEvent *event, const QPoint &mousePos)
+{
+ // TODO: This code needs revisiting with new Qt releases and possibly move to using touch events for these as well.
+ if (Qt::LeftButton == event->button()) {
+ if (scene()->isSlicingActivated()) {
+ if (scene()->isInputInsideMainView(mousePos)) {
+ setInputState(QDataVis::InputOnOverview);
+ //qDebug() << "Mouse pressed on overview";
+ } else if (scene()->isInputInsideSliceView(mousePos)) {
+ setInputState(QDataVis::InputOnSlice);
+ //qDebug() << "Mouse pressed on zoom";
+ } else {
+ setInputState(QDataVis::InputNone);
+ }
+ } else {
+ setInputState(QDataVis::InputRotating);
+ // update mouse positions to prevent jumping when releasing or repressing a button
+ setInputPosition(mousePos);
+ //qDebug() << "Mouse pressed on scene";
+ }
+ } else if (Qt::MiddleButton == event->button()) {
+ // reset rotations
+ setInputPosition(QPoint(0, 0));
+ } else if (Qt::RightButton == event->button()) {
+ // disable rotating when in slice view
+ setInputState(QDataVis::InputOnScene);
+ // update mouse positions to prevent jumping when releasing or repressing a button
+ setInputPosition(mousePos);
+ }
+}
+
+QT_DATAVISUALIZATION_END_NAMESPACE
diff --git a/src/datavisualization/input/qtouch3dinputhandler.h b/src/datavisualization/input/qtouch3dinputhandler.h
new file mode 100644
index 00000000..b915ff2a
--- /dev/null
+++ b/src/datavisualization/input/qtouch3dinputhandler.h
@@ -0,0 +1,45 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc
+** All rights reserved.
+** For any questions to Digia, please use contact form at http://qt.digia.com
+**
+** This file is part of the QtDataVisualization module.
+**
+** Licensees holding valid Qt Enterprise licenses may use this file in
+** accordance with the Qt Enterprise License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia.
+**
+** If you have questions regarding the use of this file, please use
+** contact form at http://qt.digia.com
+**
+****************************************************************************/
+
+#ifndef QTOUCH3DINPUTHANDLER_H
+#define QTOUCH3DINPUTHANDLER_H
+
+#include "q3dinputhandler.h"
+
+QT_DATAVISUALIZATION_BEGIN_NAMESPACE
+
+class QT_DATAVISUALIZATION_EXPORT QTouch3DInputHandler : public Q3DInputHandler
+{
+ Q_OBJECT
+
+public:
+ explicit QTouch3DInputHandler(QObject *parent = 0);
+ virtual ~QTouch3DInputHandler();
+
+ // Input event listeners
+ virtual void mouseDoubleClickEvent(QMouseEvent *event);
+ virtual void touchEvent(QTouchEvent *event);
+ virtual void mousePressEvent(QMouseEvent *event, const QPoint &mousePos);
+
+private:
+ Q_DISABLE_COPY(QTouch3DInputHandler)
+};
+
+QT_DATAVISUALIZATION_END_NAMESPACE
+
+#endif // QTOUCH3DINPUTHANDLER_H