.. _vector-settings-tutorial:

###################################################
UnstructGrid: Set Vector Settings on a Loaded Model
###################################################

.. image:: ../images/tut_vectorsettings.png
    :height: 300
    :align: center

The vector result can be configured to make a better visual appearance of your result data, 
for instance settings such as scale and coloring.

Each vector result has its own settings.

This tutorial shows how to change vector settings for visualized result. 

The demo model file (10x10x10.vtf) contains a simple geometry and a vector result. 

This tutorial will show the vector as on the model, and set some vector settings
for demonstration. 

-   Set the relative scaling to 0.2.
-   Set single vector color to yellow.

Load the file and setup the model specification to show the result. For a more thorough 
explanation on creating a data source from a file interface and setup the model specification,
see the Load VFT tutorial:
:ref:`simple-load-vtf-tutorial`

.. note::
    This tutorial expect the application to have a correctly configured :class:`cee::vis::View`
    in place. See demo applications on how to set up a :class:`cee::vis::View` in your application.

**Load model**

Create the model and a VTF file interface data source. Open the file and set the created data
source in the model.

.. literalinclude:: ../../../../EnvisionDesktop/Tutorials/VectorSettings.cpp
    :language: cpp
    :lines: 47-49,51-56,59


**Setup model specification**

The model specification in this tutorial is set up with the first state and the model's only
vector result.

Use the information retrieved from the data source directory to set up the model specification.

.. literalinclude:: ../../../../EnvisionDesktop/Tutorials/VectorSettings.cpp
    :language: cpp
    :lines: 62-65,67-69

**Set vector visibility**

Toggle on vector result visibility for all parts. For easy access 
to the settings for all available parts in a model, use the :class:`cee::ug::PartSettingsIterator`.

.. literalinclude:: ../../../../EnvisionDesktop/Tutorials/VectorSettings.cpp
    :language: cpp
    :lines: 72-77

**Set vector settings**

Available vector settings:

-   Relative/Absolute scaling
-   Color mode (Single/From scalar)
-   Single color
    
In this tutorial we will set relative scaling and single color

Get vector settings for a specific vector result by calling 
:func:`cee::ug::UnstructGridModel::vectorSettings()` with the requested vector result id.

.. literalinclude:: ../../../../EnvisionDesktop/Tutorials/VectorSettings.cpp
    :language: cpp
    :lines: 80

Set number relative scaling to 0.2.

.. literalinclude:: ../../../../EnvisionDesktop/Tutorials/VectorSettings.cpp
    :language: cpp
    :lines: 83

Set the single vector color to yellow.

.. literalinclude:: ../../../../EnvisionDesktop/Tutorials/VectorSettings.cpp
    :language: cpp
    :lines: 86

**Set up the created model**

The model is ready to use and can be added to the view. Exactly where the view exists
depends on the platform and solution. These examples uses Qt and the view is set up 
in a :class:`cee::qt::ViewerWidget`.

.. literalinclude:: ../../../../EnvisionDesktop/Tutorials/VectorSettings.cpp
    :language: cpp
    :lines: 89,91,93


**See the complete source code here:**

:ref:`scalar-settings-example`

