schrodinger.graphics3d.arrow module

OpenGL arrows.

The arrow module allows creation and drawing of arrows. Clients draw using graphics3d.common.Group instances, aliased here as ArrowGroup, not through Arrow 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 endpoints, radius, color, resolution and transparency of a arrow are provided. See the Arrow class for more info.

To draw any number of arrows create Arrow instances, add them to a Group instance, then invoke the Group’s draw() method.

Copyright Schrodinger LLC, All rights reserved.

schrodinger.graphics3d.arrow.vector_normalize(X)
schrodinger.graphics3d.arrow.vector_cross(X, Y)

Returns the cross product of the len 3 vectors X and Y

class schrodinger.graphics3d.arrow.ArrowCore(xhead=None, yhead=None, zhead=None, xtail=None, ytail=None, ztail=None, color=None, r=0.0, g=1.0, b=0.0, radius=0.15, transparency=None, opacity=1.0, resolution=16)

Bases: schrodinger.graphics3d.common.Primitive

Base class for drawing a 3D arrow

See doc string for __init__ for details on instantiation

Arrows should be added to a graphics3d.common.Group, or ArrowGroup, and drawing done via the Group. See the graphics3d.common.Group documentation.

__init__(xhead=None, yhead=None, zhead=None, xtail=None, ytail=None, ztail=None, color=None, r=0.0, g=1.0, b=0.0, radius=0.15, transparency=None, opacity=1.0, resolution=16)

Constructor requires:

Parameters:
  • xhead – x coordinate of head position
  • yhead – y coordinate of head position
  • zhead – z coordinate of head position
  • xtail – x coordinate of tail position
  • ytail – y coordinate of tail position
  • ztail – z coordinate of tail position
  • color – One of Color object (Color class) or Color name (string) or Tuple of (R, G, B) (each a float in range 0.0-1.0)
  • radius – radius of the arrow in Angstroms Default: .15
  • opacity – 0.0 (invisible) through 1.0 (opaque) Default: 0.0
  • resolution – Ranges from ?? to ??. Default: ??
__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.arrow', '__doc__': '\n Base class for drawing a 3D arrow\n\n See doc string for __init__ for details on instantiation\n\n Arrows should be added to a graphics3d.common.Group, or ArrowGroup,\n and drawing done via the Group. See the graphics3d.common.Group\n documentation.\n\n ', '_blend': None, '_smooth_point': None, '_cull': None, '_lighting': None, '_lighting_model': None, '_shading_model': None, '__init__': <function ArrowCore.__init__>, '_calculateBoundingBox': <function ArrowCore._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.arrow'
__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.arrow.Arrow(xhead=None, yhead=None, zhead=None, xtail=None, ytail=None, ztail=None, color=None, r=0.0, g=1.0, b=0.0, radius=0.15, transparency=None, opacity=1.0, resolution=16)

Bases: schrodinger.graphics3d.arrow.ArrowCore

Class for drawing a 3D arrow 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.

Arrows should be added to a Group and drawing done via the Group. See the graphics3d.common.Group documentation.

API Example:

import schrodinger.maestro.maestro as maestro
import schrodinger.graphics3d.common as common
import schrodinger.graphics3d.arrow as arrow

arrow_grp = common.Group()
st = maestro.workspace_get()
for bond in st.bond:
    ar = arrow.Arrow(
        xhead=bond.atom2.x, yhead=bond.atom2.y, zhead=bond.atom2.z,
        xtail=bond.atom1.x, ytail=bond.atom1.y, ztail=bond.atom1.z,
        color='red',
        radius=0.15,
        opacity=0.8,
        resolution=50
    )
    # Add the primative to the container.
    arrow_grp.add(ar)

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

# Hide the markers.
arrow_grp.hide()

# Remove the markers and the callback.
arrow_grp.clear()
maestro.workspace_draw_function_remove(arrow_grp.draw)
__init__(xhead=None, yhead=None, zhead=None, xtail=None, ytail=None, ztail=None, color=None, r=0.0, g=1.0, b=0.0, radius=0.15, transparency=None, opacity=1.0, resolution=16)

Constructor requires:

