diff options
author | Tomi Korpipää <tomi.korpipaa@digia.com> | 2014-01-21 12:01:27 +0200 |
---|---|---|
committer | Tomi Korpipää <tomi.korpipaa@digia.com> | 2014-01-21 12:07:00 +0200 |
commit | 1b1dfcaadf83c73d3f7c1c1cd893894a3aea0ecb (patch) | |
tree | 776666dbf0368ec412fcbb154c2fe27076f6d404 /src | |
parent | 177f9d385c8cd062c4bad78cf6b794a96fa025ad (diff) |
InputState enum divided
Task-number: QTRD-2683
Change-Id: Ib05469ac1bf8c8ed828974a3adb91ecb5f8f1fc9
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@digia.com>
Diffstat (limited to 'src')
11 files changed, 85 insertions, 30 deletions
diff --git a/src/datavisualization/engine/abstract3dcontroller.cpp b/src/datavisualization/engine/abstract3dcontroller.cpp index 1efbea8d..2cda94e2 100644 --- a/src/datavisualization/engine/abstract3dcontroller.cpp +++ b/src/datavisualization/engine/abstract3dcontroller.cpp @@ -68,8 +68,8 @@ Abstract3DController::Abstract3DController(QRect initialViewport, Q3DScene *scen inputHandler = new QTouch3DInputHandler(); inputHandler->d_ptr->m_isDefaultHandler = true; setActiveInputHandler(inputHandler); - connect(inputHandler, &QAbstract3DInputHandler::inputStateChanged, this, - &Abstract3DController::handleInputStateChanged); + connect(inputHandler, &QAbstract3DInputHandler::inputViewChanged, this, + &Abstract3DController::handleInputViewChanged); connect(inputHandler, &QAbstract3DInputHandler::positionChanged, this, &Abstract3DController::handleInputPositionChanged); connect(m_scene->d_ptr.data(), &Q3DScenePrivate::needRender, this, @@ -863,15 +863,15 @@ void Abstract3DController::handleAxisLabelFormatChanged(const QString &format) handleAxisLabelFormatChangedBySender(sender()); } -void Abstract3DController::handleInputStateChanged(QAbstract3DInputHandler::InputState state) +void Abstract3DController::handleInputViewChanged(QAbstract3DInputHandler::InputView view) { - // When in automatic slicing mode, input state change to overview disables slice mode + // When in automatic slicing mode, input view change to primary disables slice mode if (m_selectionMode.testFlag(QAbstract3DGraph::SelectionSlice) - && state == QAbstract3DInputHandler::InputStateOnPrimaryView) { + && view == QAbstract3DInputHandler::InputViewOnPrimary) { setSlicingActive(false); } - m_changeTracker.inputStateChanged = true; + m_changeTracker.inputViewChanged = true; emitNeedRender(); } diff --git a/src/datavisualization/engine/abstract3dcontroller_p.h b/src/datavisualization/engine/abstract3dcontroller_p.h index 0b89251d..d0d2ea96 100644 --- a/src/datavisualization/engine/abstract3dcontroller_p.h +++ b/src/datavisualization/engine/abstract3dcontroller_p.h @@ -76,7 +76,7 @@ struct Abstract3DChangeBitField { bool axisXLabelFormatChanged : 1; bool axisYLabelFormatChanged : 1; bool axisZLabelFormatChanged : 1; - bool inputStateChanged : 1; + bool inputViewChanged : 1; bool inputPositionChanged : 1; Abstract3DChangeBitField() : @@ -243,7 +243,7 @@ public slots: void handleAxisSubSegmentCountChanged(int count); void handleAxisAutoAdjustRangeChanged(bool autoAdjust); void handleAxisLabelFormatChanged(const QString &format); - void handleInputStateChanged(QAbstract3DInputHandler::InputState state); + void handleInputViewChanged(QAbstract3DInputHandler::InputView view); void handleInputPositionChanged(const QPoint &position); void handleSeriesVisibilityChanged(bool visible); diff --git a/src/datavisualization/engine/bars3drenderer.cpp b/src/datavisualization/engine/bars3drenderer.cpp index e7fcf57e..17f61818 100644 --- a/src/datavisualization/engine/bars3drenderer.cpp +++ b/src/datavisualization/engine/bars3drenderer.cpp @@ -1001,6 +1001,8 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle) m_clickedPosition = selectionColorToArrayPosition(clickedColor); m_clickedSeries = selectionColorToSeries(clickedColor); + emit needRender(); + // Revert to original render target and viewport glBindFramebuffer(GL_FRAMEBUFFER, defaultFboHandle); glViewport(m_primarySubViewport.x(), diff --git a/src/datavisualization/engine/qabstract3dgraph.cpp b/src/datavisualization/engine/qabstract3dgraph.cpp index 29ceabc9..ebf2daac 100644 --- a/src/datavisualization/engine/qabstract3dgraph.cpp +++ b/src/datavisualization/engine/qabstract3dgraph.cpp @@ -159,6 +159,8 @@ QAbstract3DGraph::QAbstract3DGraph(QAbstract3DGraphPrivate *d, const QSurfaceFor QStringList splitversionstr = QString::fromLatin1((const char *)shaderVersion).split(QChar::fromLatin1(' ')); if (splitversionstr[0].toFloat() < 1.2) qFatal("GLSL version must be 1.20 or higher. Try installing latest display drivers."); +#else + Q_UNUSED(shaderVersion) #endif d_ptr->renderLater(); diff --git a/src/datavisualization/engine/scatter3drenderer.cpp b/src/datavisualization/engine/scatter3drenderer.cpp index 22910756..047b0aad 100644 --- a/src/datavisualization/engine/scatter3drenderer.cpp +++ b/src/datavisualization/engine/scatter3drenderer.cpp @@ -571,6 +571,8 @@ void Scatter3DRenderer::drawScene(const GLuint defaultFboHandle) m_viewport.height()); selectionColorToSeriesAndIndex(clickedColor, m_clickedIndex, m_clickedSeries); + emit needRender(); + // Revert to original fbo and viewport glBindFramebuffer(GL_FRAMEBUFFER, defaultFboHandle); glViewport(m_primarySubViewport.x(), diff --git a/src/datavisualization/engine/surface3drenderer.cpp b/src/datavisualization/engine/surface3drenderer.cpp index b65cea83..135e08e5 100644 --- a/src/datavisualization/engine/surface3drenderer.cpp +++ b/src/datavisualization/engine/surface3drenderer.cpp @@ -1051,6 +1051,8 @@ void Surface3DRenderer::drawScene(GLuint defaultFboHandle) m_clickedPosition = selectionIdToSurfacePoint(selectionId); m_clickedSeries = m_visibleSeriesList.at(0).series(); + emit needRender(); + // Revert to original viewport glViewport(m_primarySubViewport.x(), m_primarySubViewport.y(), diff --git a/src/datavisualization/input/q3dinputhandler.cpp b/src/datavisualization/input/q3dinputhandler.cpp index 27ebf89d..9e19df0c 100644 --- a/src/datavisualization/input/q3dinputhandler.cpp +++ b/src/datavisualization/input/q3dinputhandler.cpp @@ -91,17 +91,18 @@ void Q3DInputHandler::mousePressEvent(QMouseEvent *event, const QPoint &mousePos if (Qt::LeftButton == event->button()) { if (scene()->isSlicingActive()) { if (scene()->isPointInPrimarySubView(mousePos)) { - setInputState(InputStateOnPrimaryView); + setInputView(InputViewOnPrimary); } else if (scene()->isPointInSecondarySubView(mousePos)) { - setInputState(InputStateOnSecondaryView); + setInputView(InputViewOnSecondary); } else { - setInputState(InputStateNone); + setInputView(InputViewNone); } } else { - setInputState(InputStateOnScene); // update mouse positions to prevent jumping when releasing or repressing a button setInputPosition(mousePos); scene()->setSelectionQueryPosition(mousePos); + setInputView(InputViewOnPrimary); + setInputState(InputStateSelecting); } } else if (Qt::MiddleButton == event->button()) { // reset rotations @@ -131,6 +132,7 @@ void Q3DInputHandler::mouseReleaseEvent(QMouseEvent *event, const QPoint &mouseP setInputPosition(mousePos); } setInputState(InputStateNone); + setInputView(InputViewNone); #endif } diff --git a/src/datavisualization/input/qabstract3dinputhandler.cpp b/src/datavisualization/input/qabstract3dinputhandler.cpp index a0811f5b..a369a054 100644 --- a/src/datavisualization/input/qabstract3dinputhandler.cpp +++ b/src/datavisualization/input/qabstract3dinputhandler.cpp @@ -38,12 +38,6 @@ QT_BEGIN_NAMESPACE_DATAVISUALIZATION * * \value InputStateNone * Default "no input received" state. - * \value InputStateOnScene - * Mouse or touch input received on the 3D scene. - * \value InputStateOnPrimaryView - * Mouse or touch input received on the primary view area. - * \value InputStateOnSecondaryView - * Mouse or touch input received on the secondary view area. * \value InputStateRotating * Rotation of the 3D geometry ongoing. * \value InputStatePinching @@ -51,6 +45,19 @@ QT_BEGIN_NAMESPACE_DATAVISUALIZATION */ /*! + * \enum QAbstract3DInputHandler::InputView + * + * Predefined input views for mouse and touch based input handlers. + * + * \value InputViewNone + * Mouse or touch not on a view. + * \value InputViewOnPrimary + * Mouse or touch input received on the primary view area. + * \value InputViewOnSecondary + * Mouse or touch input received on the secondary view area. + */ + +/*! * \qmltype AbstractInputHandler3D * \inqmlmodule QtDataVisualization * \since QtDataVisualization 1.0 @@ -159,6 +166,25 @@ void QAbstract3DInputHandler::setInputState(InputState inputState) } /*! + * \property QAbstract3DInputHandler::inputView + * + * Current enumerated input view based on the view of the processed input events. + * When the view changes inputViewChanged() is emitted. + */ +QAbstract3DInputHandler::InputView QAbstract3DInputHandler::inputView() +{ + return d_ptr->m_inputView; +} + +void QAbstract3DInputHandler::setInputView(InputView inputView) +{ + if (inputView != d_ptr->m_inputView) { + d_ptr->m_inputView = inputView; + emit inputViewChanged(inputView); + } +} + +/*! * \property QAbstract3DInputHandler::inputPosition * * Last input position based on the processed input events. @@ -234,6 +260,7 @@ QAbstract3DInputHandlerPrivate::QAbstract3DInputHandlerPrivate(QAbstract3DInputH m_prevDistance(0), m_previousInputPos(QPoint(0,0)), m_inputState(QAbstract3DInputHandler::InputStateNone), + m_inputView(QAbstract3DInputHandler::InputViewNone), m_inputPosition(QPoint(0,0)), m_scene(0) { diff --git a/src/datavisualization/input/qabstract3dinputhandler.h b/src/datavisualization/input/qabstract3dinputhandler.h index f8b8ba88..47ae9e1c 100644 --- a/src/datavisualization/input/qabstract3dinputhandler.h +++ b/src/datavisualization/input/qabstract3dinputhandler.h @@ -30,20 +30,26 @@ class QT_DATAVISUALIZATION_EXPORT QAbstract3DInputHandler : public QObject { Q_OBJECT Q_ENUMS(InputState) + Q_ENUMS(InputView) Q_PROPERTY(InputState inputState READ inputState WRITE setInputState NOTIFY inputStateChanged) + Q_PROPERTY(InputView inputView READ inputView WRITE setInputView NOTIFY inputViewChanged) Q_PROPERTY(QPoint inputPosition READ inputPosition WRITE setInputPosition NOTIFY positionChanged) Q_PROPERTY(Q3DScene *scene READ scene WRITE setScene NOTIFY sceneChanged) public: enum InputState { InputStateNone = 0, - InputStateOnScene, - InputStateOnPrimaryView, - InputStateOnSecondaryView, + InputStateSelecting, InputStateRotating, InputStatePinching }; + enum InputView { + InputViewNone = 0, + InputViewOnPrimary, + InputViewOnSecondary + }; + public: explicit QAbstract3DInputHandler(QObject *parent = 0); virtual ~QAbstract3DInputHandler(); @@ -61,6 +67,10 @@ public: InputState inputState(); void setInputState(InputState inputState); + // TODO: Check if the inputView needs to be visible outside of subclasses in the final architecture + InputView inputView(); + void setInputView(InputView inputView); + QPoint inputPosition() const; void setInputPosition(const QPoint &position); @@ -70,6 +80,7 @@ public: signals: void positionChanged(QPoint position); void inputStateChanged(InputState state); + void inputViewChanged(InputView view); void sceneChanged(const Q3DScene *scene); protected: diff --git a/src/datavisualization/input/qabstract3dinputhandler_p.h b/src/datavisualization/input/qabstract3dinputhandler_p.h index 7e616ec2..c210feee 100644 --- a/src/datavisualization/input/qabstract3dinputhandler_p.h +++ b/src/datavisualization/input/qabstract3dinputhandler_p.h @@ -54,6 +54,7 @@ public: private: QAbstract3DInputHandler::InputState m_inputState; + QAbstract3DInputHandler::InputView m_inputView; QPoint m_inputPosition; QRect m_mainViewPort; diff --git a/src/datavisualization/input/qtouch3dinputhandler.cpp b/src/datavisualization/input/qtouch3dinputhandler.cpp index 909beb74..3fc5bea4 100644 --- a/src/datavisualization/input/qtouch3dinputhandler.cpp +++ b/src/datavisualization/input/qtouch3dinputhandler.cpp @@ -99,24 +99,27 @@ void QTouch3DInputHandler::touchEvent(QTouchEvent *event) if (event->type() == QEvent::TouchBegin) { if (scene()->isSlicingActive()) { if (scene()->isPointInPrimarySubView(pointerPos.toPoint())) - setInputState(InputStateOnPrimaryView); + setInputView(InputViewOnPrimary); else if (scene()->isPointInSecondarySubView(pointerPos.toPoint())) - setInputState(InputStateOnSecondaryView); + setInputView(InputViewOnSecondary); else - setInputState(InputStateNone); + setInputView(InputViewNone); } else { // Handle possible tap-and-hold selection d_ptr->m_startHoldPos = pointerPos; d_ptr->m_touchHoldPos = d_ptr->m_startHoldPos; d_ptr->m_holdTimer->start(); + setInputView(InputViewOnPrimary); // Start rotating setInputState(InputStateRotating); setInputPosition(pointerPos.toPoint()); } } else if (event->type() == QEvent::TouchEnd) { + setInputView(InputViewNone); d_ptr->m_holdTimer->stop(); // Handle possible selection - d_ptr->handleSelection(pointerPos); + if (QAbstract3DInputHandler::InputStatePinching != inputState()) + d_ptr->handleSelection(pointerPos); } else if (event->type() == QEvent::TouchUpdate) { if (!scene()->isSlicingActive()) { d_ptr->m_touchHoldPos = pointerPos; @@ -172,19 +175,22 @@ void QTouch3DInputHandlerPrivate::handleTapAndHold() QPointF distance = m_startHoldPos - m_touchHoldPos; if (distance.manhattanLength() < maxTapAndHoldJitter) { q_ptr->setInputPosition(m_touchHoldPos.toPoint()); - q_ptr->setInputState(QAbstract3DInputHandler::InputStateOnScene); + q_ptr->scene()->setSelectionQueryPosition(m_touchHoldPos.toPoint()); + q_ptr->setInputState(QAbstract3DInputHandler::InputStateSelecting); } } void QTouch3DInputHandlerPrivate::handleSelection(const QPointF &position) { QPointF distance = m_startHoldPos - position; - if (distance.manhattanLength() < maxSelectionJitter) - q_ptr->setInputState(QAbstract3DInputHandler::InputStateOnScene); - else + if (distance.manhattanLength() < maxSelectionJitter) { + q_ptr->setInputState(QAbstract3DInputHandler::InputStateSelecting); + q_ptr->scene()->setSelectionQueryPosition(position.toPoint()); + } else { q_ptr->setInputState(QAbstract3DInputHandler::InputStateNone); + q_ptr->setInputView(QAbstract3DInputHandler::InputViewNone); + } q_ptr->setPreviousInputPos(position.toPoint()); - q_ptr->scene()->setSelectionQueryPosition(position.toPoint()); } void QTouch3DInputHandlerPrivate::handleRotation(const QPointF &position) |