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)
__init__(vertices, color=None, opacity=1.0, style=1)

Constructor requires:

vertices: List of vertex coordinates (x, y, z).
Specify at least 3 vertices in consecutive order. All vertices must be in the same plane.
color: One of:
Color object (Color class) Color name (string) Tuple of (R, G, B) (each a float in range 0.0-1.0)

Optional arguments:

opacity: 0.0 (invisible) through 1.0 (opaque)
Defaults to 1.0

style: LINE or FILL. Default is FILL.

__class__

alias of builtins.type

__del__(_hasattr=<built-in function hasattr>, _maestro=<module 'schrodinger.maestro.maestro' from '/scr/buildbot/savedbuilds/2018-4/NB/build-145/internal/lib/python3.6/site-packages/schrodinger/maestro/maestro.py'>)
__delattr__

Implement delattr(self, name).

__dict__ = mappingproxy({'__module__': 'schrodinger.graphics3d.polygon', '__doc__': "\n Class to draw a flat polygon in OpenGL. Will be drawn in the current OpenGL\n drawable. This includes the ability to draw into Maestro's Workspace. It\n just needs to be the current drawable.\n\n API Example::\n\n import schrodinger.maestro.maestro as maestro\n import schrodinger.graphics3d.common as common\n import schrodinger.graphics3d.polygon as polygon\n import math\n\n poly_grp = common.Group()\n st = maestro.workspace_get()\n at = st.atom[1]\n vertices = []\n for theta in range(0, 360, 80):\n theta_rad = theta * math.pi/180\n x = math.cos(theta_rad)\n y = math.sin(theta_rad)\n vertices.append(\n (at.x + x, at.y + y, at.z)\n )\n pgon = polygon.Polygon(\n vertices=vertices,\n color='red',\n opacity=0.8,\n )\n\n # Add the primative to the container.\n poly_grp.add(pgon)\n\n # Hide the markers.\n poly_grp.hide()\n\n # Remove the markers and the callback.\n poly_grp.clear()\n maestro.workspace_draw_function_remove(poly_grp.draw)\n\n ", '_blend': None, '_smooth_point': None, '_cull': None, '_lighting': None, '_lighting_model': None, '_shading_model': None, '_polygon_mode': None, '__init__': <function Polygon.__init__>, '_checkVertexArgument': <function Polygon._checkVertexArgument>, '_glSetup': <staticmethod object>, '_glReset': <staticmethod object>, '_draw': <function Polygon._draw>, '_calculateBoundingBox': <function Polygon._calculateBoundingBox>})
__dir__() → list

default dir() implementation

__eq__

Return self==value.

__format__()

default object formatter

__ge__

Return self>=value.

__getattribute__

Return getattr(self, name).

__gt__

Return self>value.

__hash__

Return hash(self).

__init_subclass__()

This method is called when a class is subclassed.

The default implementation does nothing. It may be overridden to extend subclasses.

__le__

Return self<=value.

__lt__

Return self<value.

__module__ = 'schrodinger.graphics3d.polygon'
__ne__

Return self!=value.

__new__()

Create and return a new object. See help(type) for accurate signature.

__reduce__()

helper for pickle

__reduce_ex__()

helper for pickle

__repr__

Return repr(self).

__setattr__

Implement setattr(self, name, value).

__sizeof__() → int

size of object in memory, in bytes

__str__

Return str(self).

__subclasshook__()

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).

__weakref__

list of weak references to the object (if defined)

groupHidden()

Called when the group of this object is hidden. Hide the Maestro object(s).

groupShown()

Called when the group of this object is shown. Show the Maestro object, if we are being shown.

hide()

Hide the object. It will not be drawn when the group is drawn.

isGroupShown()

Returns True if this object’s group is shown. False otherwise.

isShown()

Returns True if this object shown. False otherwise.

setEntryID(entry_id)

