Index: /trunk/configure
===================================================================
--- /trunk/configure	(revision 1956)
+++ /trunk/configure	(revision 1957)
@@ -9636,5 +9636,5 @@
 
 
-ac_config_files="$ac_config_files Makefile packages/Makefile src/Makefile src/core/Makefile src/core2/Makefile src/objects/Makefile src/objects/RpHash.h gui/Makefile gui/apps/Makefile gui/apps/about gui/apps/encodedata gui/apps/rappture gui/apps/rappture-csh.env gui/apps/rappture.env gui/apps/rappture.use gui/apps/rerun gui/apps/simsim gui/apps/xmldiff gui/pkgIndex.tcl gui/scripts/Makefile instant/Makefile instant/irappture lang/Makefile lang/java/Makefile lang/java/rappture/Makefile lang/perl/Makefile lang/perl/Makefile.PL lang/python/Makefile lang/python/setup.py lang/matlab/Makefile lang/octave/Makefile lang/octave/octave2/Makefile lang/octave/octave3/Makefile lang/ruby/Makefile lang/ruby/build.rb lang/tcl/Makefile lang/tcl/pkgIndex.tcl lang/tcl/src/Makefile lang/tcl/scripts/Makefile lang/tcl/tests/Makefile lib/Makefile examples/3D/Makefile examples/Makefile examples/app-fermi/2.0/Makefile examples/app-fermi/Makefile examples/app-fermi/cee/Makefile examples/app-fermi/fortran/Makefile examples/app-fermi/java/Makefile examples/app-fermi/matlab/Makefile examples/app-fermi/matlab/compiled/Makefile examples/app-fermi/matlab/uncompiled/Makefile examples/app-fermi/octave/Makefile examples/app-fermi/octave/2/Makefile examples/app-fermi/octave/3/Makefile examples/app-fermi/perl/Makefile examples/app-fermi/python/Makefile examples/app-fermi/ruby/Makefile examples/app-fermi/tcl/Makefile examples/app-fermi/wrapper/Makefile examples/app-fermi/wrapper/cee/Makefile examples/app-fermi/wrapper/perl/Makefile examples/app-fermi/wrapper/python/Makefile examples/app-fermi/wrapper/tcl/Makefile examples/c-example/Makefile examples/canvas/Makefile examples/demo.bash examples/flow/Makefile examples/flow/demo1/Makefile examples/flow/demo2/Makefile examples/flow/demo3/Makefile examples/graph/Makefile examples/objects/Makefile examples/objects/axis/Makefile examples/objects/contour/Makefile examples/objects/curve/Makefile examples/objects/dxWriter/Makefile examples/objects/floatBuffer/Makefile examples/objects/histogram/Makefile examples/objects/library/Makefile examples/objects/number/Makefile examples/objects/path/Makefile examples/objects/plot/Makefile examples/objects/scatter/Makefile examples/objects/string/Makefile examples/objects/tree/Makefile examples/objects/xmlparser/Makefile examples/zoo/Makefile examples/zoo/binary/Makefile examples/zoo/boolean/Makefile examples/zoo/cell/Makefile examples/zoo/choice/Makefile examples/zoo/cloud/Makefile examples/zoo/cloud/matlab/Makefile examples/zoo/curve/Makefile examples/zoo/enable/Makefile examples/zoo/field/Makefile examples/zoo/group/Makefile examples/zoo/image/Makefile examples/zoo/image/docs/Makefile examples/zoo/image/examples/Makefile examples/zoo/integer/Makefile examples/zoo/integer2/Makefile examples/zoo/loader/Makefile examples/zoo/loader/examples/Makefile examples/zoo/loadrun/Makefile examples/zoo/log/Makefile examples/zoo/note/Makefile examples/zoo/note/docs/Makefile examples/zoo/number/Makefile examples/zoo/number2/Makefile examples/zoo/periodicelement/Makefile examples/zoo/phase/Makefile examples/zoo/sequence/Makefile examples/zoo/sequence/examples/Makefile examples/zoo/string/Makefile examples/zoo/structure/Makefile examples/zoo/structure/examples/Makefile examples/zoo/table/Makefile examples/zoo/unirect2d/Makefile test/Makefile test/src/Makefile"
+ac_config_files="$ac_config_files Makefile packages/Makefile src/Makefile src/core/Makefile src/core2/Makefile src/objects/Makefile src/objects/RpHash.h gui/Makefile gui/apps/Makefile gui/apps/about gui/apps/encodedata gui/apps/rappture gui/apps/rappture-csh.env gui/apps/rappture.env gui/apps/rappture.use gui/apps/rerun gui/apps/simsim gui/apps/xmldiff gui/pkgIndex.tcl gui/scripts/Makefile instant/Makefile instant/irappture lang/Makefile lang/java/Makefile lang/java/rappture/Makefile lang/perl/Makefile lang/perl/Makefile.PL lang/python/Makefile lang/python/setup.py lang/matlab/Makefile lang/octave/Makefile lang/octave/octave2/Makefile lang/octave/octave3/Makefile lang/ruby/Makefile lang/ruby/build.rb lang/tcl/Makefile lang/tcl/pkgIndex.tcl lang/tcl/src/Makefile lang/tcl/scripts/Makefile lang/tcl/tests/Makefile lib/Makefile examples/3D/Makefile examples/Makefile examples/app-fermi/2.0/Makefile examples/app-fermi/Makefile examples/app-fermi/cee/Makefile examples/app-fermi/fortran/Makefile examples/app-fermi/java/Makefile examples/app-fermi/matlab/Makefile examples/app-fermi/matlab/compiled/Makefile examples/app-fermi/matlab/uncompiled/Makefile examples/app-fermi/octave/Makefile examples/app-fermi/octave/2/Makefile examples/app-fermi/octave/3/Makefile examples/app-fermi/perl/Makefile examples/app-fermi/python/Makefile examples/app-fermi/ruby/Makefile examples/app-fermi/tcl/Makefile examples/app-fermi/wrapper/Makefile examples/app-fermi/wrapper/cee/Makefile examples/app-fermi/wrapper/perl/Makefile examples/app-fermi/wrapper/python/Makefile examples/app-fermi/wrapper/tcl/Makefile examples/c-example/Makefile examples/canvas/Makefile examples/demo.bash examples/flow/Makefile examples/flow/demo1/Makefile examples/flow/demo2/Makefile examples/flow/demo3/Makefile examples/graph/Makefile examples/objects/Makefile examples/objects/axis/Makefile examples/objects/contour/Makefile examples/objects/curve/Makefile examples/objects/dxWriter/Makefile examples/objects/floatBuffer/Makefile examples/objects/histogram/Makefile examples/objects/library/Makefile examples/objects/number/Makefile examples/objects/path/Makefile examples/objects/plot/Makefile examples/objects/scatter/Makefile examples/objects/string/Makefile examples/objects/tree/Makefile examples/objects/xmlparser/Makefile examples/zoo/Makefile examples/zoo/binary/Makefile examples/zoo/boolean/Makefile examples/zoo/parallelepiped/Makefile examples/zoo/choice/Makefile examples/zoo/cloud/Makefile examples/zoo/cloud/matlab/Makefile examples/zoo/curve/Makefile examples/zoo/enable/Makefile examples/zoo/field/Makefile examples/zoo/group/Makefile examples/zoo/image/Makefile examples/zoo/image/docs/Makefile examples/zoo/image/examples/Makefile examples/zoo/integer/Makefile examples/zoo/integer2/Makefile examples/zoo/loader/Makefile examples/zoo/loader/examples/Makefile examples/zoo/loadrun/Makefile examples/zoo/log/Makefile examples/zoo/note/Makefile examples/zoo/note/docs/Makefile examples/zoo/number/Makefile examples/zoo/number2/Makefile examples/zoo/periodicelement/Makefile examples/zoo/phase/Makefile examples/zoo/sequence/Makefile examples/zoo/sequence/examples/Makefile examples/zoo/string/Makefile examples/zoo/structure/Makefile examples/zoo/structure/examples/Makefile examples/zoo/table/Makefile examples/zoo/unirect2d/Makefile test/Makefile test/src/Makefile"
 
 cat >confcache <<\_ACEOF
