schrodinger.graphics3d.sphere module¶
OpenGL spheres.
The sphere module allows creation and drawing of spheres. Clients draw using Group instances not through Sphere 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 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
-
__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.sphere', '__doc__': '\n Base class for Sphere and MaestroSphere classes.\n\n See doc string for __init__ for details on instantiation.\n\n Spheres should be added to a SphereGroup and drawing done via\n SphereGroup. See SphereGroup documentation.\n\n ', '_blend': None, '_smooth_point': None, '_cull': None, '_lighting': None, '_lighting_model': None, '_shading_model': None, '__init__': <function SphereCore.__init__>, '_calculateBoundingBox': <function SphereCore._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.sphere'¶
-
__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.sphere.
Sphere
(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.sphere.SphereCore
Class to draw a 3D sphere 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.
Spheres should be added to a SphereGroup and drawing done via SphereGroup. See SphereGroup documentation.
This class draws the sphere directly using OpenGL.
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.Sphere( 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) # Add the draw callback. maestro.workspace_draw_function_add(sphere_grp.draw) # 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)¶ 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
-
__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.sphere', '__doc__': "\n Class to draw a 3D sphere 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 Spheres should be added to a SphereGroup and drawing done via SphereGroup.\n See SphereGroup documentation.\n\n This class draws the sphere directly using OpenGL.\n\n API Example::\n\n import schrodinger.maestro.maestro as maestro\n import schrodinger.graphics3d.common as common\n import schrodinger.graphics3d.sphere as sphere\n\n sphere_grp = common.Group()\n st = maestro.workspace_get()\n for at in st.atom:\n sph = sphere.Sphere(\n x=at.x,\n y=at.y,\n z=at.z,\n radius=1.0,\n resolution=20,\n opacity=0.8,\n color='red'\n )\n # Add the primative to the container.\n sphere_grp.add(sph)\n\n # Add the draw callback.\n maestro.workspace_draw_function_add(sphere_grp.draw)\n\n # Hide the markers.\n sphere_grp.hide()\n\n # Remove the markers and the callback.\n sphere_grp.clear()\n maestro.workspace_draw_function_remove(sphere_grp.draw)\n\n ", '__init__': <function Sphere.__init__>, '_glSetup': <staticmethod object>, '_glReset': <staticmethod object>, '_draw': <function Sphere._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.sphere'¶
-
__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.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.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
()¶
-
setColors
()¶
-
setXYZCoords
(x, y, z)¶
-
setRGBColors
(r, g, b)¶
-
x
¶ X coordinate
-
__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.sphere', '__doc__': "\n Class to create a 3D sphere in Maestro. This sphere will be drawn at the\n appropriate time in Maestro to interact properly with transparent objects.\n\n Spheres should be added to a Group and drawing done via the Group. See\n 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.sphere as sphere\n\n sphere_grp = common.Group()\n st = maestro.workspace_get()\n for at in st.atom:\n sph = sphere.MaestroSphere(\n x=at.x,\n y=at.y,\n z=at.z,\n radius=1.0,\n resolution=20,\n opacity=0.8,\n color='red'\n )\n # Add the primative to the container.\n sphere_grp.add(sph)\n\n # Unlike Sphere MaestroSphere simply needs to be shown to be drawn.\n # No special callback like there is for Spheres is needed.\n sphere_grp.show()\n\n # Hide the markers.\n sphere_grp.hide()\n\n # Remove the markers and the callback.\n sphere_grp.clear()\n maestro.workspace_draw_function_remove(sphere_grp.draw)\n\n ", '__init__': <function MaestroSphere.__init__>, '_glSetup': <staticmethod object>, '_glReset': <staticmethod object>, '_draw': <function MaestroSphere._draw>, 'setCoords': <function MaestroSphere.setCoords>, 'setColors': <function MaestroSphere.setColors>, 'setXYZCoords': <function MaestroSphere.setXYZCoords>, 'setRGBColors': <function MaestroSphere.setRGBColors>, '_getX': <function MaestroSphere._getX>, '_setX': <function MaestroSphere._setX>, '_getY': <function MaestroSphere._getY>, '_setY': <function MaestroSphere._setY>, '_getZ': <function MaestroSphere._getZ>, '_setZ': <function MaestroSphere._setZ>, '_getR': <function MaestroSphere._getR>, '_setR': <function MaestroSphere._setR>, '_getG': <function MaestroSphere._getG>, '_setG': <function MaestroSphere._setG>, '_getB': <function MaestroSphere._getB>, '_setB': <function MaestroSphere._setB>, '_getOpacity': <function MaestroSphere._getOpacity>, '_setOpacity': <function MaestroSphere._setOpacity>, '_getRadius': <function MaestroSphere._getRadius>, '_setRadius': <function MaestroSphere._setRadius>, '_getMaterial': <function MaestroSphere._getMaterial>, '_setMaterial': <function MaestroSphere._setMaterial>, '_getPickID': <function MaestroSphere._getPickID>, '_setPickID': <function MaestroSphere._setPickID>, '_getPickCategory': <function MaestroSphere._getPickCategory>, '_setPickCategory': <function MaestroSphere._setPickCategory>, 'x': <property object>, 'y': <property object>, 'z': <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 MaestroSphere._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.sphere'¶
-
__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
-
y
¶ Y coordinate
-
z
¶ Z coordinate
-
r
¶ Red value in RGB triplet
-
g
¶ Green value in RGB triplet
-
b
¶ Blue value in RGB triplet
-
radius
¶ Sphere’s radius
-
opacity
¶ Sphere’s opacity
-
material
¶ Sphere’s material
-
pick_id
¶ Sphere object’s pick ID
-
pick_category
¶ Sphere’s picking category
-