Sophie

Sophie

distrib > Mageia > 7 > armv7hl > media > core-updates > by-pkgid > 845e36bb3ecce380666d628d88446962 > files > 332

qtdatavis3d5-doc-5.12.6-1.mga7.noarch.rpm

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qmlsurfacelayers.qdoc -->
  <title>Qt Quick 2 Surface Multiseries Example | Qt Data Visualization 5.12.6</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td >Qt 5.12</td><td ><a href="qtdatavisualization-index.html">Qt Data Visualization</a></td><td >Qt Quick 2 Surface Multiseries Example</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right"><a href="qtdatavisualization-index.html">Qt Data Visualization | Commercial or GPLv3</a></td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#running-the-example">Running the Example</a></li>
<li class="level1"><a href="#adding-data-to-the-graph">Adding Data to the Graph</a></li>
<li class="level1"><a href="#controlling-the-graph">Controlling the Graph</a></li>
<li class="level1"><a href="#example-contents">Example Contents</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">Qt Quick 2 Surface Multiseries Example</h1>
<span class="subtitle"></span>
<!-- $$$qmlsurfacelayers-brief -->
<p>Using multiple series with <a href="qml-qtdatavisualization-surface3d.html">Surface3D</a> in a QML application.</p>
<!-- @@@qmlsurfacelayers -->
<!-- $$$qmlsurfacelayers-description -->
<div class="descr"> <a name="details"></a>
<p>The Qt Quick 2 surface example shows how to make a 3D surface plot displaying 3 layers using <a href="qml-qtdatavisualization-surface3d.html">Surface3D</a> with Qt Quick 2.</p>
<p class="centerAlign"><img src="images/qmlsurfacelayers-example.png" alt="" /></p><p>The focus in this example is on generating a multiseries surface plot from 3 different height map images, so in this section we skip explaining the application creation. For a more detailed QML example documentation, see <a href="qtdatavisualization-qmlscatter-example.html">Qt Quick 2 Scatter Example</a>.</p>
<a name="running-the-example"></a>
<h2 id="running-the-example">Running the Example</h2>
<p>To run the example from Qt Creator, open the <b>Welcome</b> mode and select the example from <b>Examples</b>. For more information, visit Building and Running an Example.</p>
<a name="adding-data-to-the-graph"></a>
<h2 id="adding-data-to-the-graph">Adding Data to the Graph</h2>
<p>This example shows how to add several surface series to one graph using using HeightMapSurfaceDataProxies and how to control their visibilities individually.</p>
<p>Let's start by creating a specific gradient for each layer:</p>
<pre class="qml">

  ColorGradient {
      id: layerOneGradient
      ColorGradientStop { position: 0.0; color: "black" }
      ColorGradientStop { position: 0.31; color: "tan" }
      ColorGradientStop { position: 0.32; color: "green" }
      ColorGradientStop { position: 0.40; color: "darkslategray" }
      ColorGradientStop { position: 1.0; color: "white" }
  }

  ColorGradient {
      id: layerTwoGradient
      ColorGradientStop { position: 0.315; color: "blue" }
      ColorGradientStop { position: 0.33; color: "white" }
  }

  ColorGradient {
      id: layerThreeGradient
      ColorGradientStop { position: 0.0; color: "red" }
      ColorGradientStop { position: 0.15; color: "black" }
  }

</pre>
<p>Then we'll create the series themselves. It happens simply by adding 3 separate <a href="qml-qtdatavisualization-surface3dseries.html">Surface3DSeries</a> to the <a href="qml-qtdatavisualization-surface3d.html">Surface3D</a> graph as children:</p>
<pre class="cpp">

  ...
  Surface3DSeries {
      id: layerOneSeries
      baseGradient: layerOneGradient
      HeightMapSurfaceDataProxy {
          heightMapFile: ":/heightmaps/layer_1.png"
      }
      flatShadingEnabled: false
      drawMode: Surface3DSeries.DrawSurface
      visible: layerOneToggle.checked // bind to checkbox state
  }

  Surface3DSeries {
      id: layerTwoSeries
      baseGradient: layerTwoGradient
      HeightMapSurfaceDataProxy {
          heightMapFile: ":/heightmaps/layer_2.png"
      }
      flatShadingEnabled: false
      drawMode: Surface3DSeries.DrawSurface
      visible: layerTwoToggle.checked // bind to checkbox state
  }

  Surface3DSeries {
      id: layerThreeSeries
      baseGradient: layerThreeGradient
      HeightMapSurfaceDataProxy {
          heightMapFile: ":/heightmaps/layer_3.png"
      }
      flatShadingEnabled: false
      drawMode: Surface3DSeries.DrawSurface
      visible: layerThreeToggle.checked // bind to checkbox state
  }
  ...

