summaryrefslogtreecommitdiffstats
path: root/examples/datavisualization
diff options
context:
space:
mode:
authorTomi Korpipää <tomi.korpipaa@digia.com>2014-05-13 08:26:06 +0300
committerTomi Korpipää <tomi.korpipaa@digia.com>2014-05-13 08:40:48 +0300
commit604d8a652cc088a4b3a4307ec291916757e03201 (patch)
tree23ef89627b1bad166a8d9d611fee2cff9b8ac2bd /examples/datavisualization
parente5c7d46ba8c817e663d373fda191662b3276fdc6 (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')
-rw-r--r--examples/datavisualization/customitems/customitemgraph.cpp29
-rw-r--r--examples/datavisualization/customitems/customitemgraph.h7
-rw-r--r--examples/datavisualization/customitems/main.cpp15
3 files changed, 47 insertions, 4 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");
+ }
+}
diff --git a/examples/datavisualization/customitems/customitemgraph.h b/examples/datavisualization/customitems/customitemgraph.h
index a13e8620..aee32c62 100644
--- a/examples/datavisualization/customitems/customitemgraph.h
+++ b/examples/datavisualization/customitems/customitemgraph.h
@@ -24,6 +24,7 @@
#include <QtDataVisualization/QHeightMapSurfaceDataProxy>
#include <QtDataVisualization/QSurface3DSeries>
#include <QtWidgets/QSlider>
+#include <QtWidgets/QLabel>
using namespace QtDataVisualization;
@@ -31,7 +32,7 @@ class CustomItemGraph : public QObject
{
Q_OBJECT
public:
- explicit CustomItemGraph(Q3DSurface *surface);
+ explicit CustomItemGraph(Q3DSurface *surface, QLabel *label);
~CustomItemGraph();
void toggleItemOne(bool show);
@@ -42,7 +43,11 @@ public:
void toggleShadows(bool shadows);
private:
+ void handleElementSelected(QAbstract3DGraph::ElementType type);
+
+private:
Q3DSurface *m_graph;
+ QLabel *m_textField;
};
#endif
diff --git a/examples/datavisualization/customitems/main.cpp b/examples/datavisualization/customitems/main.cpp
index a37cc76f..fe2d0edc 100644
--- a/examples/datavisualization/customitems/main.cpp
+++ b/examples/datavisualization/customitems/main.cpp
@@ -65,10 +65,12 @@ int main(int argc, char **argv)
vLayoutLeft->addWidget(checkboxThree);
QLabel *label2 = new QLabel("Visuals:");
+ font.setBold(true);
label2->setFont(font);
vLayoutRight->addWidget(label2);
QCheckBox *checkboxOneRight = new QCheckBox("See-Through");
+ font.setBold(false);
checkboxOneRight->setFont(font);
vLayoutRight->addWidget(checkboxOneRight);
@@ -81,11 +83,22 @@ int main(int argc, char **argv)
checkboxThreeRight->setChecked(true);
vLayoutRight->addWidget(checkboxThreeRight);
+ QLabel *label3 = new QLabel("Selection:");
+ font.setBold(true);
+ label3->setFont(font);
+ vLayoutRight->addWidget(label3);
+
+ QLabel *label4 = new QLabel("Nothing");
+ font.setBold(false);
+ font.setPointSize(12);
+ label4->setFont(font);
+ vLayoutRight->addWidget(label4);
+
widget->setWindowTitle(QStringLiteral("Custom Items Example"));
widget->show();
- CustomItemGraph *modifier = new CustomItemGraph(graph);
+ CustomItemGraph *modifier = new CustomItemGraph(graph, label4);
QObject::connect(checkboxOne, &QCheckBox::stateChanged,
modifier, &CustomItemGraph::toggleItemOne);