diff --git a/.github/workflows/documentation.yaml b/.github/workflows/documentation.yaml index 61a2f9126..9d9dc3ee2 100644 --- a/.github/workflows/documentation.yaml +++ b/.github/workflows/documentation.yaml @@ -1,5 +1,5 @@ name: Docs -on: [pull_request, workflow_dispatch] +on: [push, pull_request, workflow_dispatch] jobs: docs: runs-on: ubuntu-latest diff --git a/doc/howtos/using_scripted_diagrams/assets/scripted_diagrams_relations.png b/doc/howtos/using_scripted_diagrams/assets/scripted_diagrams_relations.png new file mode 100644 index 000000000..bba2fa238 Binary files /dev/null and b/doc/howtos/using_scripted_diagrams/assets/scripted_diagrams_relations.png differ diff --git a/doc/howtos/using_scripted_diagrams/using_scripted_diagrams.md b/doc/howtos/using_scripted_diagrams/using_scripted_diagrams.md index ebc6fe970..2b6a7268d 100644 --- a/doc/howtos/using_scripted_diagrams/using_scripted_diagrams.md +++ b/doc/howtos/using_scripted_diagrams/using_scripted_diagrams.md @@ -18,6 +18,10 @@ You can use multiple scripted diagrams at the same time, which will be stacked v The concept of scripted diagrams builds upon [scripted elements](../scripted_elements/scripted_elements_introduction.md) and [services](../using_services/using_services.md). [Tokens on scripted elements](../scripted_elements/tokens_on_scripted_elements.md) are used to convey data to the diagram service. +![Scripted diagrams relations](assets/scripted_diagrams_relations.png) + +Each diagram service combines data from one or more scripted elements to create a single scripted diagram. + ## Usage ### 1. Create or modify scripted elements to contribute data to a scripted diagram @@ -52,6 +56,28 @@ See Using ser * The service function name must be the same as set in the scripted elements' `"ude_diagram_service"` parameter. ``` +#### Diagram service function description + +The scripted diagram's service function implementation must adhere to the following interface description: + +```{py:function} (view, element_data): str + +Create an SVG diagram based on scripted elements' context data +:param dict view: ZEISS INSPECT 'Inspection Details' canvas properties + - 'width': (int) Canvas width in pixels + - 'height': (int) Canvas height in pixels + - 'dpi': (float) Canvas resolution in dpi + - 'font': (int) Default font size in pt +:param list[dict1, dict2, ..., dictN] element_data: List of dictionaries containing scripted element references and context data + - 'element': (object) Element reference + - 'data': (dict) Context data of the scripted element + - 'type': (str) Element type (always 'SVGDiagram') +:return: SVG diagram +:rtype: str +``` + +#### Template + The following script serves as a minimum template for a scripted diagram service: ```{code-block} python :caption: Scripted diagram service template @@ -69,15 +95,15 @@ def diagram_service_template(view, element_data)->str: mpltools.setup_plot(plt, view) for e in element_data: - # Read the the current element + # Read element reference element = e['element'] - # Read all parameters received from mapped scripted element + # Read scripted element's context data data = e['data'] # Create your diagram # Example: - # plt.plot ([element.name], [data['ude_diagram_radius']], 'bx') + plt.plot ([element.name], [data['ude_diagram_radius']], 'bx') return mpltools.create_svg(plt, view)