summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/datavisualization/customitems/customitemgraph.cpp3
-rw-r--r--examples/datavisualization/draggableaxes/axesinputhandler.cpp2
-rw-r--r--src/datavisualization/doc/src/qtdatavisualization-qml-abstractdeclarative.qdoc39
-rw-r--r--src/datavisualization/engine/abstract3dcontroller.cpp5
-rw-r--r--src/datavisualization/engine/abstract3dcontroller_p.h2
-rw-r--r--src/datavisualization/engine/qabstract3dgraph.cpp62
-rw-r--r--src/datavisualization/engine/qabstract3dgraph.h6
-rw-r--r--src/datavisualizationqml2/abstractdeclarative.cpp7
-rw-r--r--src/datavisualizationqml2/abstractdeclarative_p.h15
-rw-r--r--src/datavisualizationqml2/datavisualizationqml2_plugin.cpp3
10 files changed, 104 insertions, 40 deletions
diff --git a/examples/datavisualization/customitems/customitemgraph.cpp b/examples/datavisualization/customitems/customitemgraph.cpp
index be51f1f0..ca6a46ef 100644
--- a/examples/datavisualization/customitems/customitemgraph.cpp
+++ b/examples/datavisualization/customitems/customitemgraph.cpp
@@ -90,7 +90,7 @@ CustomItemGraph::CustomItemGraph(Q3DSurface *surface, QLabel *label)
m_graph->scene()->activeCamera()->setCameraPreset(Q3DCamera::CameraPresetFront);
- connect(m_graph, &QAbstract3DGraph::elementSelected,
+ connect(m_graph, &QAbstract3DGraph::selectedElementChanged,
this, &CustomItemGraph::handleElementSelected);
m_selectionAnimation = new QPropertyAnimation(this);
@@ -237,7 +237,6 @@ void CustomItemGraph::handleElementSelected(QAbstract3DGraph::ElementType type)
m_selectionAnimation->setStartValue(item->scaling());
m_selectionAnimation->setEndValue(item->scaling() * 1.5f);
m_selectionAnimation->start();
- item->setShadowCasting(false);
} else if (type == QAbstract3DGraph::ElementSeries) {
QString text = "Surface (";
QSurface3DSeries *series = m_graph->selectedSeries();
diff --git a/examples/datavisualization/draggableaxes/axesinputhandler.cpp b/examples/datavisualization/draggableaxes/axesinputhandler.cpp
index 70086b1c..ef7b871b 100644
--- a/examples/datavisualization/draggableaxes/axesinputhandler.cpp
+++ b/examples/datavisualization/draggableaxes/axesinputhandler.cpp
@@ -30,7 +30,7 @@ AxesInputHandler::AxesInputHandler(QAbstract3DGraph *graph, QObject *parent) :
{
//! [3]
// Connect to the item selection signal from graph
- connect(graph, &QAbstract3DGraph::elementSelected, this,
+ connect(graph, &QAbstract3DGraph::selectedElementChanged, this,
&AxesInputHandler::handleElementSelected);
//! [3]
}
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);
diff --git a/src/datavisualizationqml2/abstractdeclarative.cpp b/src/datavisualizationqml2/abstractdeclarative.cpp
index 47d3bb66..c09204da 100644
--- a/src/datavisualizationqml2/abstractdeclarative.cpp
+++ b/src/datavisualizationqml2/abstractdeclarative.cpp
@@ -309,7 +309,7 @@ void AbstractDeclarative::setSharedController(Abstract3DController *controller)
QObject::connect(m_controller.data(), &Abstract3DController::selectionModeChanged, this,
&AbstractDeclarative::handleSelectionModeChange);
QObject::connect(m_controller.data(), &Abstract3DController::elementSelected, this,
- &AbstractDeclarative::elementSelected);
+ &AbstractDeclarative::selectedElementChanged);
QObject::connect(m_controller.data(), &Abstract3DController::axisXChanged, this,
&AbstractDeclarative::handleAxisXChanged);
@@ -682,6 +682,11 @@ bool AbstractDeclarative::isOrthoProjection() const
return m_controller->isOrthoProjection();
}
+AbstractDeclarative::ElementType AbstractDeclarative::selectedElement() const
+{
+ return ElementType(m_controller->selectedElement());
+}
+
void AbstractDeclarative::windowDestroyed(QObject *obj)
{
// Remove destroyed window from window lists
diff --git a/src/datavisualizationqml2/abstractdeclarative_p.h b/src/datavisualizationqml2/abstractdeclarative_p.h
index 8095e87a..2cdcafc8 100644
--- a/src/datavisualizationqml2/abstractdeclarative_p.h
+++ b/src/datavisualizationqml2/abstractdeclarative_p.h
@@ -57,6 +57,7 @@ class AbstractDeclarative : public QQuickItem
Q_OBJECT
Q_ENUMS(ShadowQuality)
Q_ENUMS(RenderingMode)
+ Q_ENUMS(ElementType)
Q_FLAGS(SelectionFlag SelectionFlags)
Q_PROPERTY(SelectionFlags selectionMode READ selectionMode WRITE setSelectionMode NOTIFY selectionModeChanged)
Q_PROPERTY(ShadowQuality shadowQuality READ shadowQuality WRITE setShadowQuality NOTIFY shadowQualityChanged)
@@ -70,6 +71,7 @@ class AbstractDeclarative : public QQuickItem
Q_PROPERTY(qreal currentFps READ currentFps NOTIFY currentFpsChanged REVISION 1)
Q_PROPERTY(QQmlListProperty<QCustom3DItem> customItemList READ customItemList REVISION 1)
Q_PROPERTY(bool orthoProjection READ isOrthoProjection WRITE setOrthoProjection NOTIFY orthoProjectionChanged REVISION 1)
+ Q_PROPERTY(ElementType selectedElement READ selectedElement NOTIFY selectedElementChanged REVISION 1)
public:
enum SelectionFlag {
@@ -96,6 +98,15 @@ public:
ShadowQualitySoftHigh
};
+ enum ElementType {
+ ElementNone = 0,
+ ElementSeries,
+ ElementAxisXLabel,
+ ElementAxisZLabel,
+ ElementAxisYLabel,
+ ElementCustomItem
+ };
+
enum RenderingMode {
RenderDirectToBackground = 0,
RenderDirectToBackground_NoClear,
@@ -168,6 +179,8 @@ public:
void setOrthoProjection(bool enable);
bool isOrthoProjection() const;
+ AbstractDeclarative::ElementType selectedElement() const;
+
public slots:
virtual void handleAxisXChanged(QAbstract3DAxis *axis) = 0;
virtual void handleAxisYChanged(QAbstract3DAxis *axis) = 0;
@@ -199,7 +212,7 @@ signals:
void renderingModeChanged(AbstractDeclarative::RenderingMode mode);
Q_REVISION(1) void measureFpsChanged(bool enabled);
Q_REVISION(1) void currentFpsChanged(qreal fps);
- Q_REVISION(1) void elementSelected(QAbstract3DGraph::ElementType type);
+ Q_REVISION(1) void selectedElementChanged(QAbstract3DGraph::ElementType type);
Q_REVISION(1) void orthoProjectionChanged(bool enabled);
private:
diff --git a/src/datavisualizationqml2/datavisualizationqml2_plugin.cpp b/src/datavisualizationqml2/datavisualizationqml2_plugin.cpp
index f90ffb4b..fd45bdca 100644
--- a/src/datavisualizationqml2/datavisualizationqml2_plugin.cpp
+++ b/src/datavisualizationqml2/datavisualizationqml2_plugin.cpp
@@ -102,6 +102,9 @@ void QtDataVisualizationQml2Plugin::registerTypes(const char *uri)
qmlRegisterType<QValue3DAxisFormatter>(uri, 1, 1, "ValueAxis3DFormatter");
qmlRegisterType<QLogValue3DAxisFormatter>(uri, 1, 1, "LogValueAxis3DFormatter");
qmlRegisterType<QCustom3DItem>(uri, 1, 1, "Custom3DItem");
+
+ // New metatypes
+ qRegisterMetaType<QAbstract3DGraph::ElementType>("QAbstract3DGraph::ElementType");
}
QT_END_NAMESPACE_DATAVISUALIZATION