Skip to content

Commit

Permalink
Merge pull request #39 from ZEISS/20240821-feat-scripted-diagram
Browse files Browse the repository at this point in the history
  • Loading branch information
mprinkezs authored Aug 26, 2024
2 parents a9a90a7 + fcb076d commit f08179e
Show file tree
Hide file tree
Showing 17 changed files with 1,194 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/scripts/gen_overview.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
'script_resources': 'How to access binary data of your App (resources)',
'scripted_actuals': 'Building custom actual elements with Python code',
'scripted_checks': 'Building custom checks with Python code',
'scripted_diagrams': 'Creating custom diagrams',
'projects': 'ZEISS INSPECT projects'
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# ScriptedDiagramBasics

![Circle radius histogram](scripted_diagram-histogram.png)

## Short description

This example includes a script for generation of scripted actual circles, which can provide data — their radius — to any of two scripted diagram services. The diagram service `RadiusPlot` plots the radius of each circle element, the diagram service `RadiusHistogram` creates a radius histogram.

> [!WARNING]
> Only one service function may be used at a time.
> All diagram services currently not in use must be stopped, otherwise no diagram is created.
## Prerequisite

Review [Using scripted diagrams](https://zeissiqs.github.io/zeiss-inspect-addon-api/2025/howtos/using_scripted_diagrams/using_scripted_diagrams.html) for a general introduction.

## Creating scripted actual circle elements

![Scripted circle creation parameters dialog](scripted_circle_dialog.png)

The script `scr_act_circle.py` creates a scripted circle and passes the radius to any of the two scripted diagram services, which is selected from the circle's creation parameters dialog.

The radius of any scripted circle is passed as a parameter to the scripted diagram service using:
```
context.data[stage] = {
"ude_diagram_custom": 1,
"ude_diagram_type": "SVGDiagram",
# Selected by circle creation dialog: "gom.api.diagram.radius_plot" or "gom.api.statistics.radius_histogram"
"ude_diagram_service" : params['service'],
"ude_diagram_radius": params['radius']
}
```

## Managing the scripted diagram services

Use Apps->Manage Services... to start either `RadiusPlot` or `RadiusHistogram` and stop any diagram service currently not in use. Only one diagram service may be active!

## Diagram settings

![App-Settings](app_settings.png)

The `RadiusHistogram` service uses some user settings from Preferences->App-Settings.

This feature is implemented using the [Settings API](https://zeissiqs.github.io/zeiss-inspect-addon-api/2025/python_api/python_api.html#gom-api-settings).

The settings are stored in `metainfo.json`:
```
...
"settings": [
{
"description": "Histogram bin edges",
"name": "bins",
"value": "0, 10, 20, 30",
"visible": true
},
{
"description": "Bar color",
"name": "barcolor",
"value": "blue",
"visible": true
},
{
"description": "Title",
"name": "title",
"value": "Circle radius histogram",
"visible": true
},
{
"description": "X label",
"name": "xlabel",
"value": "Radius",
"visible": true
},
{
"description": "Y label",
"name": "ylabel",
"value": "Count",
"visible": true
}
],
...
```

## View the diagram

The diagram is shown in the tab **Inspection Details** in the 3D view. Adding/removing scripted elements contributing to the diagram or modifying the scripted elements' creation parameters updates the diagram accordingly.

## See also

* [Scripted elements](https://zeissiqs.github.io/zeiss-inspect-addon-api/2025/howtos/scripted_elements/scripted_elements_toc.html)
* [Tokens on scripted elements](https://zeissiqs.github.io/zeiss-inspect-addon-api/2025/howtos/scripted_elements/tokens_on_scripted_elements.html)
* [Using services](https://zeissiqs.github.io/zeiss-inspect-addon-api/2025/howtos/using_services/using_services.html)
* [Settings API](https://zeissiqs.github.io/zeiss-inspect-addon-api/2025/python_api/python_api.html#gom-api-settings)
* [Matplotlib: Visualization with Python](https://matplotlib.org/)

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## ScriptedDiagramBasics

This App is part of the [ZEISS INSPECT Python API App Examples](https://github.com/ZEISS/zeiss-inspect-app-examples/tree/main/AppExamples).

See [App documentation](Documentation.md) for details.

You can [download this App](https://software-store.zeiss.com/products/apps/ScriptedDiagramBasics) from the [ZEISS Quality Software Store](https://software-store.zeiss.com).

The ZEISS INSPECT App develomment documentation can be found on [ZEISS IQS GitHub](https://zeissiqs.github.io/zeiss-inspect-addon-api/2025/index.html).
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit f08179e

Please sign in to comment.