summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@digia.com>2013-10-29 14:01:42 +0200
committerMiikka Heikkinen <miikka.heikkinen@digia.com>2013-10-30 10:06:08 +0200
commit84c156d3e2fcceeab608f401fbc638f2d01219b3 (patch)
tree74de2de1635c60645f4864d08f6afb941948aea8 /examples
parent233d5c02638903e96687d580ada7188f0e6a9756 (diff)
Selection overhaul
Selection modes are now proper flags, so you can easily mix and match item, row, and column modes as you wish. Slice flag means automatic slicing control - if user wishes to control slicing himself, he should not set this mode flag. Clicking an item on graph now emits clicked signal from renderer to controller on all graphs instead of setting the selected item. Controller will set the selected item based on this information. Task-number: QTRD-2366 Task-number: QTRD-2491 Change-Id: I6251c42e22ea676613fbd36685e33574e6eb9a1a Reviewed-by: Tomi Korpipää <tomi.korpipaa@digia.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/audiolevels/audiolevels.cpp2
-rw-r--r--examples/bars/graphmodifier.cpp7
-rw-r--r--examples/bars/main.cpp31
-rw-r--r--examples/customproxy/rainfallgraph.cpp2
-rw-r--r--examples/itemmodel/doc/src/itemmodel.qdoc2
-rw-r--r--examples/itemmodel/main.cpp8
-rw-r--r--examples/qmlbars/qml/qmlbars/main.qml6
-rw-r--r--examples/qmlsurface/qml/qmlsurface/main.qml2
-rw-r--r--examples/surface/surfacegraph.h10
9 files changed, 47 insertions, 23 deletions
diff --git a/examples/audiolevels/audiolevels.cpp b/examples/audiolevels/audiolevels.cpp
index 0922e664..307240c5 100644
--- a/examples/audiolevels/audiolevels.cpp
+++ b/examples/audiolevels/audiolevels.cpp
@@ -44,7 +44,7 @@ AudioLevels::AudioLevels(Q3DBars *graph, QObject *parent)
m_graph->valueAxis()->setSegmentCount(20);
m_graph->valueAxis()->setLabelFormat(QStringLiteral("%d%%"));
m_graph->setShadowQuality(QDataVis::ShadowQualityNone);
- m_graph->setSelectionMode(QDataVis::SelectionModeNone);
+ m_graph->setSelectionMode(QDataVis::SelectionNone);
m_graph->scene()->activeCamera()->setCameraPosition(-25.0, 10.0, 190.0);
m_graph->setTheme(QDataVis::ThemeIsabelle);
m_graph->setBarType(QDataVis::MeshStyleBars);
diff --git a/examples/bars/graphmodifier.cpp b/examples/bars/graphmodifier.cpp
index e2ace423..89c651ff 100644
--- a/examples/bars/graphmodifier.cpp
+++ b/examples/bars/graphmodifier.cpp
@@ -23,6 +23,7 @@
#include <QtDataVisualization/q3dscene.h>
#include <QtDataVisualization/q3dcamera.h>
#include <QTime>
+#include <QComboBox>
QT_DATAVISUALIZATION_USE_NAMESPACE
@@ -167,7 +168,11 @@ void GraphModifier::changeLabelStyle()
void GraphModifier::changeSelectionMode(int selectionMode)
{
- m_graph->setSelectionMode((QDataVis::SelectionMode)selectionMode);
+ QComboBox *comboBox = qobject_cast<QComboBox *>(sender());
+ if (comboBox) {
+ int flags = comboBox->itemData(selectionMode).toInt();
+ m_graph->setSelectionMode(QDataVis::SelectionFlags(flags));
+ }
}
void GraphModifier::changeFont(const QFont &font)
diff --git a/examples/bars/main.cpp b/examples/bars/main.cpp
index 158244b4..fc3737f6 100644
--- a/examples/bars/main.cpp
+++ b/examples/bars/main.cpp
@@ -84,13 +84,30 @@ int main(int argc, char **argv)
cameraButton->setText(QStringLiteral("Change camera preset"));
QComboBox *selectionModeList = new QComboBox(widget);
- selectionModeList->addItem(QStringLiteral("None"));
- selectionModeList->addItem(QStringLiteral("Bar"));
- selectionModeList->addItem(QStringLiteral("Bar and Row"));
- selectionModeList->addItem(QStringLiteral("Bar and Column"));
- selectionModeList->addItem(QStringLiteral("Bar, Row and Column"));
- selectionModeList->addItem(QStringLiteral("Slice into Row"));
- selectionModeList->addItem(QStringLiteral("Slice into Column"));
+ selectionModeList->addItem(QStringLiteral("None"),
+ int(QDataVis::SelectionNone));
+ selectionModeList->addItem(QStringLiteral("Bar"),
+ int(QDataVis::SelectionItem));
+ selectionModeList->addItem(QStringLiteral("Row"),
+ int(QDataVis::SelectionRow));
+ selectionModeList->addItem(QStringLiteral("Bar and Row"),
+ int(QDataVis::SelectionItemAndRow));
+ selectionModeList->addItem(QStringLiteral("Column"),
+ int(QDataVis::SelectionColumn));
+ selectionModeList->addItem(QStringLiteral("Bar and Column"),
+ int(QDataVis::SelectionItemAndColumn));
+ selectionModeList->addItem(QStringLiteral("Row and Column"),
+ int(QDataVis::SelectionRowAndColumn));
+ selectionModeList->addItem(QStringLiteral("Bar, Row and Column"),
+ int(QDataVis::SelectionItemRowAndColumn));
+ selectionModeList->addItem(QStringLiteral("Slice into Row"),
+ int(QDataVis::SelectionSlice | QDataVis::SelectionRow));
+ selectionModeList->addItem(QStringLiteral("Slice into Row and Item"),
+ int(QDataVis::SelectionSlice | QDataVis::SelectionItemAndRow));
+ selectionModeList->addItem(QStringLiteral("Slice into Column"),
+ int(QDataVis::SelectionSlice | QDataVis::SelectionColumn));
+ selectionModeList->addItem(QStringLiteral("Slice into Column and Item"),
+ int(QDataVis::SelectionSlice | QDataVis::SelectionItemAndColumn));
selectionModeList->setCurrentIndex(1);
QCheckBox *backgroundCheckBox = new QCheckBox(widget);
diff --git a/examples/customproxy/rainfallgraph.cpp b/examples/customproxy/rainfallgraph.cpp
index 3a9f820a..0327ecb9 100644
--- a/examples/customproxy/rainfallgraph.cpp
+++ b/examples/customproxy/rainfallgraph.cpp
@@ -69,7 +69,7 @@ RainfallGraph::RainfallGraph(Q3DBars *rainfall)
m_graph->setFont(QFont("Century Gothic", 30));
// Set selection mode to bar and column
- m_graph->setSelectionMode(QDataVis::SelectionModeSliceColumn);
+ m_graph->setSelectionMode(QDataVis::SelectionItemAndColumn | QDataVis::SelectionSlice);
// Set theme
m_graph->setTheme(QDataVis::ThemeArmyBlue);
diff --git a/examples/itemmodel/doc/src/itemmodel.qdoc b/examples/itemmodel/doc/src/itemmodel.qdoc
index 682ebb1f..6c192f6f 100644
--- a/examples/itemmodel/doc/src/itemmodel.qdoc
+++ b/examples/itemmodel/doc/src/itemmodel.qdoc
@@ -164,7 +164,7 @@
Now we'll find out what these were for.
The first one connects a signal from Q3DBars to the GraphDataGenerator. Signal
- Q3DBars::selectedBarPosChanged() is emitted when a bar is selected from the graph. We connect
+ Q3DBars::selectedBarChanged() is emitted when a bar is selected from the graph. We connect
that to a method in the data generator that selects the same data item in the table widget:
\snippet ../examples/itemmodel/main.cpp 13
diff --git a/examples/itemmodel/main.cpp b/examples/itemmodel/main.cpp
index fac6b442..5964992d 100644
--- a/examples/itemmodel/main.cpp
+++ b/examples/itemmodel/main.cpp
@@ -90,7 +90,7 @@ GraphDataGenerator::GraphDataGenerator(Q3DBars *bargraph, QTableWidget *tableWid
m_tableWidget->setColumnCount(m_columnCount);
// Set selection mode to full
- m_graph->setSelectionMode(QDataVis::SelectionModeItemRowAndColumn);
+ m_graph->setSelectionMode(QDataVis::SelectionItemRowAndColumn);
// Hide axis labels by explicitly setting one empty string as label list
m_graph->rowAxis()->setCategoryLabels(QStringList(QString()));
@@ -101,7 +101,7 @@ GraphDataGenerator::GraphDataGenerator(Q3DBars *bargraph, QTableWidget *tableWid
//! [6]
// Set selection mode to slice row
- m_graph->setSelectionMode(QDataVis::SelectionModeSliceRow);
+ m_graph->setSelectionMode(QDataVis::SelectionItemAndRow | QDataVis::SelectionSlice);
// Set font
m_graph->setFont(QFont("Impact", 20));
@@ -222,7 +222,7 @@ void GraphDataGenerator::selectedFromTable(int currentRow, int currentColumn,
{
Q_UNUSED(previousRow)
Q_UNUSED(previousColumn)
- m_graph->setSelectedBarPos(QPoint(currentRow, currentColumn));
+ m_graph->setSelectedBar(QPoint(currentRow, currentColumn));
}
//! [14]
@@ -273,7 +273,7 @@ int main(int argc, char **argv)
//! [3]
GraphDataGenerator generator(graph, tableWidget);
- QObject::connect(graph, &Q3DBars::selectedBarPosChanged, &generator,
+ QObject::connect(graph, &Q3DBars::selectedBarChanged, &generator,
&GraphDataGenerator::selectFromTable);
QObject::connect(tableWidget, &QTableWidget::currentCellChanged, &generator,
&GraphDataGenerator::selectedFromTable);
diff --git a/examples/qmlbars/qml/qmlbars/main.qml b/examples/qmlbars/qml/qmlbars/main.qml
index 5b1cc006..3d8aa7e0 100644
--- a/examples/qmlbars/qml/qmlbars/main.qml
+++ b/examples/qmlbars/qml/qmlbars/main.qml
@@ -46,7 +46,7 @@ Item {
width: dataView.width
height: dataView.height
shadowQuality: AbstractGraph3D.ShadowQualityMedium
- selectionMode: AbstractGraph3D.SelectionModeItem
+ selectionMode: AbstractGraph3D.SelectionItem
font.pointSize: 35
theme: AbstractGraph3D.ThemeRetro
labelStyle: AbstractGraph3D.LabelStyleFromTheme
@@ -59,7 +59,7 @@ Item {
valueAxis: graphAxes.expenses
itemLabelFormat: "@valueTitle for @colLabel, @rowLabel: @valueLabel"
- onSelectedBarPosChanged: {
+ onSelectedBarChanged: {
// Set tableView current row to selected bar
var rowRole = graphData.proxy.rowLabels[position.x];
var colRole = graphData.proxy.columnLabels[position.y];
@@ -161,7 +161,7 @@ Item {
onCurrentRowChanged: {
var rowIndex = graphData.proxy.activeMapping.rowCategoryIndex(graphData.model.get(currentRow).year)
var colIndex = graphData.proxy.activeMapping.columnCategoryIndex(graphData.model.get(currentRow).month)
- testGraph.selectedBarPos = Qt.point(rowIndex, colIndex)
+ testGraph.selectedBar = Qt.point(rowIndex, colIndex)
}
//! [2]
}
diff --git a/examples/qmlsurface/qml/qmlsurface/main.qml b/examples/qmlsurface/qml/qmlsurface/main.qml
index bc8d9499..b4ea17f6 100644
--- a/examples/qmlsurface/qml/qmlsurface/main.qml
+++ b/examples/qmlsurface/qml/qmlsurface/main.qml
@@ -51,7 +51,7 @@ Item {
height: surfaceView.height
theme: AbstractGraph3D.ThemeStoneMoss
shadowQuality: AbstractGraph3D.ShadowQualityMedium
- selectionMode: AbstractGraph3D.SelectionModeSliceRow
+ selectionMode: AbstractGraph3D.SelectionSlice | AbstractGraph3D.SelectionItemAndRow
smoothSurfaceEnabled: true
surfaceGridEnabled: false
font.family: "STCaiyun"
diff --git a/examples/surface/surfacegraph.h b/examples/surface/surfacegraph.h
index ac297bf6..ff0e5fc4 100644
--- a/examples/surface/surfacegraph.h
+++ b/examples/surface/surfacegraph.h
@@ -37,10 +37,12 @@ public:
void enableSqrtSinModel();
//! [0]
- void toggleModeNone() { m_graph->setSelectionMode(QDataVis::SelectionModeNone); }
- void toggleModeItem() { m_graph->setSelectionMode(QDataVis::SelectionModeItem); }
- void toggleModeSliceRow() { m_graph->setSelectionMode(QDataVis::SelectionModeSliceRow); }
- void toggleModeSliceColumn() { m_graph->setSelectionMode(QDataVis::SelectionModeSliceColumn); }
+ void toggleModeNone() { m_graph->setSelectionMode(QDataVis::SelectionNone); }
+ void toggleModeItem() { m_graph->setSelectionMode(QDataVis::SelectionItem); }
+ void toggleModeSliceRow() { m_graph->setSelectionMode(QDataVis::SelectionItemAndRow
+ | QDataVis::SelectionSlice); }
+ void toggleModeSliceColumn() { m_graph->setSelectionMode(QDataVis::SelectionItemAndColumn
+ | QDataVis::SelectionSlice); }
//! [0]
void setBlackToYellowGradient();