This type of viewport layer lets you write your own Python script function to paint arbitrary text and graphics on top of images rendered in OVITO. This makes it possible to enrich figures or movies with additional information (e.g. a scale bar or a data plot).
The Edit script button opens a code editor, where you enter the code for the user-defined
This function will be invoked by OVITO each time the viewport is repainted or
whenever an image or movie frame is being rendered. The
args function parameter
gives access to a QPainter object,
which allows issuing arbitrary drawing commands to paint over the three-dimensional objects rendered by OVITO.
Any Python exceptions raised during script execution are displayed in the output area below.
It also shows any output from calls to the
print() Python function.
The user-defined script has full access to OVITO’s data model and can access viewport properties, camera and animation settings, modifiers, and data pipeline outputs. For more information on OVITO’s Python interface and the object model, see the Introduction.
This page provides several code examples demonstrating how to write a
render() function for a Python viewport layer:
ovito.vis.PythonViewportOverlay (Python API)