Sophie

Sophie

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

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" />
<!-- rotations.qdoc -->
  <title>Rotations 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 >Rotations 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="#using-rotations">Using Rotations</a></li>
<li class="level1"><a href="#using-custom-item-meshes">Using Custom Item Meshes</a></li>
<li class="level1"><a href="#using-range-gradient">Using Range Gradient</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">Rotations Example</h1>
<span class="subtitle"></span>
<!-- $$$rotations-brief -->
<p>Using rotated scatter items.</p>
<!-- @@@rotations -->
<!-- $$$rotations-description -->
<div class="descr"> <a name="details"></a>
<p>This example shows how to do the following:</p>
<ul>
<li>Use item rotations</li>
<li>Use custom item meshes</li>
<li>Use range gradient to color the series</li>
</ul>
<p>For more basic example about using Qt Data Visualization graphs, see <a href="qtdatavisualization-bars-example.html">Bars Example</a>.</p>
<p class="centerAlign"><img src="images/rotations-example.png" alt="" /></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="using-rotations"></a>
<h2 id="using-rotations">Using Rotations</h2>
<p>In this example we want to orient the arrow items tangentially to the origin. This requires rotating them, which can be achieved by specifying rotation quaternion to each item:</p>
<pre class="cpp">

  <span class="type">QQuaternion</span> yRotation <span class="operator">=</span> <span class="type">QQuaternion</span><span class="operator">::</span>fromAxisAndAngle(<span class="number">0.0f</span><span class="operator">,</span> <span class="number">1.0f</span><span class="operator">,</span> <span class="number">0.0f</span><span class="operator">,</span> horizontalAngle <span class="operator">*</span> radiansToDegrees);
  <span class="type">QQuaternion</span> zRotation <span class="operator">=</span> <span class="type">QQuaternion</span><span class="operator">::</span>fromAxisAndAngle(<span class="number">0.0f</span><span class="operator">,</span> <span class="number">0.0f</span><span class="operator">,</span> <span class="number">1.0f</span><span class="operator">,</span> verticalAngle <span class="operator">*</span> radiansToDegrees);
  <span class="type">QQuaternion</span> totalRotation <span class="operator">=</span> yRotation <span class="operator">*</span> zRotation;
  ptrToDataArray<span class="operator">-</span><span class="operator">&gt;</span>setRotation(totalRotation);

</pre>
<p>Since the items need to be rotated along two axes, we define two rotation quaternions, one for Y-axis and one for Z-axis, and then multiply these together to get the total rotation, which we set to the data item.</p>
<a name="using-custom-item-meshes"></a>
<h2 id="using-custom-item-meshes">Using Custom Item Meshes</h2>
<p>The narrow arrow mesh we use for magnetic field arrow items is not a standard mesh. Instead we supply our own <code>narrowarrow.obj</code> file which contains the object definition for the mesh in <code>Wavefront</code> obj format:</p>
<pre class="cpp">

  m_magneticField<span class="operator">-</span><span class="operator">&gt;</span>setMesh(QAbstract3DSeries<span class="operator">::</span>MeshUserDefined);
  m_magneticField<span class="operator">-</span><span class="operator">&gt;</span>setUserDefinedMesh(<span class="type">QStringLiteral</span>(<span class="string">&quot;:/mesh/narrowarrow.obj&quot;</span>));

</pre>
<a name="using-range-gradient"></a>
<h2 id="using-range-gradient">Using Range Gradient</h2>
<p>Setting the color style to range gradient in a series means that the item is colored according to its relative Y-value on the visible Y-coordinate range. We want the arrows on the bottom part of the graph to be darker and gradually get lighter higher they are, so we define a range gradient with black color at the position 0.0 and white color at the position 1.0:</p>
<pre class="cpp">

  <span class="type">QLinearGradient</span> fieldGradient(<span class="number">0</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">16</span><span class="operator">,</span> <span class="number">1024</span>);
  fieldGradient<span class="operator">.</span>setColorAt(<span class="number">0.0</span><span class="operator">,</span> <span class="type">Qt</span><span class="operator">::</span>black);
  fieldGradient<span class="operator">.</span>setColorAt(<span class="number">1.0</span><span class="operator">,</span> <span class="type">Qt</span><span class="operator">::</span>white);
  m_magneticField<span class="operator">-</span><span class="operator">&gt;</span>setBaseGradient(fieldGradient);
  m_magneticField<span class="operator">-</span><span class="operator">&gt;</span>setColorStyle(<span class="type"><a href="q3dtheme.html">Q3DTheme</a></span><span class="operator">::</span>ColorStyleRangeGradient);

</pre>
<a name="example-contents"></a>
<h2 id="example-contents">Example Contents</h2>
<p>Files:</p>
<ul>
<li><a href="qtdatavisualization-rotations-main-cpp.html">rotations/main.cpp</a></li>
<li><a href="qtdatavisualization-rotations-rotations-pro.html">rotations/rotations.pro</a></li>
<li><a href="qtdatavisualization-rotations-rotations-qrc.html">rotations/rotations.qrc</a></li>
<li><a href="qtdatavisualization-rotations-scatterdatamodifier-cpp.html">rotations/scatterdatamodifier.cpp</a></li>
<li><a href="qtdatavisualization-rotations-scatterdatamodifier-h.html">rotations/scatterdatamodifier.h</a></li>
</ul>
</div>
<!-- @@@rotations -->
        </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>