diff options
author | Tomi Korpipää <tomi.korpipaa@digia.com> | 2014-05-13 08:26:06 +0300 |
---|---|---|
committer | Tomi Korpipää <tomi.korpipaa@digia.com> | 2014-05-13 08:40:48 +0300 |
commit | 604d8a652cc088a4b3a4307ec291916757e03201 (patch) | |
tree | 23ef89627b1bad166a8d9d611fee2cff9b8ac2bd /examples/datavisualization/customitems/customitemgraph.cpp | |
parent | e5c7d46ba8c817e663d373fda191662b3276fdc6 (diff) |
API to query custom item selection
Task-number: QTRD-3046
+ Added missing elementSelected signal to QML
Change-Id: I5e79d8e910d2730e3d2ae5550ce576f01aac0b18
Change-Id: I5e79d8e910d2730e3d2ae5550ce576f01aac0b18
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@digia.com>
Diffstat (limited to 'examples/datavisualization/customitems/customitemgraph.cpp')
-rw-r--r-- | examples/datavisualization/customitems/customitemgraph.cpp | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/examples/datavisualization/customitems/customitemgraph.cpp b/examples/datavisualization/customitems/customitemgraph.cpp index c2479a9a..0a757e7d 100644 --- a/examples/datavisualization/customitems/customitemgraph.cpp +++ b/examples/datavisualization/customitems/customitemgraph.cpp @@ -24,8 +24,9 @@ using namespace QtDataVisualization; -CustomItemGraph::CustomItemGraph(Q3DSurface *surface) - : m_graph(surface) +CustomItemGraph::CustomItemGraph(Q3DSurface *surface, QLabel *label) + : m_graph(surface), + m_textField(label) { QImage layerOneHMap(":/maps/layer_1.png"); QHeightMapSurfaceDataProxy *layerOneProxy = new QHeightMapSurfaceDataProxy(layerOneHMap); @@ -87,6 +88,9 @@ CustomItemGraph::CustomItemGraph(Q3DSurface *surface) m_graph->seriesList().at(2)->setColorStyle(Q3DTheme::ColorStyleRangeGradient); m_graph->scene()->activeCamera()->setCameraPreset(Q3DCamera::CameraPresetFront); + + connect(m_graph, &QAbstract3DGraph::elementSelected, + this, &CustomItemGraph::handleElementSelected); } CustomItemGraph::~CustomItemGraph() @@ -189,3 +193,24 @@ void CustomItemGraph::toggleShadows(bool shadows) else m_graph->setShadowQuality(QAbstract3DGraph::ShadowQualityNone); } + +void CustomItemGraph::handleElementSelected(QAbstract3DGraph::ElementType type) +{ + if (type == QAbstract3DGraph::ElementCustomItem) { + int index = m_graph->selectedCustomItemIndex(); + QCustom3DItem *item = m_graph->selectedCustomItem(); + QString text; + text.setNum(index); + text.append(": "); + QStringList split = item->meshFile().split("/"); + text.append(split.last()); + m_textField->setText(text); + } else if (type == QAbstract3DGraph::ElementSeries) { + m_textField->setText("Surface"); + } else if (type > QAbstract3DGraph::ElementSeries + && type < QAbstract3DGraph::ElementCustomItem) { + m_textField->setText("Axis"); + } else { + m_textField->setText("Nothing"); + } +} |