summaryrefslogtreecommitdiffstats
path: root/src/datavisualization
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@digia.com>2014-01-16 10:48:47 +0200
committerMiikka Heikkinen <miikka.heikkinen@digia.com>2014-01-16 11:01:10 +0200
commitd2c37e276d17fb91163188878988894df993e69b (patch)
tree75081e4f9ef26242213367aecd3eb49861e16e5f /src/datavisualization
parent3e7dc5bd1769e4578733f7ce0f4eba72346b6d98 (diff)
Implement generic clearSelection() method for graphs
Also fixed scene sync related bug on selection. Task-number: QTRD-2606 Task-number: QTRD-2773 Change-Id: I057fd83ae5bf5ee94e413287fb2b3cefa455b156 Reviewed-by: Tomi Korpipää <tomi.korpipaa@digia.com>
Diffstat (limited to 'src/datavisualization')
-rw-r--r--src/datavisualization/data/qbar3dseries.cpp16
-rw-r--r--src/datavisualization/data/qscatter3dseries.cpp16
-rw-r--r--src/datavisualization/data/qsurface3dseries.cpp16
-rw-r--r--src/datavisualization/doc/src/qtdatavisualization-qml-abstractdeclarative.qdoc6
-rw-r--r--src/datavisualization/engine/abstract3dcontroller_p.h2
-rw-r--r--src/datavisualization/engine/abstract3drenderer.cpp7
-rw-r--r--src/datavisualization/engine/bars3dcontroller.cpp5
-rw-r--r--src/datavisualization/engine/bars3dcontroller_p.h1
-rw-r--r--src/datavisualization/engine/qabstract3dgraph.cpp8
-rw-r--r--src/datavisualization/engine/qabstract3dgraph.h2
-rw-r--r--src/datavisualization/engine/scatter3dcontroller.cpp5
-rw-r--r--src/datavisualization/engine/scatter3dcontroller_p.h1
-rw-r--r--src/datavisualization/engine/surface3dcontroller.cpp5
-rw-r--r--src/datavisualization/engine/surface3dcontroller_p.h1
14 files changed, 76 insertions, 15 deletions
diff --git a/src/datavisualization/data/qbar3dseries.cpp b/src/datavisualization/data/qbar3dseries.cpp
index edee80f5..ff64aca7 100644
--- a/src/datavisualization/data/qbar3dseries.cpp
+++ b/src/datavisualization/data/qbar3dseries.cpp
@@ -95,16 +95,20 @@ namespace QtDataVisualization {
* Selects a bar at the \a position. The \a position is the (row, column) position in
* the data array of the series.
* Only one bar can be selected at a time.
- * To clear selection, set invalidSelectionPosition as the \a position.
+ * To clear selection from this series, set invalidSelectionPosition as the \a position.
* If this series is added to a graph, the graph can adjust the selection according to user
* interaction or if it becomes invalid. Selecting a bar on another added series will also
* clear the selection.
+ *
+ * \sa AbstractGraph3D::clearSelection()
*/
/*!
* \qmlproperty point Bar3DSeries::invalidSelectionPosition
* A constant property providing an invalid position for selection. Set this position to
- * selectedBar property if you want to clear the selection.
+ * selectedBar property if you want to clear the selection from this series.
+ *
+ * \sa AbstractGraph3D::clearSelection()
*/
/*!
@@ -164,10 +168,12 @@ QBarDataProxy *QBar3DSeries::dataProxy() const
* Selects a bar at the \a position. The \a position is the (row, column) position in
* the data array of the series.
* Only one bar can be selected at a time.
- * To clear selection, set invalidSelectionPosition() as the \a position.
+ * To clear selection from this series, set invalidSelectionPosition() as the \a position.
* If this series is added to a graph, the graph can adjust the selection according to user
* interaction or if it becomes invalid. Selecting a bar on another added series will also
* clear the selection.
+ *
+ * \sa QAbstract3DGraph::clearSelection()
*/
void QBar3DSeries::setSelectedBar(const QPoint &position)
{
@@ -185,7 +191,9 @@ QPoint QBar3DSeries::selectedBar() const
/*!
* \return an invalid position for selection. Set this position to selectedBar property if you
- * want to clear the selection.
+ * want to clear the selection from this series.
+ *
+ * \sa QAbstract3DGraph::clearSelection()
*/
QPoint QBar3DSeries::invalidSelectionPosition()
{
diff --git a/src/datavisualization/data/qscatter3dseries.cpp b/src/datavisualization/data/qscatter3dseries.cpp
index edc64989..89f37995 100644
--- a/src/datavisualization/data/qscatter3dseries.cpp
+++ b/src/datavisualization/data/qscatter3dseries.cpp
@@ -90,10 +90,12 @@ namespace QtDataVisualization {
*
* Selects an item at the \a index. The \a index is the index in the data array of the series.
* Only one item can be selected at a time.
- * To clear selection, set invalidSelectionIndex as the \a index.
+ * To clear selection from this series, set invalidSelectionIndex as the \a index.
* If this series is added to a graph, the graph can adjust the selection according to user
* interaction or if it becomes invalid. Selecting an item on another added series will also
* clear the selection.
+ *
+ * \sa AbstractGraph3D::clearSelection()
*/
/*!
@@ -107,7 +109,9 @@ namespace QtDataVisualization {
/*!
* \qmlproperty int Scatter3DSeries::invalidSelectionIndex
* A constant property providing an invalid index for selection. Set this index to
- * selectedItem property if you want to clear the selection.
+ * selectedItem property if you want to clear the selection from this series.
+ *
+ * \sa AbstractGraph3D::clearSelection()
*/
/*!
@@ -166,10 +170,12 @@ QScatterDataProxy *QScatter3DSeries::dataProxy() const
*
* Selects an item at the \a index. The \a index is the index in the data array of the series.
* Only one item can be selected at a time.
- * To clear selection, set invalidSelectionIndex() as the \a index.
+ * To clear selection from this series, set invalidSelectionIndex() as the \a index.
* If this series is added to a graph, the graph can adjust the selection according to user
* interaction or if it becomes invalid. Selecting an item on another added series will also
* clear the selection.
+ *
+ * \sa QAbstract3DGraph::clearSelection()
*/
void QScatter3DSeries::setSelectedItem(int index)
{
@@ -209,7 +215,9 @@ float QScatter3DSeries::itemSize() const
/*!
* \return an invalid index for selection. Set this index to selectedItem property if you
- * want to clear the selection.
+ * want to clear the selection from this series.
+ *
+ * \sa QAbstract3DGraph::clearSelection()
*/
int QScatter3DSeries::invalidSelectionIndex()
{
diff --git a/src/datavisualization/data/qsurface3dseries.cpp b/src/datavisualization/data/qsurface3dseries.cpp
index c34c1415..ec146e22 100644
--- a/src/datavisualization/data/qsurface3dseries.cpp
+++ b/src/datavisualization/data/qsurface3dseries.cpp
@@ -94,15 +94,19 @@ namespace QtDataVisualization {
* Selects a surface grid point in a \a position. The position is the (row, column) position in
* the data array of the series.
* Only one point can be selected at a time.
- * To clear selection, set invalidSelectionPosition as the \a position.
+ * To clear selection from this series, set invalidSelectionPosition as the \a position.
* If this series is added to a graph, the graph can adjust the selection according to user
* interaction or if it becomes invalid.
+ *
+ * \sa AbstractGraph3D::clearSelection()
*/
/*!
* \qmlproperty point Surface3DSeries::invalidSelectionPosition
* A constant property providing an invalid selection position.
- * Set this to selectedPoint property to clear the selection.
+ * Set this to selectedPoint property to clear the selection from this series.
+ *
+ * \sa AbstractGraph3D::clearSelection()
*/
/*!
@@ -201,9 +205,11 @@ QSurfaceDataProxy *QSurface3DSeries::dataProxy() const
* Selects a surface grid point in a \a position. The position is the (row, column) position in
* the data array of the series.
* Only one point can be selected at a time.
- * To clear selection, set invalidSelectionPosition() as the \a position.
+ * To clear selection from this series, set invalidSelectionPosition() as the \a position.
* If this series is added to a graph, the graph can adjust the selection according to user
* interaction or if it becomes invalid.
+ *
+ * \sa QAbstract3DGraph::clearSelection()
*/
void QSurface3DSeries::setSelectedPoint(const QPoint &position)
{
@@ -221,7 +227,9 @@ QPoint QSurface3DSeries::selectedPoint() const
/*!
* \return a QPoint signifying an invalid selection position. Set this to selectedPoint property
- * to clear the selection.
+ * to clear the selection from this series.
+ *
+ * \sa QAbstract3DGraph::clearSelection()
*/
QPoint QSurface3DSeries::invalidSelectionPosition()
{
diff --git a/src/datavisualization/doc/src/qtdatavisualization-qml-abstractdeclarative.qdoc b/src/datavisualization/doc/src/qtdatavisualization-qml-abstractdeclarative.qdoc
index 71be09a2..ee0c2427 100644
--- a/src/datavisualization/doc/src/qtdatavisualization-qml-abstractdeclarative.qdoc
+++ b/src/datavisualization/doc/src/qtdatavisualization-qml-abstractdeclarative.qdoc
@@ -82,3 +82,9 @@
\note If window clearing before rendering is suppressed, any areas of the window not fully
covered with opaque items may not draw properly.
*/
+
+/*!
+ * \qmlmethod void AbstractGraph3D::clearSelection()
+ * Clears selection from all attached series.
+ */
+
diff --git a/src/datavisualization/engine/abstract3dcontroller_p.h b/src/datavisualization/engine/abstract3dcontroller_p.h
index a11e80cd..aa3235ee 100644
--- a/src/datavisualization/engine/abstract3dcontroller_p.h
+++ b/src/datavisualization/engine/abstract3dcontroller_p.h
@@ -215,6 +215,8 @@ public:
void emitNeedRender();
+ virtual void clearSelection() = 0;
+
virtual void mouseDoubleClickEvent(QMouseEvent *event);
virtual void touchEvent(QTouchEvent *event);
virtual void mousePressEvent(QMouseEvent *event, const QPoint &mousePos);
diff --git a/src/datavisualization/engine/abstract3drenderer.cpp b/src/datavisualization/engine/abstract3drenderer.cpp
index 9b4ae6ab..6e286095 100644
--- a/src/datavisualization/engine/abstract3drenderer.cpp
+++ b/src/datavisualization/engine/abstract3drenderer.cpp
@@ -198,6 +198,10 @@ void Abstract3DRenderer::updateScene(Q3DScene *scene)
updateInputPosition(QPoint(logicalPixelPosition.x() * m_devicePixelRatio,
logicalPixelPosition.y() * m_devicePixelRatio));
+
+ // Synchronize the renderer scene to controller scene
+ scene->d_ptr->sync(*m_cachedScene->d_ptr);
+
if (Q3DScene::invalidSelectionPoint() == logicalPixelPosition) {
updateSelectionState(SelectNone);
} else {
@@ -215,9 +219,6 @@ void Abstract3DRenderer::updateScene(Q3DScene *scene)
updateSelectionState(SelectOnScene);
}
}
-
- // Synchronize the controller scene with renderer
- scene->d_ptr->sync(*m_cachedScene->d_ptr);
}
void Abstract3DRenderer::reInitShaders()
diff --git a/src/datavisualization/engine/bars3dcontroller.cpp b/src/datavisualization/engine/bars3dcontroller.cpp
index b152909d..a67f1adb 100644
--- a/src/datavisualization/engine/bars3dcontroller.cpp
+++ b/src/datavisualization/engine/bars3dcontroller.cpp
@@ -457,6 +457,11 @@ void Bars3DController::setSelectedBar(const QPoint &position, QBar3DSeries *seri
}
}
+void Bars3DController::clearSelection()
+{
+ setSelectedBar(invalidSelectionPosition(), 0);
+}
+
void Bars3DController::adjustAxisRanges()
{
QCategory3DAxis *categoryAxisZ = static_cast<QCategory3DAxis *>(m_axisZ);
diff --git a/src/datavisualization/engine/bars3dcontroller_p.h b/src/datavisualization/engine/bars3dcontroller_p.h
index 0632830e..79d3c3ba 100644
--- a/src/datavisualization/engine/bars3dcontroller_p.h
+++ b/src/datavisualization/engine/bars3dcontroller_p.h
@@ -92,6 +92,7 @@ public:
void setSelectionMode(QAbstract3DGraph::SelectionFlags mode);
void setSelectedBar(const QPoint &position, QBar3DSeries *series);
+ virtual void clearSelection();
virtual void handleAxisAutoAdjustRangeChangedInOrientation(QAbstract3DAxis::AxisOrientation orientation, bool autoAdjust);
virtual void handleSeriesVisibilityChangedBySender(QObject *sender);
diff --git a/src/datavisualization/engine/qabstract3dgraph.cpp b/src/datavisualization/engine/qabstract3dgraph.cpp
index ef6e1de5..af0dc7ad 100644
--- a/src/datavisualization/engine/qabstract3dgraph.cpp
+++ b/src/datavisualization/engine/qabstract3dgraph.cpp
@@ -331,6 +331,14 @@ Q3DScene *QAbstract3DGraph::scene() const
}
/*!
+ * Clears selection from all attached series.
+ */
+void QAbstract3DGraph::clearSelection()
+{
+ d_ptr->m_visualController->clearSelection();
+}
+
+/*!
* \internal
*/
bool QAbstract3DGraph::event(QEvent *event)
diff --git a/src/datavisualization/engine/qabstract3dgraph.h b/src/datavisualization/engine/qabstract3dgraph.h
index 9441544b..5383850e 100644
--- a/src/datavisualization/engine/qabstract3dgraph.h
+++ b/src/datavisualization/engine/qabstract3dgraph.h
@@ -95,6 +95,8 @@ public:
Q3DScene *scene() const;
+ void clearSelection();
+
protected:
bool event(QEvent *event);
void resizeEvent(QResizeEvent *event);
diff --git a/src/datavisualization/engine/scatter3dcontroller.cpp b/src/datavisualization/engine/scatter3dcontroller.cpp
index b2964c9c..3c577fe2 100644
--- a/src/datavisualization/engine/scatter3dcontroller.cpp
+++ b/src/datavisualization/engine/scatter3dcontroller.cpp
@@ -267,6 +267,11 @@ void Scatter3DController::setSelectedItem(int index, QScatter3DSeries *series)
}
}
+void Scatter3DController::clearSelection()
+{
+ setSelectedItem(invalidSelectionIndex(), 0);
+}
+
void Scatter3DController::adjustValueAxisRange()
{
QValue3DAxis *valueAxisX = static_cast<QValue3DAxis *>(m_axisX);
diff --git a/src/datavisualization/engine/scatter3dcontroller_p.h b/src/datavisualization/engine/scatter3dcontroller_p.h
index 8bc43636..2a37e343 100644
--- a/src/datavisualization/engine/scatter3dcontroller_p.h
+++ b/src/datavisualization/engine/scatter3dcontroller_p.h
@@ -73,6 +73,7 @@ public:
void setSelectedItem(int index, QScatter3DSeries *series);
static inline int invalidSelectionIndex() { return -1; }
+ virtual void clearSelection();
void synchDataToRenderer();
diff --git a/src/datavisualization/engine/surface3dcontroller.cpp b/src/datavisualization/engine/surface3dcontroller.cpp
index 7ed69466..ca546a74 100644
--- a/src/datavisualization/engine/surface3dcontroller.cpp
+++ b/src/datavisualization/engine/surface3dcontroller.cpp
@@ -280,6 +280,11 @@ void Surface3DController::setSelectedPoint(const QPoint &position, QSurface3DSer
}
}
+void Surface3DController::clearSelection()
+{
+ setSelectedPoint(invalidSelectionPosition(), 0);
+}
+
void Surface3DController::handleArrayReset()
{
QSurface3DSeries *series = static_cast<QSurfaceDataProxy *>(sender())->series();
diff --git a/src/datavisualization/engine/surface3dcontroller_p.h b/src/datavisualization/engine/surface3dcontroller_p.h
index dcd55982..d823bd85 100644
--- a/src/datavisualization/engine/surface3dcontroller_p.h
+++ b/src/datavisualization/engine/surface3dcontroller_p.h
@@ -78,6 +78,7 @@ public:
void setSelectionMode(QAbstract3DGraph::SelectionFlags mode);
void setSelectedPoint(const QPoint &position, QSurface3DSeries *series);
+ virtual void clearSelection();
virtual void handleAxisAutoAdjustRangeChangedInOrientation(
QAbstract3DAxis::AxisOrientation orientation, bool autoAdjust);