diff options
Diffstat (limited to 'src/datavisualization/input/q3dinputhandler.cpp')
-rw-r--r-- | src/datavisualization/input/q3dinputhandler.cpp | 58 |
1 files changed, 36 insertions, 22 deletions
diff --git a/src/datavisualization/input/q3dinputhandler.cpp b/src/datavisualization/input/q3dinputhandler.cpp index 9e19df0c..17f5aee5 100644 --- a/src/datavisualization/input/q3dinputhandler.cpp +++ b/src/datavisualization/input/q3dinputhandler.cpp @@ -17,9 +17,8 @@ ****************************************************************************/ #include "datavisualizationglobal_p.h" -#include "q3dinputhandler.h" +#include "q3dinputhandler_p.h" #include "q3dcamera_p.h" -#include "q3dlight.h" QT_BEGIN_NAMESPACE_DATAVISUALIZATION @@ -44,20 +43,24 @@ const float rotationSpeed = 100.0f; * * Default input handler has the following functionalty: * \table - * \header - * \li Mouse action \li Action - * \row - * \li Drag with right button pressed \li Rotate graph within limits set for Q3DCamera. - * \row - * \li Left click \li Select item under cursor or remove selection if none. - * May open the secondary view depending on the - * selection mode. - * \row - * \li Mouse wheel \li Zoom in/out within default range (10...500%). - * \row - * \li Left click on the primary view when the secondary view is visible - * \li Closes the secondary view. - * \note Secondary view is available only for Q3DBars and Q3DSurface graphs. + * \header + * \li Mouse action + * \li Action + * \row + * \li Drag with right button pressed + * \li Rotate graph within limits set for Q3DCamera. + * \row + * \li Left click + * \li Select item under cursor or remove selection if none. + * May open the secondary view depending on the + * \l {QAbstract3DGraph::selectionMode}{selection mode}. + * \row + * \li Mouse wheel + * \li Zoom in/out within default range (10...500%). + * \row + * \li Left click on the primary view when the secondary view is visible + * \li Closes the secondary view. + * \note Secondary view is available only for Q3DBars and Q3DSurface graphs. * \endtable */ @@ -66,7 +69,8 @@ const float rotationSpeed = 100.0f; * and is then passed to QObject constructor. */ Q3DInputHandler::Q3DInputHandler(QObject *parent) : - QAbstract3DInputHandler(parent) + QAbstract3DInputHandler(parent), + d_ptr(new Q3DInputHandlerPrivate(this)) { } @@ -102,7 +106,7 @@ void Q3DInputHandler::mousePressEvent(QMouseEvent *event, const QPoint &mousePos setInputPosition(mousePos); scene()->setSelectionQueryPosition(mousePos); setInputView(InputViewOnPrimary); - setInputState(InputStateSelecting); + d_ptr->m_inputState = QAbstract3DInputHandlerPrivate::InputStateSelecting; } } else if (Qt::MiddleButton == event->button()) { // reset rotations @@ -110,7 +114,7 @@ void Q3DInputHandler::mousePressEvent(QMouseEvent *event, const QPoint &mousePos } else if (Qt::RightButton == event->button()) { // disable rotating when in slice view if (!scene()->isSlicingActive()) - setInputState(InputStateRotating); + d_ptr->m_inputState = QAbstract3DInputHandlerPrivate::InputStateRotating; // update mouse positions to prevent jumping when releasing or repressing a button setInputPosition(mousePos); } @@ -127,11 +131,11 @@ void Q3DInputHandler::mouseReleaseEvent(QMouseEvent *event, const QPoint &mouseP #if defined (Q_OS_ANDROID) Q_UNUSED(mousePos); #else - if (InputStateRotating == inputState()) { + if (QAbstract3DInputHandlerPrivate::InputStateRotating == d_ptr->m_inputState) { // update mouse positions to prevent jumping when releasing or repressing a button setInputPosition(mousePos); } - setInputState(InputStateNone); + d_ptr->m_inputState = QAbstract3DInputHandlerPrivate::InputStateNone; setInputView(InputViewNone); #endif } @@ -146,7 +150,7 @@ void Q3DInputHandler::mouseMoveEvent(QMouseEvent *event, const QPoint &mousePos) #if defined (Q_OS_ANDROID) Q_UNUSED(mousePos); #else - if (InputStateRotating == inputState()) { + if (QAbstract3DInputHandlerPrivate::InputStateRotating == d_ptr->m_inputState) { // Calculate mouse movement since last frame float xRotation = scene()->activeCamera()->xRotation(); float yRotation = scene()->activeCamera()->yRotation(); @@ -192,4 +196,14 @@ void Q3DInputHandler::wheelEvent(QWheelEvent *event) scene()->activeCamera()->setZoomLevel(zoomLevel); } +Q3DInputHandlerPrivate::Q3DInputHandlerPrivate(Q3DInputHandler *q) + : q_ptr(q), + m_inputState(QAbstract3DInputHandlerPrivate::InputStateNone) +{ +} + +Q3DInputHandlerPrivate::~Q3DInputHandlerPrivate() +{ +} + QT_END_NAMESPACE_DATAVISUALIZATION |