@@ -10433,5 +10433,5 @@
     "examples/zoo/binary/Makefile") CONFIG_FILES="$CONFIG_FILES examples/zoo/binary/Makefile" ;;
     "examples/zoo/boolean/Makefile") CONFIG_FILES="$CONFIG_FILES examples/zoo/boolean/Makefile" ;;
-    "examples/zoo/cell/Makefile") CONFIG_FILES="$CONFIG_FILES examples/zoo/cell/Makefile" ;;
+    "examples/zoo/parallelepiped/Makefile") CONFIG_FILES="$CONFIG_FILES examples/zoo/parallelepiped/Makefile" ;;
     "examples/zoo/choice/Makefile") CONFIG_FILES="$CONFIG_FILES examples/zoo/choice/Makefile" ;;
     "examples/zoo/cloud/Makefile") CONFIG_FILES="$CONFIG_FILES examples/zoo/cloud/Makefile" ;;
Index: /trunk/configure.in
===================================================================
--- /trunk/configure.in	(revision 1956)
+++ /trunk/configure.in	(revision 1957)
@@ -859,5 +859,5 @@
     examples/zoo/binary/Makefile
     examples/zoo/boolean/Makefile
-    examples/zoo/cell/Makefile
+    examples/zoo/parallelepiped/Makefile
     examples/zoo/choice/Makefile
     examples/zoo/cloud/Makefile
