Changeset 1957


Ignore:
Timestamp:
Nov 17, 2010 7:51:18 AM (14 years ago)
Author:
gah
Message:

add unit cell to molvisviewer

Location:
trunk
Files:
4 added
1 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/configure

    r1944 r1957  
    96369636
    96379637
    9638 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"
     9638ac_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"
    96399639
    96409640cat >confcache <<\_ACEOF
     
    1043310433    "examples/zoo/binary/Makefile") CONFIG_FILES="$CONFIG_FILES examples/zoo/binary/Makefile" ;;
    1043410434    "examples/zoo/boolean/Makefile") CONFIG_FILES="$CONFIG_FILES examples/zoo/boolean/Makefile" ;;
    10435     "examples/zoo/cell/Makefile") CONFIG_FILES="$CONFIG_FILES examples/zoo/cell/Makefile" ;;
     10435    "examples/zoo/parallelepiped/Makefile") CONFIG_FILES="$CONFIG_FILES examples/zoo/parallelepiped/Makefile" ;;
    1043610436    "examples/zoo/choice/Makefile") CONFIG_FILES="$CONFIG_FILES examples/zoo/choice/Makefile" ;;
    1043710437    "examples/zoo/cloud/Makefile") CONFIG_FILES="$CONFIG_FILES examples/zoo/cloud/Makefile" ;;
  • trunk/configure.in

    r1944 r1957  
    859859    examples/zoo/binary/Makefile
    860860    examples/zoo/boolean/Makefile
    861     examples/zoo/cell/Makefile
     861    examples/zoo/parallelepiped/Makefile
    862862    examples/zoo/choice/Makefile
    863863    examples/zoo/cloud/Makefile
  • trunk/examples/zoo/Makefile.in

    r1629 r1957  
    3333                number2 \
    3434                phase \
     35                parallelepiped \
    3536                periodicelement \
    3637                sequence \
  • trunk/gui/scripts/molvisviewer.tcl

    r1943 r1957  
    135135    private method Representation {option {model "all"} }
    136136    private method CartoonTrace {option {model "all"}}
     137    private method ComputeParallelepipedVertices { dataobj }
    137138    private method Cell {option}
    138139    private method Rock {option}
    139 
    140140}
    141141
     
    495495        "Set cartoon representation of bonds (sticks)."
    496496
    497     checkbutton $inner.cell -text "Cell" \
     497    checkbutton $inner.cell -text "Parallelepiped" \
    498498        -command [itcl::code $this Cell toggle] \
    499499        -font "Arial 9 bold"
     
    845845                }
    846846                set _dataobjs($model-$state) 1
    847             }
     847            }
    848848        }
    849849        if { ![info exists _model($model-transparency)] } {
     
    862862            set _active($model) $dataobj
    863863        }
    864         set values [$dataobj get components.cell.values]
    865         if { $values != "" } {
    866             regsub -all {,} $values { } values
    867             set rows {}
    868             foreach { x y z } $values {
    869                 lappend rows "    \[ $x, $y, $z \]"
    870             }
    871             set rows [join $rows ",\\\n"]
    872             SendCmd "raw -defer {verts = \[$rows\]\n}"
     864        set vector [$dataobj get components.parallelepiped.vector]
     865        if { $vector != "" } {
     866            set vertices [ComputeParallelepipedVertices $dataobj]
     867            SendCmd "raw -defer {verts = \[$vertices\]\n}"
    873868            SendCmd "raw -defer {run \$PYMOL_PATH/rappture/box.py\n}"
    874869            SendCmd "raw -defer {draw_box(verts)\n}"
     
    876871        }
    877872    }
    878 
     873       
    879874    # enable/disable models as required (0=off->off, 1=on->off, 2=off->on,
    880875    # 3=on->on)
     
    20122007}
    20132008
     2009itcl::body Rappture::MolvisViewer::snap { w h } {
     2010    if { $w <= 0 || $h <= 0 } {
     2011        set w [image width $_image(plot)]
     2012        set h [image height $_image(plot)]
     2013    }
     2014    set tag "$_state(client),$_rocker(client)"
     2015    if { $_image(id) != "$tag" } {
     2016        while { ![info exists _imagecache($tag)] } {
     2017            update idletasks
     2018            update
     2019            after 100
     2020        }
     2021        if { [info exists _imagecache($tag)] } {
     2022            $_image(plot) configure -data $_imagecache($tag)
     2023            set _image(id) "$tag"
     2024        }
     2025    }
     2026    set img [image create picture -width $w -height $h]
     2027    $img resample $_image(plot)
     2028    return $img
     2029}
     2030
     2031# FIXME: Handle 2D vectors
     2032itcl::body Rappture::MolvisViewer::ComputeParallelepipedVertices { dataobj } {
     2033    # Create a vector for every 3D point
     2034    blt::vector point0(3) point1(3) point2(3) point3(3) point4(3) point5(3) \
     2035        point6(3) point7(3) origin(3) scale(3)
     2036
     2037    set count 0
     2038    set parent [$dataobj element -as object "components.parallelepiped"]
     2039    foreach child [$parent children] {
     2040        if { ![string match "vector*" $child] } {
     2041            continue
     2042        }
     2043        incr count
     2044        set vector  [$parent get $child]
     2045        regexp -all {,} $vector {} vector
     2046        point$count set $vector
     2047    }
     2048    itcl::delete object $parent
     2049    if { $count < 1 || $count > 3 } {
     2050        error "bad number of vectors supplied to parallelepiped"
     2051    }
     2052    set values [$dataobj get components.parallelepiped.scale]
     2053    set n [llength $values]
     2054    scale set { 1.0 1.0 1.0 }
     2055    if { $n == 1 } {
     2056        set scale(0:2) [lindex $values 0]
     2057    } elseif { $n == 2 } {
     2058        set scale(0:1) [lindex $values 0]
     2059    } elseif { $n == 3 } {
     2060        scale set $values
     2061    }
     2062    set values [$dataobj get components.parallelepiped.origin]
     2063    set n [llength $values]
     2064    origin set { 0.0 0.0 0.0 }
     2065    if { $n == 1 } {
     2066        set origin(0) [lindex $values 0]
     2067    } elseif { $n == 2 } {
     2068        set origin(0) [lindex $values 0]
     2069        set origin(1) [lindex $values 1]
     2070    } elseif { $n == 3 } {
     2071        origin set $values
     2072    }
     2073    point0 set { 0.0 0.0 0.0 }
     2074    point4 expr {point2 + point1}
     2075    point5 expr {point4 + point3}
     2076    point6 expr {point2 + point3}
     2077    point7 expr {point1 + point3}
     2078
     2079    # Generate vertices as a string for PyMOL
     2080    set vertices ""
     2081    blt::vector x
     2082    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 } {
     2083        x expr "(point${n} * scale) + origin"
     2084        set values [x print 0 end]
     2085        append vertices "\[ [join $values {, }] \], \\\n"
     2086    }
     2087    x expr "(point6 * scale) + origin"
     2088    set values [x print 0 end]
     2089    append vertices "\[ [join $values {, }] \]  \\\n"
     2090    blt::vector destroy point0 point1 point2 point3 point4 point5 point6 \
     2091        point7 x origin scale
     2092    return $vertices
     2093}
Note: See TracChangeset for help on using the changeset viewer.