Package schrodinger :: Package graphics3d :: Module polygon :: Class Polygon
[hide private]
[frames] | no frames]

Class Polygon

      object --+    
               |    
common.Primitive --+
                   |
                  Polygon
Known Subclasses:


Class to draw a flat polygon 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.

API Example
-----------
import schrodinger.maestro.maestro as maestro
import schrodinger.graphics3d.common as common
import schrodinger.graphics3d.polygon as polygon
import math

poly_grp = common.Group()
st = maestro.workspace_get()
at = st.atom[1]
vertices = []
for theta in range(0, 360, 80):
    theta_rad = theta * math.pi/180
    x = math.cos(theta_rad)
    y = math.sin(theta_rad) 
    vertices.append(
        (at.x + x, at.y + y, at.z)
    )
pgon = polygon.Polygon(
    vertices=vertices,
    color='red',
    opacity=0.8,
)

# Add the primative to the container.
poly_grp.add(pgon)

# Hide the markers.
poly_grp.hide()

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

Instance Methods [hide private]
 
__init__(self, vertices, color=None, opacity=1.0, style=1)
Constructor requires:
 
_checkVertexArgument(self, vertices)
Private method to check if the vertices are in the coorect 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, 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 polygons
 
_glReset()
Private method to reset the GL state for polygons
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)
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

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

 

Constructor requires:

vertices: List of vertex coordinates (x, y, z).
          Specify at least 3 vertices in consecutive order.
          All vertices must be in the same plane.

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:

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 Group instances.