Package schrodinger :: Package graphics3d :: Module lines :: Class Lines
[hide private]
[frames] | no frames]

Class Lines

      object --+    
               |    
common.Primitive --+
                   |
                  Lines


Class to draw a set of lines 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.

Lines with the same characteristics must be placed
(color, width) into a single Lines instance.

See doc string for __init__ for details on instantiation.

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

line_grp = common.Group()
st = maestro.workspace_get()
color='red'
displacement = 1.0
for at in st.atom: 
    vert = [
        (at.x - displacement, at.y, at.z),
        (at.x + displacement, at.y, at.z),
        (at.x, at.y - displacement, at.z),
        (at.x, at.y + displacement, at.z),
        (at.x, at.y, at.z - displacement),
        (at.x, at.y, at.z + displacement),
    ]
    # Add the primatives to the container.
    line_grp.add(lines.Lines(vertices=vert, color=color))

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

# Hide the markers.
line_grp.hide()

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

Instance Methods [hide private]
 
__init__(self, vertices=None, color=None, width=1.0)
Lines 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)

Inherited from common.Primitive: __del__, groupHidden, groupShown, hide, isGroupShown, isShown, setEntryID, 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 lines
 
_glReset()
Private method to reset the GL state for lines
Class Variables [hide private]
  _blend = None
hash(x)
  _smooth_point = None
hash(x)
  _smooth_line = None
hash(x)
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, vertices=None, color=None, width=1.0)
(Constructor)

 

Lines constructor requires:

vertices: List of vertex coordinates (x, y, z).
          Each vertex coordinate is itself an xyz list:
          [[x1,y1,z1],[x2,y2,z2]...]
          Treats each pair of vertices as an independent
          line segment.  Total number of vertices should be 2n.
          N/2 lines are drawn.  It is an error to
          specify an odd number of vertices.

color:    One of:
            Color object (Color class)
            Color name (string)
            Tuple of (R, G, B) (each a float in range 0.0-1.0)

Optional arguments:

width (float):  Defaults to 1.0.  Lines are always drawn out
                anti-aliased.  So the actual width is determined
                at rasterization time.  Not all widths are
                supported and if an unsupported width is chosen,
                the nearest supported with is used.  Only width
                1 is guaranteed to be supported.

Overrides: object.__init__

_draw(self)

 

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