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: ??
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: ??
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
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