schrodinger.graphics3d.lines module

OpenGL lines.

The lines module allows creation and drawing of lines. Clients draw using Group instances not through Lines instances.

Drawing is done in whatever is the current GL rendering context and current GL window. So you must set those prior to drawing. If you are using this with Maestro’s drawing callback mechanism you need not worry about the above details. These are handled for you automatically.

Control over the vertices, color, and width of the lines are provided. See the Lines class for more info.

To draw any number of lines that share the same color and width, then place them in a single Lines instance and add the instance to a Group instance (LinesGroup can be used and is a synonym). Then invoke the Group’s draw() method. A set of lines with a different width or color should be placed into a separate Lines instance.

Copyright Schrodinger, LLC. All Rights Reserved

class schrodinger.graphics3d.lines.Lines(vertices=None, color=None, width=1.0)

Bases: schrodinger.graphics3d.common.Primitive

Class to draw a set of lines in OpenGL. Will be drawn in the current OpenGL drawable. This includes the ability to draw into Maestro’s Workspace. It just needs to be the current drawable.

Lines with the same characteristics must be placed (color, width) into a single Lines instance.

API Example:

import schrodinger.maestro.maestro as maestro
import schrodinger.graphics3d.common as common
import schrodinger.graphics3d.lines as lines

line_grp = common.Group()
st = maestro.workspace_get()
color='red'
displacement = 1.0
for at in st.atom: 
    vert = [
        (at.x - displacement, at.y, at.z),
        (at.x + displacement, at.y, at.z),
        (at.x, at.y - displacement, at.z),
        (at.x, at.y + displacement, at.z),
        (at.x, at.y, at.z - displacement),
        (at.x, at.y, at.z + displacement),
    ]
    # Add the primatives to the container.
    line_grp.add(lines.Lines(vertices=vert, color=color))

# Add the draw callback.
maestro.workspace_draw_function_add(line_grp.draw)

# Hide the markers.
line_grp.hide()

# Remove the markers and the callback.
line_grp.clear()
maestro.workspace_draw_function_remove(line_grp.draw)