diff options
author | Tomi Korpipää <tomi.korpipaa@digia.com> | 2014-05-21 10:10:36 +0300 |
---|---|---|
committer | Tomi Korpipää <tomi.korpipaa@digia.com> | 2014-05-21 10:12:29 +0300 |
commit | fdae1424df750bd02913b9ceec1716b1187b2ae7 (patch) | |
tree | 7a7e6448b5b0daa4f42162be6403016341b8103b /src/datavisualization | |
parent | 1fe989d12f8fe5c13675158044bb76551fb5eb0f (diff) |
Added enablers for axis dragging to QML
Task-number: QTRD-3003
Will add an example in a separate commit
Change-Id: I7fa9eb1b504d188c77b66ef8d4b2ee44416667e2
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@digia.com>
Diffstat (limited to 'src/datavisualization')
5 files changed, 79 insertions, 35 deletions
diff --git a/src/datavisualization/doc/src/qtdatavisualization-qml-abstractdeclarative.qdoc b/src/datavisualization/doc/src/qtdatavisualization-qml-abstractdeclarative.qdoc index a71bd28b..2af73021 100644 --- a/src/datavisualization/doc/src/qtdatavisualization-qml-abstractdeclarative.qdoc +++ b/src/datavisualization/doc/src/qtdatavisualization-qml-abstractdeclarative.qdoc @@ -201,55 +201,70 @@ /*! * \qmlmethod int AbstractGraph3D::selectedLabelIndex() * - * Can be used to query the index of the selected label after receiving elementSelected signal with - * any label type. Selection is valid until the next elementSelected signal. + * Can be used to query the index of the selected label after receiving \c selectedElementChanged + * signal with any label type. Selection is valid until the next \c selectedElementChanged signal. * * \return index of the selected label, or -1. * * \since Qt Data Visualization 1.1 + * + * \sa selectedElement */ /*! * \qmlmethod Abstract3DAxis AbstractGraph3D::selectedAxis() * - * Can be used to get the selected axis after receiving elementSelected signal with any label type. - * Selection is valid until the next elementSelected signal. + * Can be used to get the selected axis after receiving \c selectedElementChanged signal with any label + * type. Selection is valid until the next \c selectedElementChanged signal. * * \return the selected axis, or null. * * \since Qt Data Visualization 1.1 + * + * \sa selectedElement */ /*! * \qmlmethod int AbstractGraph3D::selectedCustomItemIndex() * - * Can be used to query the index of the selected custom item after receiving elementSelected signal - * with \l{QAbstract3DGraph::ElementCustomItem}{ElementCustomItem} type. Selection is valid until - * the next elementSelected signal. + * Can be used to query the index of the selected custom item after receiving \c selectedElementChanged + * signal with \l{QAbstract3DGraph::ElementCustomItem}{ElementCustomItem} type. Selection is valid + * until the next \c selectedElementChanged signal. * * \return index of the selected custom item, or -1. * * \since Qt Data Visualization 1.1 + * + * \sa selectedElement */ /*! * \qmlmethod Custom3DItem AbstractGraph3D::selectedCustomItem() * - * Can be used to get the selected custom item after receiving elementSelected signal with + * Can be used to get the selected custom item after receiving \c selectedElementChanged signal with * \l{QAbstract3DGraph::ElementCustomItem}{ElementCustomItem} type. Ownership of the item remains - * with the graph. Selection is valid until the next elementSelected signal. + * with the graph. Selection is valid until the next \c selectedElementChanged signal. * * \return the selected custom item, or null. * * \since Qt Data Visualization 1.1 + * + * \sa selectedElement */ -/*! \qmlsignal AbstractGraph3D::elementSelected(ElementType type) +/*! + * \qmlproperty AbstractGraph3D.ElementType AbstractGraph3D::selectedElement + * + * Can be used to query the selected element type. + * Type is valid until the next \c selectedElementChanged signal. + * + * \c selectedElementChanged signal is emitted when a selection is made in the graph. * - * Emits selection \a type when a selection is made in the graph. + * Signal can be used for example for implementing customized input handling, as demonstrated in + * this \l {Qt Quick 2 Axis Dragging Example}{example}. * * \sa selectedLabelIndex(), selectedAxis(), selectedCustomItemIndex(), selectedCustomItem(), - * Bars3D::selectedSeries, Scatter3D::selectedSeries, Surface3D::selectedSeries + * Bars3D::selectedSeries, Scatter3D::selectedSeries, Scene3D::selectionQueryPosition * * \since Qt Data Visualization 1.1 */ diff --git a/src/datavisualization/engine/abstract3dcontroller.cpp b/src/datavisualization/engine/abstract3dcontroller.cpp index 9ba39786..838d6926 100644 --- a/src/datavisualization/engine/abstract3dcontroller.cpp +++ b/src/datavisualization/engine/abstract3dcontroller.cpp @@ -1393,6 +1393,11 @@ QCustom3DItem *Abstract3DController::selectedCustomItem() const return item; } +QAbstract3DGraph::ElementType Abstract3DController::selectedElement() const +{ + return m_renderer->clickedType(); +} + void Abstract3DController::setOrthoProjection(bool enable) { if (enable != m_useOrthoProjection) { diff --git a/src/datavisualization/engine/abstract3dcontroller_p.h b/src/datavisualization/engine/abstract3dcontroller_p.h index e1b266ce..a5d00cff 100644 --- a/src/datavisualization/engine/abstract3dcontroller_p.h +++ b/src/datavisualization/engine/abstract3dcontroller_p.h @@ -320,6 +320,8 @@ public slots: inline bool measureFps() const { return m_measureFps; } inline qreal currentFps() const { return m_currentFps; } + QAbstract3DGraph::ElementType selectedElement() const; + void updateCustomItem(); signals: diff --git a/src/datavisualization/engine/qabstract3dgraph.cpp b/src/datavisualization/engine/qabstract3dgraph.cpp index 196460da..a232af6e 100644 --- a/src/datavisualization/engine/qabstract3dgraph.cpp +++ b/src/datavisualization/engine/qabstract3dgraph.cpp @@ -442,12 +442,14 @@ void QAbstract3DGraph::releaseCustomItem(QCustom3DItem *item) } /*! - * Can be used to query the index of the selected label after receiving elementSelected signal with - * any label type. Selection is valid until the next elementSelected signal. + * Can be used to query the index of the selected label after receiving \c selectedElementChanged + * signal with any label type. Selection is valid until the next \c selectedElementChanged signal. * * \return index of the selected label, or -1. * * \since Qt Data Visualization 1.1 + * + * \sa selectedElement */ int QAbstract3DGraph::selectedLabelIndex() const { @@ -455,12 +457,14 @@ int QAbstract3DGraph::selectedLabelIndex() const } /*! - * Can be used to get the selected axis after receiving elementSelected signal with any label type. - * Selection is valid until the next elementSelected signal. + * Can be used to get the selected axis after receiving \c selectedElementChanged signal with any label + * type. Selection is valid until the next \c selectedElementChanged signal. * * \return pointer to the selected axis, or null. * * \since Qt Data Visualization 1.1 + * + * \sa selectedElement */ QAbstract3DAxis *QAbstract3DGraph::selectedAxis() const { @@ -468,13 +472,15 @@ QAbstract3DAxis *QAbstract3DGraph::selectedAxis() const } /*! - * Can be used to query the index of the selected custom item after receiving elementSelected signal - * with QAbstract3DGraph::ElementCustomItem type. Selection is valid until the next elementSelected - * signal. + * Can be used to query the index of the selected custom item after receiving \c selectedElementChanged + * signal with QAbstract3DGraph::ElementCustomItem type. Selection is valid until the next + * \c selectedElementChanged signal. * * \return index of the selected custom item, or -1. * * \since Qt Data Visualization 1.1 + * + * \sa selectedElement */ int QAbstract3DGraph::selectedCustomItemIndex() const { @@ -482,13 +488,15 @@ int QAbstract3DGraph::selectedCustomItemIndex() const } /*! - * Can be used to get the selected custom item after receiving elementSelected signal with + * Can be used to get the selected custom item after receiving \c selectedElementChanged signal with * QAbstract3DGraph::ElementCustomItem type. Ownership of the item remains with the graph. - * Selection is valid until the next elementSelected signal. + * Selection is valid until the next \c selectedElementChanged signal. * * \return pointer to the selected custom item, or null. * * \since Qt Data Visualization 1.1 + * + * \sa selectedElement */ QCustom3DItem *QAbstract3DGraph::selectedCustomItem() const { @@ -496,6 +504,28 @@ QCustom3DItem *QAbstract3DGraph::selectedCustomItem() const } /*! + * \property QAbstract3DGraph::selectedElement + * + * Can be used to query the selected element type. + * Type is valid until the next \c selectedElementChanged signal. + * + * \c selectedElementChanged signal is emitted when a selection is made in the graph. + * + * Signal can be used for example for implementing custom input handlers, as demonstrated in this + * \l {Axis Range Dragging With Labels Example}{example}. + * + * \sa selectedLabelIndex(), selectedAxis(), selectedCustomItemIndex(), selectedCustomItem(), + * Q3DBars::selectedSeries(), Q3DScatter::selectedSeries(), Q3DSurface::selectedSeries(), + * Q3DScene::setSelectionQueryPosition() + * + * \since Qt Data Visualization 1.1 + */ +QAbstract3DGraph::ElementType QAbstract3DGraph::selectedElement() const +{ + return d_ptr->m_visualController->selectedElement(); +} + +/*! * Renders current frame to an image of \a imageSize. Default size is the window size. Image is * rendered with antialiasing level given in \a msaaSamples. Default level is \c{0}. * @@ -511,18 +541,6 @@ QImage QAbstract3DGraph::renderToImage(int msaaSamples, const QSize &imageSize) return d_ptr->renderToImage(msaaSamples, renderSize); } -/*! \fn QAbstract3DGraph::elementSelected(ElementType type) - * \since Qt Data Visualization 1.1 - * - * Emits selection \a type when a selection is made in the graph. - * - * Signal can be used for example for implementing custom input handlers, as demonstrated in this - * \l {Axis Range Dragging With Labels Example}{example}. - * - * \sa selectedLabelIndex(), selectedAxis(), selectedCustomItemIndex(), selectedCustomItem(), - * Q3DBars::selectedSeries(), Q3DScatter::selectedSeries(), Q3DSurface::selectedSeries() - */ - /*! * \property QAbstract3DGraph::measureFps * \since Qt Data Visualization 1.1 @@ -699,7 +717,7 @@ void QAbstract3DGraphPrivate::setVisualController(Abstract3DController *controll QObject::connect(m_visualController, &Abstract3DController::shadowQualityChanged, q_ptr, &QAbstract3DGraph::shadowQualityChanged); QObject::connect(m_visualController, &Abstract3DController::elementSelected, q_ptr, - &QAbstract3DGraph::elementSelected); + &QAbstract3DGraph::selectedElementChanged); QObject::connect(m_visualController, &Abstract3DController::needRender, this, &QAbstract3DGraphPrivate::renderLater); diff --git a/src/datavisualization/engine/qabstract3dgraph.h b/src/datavisualization/engine/qabstract3dgraph.h index 23dba269..23214c57 100644 --- a/src/datavisualization/engine/qabstract3dgraph.h +++ b/src/datavisualization/engine/qabstract3dgraph.h @@ -36,6 +36,7 @@ class QT_DATAVISUALIZATION_EXPORT QAbstract3DGraph : public QWindow, protected Q { Q_OBJECT Q_ENUMS(ShadowQuality) + Q_ENUMS(ElementType) Q_FLAGS(SelectionFlag SelectionFlags) Q_PROPERTY(QAbstract3DInputHandler* activeInputHandler READ activeInputHandler WRITE setActiveInputHandler NOTIFY activeInputHandlerChanged) Q_PROPERTY(Q3DTheme* activeTheme READ activeTheme WRITE setActiveTheme NOTIFY activeThemeChanged) @@ -45,6 +46,7 @@ class QT_DATAVISUALIZATION_EXPORT QAbstract3DGraph : public QWindow, protected Q Q_PROPERTY(bool measureFps READ measureFps WRITE setMeasureFps NOTIFY measureFpsChanged) Q_PROPERTY(qreal currentFps READ currentFps NOTIFY currentFpsChanged) Q_PROPERTY(bool orthoProjection READ isOrthoProjection WRITE setOrthoProjection NOTIFY orthoProjectionChanged) + Q_PROPERTY(ElementType selectedElement READ selectedElement NOTIFY selectedElementChanged) protected: explicit QAbstract3DGraph(QAbstract3DGraphPrivate *d, const QSurfaceFormat *format, @@ -131,6 +133,8 @@ public: void setOrthoProjection(bool enable); bool isOrthoProjection() const; + ElementType selectedElement() const; + protected: bool event(QEvent *event); void resizeEvent(QResizeEvent *event); @@ -148,7 +152,7 @@ signals: void activeThemeChanged(Q3DTheme *theme); void selectionModeChanged(QAbstract3DGraph::SelectionFlags mode); void shadowQualityChanged(QAbstract3DGraph::ShadowQuality quality); - void elementSelected(QAbstract3DGraph::ElementType type); + void selectedElementChanged(QAbstract3DGraph::ElementType type); void measureFpsChanged(bool enabled); void currentFpsChanged(qreal fps); void orthoProjectionChanged(bool enabled); |