Package schrodinger :: Package graphics3d :: Module box :: Class Box
[hide private]
[frames] | no frames]

Class Box

      object --+    
               |    
common.Primitive --+
                   |
                  Box


Class to draw a 3D box 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.

See doc string for __init__ for details on instantiation.

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

See note on transparency in the module level docstring.

API Example
-----------
import schrodinger.maestro.maestro as maestro
import schrodinger.graphics3d.common as common
import schrodinger.graphics3d.box as box

box_grp = common.Group()
st = maestro.workspace_get() # Here, st is methane.
methane_vertices = [
    # plane-1, defined in clockwise order.
    st.atom[1].x + 0,
    st.atom[1].y + 1,
    st.atom[1].z + 1,

    st.atom[1].x + 1,
    st.atom[1].y + 0,
    st.atom[1].z + 1,

    st.atom[1].x + 0,
    st.atom[1].y - 1,
    st.atom[1].z + 1,

    st.atom[1].x - 1,
    st.atom[1].y + 0,
    st.atom[1].z + 1,

    # plane-2, defined in clockwise order.
    st.atom[1].x + 0,
    st.atom[1].y + 1,
    st.atom[1].z - 1,

    st.atom[1].x + 1,
    st.atom[1].y + 0,
    st.atom[1].z - 1,

    st.atom[1].x + 0,
    st.atom[1].y - 1,
    st.atom[1].z - 1,

    st.atom[1].x - 1,
    st.atom[1].y + 0,
    st.atom[1].z - 1,

]
bx = box.Box(
    vertices=methane_vertices,
    color='red',
    opacity=1.0,
    style=box.LINE
)
# Add the primitive to the container.
box_grp.add(bx)

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

# Hide the markers.
box_grp.hide()

# Remove the markers and the callback.
box_grp.clear()
maestro.workspace_draw_function_remove(box_grp.draw)

Instance Methods [hide private]
 
__init__(self, vertices=None, center=None, extents=None, color=None, opacity=1.0, style=1)
Constructor requires:
 
_checkVertexArgument(self, vertices)
Private method to check if the vertices are in the correct format
 
_draw(self)
Private method to draw out the box with the current settings.
 
_calculateBoundingBox(self, mat)
 
_getLineWidth(self)
Private method.
 
_setLineWidth(self, width)
Private method.

Inherited from common.Primitive: __del__, groupHidden, groupShown, hide, isGroupShown, isShown, setEntryID, setGlowColor, setIsGlowing, setRightClickOnGObject, show

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Static Methods [hide private]
 
_glSetup()
Private method to set up the GL state for boxes
 
_glReset()
Private method to reset the GL state for boxes
Class Variables [hide private]
  _blend = None
hash(x)
  _smooth_point = None
hash(x)
  _cull = None
hash(x)
  _lighting = None
hash(x)
  _lighting_model = None
hash(x)
  _shading_model = None
hash(x)
  _polygon_mode = None
hash(x)
  _line_width = 1.0
Properties [hide private]
  line_width
This attribute controls the width of the lines used to draw the box.

Inherited from object: __class__

Method Details [hide private]

__init__(self, vertices=None, center=None, extents=None, color=None, opacity=1.0, style=1)
(Constructor)

 

Constructor requires:

You may specify vertices  OR  extents and a center.  These
are in Angstroms 

vertices: List of 24 values: x1, y1, z1 ... x8, y8, z8   OR
          list of 8 vertex lists [x, y, z], ..., [x, y, z]

          Specify 4 vertices from one face first, then
          the corresponding 4 vertices from the parallel opposite 
          side. Do these in the same clockwise ordering
          as viewed from the same location.  For
          example, if the first vertex in the front face is top-left,
          then start 2nd rear face with top-left vertex as viewed
          from the same direction/location.

center:   List of 3 Angstrom values indicating the center coordinate 
          of the box.  If specified, extents must also be specified 
          and vertices will be ignored.

extents:  List of 3 float values in Angstroms - 
          x length, y length, z length.
          If this is specifiied, center must also be specified

/zone1/adzhigir/trunk/mmshare/python/modules/schrodinger/protein/membrane.pybb

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


Optional arguments:

opacity:  0.0 (invisible) through 1.0 (opaque)
               Defaults to 1.0
          
style:         LINE or FILL.  Default is FILL.

Overrides: object.__init__

_draw(self)

 

Private method to draw out the box with the current settings. This should only be called by BoxGroup instances.

_getLineWidth(self)

 

Private method. See docstring for line_width property.

_setLineWidth(self, width)

 

Private method. See docstring for line_width property.


Property Details [hide private]

line_width

This attribute controls the width of the lines used to draw the box. Width is a float and subject to the limitations of glLineWidth, meaning that (among other things) not all widths are supported. If an unsupported width is chosen, the nearest supported width is used. See the glLineWidth documentation for details on this and other behaviors.

Get Method:
_getLineWidth(self) - Private method.
Set Method:
_setLineWidth(self, width) - Private method.