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

Lines constructor requires:

vertices: List of vertex coordinates (x, y, z).
Each vertex coordinate is itself an xyz list: [[x1,y1,z1],[x2,y2,z2]…] Treats each pair of vertices as an independent line segment. Total number of vertices should be 2n. N/2 lines are drawn. It is an error to specify an odd number of vertices.
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:

width (float): Defaults to 1.0. Lines are always drawn out
anti-aliased. So the actual width is determined at rasterization time. Not all widths are supported and if an unsupported width is chosen, the nearest supported with is used. Only width 1 is guaranteed to be supported.
__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.lines', '__doc__': "\n Class to draw a set of lines in OpenGL. Will be drawn\n in the current OpenGL drawable. This includes the ability\n to draw into Maestro's Workspace. It just needs to be\n the current drawable.\n\n Lines with the same characteristics must be placed\n (color, width) into a single Lines instance.\n\n API Example::\n\n import schrodinger.maestro.maestro as maestro\n import schrodinger.graphics3d.common as common\n import schrodinger.graphics3d.lines as lines\n\n line_grp = common.Group()\n st = maestro.workspace_get()\n color='red'\n displacement = 1.0\n for at in st.atom:\n vert = [\n (at.x - displacement, at.y, at.z),\n (at.x + displacement, at.y, at.z),\n (at.x, at.y - displacement, at.z),\n (at.x, at.y + displacement, at.z),\n (at.x, at.y, at.z - displacement),\n (at.x, at.y, at.z + displacement),\n ]\n # Add the primatives to the container.\n line_grp.add(lines.Lines(vertices=vert, color=color))\n\n # Add the draw callback.\n maestro.workspace_draw_function_add(line_grp.draw)\n\n # Hide the markers.\n line_grp.hide()\n\n # Remove the markers and the callback.\n line_grp.clear()\n maestro.workspace_draw_function_remove(line_grp.draw)\n\n ", '_blend': None, '_smooth_point': None, '_smooth_line': None, '__init__': <function Lines.__init__>, '_checkVertexArgument': <function Lines._checkVertexArgument>, '_glSetup': <staticmethod object>, '_glReset': <staticmethod object>, '_draw': <function Lines._draw>, '_calculateBoundingBox': <function Lines._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.lines'
__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