Add Text On Ovitos Overlay

# This user-defined function gets called by OVITO to make it draw text and graphics on top of the viewport.
# The 'args' parameter provides various information such as the viewport being rendered and the target
# canvas the function should paint onto. Refer to the documentation of the ovito.vis.PythonViewportOverlay class 
# for further information.

def render(args):
    font=args.painter.font()
    font.setPointSize(8)
    args.painter.setFont(font)
    # This demo code prints the current animation frame into the upper left corner of the viewport.
    text1 = "{:.2f} ps".format(args.frame*0.2)
    args.painter.drawText(105, 20 + args.painter.fontMetrics().ascent(), text1)
Linyuan Shi
Linyuan Shi
Lecturer

My research interests include non-equilibrium reactive molecular dynamics simulation and first principles computation.