Sets entry ID for Maestro object (necessary to render in tile-by-entry mode.

Parameters:entry_id (str) – Object’s entry ID.
setGlowColor(r, g, b)

Sets glow color for the object.

Parameters:
  • r (float) – Red component of glow color [0.0 .. 1.0]
  • g (float) – Green component of glow color [0.0 .. 1.0]
  • b (float) – Blue component of glow color [0.0 .. 1.0]
setIsGlowing(is_glowing)

Enables or disables glow effect for the object.

Parameters:is_glowing (bool) – Whether the object is glowing.
setRightClickOnGObject(pymodule, pyfunc)

Sets the python callback which should be called whenever given graphics object is right clicked.

Parameters:
  • pymodule (str) – Python module
  • pyfunc (str) – Python function
show()

Display this object, if it was hidden

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

Bases: schrodinger.graphics3d.polygon.Polygon

__init__(vertices, color=None, opacity=1.0, style=1)

Creates polygon object in Maestro.

Constructor requires:

vertices: List of vertex coordinates (x, y, z).
Specify at least 3 vertices in consecutive order. All vertices must be in the same plane.
color: One of:
Color object (Color class) Color name (string) Tuple of (R, G, B) (each a float in range 0.0-1.0)

Optional arguments:

opacity: 0.0 (invisible) through 1.0 (opaque)
Defaults to 1.0

style: LINE or FILL. Default is FILL.

__class__

alias of builtins.type

__del__(_hasattr=<built-in function hasattr>, _maestro=<module 'schrodinger.maestro.maestro' from '/scr/buildbot/savedbuilds/2018-4/NB/build-145/internal/lib/python3.6/site-packages/schrodinger/maestro/maestro.py'>)
__delattr__

Implement delattr(self, name).

__dict__ = mappingproxy({'__module__': 'schrodinger.graphics3d.polygon', '__init__': <function MaestroPolygon.__init__>, '_glSetup': <staticmethod object>, '_glReset': <staticmethod object>, '_draw': <function MaestroPolygon._draw>, '__doc__': None})
__dir__() → list

default dir() implementation

__eq__

Return self==value.

__format__()

default object formatter

__ge__

Return self>=value.

__getattribute__

Return getattr(self, name).

__gt__

Return self>value.

__hash__

Return hash(self).

__init_subclass__()

This method is called when a class is subclassed.

The default implementation does nothing. It may be overridden to extend subclasses.

__le__

Return self<=value.

__lt__

Return self<value.

__module__ = 'schrodinger.graphics3d.polygon'
__ne__

Return self!=value.

__new__()

Create and return a new object. See help(type) for accurate signature.

__reduce__()

helper for pickle

__reduce_ex__()

helper for pickle

__repr__

Return repr(self).

__setattr__

Implement setattr(self, name, value).

__sizeof__() → int

size of object in memory, in bytes

__str__

Return str(self).

__subclasshook__()

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).

__weakref__

list of weak references to the object (if defined)

groupHidden()

Called when the group of this object is hidden. Hide the Maestro object(s).

groupShown()

Called when the group of this object is shown. Show the Maestro object, if we are being shown.

hide()

Hide the object. It will not be drawn when the group is drawn.

isGroupShown()

Returns True if this object’s group is shown. False otherwise.

isShown()

Returns True if this object shown. False otherwise.

setEntryID(entry_id)

Sets entry ID for Maestro object (necessary to render in tile-by-entry mode.

Parameters:entry_id (str) – Object’s entry ID.
setGlowColor(r, g, b)

Sets glow color for the object.

Parameters:
  • r (float) – Red component of glow color [0.0 .. 1.0]
  • g (float) – Green component of glow color [0.0 .. 1.0]
  • b (float) – Blue component of glow color [0.0 .. 1.0]
setIsGlowing(is_glowing)

Enables or disables glow effect for the object.

Parameters:is_glowing (bool) – Whether the object is glowing.
setRightClickOnGObject(pymodule, pyfunc)

Sets the python callback which should be called whenever given graphics object is right clicked.

Parameters:
  • pymodule (str) – Python module
  • pyfunc (str) – Python function
show()

Display this object, if it was hidden