.. _field-values-page:

###############
Field Values
###############

The Report component also has a concept called "Field Values". Each snapshot has a set of field values that contains a 
number of field names and the corresponding values, for instance database name, result name, min/max value and so 
on. If a field value tag is found in a document template, it will be replaced with the matching value from the 
correct snapshot when the report is created.

**********
Tag Syntax
**********

The syntax of the field value tag is SIT1_$MYFIELDVALUE where MYFIELDVALUE is the field name. The number behind SIT is 
the index of the snapshot in the repository. When the Report component encounters this tag in the text, it will go to 
snapshot 1 (indicated by SIT1) in the repository and search its field value set for a field named MYFIELDVALUE. 
If a match is found, it will take the corresponding value and replace the field value in the text.

**Example in Word**

Text found in MS Word:
"The result "N/A" has min value N/A and max value N/A."

In Design Mode, content controls will show the selected field values:

.. image:: ../../images/rep_tags_word.png
    :height: 80


The generated text in the report will be:
"The result "Stress" has the min value 0 and max value 42."

**********************
Field Value Set
**********************

The data storage for field values is the FieldValueSet class. This is basically a map of field names and field values.
For convenience, the Report component offers a helper function, cee::rep::FieldValueSet::fromModel(), which populates
a set of field values from an UnstructModel. You can also create your own field value pairs to use in your report
generation.

.. code-block:: cpp

    cee::PtrRef<cee::rep::Snapshot> snapshot = new cee::rep::Snapshot(cee::rep::Snapshot::OBJECT_VTFX);
    snapshot->setTitle("My VTFx Model Title");
    cee::rep::FieldValueSet fieldValueSet = cee::rep::FieldValueSet::fromModel(m_unstructModel.get());
    snapshot->setFieldValueSet(fieldValueSet);


The following field names and values are set:

+-------------------------------+
|Field value name               | 
+-------------------------------+
| | DATABASE_NAME               |
| | DATABASE_PATH               |
| | DATABASE_TITLE              |
| | DATABASE_DESCRIPTION        |
| | DATABASE_NUM_STATES         |
| | DATABASE_NUM_SCALARS        |
| | DATABASE_NUM_VECTORS        |
| | DATABASE_NUM_DISPLACEMENTS  |
| | DATABASE_TYPE               |
| | CASE_NUM_PARTS              |
| | CASE_BOUNDING_BOX_MIN       |
| | CASE_BOUNDING_BOX_MAX       |
| | FRAME_BOUNDING_BOX_MIN      |
| | FRAME_BOUNDING_BOX_MAX      |
| | FRAME_NUM_ELEMENTS          |
| | FRAME_NUM_NODES             |
| | FRAME_TIMESTEP              |
| | FRAME_TIMESTEP_REF_VALUE    |
| | SCALAR_RESULT_NAME          |
| | SCALAR_RESULT_ID            |
| | SCALAR_RESULT_MAPPING       |
| | SCALAR_RESULT_MIN           |
| | SCALAR_RESULT_MAX           |
| | VECTOR?_RESULT_NAME         |
| | VECTOR?_RESULT_ID           |
| | VECTOR?_RESULT_MAPPING      |
| | VECTOR?_RESULT_MIN          |
| | VECTOR?_RESULT_MAX          |
| | DISPLACEMENT_RESULT_NAME    |
| | DISPLACEMENT_RESULT_ID      |
| | CUTPLANE?_POSITION          |
| | CUTPLANE?_NORMAL            |
| | CUTPLANE?_SCALAR_NAME       |
| | ISOSURFACE?_ISO_VALUE       |
| | ISOSURFACE?_ISO_SCALAR_NAME |
| | ISOSURFACE?_MAP_SCALAR_NAME |
| | ISOSURFACE?_MAP_VECTOR_NAME |
| | ISOVOLUME?_ISO_VALUE_MIN    |
| | ISOVOLUME?_ISO_VALUE_MAX    |
| | ISOVOLUME?_ISO_SCALAR_NAME  |
| | ISOVOLUME?_MAP_SCALAR_NAME  |
| | ISOVOLUME?_MAP_VECTOR_NAME  |
+-------------------------------+

Note the ? in the field values names. This applies to cutting planes, isovolumes, isosurfaces and vectors which there can 
be more that one of for the model at the same time. These will be replaced with the correct index found in the model.
