summaryrefslogtreecommitdiffstats
path: root/examples/qmlscatter/qml/qmlscatter/main.qml
diff options
context:
space:
mode:
authorMika Salmela <mika.salmela@digia.com>2013-12-18 11:50:03 +0200
committerMika Salmela <mika.salmela@digia.com>2013-12-18 11:51:20 +0200
commit07aba602fc82ac31684988f8e8e22521d2b3c982 (patch)
tree7ae1da139e8661bf157f996fe71844031d2995f4 /examples/qmlscatter/qml/qmlscatter/main.qml
parentcf0cf6ca67aec8ae480bb705443ea17f5ab9f9e2 (diff)
parentea0442bc81ae034d22c5742b6075dee993fdd54d (diff)
Merge branch 'develop' into mergebranch
Conflicts: examples/qmlbars/qml/qmlbars/main.qml examples/qmlscatter/qml/qmlscatter/main.qml examples/qmlsurface/qml/qmlsurface/main.qml src/datavisualization/data/qitemmodelbardatamapping.cpp src/datavisualization/data/qitemmodelscatterdatamapping.cpp src/datavisualization/data/qitemmodelsurfacedatamapping.cpp src/datavisualization/engine/drawer.cpp Change-Id: I731ebdb2cc5cee8f2cb32becee96d1fc1b3e5de1
Diffstat (limited to 'examples/qmlscatter/qml/qmlscatter/main.qml')
-rw-r--r--examples/qmlscatter/qml/qmlscatter/main.qml223
1 files changed, 145 insertions, 78 deletions
diff --git a/examples/qmlscatter/qml/qmlscatter/main.qml b/examples/qmlscatter/qml/qmlscatter/main.qml
index 7fd4ec84..22eab76b 100644
--- a/examples/qmlscatter/qml/qmlscatter/main.qml
+++ b/examples/qmlscatter/qml/qmlscatter/main.qml
@@ -18,6 +18,7 @@
//! [0]
import QtQuick 2.1
+import QtQuick.Layouts 1.0
import QtDataVisualization 1.0
import "."
//! [0]
@@ -30,10 +31,18 @@ Item {
//! [4]
Data {
- id: graphData
+ id: seriesOneData
}
//! [4]
+ Data {
+ id: seriesTwoData
+ }
+
+ Data {
+ id: seriesThreeData
+ }
+
//! [8]
//! [9]
Item {
@@ -41,7 +50,7 @@ Item {
anchors.bottom: parent.bottom
//! [9]
width: parent.width
- height: parent.height - shadowToggle.height
+ height: parent.height - buttonLayout.height
//! [8]
//! [2]
@@ -51,16 +60,14 @@ Item {
height: dataView.height
//! [2]
//! [3]
- font.family: "Lucida Handwriting"
- font.pointSize: 40
- theme: AbstractGraph3D.ThemeIsabelle
+ theme: Theme3D {
+ type: Theme3D.ThemeIsabelle
+ font.family: "Lucida Handwriting"
+ font.pointSize: 40
+ }
shadowQuality: AbstractGraph3D.ShadowQualitySoftLow
//! [3]
- //! [5]
- dataProxy: graphData.proxy
- //! [5]
//! [6]
- itemLabelFormat: "X:@xLabel Y:@yLabel Z:@zLabel"
axisX.segmentCount: 3
axisX.subSegmentCount: 2
axisX.labelFormat: "%.2f"
@@ -71,91 +78,151 @@ Item {
axisY.subSegmentCount: 2
axisY.labelFormat: "%.2f"
//! [6]
+ //! [5]
+ Scatter3DSeries {
+ id: scatterSeries
+ //! [5]
+ //! [10]
+ itemLabelFormat: "Series 1: X:@xLabel Y:@yLabel Z:@zLabel"
+ //! [10]
+
+ //! [11]
+ ItemModelScatterDataProxy {
+ itemModel: seriesOneData.model
+ xPosRole: "xPos"
+ yPosRole: "yPos"
+ zPosRole: "zPos"
+ }
+ //! [11]
+ }
+
+ //! [12]
+ Scatter3DSeries {
+ id: scatterSeriesTwo
+ itemLabelFormat: "Series 2: X:@xLabel Y:@yLabel Z:@zLabel"
+ itemSize: 0.1
+ mesh: Abstract3DSeries.MeshCube
+ //! [12]
+
+ ItemModelScatterDataProxy {
+ itemModel: seriesTwoData.modelTwo
+ xPosRole: "xPos"
+ yPosRole: "yPos"
+ zPosRole: "zPos"
+ }
+ }
+ Scatter3DSeries {
+ id: scatterSeriesThree
+ itemLabelFormat: "Series 3: X:@xLabel Y:@yLabel Z:@zLabel"
+ itemSize: 0.2
+ mesh: Abstract3DSeries.MeshMinimal
+
+ ItemModelScatterDataProxy {
+ itemModel: seriesThreeData.modelThree
+ xPosRole: "xPos"
+ yPosRole: "yPos"
+ zPosRole: "zPos"
+ }
+ }
}
}
- //! [7]
- NewButton {
- id: shadowToggle
- width: parent.width / 6 // We're adding 6 buttons and want to divide them equally
- text: "Hide Shadows"
- onClicked: {
- if (scatterGraph.shadowQuality === AbstractGraph3D.ShadowQualityNone) {
- scatterGraph.shadowQuality = AbstractGraph3D.ShadowQualitySoftLow;
- text = "Hide Shadows";
- } else {
- scatterGraph.shadowQuality = AbstractGraph3D.ShadowQualityNone;
- text = "Show Shadows";
+ RowLayout {
+ id: buttonLayout
+ Layout.minimumHeight: cameraToggle.height
+ width: parent.width
+ anchors.left: parent.left
+ spacing: 0
+ //! [7]
+ NewButton {
+ id: shadowToggle
+ Layout.fillHeight: true
+ Layout.fillWidth: true
+ text: "Hide Shadows"
+ onClicked: {
+ if (scatterGraph.shadowQuality === AbstractGraph3D.ShadowQualityNone) {
+ scatterGraph.shadowQuality = AbstractGraph3D.ShadowQualitySoftLow;
+ text = "Hide Shadows";
+ } else {
+ scatterGraph.shadowQuality = AbstractGraph3D.ShadowQualityNone;
+ text = "Show Shadows";
+ }
}
}
- }
- //! [7]
-
- NewButton {
- id: smoothToggle
- width: parent.width / 6
- text: "Use Smooth Dots"
- anchors.left: shadowToggle.right
- onClicked: {
- if (scatterGraph.objectSmoothingEnabled === false) {
- text = "Use Flat Dots";
- scatterGraph.objectSmoothingEnabled = true;
- } else {
- text = "Use Smooth Dots"
- scatterGraph.objectSmoothingEnabled = false;
+ //! [7]
+
+ NewButton {
+ id: smoothToggle
+ Layout.fillHeight: true
+ Layout.fillWidth: true
+ text: "Use Smooth for Series One"
+ onClicked: {
+ if (scatterSeries.meshSmooth === false) {
+ text = "Use Flat for Series One";
+ scatterSeries.meshSmooth = true;
+ } else {
+ text = "Use Smooth for Series One"
+ scatterSeries.meshSmooth = false;
+ }
}
}
- }
- NewButton {
- id: cameraToggle
- width: parent.width / 6
- text: "Change Camera Placement"
- anchors.left: smoothToggle.right
- onClicked: {
- if (scatterGraph.scene.activeCamera.cameraPreset === AbstractGraph3D.CameraPresetFront) {
- scatterGraph.scene.activeCamera.cameraPreset = AbstractGraph3D.CameraPresetIsometricRightHigh;
- } else {
- scatterGraph.scene.activeCamera.cameraPreset = AbstractGraph3D.CameraPresetFront;
+ NewButton {
+ id: cameraToggle
+ Layout.fillHeight: true
+ Layout.fillWidth: true
+ text: "Change Camera Placement"
+ onClicked: {
+ if (scatterGraph.scene.activeCamera.cameraPreset === Camera3D.CameraPresetFront) {
+ scatterGraph.scene.activeCamera.cameraPreset =
+ Camera3D.CameraPresetIsometricRightHigh;
+ } else {
+ scatterGraph.scene.activeCamera.cameraPreset = Camera3D.CameraPresetFront;
+ }
}
}
- }
- NewButton {
- id: themeToggle
- width: parent.width / 6
- text: "Change Theme"
- anchors.left: cameraToggle.right
- onClicked: {
- if (scatterGraph.theme === AbstractGraph3D.ThemeArmyBlue) {
- scatterGraph.theme = AbstractGraph3D.ThemeIsabelle;
- } else {
- scatterGraph.theme = AbstractGraph3D.ThemeArmyBlue;
+ NewButton {
+ id: themeToggle
+ Layout.fillHeight: true
+ Layout.fillWidth: true
+ text: "Change Theme"
+ onClicked: {
+ if (scatterGraph.theme.type === Theme3D.ThemeArmyBlue) {
+ // Ownership of the theme is transferred and old theme is destroyed when setting
+ // a new one, so we need to create them dynamically
+ scatterGraph.theme = Qt.createQmlObject('import QtDataVisualization 1.0;
+ Theme3D {type: Theme3D.ThemeIsabelle; font.family: "Lucida Handwriting";
+ font.pointSize: 40}', parent);
+ } else {
+ scatterGraph.theme = Qt.createQmlObject('import QtDataVisualization 1.0;
+ Theme3D {type: Theme3D.ThemeArmyBlue}', parent);
+ }
}
}
- }
- NewButton {
- id: backgroundToggle
- width: parent.width / 6
- text: "Hide Background"
- anchors.left: themeToggle.right
- onClicked: {
- if (scatterGraph.backgroundVisible === true) {
- scatterGraph.backgroundVisible = false;
- text = "Show Background";
- } else {
- scatterGraph.backgroundVisible = true;
- text = "Hide Background";
+ NewButton {
+ id: backgroundToggle
+ Layout.fillHeight: true
+ Layout.fillWidth: true
+ text: "Hide Background"
+ onClicked: {
+ if (scatterGraph.theme.backgroundEnabled === true) {
+ scatterGraph.theme.backgroundEnabled = false;
+ text = "Show Background";
+ } else {
+ scatterGraph.theme.backgroundEnabled = true;
+ text = "Hide Background";
+ }
}
}
- }
- NewButton {
- id: exitButton
- width: parent.width / 6
- text: "Quit"
- anchors.left: backgroundToggle.right
- onClicked: Qt.quit(0);
+ NewButton {
+ id: exitButton
+ Layout.fillHeight: true
+ Layout.fillWidth: true
+ text: "Quit"
+ onClicked: Qt.quit(0);
+ }
}
}