summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/qmlsurface/qml/qmlsurface/main.qml44
-rw-r--r--examples/surface/surfacegraph.cpp8
2 files changed, 27 insertions, 25 deletions
diff --git a/examples/qmlsurface/qml/qmlsurface/main.qml b/examples/qmlsurface/qml/qmlsurface/main.qml
index b2ab7768..a90b916e 100644
--- a/examples/qmlsurface/qml/qmlsurface/main.qml
+++ b/examples/qmlsurface/qml/qmlsurface/main.qml
@@ -58,8 +58,6 @@ Item {
}
shadowQuality: AbstractGraph3D.ShadowQualityMedium
selectionMode: AbstractGraph3D.SelectionSlice | AbstractGraph3D.SelectionItemAndRow
- smoothSurfaceEnabled: true
- surfaceGridEnabled: false
scene.activeCamera.cameraPreset: AbstractGraph3D.CameraPresetIsometricLeft
axisY.min: 0.0
axisY.max: 500.0
@@ -75,6 +73,8 @@ Item {
Surface3DSeries {
id: surfaceSeries
+ flatShadingEnabled: false
+ surfaceGridEnabled: false
ItemModelSurfaceDataProxy {
itemModel: surfaceData.model
@@ -82,16 +82,9 @@ Item {
columnRole: "latitude"
valueRole: "height"
}
- }
- // Since flat is not supported on all platforms, and changes back to smooth
- // asynchronously on those platforms, handle button text on changed
- // signal handler rather than when we set the value.
- onSmoothSurfaceEnabledChanged: {
- if (enabled === true) {
- smoothSurfaceToggle.text = "Show Flat"
- } else {
- smoothSurfaceToggle.text = "Show Smooth"
+ onFlatShadingSupportedChanged: {
+ flatShadingToggle.text = "Flat not supported"
}
}
}
@@ -100,6 +93,8 @@ Item {
// TODO: Kept outside until surface supports multiple added series (QTRD-2579)
Surface3DSeries {
id: heightSeries
+ flatShadingEnabled: false
+ surfaceGridEnabled: false
HeightMapSurfaceDataProxy {
heightMapFile: ":/heightmaps/image"
@@ -119,11 +114,13 @@ Item {
text: "Show Surface Grid"
//! [1]
onClicked: {
- if (surfaceplot.surfaceGridEnabled === false) {
- surfaceplot.surfaceGridEnabled = true;
+ if (surfaceSeries.surfaceGridEnabled === false) {
+ surfaceSeries.surfaceGridEnabled = true;
+ heightSeries.surfaceGridEnabled = true;
text = "Hide Surface Grid"
} else {
- surfaceplot.surfaceGridEnabled = false;
+ surfaceSeries.surfaceGridEnabled = false;
+ heightSeries.surfaceGridEnabled = false;
text = "Show Surface Grid"
}
}
@@ -136,7 +133,7 @@ Item {
width: surfaceGridToggle.width
text: "Hide Surface"
onClicked: {
- if (surfaceplot.seriesList[0].visible === true) {
+ if (surfaceSeries.visible === true) {
surfaceSeries.visible = false;
heightSeries.visible = false;
text = "Show Surface"
@@ -149,16 +146,21 @@ Item {
}
NewButton {
- id: smoothSurfaceToggle
+ id: flatShadingToggle
anchors.top: surfaceToggle.bottom
width: surfaceToggle.width
text: "Show Flat"
+ enabled: surfaceSeries.flatShadingSupported
//! [2]
onClicked: {
- if (surfaceplot.smoothSurfaceEnabled === true) {
- surfaceplot.smoothSurfaceEnabled = false;
+ if (surfaceSeries.flatShadingEnabled === true) {
+ surfaceSeries.flatShadingEnabled = false;
+ heightSeries.flatShadingEnabled = false;
+ text = "Show Flat"
} else {
- surfaceplot.smoothSurfaceEnabled = true;
+ surfaceSeries.flatShadingEnabled = true;
+ heightSeries.flatShadingEnabled = true;
+ text = "Show Smooth"
}
}
//! [2]
@@ -166,8 +168,8 @@ Item {
NewButton {
id: backgroundToggle
- anchors.top: smoothSurfaceToggle.bottom
- width: smoothSurfaceToggle.width
+ anchors.top: flatShadingToggle.bottom
+ width: flatShadingToggle.width
text: "Hide Background"
onClicked: {
if (surfaceplot.theme.backgroundEnabled === true) {
diff --git a/examples/surface/surfacegraph.cpp b/examples/surface/surfacegraph.cpp
index 7008a32b..be9e4573 100644
--- a/examples/surface/surfacegraph.cpp
+++ b/examples/surface/surfacegraph.cpp
@@ -91,8 +91,8 @@ void SurfaceGraph::enableSqrtSinModel(bool enable)
{
if (enable) {
//! [3]
- m_graph->setSurfaceGridEnabled(true);
- m_graph->setSmoothSurfaceEnabled(false);
+ m_sqrtSinSeries->setSurfaceGridEnabled(true);
+ m_sqrtSinSeries->setFlatShadingEnabled(true);
m_graph->axisX()->setLabelFormat("%.2f");
m_graph->axisZ()->setLabelFormat("%.2f");
@@ -124,8 +124,8 @@ void SurfaceGraph::enableHeightMapModel(bool enable)
{
if (enable) {
//! [4]
- m_graph->setSurfaceGridEnabled(false);
- m_graph->setSmoothSurfaceEnabled(true);
+ m_heightMapSeries->setSurfaceGridEnabled(false);
+ m_heightMapSeries->setFlatShadingEnabled(false);
m_graph->axisX()->setLabelFormat("%.1f N");
m_graph->axisZ()->setLabelFormat("%.1f E");