|
| 1 | +UI.JSON Format |
| 2 | +============== |
| 3 | + |
| 4 | +About |
| 5 | +^^^^^ |
| 6 | + |
| 7 | +The **ui.json** format provides a User Interface (UI) between geoh5py and `Geoscience ANALYST Pro |
| 8 | +<http://www.mirageoscience.com/our-products/software-product/geoscience-analyst>`_. The file structure is built on an array of `JSON objects <https://json-schema.org/specification.html>`_, each representing a parameter that is used in a python script. An object contains members that control the style and behaviour of the UI. In general only a **label** and **value** member is required in each object, however as outlined below, there are many types of input and dependencies that can be drawn on throughout the file. On output from Geoscience ANALYST, the value and whether the parameter is enabled will be updated or added to each JSON. Extra objects in the JSON are allowed and are ignored, but written out by Geoscience ANALYST. In general, objects will be put in order that they are set in the JSON. The exception is data parameters that depend on object parameters. Placing those parameters in the same group will ensure that they are close in the UI. |
| 9 | + |
| 10 | + |
| 11 | +Input Objects |
| 12 | +^^^^^^^^^^^^^ |
| 13 | +Within the **ui.json** file, each JSON object with **value** and **label** members will be considered a parameter to the UI. The following JSON objects could also be present: |
| 14 | + |
| 15 | +run_command ``str`` |
| 16 | + Name of python script excluding the .py extension (i.e., "run_me" for run_me.py) required for Geoscience ANALYST Pro to run on save or auto-load. |
| 17 | +conda_environment ``str`` |
| 18 | + Optional name of conda environment to activate when running the python script in *run_command* |
| 19 | +title ``str`` |
| 20 | + Optional title of user interface window |
| 21 | + |
| 22 | +Object Members |
| 23 | +^^^^^^^^^^^^^^ |
| 24 | +Each JSON object with the following members become a parameter in the user interface. Each object must have the members ``label`` and ``value``. Each member will contribute to the appearence and behaviour within Geoscience ANALYST>. The possible members that can be given to all parameter objects are: |
| 25 | + |
| 26 | +label ``str`` |
| 27 | + Required string describing parameter. A colon will automatically be added within Geoscience ANALYST, so this should be omitted. |
| 28 | +value ``str``, ``int``, ``bool`` , or ``float`` |
| 29 | + This require member takes a different form, including empty, depending on the :ref:`parameter type <json_param_examples>`. The value is updated when written from Geoscience ANALYST. |
| 30 | +main ``bool`` |
| 31 | + If set to true, the parameter is shown in the first tab and will throw an error if not given and not optional. Optional parameters may be set to main. When main is not given or is false, the parameter will be under the *Optional Parameters* tab. |
| 32 | +tooltip ``str`` |
| 33 | + String describing the parameter in detail that appears when the mouse hovers over it. |
| 34 | +optional ``bool`` |
| 35 | + *true* or *false* on whether the parameter is optional. On output, check if *enabled* is set to true. |
| 36 | +enabled ``bool`` |
| 37 | + *true* or *false* if the parameter is enabled. The default is true. If a parameter is optional and not enabled, it will start as disabled (grey and inactive in the UI). |
| 38 | +group ``str`` |
| 39 | + Name of the group to which the parameter belongs. Adds a box and name around the parameters with the same case-sensitive group name. |
| 40 | +groupOptional ``bool`` |
| 41 | + If true, adds a checkbox in the top of the group box next to the name. The group parameters will be disabled if not checked. The initial statedpends on the **groupDependency** and **groupDependencyType** members and the **enabled** member of the group's parameters. |
| 42 | +dependency ``str`` |
| 43 | + The name of the object of which this object is dependent upon. The dependency parameter should be optional or boolean parameter (i.e., has a checkbox). |
| 44 | +dependencyType ``str`` |
| 45 | + What happens when the dependency member is checked. Options are ``enabled`` or ``disabled`` |
| 46 | +groupDependency ``str`` |
| 47 | + The name of the object of which the group of the parameter is dependent upon. This member will also require the **groupOptional** member to be present and set to ``true``. Be sure that the object is not within the group. |
| 48 | +groupDependencyType ``str`` |
| 49 | + What happens when the group's dependency parameter is checked. Options are ``enabled`` or ``disabled``. |
| 50 | + |
| 51 | + |
| 52 | +.. _json_param_examples: |
| 53 | + |
| 54 | +Parameter Types |
| 55 | +^^^^^^^^^^^^^^^ |
| 56 | +There are other JSON members that may be available or required based on the parameter type. The following sections define different parameter types that can be found in the **ui.json** format. |
| 57 | + |
| 58 | + .. toctree:: |
| 59 | + :maxdepth: 1 |
| 60 | + |
| 61 | + json_objects.rst |
| 62 | + |
| 63 | + |
| 64 | +Exporting from Geoscience ANALYST |
| 65 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 66 | +When a **ui.json** is saved with Geoscience ANALYST Pro, the following object members are updated or added: |
| 67 | + |
| 68 | +- The **value** member with the appropriate type |
| 69 | +- The **enabled** member ``bool`` for whether the parameter is enabled |
| 70 | +- The :ref:`Data parameter <data_parameter>` will also have updated **isValue** and **property** members. The **isValue** ``bool`` member is *true* if the **value** member was selected and *false* if the **property** member was selected. |
| 71 | + |
| 72 | +The following JSON objects will be written (and overwritten if given) upon export from Geoscience ANALYST Pro: |
| 73 | + |
| 74 | +- monitoring_directory ``str`` the absolute path of a monitoring directory. Workspace files written to this folder will be automatically processed by Geoscience ANALYST. |
| 75 | +- workspace_geoh5 ``str`` the absolute path to the current workspace (if previously saved) being used |
| 76 | +- geoh5 ``str`` the absolute path to the geoh5 written containing all the objects of the workspace within the parameters of the **ui.json**. One only needs to use this workspace along with the JSON file to access the objects with geoh5py. |
| 77 | + |
| 78 | + |
| 79 | +Tips on creating UIs |
| 80 | +^^^^^^^^^^^^^^^^^^^^ |
| 81 | +Here are a few tips on creating good looking UIs: |
| 82 | + |
| 83 | +- Keep labels short and concise. Be consistent with capitalization and do not include the colons. Geoscience ANALYST will add colons and align them. |
| 84 | +- Write detailed tooltips. |
| 85 | +- Group related objects, but do not use a group if there are fewer than 3 objects. |
| 86 | +- The **main** member is for general, required parameters. Do not include this member with every object, unless there are only a handful of objects. Objects that are in the required parameters without a valid value will invoke an error when exporting or running from Geoscience ANALYST. "Non-main" members are designated to a second page under *Optional parameters*. |
| 87 | +- Utilize **optional** object members and dependencies. If a single workspace object input is optional, use the :ref:`Object parameter <object_parameter>` rather than two parameters with a dependency. |
| 88 | + |
| 89 | + |
| 90 | +External Links |
| 91 | +^^^^^^^^^^^^^^ |
| 92 | + |
| 93 | +- `JSON Terminology <https://json-schema.org/specification.html>`_ |
| 94 | +- `Universally Unique IDentifier (UUID) <https://en.wikipedia.org/wiki/Universally_unique_identifier>`_ |
| 95 | +- `C++ JSON Library <https://github.com/nlohmann/JSON>`_ |
0 commit comments