Parameters:
  • xhead – x coordinate of head position
  • yhead – y coordinate of head position
  • zhead – z coordinate of head position
  • xtail – x coordinate of tail position
  • ytail – y coordinate of tail position
  • ztail – z coordinate of tail position
  • color – One of Color object (Color class) or Color name (string) or Tuple of (R, G, B) (each a float in range 0.0-1.0)
  • radius – radius of the arrow in Angstroms Default: .15
  • opacity – 0.0 (invisible) through 1.0 (opaque) Default: 0.0
  • resolution – Ranges from ?? to ??. Default: ??
__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.arrow', '__doc__': "\n Class for drawing a 3D arrow in OpenGL. Will be drawn in the current\n OpenGL drawable. This includes the ability to draw into Maestro's\n Workspace. It just needs to be the current drawable.\n\n Arrows should be added to a Group and drawing done via the Group. See the\n graphics3d.common.Group documentation.\n\n API Example::\n\n import schrodinger.maestro.maestro as maestro\n import schrodinger.graphics3d.common as common\n import schrodinger.graphics3d.arrow as arrow\n\n arrow_grp = common.Group()\n st = maestro.workspace_get()\n for bond in st.bond:\n ar = arrow.Arrow(\n xhead=bond.atom2.x, yhead=bond.atom2.y, zhead=bond.atom2.z,\n xtail=bond.atom1.x, ytail=bond.atom1.y, ztail=bond.atom1.z,\n color='red',\n radius=0.15,\n opacity=0.8,\n resolution=50\n )\n # Add the primative to the container.\n arrow_grp.add(ar)\n\n # Add the draw callback.\n maestro.workspace_draw_function_add(arrow_grp.draw)\n\n # Hide the markers.\n arrow_grp.hide()\n\n # Remove the markers and the callback.\n arrow_grp.clear()\n maestro.workspace_draw_function_remove(arrow_grp.draw)\n\n ", '__init__': <function Arrow.__init__>, '_drawCylinder': <function Arrow._drawCylinder>, '_glSetup': <staticmethod object>, '_glReset': <staticmethod object>, '_draw': <function Arrow._draw>})
__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.arrow'
__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.arrow.MaestroArrow(xhead=None, yhead=None, zhead=None, xtail=None, ytail=None, ztail=None, color=None, r=0.0, g=1.0, b=0.0, radius=0.15, transparency=None, opacity=1.0, resolution=16, body_percentage=0.75, remove_endcaps=False)

Bases: schrodinger.graphics3d.arrow.ArrowCore

Class for creating a 3D arrow in Maestro

Arrows should be added to a Group and drawing done via the Group. See the Group documentation.

API Example:

import schrodinger.maestro.maestro as maestro
import schrodinger.graphics3d.common as common
import schrodinger.graphics3d.arrow as arrow

arrow_grp = common.Group()
st = maestro.workspace_get()
for bond in st.bond:
    ar = arrow.MaestroArrow(
        xhead=bond.atom2.x, yhead=bond.atom2.y, zhead=bond.atom2.z,
        xtail=bond.atom1.x, ytail=bond.atom1.y, ztail=bond.atom1.z,
        color='red',
        radius=0.15,
        opacity=0.8,
        resolution=50
    )
    # Add the primative to the container.
    arrow_grp.add(ar)

# Unlike Arrow MaestroArrow simply needs to be shown to be drawn.
# No special callback like there is for Arrows is needed.
arrow_grp.show()

# Hide the markers.
arrow_grp.hide()

# Remove the markers and the callback.
arrow_grp.clear()
maestro.workspace_draw_function_remove(arrow_grp.draw)
__init__(xhead=None, yhead=None, zhead=None, xtail=None, ytail=None, ztail=None, color=None, r=0.0, g=1.0, b=0.0, radius=0.15, transparency=None, opacity=1.0, resolution=16, body_percentage=0.75, remove_endcaps=False)

Constructor requires:

Parameters:
  • xhead – x coordinate of head position
  • yhead – y coordinate of head position
  • zhead – z coordinate of head position
  • xtail – x coordinate of tail position
  • ytail – y coordinate of tail position
  • ztail – z coordinate of tail position
  • color – One of Color object (Color class) or Color name (string) or Tuple of (R, G, B) (each a float in range 0.0-1.0)
  • radius – radius of the arrow in Angstroms Default: .15
  • opacity – 0.0 (invisible) through 1.0 (opaque) Default: 0.0
  • resolution – Ranges from ?? to ??. Default: ??
  • remove_endcaps – Whether to remove cylinder endcaps on arrow body.
