UnstructGrid: Set scalar settings on a loaded model

The scalar result can be configured to make a better visual appearance of your result data, for instance settings such as legend scheme, legend range and filtering.

This example will show the scalar as fringes on the model, and set some scalar settings for demonstration. - Set number of legend levels to 5 - Set color scheme to Normal Inverted. - Filter away all values under 20.

The demo model file (100x100x100.vtf) contains a simple geometry and a scalar result.

void TutorialRunnerMainWindow::setScalarSettings()
    // Load a UnstructGridModel from file and set a scalar result
    // Apply some scalar settings

    // Create the model and data source
    cee::PtrRef<cee::ug::UnstructGridModel> ugModel = new cee::ug::UnstructGridModel();
    cee::PtrRef<cee::ug::DataSourceVTF> source = new cee::ug::DataSourceVTF(42);

    // Open the vtf file
    cee::Str vtfFile = TutorialUtils::testDataDir() + "100x100x100.vtf";
    if (!source->open(vtfFile))
        // VTF file not found

    // Add the data source to the model

    // Set the first state as current
    std::vector<cee::ug::StateInfo> stateInfos = source->directory()->stateInfos();
    int stateId = stateInfos[0].id();

    // Show the scalar result as fringes on the model
    std::vector<cee::ug::ResultInfo> scalarResultInfos = source->directory()->scalarResultInfos();
    int scalarId = scalarResultInfos[0].id();

    // Set fringes visible for all parts
    cee::ug::PartSettingsIterator it(ugModel.get());
    while (it.hasNext())
        cee::ug::PartSettings* partSettings = it.next();

    // Get scalar settings for the current fringes result
    cee::ug::ScalarSettings* settings = ugModel->scalarSettings(scalarId);

    // Set number of legend levels to 0 to get a continuous legend

    // Set the color scheme to the reverted normal

    // Use filter to only show values above 20. Toggle on filtering.
    settings->setFringesElementFilteringVisibleRange(20, 99);

    // Add model to view. Ensure that old models are removed first
    cee::vis::View* gcView = getTutorialView();


    cee::BoundingBox bb = gcView->boundingBox();
    gcView->camera().fitView(bb, cee::Vec3d(0, 0, -1), cee::Vec3d(0, 1, 0));