</pre>
<p>You'll notice we added the created gradients to the <code>baseGradient</code> properties of the series. We could have added them to the <code>baseGradients</code> property of the <a href="qml-qtdatavisualization-theme3d.html">Theme3D</a> in <a href="qml-qtdatavisualization-surface3d.html">Surface3D</a> instead, but doing it this way ensures each gradient is applied to a correct series:</p>
<pre class="qml">

  Surface3DSeries {
      id: layerOneSeries
      baseGradient: layerOneGradient
      ...

</pre>
<a name="controlling-the-graph"></a>
<h2 id="controlling-the-graph">Controlling the Graph</h2>
<p>Let's add some checkboxes to control the visibility of layers:</p>
<pre class="qml">

  GroupBox {
      flat: true
      Layout.fillWidth: true
      Column {
          spacing: 10

          Label {
              font.pointSize: fontSize
              font.bold: true
              text: "Layer Selection"
          }

          CheckBox {
              id: layerOneToggle
              checked: true
              style: CheckBoxStyle {
                  label: Label {
                      font.pointSize: fontSize
                      text: "Show Ground Layer"
                  }
              }
          }

          CheckBox {
              id: layerTwoToggle
              checked: true
              style: CheckBoxStyle {
                  label: Label {
                      font.pointSize: fontSize
                      text: "Show Sea Layer"
                  }
              }
          }

          CheckBox {
              id: layerThreeToggle
              checked: true
              style: CheckBoxStyle {
                  label: Label {
                      font.pointSize: fontSize
                      text: "Show Tectonic Layer"
                  }
              }
          }
      }
  }

</pre>
<p>We don't need to do anything on the <code>onCheckedChanged</code> as we bound the <code>checked</code> state to the <code>visible</code> property of the series directly:</p>
<pre class="cpp">

  ...
  visible: layerOneToggle.checked // bind to checkbox state
  ...

</pre>
<p>Let's add some more checkboxes to control how the layers are displayed, when visible:</p>
<pre class="qml">

  GroupBox {
      flat: true
      Layout.fillWidth: true
      Column {
          spacing: 10

          Label {
              font.pointSize: fontSize
              font.bold: true
              text: "Layer Style"
          }

          CheckBox {
              id: layerOneGrid
              style: CheckBoxStyle {
                  label: Label {
                      font.pointSize: fontSize
                      text: "Show Ground as Grid"
                  }
              }
              onCheckedChanged: {
                  if (checked)
                      layerOneSeries.drawMode = Surface3DSeries.DrawWireframe
                  else
                      layerOneSeries.drawMode = Surface3DSeries.DrawSurface
              }
          }

          CheckBox {
              id: layerTwoGrid
              style: CheckBoxStyle {
                  label: Label {
                      font.pointSize: fontSize
                      text: "Show Sea as Grid"
                  }
              }
              onCheckedChanged: {
                  if (checked)
                      layerTwoSeries.drawMode = Surface3DSeries.DrawWireframe
                  else
                      layerTwoSeries.drawMode = Surface3DSeries.DrawSurface
              }
          }

          CheckBox {
              id: layerThreeGrid
              style: CheckBoxStyle {
                  label: Label {
                      font.pointSize: fontSize
                      text: "Show Tectonic as Grid"
                  }
              }
              onCheckedChanged: {
                  if (checked)
                      layerThreeSeries.drawMode = Surface3DSeries.DrawWireframe
                  else
                      layerThreeSeries.drawMode = Surface3DSeries.DrawSurface
              }
          }
      }
  }

</pre>
<p>In addition to these we have three buttons, one of which is of special interest to us. It is used to control whether we want to slice into only one layer, or all of them:</p>
<pre class="qml">

  NewButton {
      id: sliceButton
      text: "Slice All Layers"
      fontSize: fontSize
      Layout.fillWidth: true
      Layout.minimumHeight: 40
      onClicked: {
          if (surfaceLayers.selectionMode & AbstractGraph3D.SelectionMultiSeries) {
              surfaceLayers.selectionMode = AbstractGraph3D.SelectionRow
                      | AbstractGraph3D.SelectionSlice
              text = "Slice All Layers"
          } else {
              surfaceLayers.selectionMode = AbstractGraph3D.SelectionRow
                      | AbstractGraph3D.SelectionSlice
                      | AbstractGraph3D.SelectionMultiSeries
              text = "Slice One Layer"
          }
      }
  }

</pre>
<a name="example-contents"></a>
<h2 id="example-contents">Example Contents</h2>
<p>Files:</p>
<ul>
<li><a href="qtdatavisualization-qmlsurfacelayers-main-cpp.html">qmlsurfacelayers/main.cpp</a></li>
<li><a href="qtdatavisualization-qmlsurfacelayers-qml-qmlsurfacelayers-newbutton-qml.html">qmlsurfacelayers/qml/qmlsurfacelayers/NewButton.qml</a></li>
<li><a href="qtdatavisualization-qmlsurfacelayers-qml-qmlsurfacelayers-main-qml.html">qmlsurfacelayers/qml/qmlsurfacelayers/main.qml</a></li>
<li><a href="qtdatavisualization-qmlsurfacelayers-qmlsurfacelayers-pro.html">qmlsurfacelayers/qmlsurfacelayers.pro</a></li>
<li><a href="qtdatavisualization-qmlsurfacelayers-qmlsurfacelayers-qrc.html">qmlsurfacelayers/qmlsurfacelayers.qrc</a></li>
</ul>
<p>Images:</p>
<ul>
<li><a href="images/used-in-examples/qmlsurfacelayers/layer_1.png">qmlsurfacelayers/layer_1.png</a></li>
<li><a href="images/used-in-examples/qmlsurfacelayers/layer_2.png">qmlsurfacelayers/layer_2.png</a></li>
<li><a href="images/used-in-examples/qmlsurfacelayers/layer_3.png">qmlsurfacelayers/layer_3.png</a></li>
</ul>
</div>
<!-- @@@qmlsurfacelayers -->
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2019 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br/>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br/>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>