Index: /trunk/examples/zoo/Makefile.in
===================================================================
--- /trunk/examples/zoo/Makefile.in	(revision 1956)
+++ /trunk/examples/zoo/Makefile.in	(revision 1957)
@@ -33,4 +33,5 @@
 		number2 \
 		phase \
+		parallelepiped \
 		periodicelement \
 		sequence \
Index: /trunk/examples/zoo/parallelepiped/Makefile.in
===================================================================
--- /trunk/examples/zoo/parallelepiped/Makefile.in	(revision 1957)
+++ /trunk/examples/zoo/parallelepiped/Makefile.in	(revision 1957)
@@ -0,0 +1,38 @@
+
+bindir          = @bindir@
+datadir		= @datadir@
+datarootdir	= @datarootdir@
+exec_prefix     = @exec_prefix@
+includedir      = @includedir@
+libdir          = @libdir@
+mandir          = @mandir@
+srcdir		= @srcdir@
+prefix          = @prefix@
+
+INSTALL		= @INSTALL@
+MKDIR_P		= @MKDIR_P@
+VPATH		= $(srcdir)
+RM		= rm -f
+
+FILES		= \
+		$(srcdir)/parallelepiped.tcl \
+		$(srcdir)/tool.xml
+
+destdir		= $(prefix)/examples/zoo/parallelepiped
+
+all: 
+	$(MAKE) -C examples all
+
+install: 
+	$(MKDIR_P) -m 0755 $(destdir)
+	for i in $(FILES) ; do \
+	  $(INSTALL) -m 0444  $$i $(destdir) ; \
+	done
+	$(MAKE) -C examples install
+
+clean:
+	$(MAKE) -C examples clean
+
+distclean: 
+	$(MAKE) -C examples distclean
+	$(RM) Makefile *~
Index: /trunk/examples/zoo/parallelepiped/parallelepiped.tcl
===================================================================
--- /trunk/examples/zoo/parallelepiped/parallelepiped.tcl	(revision 1957)
+++ /trunk/examples/zoo/parallelepiped/parallelepiped.tcl	(revision 1957)
@@ -0,0 +1,33 @@
+
+
+package require Rappture
+
+set driver [Rappture::library [lindex $argv 0]]
+
+set components "output.structure.components"
+
+set pdb {
+ATOM      0   Si UNK A   1       0.000   0.000   0.000  1.00
+ATOM      1   Si UNK A   1       2.710   2.710   0.000  1.00
+ATOM      2   Si UNK A   1       2.710   0.000   2.710  1.00
+ATOM      3   Si UNK A   1       0.000   2.710   2.710  1.00
+ATOM      4   Si UNK A   1       5.420   2.710   2.710  1.00
+ATOM      5   Si UNK A   1       2.710   5.420   2.710  1.00
+ATOM      6   Si UNK A   1       2.710   2.710   5.420  1.00
+ATOM      7   Si UNK A   1       5.420   5.420   5.420  1.00
+ATOM      8   Si UNK A   1       1.355   1.355   1.355  1.00
+TER       9      UNK A   1
+}
+
+$driver put $components.molecule.pdb $pdb
+
+$driver put $components.parallelepiped.origin "0.0 0.0 0.0"
+$driver put $components.parallelepiped.scale "5.42"
+#$driver put $components.parallelepiped.scale "1.0"
+ 
+$driver put $components.parallelepiped.vector(1) ".5 .5 .0"
+$driver put $components.parallelepiped.vector(2) ".5 .0 .5"
+$driver put $components.parallelepiped.vector(3) ".0 .5 .5"
+
+Rappture::result $driver 
+exit 0
Index: /trunk/examples/zoo/parallelepiped/tool.xml
===================================================================
--- /trunk/examples/zoo/parallelepiped/tool.xml	(revision 1957)
+++ /trunk/examples/zoo/parallelepiped/tool.xml	(revision 1957)
@@ -0,0 +1,42 @@
+<?xml version="1.0"?>
+<run>
+    <tool>
+        <about>Press Simulate to view results.</about>
+        <command>tclsh @tool/parallelepiped.tcl @driver</command>
+    </tool>
+    <input>
+        <number id="temperature">
+            <about>
+                <label>Ambient temperature</label>
+                <description>Temperature of the environment.</description>
+            </about>
+            <units>K</units>
+            <min>0K</min>
+            <max>500K</max>
+            <default>300K</default>
+            <preset>
+                <value>300K</value>
+                <label>300K (room temperature)</label>
+            </preset>
+            <preset>
+                <value>77K</value>
+                <label>77K (liquid nitrogen)</label>
+            </preset>
+            <preset>
+                <value>4.2K</value>
+                <label>4.2K (liquid helium)</label>
+            </preset>
+        </number>
+        <number id="Ef">
+            <about>
+                <label>Fermi Level</label>
+                <description>Energy at center of distribution.</description>
+            </about>
+            <units>eV</units>
+            <min>-10eV</min>
+            <max>10eV</max>
+            <default>0eV</default>
+        </number>
+    </input>
+</run>
+
Index: /trunk/gui/scripts/molvisviewer.tcl
===================================================================
--- /trunk/gui/scripts/molvisviewer.tcl	(revision 1956)
+++ /trunk/gui/scripts/molvisviewer.tcl	(revision 1957)
@@ -135,7 +135,7 @@
     private method Representation {option {model "all"} }
     private method CartoonTrace {option {model "all"}}
