schrodinger.graphics3d.sphere module

Maestro 3D spheres.

The sphere module allows creation and drawing of spheres. Clients draw using Group instances not through Sphere instances.

Control over the center, radius, color, resolution and opacity of a sphere are provided. See the Sphere class for more info.

To draw any number of spheres, create the Sphere instance and add it to a Group instance. Then invoke the Group’s draw() method.

Copyright Schrodinger, LLC. All rights reserved.

class schrodinger.graphics3d.sphere.SphereCore(x=None, y=None, z=None, color=None, r=None, g=None, b=None, radius=None, transparency=None, opacity=1.0, resolution=16)

Bases: schrodinger.graphics3d.common.Primitive

Base class for Sphere and MaestroSphere classes.

See doc string for __init__ for details on instantiation.

Spheres should be added to a SphereGroup and drawing done via SphereGroup. See SphereGroup documentation.

__init__(x=None, y=None, z=None, color=None, r=None, g=None, b=None, radius=None, transparency=None, opacity=1.0, resolution=16)

Constructor requires:

x, y, z: coordinate specifying center of sphere in Angstroms.

color: One of:

Color object Color name (string) Tuble of (R, G, B) (each 0.0-1.0)

radius: radius of the sphere in Angstroms

Optional arguments:

opacity: 0.0 (transparent) through 1.0 (opaque)

Defaults to 1.0

resolution: 4 to 50

Defaults to 16

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.sphere.MaestroSphere(x=None, y=None, z=None, color=None, r=None, g=None, b=None, radius=None, transparency=None, opacity=1.0, resolution=16, angle_dep_transparency=False)

Bases: schrodinger.graphics3d.common._MaestroPrimitiveMixin, schrodinger.graphics3d.sphere.SphereCore

Class to create a 3D sphere in Maestro. This sphere will be drawn at the appropriate time in Maestro to interact properly with transparent objects.

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

API Example:

import schrodinger.maestro.maestro as maestro
import schrodinger.graphics3d.common as common
import schrodinger.graphics3d.sphere as sphere

sphere_grp = common.Group()
st = maestro.workspace_get()
for at in st.atom:
    sph = sphere.MaestroSphere(
        x=at.x,
        y=at.y,
        z=at.z,
        radius=1.0,
        resolution=20,
        opacity=0.8,
        color='red'
    )
    # Add the primative to the container.
    sphere_grp.add(sph)

# Unlike Sphere MaestroSphere simply needs to be shown to be drawn.
# No special callback like there is for Spheres is needed.
sphere_grp.show()

# Hide the markers.
sphere_grp.hide()

# Remove the markers and the callback.
sphere_grp.clear()
maestro.workspace_draw_function_remove(sphere_grp.draw)
__init__(x=None, y=None, z=None, color=None, r=None, g=None, b=None, radius=None, transparency=None, opacity=1.0, resolution=16, angle_dep_transparency=False)

Constructor requires:

x, y, z: coordinate specifying center of sphere in Angstroms.

color: One of:

Color object Color name (string) Tuple of (R, G, B) (each 0.0-1.0)

radius: radius of the sphere in Angstroms

Optional arguments:

opacity: 0.0 (transparent) through 1.0 (opaque)

Defaults to 1.0

resolution: 4 to 50

Defaults to 16

setCoords()
setXYZCoords(x, y, z)
property b
property g
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.

property material
property opacity
property persistent_name
property pick_category
property pick_id
property r
setColors()
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.

setRGBColors(r, g, b, a=None)
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

property x

X coordinate

property y

Y coordinate

property z

Z coordinate

property radius

Sphere’s radius