calculateCoords(body_percentage=0.75)

Calculate the intermediate coordinate between head and body

setRGBColors(r, g, b)
xhead
yhead
zhead
__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.arrow', '__doc__': "\n Class for creating a 3D arrow in Maestro\n\n Arrows should be added to a Group and drawing done via the Group.\n See the Group documentation.\n\n API Example::\n\n import schrodinger.maestro.maestro as maestro\n import schrodinger.graphics3d.common as common\n import schrodinger.graphics3d.arrow as arrow\n\n arrow_grp = common.Group()\n st = maestro.workspace_get()\n for bond in st.bond:\n ar = arrow.MaestroArrow(\n xhead=bond.atom2.x, yhead=bond.atom2.y, zhead=bond.atom2.z,\n xtail=bond.atom1.x, ytail=bond.atom1.y, ztail=bond.atom1.z,\n color='red',\n radius=0.15,\n opacity=0.8,\n resolution=50\n )\n # Add the primative to the container.\n arrow_grp.add(ar)\n\n # Unlike Arrow MaestroArrow simply needs to be shown to be drawn.\n # No special callback like there is for Arrows is needed.\n arrow_grp.show()\n\n # Hide the markers.\n arrow_grp.hide()\n\n # Remove the markers and the callback.\n arrow_grp.clear()\n maestro.workspace_draw_function_remove(arrow_grp.draw)\n\n ", '__init__': <function MaestroArrow.__init__>, 'calculateCoords': <function MaestroArrow.calculateCoords>, '_glSetup': <staticmethod object>, '_glReset': <staticmethod object>, '_draw': <function MaestroArrow._draw>, '_setCoords': <function MaestroArrow._setCoords>, '_setColors': <function MaestroArrow._setColors>, 'setRGBColors': <function MaestroArrow.setRGBColors>, '_getXHead': <function MaestroArrow._getXHead>, '_setXHead': <function MaestroArrow._setXHead>, '_getYHead': <function MaestroArrow._getYHead>, '_setYHead': <function MaestroArrow._setYHead>, '_getZHead': <function MaestroArrow._getZHead>, '_setZHead': <function MaestroArrow._setZHead>, '_getXTail': <function MaestroArrow._getXTail>, '_setXTail': <function MaestroArrow._setXTail>, '_getYTail': <function MaestroArrow._getYTail>, '_setYTail': <function MaestroArrow._setYTail>, '_getZTail': <function MaestroArrow._getZTail>, '_setZTail': <function MaestroArrow._setZTail>, '_getR': <function MaestroArrow._getR>, '_setR': <function MaestroArrow._setR>, '_getG': <function MaestroArrow._getG>, '_setG': <function MaestroArrow._setG>, '_getB': <function MaestroArrow._getB>, '_setB': <function MaestroArrow._setB>, '_getOpacity': <function MaestroArrow._getOpacity>, '_setOpacity': <function MaestroArrow._setOpacity>, '_getRadius': <function MaestroArrow._getRadius>, '_setRadius': <function MaestroArrow._setRadius>, '_getMaterial': <function MaestroArrow._getMaterial>, '_setMaterial': <function MaestroArrow._setMaterial>, '_getPickID': <function MaestroArrow._getPickID>, '_setPickID': <function MaestroArrow._setPickID>, '_getPickCategory': <function MaestroArrow._getPickCategory>, '_setPickCategory': <function MaestroArrow._setPickCategory>, 'xhead': <property object>, 'yhead': <property object>, 'zhead': <property object>, 'xtail': <property object>, 'ytail': <property object>, 'ztail': <property object>, 'r': <property object>, 'g': <property object>, 'b': <property object>, 'radius': <property object>, 'opacity': <property object>, 'material': <property object>, 'pick_id': <property object>, 'pick_category': <property object>, '_handleOpenGLLevelChange': <function MaestroArrow._handleOpenGLLevelChange>})
__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.arrow'
__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

xtail
ytail
ztail
r
g
b
radius
opacity
material
pick_id
pick_category