+    private method ComputeParallelepipedVertices { dataobj }
     private method Cell {option}
     private method Rock {option}
-
 }
 
@@ -495,5 +495,5 @@
         "Set cartoon representation of bonds (sticks)."
 
-    checkbutton $inner.cell -text "Cell" \
+    checkbutton $inner.cell -text "Parallelepiped" \
 	-command [itcl::code $this Cell toggle] \
         -font "Arial 9 bold"
@@ -845,5 +845,5 @@
                 }
                 set _dataobjs($model-$state) 1
-            }
+	    }
         }
         if { ![info exists _model($model-transparency)] } {
@@ -862,13 +862,8 @@
             set _active($model) $dataobj
         }
-        set values [$dataobj get components.cell.values]
-	if { $values != "" } {
-	    regsub -all {,} $values { } values
-	    set rows {}
-	    foreach { x y z } $values {
-		lappend rows "    \[ $x, $y, $z \]"
-	    }
-	    set rows [join $rows ",\\\n"]
-	    SendCmd "raw -defer {verts = \[$rows\]\n}"
+        set vector [$dataobj get components.parallelepiped.vector]
+	if { $vector != "" } {
+	    set vertices [ComputeParallelepipedVertices $dataobj]
+	    SendCmd "raw -defer {verts = \[$vertices\]\n}"
 	    SendCmd "raw -defer {run \$PYMOL_PATH/rappture/box.py\n}"
 	    SendCmd "raw -defer {draw_box(verts)\n}"
@@ -876,5 +871,5 @@
 	}
     }
