schrodinger.graphics3d.polygon module

OpenGL polygons.

The polygon module allows creation and drawing of polygons. Clients draw using Group instances not through Polygon 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 transparency of a polygon are provided. See the Polygon class for more info.

To draw any number of polygons create the Polygon instances and add them to a Group instance (PolygonGroup can be used and is a synonym). Then invoke the Group’s draw() method.

Copyright Schrodinger, LLC. All rights reserved.

class schrodinger.graphics3d.polygon.Polygon(vertices, color=None, opacity=1.0, style=1)

Bases: schrodinger.graphics3d.common.Primitive

Class to draw a flat polygon 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.

API Example:

import schrodinger.maestro.maestro as maestro
import schrodinger.graphics3d.common as common
import schrodinger.graphics3d.polygon as polygon
import math

poly_grp = common.Group()
st = maestro.workspace_get()
at = st.atom[1]
vertices = []
for theta in range(0, 360, 80):
    theta_rad = theta * math.pi/180
    x = math.cos(theta_rad)
    y = math.sin(theta_rad) 
    vertices.append(
        (at.x + x, at.y + y, at.z)
    )
pgon = polygon.Polygon(
    vertices=vertices,
    color='red',
    opacity=0.8,
)

# Add the primative to the container.
poly_grp.add(pgon)

# Hide the markers.
poly_grp.hide()

# Remove the markers and the callback.
poly_grp.clear()
maestro.workspace_draw_function_remove(poly_grp.draw)
class schrodinger.graphics3d.polygon.MaestroPolygon(vertices, color=None, opacity=1.0, style=1)

Bases: schrodinger.graphics3d.polygon.Polygon