# UnstructGrid: Set Vector Settings on a Loaded Model

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: UnstructGrid: Load Model from File and Set Up Model Specification

Note

This tutorial expect the application to have a correctly configured `cee::vis::View` in place. See demo applications on how to set up a `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.

        cee::PtrRef<cee::ug::UnstructGridModel> ugModel = new cee::ug::UnstructGridModel();
        cee::PtrRef<cee::ug::DataSourceVTF> source = new cee::ug::DataSourceVTF(42);

        cee::Str vtfFile = TutorialUtils::testDataDir() + "10x10x10.vtf";
        if (!source->open(vtfFile))
        {
            // VTF file not found
            return;
        }
        ugModel->setDataSource(source.get());

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.

        std::vector<cee::ug::StateInfo> stateInfos = source->directory()->stateInfos();
        int stateId = stateInfos[0].id();
        ugModel->modelSpec().setStateId(stateId);

        std::vector<cee::ug::ResultInfo> vectorResultInfos = source->directory()->vectorResultInfos();
        int vectorId = vectorResultInfos[0].id();
        ugModel->modelSpec().setVectorResultId(vectorId);

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 `cee::ug::PartSettingsIterator`.

        cee::ug::PartSettingsIterator it(ugModel.get());
        while (it.hasNext())
        {
            cee::ug::PartSettings* partSettings = it.next();
            partSettings->setVectorsVisible(true);
        }

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 `cee::ug::UnstructGridModel::vectorSettings()` with the requested vector result id.

        cee::ug::VectorSettings* settings = ugModel->vectorSettings(vectorId);

Set number relative scaling to 0.2.

        settings->setScaleFactor(cee::ug::VectorSettings::RELATIVE_SCALING, 0.2);

Set the single vector color to yellow.

        settings->setSingleVectorColor(cee::Color3f(1.0, 1.0, 0.0));

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 `cee::qt::ViewerWidget`.

        cee::vis::View* gcView = getTutorialView();
        gcView->addModel(ugModel.get());
        ugModel->updateVisualization();

See the complete source code here:

UnstructGrid: Set Scalar Settings on a Loaded Model

Conversation saved
HOOPSY BETA

### Hello! I'm HOOPSY

Your Docs generative AI assistant. Ask me anything about HOOPS Envision for Desktop or choose a sample question below to start a conversation:

What is HOOPS Envision for Desktop?
What are the latest release notes for HOOPS Envision for Desktop?
How do I start evaluating HOOPS Envision for Desktop?
How do I write my first sample application?
How can I get assistance?

HOOPSY may store conversations according to OpenAI's policy. Responses may not always be accurate.

HOOPSY is thinking...