-
+	
     # enable/disable models as required (0=off->off, 1=on->off, 2=off->on,
     # 3=on->on)
@@ -2012,2 +2007,87 @@
 }
 
+itcl::body Rappture::MolvisViewer::snap { w h } {
+    if { $w <= 0 || $h <= 0 } {
+        set w [image width $_image(plot)]
+        set h [image height $_image(plot)]
+    } 
+    set tag "$_state(client),$_rocker(client)"
+    if { $_image(id) != "$tag" } {
+        while { ![info exists _imagecache($tag)] } {
+            update idletasks
+            update
+            after 100
+        }
+        if { [info exists _imagecache($tag)] } {
+            $_image(plot) configure -data $_imagecache($tag)
+            set _image(id) "$tag"
+        }
+    }
+    set img [image create picture -width $w -height $h]
+    $img resample $_image(plot)
+    return $img
+}
+
+# FIXME: Handle 2D vectors
+itcl::body Rappture::MolvisViewer::ComputeParallelepipedVertices { dataobj } {
+    # Create a vector for every 3D point
+    blt::vector point0(3) point1(3) point2(3) point3(3) point4(3) point5(3) \
+	point6(3) point7(3) origin(3) scale(3)
+
+    set count 0
+    set parent [$dataobj element -as object "components.parallelepiped"]
+    foreach child [$parent children] {
+	if { ![string match "vector*" $child] } {
+	    continue
+	}
+	incr count
+	set vector  [$parent get $child]
+	regexp -all {,} $vector {} vector
+	point$count set $vector
+    }
+    itcl::delete object $parent
+    if { $count < 1 || $count > 3 } {
+	error "bad number of vectors supplied to parallelepiped"
+    }
+    set values [$dataobj get components.parallelepiped.scale]
+    set n [llength $values]
+    scale set { 1.0 1.0 1.0 }
+    if { $n == 1 } {
+	set scale(0:2) [lindex $values 0]
+    } elseif { $n == 2 } {
+	set scale(0:1) [lindex $values 0]
+    } elseif { $n == 3 } {
+	scale set $values
+    }
+    set values [$dataobj get components.parallelepiped.origin]
+    set n [llength $values]
+    origin set { 0.0 0.0 0.0 }
+    if { $n == 1 } {
+	set origin(0) [lindex $values 0]
+    } elseif { $n == 2 } {
+	set origin(0) [lindex $values 0]
+	set origin(1) [lindex $values 1]
+    } elseif { $n == 3 } {
+	origin set $values
+    }
+    point0 set { 0.0 0.0 0.0 }
+    point4 expr {point2 + point1}
+    point5 expr {point4 + point3}
+    point6 expr {point2 + point3}
+    point7 expr {point1 + point3}
+
+    # Generate vertices as a string for PyMOL
+    set vertices ""
+    blt::vector x
+    foreach n { 0 1 0 2 0 3 1 4 2 4 2 6 1 7 3 7 5 7 4 5 3 6 5 } {
+	x expr "(point${n} * scale) + origin"
+	set values [x print 0 end]
+	append vertices "\[ [join $values {, }] \], \\\n"
+    }
+    x expr "(point6 * scale) + origin"
+    set values [x print 0 end]
+    append vertices "\[ [join $values {, }] \]  \\\n"
+    blt::vector destroy point0 point1 point2 point3 point4 point5 point6 \
+	point7 x origin scale
+    return $vertices
+}
