Changeset 4919


Ignore:
Timestamp:
Jan 4, 2015 6:52:23 PM (9 years ago)
Author:
gah
Message:
 
Location:
branches/r9
Files:
41 edited

Legend:

Unmodified
Added
Removed
  • branches/r9/apps/Makefile.in

    r4914 r4919  
    2626                $(srcdir)/execute.tcl \
    2727                $(srcdir)/launcher.tcl \
    28                 $(srcdir)/mapviewer-test \
    2928                $(srcdir)/grabdata \
    3029                $(srcdir)/nanovis-test \
  • branches/r9/apps/launcher.tcl

    r4127 r4919  
    1212#    rappture -builder ?-tool <toolfile>?
    1313#    rappture -tester ?-tool <toolfile>? ?-testdir <directory>?
     14#    rappture -execute driver.xml ?-tool <toolfile>?
    1415#
    1516#  The default option is "-run", which brings up the GUI used to
     
    5354                set reqpkgs Tk
    5455            }
     56            -execute {
     57                # for web services and simulation cache -- don't load Tk
     58                set reqpkgs ""
     59                if {[llength $argv] < 1} {
     60                    puts stderr "error: missing driver.xml file for -execute option"
     61                    exit 1
     62                }
     63                set driverxml [lindex $argv 0]
     64                set argv [lrange $argv 1 end]
     65
     66                if {![file readable $driverxml]} {
     67                    puts stderr "error: driver file \"$driverxml\" not found"
     68                    exit 1
     69                }
     70
     71                set dir [file dirname [info script]]
     72                set mainscript [file join $dir execute.tcl]
     73            }
    5574            -tool {
    5675                set toolxml [lindex $argv 0]
     
    89108                puts stderr "  rappture -builder ?-tool toolFile?"
    90109                puts stderr "  rappture -tester ?-auto? ?-tool toolFile? ?-testdir directory?"
     110                puts stderr "  rappture -execute driver.xml ?-tool toolFile?"
    91111                exit 1
    92112            }
  • branches/r9/apps/rappture.use.in

    r4118 r4919  
    3333prepend TK_LIBRARY ${libdir}/tk${tcl_version}
    3434
     35prepend CLASSPATH ${libdir}/java
     36
    3537prepend R_LIBS ${libdir}/R
    3638
  • branches/r9/apps/rpdiff

    r3177 r4919  
    490490            }
    491491        }
     492        loader {
     493        }
    492494        default {
    493             error "don't know how to compare type \"$type\""
     495            puts stderr "ignoring \"$type1\" for \"$path\""
    494496        }
    495497    }
     
    557559
    558560# ======================================================================
    559 if {$argc != 2} {
     561
     562if {$argc < 2} {
    560563    puts stderr "USAGE: rpdiff file1.xml file2.xml"
    561564    exit 9
     
    563566set lib1 [Rappture::library [lindex $argv 0]]
    564567set lib2 [Rappture::library [lindex $argv 1]]
     568set path "output"
     569if { $argc > 2 } {
     570   set arg [lindex $argv 2]
     571   if { $arg == "-path" && $argc == 4 } {
     572      set path [lindex $argv 3]
     573   }
     574}
    565575
    566576# compute the differences
    567 set diffs [diff output $lib1 $lib2]
     577set diffs [diff $path $lib1 $lib2]
    568578
    569579if {[llength $diffs] == 0} {
  • branches/r9/gui/scripts/analyzer.tcl

    r4261 r4919  
    800800                        _autoLabel $xmlobj output.$item "Integer" counters
    801801                    }
     802                    mesh* {
     803                        _autoLabel $xmlobj output.$item "Mesh" counters
     804                    }
    802805                    string* {
    803806                        _autoLabel $xmlobj output.$item "String" counters
  • branches/r9/gui/scripts/balloon.tcl

    r3555 r4919  
    232232    # grab the mouse pointer
    233233    update
    234     while {[catch {grab set -local $itk_component(hull)}]} {
     234    while {[catch {grab set $itk_component(hull)}]} {
    235235        after 100
    236236    }
     
    249249
    250250    grab release $itk_component(hull)
    251 
    252251    wm withdraw $itk_component(hull)
    253252    foreach dir {left right above below} {
  • branches/r9/gui/scripts/bugreport.tcl

    r4003 r4919  
    8787        set h [winfo reqheight .bugreport]
    8888
    89         set rootx [winfo rootx .main]
    90         set rooty [winfo rooty .main]
    91         set mw [winfo reqwidth .main]
    92         set mh [winfo reqheight .main]
    93        
    94         set x [expr { $rootx + (($mw-$w)/2) }]
    95         if {$x < 0} {set x 0}
    96         set y [expr { $rooty + (($mh-$h)/2) }]
    97         if {$y < 0} {set y 0}
    98        
     89        set x [winfo rootx .main]
     90        set y [winfo rooty .main]
     91
     92        set mw [winfo width .main]
     93        if { $mw == 1 } {
     94            set mw [winfo reqwidth .main]
     95        }           
     96        set mh [winfo height .main]
     97        if { $mh == 1 } {
     98            set mh [winfo reqwidth .main]
     99        }           
     100        if { $mw > $w } {
     101            set x [expr { $x + (($mw-$w)/2) }]
     102        }
     103        if { $mh > $h } {
     104            set y [expr { $y + (($mh-$h)/2) }]
     105        }
    99106        wm geometry .bugreport +$x+$y
    100107        raise .bugreport
     
    151158    set h [winfo reqheight .bugreport]
    152159
    153     set rootx [winfo rootx .main]
    154     set rooty [winfo rooty .main]
    155     set mw [winfo reqwidth .main]
    156     set mh [winfo reqheight .main]
    157 
    158     set x [expr { $rootx + (($mw-$w)/2) }]
    159     if {$x < 0} {set x 0}
    160     set y [expr { $rooty + (($mh-$h)/2) }]
    161     if {$y < 0} {set y 0}
     160    set x [winfo rootx .main]
     161    set y [winfo rooty .main]
     162
     163    set mw [winfo width .main]
     164    if { $mw == 1 } {
     165        set mw [winfo reqwidth .main]
     166    }           
     167    set mh [winfo height .main]
     168    if { $mh == 1 } {
     169        set mh [winfo reqwidth .main]
     170    }           
     171
     172    if { $mw > $w } {
     173        set x [expr { $x + (($mw-$w)/2) }]
     174    }
     175    if { $mh > $h } {
     176        set y [expr { $y + (($mh-$h)/2) }]
     177    }
    162178
    163179    wm geometry .bugreport +$x+$y
     
    165181    raise .bugreport
    166182
    167     catch {grab -local set .bugreport}
     183    catch {grab set .bugreport}
    168184    update
    169185}
     
    474490    package require http
    475491    package require tls
    476     http::register https 443 ::tls::socket
     492    http::register https 443 [list ::tls::socket -tls1 1]
    477493
    478494    set report $details(stackTrace)
  • branches/r9/gui/scripts/cloud.tcl

    r4133 r4919  
    128128    foreach label [$_cloud get labels] axis { x y z } {
    129129        if { $label != "" } {
    130             set _axis2labels($axis) $label
     130            set _axis2label($axis) $label
    131131        } else {
    132             set _axis2labels($axis) [string toupper $axis]
     132            set _axis2label($axis) [string toupper $axis]
    133133        }
    134134    }
     
    149149        foreach {x y z} $line break
    150150        foreach axis {x y z} units $_units {
    151             set value [Rappture::Units::convert [set $axis] \
     151            if { $units == "" } {
     152                set value [set $axis]
     153            } else {
     154                set value [Rappture::Units::convert [set $axis] \
    152155                        -context $units -to $units -units off]
     156            }
    153157            set $axis $value;           # Set the (x/y/z) coordinate to
    154158                                        # converted value.
     
    266270#
    267271itcl::body Rappture::Cloud::label { axis } {
    268     if { ![info exists axis2label($axis)] } {
     272    if { ![info exists _axis2label($axis)] } {
    269273        return ""
    270274    }
    271     return $axis2label($axis)
     275    return $_axis2label($axis)
    272276}
    273277
  • branches/r9/gui/scripts/curve.tcl

    r4042 r4919  
    112112# USAGE: values ?<name>?
    113113#
    114 # Returns the xvec for the specified curve component <name>.
     114# Returns the yvec for the specified curve component <name>.
    115115# If the name is not specified, then it returns the vectors for the
    116116# overall curve (sum of all components).
  • branches/r9/gui/scripts/drawing.tcl

    r4002 r4919  
    11# -*- mode: tcl; indent-tabs-mode: nil -*-
    2 
    3 # ----------------------------------------------------------------------
    4 #  COMPONENT: drawing - 2D drawing of data
     2# ----------------------------------------------------------------------
     3#  COMPONENT: drawing - 3D drawing of data
    54# ======================================================================
    65#  AUTHOR:  Michael McLennan, Purdue University
     
    2019    private variable _drawing
    2120    private variable _xmlobj
    22     private variable _actors
    2321    private variable _styles
    2422    private variable _shapes
     
    2826    private variable _hints
    2927    private variable _units
    30     private variable _limits
    3128
    3229    constructor {xmlobj path} {
     
    3633        # defined below
    3734    }
    38     public method limits {axis}
     35
    3936    public method label { elem }
    4037    public method type { elem }
     
    6360        set xunits "um"
    6461    }
    65     array set _limits {
    66         xMin 0
    67         xMax 0
    68         yMin 0
    69         yMax 0
    70         zMin 0
    71         zMax 0
    72     }
    7362    # determine the overall size of the device
    7463    foreach elem [$_xmlobj children $path] {
    7564        switch -glob -- $elem {
    76             polygon* {
    77                 set _data($elem) [$_xmlobj get $path.$elem.vtk]
    78                 set _data($elem) [string trim $_data($elem)]
    79                 set _styles($elem) [$_xmlobj get $path.$elem.about.style]
    80                 set _labels($elem) [$_xmlobj get $path.$elem.about.label]
    81                 set _types($elem) polydata
    82             }
    83             polydata* {
     65            # polygon is deprecated in favor of polydata
     66            polygon* - polydata* {
    8467                set _data($elem) [$_xmlobj get $path.$elem.vtk]
    8568                set _data($elem) [string trim $_data($elem)]
     
    8770                set _labels($elem) [$_xmlobj get $path.$elem.about.label]
    8871                set _types($elem) polydata
    89             }
    90             streamlines* {
    91                 set _data($elem) [$_xmlobj get $path.$elem.vtk]
    92                 set _data($elem) [string trim $_data($elem)]
    93                 set _styles($elem) [$_xmlobj get $path.$elem.about.style]
    94                 set _labels($elem) [$_xmlobj get $path.$elem.about.label]
    95                 set _types($elem) streamlines
    9672            }
    9773            glyphs* {
     
    250226
    251227# ----------------------------------------------------------------------
    252 # method limits <axis>
    253 #       Returns a list {min max} representing the limits for the
    254 #       specified axis.
    255 # ----------------------------------------------------------------------
    256 itcl::body Rappture::Drawing::limits {which} {
    257     set min ""
    258     set max ""
    259     foreach key [array names _data] {
    260         set actor $_actors($key)
    261         foreach key { xMin xMax yMin yMax zMin zMax} value [$actor GetBounds] {
    262             set _limits($key) $value
    263         }
    264         break
    265     }   
    266    
    267     foreach key [array names _actors] {
    268         set actor $_actors($key)
    269         foreach { xMin xMax yMin yMax zMin zMax} [$actor GetBounds] break
    270         if { $xMin < $_limits(xMin) } {
    271             set _limits(xMin) $xMin
    272         }
    273         if { $xMax > $_limits(xMax) } {
    274             set _limits(xMax) $xMax
    275         }
    276         if { $yMin < $_limits(yMin) } {
    277             set _limits(yMin) $yMin
    278         }
    279         if { $yMax > $_limits(yMax) } {
    280             set _limits(yMax) $yMax
    281         }
    282         if { $zMin < $_limits(zMin) } {
    283             set _limits(zMin) $zMin
    284         }
    285         if { $zMax > $_limits(zMax) } {
    286             set _limits(zMax) $zMax
    287         }
    288     }
    289     switch -- $which {
    290         x {
    291             set min $_limits(xMin)
    292             set max $_limits(xMax)
    293             set axis "xaxis"
    294         }
    295         y {
    296             set min $_limits(yMin)
    297             set max $_limits(yMax)
    298             set axis "yaxis"
    299         }
    300         v - z {
    301             set min $_limits(zMin)
    302             set max $_limits(zMax)
    303             set axis "zaxis"
    304         }
    305         default {
    306             error "unknown axis description \"$which\""
    307         }
    308     }
    309     return [list $min $max]
    310 }
    311 
    312 # ----------------------------------------------------------------------
    313228# USAGE: hints ?<keyword>?
    314229#
     
    340255    return [array get _hints]
    341256}
    342 
  • branches/r9/gui/scripts/drawingentry.tcl

    r4176 r4919  
    146146        }
    147147        if {$name eq ""} {
    148             puts stderr "no name defined for substituion variable \"$cpath\""
     148            puts stderr "no name defined for substitution variable \"$cpath\""
    149149            continue
    150150        }
     
    672672itcl::body Rappture::DrawingEntry::ParsePolygon { cpath cname } {
    673673    array set attr2option {
     674        "outline"       "-outline"
     675        "color"         "-fill"
     676        "fill"          "-fill"
    674677        "linewidth"     "-width"
    675         "color"         "-fill"
    676678    }
    677679    # Set default options first and then let tool.xml override them.
  • branches/r9/gui/scripts/field.tcl

    r4251 r4919  
    11# -*- mode: tcl; indent-tabs-mode: nil -*-
    2 
    32# ----------------------------------------------------------------------
    43#  COMPONENT: field - extracts data from an XML description of a field
     
    8281                                        # valid data.
    8382    private variable _isValidComponent; #  Array of valid components found
     83    private variable _alwaysConvertDX 0;
     84
    8485    constructor {xmlobj path} {
    8586        # defined below
     
    152153    private method AvsToVtk { cname contents }
    153154    private method DicomToVtk { cname contents }
    154     private method DicomToVtk.old { cname contents }
    155155    private method BuildPointsOnMesh { cname }
    156156    protected method GetAssociation { cname }
     
    321321    }
    322322    if {[info exists _comp2dx($cname)]} {
    323         return ""  ;# no mesh -- it's embedded in the value data
     323        return ""  ;# no mesh -- it's embedded in the blob data
    324324    }
    325325    if {[info exists _comp2mesh($cname)]} {
     
    365365    }
    366366    if {[info exists _comp2dx($cname)]} {
    367         error "method \"values\" is not implemented for dx data"
     367        error "method \"values\" is not implemented for dx file data"
    368368    }
    369369    if {[info exists _comp2unirect2d($cname)]} {
    370         return [$_comp2unirect2d($cname) values]
     370        return $_values
    371371    }
    372372    if {[info exists _comp2unirect3d($cname)]} {
     
    392392    }
    393393    if {[info exists _comp2dx($cname)]} {
    394         return $_comp2dx($cname)
     394        return $_comp2dx($cname)  ;# return gzipped, base64-encoded DX data
    395395    }
    396396    if {[info exists _comp2unirect2d($cname)]} {
     
    405405}
    406406
     407# ----------------------------------------------------------------------
     408# USAGE: valueLimits <cname>
     409#
     410# Returns an array for the requested component with a list {min max}
     411# representing the limits for each axis.
     412# ----------------------------------------------------------------------
    407413itcl::body Rappture::Field::valueLimits { cname } {
    408414    if { [info exists _comp2limits($cname)] } {
     
    421427    set min ""
    422428    set max ""
    423     blt::vector tmp zero
    424429
    425430    foreach cname [array names _comp2dims] {
     
    447452
    448453                if {$log} {
    449                     # on a log scale, use abs value and ignore 0's
     454                    blt::vector tmp zero
     455                    # on a log scale, use abs value and ignore zeros
    450456                    $vname dup tmp
    451457                    $vname dup zero
    452                     zero expr {tmp == 0}            ;# find the 0's
     458                    zero expr {tmp == 0}            ;# find the zeros
    453459                    tmp expr {abs(tmp)}             ;# get the abs value
    454                     tmp expr {tmp + zero*max(tmp)}  ;# replace 0's with abs max
     460                    tmp expr {tmp + zero*max(tmp)}  ;# replace 0s with abs max
    455461                    set axisMin [blt::vector expr min(tmp)]
    456462                    set axisMax [blt::vector expr max(tmp)]
     463                    blt::vector destroy tmp zero
    457464                } else {
    458465                    set axisMin [$vname min]
     
    471478                }
    472479            }
    473             2D - 3D {
     480            default {
    474481                if {[info exists _comp2limits($cname)]} {
    475482                    array set limits $_comp2limits($cname)
     
    513520        }
    514521    }
    515     blt::vector destroy tmp zero
    516522    set val [$_field get "${axis}axis.min"]
    517523    if {"" != $val && "" != $min} {
     
    531537}
    532538
    533 
    534539# ----------------------------------------------------------------------
    535540# USAGE: fieldlimits
     
    541546    foreach cname [array names _comp2limits] {
    542547        array set limits $_comp2limits($cname)
    543         foreach fname $_comp2fldName($cname) {
     548        foreach fname [fieldnames $cname] {
    544549            if { ![info exists limits($fname)] } {
    545550                puts stderr "ERROR: field \"$fname\" unknown in \"$cname\""
     
    805810        set _comp2style($cname) ""
    806811        if { $type == "" } {
    807             puts stderr "WARNING: ignoring field component \"$_path.$cname\": no data found."
     812            puts stderr "WARNING: Ignoring field component \"$_path.$cname\": no data found."
    808813            continue
    809814        }
     
    881886            set contents [$_field get $cname.vtk]
    882887            if { $contents == "" } {
    883                 puts stderr "WARNING: no data fo \"$_path.$cname.vtk\""
     888                puts stderr "WARNING: No data for \"$_path.$cname.vtk\""
    884889                continue;               # Ignore this component
    885890            }
     
    899904            }
    900905            if { $_viewer == "" } {
    901                 set _viewer "nanovis"
     906                if {[$_field element $cname.flow] != ""} {
     907                    set _viewer "flowvis"
     908                } else {
     909                    set _viewer "nanovis"
     910                }
    902911            }
    903912            set _dim 3
     
    906915            set contents [Rappture::encoding::decode -as zb64 $data]
    907916            if { $contents == "" } {
    908                 puts stderr "WARNING: no data for \"$_path.$cname.$type\""
     917                puts stderr "WARNING: No data for \"$_path.$cname.$type\""
    909918                continue;               # Ignore this component
    910919            }
    911             set vector ""
    912920            if 0 {
    913921                set f [open /tmp/$_path.$cname.dx "w"]
     
    915923                close $f
    916924            }
    917             # This is temporary.  I put a check for this in the DxToVtk
    918             # parser. 
    919             if { [string range $contents  0 3] == "<DX>" } {
    920                 set contents [string range $contents 4 end]
    921             }
    922925            if { [catch { Rappture::DxToVtk $contents } vtkdata] == 0 } {
    923926                ReadVtkDataSet $cname $vtkdata
     927                if 0 {
     928                    set f [open /tmp/$_path.$cname.vtk "w"]
     929                    puts -nonewline $f $vtkdata
     930                    close $f
     931                }
    924932            } else {
    925933                puts stderr "Can't parse dx data: $vtkdata"
    926934            }
    927             if 0 {
    928                 set f [open /tmp/$_path.$cname.vtk "w"]
    929                 puts -nonewline $f $vtkdata
    930                 close $f
    931             }
    932             if { $_viewer != "nanovis" && $_viewer != "flowvis" } {
     935            if { $_alwaysConvertDX ||
     936                 ($_viewer != "nanovis" && $_viewer != "flowvis") } {
    933937                set _type "vtk"
    934938                set _comp2vtk($cname) $vtkdata
     
    942946                    [Rappture::FlowHints ::\#auto $_field $cname $_units]
    943947            }
    944             set _dim 3
    945948            incr _counter
    946949        } elseif { $type == "dicom"} {
     
    975978    }
    976979    if { [array size _isValidComponent] == 0 } {
    977         puts stderr "WARNING: no valid components for field \"$_path\""
     980        puts stderr "ERROR: All components of field \"$_path\" are invalid."
    978981        return 0
    979982    }
     
    987990        }
    988991        if { $dim != $_comp2dims($cname) } {
    989             puts stderr "WARNING: field can't have components of different dimensions: [join [array get _comp2dims] ,]"
     992            puts stderr "WARNING: A field can't have components of different dimensions: [join [array get _comp2dims] ,]"
    990993            return 0
    991994        }
     
    11841187    set dataAttrs [$dataset GetPointData]
    11851188    if { $dataAttrs == ""} {
    1186         puts stderr "WARNING: no point data found in \"$_path\""
     1189        puts stderr "WARNING: No point data found in \"$_path\""
    11871190        rename $reader ""
    11881191        return 0
     
    12471250        set dataAttrs [$dataset GetPointData]
    12481251        if { $dataAttrs == ""} {
    1249             puts stderr "WARNING: no point data found in \"$_path\""
     1252            puts stderr "WARNING: No point data found in \"$_path\""
    12501253            rename $reader ""
    12511254            return 0
     
    12531256        set array [$dataAttrs GetScalars]
    12541257        if { $array == ""} {
    1255             puts stderr "WARNING: no scalar point data found in \"$_path\""
     1258            puts stderr "WARNING: No scalar point data found in \"$_path\""
    12561259            rename $reader ""
    12571260            return 0
     
    12691272    set dataAttrs [$dataset GetPointData]
    12701273    if { $dataAttrs == ""} {
    1271         puts stderr "WARNING: no point data found in \"$_path\""
     1274        puts stderr "WARNING: No point data found in \"$_path\""
    12721275        rename $reader ""
    12731276        return 0
     
    15091512        set dim 0
    15101513        foreach axis {x y z} {
    1511             foreach {min max} [$mesh limits $axis] { 
     1514            foreach {min max} [$mesh limits $axis] {
    15121515                if { $min < $max } {
    15131516                    incr dim
     
    15401543        # sort x-coords in increasing order
    15411544        $xv sort $yv
    1542        
    15431545        set _comp2dims($cname) "1D"
    15441546        set _comp2xy($cname) [list $xv $yv]
     
    15561558            set _viewer "contour"
    15571559        }
     1560        set numFieldValues [$v length]
     1561        set numComponentsPerTuple [numComponents $cname]
     1562        if { [expr $numFieldValues % $numComponentsPerTuple] != 0 } {
     1563            puts stderr "ERROR: Number of field values ($numFieldValues) not divisble by elemsize ($numComponentsPerTuple)"
     1564            return 0
     1565        }
     1566        set numFieldTuples [expr $numFieldValues / $numComponentsPerTuple]
     1567        if { $_comp2assoc($cname) == "pointdata" } {
     1568            set numPoints [$mesh numpoints]
     1569            if { $numPoints != $numFieldTuples } {
     1570                puts stderr "ERROR: Number of points in mesh ($numPoints) and number of field tuples ($numFieldTuples) don't agree"
     1571                return 0
     1572            }
     1573        } elseif { $_comp2assoc($cname) == "celldata" } {
     1574            set numCells [$mesh numcells]
     1575            if { $numCells != $numFieldTuples } {
     1576                puts stderr "ERROR: Number of cells in mesh ($numCells) and number of field tuples ($numFieldTuples) don't agree"
     1577                return 0
     1578            }
     1579        }
    15581580        set _comp2dims($cname) "[$mesh dimensions]D"
    15591581        set _comp2mesh($cname) [list $mesh $v]
     
    15831605            return 0
    15841606        }
     1607        set numFieldValues [$v length]
     1608        set numComponentsPerTuple [numComponents $cname]
     1609        if { [expr $numFieldValues % $numComponentsPerTuple] != 0 } {
     1610            puts stderr "ERROR: Number of field values ($numFieldValues) not divisble by elemsize ($numComponentsPerTuple)"
     1611            return 0
     1612        }
     1613        set numFieldTuples [expr $numFieldValues / $numComponentsPerTuple]
     1614        if { $_comp2assoc($cname) == "pointdata" } {
     1615            set numPoints [$mesh numpoints]
     1616            if { $numPoints != $numFieldTuples } {
     1617                puts stderr "ERROR: Number of points in mesh ($numPoints) and number of field tuples ($numFieldTuples) don't agree"
     1618                return 0
     1619            }
     1620        } elseif { $_comp2assoc($cname) == "celldata" } {
     1621            set numCells [$mesh numcells]
     1622            if { $numCells != $numFieldTuples } {
     1623                puts stderr "ERROR: Number of cells in mesh ($numCells) and number of field tuples ($numFieldTuples) don't agree"
     1624                return 0
     1625            }
     1626        }
    15851627        set _comp2dims($cname) "[$mesh dimensions]D"
    15861628        set _comp2mesh($cname) [list $mesh $v]
     
    16591701    }
    16601702
    1661     foreach key [array names data] {
    1662         if {$key == "vtkdata"} {
    1663             if {1} {
    1664                 set f [open /tmp/$cname.vtk "w"]
    1665                 fconfigure $f -translation binary -encoding binary
    1666                 puts -nonewline $f $data(vtkdata)
    1667                 close $f
    1668             }
    1669         } else {
    1670             puts stderr "$key = \"$data($key)\""
     1703    if 0 {
     1704        foreach key [array names data] {
     1705            if {$key == "vtkdata"} {
     1706                if 0 {
     1707                    set f [open /tmp/$cname.vtk "w"]
     1708                    fconfigure $f -translation binary -encoding binary
     1709                    puts -nonewline $f $data(vtkdata)
     1710                    close $f
     1711                }
     1712            } else {
     1713                puts stderr "$key = \"$data($key)\""
     1714            }
    16711715        }
    16721716    }
     
    16781722    set _viewer $viewer
    16791723    return $data(vtkdata)
    1680 }
    1681 
    1682 itcl::body Rappture::Field::DicomToVtk.old { cname path } {
    1683     package require vtk
    1684 
    1685     if { ![file exists $path] } {
    1686         puts stderr "path \"$path\" doesn't exist."
    1687         return 0
    1688     }
    1689     set reader $this-datasetreader
    1690     vtkDICOMImageReader $reader
    1691     if { [file isdir $path] } {
    1692         set files [glob -nocomplain $path/*.dcm]
    1693         if { [llength $files] == 0 } {
    1694             puts stderr "no dicom files found in \"$path\""
    1695             #return 0
    1696         }       
    1697         $reader SetDirectoryName $path
    1698     } else {
    1699         $reader SetFileName $path
    1700     }
    1701     $reader Update
    1702    
    1703     set dataset [$reader GetOutput]
    1704     set limits {}
    1705     foreach {xmin xmax ymin ymax zmin zmax} [$dataset GetBounds] break
    1706     set _dim 0
    1707     if { $xmax > $xmin } {
    1708         incr _dim
    1709     }
    1710     if { $ymax > $ymin } {
    1711         incr _dim
    1712     }
    1713     if { $zmax > $zmin } {
    1714         incr _dim
    1715     }
    1716 
    1717     set _comp2dims($cname) "${_dim}D"
    1718 
    1719     lappend limits x [list $xmin $xmax]
    1720     lappend limits y [list $ymin $ymax]
    1721     lappend limits z [list $zmin $zmax]
    1722     set dataAttrs [$dataset GetPointData]
    1723     if { $dataAttrs == ""} {
    1724         puts stderr "WARNING: no point data found in \"$_path\""
    1725         rename $reader ""
    1726         return 0
    1727     }
    1728     set vmin 0
    1729     set vmax 1
    1730     set numArrays [$dataAttrs GetNumberOfArrays]
    1731     if { $numArrays > 0 } {
    1732         for {set i 0} {$i < [$dataAttrs GetNumberOfArrays] } {incr i} {
    1733             set array [$dataAttrs GetArray $i]
    1734             set fname  [$dataAttrs GetArrayName $i]
    1735             foreach {min max} [$array GetRange -1] break
    1736             if {$i == 0} {
    1737                 set vmin $min
    1738                 set vmax $max
    1739             }
    1740             lappend limits $fname [list $min $max]
    1741             set _fld2Units($fname) ""
    1742             set _fld2Label($fname) $fname
    1743             # Let the VTK file override the <type> designated.
    1744             set _fld2Components($fname) [$array GetNumberOfComponents]
    1745             lappend _comp2fldName($cname) $fname
    1746         }
    1747     }
    1748     lappend limits v [list $vmin $vmax]
    1749     set _comp2limits($cname) $limits
    1750 
    1751     set tmpfile $this-$cname.vtk
    1752     set writer $this-datasetwriter
    1753     vtkDataSetWriter $writer
    1754     $writer SetInputConnection [$reader GetOutputPort]
    1755     $writer SetFileName $tmpfile
    1756     $writer SetFileTypeToBinary
    1757     $writer Write
    1758     rename $reader ""
    1759     rename $writer ""
    1760 
    1761     set f [open "$tmpfile" "r"]
    1762     fconfigure $f -translation binary -encoding binary
    1763     set vtkdata [read $f]
    1764     close $f
    1765     file delete $tmpfile
    1766     return $vtkdata
    17671724}
    17681725
  • branches/r9/gui/scripts/fieldresult.tcl

    r4344 r4919  
    156156# ----------------------------------------------------------------------
    157157itcl::body Rappture::FieldResult::add {dataobj {settings ""}} {
     158    if { ![info exists itk_component(renderer)] } {
     159        puts stderr "add: no renderer created."
     160        return
     161    }
    158162    eval $itk_component(renderer) add $dataobj [list $settings]
    159163}
     
    166170# ----------------------------------------------------------------------
    167171itcl::body Rappture::FieldResult::get {} {
     172    if { ![info exists itk_component(renderer)] } {
     173        puts stderr "get: no renderer created."
     174        return
     175    }
    168176    return [$itk_component(renderer) get]
    169177}
     
    191199# ----------------------------------------------------------------------
    192200itcl::body Rappture::FieldResult::scale {args} {
     201    if { ![info exists itk_component(renderer)] } {
     202        puts stderr "scale: no renderer created."
     203        return
     204    }
    193205    eval $itk_component(renderer) scale $args
    194206}
     
    205217# ----------------------------------------------------------------------
    206218itcl::body Rappture::FieldResult::download {option args} {
     219    if { ![info exists itk_component(renderer)] } {
     220        puts stderr "download: no renderer created."
     221        return
     222    }
    207223    eval $itk_component(renderer) download $option $args
    208224}
    209225
    210226itcl::body Rappture::FieldResult::snap { w h } {
     227    if { ![info exists itk_component(renderer)] } {
     228        puts stderr "snap: no renderer created."
     229        return
     230    }
    211231    return [$itk_component(renderer) snap $w $h]
    212232}
  • branches/r9/gui/scripts/flowvisviewer.tcl

    r4336 r4919  
    250250        $this-streams           0
    251251        $this-volume            1
    252         $this-ambient           60
    253         $this-diffuse           40
    254         $this-light2side        1
    255         $this-opacity           100
    256         $this-specularLevel     30
    257         $this-specularExponent  90
    258         $this-thickness         350
    259         $this-transp            50
    260         $this-cutplaneVisible   0
    261         $this-xcutplane         1
     252        $this-xcutplane         0
    262253        $this-xcutposition      0
    263         $this-ycutplane         1
     254        $this-ycutplane         0
    264255        $this-ycutposition      0
    265         $this-zcutplane         1
     256        $this-zcutplane         0
    266257        $this-zcutposition      0
    267258    }]
     
    324315        "Toggle the volume cloud on/off"
    325316    pack $itk_component(volume) -padx 2 -pady 2
    326 
    327     itk_component add cutplane {
    328         Rappture::PushButton $f.cutplane \
    329             -onimage [Rappture::icon cutbutton] \
    330             -offimage [Rappture::icon cutbutton] \
    331             -variable [itcl::scope _settings($this-cutplaneVisible)] \
    332             -command [itcl::code $this AdjustSetting cutplaneVisible]
    333     }
    334     Rappture::Tooltip::for $itk_component(cutplane) \
    335         "Show/Hide cutplanes"
    336     pack $itk_component(cutplane) -padx 2 -pady 2
    337317
    338318    if { [catch {
     
    736716# ----------------------------------------------------------------------
    737717itcl::body Rappture::FlowvisViewer::scale {args} {
    738     array set style {
     718    array set styles {
    739719        -color BCGYR
    740720        -levels 6
     721        -markers ""
    741722        -opacity 1.0
    742         -markers ""
    743723    }
    744724    array unset _limits
     
    751731            if { ![info exists _volcomponents($cname)] } {
    752732                lappend _componentsList $cname
    753                 array set style [lindex [$dataobj components -style $cname] 0]
    754                 set cmap [ColorsToColormap $style(-color)]
     733                array set styles [lindex [$dataobj components -style $cname] 0]
     734                set cmap [ColorsToColormap $styles(-color)]
    755735                set _cname2defaultcolormap($cname) $cmap
    756                 set _settings($cname-colormap) $style(-color)
     736                set _settings($cname-colormap) $styles(-color)
    757737            }
    758738            lappend _volcomponents($cname) $dataobj-$cname
     
    904884                set session $env(SESSION)
    905885            }
     886            lappend info "version" "$Rappture::version"
     887            lappend info "build" "$Rappture::build"
     888            lappend info "svnurl" "$Rappture::svnurl"
     889            lappend info "installdir" "$Rappture::installdir"
    906890            lappend info "hub" [exec hostname]
    907891            lappend info "client" "flowvisviewer"
     
    10571041    set tf $_obj2style($tag)
    10581042    foreach {vmin vmax} [limits $tf] break
    1059     $c itemconfigure vmin -text [format %.2g $vmin]
     1043    $c itemconfigure vmin -text [format %g $vmin]
    10601044    $c coords vmin $lx $ly
    10611045
    1062     $c itemconfigure vmax -text [format %.2g $vmax]
     1046    $c itemconfigure vmax -text [format %g $vmax]
    10631047    $c coords vmax [expr {$w-$lx}] $ly
    10641048
     
    11891173    set _first [lindex [get] 0]
    11901174
    1191     foreach axis {x y z} {
    1192         # Turn off cutplanes for all volumes
    1193         SendCmd "cutplane state 0 $axis"
    1194     }
    1195 
    11961175    # Reset the camera and other view parameters
    1197     InitSettings light2side ambient diffuse specularLevel specularExponent \
    1198         transp isosurface grid axes volume outline \
    1199         cutplaneVisible xcutplane ycutplane zcutplane
    1200 
     1176    InitSettings light2side light transp isosurface grid axes volume outline
     1177   
    12011178    # nothing to send -- activate the proper volume
    12021179    if {"" != $_first} {
     1180        AdjustSetting light
     1181        AdjustSetting transp
    12031182        set axis [$_first hints updir]
    12041183        if {"" != $axis} {
     
    12511230    set vols [CurrentVolumeIds -cutplanes]
    12521231    foreach axis {x y z} {
     1232        SendCmd "cutplane state $_settings($this-${axis}cutplane) $axis $vols"
    12531233        set pos [expr {0.01*$_settings($this-${axis}cutposition)}]
    12541234        SendCmd "cutplane position $pos $axis $vols"
     
    12791259    foreach key [array names _serverObjs *-*] {
    12801260        if {[string match $_first-* $key]} {
    1281             array set style {
     1261            array set styles {
    12821262                -cutplanes 1
    12831263            }
    12841264            foreach {dataobj comp} [split $key -] break
    1285             array set style [lindex [$dataobj components -style $comp] 0]
    1286             if {$what != "-cutplanes" || $style(-cutplanes)} {
     1265            array set styles [lindex [$dataobj components -style $comp] 0]
     1266            if {$what != "-cutplanes" || $styles(-cutplanes)} {
    12871267                lappend rlist $_serverObjs($key)
    12881268            }
     
    15751555            #ResetColormap $color
    15761556        }
    1577         ambient {
     1557        light {
    15781558            if { $_first != "" } {
    15791559                set comp [lindex [$_first components] 0]
    15801560                set tag $_first-$comp
    1581                 set val $_settings($this-ambient)
    1582                 set val [expr {0.01*$val}]
    1583                 SendCmd "$tag configure -ambient $val"
    1584             }
    1585         }
    1586         diffuse {
    1587             if { $_first != "" } {
    1588                 set comp [lindex [$_first components] 0]
    1589                 set tag $_first-$comp
    1590                 set val $_settings($this-diffuse)
    1591                 set val [expr {0.01*$val}]
    1592                 SendCmd "$tag configure -diffuse $val"
    1593             }
    1594         }
    1595         specularLevel {
    1596             if { $_first != "" } {
    1597                 set comp [lindex [$_first components] 0]
    1598                 set tag $_first-$comp
    1599                 set val $_settings($this-specularLevel)
    1600                 set val [expr {0.01*$val}]
    1601                 SendCmd "$tag configure -specularLevel $val"
    1602             }
    1603         }
    1604         specularExponent {
    1605             if { $_first != "" } {
    1606                 set comp [lindex [$_first components] 0]
    1607                 set tag $_first-$comp
    1608                 set val $_settings($this-specularExponent)
    1609                 SendCmd "$tag configure -specularExp $val"
     1561                set diffuse [expr {0.01*$_settings($this-light)}]
     1562                set ambient [expr {1.0 - $diffuse}]
     1563                set specularLevel 0.3
     1564                set specularExp 90.0
     1565                SendCmd "$tag configure -ambient $ambient -diffuse $diffuse -specularLevel $specularLevel -specularExp $specularExp"
    16101566            }
    16111567        }
     
    16831639                SendCmd "$tag configure -volume $_settings($this-volume)"
    16841640            }
    1685         }
    1686         "cutplaneVisible" {
    1687             set bool $_settings($this-$what)
    1688             set datasets [CurrentVolumeIds -cutplanes]
    1689             set tag [lindex $datasets 0]
    1690             SendCmd "cutplane visible $bool $tag"
    16911641        }
    16921642        "xcutplane" - "ycutplane" - "zcutplane" {
     
    17571707#
    17581708itcl::body Rappture::FlowvisViewer::NameTransferFunc { dataobj cname } {
    1759     array set style {
     1709    array set styles {
     1710        -color BCGYR
     1711        -levels 6
     1712        -light 40
     1713        -opacity 1.0
     1714        -transp 50
     1715    }
     1716    array set styles [lindex [$dataobj components -style $cname] 0]
     1717    set _settings($this-light) $styles(-light)
     1718    set _settings($this-transp) $styles(-transp)
     1719    set _settings($this-opacity) [expr $styles(-opacity) * 100]
     1720    set _obj2style($dataobj-$cname) $cname
     1721    lappend _style2objs($cname) $dataobj $cname
     1722    return $cname
     1723}
     1724
     1725#
     1726# ComputeTransferFunc --
     1727#
     1728#   Computes and sends the transfer function to the render server.  It's
     1729#   assumed that the volume data limits are known and that the global
     1730#   transfer-functions slider values have be setup.  Both parts are
     1731#   needed to compute the relative value (location) of the marker, and
     1732#   the alpha map of the transfer function.
     1733#
     1734itcl::body Rappture::FlowvisViewer::ComputeTransferFunc { tf } {
     1735    array set styles {
    17601736        -color BCGYR
    17611737        -levels 6
     
    17641740        -transp 50
    17651741    }
    1766     array set style [lindex [$dataobj components -style $cname] 0]
    1767     set _settings($this-light) $style(-light)
    1768     set _settings($this-transp) $style(-transp)
    1769     set _settings($this-opacity) [expr $style(-opacity) * 100]
    1770     set _obj2style($dataobj-$cname) $cname
    1771     lappend _style2objs($cname) $dataobj $cname
    1772     return $cname
    1773 }
    1774 
    1775 #
    1776 # ComputeTransferFunc --
    1777 #
    1778 #   Computes and sends the transfer function to the render server.  It's
    1779 #   assumed that the volume data limits are known and that the global
    1780 #   transfer-functions slider values have be setup.  Both parts are
    1781 #   needed to compute the relative value (location) of the marker, and
    1782 #   the alpha map of the transfer function.
    1783 #
    1784 itcl::body Rappture::FlowvisViewer::ComputeTransferFunc { tf } {
    1785     array set style {
    1786         -color BCGYR
    1787         -levels 6
    1788         -opacity 1.0
    1789         -light 40
    1790         -transp 50
    1791     }
    17921742    set dataobj ""; set comp ""
    17931743    foreach {dataobj comp} $_style2objs($tf) break
     
    17951745        return 0
    17961746    }
    1797     array set style [lindex [$dataobj components -style $comp] 0]
     1747    array set styles [lindex [$dataobj components -style $comp] 0]
    17981748
    17991749
     
    18131763    if { ![info exists _isomarkers($tf)] } {
    18141764        # Have to defer creation of isomarkers until we have data limits
    1815         if { [info exists style(-markers)] &&
    1816              [llength $style(-markers)] > 0  } {
    1817             ParseMarkersOption $tf $style(-markers)
     1765        if { [info exists styles(-markers)] &&
     1766             [llength $styles(-markers)] > 0  } {
     1767            ParseMarkersOption $tf $styles(-markers)
    18181768        } else {
    1819             ParseLevelsOption $tf $style(-levels)
    1820         }
    1821     }
    1822     if { [info exists style(-nonuniformcolors)] } {
    1823         foreach { value color } $style(-nonuniformcolors) {
     1769            ParseLevelsOption $tf $styles(-levels)
     1770        }
     1771    }
     1772    if { [info exists styles(-nonuniformcolors)] } {
     1773        foreach { value color } $styles(-nonuniformcolors) {
    18241774            append cmap "$value [Color2RGB $color] "
    18251775        }
    18261776    } else {
    1827         set cmap [ColorsToColormap $style(-color)]
     1777        set cmap [ColorsToColormap $styles(-color)]
    18281778    }
    18291779    set tag $this-$tf
    18301780    if { ![info exists _settings($tag-opacity)] } {
    1831         set _settings($tag-opacity) $style(-opacity)
     1781        set _settings($tag-opacity) $styles(-opacity)
    18321782    }
    18331783    set max 1.0 ;#$_settings($tag-opacity)
     
    21732123
    21742124itcl::body Rappture::FlowvisViewer::BuildVolumeTab {} {
     2125    foreach { key value } {
     2126        light2side      1
     2127        light           40
     2128        transp          50
     2129        opacity         100
     2130        thickness       350
     2131    } {
     2132        set _settings($this-$key) $value
     2133    }
     2134
    21752135    set inner [$itk_component(main) insert end \
    21762136        -title "Volume Settings" \
     
    21932153        -command [itcl::code $this AdjustSetting light2side]
    21942154
    2195     label $inner.ambient_l -text "Ambient" -font $fg
    2196     ::scale $inner.ambient -from 0 -to 100 -orient horizontal \
    2197         -variable [itcl::scope _settings($this-ambient)] \
     2155    label $inner.dim -text "Glow" -font $fg
     2156    ::scale $inner.light -from 0 -to 100 -orient horizontal \
     2157        -variable [itcl::scope _settings($this-light)] \
    21982158        -width 10 \
    2199         -showvalue off -command [itcl::code $this AdjustSetting ambient]
    2200 
    2201     label $inner.diffuse_l -text "Diffuse" -font $fg
    2202     ::scale $inner.diffuse -from 0 -to 100 -orient horizontal \
    2203         -variable [itcl::scope _settings($this-diffuse)] \
    2204         -width 10 \
    2205         -showvalue off -command [itcl::code $this AdjustSetting diffuse]
    2206 
    2207     label $inner.specularLevel_l -text "Specular" -font $fg
    2208     ::scale $inner.specularLevel -from 0 -to 100 -orient horizontal \
    2209         -variable [itcl::scope _settings($this-specularLevel)] \
    2210         -width 10 \
    2211         -showvalue off -command [itcl::code $this AdjustSetting specularLevel]
    2212 
    2213     label $inner.specularExponent_l -text "Shininess" -font $fg
    2214     ::scale $inner.specularExponent -from 10 -to 128 -orient horizontal \
    2215         -variable [itcl::scope _settings($this-specularExponent)] \
    2216         -width 10 \
    2217         -showvalue off -command [itcl::code $this AdjustSetting specularExponent]
    2218 
    2219     label $inner.clear -text "Clear" -font $fg
     2159        -showvalue off -command [itcl::code $this AdjustSetting light]
     2160    label $inner.bright -text "Surface" -font $fg
     2161
     2162    label $inner.fog -text "Clear" -font $fg
    22202163    ::scale $inner.transp -from 0 -to 100 -orient horizontal \
    22212164        -variable [itcl::scope _settings($this-transp)] \
    22222165        -width 10 \
    22232166        -showvalue off -command [itcl::code $this AdjustSetting transp]
     2167    label $inner.plastic -text "Opaque" -font $fg
     2168
     2169    label $inner.clear -text "Clear" -font $fg
     2170    ::scale $inner.opacity -from 0 -to 100 -orient horizontal \
     2171        -variable [itcl::scope _settings($this-opacity)] \
     2172        -width 10 \
     2173        -showvalue off -command [itcl::code $this AdjustSetting opacity]
    22242174    label $inner.opaque -text "Opaque" -font $fg
    22252175
     
    22352185        Rappture::Combobox $inner.colormap -width 10 -editable no
    22362186    }
     2187
    22372188    $inner.colormap choices insert end [GetColormapList -includeNone]
    22382189    $itk_component(colormap) value "BCGYR"
     
    22442195        1,0 $inner.shading -cspan 4 -anchor w -pady {10 2} \
    22452196        2,0 $inner.light2side -cspan 4 -anchor w -pady 2 \
    2246         3,0 $inner.ambient_l -anchor e -pady 2 \
    2247         3,1 $inner.ambient -cspan 3 -pady 2 -fill x \
    2248         4,0 $inner.diffuse_l -anchor e -pady 2 \
    2249         4,1 $inner.diffuse -cspan 3 -pady 2 -fill x \
    2250         5,0 $inner.specularLevel_l -anchor e -pady 2 \
    2251         5,1 $inner.specularLevel -cspan 3 -pady 2 -fill x \
    2252         6,0 $inner.specularExponent_l -anchor e -pady 2 \
    2253         6,1 $inner.specularExponent -cspan 3 -pady 2 -fill x \
    2254         7,0 $inner.clear -anchor e -pady 2 \
    2255         7,1 $inner.transp -cspan 2 -pady 2 -fill x \
    2256         7,3 $inner.opaque -anchor w -pady 2 \
    2257         8,0 $inner.thin -anchor e -pady 2 \
    2258         8,1 $inner.thickness -cspan 2 -pady 2 -fill x \
    2259         8,3 $inner.thick -anchor w -pady 2
     2197        3,0 $inner.dim -anchor e -pady 2 \
     2198        3,1 $inner.light -cspan 2 -pady 2 -fill x \
     2199        3,3 $inner.bright -anchor w -pady 2 \
     2200        4,0 $inner.fog -anchor e -pady 2 \
     2201        4,1 $inner.transp -cspan 2 -pady 2 -fill x \
     2202        4,3 $inner.plastic -anchor w -pady 2 \
     2203        5,0 $inner.thin -anchor e -pady 2 \
     2204        5,1 $inner.thickness -cspan 2 -pady 2 -fill x\
     2205        5,3 $inner.thick -anchor w -pady 2
    22602206
    22612207    blt::table configure $inner c0 c1 c3 r* -resize none
    2262     blt::table configure $inner r9 -resize expand
     2208    blt::table configure $inner r6 -resize expand
    22632209}
    22642210
     
    22792225    Rappture::Tooltip::for $itk_component(xCutButton) \
    22802226        "Toggle the X cut plane on/off"
    2281     $itk_component(xCutButton) select
    22822227
    22832228    itk_component add xCutScale {
     
    23072252    Rappture::Tooltip::for $itk_component(yCutButton) \
    23082253        "Toggle the Y cut plane on/off"
    2309     $itk_component(yCutButton) select
    23102254
    23112255    itk_component add yCutScale {
     
    23352279    Rappture::Tooltip::for $itk_component(zCutButton) \
    23362280        "Toggle the Z cut plane on/off"
    2337     $itk_component(zCutButton) select
    23382281
    23392282    itk_component add zCutScale {
  • branches/r9/gui/scripts/grab.tcl

    r3330 r4919  
    3939# ----------------------------------------------------------------------
    4040rename grab _tk_grab
    41 proc grab {args} {
     41proc grab { args } {
    4242    set op [lindex $args 0]
    4343    if {[winfo exists $op]} {
     
    5454        set state $::Rappture::grab::state
    5555        set window [lindex $args end]
     56
    5657        if {[lsearch -exact $args -global] >= 0} {
    5758            set state "-global"
     
    9192
    9293        # and set the next one
    93         if {"" != $window} {
    94             if {[lindex $window 0] != "-global"} {
    95                 # no more global grabs -- resume local grabs
    96                 set ::Rappture::grab::state ""
    97             }
     94        if {[lindex $window 0] != "-global"} {
     95            # no more global grabs -- resume local grabs
     96            set ::Rappture::grab::state ""
     97        }
     98        if { $window != "" } {
    9899            eval _grabset $window
    99100        }
  • branches/r9/gui/scripts/isomarker.tcl

    r4166 r4919  
    113113        set _value $x
    114114        set y 31
    115         $_canvas itemconfigure $_label -text [format %.2g $_value]
     115        $_canvas itemconfigure $_label -text [format %g $_value]
    116116        set x [screenpos]
    117117        $_canvas coords $_tick $x [expr {$y+3}]
  • branches/r9/gui/scripts/map.tcl

    r4303 r4919  
    119119        set name "layer[incr _nextLayer]"
    120120        set child [$_tree insert $parent -label $name]
    121         $_tree set $child "title" [$layers get $layer.label]
    122121        set layerType [$layers get $layer.type]
    123122        if { ![info exists _layerTypes($layerType)] } {
     
    126125        $_tree set $child "name" $layer
    127126        $_tree set $child "type" $layerType
    128         foreach key { label description url } {
     127        foreach key { label description } {
    129128            $_tree set $child $key [$layers get $layer.$key]
    130129        }
    131130        # Common settings (for all layer types) with defaults
    132         foreach {key defval} { visible true } {
     131        foreach { key defval } { visible true } {
    133132            $_tree set $child $key $defval
    134133            set val [$layers get $layer.$key]
     
    146145            }
    147146        }
    148         set file [$layers get $layer.file]
    149         if { $file != "" } {
    150             # FIXME: Add test for valid file path
    151             $_tree set $child "url" $file
     147        $_tree set $child "driver" "debug"
     148        set gdal [$layers element -as type $layer.gdal]
     149        if { $gdal != "" } {
     150            foreach key { url } {
     151                set value [$layers get $layer.gdal.$key]
     152                $_tree set $child "gdal.$key" $value
     153            }
     154            set file [$layers get $layer.gdal.file]
     155            if { $file != "" } {
     156                # FIXME: Add test for valid file path
     157                $_tree set $child "gdal.url" $file
     158            }
     159            $_tree set $child "driver" "gdal"
     160        }
     161        set ogr [$layers element -as type $layer.ogr]
     162        if { $ogr != "" } {
     163            foreach key { url } {
     164                set value [$layers get $layer.ogr.$key]
     165                $_tree set $child "ogr.$key" $value
     166            }
     167            set file [$layers get $layer.ogr.file]
     168            if { $file != "" } {
     169                # FIXME: Add test for valid file path
     170                $_tree set $child "ogr.url" $file
     171            }
     172            $_tree set $child "driver" "ogr"
     173        }
     174        set tfs [$layers element -as type $layer.tfs]
     175        if { $tfs != "" } {
     176            foreach key { url format } {
     177                set value [$layers get $layer.tfs.$key]
     178                $_tree set $child "tfs.$key" $value
     179            }
     180            $_tree set $child "driver" "tfs"
     181        }
     182        set tms [$layers element -as type $layer.tms]
     183        if { $tms != "" } {
     184            foreach key { url tmsType format } {
     185                set value [$layers get $layer.tms.$key]
     186                $_tree set $child "tms.$key" $value
     187            }
     188            $_tree set $child "driver" "tms"
     189        }
     190        set wfs [$layers element -as type $layer.wfs]
     191        if { $wfs != "" } {
     192            foreach key { url typename outputformat maxfeatures request_buffer } {
     193                set value [$layers get $layer.wfs.$key]
     194                $_tree set $child "wfs.$key" $value
     195            }
     196            $_tree set $child "driver" "wfs"
     197        }
     198        set wms [$layers element -as type $layer.wms]
     199        if { $wms != "" } {
     200            foreach key { url layers format transparent } {
     201                set value [$layers get $layer.wms.$key]
     202                $_tree set $child "wms.$key" $value
     203            }
     204            $_tree set $child "driver" "wms"
     205        }
     206        set xyz [$layers element -as type $layer.xyz]
     207        if { $xyz != "" } {
     208            foreach key { url } {
     209                set value [$layers get $layer.xyz.$key]
     210                $_tree set $child "xyz.$key" $value
     211            }
     212            $_tree set $child "driver" "xyz"
    152213        }
    153214    }
  • branches/r9/gui/scripts/mapviewer.tcl

    r4336 r4919  
    7272    protected method DoResize {}
    7373    protected method DoRotate {}
    74     protected method FixSettings { args  }
     74    protected method InitSettings { args  }
    7575    protected method KeyPress { key }
    7676    protected method KeyRelease { key }
     
    177177    # to update the Lat/Long coordinate display
    178178    array set _motion {
     179        compress        0
     180        delay           100
     181        enable          0
     182        pending         0
    179183        x               0
    180184        y               0
    181         pending         0
    182         delay           100
    183         compress        0
    184185    }
    185186    # This array holds the Viewpoint parameters that the
    186187    # server sends on "camera get".
    187188    array set _view {
     189        distance        1.0
     190        heading         0.0
     191        pitch           -89.9
     192        srs             ""
     193        verticalDatum   ""
    188194        x               0.0
    189195        y               0.0
    190196        z               0.0
    191         heading         0.0
    192         pitch           -89.9
    193         distance        1.0
    194         srs             ""
    195         verticalDatum   ""
    196197    }
    197198
     
    200201    array set _settings [subst {
    201202        camera-throw           0
     203        coords-precision       5
     204        coords-units           "latlong_decimal_degrees"
     205        coords-visible         1
    202206        grid                   0
    203207        grid-type              "geodetic"
     
    334338            [itcl::code $this MouseRelease 3 %x %y]
    335339
    336         bind $itk_component(view) <Motion> \
    337             [itcl::code $this EventuallyHandleMotionEvent %x %y]
     340        # Binding for mouse motion events
     341        if {$_motion(enable)} {
     342            bind $itk_component(view) <Motion> \
     343                [itcl::code $this EventuallyHandleMotionEvent %x %y]
     344        }
    338345    } else {
    339346        # Bindings for panning via mouse
     
    344351        bind $itk_component(view) <ButtonRelease-1> \
    345352            [itcl::code $this Pan release %x %y]
     353        bind $itk_component(view) <Button-1> \
     354            +[itcl::code $this SendCmd "map setpos %x %y"]
    346355        bind $itk_component(view) <Double-1> \
    347356            [itcl::code $this camera go %x %y 0.4]
     
    364373        bind $itk_component(view) <Double-3> \
    365374            [itcl::code $this camera go %x %y 2.5]
     375        bind $itk_component(view) <Double-3> \
     376            +[itcl::code $this SendCmd "map setpos %x %y"]
    366377
    367378        # Bindings for panning via keyboard
     
    375386            [itcl::code $this Pan set 0 10]
    376387
    377         # Send (compressed) motion events to update Lat/Long
     388        # Binding for mouse motion events
    378389        set _motion(compress) 1
    379         bind $itk_component(view) <Motion> \
    380             [itcl::code $this EventuallyHandleMotionEvent %x %y]
     390        if {$_motion(enable)} {
     391            bind $itk_component(view) <Motion> \
     392                [itcl::code $this EventuallyHandleMotionEvent %x %y]
     393        }
    381394    }
    382395
     
    954967                SetTerrainStyle $_mapsettings(style)
    955968            } else {
    956                 FixSettings terrain-edges terrain-lighting \
     969                InitSettings terrain-edges terrain-lighting \
    957970                    terrain-vertscale terrain-wireframe
    958971            }
     972            InitSettings coords-visible
    959973        } else {
    960974            error "No map settings on reset"
     
    971985            array set info [$dataobj layer $layer]
    972986            if { ![info exists _layers($layer)] } {
    973                 if { ![info exists info(url)] }  {
    974                     continue
    975                 }
    976987                if { $_reportClientInfo }  {
    977988                    set cinfo {}
     
    12941305
    12951306# ----------------------------------------------------------------------
    1296 # USAGE: FixSettings <what> ?<value>?
     1307# USAGE: InitSettings <what> ?<value>?
    12971308#
    12981309# Used internally to update rendering settings whenever parameters
     
    13001311# to the back end.
    13011312# ----------------------------------------------------------------------
    1302 itcl::body Rappture::MapViewer::FixSettings { args } {
     1313itcl::body Rappture::MapViewer::InitSettings { args } {
    13031314    foreach setting $args {
    13041315        AdjustSetting $setting
     
    13181329    }
    13191330    switch -- $what {
     1331        "coords-visible" - "coords-precision" - "coords-units" {
     1332            set bool $_settings(coords-visible)
     1333            set units $_settings(coords-units)
     1334            set precision $_settings(coords-precision)
     1335            SendCmd "map posdisp $bool $units $precision"
     1336        }
    13201337        "grid" - "grid-type" {
    13211338            set bool $_settings(grid)
     
    13241341        }
    13251342        "camera-throw" {
    1326             set bool $_settings(camera-throw)
     1343            set bool $_settings($what)
    13271344            SendCmd "camera throw $bool"
    13281345        }
    13291346        "terrain-edges" {
    1330             set bool $_settings(terrain-edges)
     1347            set bool $_settings($what)
    13311348            SendCmd "map terrain edges $bool"
    13321349        }
    13331350        "terrain-lighting" {
    1334             set bool $_settings(terrain-lighting)
     1351            set bool $_settings($what)
    13351352            SendCmd "map terrain lighting $bool"
    13361353        }
     
    13401357        }
    13411358        "terrain-vertscale" {
    1342             set val $_settings(terrain-vertscale)
     1359            set val $_settings($what)
    13431360            SendCmd "map terrain vertscale $val"
    13441361        }
    13451362        "terrain-wireframe" {
    1346             set bool $_settings(terrain-wireframe)
     1363            set bool $_settings($what)
    13471364            SendCmd "map terrain wireframe $bool"
    13481365        }
     
    13871404        -icon [Rappture::icon surface]]
    13881405    $inner configure -borderwidth 4
     1406
     1407    checkbutton $inner.posdisp \
     1408        -text "Show Coordinate Readout" \
     1409        -variable [itcl::scope _settings(coords-visible)] \
     1410        -command [itcl::code $this AdjustSetting coords-visible] \
     1411        -font "Arial 9" -anchor w
    13891412
    13901413    checkbutton $inner.grid \
     
    14321455
    14331456    blt::table $inner \
    1434         0,0 $inner.grid      -cspan 2  -anchor w -pady 2 \
    1435         1,0 $inner.wireframe -cspan 2  -anchor w -pady 2 \
    1436         2,0 $inner.lighting  -cspan 2  -anchor w -pady 2 \
    1437         3,0 $inner.edges     -cspan 2  -anchor w -pady 2 \
    1438         4,0 $inner.vscale_l  -anchor w -pady 2 \
    1439         4,1 $inner.vscale    -fill x   -pady 2 \
    1440         5,0 $inner.palette_l -anchor w -pady 2 \
    1441         5,1 $inner.palette   -fill x   -pady 2 
     1457        0,0 $inner.posdisp   -cspan 2  -anchor w -pady 2 \
     1458        1,0 $inner.grid      -cspan 2  -anchor w -pady 2 \
     1459        2,0 $inner.wireframe -cspan 2  -anchor w -pady 2 \
     1460        3,0 $inner.lighting  -cspan 2  -anchor w -pady 2 \
     1461        4,0 $inner.edges     -cspan 2  -anchor w -pady 2 \
     1462        5,0 $inner.vscale_l  -anchor w -pady 2 \
     1463        5,1 $inner.vscale    -fill x   -pady 2 \
     1464        6,0 $inner.palette_l -anchor w -pady 2 \
     1465        6,1 $inner.palette   -fill x   -pady 2 
    14421466
    14431467    blt::table configure $inner r* c* -resize none
    1444     blt::table configure $inner r7 c1 -resize expand
     1468    blt::table configure $inner r8 c1 -resize expand
    14451469}
    14461470
     
    14521476    set inner [$itk_component(main) insert end \
    14531477        -title "Layers" \
    1454         -icon [Rappture::icon wrench]]
     1478        -icon [Rappture::icon layers]]
    14551479    $inner configure -borderwidth 4
    14561480    set f [frame $inner.layers]
     
    16981722            }
    16991723            if {!$_sendEarthFile} {
    1700                 SendCmd [list map layer add image gdal $info(url) $layer]
     1724                switch -- $info(driver)  {
     1725                    "debug" {
     1726                        SendCmd [list map layer add image debug $layer]
     1727                    }
     1728                    "gdal" {
     1729                        SendCmd [list map layer add image gdal \
     1730                                     $info(gdal.url) $layer]
     1731                    }
     1732                    "tms" {
     1733                        SendCmd [list map layer add image tms \
     1734                                     $info(tms.url) $layer]
     1735                    }
     1736                    "wms" {
     1737                        SendCmd [list map layer add image wms \
     1738                                     $info(wms.url) \
     1739                                     $info(wms.layers) \
     1740                                     $info(wms.format) \
     1741                                     $info(wms.transparent) \
     1742                                     $layer]
     1743                    }
     1744                    "xyz" {
     1745                        SendCmd [list map layer add image xyz \
     1746                                     $info(xyz.url) \
     1747                                     $layer]
     1748                    }
     1749                }                       
    17011750            }
    17021751            SendCmd "map layer opacity $settings(-opacity) $layer"
     
    17111760            }
    17121761            if {!$_sendEarthFile} {
    1713                 SendCmd [list map layer add elevation gdal $info(url) $layer]
     1762                switch -- $info(driver)  {
     1763                    "gdal" {
     1764                        SendCmd [list map layer add elevation gdal \
     1765                                     $info(gdal.url) $layer]
     1766                    }
     1767                    "tms" {
     1768                        SendCmd [list map layer add elevation tms \
     1769                                     $info(tms.url) $layer]
     1770                    }
     1771                }
    17141772            }
    17151773        }
     
    17271785                set settings(-opacity) $info(opacity)
    17281786            }
    1729             SendCmd [list map layer add line $info(url) $layer]
     1787            SendCmd [list map layer add line $info(ogr.url) $layer]
    17301788            SendCmd "map layer opacity $settings(-opacity) $layer"
    17311789        }
     
    17421800                set settings(-opacity) $info(opacity)
    17431801            }
    1744             SendCmd [list map layer add polygon $info(url) $layer]
     1802            SendCmd [list map layer add polygon $info(ogr.url) $layer]
    17451803            SendCmd "map layer opacity $settings(-opacity) $layer"
    17461804        }
     
    17711829                set priorityExpr ""
    17721830            }
    1773             SendCmd [list map layer add text $info(url) $contentExpr $priorityExpr $layer]
     1831            SendCmd [list map layer add text $info(ogr.url) $contentExpr $priorityExpr $layer]
    17741832            SendCmd "map layer opacity $settings(-opacity) $layer"
    17751833        }
     
    18151873            array set info [$dataobj layer $layer]
    18161874            checkbutton $f.$layer \
    1817                 -text $info(title) \
     1875                -text $info(label) \
    18181876                -variable [itcl::scope _visibility($layer)] \
    18191877                -command [itcl::code $this \
  • branches/r9/gui/scripts/mesh.tcl

    r4259 r4919  
    3333                                        # xmin, xmax, ymin, ymax, ...
    3434    private variable _numPoints 0   ;   # # of points in mesh
    35     private variable _numCells 0   ;    # # of cells in mesh
     35    private variable _numCells 0;       # # of cells in mesh
    3636    private variable _vtkdata "";       # Mesh in vtk file format.
    3737    private variable _isValid 0;        # Indicates if the mesh is valid.
     
    6363        return $_numPoints
    6464    }
    65 
     65    public method numcells {} {
     66        return $_numCells
     67    }
    6668
    6769    private common _xp2obj       ;      # used for fetch/release ref counting
     
    7476   
    7577    private method ReadNodesElements {path}
     78    private method GetCellCount { xNum yNum zNum }
    7679    private method GetDimension { path }
    7780    private method GetDouble { path }
     
    8386    private method WriteTriangles { path xv yv zv triangles }
    8487    private method WriteQuads { path xv yv zv quads }
     88    private method WriteVertices { path xv yv zv vertices }
     89    private method WriteLines { path xv yv zv lines }
     90    private method WritePolygons { path xv yv zv polygons }
     91    private method WriteTriangleStrips { path xv yv zv trianglestrips }
    8592    private method WriteTetrahedrons { path xv yv zv tetrahedrons }
    8693    private method WriteHexahedrons { path xv yv zv hexhedrons }
     
    420427        }
    421428    }
     429    foreach {key path} {
     430        toolid          tool.id
     431        toolname        tool.name
     432        toolcommand     tool.execute
     433        tooltitle       tool.title
     434        toolrevision    tool.version.application.revision
     435    } {
     436        set str [$_xmlobj get $path]
     437        if { "" != $str } {
     438            set _hints($key) $str
     439        }
     440    }
    422441}
    423442
     
    454473    return $value
    455474}
    456 
    457475
    458476itcl::body Rappture::Mesh::ReadVtk { path } {
     
    482500    $reader Update
    483501    set output [$reader GetOutput]
     502    set _numPoints [$output GetNumberOfPoints]
     503    set _numCells [$output GetNumberOfCells]
    484504    foreach { xmin xmax ymin ymax zmin zmax } [$output GetBounds] break
    485505    set _limits(x) [list $xmin $xmax]
     
    490510    rename $reader ""
    491511    return 1
     512}
     513
     514itcl::body Rappture::Mesh::GetCellCount { xNum yNum zNum } {
     515    set numCells 1
     516    if { $xNum > 1 } {
     517        set numCells [expr $numCells * ($xNum - 1)]
     518    }
     519    if { $yNum > 1 } {
     520        set numCells [expr $numCells * ($yNum - 1)]
     521    }
     522    if { $zNum > 1 } {
     523        set numCells [expr $numCells * ($zNum - 1)]
     524    }
     525    return $numCells
    492526}
    493527
     
    511545            set ${axis}Max $max
    512546            set ${axis}Num $num
     547            if {$min > $max} {
     548                puts stderr "ERROR: grid $axis min can't be greater than max"
     549                return 0
     550            }
    513551            incr numUniform
    514552        } elseif { $coords != "" } {
     
    550588            set _dim 3
    551589            set _numPoints [expr $xNum * $yNum * $zNum]
    552             if { ($_numPoints*3) != $numCoords } {
    553                 puts stderr "WARNING: bad grid \"$path\": invalid grid: \# of points does not match dimensions <xdim> * <ydim> * <zdim>"
     590            set _numCells [GetCellCount $xNum $yNum $zNum]
     591            if { ($_numPoints * 3) != $numCoords } {
     592                puts stderr "WARNING: bad grid \"$path\": \# of points does not match dimensions $xNum * $yNum * $zNum"
    554593                return 0
    555594            }
     
    572611            set _dim 2
    573612            set _numPoints [expr $xNum * $yNum]
    574             if { ($_numPoints*2) != $numCoords } {
    575                 puts stderr "WARNING: bad grid \"$path\": \# of points does not match dimensions <xdim> * <ydim>"
     613            set _numCells [GetCellCount $xNum $yNum 1]
     614            if { ($_numPoints * 2) != $numCoords } {
     615                puts stderr "WARNING: bad grid \"$path\": \# of points does not match dimensions $xNum * $yNum"
    576616                return 0
    577617            }
     
    596636            set _dim 1
    597637            set _numPoints $xNum
     638            set _numCells [GetCellCount $xNum 1 1]
    598639            if { $_numPoints != $numCoords } {
    599                 puts stderr "WARNING: bad grid \"$path\": \# of points does not match <xdim>"
     640                puts stderr "WARNING: bad grid \"$path\": \# of points does not match $xNum"
    600641                return 0
    601642            }
     
    620661        # This results in a STRUCTURED_POINTS
    621662        if { $_dim == 1 } {
    622             set xSpace [expr ($xMax - $xMin) / double($xNum - 1)]
     663            set xSpacing 0
     664            if { $xNum > 1 } {
     665                set xSpacing [expr ($xMax - $xMin) / double($xNum - 1)]
     666            }
    623667            set _numPoints $xNum
     668            set _numCells [GetCellCount $xNum 1 1]
    624669            append out "DATASET STRUCTURED_POINTS\n"
    625670            append out "DIMENSIONS $xNum 1 1\n"
    626671            append out "ORIGIN $xMin 0 0\n"
    627             append out "SPACING $xSpace 0 0\n"
     672            append out "SPACING $xSpacing 0 0\n"
    628673            set _vtkdata $out
    629674            set _limits(x) [list $xMin $xMax]
     
    631676            set _limits(z) [list 0 0]
    632677        } elseif { $_dim == 2 } {
    633             set xSpace [expr ($xMax - $xMin) / double($xNum - 1)]
    634             set ySpace [expr ($yMax - $yMin) / double($yNum - 1)]
     678            set xSpacing 0
     679            set ySpacing 0
     680            if { $xNum > 1 } {
     681                set xSpacing [expr ($xMax - $xMin) / double($xNum - 1)]
     682            }
     683            if { $yNum > 1 } {
     684                set ySpacing [expr ($yMax - $yMin) / double($yNum - 1)]
     685            }
    635686            set _numPoints [expr $xNum * $yNum]
     687            set _numCells [GetCellCount $xNum $yNum 1]
    636688            append out "DATASET STRUCTURED_POINTS\n"
    637689            append out "DIMENSIONS $xNum $yNum 1\n"
    638690            append out "ORIGIN $xMin $yMin 0\n"
    639             append out "SPACING $xSpace $ySpace 0\n"
     691            append out "SPACING $xSpacing $ySpacing 0\n"
    640692            set _vtkdata $out
    641693            foreach axis {x y} {
     
    644696            set _limits(z) [list 0 0]
    645697        } elseif { $_dim == 3 } {
    646             set xSpace [expr ($xMax - $xMin) / double($xNum - 1)]
    647             set ySpace [expr ($yMax - $yMin) / double($yNum - 1)]
    648             set zSpace [expr ($zMax - $zMin) / double($zNum - 1)]
     698            set xSpacing 0
     699            set ySpacing 0
     700            set zSpacing 0
     701            if {$xNum > 1} {
     702                set xSpacing [expr ($xMax - $xMin) / double($xNum - 1)]
     703            }
     704            if {$yNum > 1} {
     705                set ySpacing [expr ($yMax - $yMin) / double($yNum - 1)]
     706            }
     707            if {$zNum > 1} {
     708                set zSpacing [expr ($zMax - $zMin) / double($zNum - 1)]
     709            }
    649710            set _numPoints [expr $xNum * $yNum * $zNum]
     711            set _numCells [GetCellCount $xNum $yNum $zNum]
    650712            append out "DATASET STRUCTURED_POINTS\n"
    651713            append out "DIMENSIONS $xNum $yNum $zNum\n"
    652714            append out "ORIGIN $xMin $yMin $zMin\n"
    653             append out "SPACING $xSpace $ySpace $zSpace\n"
     715            append out "SPACING $xSpacing $ySpacing $zSpacing\n"
    654716            set _vtkdata $out
    655717            foreach axis {x y z} {
     
    700762    if { $_dim == 3 } {
    701763        set _numPoints [expr $xNum * $yNum * $zNum]
     764        set _numCells [GetCellCount $xNum $yNum $zNum]
    702765        append out "DATASET RECTILINEAR_GRID\n"
    703766        append out "DIMENSIONS $xNum $yNum $zNum\n"
     
    719782    } elseif { $_dim == 2 } {
    720783        set _numPoints [expr $xNum * $yNum]
     784        set _numCells [GetCellCount $xNum $yNum 1]
    721785        append out "DATASET RECTILINEAR_GRID\n"
    722786        append out "DIMENSIONS $xNum $yNum 1\n"
     
    738802    } elseif { $_dim == 1 } {
    739803        set _numPoints $xNum
     804        set _numCells [GetCellCount $xNum 1 1]
    740805        append out "DATASET RECTILINEAR_GRID\n"
    741806        append out "DIMENSIONS $xNum 1 1\n"
     
    787852    set _type "triangles"
    788853    set _numPoints [$xv length]
    789     set count 0
     854    set _numCells 0
    790855    set data {}
    791856    set celltypes {}
     
    793858        append data " 3 $a $b $c\n"
    794859        append celltypes "5\n"
    795         incr count
     860        incr _numCells
    796861    }
    797862    append out "DATASET UNSTRUCTURED_GRID\n"
     
    800865        append out " $x $y $z\n"
    801866    }
    802     append out "CELLS $count [expr $count * 4]\n"
     867    set count [expr $_numCells * 4]
     868    append out "CELLS $_numCells $count\n"
    803869    append out $data
    804     append out "CELL_TYPES $count\n"
     870    append out "CELL_TYPES $_numCells\n"
    805871    append out $celltypes
    806872    set _limits(x) [$xv limits]
     
    818884    set _type "quads"
    819885    set _numPoints [$xv length]
    820     set count 0
     886    set _numCells 0
    821887    set data {}
    822888    set celltypes {}
     
    824890        append data " 4 $a $b $c $d\n"
    825891        append celltypes "9\n"
    826         incr count
     892        incr _numCells
    827893    }
    828894    append out "DATASET UNSTRUCTURED_GRID\n"
     
    831897        append out " $x $y $z\n"
    832898    }
    833     append out "CELLS $count [expr $count * 5]\n"
     899    set count [expr $_numCells * 5]
     900    append out "CELLS $_numCells $count\n"
    834901    append out $data
    835     append out "CELL_TYPES $count\n"
     902    append out "CELL_TYPES $_numCells\n"
    836903    append out $celltypes
    837904    set _limits(x) [$xv limits]
     
    846913}
    847914
     915itcl::body Rappture::Mesh::WriteVertices { path xv yv zv vertices } {
     916    set _type "vertices"
     917    set _numPoints [$xv length]
     918    set _numCells 0
     919    set data {}
     920    set lines [split $vertices \n]
     921    set count 0
     922    foreach { line } $lines {
     923        set numIndices [llength $line]
     924        if { $numIndices == 0 } {
     925            continue
     926        }
     927        append data " $numIndices $line\n"
     928        incr _numCells
     929        set count [expr $count + $numIndices + 1]
     930    }
     931    append out "DATASET POLYDATA\n"
     932    append out "POINTS $_numPoints double\n"
     933    foreach x [$xv range 0 end] y [$yv range 0 end] z [$zv range 0 end] {
     934        append out " $x $y $z\n"
     935    }
     936    append out "VERTICES $_numCells $count\n"
     937    append out $data
     938    set _limits(x) [$xv limits]
     939    set _limits(y) [$yv limits]
     940    if { $_dim == 3 } {
     941        set _limits(z) [$zv limits]
     942    } else {
     943        set _limits(z) [list 0 0]
     944    }
     945    set _vtkdata $out
     946    return 1
     947}
     948
     949itcl::body Rappture::Mesh::WriteLines { path xv yv zv polylines } {
     950    set _type "lines"
     951    set _numPoints [$xv length]
     952    set _numCells 0
     953    set data {}
     954    set lines [split $polylines \n]
     955    set count 0
     956    foreach { line } $lines {
     957        set numIndices [llength $line]
     958        if { $numIndices == 0 } {
     959            continue
     960        }
     961        append data " $numIndices $line\n"
     962        incr _numCells
     963        set count [expr $count + $numIndices + 1]
     964    }
     965    append out "DATASET POLYDATA\n"
     966    append out "POINTS $_numPoints double\n"
     967    foreach x [$xv range 0 end] y [$yv range 0 end] z [$zv range 0 end] {
     968        append out " $x $y $z\n"
     969    }
     970    append out "LINES $_numCells $count\n"
     971    append out $data
     972    set _limits(x) [$xv limits]
     973    set _limits(y) [$yv limits]
     974    if { $_dim == 3 } {
     975        set _limits(z) [$zv limits]
     976    } else {
     977        set _limits(z) [list 0 0]
     978    }
     979    set _vtkdata $out
     980    return 1
     981}
     982
     983itcl::body Rappture::Mesh::WritePolygons { path xv yv zv polygons } {
     984    set _type "polygons"
     985    set _numPoints [$xv length]
     986    set _numCells 0
     987    set data {}
     988    set lines [split $polygons \n]
     989    set count 0
     990    foreach { line } $lines {
     991        set numIndices [llength $line]
     992        if { $numIndices == 0 } {
     993            continue
     994        }
     995        append data " $numIndices $line\n"
     996        incr _numCells
     997        set count [expr $count + $numIndices + 1]
     998    }
     999    append out "DATASET POLYDATA\n"
     1000    append out "POINTS $_numPoints double\n"
     1001    foreach x [$xv range 0 end] y [$yv range 0 end] z [$zv range 0 end] {
     1002        append out " $x $y $z\n"
     1003    }
     1004    append out "POLYGONS $_numCells $count\n"
     1005    append out $data
     1006    set _limits(x) [$xv limits]
     1007    set _limits(y) [$yv limits]
     1008    if { $_dim == 3 } {
     1009        set _limits(z) [$zv limits]
     1010    } else {
     1011        set _limits(z) [list 0 0]
     1012    }
     1013    set _vtkdata $out
     1014    return 1
     1015}
     1016
     1017itcl::body Rappture::Mesh::WriteTriangleStrips { path xv yv zv trianglestrips } {
     1018    set _type "trianglestrips"
     1019    set _numPoints [$xv length]
     1020    set _numCells 0
     1021    set data {}
     1022    set lines [split $trianglestrips \n]
     1023    set count 0
     1024    foreach { line } $lines {
     1025        set numIndices [llength $line]
     1026        if { $numIndices == 0 } {
     1027            continue
     1028        }
     1029        append data " $numIndices $line\n"
     1030        incr _numCells
     1031        set count [expr $count + $numIndices + 1]
     1032    }
     1033    append out "DATASET POLYDATA\n"
     1034    append out "POINTS $_numPoints double\n"
     1035    foreach x [$xv range 0 end] y [$yv range 0 end] z [$zv range 0 end] {
     1036        append out " $x $y $z\n"
     1037    }
     1038    append out "TRIANGLE_STRIPS $_numCells $count\n"
     1039    append out $data
     1040    set _limits(x) [$xv limits]
     1041    set _limits(y) [$yv limits]
     1042    if { $_dim == 3 } {
     1043        set _limits(z) [$zv limits]
     1044    } else {
     1045        set _limits(z) [list 0 0]
     1046    }
     1047    set _vtkdata $out
     1048    return 1
     1049}
     1050
    8481051itcl::body Rappture::Mesh::WriteTetrahedrons { path xv yv zv tetras } {
    8491052    set _type "tetrahedrons"
    8501053    set _numPoints [$xv length]
    851     set count 0
     1054    set _numCells 0
    8521055    set data {}
    8531056    set celltypes {}
     
    8551058        append data " 4 $a $b $c $d\n"
    8561059        append celltypes "10\n"
    857         incr count
     1060        incr _numCells
    8581061    }
    8591062    append out "DATASET UNSTRUCTURED_GRID\n"
     
    8621065        append out " $x $y $z\n"
    8631066    }
    864     append out "CELLS $count [expr $count * 5]\n"
     1067    set count [expr $_numCells * 5]
     1068    append out "CELLS $_numCells $count\n"
    8651069    append out $data
    866     append out "CELL_TYPES $count\n"
     1070    append out "CELL_TYPES $_numCells\n"
    8671071    append out $celltypes
    8681072    set _limits(x) [$xv limits]
     
    8771081    set _type "hexahedrons"
    8781082    set _numPoints [$xv length]
    879     set count 0
     1083    set _numCells 0
    8801084    set data {}
    8811085    set celltypes {}
     
    8831087        append data " 8 $a $b $c $d $e $f $g $h\n"
    8841088        append celltypes "12\n"
    885         incr count
     1089        incr _numCells
    8861090    }
    8871091    append out "DATASET UNSTRUCTURED_GRID\n"
     
    8901094        append out " $x $y $z\n"
    8911095    }
    892     append out "CELLS $count [expr $count * 9]\n"
     1096    set count [expr $_numCells * 9]
     1097    append out "CELLS $_numCells $count\n"
    8931098    append out $data
    894     append out "CELL_TYPES $count\n"
     1099    append out "CELL_TYPES $_numCells\n"
    8951100    append out $celltypes
    8961101    set _limits(x) [$xv limits]
     
    9051110    set _type "wedges"
    9061111    set _numPoints [$xv length]
    907     set count 0
     1112    set _numCells 0
    9081113    set data {}
    9091114    set celltypes {}
     
    9111116        append data " 6 $a $b $c $d $e $f\n"
    9121117        append celltypes "13\n"
    913         incr count
     1118        incr _numCells
    9141119    }
    9151120    append out "DATASET UNSTRUCTURED_GRID\n"
     
    9181123        append out " $x $y $z\n"
    9191124    }
    920     append out "CELLS $count [expr $count * 7]\n"
     1125    set count [expr $_numCells * 7]
     1126    append out "CELLS $_numCells $count\n"
    9211127    append out $data
    922     append out "CELL_TYPES $count\n"
     1128    append out "CELL_TYPES $_numCells\n"
    9231129    append out $celltypes
    9241130    set _limits(x) [$xv limits]
     
    9331139    set _type "pyramids"
    9341140    set _numPoints [$xv length]
    935     set count 0
     1141    set _numCells 0
    9361142    set data {}
    9371143    set celltypes {}
     
    9391145        append data " 5 $a $b $c $d $e\n"
    9401146        append celltypes "14\n"
    941         incr count
     1147        incr _numCells
    9421148    }
    9431149    append out "DATASET UNSTRUCTURED_GRID\n"
     
    9461152        append out " $x $y $z\n"
    9471153    }
    948     append out "CELLS $count [expr $count * 6]\n"
     1154    set count [expr $_numCells * 6]
     1155    append out "CELLS $_numCells $count\n"
    9491156    append out $data
    950     append out "CELL_TYPES $count\n"
     1157    append out "CELL_TYPES $_numCells\n"
    9511158    append out $celltypes
    9521159    set _limits(x) [$xv limits]
     
    9831190            puts stderr "WARNING: bad unstructured grid \"$path\": wrong \# of indices specified for celltype $celltype on line \"$line\""
    9841191            return 0
     1192        } else {
     1193            set numIndices $length
    9851194        }
    9861195        append data " $numIndices $line\n"
     
    10201229    # Step 1: Verify that there's only one cell tag of any kind.
    10211230    set numCells 0
    1022     foreach type { cells triangles quads tetrahedrons
    1023         hexahedrons wedges pyramids } {
     1231    foreach type {
     1232        cells
     1233        hexahedrons
     1234        lines
     1235        polygons
     1236        pyramids
     1237        quads
     1238        tetrahedrons
     1239        triangles
     1240        trianglestrips
     1241        vertices
     1242        wedges
     1243    } {
    10241244        set data [$_xmlobj get $path.unstructured.$type]
    10251245        if { $data != "" } {
     
    10371257        return 0
    10381258    }
    1039     foreach type { cells triangles quads tetrahedrons
    1040         hexahedrons wedges pyramids } {
     1259    foreach type {
     1260        cells
     1261        hexahedrons
     1262        lines
     1263        polygons
     1264        pyramids
     1265        quads
     1266        tetrahedrons
     1267        triangles
     1268        trianglestrips
     1269        vertices
     1270        wedges
     1271    } {
    10411272        set data [$_xmlobj get $path.unstructured.$type]
    10421273        if { $data != "" } {
     
    11531384        }
    11541385    }
     1386    set _numPoints [$xv length]
     1387
    11551388    # Step 3: Write the points and cells as vtk data.
    11561389    if { $numCells == 0 } {
     
    12771510itcl::body Rappture::Mesh::GetCellType { name } {
    12781511    array set name2type {
    1279         "triangle"     5
    1280         "quad"         9
    1281         "tetrahedron"  10
    1282         "hexahedron"   12
    1283         "wedge"        13
    1284         "pyramid"      14
     1512        "vertex"          1
     1513        "polyvertex"      2
     1514        "line"            3
     1515        "polyline"        4
     1516        "triangle"        5
     1517        "trianglestrip"   6
     1518        "polygon"         7
     1519        "pixel"           8
     1520        "quad"            9
     1521        "tetrahedron"     10
     1522        "voxel"           11
     1523        "hexahedron"      12
     1524        "wedge"           13
     1525        "pyramid"         14
     1526        "pentagonalprism" 15
     1527        "hexagonalprism"  16
    12851528    }
    12861529    if { [info exists name2type($name)] } {
     
    13091552        13      6
    13101553        14      5
    1311         15      0
    1312         16      0
     1554        15      10
     1555        16      12
    13131556    }
    13141557    if { [info exists type2indices($type)] } {
  • branches/r9/gui/scripts/molvisviewer.tcl

    r4075 r4919  
    691691                set session $env(SESSION)
    692692            }
     693            lappend info "version" "$Rappture::version"
     694            lappend info "build" "$Rappture::build"
     695            lappend info "svnurl" "$Rappture::svnurl"
     696            lappend info "installdir" "$Rappture::installdir"
    693697            lappend info "hub" [exec hostname]
    694698            lappend info "client" "molvisviewer"
  • branches/r9/gui/scripts/nanovisviewer.tcl

    r4343 r4919  
    11# -*- mode: tcl; indent-tabs-mode: nil -*-
    2 
    32# ----------------------------------------------------------------------
    43#  COMPONENT: nanovisviewer - 3D volume rendering
     
    8281    public method updateTransferFunctions {}
    8382
    84 
    8583    # The following methods are only used by this class.
     84
     85    private method AddNewMarker { x y }
    8686    private method AdjustSetting {what {value ""}}
    8787    private method BuildCameraTab {}
     
    105105    private method GetVolumeInfo { w }
    106106    private method HideAllMarkers {}
    107     private method AddNewMarker { x y }
    108107    private method InitComponentSettings { cname }
    109108    private method InitSettings { args }
     
    118117    private method ReceiveImage { args }
    119118    private method ReceiveLegend { tf vmin vmax size }
     119    private method RemoveMarker { x y }
    120120    private method ResetColormap { cname color }
    121121    private method Rotate {option x y}
    122122    private method SendTransferFunctions {}
     123    private method SetObjectStyle { dataobj cname }
    123124    private method SetOrientation { side }
    124125    private method Slice {option args}
    125126    private method SlicerTip {axis}
    126127    private method SwitchComponent { cname }
     128    private method ToggleVolume { tag name }
    127129    private method Zoom {option}
    128     private method ToggleVolume { tag name }
    129     private method RemoveMarker { x y }
    130130    private method ViewToQuaternion {} {
    131131        return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)]
     
    148148    private variable _view;             # View params for 3D view
    149149    private variable _parsedFunction
    150     private variable _transferFunctionEditors;# Array of isosurface level values 0..1
    151     private variable  _settings
     150    private variable _transferFunctionEditors
     151    private variable _settings
     152    private variable _alphamap
     153    private variable _widget
     154
    152155    private variable _first "" ;        # This is the topmost volume.
    153156    private variable _current "";       # Currently selected component
     
    208211        -qy      0.353553
    209212        -qz      0.146447
    210         -zoom    1.0
    211213        -xpan    0
    212214        -ypan    0
     215        -zoom    1.0
    213216    }
    214217    set _arcball [blt::arcball create 100 100]
     
    219222
    220223    array set _settings {
    221         -background             black
    222         -ambient                60
    223224        -axesvisible            1
    224         -colormap               default
    225         -cutplanevisible        0
    226         -diffuse                40
     225        -background             black
     226        -colormap               "default"
     227        -cutplanesvisible       0
    227228        -gridvisible            0
    228229        -isosurfaceshading      0
    229230        -legendvisible          1
     231        -light                  40
    230232        -light2side             1
    231         -opacity                50
    232233        -outlinevisible         0
    233234        -qw                     0.853553
     
    235236        -qy                     0.353553
    236237        -qz                     0.146447
    237         -specularexponent       90
    238         -specularlevel          30
    239238        -thickness              350
    240239        -volume                 1
     240        -volumeopacity          0.5
    241241        -volumevisible          1
     242        -xcutplaneposition      50
    242243        -xcutplanevisible       1
    243         -xcutplaneposition      50
    244244        -xpan                   0
     245        -ycutplaneposition      50
    245246        -ycutplanevisible       1
    246         -ycutplaneposition      50
    247247        -ypan                   0
     248        -zcutplaneposition      50
    248249        -zcutplanevisible       1
    249         -zcutplaneposition      50
    250250        -zoom                   1.0
    251251    }
    252 
     252    array set _widget {
     253        -volumeopacity          50
     254    }
    253255    itk_component add 3dview {
    254256        label $itk_component(plotarea).view -image $_image(plot) \
     
    557559# ----------------------------------------------------------------------
    558560itcl::body Rappture::NanovisViewer::scale {args} {
    559     array set style {
    560         -color BCGYR
    561         -levels 6
    562         -markers ""
     561    array set styles {
     562        -color    BCGYR
     563        -levels   6
     564        -markers  ""
    563565    }
    564566    array unset _limits
     
    571573            if { ![info exists _volcomponents($cname)] } {
    572574                lappend _componentsList $cname
    573                 array set style [lindex [$dataobj components -style $cname] 0]
    574                 set cmap [ColorsToColormap $style(-color)]
     575                array set styles [lindex [$dataobj components -style $cname] 0]
     576                set cmap [ColorsToColormap $styles(-color)]
    575577                set _cname2defaultcolormap($cname) $cmap
    576                 set _settings($cname-colormap) $style(-color)
     578                set _settings($cname-colormap) $styles(-color)
    577579            }
    578580            lappend _volcomponents($cname) $dataobj-$cname
     
    674676                set session $env(SESSION)
    675677            }
     678            lappend info "version" "$Rappture::version"
     679            lappend info "build" "$Rappture::build"
     680            lappend info "svnurl" "$Rappture::svnurl"
     681            lappend info "installdir" "$Rappture::installdir"
    676682            lappend info "hub" [exec hostname]
    677683            lappend info "client" "nanovisviewer"
     
    721727# ----------------------------------------------------------------------
    722728itcl::body Rappture::NanovisViewer::SendTransferFunctions {} {
    723     if 0 {
    724     if { $_first == "" } {
    725         puts stderr "first not set"
    726         return
    727     }
    728 
    729     foreach tag [CurrentDatasets] {
    730         if { ![info exists _serverDatasets($tag)] || !$_serverDatasets($tag) } {
    731             # The volume hasn't reached the server yet.  How did we get
    732             # here?
    733             puts stderr "Don't have $tag in _serverDatasets"
    734             continue
    735         }
    736         if { ![info exists _dataset2style($tag)] } {
    737             puts stderr "don't have style for volume $tag"
    738             continue;                        # How does this happen?
    739         }
    740         foreach {dataobj cname} [split $tag -] break
    741         set cname $_dataset2style($tag)
    742 
    743         ComputeTransferFunction $cname
    744         SendCmd "volume shading transfunc $cname $tag"
    745     }
    746     }
    747729    foreach cname [array names _volcomponents] {
    748730        ComputeTransferFunction $cname
     
    803785
    804786    foreach {min max} $_limits($cname) break
    805     $c itemconfigure vmin -text [format %.2g $min]
     787    $c itemconfigure vmin -text [format %g $min]
    806788    $c coords vmin $lx $ly
    807789
    808     $c itemconfigure vmax -text [format %.2g $max]
     790    $c itemconfigure vmax -text [format %g $max]
    809791    $c coords vmax [expr {$w-$lx}] $ly
    810792
     
    818800
    819801    # The colormap may have changed. Resync the slicers with the colormap.
    820     set datasets [CurrentDatasets -cutplanes]
    821 
    822     # Adjust the cutplane for only the first component in the topmost volume
    823     # (i.e. the first volume designated in the field).
    824     set tag [lindex $datasets 0]
    825     foreach axis {x y z} {
    826         # Turn off cutplanes for all volumes
    827         SendCmd "cutplane state 0 $axis"
    828         if { $_settings(-${axis}cutplanevisible) } {
    829             # Turn on cutplane for this particular volume and set the position
    830             SendCmd "cutplane state 1 $axis $tag"
    831             set pos [expr {0.01*$_settings(-${axis}cutplaneposition)}]
    832             SendCmd "cutplane position $pos $axis $tag"
    833         }
    834     }
     802    InitSettings -cutplanesvisible -xcutplanevisible -ycutplanevisible \
     803        -zcutplanevisible
    835804}
    836805
     
    932901        DoResize
    933902    }
     903
    934904    foreach dataobj [get] {
    935905        foreach cname [$dataobj components] {
     
    942912                    }
    943913                    set data [$dataobj blob $cname]
    944                     if 0 {
    945                         set f [open "/tmp/values-$cname.txt" "w"]
    946                         puts $f [$dataobj values $cname]
    947                         close $f
    948                     }
    949914                } else {
    950915                    set data [$dataobj vtkdata $cname]
     
    972937                set _serverDatasets($tag) 0
    973938            }
    974             NameTransferFunction $dataobj $cname
    975         }
    976     }
     939            SetObjectStyle $dataobj $cname
     940        }
     941    }
     942
     943    # Outline seems to need to be reset every update.
     944    InitSettings -outlinevisible -cutplanesvisible -current
     945
    977946    set _first [lindex [get] 0]
    978947    if { $_reset } {
     
    994963        PanCamera
    995964        SendCmd "camera zoom $_view(-zoom)"
    996 
     965       
     966        #cutplane state 0 all
    997967        foreach axis {x y z} {
    998968            # Turn off cutplanes for all volumes
     
    1000970        }
    1001971
    1002         InitSettings -light2side -ambient -diffuse -specularlevel \
    1003             -specularexponent -opacity -isosurfaceshading -gridvisible \
    1004             -axesvisible -xcutplanevisible -ycutplanevisible -zcutplanevisible \
    1005             -current
     972        InitSettings -light2side -light -volumeopacity \
     973            -isosurfaceshading -gridvisible -axesvisible \
    1006974
    1007975        if {"" != $_first} {
     
    1016984        }
    1017985    }
    1018     # Outline seems to need to be reset every update.
    1019     InitSettings -outlinevisible -cutplanesvisible
     986
    1020987    # nothing to send -- activate the proper ivol
    1021988    SendCmd "volume state 0"
     
    10551022        set tag $_first-$cname
    10561023        if { [info exists _serverDatasets($tag)] && $_serverDatasets($tag) } {
    1057             array set style {
     1024            array set styles {
    10581025                -cutplanes 1
    10591026            }
    1060             array set style [lindex [$_first components -style $cname] 0]
    1061             if { $what != "-cutplanes" || $style(-cutplanes) } {
     1027            array set styles [lindex [$_first components -style $cname] 0]
     1028            if { $what != "-cutplanes" || $styles(-cutplanes) } {
    10621029                lappend rlist $tag
    10631030            }
     
    10931060                -qy      0.353553
    10941061                -qz      0.146447
     1062                -xpan    0
     1063                -ypan    0
    10951064                -zoom    1.0
    1096                 -xpan   0
    1097                 -ypan   0
    10981065            }
    10991066            if { $_first != "" } {
     
    12491216    }
    12501217    switch -- $what {
    1251         "-current" {
    1252             set cname [$itk_component(volcomponents) value]
    1253             SwitchComponent $cname
     1218        "-axesvisible" {
     1219            SendCmd "axis visible $_settings($what)"
    12541220        }
    12551221        "-background" {
     
    12641230            DrawLegend $_current
    12651231        }
    1266         "-ambient" {
    1267             # Other parts of the code use the ambient setting to
    1268             # tell if the component settings have been initialized
    1269             if { ![info exists _settings($_current${what})] } {
    1270                 InitComponentSettings $_current
    1271             }
    1272             set _settings($_current${what}) $_settings($what)
    1273             set val $_settings($what)
    1274             set val [expr {0.01*$val}]
    1275             foreach tag [GetDatasetsWithComponent $_current] {
    1276                 SendCmd "volume shading ambient $val $tag"
    1277             }
    1278         }
    1279         "-diffuse" {
    1280             set _settings($_current${what}) $_settings($what)
    1281             set val $_settings($what)
    1282             set val [expr {0.01*$val}]
    1283             foreach tag [GetDatasetsWithComponent $_current] {
    1284                 SendCmd "volume shading diffuse $val $tag"
    1285             }
    1286         }
    1287         "-specularlevel" {
    1288             set _settings($_current${what}) $_settings($what)
    1289             set val $_settings($what)
    1290             set val [expr {0.01*$val}]
    1291             foreach tag [GetDatasetsWithComponent $_current] {
    1292                 SendCmd "volume shading specularLevel $val $tag"
    1293             }
    1294         }
    1295         "-specularexponent" {
    1296             set _settings($_current${what}) $_settings($what)
    1297             set val $_settings($what)
    1298             foreach tag [GetDatasetsWithComponent $_current] {
    1299                 SendCmd "volume shading specularExp $val $tag"
    1300             }
    1301         }
    1302         "-light2side" {
    1303             set _settings($_current${what}) $_settings($what)
    1304             set val $_settings($what)
    1305             foreach tag [GetDatasetsWithComponent $_current] {
    1306                 SendCmd "volume shading light2side $val $tag"
    1307             }
    1308         }
    1309         "-opacity" {
    1310             set _settings($_current${what}) $_settings($what)
    1311             set val $_settings($what)
    1312             set sval [expr { 0.01 * double($val) }]
    1313             foreach tag [GetDatasetsWithComponent $_current] {
    1314                 SendCmd "volume shading opacity $sval $tag"
    1315             }
    1316         }
    1317         "-thickness" {
    1318             set val $_settings($what)
    1319             set _settings($_current${what}) $val
    1320             updateTransferFunctions
    1321         }
    1322         "-outlinevisible" {
    1323             SendCmd "volume outline state $_settings($what)"
    1324         }
    1325         "-outlinecolor" {
    1326             set rgb [Color2RGB $_settings($what)]
    1327             SendCmd "volume outline color $rgb"
    1328         }
    1329         "-isosurfaceshading" {
    1330             SendCmd "volume shading isosurface $_settings($what)"
    1331         }
    13321232        "-colormap" {
    13331233            set color [$itk_component(colormap) value]
     
    13361236            ResetColormap $_current $color
    13371237        }
     1238        "-current" {
     1239            set cname [$itk_component(volcomponents) value]
     1240            SwitchComponent $cname
     1241        }
     1242        "-cutplanesvisible" {
     1243            set bool $_settings($what)
     1244            # We only set cutplanes on the first dataset.
     1245            set datasets [CurrentDatasets -cutplanes]
     1246            set tag [lindex $datasets 0]
     1247            if { $bool } {
     1248                foreach axis { x y z } {
     1249                    if { $_settings(-${axis}cutplanevisible) } {
     1250                        SendCmd "cutplane state 1 $axis $tag"
     1251                    }
     1252                }
     1253            } else {
     1254                foreach axis { x y z } {
     1255                    SendCmd "cutplane state 0 $axis $tag"
     1256                }
     1257            }
     1258        }
    13381259        "-gridvisible" {
    13391260            SendCmd "grid visible $_settings($what)"
    13401261        }
    1341         "-axesvisible" {
    1342             SendCmd "axis visible $_settings($what)"
     1262        "-isosurfaceshading" {
     1263            SendCmd "volume shading isosurface $_settings($what)"
    13431264        }
    13441265        "-legendvisible" {
     
    13511272                blt::table forget $itk_component(legend)
    13521273            }
     1274        }
     1275        "-light" {
     1276            set _settings($_current${what}) $_settings($what)
     1277            set val $_settings($what)
     1278            set diffuse [expr {0.01*$val}]
     1279            set ambient [expr {1.0-$diffuse}]
     1280            set specularLevel 0.3
     1281            set specularExp 90.0
     1282            foreach tag [GetDatasetsWithComponent $_current] {
     1283                SendCmd "volume shading ambient $ambient $tag"
     1284                SendCmd "volume shading diffuse $diffuse $tag"
     1285                SendCmd "volume shading specularLevel $specularLevel $tag"
     1286                SendCmd "volume shading specularExp $specularExp $tag"
     1287            }
     1288        }
     1289        "-light2side" {
     1290            set _settings($_current${what}) $_settings($what)
     1291            set val $_settings($what)
     1292            foreach tag [GetDatasetsWithComponent $_current] {
     1293                SendCmd "volume shading light2side $val $tag"
     1294            }
     1295        }
     1296        "-outlinevisible" {
     1297            SendCmd "volume outline state $_settings($what)"
     1298        }
     1299        "-thickness" {
     1300            set val $_settings($what)
     1301            set _settings($_current${what}) $val
     1302            updateTransferFunctions
    13531303        }
    13541304        "-volume" {
     
    13651315            set _settings(-volumevisible) $bool
    13661316        }
     1317        "-volumeopacity" {
     1318            set _settings($what) [expr $_widget($what) * 0.01]
     1319            set _settings($_current${what}) $_settings($what)
     1320       
     1321            foreach {cmap wmap} $_cname2transferFunction($_current) break
     1322            set wmap [ComputeAlphamap $_current]
     1323            set _cname2transferFunction($_current) [list $cmap $wmap]
     1324            SendCmd [list transfunc define $_current $cmap $wmap]
     1325        }
    13671326        "-volumevisible" {
    13681327            # This is the component specific control.  It changes the
     
    13731332            }
    13741333        }
    1375         "-cutplanesvisible" {
    1376             set bool $_settings($what)
    1377             set datasets [CurrentDatasets -cutplanes]
    1378             set tag [lindex $datasets 0]
    1379             SendCmd "cutplane visible $bool $tag"
    1380         }
    13811334        "-xcutplanevisible" - "-ycutplanevisible" - "-zcutplanevisible" {
    13821335            set axis [string range $what 1 1]
    13831336            set bool $_settings($what)
     1337            # We only set cutplanes on the first dataset.
    13841338            set datasets [CurrentDatasets -cutplanes]
    13851339            set tag [lindex $datasets 0]
    1386             SendCmd "cutplane state $bool $axis $tag"
     1340            if { $_settings(-cutplanesvisible) } {
     1341                SendCmd "cutplane state $bool $axis $tag"
     1342            }
    13871343            if { $bool } {
    13881344                $itk_component(${axis}CutScale) configure -state normal \
     
    14281384#
    14291385itcl::body Rappture::NanovisViewer::NameTransferFunction { dataobj cname } {
    1430     array set style {
     1386    array set styles {
    14311387        -color BCGYR
    14321388        -levels 6
     
    14341390    }
    14351391    set tag $dataobj-$cname
    1436     array set style [lindex [$dataobj components -style $cname] 0]
     1392    array set styles [lindex [$dataobj components -style $cname] 0]
    14371393    if { ![info exists _cname2transferFunction($cname)] } {
    14381394        # Get the colormap right now, since it doesn't change with marker
    14391395        # changes.
    1440         set cmap [ColorsToColormap $style(-color)]
     1396        set cmap [ColorsToColormap $styles(-color)]
    14411397        set wmap [list 0.0 0.0 1.0 1.0]
    14421398        set _cname2transferFunction($cname) [list $cmap $wmap]
     
    14741430    # reference.
    14751431    if { ![info exists _parsedFunction($cname)] } {
    1476         array set style {
     1432        array set styles {
    14771433            -color BCGYR
    14781434            -levels 6
     
    14821438        foreach tag [GetDatasetsWithComponent $cname] {
    14831439            foreach {dataobj cname} [split [lindex $tag 0] -] break
    1484             array set style [lindex [$dataobj components -style $cname] 0]
     1440            array set styles [lindex [$dataobj components -style $cname] 0]
    14851441        }
    14861442        eval $_transferFunctionEditors($cname) limits $_limits($cname)
    14871443        # Have to defer creation of isomarkers until we have data limits
    1488         if { [info exists style(-markers)] &&
    1489              [llength $style(-markers)] > 0 } {
    1490             ParseMarkersOption $cname $style(-markers)
     1444        if { [info exists styles(-markers)] &&
     1445             [llength $styles(-markers)] > 0 } {
     1446            ParseMarkersOption $cname $styles(-markers)
    14911447        } else {
    1492             ParseLevelsOption $cname $style(-levels)
     1448            ParseLevelsOption $cname $styles(-levels)
    14931449        }
    14941450       
     
    17341690
    17351691    set font [option get $itk_component(hull) font Font]
    1736     #set bfont [option get $itk_component(hull) boldFont Font]
    1737 
    1738     label $inner.lighting_l \
    1739         -text "Lighting / Material Properties" \
    1740         -font "Arial 9 bold"
    1741 
    1742     checkbutton $inner.light2side \
    1743         -text "Two-sided lighting" \
    1744         -font $font \
     1692    set fg [option get $itk_component(hull) font Font]
     1693    #set bfg [option get $itk_component(hull) boldFont Font]
     1694
     1695    checkbutton $inner.vol -text "Show volume" -font $fg \
     1696        -variable [itcl::scope _settings(-volumevisible)] \
     1697        -command [itcl::code $this AdjustSetting -volumevisible]
     1698    label $inner.shading -text "Shading:" -font $fg
     1699
     1700    checkbutton $inner.light2side -text "Two-sided lighting" -font $fg \
    17451701        -variable [itcl::scope _settings(-light2side)] \
    17461702        -command [itcl::code $this AdjustSetting -light2side]
    17471703
    1748     checkbutton $inner.visibility \
    1749         -text "Visible" \
    1750         -font $font \
    1751         -variable [itcl::scope _settings(-volumevisible)] \
    1752         -command [itcl::code $this AdjustSetting -volumevisible] \
    1753 
    1754     label $inner.ambient_l \
    1755         -text "Ambient" \
    1756         -font $font
    1757     ::scale $inner.ambient -from 0 -to 100 -orient horizontal \
    1758         -variable [itcl::scope _settings(-ambient)] \
    1759         -showvalue off -command [itcl::code $this AdjustSetting -ambient] \
    1760         -troughcolor grey92
    1761 
    1762     label $inner.diffuse_l -text "Diffuse" -font $font
    1763     ::scale $inner.diffuse -from 0 -to 100 -orient horizontal \
    1764         -variable [itcl::scope _settings(-diffuse)] \
    1765         -showvalue off -command [itcl::code $this AdjustSetting -diffuse] \
    1766         -troughcolor grey92
    1767 
    1768     label $inner.specularLevel_l -text "Specular" -font $font
    1769     ::scale $inner.specularLevel -from 0 -to 100 -orient horizontal \
    1770         -variable [itcl::scope _settings(-specularlevel)] \
    1771         -showvalue off \
    1772         -command [itcl::code $this AdjustSetting -specularlevel] \
    1773         -troughcolor grey92
    1774 
    1775     label $inner.specularExponent_l -text "Shininess" -font $font
    1776     ::scale $inner.specularExponent -from 10 -to 128 -orient horizontal \
    1777         -variable [itcl::scope _settings(-specularexponent)] \
    1778         -showvalue off \
    1779         -command [itcl::code $this AdjustSetting -specularexponent] \
    1780         -troughcolor grey92
    1781 
    1782     label $inner.opacity_l -text "Opacity" -font $font
    1783     ::scale $inner.opacity -from 0 -to 100 -orient horizontal \
    1784         -variable [itcl::scope _settings(-opacity)] \
    1785         -showvalue off -command [itcl::code $this AdjustSetting -opacity] \
    1786         -troughcolor grey92
    1787 
    1788     label $inner.transferfunction_l \
    1789         -text "Transfer Function" -font "Arial 9 bold"
    1790 
    1791     label $inner.thin -text "Thin" -font $font
     1704    label $inner.dim -text "Glow" -font $fg
     1705    ::scale $inner.light -from 0 -to 100 -orient horizontal \
     1706        -variable [itcl::scope _settings(-light)] \
     1707        -width 10 \
     1708        -showvalue off -command [itcl::code $this AdjustSetting -light]
     1709    label $inner.bright -text "Surface" -font $fg
     1710
     1711    # Opacity
     1712    label $inner.fog -text "Clear" -font $fg
     1713    ::scale $inner.transp -from 0 -to 100 -orient horizontal \
     1714        -variable [itcl::scope _widget(-volumeopacity)] \
     1715        -width 10 \
     1716        -showvalue off -command [itcl::code $this AdjustSetting -volumeopacity]
     1717    label $inner.plastic -text "Opaque" -font $fg
     1718
     1719    # Tooth thickness
     1720    label $inner.thin -text "Thin" -font $fg
    17921721    ::scale $inner.thickness -from 0 -to 1000 -orient horizontal \
    17931722        -variable [itcl::scope _settings(-thickness)] \
    1794         -showvalue off -command [itcl::code $this AdjustSetting -thickness] \
    1795         -troughcolor grey92
    1796 
    1797     label $inner.thick -text "Thick" -font $font
    1798 
    1799     label $inner.colormap_l -text "Colormap" -font $font
     1723        -width 10 \
     1724        -showvalue off -command [itcl::code $this AdjustSetting -thickness]
     1725    label $inner.thick -text "Thick" -font $fg
     1726
     1727    # Colormap
     1728    label $inner.colormap_l -text "Colormap" -font "Arial 9"
    18001729    itk_component add colormap {
    18011730        Rappture::Combobox $inner.colormap -width 10 -editable no
     
    18081737    set _settings(-colormap) "default"
    18091738
     1739    # Component
    18101740    label $inner.volcomponents_l -text "Component" -font $font
    18111741    itk_component add volcomponents {
     
    18181748        0,0 $inner.volcomponents_l -anchor e -cspan 2 \
    18191749        0,2 $inner.volcomponents             -cspan 3 -fill x \
    1820         1,1 $inner.lighting_l -anchor w -cspan 4 \
    1821         2,1 $inner.ambient_l       -anchor e -pady 2 \
    1822         2,2 $inner.ambient                   -cspan 3 -fill x \
    1823         3,1 $inner.diffuse_l       -anchor e -pady 2 \
    1824         3,2 $inner.diffuse                   -cspan 3 -fill x \
    1825         4,1 $inner.specularLevel_l -anchor e -pady 2 \
    1826         4,2 $inner.specularLevel             -cspan 3 -fill x \
    1827         5,1 $inner.specularExponent_l -anchor e -pady 2 \
    1828         5,2 $inner.specularExponent          -cspan 3 -fill x \
    1829         6,1 $inner.light2side -cspan 3 -anchor w \
    1830         7,1 $inner.visibility -cspan 3 -anchor w \
    1831         8,1 $inner.transferfunction_l -anchor w              -cspan 4 \
    1832         9,1 $inner.opacity_l -anchor e -pady 2 \
    1833         9,2 $inner.opacity                    -cspan 3 -fill x \
    1834         10,1 $inner.colormap_l       -anchor e \
    1835         10,2 $inner.colormap                  -padx 2 -cspan 3 -fill x \
    1836         11,1 $inner.thin             -anchor e \
    1837         11,2 $inner.thickness                 -cspan 2 -fill x \
    1838         11,4 $inner.thick -anchor w 
    1839 
    1840     blt::table configure $inner c* r* -resize none
    1841     blt::table configure $inner r* -pady { 2 0 }
    1842     blt::table configure $inner c2 c3 r12 -resize expand
    1843     blt::table configure $inner c0 -width .1i
     1750        1,0 $inner.shading -cspan 4 -anchor w -pady {10 2} \
     1751        2,0 $inner.light2side -cspan 4 -anchor w -pady 2 \
     1752        3,0 $inner.dim -anchor e -pady 2 \
     1753        3,1 $inner.light -cspan 2 -pady 2 -fill x \
     1754        3,3 $inner.bright -anchor w -pady 2 \
     1755        4,0 $inner.fog -anchor e -pady 2 \
     1756        4,1 $inner.transp -cspan 2 -pady 2 -fill x \
     1757        4,3 $inner.plastic -anchor w -pady 2 \
     1758        5,0 $inner.thin -anchor e -pady 2 \
     1759        5,1 $inner.thickness -cspan 2 -pady 2 -fill x\
     1760        5,3 $inner.thick -anchor w -pady 2
     1761
     1762    blt::table configure $inner c0 c1 c3 r* -resize none
     1763    blt::table configure $inner r6 -resize expand
    18441764}
    18451765
     
    18551775        -command [itcl::code $this AdjustSetting -cutplanesvisible] \
    18561776        -font "Arial 9"
    1857 
     1777   
    18581778    # X-value slicer...
    18591779    itk_component add xCutButton {
     
    19401860
    19411861    blt::table $inner \
    1942         0,1 $inner.visible              -anchor w -pady 2 -cspan 4 \
    1943         1,1 $itk_component(xCutScale) \
    1944         1,2 $itk_component(yCutScale) \
    1945         1,3 $itk_component(zCutScale) \
    1946         2,1 $itk_component(xCutButton) \
    1947         2,2 $itk_component(yCutButton) \
    1948         2,3 $itk_component(zCutButton)
    1949 
    1950     blt::table configure $inner r0 r1 r2 c* -resize none
    1951     blt::table configure $inner r3 c4 -resize expand
     1862        1,1 $itk_component(xCutButton) \
     1863        1,2 $itk_component(yCutButton) \
     1864        1,3 $itk_component(zCutButton) \
     1865        0,1 $itk_component(xCutScale) \
     1866        0,2 $itk_component(yCutScale) \
     1867        0,3 $itk_component(zCutScale)
     1868
     1869    blt::table configure $inner r0 r1 c* -resize none
     1870    blt::table configure $inner r2 c4 -resize expand
    19521871    blt::table configure $inner c0 -width 2
    19531872    blt::table configure $inner c1 c2 c3 -padx 2
     
    21802099# InitComponentSettings --
    21812100#
    2182 #       Initializes the volume settings for a specific component. This
    2183 #       should match what's used as global settings above. This
    2184 #       is called the first time we try to switch to a given component
    2185 #       in SwitchComponent below.
     2101#    Initializes the volume settings for a specific component. This should
     2102#    match what's used as global settings above. This is called the first
     2103#    time we try to switch to a given component in SwitchComponent below.
    21862104#
    21872105itcl::body Rappture::NanovisViewer::InitComponentSettings { cname } {
    2188     # Expanding component name for key.
    2189     array set _settings [subst {
    2190         $cname-ambient           60
    2191         $cname-colormap          default
    2192         $cname-diffuse           40
    2193         $cname-light2side        1
    2194         $cname-opacity           50
    2195         $cname-specularexponent  90
    2196         $cname-specularlevel     30
    2197         $cname-thickness         350
    2198         $cname-volumevisible     1
    2199     }]
     2106    foreach {key value} {
     2107        -colormap          "default"
     2108        -light             40
     2109        -light2side        1
     2110        -thickness         350
     2111        -volumeopacity     1.0
     2112        -volumevisible     1
     2113    } {
     2114        if { ![info exists _settings($cname${key})] } {
     2115            # Don't override existing component settings
     2116            set _settings($cname${key}) $value
     2117        }
     2118    }
    22002119}
    22012120
     
    22032122# SwitchComponent --
    22042123#
    2205 #       This is called when the current component is changed by the
    2206 #       dropdown menu in the volume tab.  It synchronizes the global
    2207 #       volume settings with the settings of the new current component.
     2124#    This is called when the current component is changed by the dropdown
     2125#    menu in the volume tab.  It synchronizes the global volume settings
     2126#    with the settings of the new current component.
    22082127#
    22092128itcl::body Rappture::NanovisViewer::SwitchComponent { cname } {
    2210     if { ![info exists _settings($cname-ambient)] } {
     2129    if { ![info exists _settings($cname-light)] } {
    22112130        InitComponentSettings $cname
    22122131    }
     2132    if { $_settings(-colormap) != $_settings($cname-colormap) } {
     2133        set _settings(-colormap)         $_settings($cname-colormap)
     2134        EventuallyRedrawLegend
     2135    }
    22132136    # _settings variables change widgets, except for colormap
    2214     set _settings(-ambient)          $_settings($cname-ambient)
    2215     set _settings(-colormap)         $_settings($cname-colormap)
    2216     set _settings(-diffuse)          $_settings($cname-diffuse)
     2137    set _settings(-light)            $_settings($cname-light)
    22172138    set _settings(-light2side)       $_settings($cname-light2side)
    2218     set _settings(-opacity)          $_settings($cname-opacity)
    2219     set _settings(-specularexponent) $_settings($cname-specularexponent)
    2220     set _settings(-specularlevel)    $_settings($cname-specularlevel)
     2139    set _settings(-volumeopacity)    $_settings($cname-volumeopacity)
    22212140    set _settings(-thickness)        $_settings($cname-thickness)
    22222141    set _settings(-volumevisible)    $_settings($cname-volumevisible)
    22232142    $itk_component(colormap) value   $_settings($cname-colormap)
     2143
     2144    set _widget(-volumeopacity) [expr $_settings(-volumeopacity) * 100.0]
     2145
    22242146    set _current $cname;                # Reset the current component
    22252147}
     
    22282150# BuildVolumeComponents --
    22292151#
    2230 #       This is called from the "scale" method which is called when a
    2231 #       new dataset is added or deleted.  It repopulates the dropdown
    2232 #       menu of volume component names.  It sets the current component
    2233 #       to the first component in the list (of components found).
    2234 #       Finally, if there is only one component, don't display the
    2235 #       label or the combobox in the volume settings tab.
     2152#    This is called from the "scale" method which is called when a new
     2153#    dataset is added or deleted.  It repopulates the dropdown menu of
     2154#    volume component names.  It sets the current component to the first
     2155#    component in the list (of components found).  Finally, if there is
     2156#    only one component, don't display the label or the combobox in the
     2157#    volume settings tab.
    22362158#
    22372159itcl::body Rappture::NanovisViewer::BuildVolumeComponents {} {
     
    22592181# GetDatasetsWithComponents --
    22602182#
    2261 #       Returns a list of all the datasets (known by the combination of
    2262 #       their data object and component name) that match the given
    2263 #       component name.  For example, this is used where we want to change
    2264 #       the settings of volumes that have the current component.
     2183#     Returns a list of all the datasets (known by the combination of their
     2184#     data object and component name) that match the given component name.
     2185#     For example, this is used where we want to change the settings of
     2186#     volumes that have the current component.
    22652187#
    22662188itcl::body Rappture::NanovisViewer::GetDatasetsWithComponent { cname } {
     
    22812203# HideAllMarkers --
    22822204#
    2283 #       Hide all the markers in all the transfer functions.  Can't simply
    2284 #       delete and recreate markers from the <style> since the user may
    2285 #       have create, deleted, or moved markers.
     2205#   Hide all the markers in all the transfer functions.  Can't simply
     2206#   delete and recreate markers from the <style> since the user may have
     2207#   create, deleted, or moved markers.
    22862208#
    22872209itcl::body Rappture::NanovisViewer::HideAllMarkers {} {
     
    23212243        return [list 0.0 0.0 1.0 1.0]
    23222244    }
    2323     if { ![info exists _settings($cname-ambient)] } {
     2245    if { ![info exists _settings($cname-light)] } {
    23242246        InitComponentSettings $cname
    23252247    }
     
    23282250
    23292251    # Currently using volume shading opacity to scale opacity in
    2330     # the volume shader. The transfer function always sets full
    2331     # opacity
    2332     set max 1.0
     2252    # the volume shader.
     2253    set max $_settings($cname-volumeopacity)
    23332254
    23342255    # Use the component-wise thickness setting from the slider
     
    25492470}
    25502471
    2551 
     2472itcl::body Rappture::NanovisViewer::SetObjectStyle { dataobj cname } {
     2473    array set styles {
     2474        -opacity  0.6
     2475    }
     2476    array set styles [lindex [$dataobj components -style $cname] 0]
     2477    set _settings($cname-volumeopacity) $styles(-opacity)
     2478    NameTransferFunction $dataobj $cname
     2479}
  • branches/r9/gui/scripts/resultselector.tcl

    r4214 r4919  
    12951295            foreach col [lrange [$_resultset diff names] 1 end] {
    12961296                set quantity $_cntlInfo($this-$col-label)
    1297                 set val [lindex [$_resultset get $col $xmlobj] 0]
     1297
     1298                # Don't know why this was being treated as a list.
     1299                #set val [lindex [$_resultset get $col $xmlobj] 0]
     1300
     1301                set val [$_resultset get $col $xmlobj]
    12981302                append desc "$quantity = $val\n"
    12991303            }
  • branches/r9/gui/scripts/transferfunctioneditor.tcl

    r4121 r4919  
    199199    set absval [GetAbsoluteValue $name]
    200200    set y 31
    201     $_canvas itemconfigure $_labels($name) -text [format %.2g $absval]
     201    $_canvas itemconfigure $_labels($name) -text [format %g $absval]
    202202    $_canvas coords $_ticks($name) $x [expr {$y+3}]
    203203    $_canvas coords $_labels($name) $x [expr {$y+5}]
     
    215215    set _values($name) $relval
    216216    set y 31
    217     $_canvas itemconfigure $_label -text [format %.2g $absval]
     217    $_canvas itemconfigure $_label -text [format %g $absval]
    218218    set x [GetScreenPosition $name]
    219219    $_canvas coords $_ticks($name) $x [expr {$y+3}]
     
    231231    set y 31
    232232    set absval [GetAbsoluteValue $name]
    233     $_canvas itemconfigure $_labels($name) -text [format %.2g $absval]
     233    $_canvas itemconfigure $_labels($name) -text [format %g $absval]
    234234    $_canvas coords $_ticks($name) $x [expr {$y+3}]
    235235    $_canvas coords $_labels($name) $x [expr {$y+5}]
  • branches/r9/gui/scripts/unirect2d.tcl

    r4030 r4919  
    176176# ----------------------------------------------------------------------
    177177# method blob
    178 #       Returns a base64 encoded, gzipped Tcl list that represents the
    179 #       Tcl command and data to recreate the uniform rectangular grid
    180 #       on the nanovis server.
     178#       Returns a Tcl list that represents the Tcl command and data to
     179#       recreate the uniform rectangular grid on the nanovis server.
    181180# ----------------------------------------------------------------------
    182181itcl::body Rappture::Unirect2d::blob {} {
     
    184183    lappend data "xmin" $_xMin "xmax" $_xMax "xnum" $_xNum
    185184    lappend data "ymin" $_yMin "ymax" $_yMax "ynum" $_yNum
    186     lappend data "xmin" $_xMin "ymin" $_yMin "xmax" $_xMax "ymax" $_yMax
    187185    return $data
    188186}
     
    190188# ----------------------------------------------------------------------
    191189# method mesh
    192 #       Returns a base64 encoded, gzipped Tcl list that represents the
    193 #       Tcl command and data to recreate the uniform rectangular grid
    194 #       on the nanovis server.
     190#       Returns a Tcl list that represents the mesh limits and dims.
    195191# ----------------------------------------------------------------------
    196192itcl::body Rappture::Unirect2d::mesh {} {
  • branches/r9/gui/scripts/unirect3d.tcl

    r4030 r4919  
    4141    private variable _xMax       0
    4242    private variable _xMin       0
    43     private variable _xNum       0;     # Number of points along x-axis.
     43    private variable _xNum       0;     # Number of points along x-axis
    4444    private variable _yMax       0
    4545    private variable _yMin       0
    46     private variable _yNum       0;     # Number of points along y-axis.
     46    private variable _yNum       0;     # Number of points along y-axis
    4747    private variable _zMax       0
    4848    private variable _zMin       0
    49     private variable _zNum       0;     # Number of points along z-axis.
    50     private variable _compNum    1;     # Number of components in values.
    51     private variable _values     "";    # BLT vector containing the z-values
     49    private variable _zNum       0;     # Number of points along z-axis
     50    private variable _compNum    1;     # Number of components in values
     51    private variable _values     "";    # BLT vector containing the values
    5252    private variable _hints
    5353}
     
    124124# ----------------------------------------------------------------------
    125125# method blob
    126 #       Returns a base64 encoded, gzipped Tcl list that represents the
    127 #       Tcl command and data to recreate the uniform rectangular grid
    128 #       on the nanovis server.
     126#       Returns a Tcl list that represents the Tcl command and data to
     127#       recreate the uniform rectangular grid on the nanovis server.
    129128# ----------------------------------------------------------------------
    130129itcl::body Rappture::Unirect3d::blob {} {
     
    142141# ----------------------------------------------------------------------
    143142# method mesh
    144 #       Returns a base64 encoded, gzipped Tcl list that represents the
    145 #       Tcl command and data to recreate the uniform rectangular grid
    146 #       on the nanovis server.
     143#       Returns a Tcl list that represents the points  of the uniform
     144#       grid.
    147145# ----------------------------------------------------------------------
    148146itcl::body Rappture::Unirect3d::mesh {} {
     
    166164# ----------------------------------------------------------------------
    167165# method values
    168 #       Returns a base64 encoded, gzipped Tcl list that represents the
    169 #       Tcl command and data to recreate the uniform rectangular grid
    170 #       on the nanovis server.
     166#       Returns a Tcl list that represents the field values
    171167# ----------------------------------------------------------------------
    172168itcl::body Rappture::Unirect3d::values {} {
     
    179175# ----------------------------------------------------------------------
    180176# method valuesObj
    181 #       Returns a base64 encoded, gzipped Tcl list that represents the
    182 #       Tcl command and data to recreate the uniform rectangular grid
    183 #       on the nanovis server.
     177#       Returns a BLT vector that represents the field values
    184178# ----------------------------------------------------------------------
    185179itcl::body Rappture::Unirect3d::valuesObj {} {
  • branches/r9/gui/scripts/visviewer.tcl

    r4336 r4919  
    3737    private variable _icon 0
    3838
    39     # Number of milliseconds to wait before idle timeout.  If greater than
    40     # 0, automatically disconnect from the visualization server when idle
    41     # timeout is reached.
     39    # Number of milliseconds to wait before idle timeout.  If greater than 0,
     40    # automatically disconnect from the visualization server when idle timeout
     41    # is reached.
    4242    private variable _idleTimeout 43200000; # 12 hours
    4343    #private variable _idleTimeout 5000;    # 5 seconds
     
    284284        if { [gets $_sid data] <= 0 } {
    285285            set _sid ""
    286             puts stderr "reading from server data=($data)"
     286            puts stderr "reading from server"
    287287            RemoveServerFromList $_serverType $server
    288288            continue
     
    454454    set _done($this) 1
    455455    set _buffer(out) $bytes
    456     if {1} {
    457         # Let's try this approach: allow a write to block so we don't
    458         # re-enter SendBytes
    459         SendHelper
    460     } else {
    461         # This can cause us to re-enter SendBytes during the tkwait, which
    462         # is not safe because the _buffer will be clobbered
    463         fileevent $_sid writable [itcl::code $this SendHelper]
    464         tkwait variable ::Rappture::VisViewer::_done($this)
    465     }
     456
     457    # There's problem when the user is interacting with the GUI at the
     458    # same time we're trying to write to the server.  Don't want to
     459    # block because, the GUI will look like it's dead.  We can start
     460    # by putting a busy window over plot so that inadvertent things like
     461    # mouse movements aren't received.
     462
     463    blt::busy hold $itk_component(main)
     464    fileevent $_sid writable [itcl::code $this SendHelper]
     465    tkwait variable ::Rappture::VisViewer::_done($this)
     466    blt::busy release $itk_component(main)
     467
    466468    set _buffer(out) ""
    467469    if { [IsConnected] } {
    468         # The connection may have closed while we were writing to the
    469         # server.  This can happen if what we sent the server caused it to
    470         # barf.
     470        # The connection may have closed while we were writing to the server.
     471        # This can happen if what we sent the server caused it to barf.
    471472        fileevent $_sid writable ""
    472473        flush $_sid
     
    518519#   Helper routine called from a file event when the connection is readable
    519520#   (i.e. a command response has been sent by the rendering server.  Reads
    520 #   the incoming command and executes it in a safe interpreter to handle
    521 #   the action.
     521#   the incoming command and executes it in a safe interpreter to handle the
     522#   action.
    522523#
    523524#       Note: This routine currently only handles command responses from
     
    601602# SendEcho --
    602603#
    603 #     Used internally to echo sent data to clients interested in this
    604 #     widget.  If the -sendcommand opti on is set, then it is invoked in
    605 #     the global scope with the <channel> and <data> values as arguments.
    606 #     Otherwise, this does nothing.
     604#     Used internally to echo sent data to clients interested in this widget.
     605#     If the -sendcommand option is set, then it is invoked in the global scope
     606#     with the <channel> and <data> values as arguments.  Otherwise, this does
     607#     nothing.
    607608#
    608609itcl::body Rappture::VisViewer::SendEcho {channel {data ""}} {
    609610    if { $_logging }  {
    610         set f [open "/tmp/recording.log" "a"]
    611         puts $f $data
    612         close $f
     611        set f [open "/tmp/recording.log" "a"]
     612        fconfigure $f -translation binary -encoding binary
     613        puts -nonewline $f $data
     614        close $f
    613615    }
    614616    #puts stderr ">>($data)"
     
    11351137        }
    11361138    }
    1137     #regsub -all "\n" $cmap " " cmap
    11381139    return $cmap
    11391140}
     
    11521153#
    11531154# StopBufferingCommands --
     1155#
     1156#       This gets called when we want to stop buffering the commands for
     1157#       the server and actually send then to the server.  Note that there's
     1158#       a reference count on buffering.  This is so that you can can
     1159#       Start/Stop multiple times without worrying about the current state.
    11541160#
    11551161itcl::body Rappture::VisViewer::StopBufferingCommands { } {
  • branches/r9/gui/scripts/vtkglyphviewer.tcl

    r4344 r4919  
    118118    # heightmaps displayed.
    119119    private variable _currentColormap ""
    120     private variable _currentOpacity ""
    121120
    122121    private variable _dataset2style    ;# maps dataobj-component to transfunc
     
    183182    $_dispatcher register !xcutplane
    184183    $_dispatcher dispatch $this !xcutplane \
    185         "[itcl::code $this AdjustSetting cutplaneXPosition]; list"
     184        "[itcl::code $this AdjustSetting -cutplanexposition]; list"
    186185
    187186    # Y-Cutplane event
    188187    $_dispatcher register !ycutplane
    189188    $_dispatcher dispatch $this !ycutplane \
    190         "[itcl::code $this AdjustSetting cutplaneYPosition]; list"
     189        "[itcl::code $this AdjustSetting -cutplaneyposition]; list"
    191190
    192191    # Z-Cutplane event
    193192    $_dispatcher register !zcutplane
    194193    $_dispatcher dispatch $this !zcutplane \
    195         "[itcl::code $this AdjustSetting cutplaneZPosition]; list"
     194        "[itcl::code $this AdjustSetting -cutplanezposition]; list"
    196195
    197196    #
     
    218217
    219218    array set _settings [subst {
    220         background              black
    221         colormap                BCGYR
    222         colormapVisible         1
    223         field                   "Default"
    224         axesVisible             1
    225         axisLabelsVisible       1
    226         axisXGrid               0
    227         axisYGrid               0
    228         axisZGrid               0
    229         cutplaneEdges           0
    230         cutplaneLighting        1
    231         cutplanePreinterp       1
    232         cutplaneOpacity         100
    233         cutplaneVisible         0
    234         cutplaneWireframe       0
    235         cutplaneXPosition       50
    236         cutplaneXVisible        1
    237         cutplaneYPosition       50
    238         cutplaneYVisible        1
    239         cutplaneZPosition       50
    240         cutplaneZVisible        1
    241         glyphEdges              0
    242         glyphLighting           1
    243         glyphNormscale          1
    244         glyphOpacity            100
    245         saveGlyphOpacity        100
    246         glyphOrient             1
    247         glyphOutline            0
    248         glyphScale              1
    249         glyphScaleMode          "vmag"
    250         glyphShape              "arrow"
    251         glyphVisible            1
    252         glyphWireframe          0
    253         legendVisible           1
     219        -axesvisible            1
     220        -axislabels             1
     221        -axisminorticks         1
     222        -axismode               "static"
     223        -background             black
     224        -colormap               BCGYR
     225        -colormapvisible        1
     226        -cutplaneedges          0
     227        -cutplanelighting       1
     228        -cutplanepreinterp      1
     229        -cutplaneopacity        100
     230        -cutplanevisible        0
     231        -cutplanewireframe      0
     232        -cutplanexposition      50
     233        -cutplanexvisible       1
     234        -cutplaneyposition      50
     235        -cutplaneyvisible       1
     236        -cutplanezposition      50
     237        -cutplanezvisible       1
     238        -field                  "Default"
     239        -glyphedges             0
     240        -glyphlighting          1
     241        -glyphopacity           100
     242        -glyphoutline           0
     243        -glyphscale             1
     244        -glyphvisible           1
     245        -glyphwireframe         0
     246        -legendvisible          1
     247        -saveglyphopacity       100
     248        -xgrid                  0
     249        -ygrid                  0
     250        -zgrid                  0
    254251    }]
    255252    array set _changed {
    256         glyphOpacity            0
    257         colormap                0
     253        -colormap               0
     254        -glyphopacity           0
    258255    }
    259256
     
    335332            -onimage [Rappture::icon volume-on] \
    336333            -offimage [Rappture::icon volume-off] \
    337             -variable [itcl::scope _settings(glyphVisible)] \
    338             -command [itcl::code $this AdjustSetting glyphVisible]
     334            -variable [itcl::scope _settings(-glyphvisible)] \
     335            -command [itcl::code $this AdjustSetting -glyphvisible]
    339336    }
    340337    $itk_component(glyphs) select
     
    348345            -onimage [Rappture::icon cutbutton] \
    349346            -offimage [Rappture::icon cutbutton] \
    350             -variable [itcl::scope _settings(cutplaneVisible)] \
    351             -command [itcl::code $this AdjustSetting cutplaneVisible]
     347            -variable [itcl::scope _settings(-cutplanevisible)] \
     348            -command [itcl::code $this AdjustSetting -cutplanevisible]
    352349    }
    353350    Rappture::Tooltip::for $itk_component(cutplane) \
     
    439436    eval itk_initialize $args
    440437    Connect
    441     update
    442438}
    443439
     
    547543}
    548544
    549 
    550545# ----------------------------------------------------------------------
    551546# USAGE: delete ?<dataobj1> <dataobj2> ...?
    552547#
    553 #       Clients use this to delete a dataobj from the plot.  If no dataobjs
    554 #       are specified, then all dataobjs are deleted.  No data objects are
    555 #       deleted.  They are only removed from the display list.
     548#    Clients use this to delete a dataobj from the plot.  If no dataobjs
     549#    are specified, then all dataobjs are deleted.  No data objects are
     550#    deleted.  They are only removed from the display list.
    556551#
    557552# ----------------------------------------------------------------------
     
    782777                set session $env(SESSION)
    783778            }
     779            lappend info "version" "$Rappture::version"
     780            lappend info "build" "$Rappture::build"
     781            lappend info "svnurl" "$Rappture::svnurl"
     782            lappend info "installdir" "$Rappture::installdir"
    784783            lappend info "hub" [exec hostname]
    785784            lappend info "client" "vtkglyphviewer"
     
    799798# isconnected --
    800799#
    801 #       Indicates if we are currently connected to the visualization server.
     800#    Indicates if we are currently connected to the visualization server.
    802801#
    803802itcl::body Rappture::VtkGlyphViewer::isconnected {} {
     
    816815# Disconnect --
    817816#
    818 #       Clients use this method to disconnect from the current rendering
    819 #       server.
     817#    Clients use this method to disconnect from the current rendering
     818#    server.
    820819#
    821820itcl::body Rappture::VtkGlyphViewer::Disconnect {} {
     
    955954        PanCamera
    956955        set _first ""
    957         InitSettings axisXGrid axisYGrid axisZGrid axisMode \
    958             axesVisible axisLabelsVisible
     956        InitSettings -xgrid -ygrid -zgrid -axismode \
     957            -axesvisible -axislabels -axisminorticks
    959958        foreach axis { x y z } {
    960959            SendCmd "axis lformat $axis %g"
     
    975974            if { ![info exists _datasets($tag)] } {
    976975                set bytes [$dataobj vtkdata $comp]
    977                 if 0 {
    978                     set f [open "/tmp/glyph.vtk" "w"]
    979                     puts $f $bytes
    980                     close $f
     976                if 0 {
     977                    set f [open "/tmp/glyph.vtk" "w"]
     978                    puts $f $bytes
     979                    close $f
    981980                }
    982981                set length [string length $bytes]
     
    992991                    SendCmd "clientinfo [list $info]"
    993992                }
    994                 append _outbuf "dataset add $tag data follows $length\n"
     993                SendCmd "dataset add $tag data follows $length"
    995994                append _outbuf $bytes
    996995                set _datasets($tag) 1
     
    10011000                # Setting dataset visible enables outline
    10021001                # and glyphs
    1003                 SendCmd "dataset visible 1 $tag"
     1002                SendCmd "dataset visible 1 $tag"
    10041003            }
    10051004        }
     
    10071006
    10081007    if { $_first != "" } {
    1009         $itk_component(field) choices delete 0 end
    1010         $itk_component(fieldmenu) delete 0 end
    1011         array unset _fields
     1008        $itk_component(field) choices delete 0 end
     1009        $itk_component(fieldmenu) delete 0 end
     1010        array unset _fields
    10121011        set _curFldName ""
    10131012        foreach cname [$_first components] {
     
    10351034        $itk_component(field) value $_curFldLabel
    10361035    }
    1037     InitSettings glyphOutline
    1038         #cutplaneVisible
     1036    InitSettings -glyphoutline
     1037        #-cutplanevisible
    10391038    if { $_reset } {
    1040         # These are settings that rely on a dataset being loaded.
     1039        # These are settings that rely on a dataset being loaded.
    10411040        InitSettings \
    1042             glyphLighting \
    1043             field \
    1044             glyphEdges glyphLighting glyphOpacity \
    1045             glyphWireframe
    1046 
    1047         #cutplaneXPosition cutplaneYPosition cutplaneZPosition \
    1048             cutplaneXVisible cutplaneYVisible cutplaneZVisible \
    1049             cutplanePreinterp
     1041            -glyphlighting \
     1042            -field \
     1043            -glyphedges -glyphlighting -glyphopacity \
     1044            -glyphwireframe
     1045
     1046        #-cutplanexposition -cutplaneyposition -cutplanezposition \
     1047            -cutplanexvisible -cutplaneyvisible -cutplanezvisible \
     1048            -cutplanepreinterp
    10501049
    10511050        Zoom reset
    1052         foreach axis { x y z } {
     1051        foreach axis { x y z } {
    10531052            # Another problem fixed by a <view>. We looking into a data
    10541053            # object for the name of the axes. This should be global to
    10551054            # the viewer itself.
    1056             set label [$_first hints ${axis}label]
    1057             if { $label == "" } {
     1055            set label [$_first hints ${axis}label]
     1056            if { $label == "" } {
    10581057                set label [string toupper $axis]
    1059             }
    1060             # May be a space in the axis label.
    1061             SendCmd [list axis name $axis $label]
     1058            }
     1059            # May be a space in the axis label.
     1060            SendCmd [list axis name $axis $label]
    10621061        }
    10631062        if { [array size _fields] < 2 } {
    1064             blt::table forget $itk_component(field) $itk_component(field_l)
     1063            catch {blt::table forget $itk_component(field) $itk_component(field_l)}
    10651064        }
    10661065        set _reset 0
     
    11661165    SendCmd "camera pan $x $y"
    11671166}
    1168 
    11691167
    11701168# ----------------------------------------------------------------------
     
    12871285itcl::body Rappture::VtkGlyphViewer::InitSettings { args } {
    12881286    foreach spec $args {
    1289         if { [info exists _settings($_first-$spec)] } {
     1287        if { [info exists _settings($_first${spec})] } {
    12901288            # Reset global setting with dataobj specific setting
    1291             set _settings($spec) $_settings($_first-$spec)
     1289            set _settings($spec) $_settings($_first${spec})
    12921290        }
    12931291        AdjustSetting $spec
     
    12981296# AdjustSetting --
    12991297#
    1300 #       Changes/updates a specific setting in the widget.  There are
    1301 #       usually user-setable option.  Commands are sent to the render
    1302 #       server.
     1298#    Changes/updates a specific setting in the widget.  There are
     1299#    usually user-setable option.  Commands are sent to the render
     1300#    server.
    13031301#
    13041302itcl::body Rappture::VtkGlyphViewer::AdjustSetting {what {value ""}} {
     
    13071305    }
    13081306    switch -- $what {
    1309         "background" {
     1307        "-background" {
    13101308            set bgcolor [$itk_component(background) value]
    1311             array set fgcolors {
    1312                 "black" "white"
    1313                 "white" "black"
    1314                 "grey"  "black"
    1315             }
     1309            array set fgcolors {
     1310                "black" "white"
     1311                "white" "black"
     1312                "grey"  "black"
     1313            }
    13161314            configure -plotbackground $bgcolor \
    1317                 -plotforeground $fgcolors($bgcolor)
    1318             $itk_component(view) delete "legend"
    1319             DrawLegend
    1320         }
    1321         "axesVisible" {
    1322             set bool $_settings(axesVisible)
     1315                -plotforeground $fgcolors($bgcolor)
     1316            $itk_component(view) delete "legend"
     1317            DrawLegend
     1318        }
     1319        "-axesvisible" {
     1320            set bool $_settings($what)
    13231321            SendCmd "axis visible all $bool"
    13241322        }
    1325         "axisLabelsVisible" {
    1326             set bool $_settings(axisLabelsVisible)
     1323        "-axislabels" {
     1324            set bool $_settings($what)
    13271325            SendCmd "axis labels all $bool"
    13281326        }
    1329         "axisXGrid" - "axisYGrid" - "axisZGrid" {
    1330             set axis [string tolower [string range $what 4 4]]
     1327        "-axisminorticks" {
     1328            set bool $_settings($what)
     1329            SendCmd "axis minticks all $bool"
     1330        }
     1331        "-xgrid" - "-ygrid" - "-zgrid" {
     1332            set axis [string tolower [string range $what 1 1]]
    13311333            set bool $_settings($what)
    13321334            SendCmd "axis grid $axis $bool"
    13331335        }
    1334         "axisMode" {
     1336        "-axismode" {
    13351337            set mode [$itk_component(axisMode) value]
    13361338            set mode [$itk_component(axisMode) translate $mode]
     
    13381340            SendCmd "axis flymode $mode"
    13391341        }
    1340         "cutplaneEdges" {
     1342        "-cutplaneedges" {
    13411343            set bool $_settings($what)
    13421344            SendCmd "cutplane edges $bool"
    13431345        }
    1344         "cutplaneVisible" {
     1346        "-cutplanevisible" {
    13451347            set bool $_settings($what)
    13461348            SendCmd "cutplane visible $bool"
    13471349        }
    1348         "cutplaneWireframe" {
     1350        "-cutplanewireframe" {
    13491351            set bool $_settings($what)
    13501352            SendCmd "cutplane wireframe $bool"
    13511353        }
    1352         "cutplaneLighting" {
     1354        "-cutplanelighting" {
    13531355            set bool $_settings($what)
    13541356            SendCmd "cutplane lighting $bool"
    13551357        }
    1356         "cutplaneOpacity" {
     1358        "-cutplaneopacity" {
    13571359            set val $_settings($what)
    13581360            set sval [expr { 0.01 * double($val) }]
    13591361            SendCmd "cutplane opacity $sval"
    13601362        }
    1361         "cutplanePreinterp" {
     1363        "-cutplanepreinterp" {
    13621364            set bool $_settings($what)
    13631365            SendCmd "cutplane preinterp $bool"
    13641366        }
    1365         "cutplaneXVisible" - "cutplaneYVisible" - "cutplaneZVisible" {
    1366             set axis [string tolower [string range $what 8 8]]
     1367        "-cutplanexvisible" - "-cutplaneyvisible" - "-cutplanezvisible" {
     1368            set axis [string tolower [string range $what 9 9]]
    13671369            set bool $_settings($what)
    13681370            if { $bool } {
     
    13731375                    -troughcolor grey82
    13741376            }
    1375             SendCmd "cutplane axis $axis $bool"
    1376         }
    1377         "cutplaneXPosition" - "cutplaneYPosition" - "cutplaneZPosition" {
    1378             set axis [string tolower [string range $what 8 8]]
     1377            SendCmd "cutplane axis $axis $bool"
     1378        }
     1379        "-cutplanexposition" - "-cutplaneyposition" - "-cutplanezposition" {
     1380            set axis [string tolower [string range $what 9 9]]
    13791381            set pos [expr $_settings($what) * 0.01]
    13801382            SendCmd "cutplane slice ${axis} ${pos}"
    13811383            set _cutplanePending 0
    13821384        }
    1383         "colormap" {
    1384             set _changed(colormap) 1
     1385        "-colormap" {
     1386            set _changed($what) 1
    13851387            StartBufferingCommands
    13861388            set color [$itk_component(colormap) value]
    1387             set _settings(colormap) $color
    1388             if { $color == "none" } {
    1389                 if { $_settings(colormapVisible) } {
    1390                     SendCmd "glyphs colormode constant {}"
    1391                     set _settings(colormapVisible) 0
    1392                 }
    1393             } else {
    1394                 if { !$_settings(colormapVisible) } {
    1395                     SendCmd "glyphs colormode $_colorMode $_curFldName"
    1396                     set _settings(colormapVisible) 1
    1397                 }
    1398                 SetCurrentColormap $color
    1399             }
     1389            set _settings($what) $color
     1390            if { $color == "none" } {
     1391                if { $_settings(-colormapvisible) } {
     1392                    SendCmd "glyphs colormode constant {}"
     1393                    set _settings(-colormapvisible) 0
     1394                }
     1395            } else {
     1396                if { !$_settings(-colormapvisible) } {
     1397                    SendCmd "glyphs colormode $_colorMode $_curFldName"
     1398                    set _settings(-colormapvisible) 1
     1399                }
     1400                SetCurrentColormap $color
     1401            }
    14001402            StopBufferingCommands
    1401             EventuallyRequestLegend
    1402         }
    1403         "glyphWireframe" {
     1403            EventuallyRequestLegend
     1404        }
     1405        "-glyphwireframe" {
    14041406            set bool $_settings($what)
    1405             SendCmd "glyphs wireframe $bool"
    1406         }
    1407         "glyphVisible" {
     1407            SendCmd "glyphs wireframe $bool"
     1408        }
     1409        "-glyphvisible" {
    14081410            set bool $_settings($what)
    1409             SendCmd "glyphs visible $bool"
     1411            SendCmd "glyphs visible $bool"
    14101412            if { $bool } {
    14111413                Rappture::Tooltip::for $itk_component(glyphs) \
     
    14151417                    "Show the glyph"
    14161418            }
    1417             DrawLegend
    1418         }
    1419         "glyphLighting" {
     1419            DrawLegend
     1420        }
     1421        "-glyphlighting" {
    14201422            set bool $_settings($what)
    1421             SendCmd "glyphs lighting $bool"
    1422         }
    1423         "glyphEdges" {
     1423            SendCmd "glyphs lighting $bool"
     1424        }
     1425        "-glyphedges" {
    14241426            set bool $_settings($what)
    1425             SendCmd "glyphs edges $bool"
    1426         }
    1427         "glyphOutline" {
     1427            SendCmd "glyphs edges $bool"
     1428        }
     1429        "-glyphoutline" {
    14281430            set bool $_settings($what)
    1429             SendCmd "outline visible $bool"
    1430         }
    1431         "glyphOpacity" {
     1431            SendCmd "outline visible $bool"
     1432        }
     1433        "-glyphopacity" {
    14321434            set val $_settings($what)
    14331435            set sval [expr { 0.01 * double($val) }]
    1434             SendCmd "glyphs opacity $sval"
    1435         }
    1436         "glyphNormscale" {
    1437             set bool $_settings($what)
    1438             SendCmd "glyphs normscale $bool"
    1439         }
    1440         "glyphOrient" {
    1441             set bool $_settings($what)
    1442             SendCmd "glyphs gorient $bool {}"
    1443         }
    1444         "glyphScale" {
     1436            SendCmd "glyphs opacity $sval"
     1437        }
     1438        "-glyphscale" {
    14451439            set val $_settings($what)
    1446             SendCmd "glyphs gscale $val"
    1447         }
    1448         "glyphScaleMode" {
    1449             set label [$itk_component(scaleMode) value]
    1450             set mode [$itk_component(scaleMode) translate $label]
    1451             set _settings($what) $mode
    1452             SendCmd "glyphs smode $mode {}"
    1453         }
    1454         "glyphShape" {
    1455             set label [$itk_component(gshape) value]
    1456             set shape [$itk_component(gshape) translate $label]
    1457             set _settings($what) $shape
    1458             SendCmd "glyphs shape $shape"
    1459         }
    1460         "field" {
     1440            if { [string is double $val] } {
     1441                SendCmd "glyphs gscale $val"
     1442            }
     1443        }
     1444        "-field" {
    14611445            set label [$itk_component(field) value]
    14621446            set fname [$itk_component(field) translate $label]
    1463             set _settings(field) $fname
     1447            set _settings($what) $fname
    14641448            if { [info exists _fields($fname)] } {
    14651449                foreach { label units components } $_fields($fname) break
     
    14751459                return
    14761460            }
    1477             #if { ![info exists _limits($_curFldName)] } {
    1478             #    SendCmd "dataset maprange all"
    1479             #} else {
    1480             #    SendCmd "dataset maprange explicit $_limits($_curFldName) $_curFldName"
    1481             #}
    1482             #SendCmd "cutplane colormode $_colorMode $_curFldName"
    14831461            SendCmd "glyphs colormode $_colorMode $_curFldName"
    14841462            DrawLegend
    14851463        }
    1486         "legendVisible" {
     1464        "-legendvisible" {
    14871465            if { !$_settings($what) } {
    14881466                $itk_component(view) delete legend
    1489             }
    1490             DrawLegend
     1467            }
     1468            DrawLegend
    14911469        }
    14921470        default {
     
    14961474}
    14971475
    1498 
    14991476#
    15001477# RequestLegend --
    15011478#
    1502 #       Request a new legend from the server.  The size of the legend
    1503 #       is determined from the height of the canvas. 
     1479#    Request a new legend from the server.  The size of the legend
     1480#    is determined from the height of the canvas. 
    15041481#
    15051482# This should be called when
    1506 #       1.  A new current colormap is set.
    1507 #       2.  Window is resized.
    1508 #       3.  The limits of the data have changed.  (Just need a redraw).
    1509 #       4.  Number of glyph have changed. (Just need a redraw).
    1510 #       5.  Legend becomes visible (Just need a redraw).
     1483#    1.  A new current colormap is set.
     1484#    2.  Window is resized.
     1485#    3.  The limits of the data have changed.  (Just need a redraw).
     1486#    4.  Number of glyph have changed. (Just need a redraw).
     1487#    5.  Legend becomes visible (Just need a redraw).
    15111488#
    15121489itcl::body Rappture::VtkGlyphViewer::RequestLegend {} {
     
    15201497    set fname $_curFldName
    15211498    if { [string match "component*" $fname] } {
    1522         set title ""
     1499        set title ""
    15231500    } else {
    1524         if { [info exists _fields($fname)] } {
    1525             foreach { title units } $_fields($fname) break
    1526             if { $units != "" } {
    1527                 set title [format "%s (%s)" $title $units]
    1528             }
    1529         } else {
    1530             set title $fname
    1531         }
     1501        if { [info exists _fields($fname)] } {
     1502            foreach { title units } $_fields($fname) break
     1503            if { $units != "" } {
     1504                set title [format "%s (%s)" $title $units]
     1505            }
     1506        } else {
     1507            set title $fname
     1508        }
    15321509    }
    15331510    # If there's a title too, substract one more line
     
    15401517    # Set the legend on the first heightmap dataset.
    15411518    if { $_currentColormap != ""  } {
    1542         set cmap $_currentColormap
    1543         SendCmdNoWait "legend $cmap $_colorMode $_curFldName {} $w $h 0"
     1519        set cmap $_currentColormap
     1520        SendCmdNoWait "legend $cmap $_colorMode $_curFldName {} $w $h 0"
    15441521    }
    15451522}
     
    15611538    if { [isconnected] } {
    15621539        set rgb [Color2RGB $itk_option(-plotforeground)]
    1563         SendCmd "axis color all $rgb"
     1540        SendCmd "axis color all $rgb"
    15641541        SendCmd "outline color $rgb"
    15651542        #SendCmd "cutplane color $rgb"
     
    15871564    checkbutton $inner.glyphs \
    15881565        -text "Glyphs" \
    1589         -variable [itcl::scope _settings(glyphVisible)] \
    1590         -command [itcl::code $this AdjustSetting glyphVisible] \
     1566        -variable [itcl::scope _settings(-glyphvisible)] \
     1567        -command [itcl::code $this AdjustSetting -glyphvisible] \
    15911568        -font "Arial 9"
    1592 
    1593     label $inner.gshape_l -text "Glyph shape" -font "Arial 9"
    1594     itk_component add gshape {
    1595         Rappture::Combobox $inner.gshape -width 10 -editable no
    1596     }
    1597     $inner.gshape choices insert end \
    1598         "arrow"              "arrow"           \
    1599         "cone"               "cone"            \
    1600         "cube"               "cube"            \
    1601         "cylinder"           "cylinder"        \
    1602         "dodecahedron"       "dodecahedron"    \
    1603         "icosahedron"        "icosahedron"     \
    1604         "line"               "line"            \
    1605         "octahedron"         "octahedron"      \
    1606         "point"              "point"           \
    1607         "sphere"             "sphere"          \
    1608         "tetrahedron"        "tetrahedron"
    1609 
    1610     $itk_component(gshape) value $_settings(glyphShape)
    1611     bind $inner.gshape <<Value>> [itcl::code $this AdjustSetting glyphShape]
    1612 
    1613     label $inner.scaleMode_l -text "Scale by" -font "Arial 9"
    1614     itk_component add scaleMode {
    1615         Rappture::Combobox $inner.scaleMode -width 10 -editable no
    1616     }
    1617     $inner.scaleMode choices insert end \
    1618         "scalar" "Scalar"            \
    1619         "vmag"   "Vector magnitude"  \
    1620         "vcomp"  "Vector components" \
    1621         "off"    "Constant size"
    1622 
    1623     $itk_component(scaleMode) value "[$itk_component(scaleMode) label $_settings(glyphScaleMode)]"
    1624     bind $inner.scaleMode <<Value>> [itcl::code $this AdjustSetting glyphScaleMode]
    1625 
    1626     checkbutton $inner.normscale \
    1627         -text "Normalize scaling" \
    1628         -variable [itcl::scope _settings(glyphNormscale)] \
    1629         -command [itcl::code $this AdjustSetting glyphNormscale] \
    1630         -font "Arial 9"
    1631     Rappture::Tooltip::for $inner.normscale "If enabled, field values are normalized to \[0,1\] before scaling and scale factor is relative to a default size"
    1632 
    1633     checkbutton $inner.gorient \
    1634         -text "Orient" \
    1635         -variable [itcl::scope _settings(glyphOrient)] \
    1636         -command [itcl::code $this AdjustSetting glyphOrient] \
    1637         -font "Arial 9"
    1638     Rappture::Tooltip::for $inner.gorient "Orient glyphs by vector field directions"
    16391569
    16401570    checkbutton $inner.wireframe \
    16411571        -text "Wireframe" \
    1642         -variable [itcl::scope _settings(glyphWireframe)] \
    1643         -command [itcl::code $this AdjustSetting glyphWireframe] \
     1572        -variable [itcl::scope _settings(-glyphwireframe)] \
     1573        -command [itcl::code $this AdjustSetting -glyphwireframe] \
    16441574        -font "Arial 9"
    16451575
    16461576    checkbutton $inner.lighting \
    16471577        -text "Enable Lighting" \
    1648         -variable [itcl::scope _settings(glyphLighting)] \
    1649         -command [itcl::code $this AdjustSetting glyphLighting] \
     1578        -variable [itcl::scope _settings(-glyphlighting)] \
     1579        -command [itcl::code $this AdjustSetting -glyphlighting] \
    16501580        -font "Arial 9"
    16511581
    16521582    checkbutton $inner.edges \
    16531583        -text "Edges" \
    1654         -variable [itcl::scope _settings(glyphEdges)] \
    1655         -command [itcl::code $this AdjustSetting glyphEdges] \
     1584        -variable [itcl::scope _settings(-glyphedges)] \
     1585        -command [itcl::code $this AdjustSetting -glyphedges] \
    16561586        -font "Arial 9"
    16571587
    16581588    checkbutton $inner.outline \
    16591589        -text "Outline" \
    1660         -variable [itcl::scope _settings(glyphOutline)] \
    1661         -command [itcl::code $this AdjustSetting glyphOutline] \
     1590        -variable [itcl::scope _settings(-glyphoutline)] \
     1591        -command [itcl::code $this AdjustSetting -glyphoutline] \
    16621592        -font "Arial 9"
    16631593
    16641594    checkbutton $inner.legend \
    16651595        -text "Legend" \
    1666         -variable [itcl::scope _settings(legendVisible)] \
    1667         -command [itcl::code $this AdjustSetting legendVisible] \
     1596        -variable [itcl::scope _settings(-legendvisible)] \
     1597        -command [itcl::code $this AdjustSetting -legendvisible] \
    16681598        -font "Arial 9"
    16691599
     
    16771607        "grey"               "grey"             
    16781608
    1679     $itk_component(background) value $_settings(background)
    1680     bind $inner.background <<Value>> [itcl::code $this AdjustSetting background]
     1609    $itk_component(background) value $_settings(-background)
     1610    bind $inner.background <<Value>> [itcl::code $this AdjustSetting -background]
    16811611
    16821612    label $inner.opacity_l -text "Opacity" -font "Arial 9"
    16831613    ::scale $inner.opacity -from 0 -to 100 -orient horizontal \
    1684         -variable [itcl::scope _settings(glyphOpacity)] \
     1614        -variable [itcl::scope _settings(-glyphopacity)] \
    16851615        -width 10 \
    16861616        -showvalue off \
    1687         -command [itcl::code $this AdjustSetting glyphOpacity]
     1617        -command [itcl::code $this AdjustSetting -glyphopacity]
    16881618
    16891619    label $inner.gscale_l -text "Scale factor" -font "Arial 9"
    1690     if {0} {
    16911620    ::scale $inner.gscale -from 1 -to 100 -orient horizontal \
    1692         -variable [itcl::scope _settings(glyphScale)] \
     1621        -variable [itcl::scope _settings(-glyphscale)] \
    16931622        -width 10 \
    16941623        -showvalue off \
    1695         -command [itcl::code $this AdjustSetting glyphScale]
    1696     } else {
    1697     itk_component add gscale {
    1698         entry $inner.gscale -font "Arial 9" -bg white \
    1699             -textvariable [itcl::scope _settings(glyphScale)]
    1700     } {
    1701         ignore -font -background
    1702     }
    1703     bind $inner.gscale <Return> \
    1704         [itcl::code $this AdjustSetting glyphScale]
    1705     bind $inner.gscale <KP_Enter> \
    1706         [itcl::code $this AdjustSetting glyphScale]
    1707     }
     1624        -command [itcl::code $this AdjustSetting -glyphscale]
    17081625    Rappture::Tooltip::for $inner.gscale "Set scaling multiplier (or constant size)"
    17091626
     
    17171634    }
    17181635    bind $inner.field <<Value>> \
    1719         [itcl::code $this AdjustSetting field]
     1636        [itcl::code $this AdjustSetting -field]
    17201637
    17211638    label $inner.colormap_l -text "Colormap" -font "Arial 9"
     
    17231640        Rappture::Combobox $inner.colormap -width 10 -editable no
    17241641    }
    1725     $inner.colormap choices insert end [GetColormapList -includeNone]
     1642
     1643    $inner.colormap choices insert end [GetColormapList]
    17261644    $itk_component(colormap) value "BCGYR"
    17271645    bind $inner.colormap <<Value>> \
    1728         [itcl::code $this AdjustSetting colormap]
     1646        [itcl::code $this AdjustSetting -colormap]
    17291647
    17301648    blt::table $inner \
     
    17331651        1,0 $inner.colormap_l   -anchor w -pady 2  \
    17341652        1,1 $inner.colormap     -anchor w -pady 2  -fill x \
    1735         2,0 $inner.gshape_l     -anchor w -pady 2  \
    1736         2,1 $inner.gshape       -anchor w -pady 2  -fill x \
    1737         3,0 $inner.background_l -anchor w -pady 2 \
    1738         3,1 $inner.background   -anchor w -pady 2  -fill x \
    1739         4,0 $inner.scaleMode_l  -anchor w -pady 2  \
    1740         4,1 $inner.scaleMode    -anchor w -pady 2  -fill x \
    1741         5,0 $inner.gscale_l     -anchor w -pady 2 \
    1742         5,1 $inner.gscale       -anchor w -pady 2  -fill x \
    1743         6,0 $inner.normscale    -anchor w -pady 2 -cspan 2 \
    1744         7,0 $inner.gorient      -anchor w -pady 2 -cspan 2 \
    1745         8,0 $inner.wireframe    -anchor w -pady 2 -cspan 2 \
    1746         9,0 $inner.lighting     -anchor w -pady 2 -cspan 2 \
    1747         10,0 $inner.edges        -anchor w -pady 2 -cspan 2 \
    1748         11,0 $inner.outline     -anchor w -pady 2 -cspan 2 \
    1749         12,0 $inner.legend      -anchor w -pady 2 \
    1750         13,0 $inner.opacity_l   -anchor w -pady 2 \
    1751         13,1 $inner.opacity     -fill x   -pady 2 -fill x \
     1653        3,0 $inner.background_l -anchor w -pady 2 \
     1654        3,1 $inner.background   -anchor w -pady 2  -fill x \
     1655        5,0 $inner.wireframe    -anchor w -pady 2 -cspan 2 \
     1656        6,0 $inner.lighting     -anchor w -pady 2 -cspan 2 \
     1657        7,0 $inner.edges        -anchor w -pady 2 -cspan 2 \
     1658        8,0 $inner.outline      -anchor w -pady 2 -cspan 2 \
     1659        9,0 $inner.legend       -anchor w -pady 2 \
     1660        10,0 $inner.opacity_l   -anchor w -pady 2 \
     1661        10,1 $inner.opacity     -fill x   -pady 2 -fill x \
    17521662
    17531663    blt::table configure $inner r* c* -resize none
    1754     blt::table configure $inner r14 c1 -resize expand
     1664    blt::table configure $inner r11 c1 -resize expand
    17551665}
    17561666
     
    17661676
    17671677    checkbutton $inner.visible \
    1768         -text "Show Axes" \
    1769         -variable [itcl::scope _settings(axesVisible)] \
    1770         -command [itcl::code $this AdjustSetting axesVisible] \
     1678        -text "Axes" \
     1679        -variable [itcl::scope _settings(-axesvisible)] \
     1680        -command [itcl::code $this AdjustSetting -axesvisible] \
    17711681        -font "Arial 9"
    17721682
    17731683    checkbutton $inner.labels \
    1774         -text "Show Axis Labels" \
    1775         -variable [itcl::scope _settings(axisLabelsVisible)] \
    1776         -command [itcl::code $this AdjustSetting axisLabelsVisible] \
     1684        -text "Axis Labels" \
     1685        -variable [itcl::scope _settings(-axislabels)] \
     1686        -command [itcl::code $this AdjustSetting -axislabels] \
    17771687        -font "Arial 9"
    1778 
    1779     checkbutton $inner.gridx \
    1780         -text "Show X Grid" \
    1781         -variable [itcl::scope _settings(axisXGrid)] \
    1782         -command [itcl::code $this AdjustSetting axisXGrid] \
     1688    label $inner.grid_l -text "Grid" -font "Arial 9"
     1689    checkbutton $inner.xgrid \
     1690        -text "X" \
     1691        -variable [itcl::scope _settings(-xgrid)] \
     1692        -command [itcl::code $this AdjustSetting -xgrid] \
    17831693        -font "Arial 9"
    1784     checkbutton $inner.gridy \
    1785         -text "Show Y Grid" \
    1786         -variable [itcl::scope _settings(axisYGrid)] \
    1787         -command [itcl::code $this AdjustSetting axisYGrid] \
     1694    checkbutton $inner.ygrid \
     1695        -text "Y" \
     1696        -variable [itcl::scope _settings(-ygrid)] \
     1697        -command [itcl::code $this AdjustSetting -ygrid] \
    17881698        -font "Arial 9"
    1789     checkbutton $inner.gridz \
    1790         -text "Show Z Grid" \
    1791         -variable [itcl::scope _settings(axisZGrid)] \
    1792         -command [itcl::code $this AdjustSetting axisZGrid] \
     1699    checkbutton $inner.zgrid \
     1700        -text "Z" \
     1701        -variable [itcl::scope _settings(-zgrid)] \
     1702        -command [itcl::code $this AdjustSetting -zgrid] \
     1703        -font "Arial 9"
     1704    checkbutton $inner.minorticks \
     1705        -text "Minor Ticks" \
     1706        -variable [itcl::scope _settings(-axisminorticks)] \
     1707        -command [itcl::code $this AdjustSetting -axisminorticks] \
    17931708        -font "Arial 9"
    17941709
     
    18031718        "furthest_triad"  "farthest" \
    18041719        "outer_edges"     "outer"         
    1805     $itk_component(axisMode) value "static"
    1806     bind $inner.mode <<Value>> [itcl::code $this AdjustSetting axisMode]
     1720    $itk_component(axisMode) value $_settings(-axismode)
     1721    bind $inner.mode <<Value>> [itcl::code $this AdjustSetting -axismode]
    18071722
    18081723    blt::table $inner \
    1809         0,0 $inner.visible -anchor w -cspan 2 \
    1810         1,0 $inner.labels  -anchor w -cspan 2 \
    1811         2,0 $inner.gridx   -anchor w -cspan 2 \
    1812         3,0 $inner.gridy   -anchor w -cspan 2 \
    1813         4,0 $inner.gridz   -anchor w -cspan 2 \
    1814         5,0 $inner.mode_l  -anchor w -cspan 2 -padx { 2 0 } \
    1815         6,0 $inner.mode    -fill x   -cspan 2
     1724        0,0 $inner.visible    -anchor w -cspan 4 \
     1725        1,0 $inner.labels     -anchor w -cspan 4 \
     1726        2,0 $inner.minorticks -anchor w -cspan 4 \
     1727        4,0 $inner.grid_l     -anchor w \
     1728        4,1 $inner.xgrid      -anchor w \
     1729        4,2 $inner.ygrid      -anchor w \
     1730        4,3 $inner.zgrid      -anchor w \
     1731        5,0 $inner.mode_l     -anchor w -padx { 2 0 } \
     1732        5,1 $inner.mode       -fill x   -cspan 3
    18161733
    18171734    blt::table configure $inner r* c* -resize none
    1818     blt::table configure $inner r7 c1 -resize expand
    1819 }
    1820 
     1735    blt::table configure $inner r7 c6 -resize expand
     1736    blt::table configure $inner r3 -height 0.125i
     1737}
    18211738
    18221739itcl::body Rappture::VtkGlyphViewer::BuildCameraTab {} {
     
    18801797    checkbutton $inner.visible \
    18811798        -text "Cutplanes" \
    1882         -variable [itcl::scope _settings(cutplaneVisible)] \
    1883         -command [itcl::code $this AdjustSetting cutplaneVisible] \
     1799        -variable [itcl::scope _settings(-cutplanevisible)] \
     1800        -command [itcl::code $this AdjustSetting -cutplanevisible] \
    18841801        -font "Arial 9"
    18851802
    18861803    checkbutton $inner.wireframe \
    18871804        -text "Wireframe" \
    1888         -variable [itcl::scope _settings(cutplaneWireframe)] \
    1889         -command [itcl::code $this AdjustSetting cutplaneWireframe] \
     1805        -variable [itcl::scope _settings(-cutplanewireframe)] \
     1806        -command [itcl::code $this AdjustSetting -cutplanewireframe] \
    18901807        -font "Arial 9"
    18911808
    18921809    checkbutton $inner.lighting \
    18931810        -text "Enable Lighting" \
    1894         -variable [itcl::scope _settings(cutplaneLighting)] \
    1895         -command [itcl::code $this AdjustSetting cutplaneLighting] \
     1811        -variable [itcl::scope _settings(-cutplanelighting)] \
     1812        -command [itcl::code $this AdjustSetting -cutplanelighting] \
    18961813        -font "Arial 9"
    18971814
    18981815    checkbutton $inner.edges \
    18991816        -text "Edges" \
    1900         -variable [itcl::scope _settings(cutplaneEdges)] \
    1901         -command [itcl::code $this AdjustSetting cutplaneEdges] \
     1817        -variable [itcl::scope _settings(-cutplaneedges)] \
     1818        -command [itcl::code $this AdjustSetting -cutplaneedges] \
    19021819        -font "Arial 9"
    19031820
    19041821    checkbutton $inner.preinterp \
    19051822        -text "Interpolate Scalars" \
    1906         -variable [itcl::scope _settings(cutplanePreinterp)] \
    1907         -command [itcl::code $this AdjustSetting cutplanePreinterp] \
     1823        -variable [itcl::scope _settings(-cutplanepreinterp)] \
     1824        -command [itcl::code $this AdjustSetting -cutplanepreinterp] \
    19081825        -font "Arial 9"
    19091826
    19101827    label $inner.opacity_l -text "Opacity" -font "Arial 9"
    19111828    ::scale $inner.opacity -from 0 -to 100 -orient horizontal \
    1912         -variable [itcl::scope _settings(cutplaneOpacity)] \
     1829        -variable [itcl::scope _settings(-cutplaneopacity)] \
    19131830        -width 10 \
    19141831        -showvalue off \
    1915         -command [itcl::code $this AdjustSetting cutplaneOpacity]
    1916     $inner.opacity set $_settings(cutplaneOpacity)
     1832        -command [itcl::code $this AdjustSetting -cutplaneopacity]
     1833    $inner.opacity set $_settings(-cutplaneopacity)
    19171834
    19181835    # X-value slicer...
     
    19211838            -onimage [Rappture::icon x-cutplane-red] \
    19221839            -offimage [Rappture::icon x-cutplane-red] \
    1923             -command [itcl::code $this AdjustSetting cutplaneXVisible] \
    1924             -variable [itcl::scope _settings(cutplaneXVisible)] \
     1840            -command [itcl::code $this AdjustSetting -cutplanexvisible] \
     1841            -variable [itcl::scope _settings(-cutplanexvisible)] \
    19251842    }
    19261843    Rappture::Tooltip::for $itk_component(xbutton) \
     
    19321849            -borderwidth 1 -highlightthickness 0 \
    19331850            -command [itcl::code $this EventuallySetCutplane x] \
    1934             -variable [itcl::scope _settings(cutplaneXPosition)] \
    1935             -foreground red2 -font "Arial 9 bold"
     1851            -variable [itcl::scope _settings(-cutplanexposition)] \
     1852            -foreground red2 -font "Arial 9 bold"
    19361853    } {
    19371854        usual
     
    19491866            -onimage [Rappture::icon y-cutplane-green] \
    19501867            -offimage [Rappture::icon y-cutplane-green] \
    1951             -command [itcl::code $this AdjustSetting cutplaneYVisible] \
    1952             -variable [itcl::scope _settings(cutplaneYVisible)] \
     1868            -command [itcl::code $this AdjustSetting -cutplaneyvisible] \
     1869            -variable [itcl::scope _settings(-cutplaneyvisible)] \
    19531870    }
    19541871    Rappture::Tooltip::for $itk_component(ybutton) \
     
    19611878            -borderwidth 1 -highlightthickness 0 \
    19621879            -command [itcl::code $this EventuallySetCutplane y] \
    1963             -variable [itcl::scope _settings(cutplaneYPosition)] \
    1964             -foreground green3 -font "Arial 9 bold"
     1880            -variable [itcl::scope _settings(-cutplaneyposition)] \
     1881            -foreground green3 -font "Arial 9 bold"
    19651882    } {
    19661883        usual
     
    19781895            -onimage [Rappture::icon z-cutplane-blue] \
    19791896            -offimage [Rappture::icon z-cutplane-blue] \
    1980             -command [itcl::code $this AdjustSetting cutplaneZVisible] \
    1981             -variable [itcl::scope _settings(cutplaneZVisible)] \
     1897            -command [itcl::code $this AdjustSetting -cutplanezvisible] \
     1898            -variable [itcl::scope _settings(-cutplanezvisible)] \
    19821899    } {
    1983         usual
    1984         ignore -foreground
     1900        usual
     1901        ignore -foreground
    19851902    }
    19861903    Rappture::Tooltip::for $itk_component(zbutton) \
     
    19931910            -borderwidth 1 -highlightthickness 0 \
    19941911            -command [itcl::code $this EventuallySetCutplane z] \
    1995             -variable [itcl::scope _settings(cutplaneZPosition)] \
    1996             -foreground blue3 -font "Arial 9 bold"
     1912            -variable [itcl::scope _settings(-cutplanezposition)] \
     1913            -foreground blue3 -font "Arial 9 bold"
    19971914    } {
    19981915        usual
     
    20051922
    20061923    blt::table $inner \
    2007         0,0 $inner.visible              -anchor w -pady 2 -cspan 3 \
    2008         1,0 $inner.lighting             -anchor w -pady 2 -cspan 3 \
    2009         2,0 $inner.wireframe            -anchor w -pady 2 -cspan 3 \
    2010         3,0 $inner.edges                -anchor w -pady 2 -cspan 3 \
    2011         4,0 $inner.preinterp            -anchor w -pady 2 -cspan 3 \
    2012         5,0 $inner.opacity_l            -anchor w -pady 2 -cspan 1 \
    2013         5,1 $inner.opacity              -fill x   -pady 2 -cspan 3 \
    2014         6,0 $inner.xbutton              -anchor w -padx 2 -pady 2 \
    2015         7,0 $inner.ybutton              -anchor w -padx 2 -pady 2 \
    2016         8,0 $inner.zbutton              -anchor w -padx 2 -pady 2 \
    2017         6,1 $inner.xval                 -fill y -rspan 4 \
    2018         6,2 $inner.yval                 -fill y -rspan 4 \
    2019         6,3 $inner.zval                 -fill y -rspan 4 \
    2020 
     1924        0,0 $inner.visible   -anchor w -pady 2 -cspan 3 \
     1925        1,0 $inner.lighting  -anchor w -pady 2 -cspan 3 \
     1926        2,0 $inner.wireframe -anchor w -pady 2 -cspan 3 \
     1927        3,0 $inner.edges     -anchor w -pady 2 -cspan 3 \
     1928        4,0 $inner.preinterp -anchor w -pady 2 -cspan 3 \
     1929        5,0 $inner.opacity_l -anchor w -pady 2 -cspan 1 \
     1930        5,1 $inner.opacity   -fill x   -pady 2 -cspan 3 \
     1931        6,0 $inner.xbutton   -anchor w -padx 2 -pady 2 \
     1932        7,0 $inner.ybutton   -anchor w -padx 2 -pady 2 \
     1933        8,0 $inner.zbutton   -anchor w -padx 2 -pady 2 \
     1934        6,1 $inner.xval      -fill y -rspan 4 \
     1935        6,2 $inner.yval      -fill y -rspan 4 \
     1936        6,3 $inner.zval      -fill y -rspan 4 \
    20211937
    20221938    blt::table configure $inner r* c* -resize none
    20231939    blt::table configure $inner r9 c4 -resize expand
    20241940}
    2025 
    2026 
    20271941
    20281942#
     
    21332047    set tag $dataobj-$comp
    21342048    array set style {
    2135         -color \#FFFFFF
    2136         -colormap BCGYR
    2137         -colorMode vmag
     2049        -color BCGYR
    21382050        -edgecolor black
    21392051        -edges 0
     
    21472059        -ptsize 1.0
    21482060        -quality 1
    2149         -scaleMode vmag
    2150         -shape arrow
     2061        -scaleMode "vmag"
     2062        -shape "arrow"
    21512063        -wireframe 0
    21522064    }
    2153     set $style(-color) $itk_option(-plotforeground)
    21542065    set numComponents [$dataobj numComponents $comp]
    21552066    if {$numComponents == 3} {
     
    21572068        set style(-orientGlyphs) 1
    21582069        set style(-scaleMode) "vmag"
    2159         set style(-colorMode) "vmag"
    21602070    } else {
    21612071        set style(-shape) "sphere"
    21622072        set style(-orientGlyphs) 0
    21632073        set style(-scaleMode) "scalar"
    2164         set style(-colorMode) "scalar"
    21652074    }
    21662075    array set style [$dataobj style $comp]
     
    21812090    # the code to handle aberrant cases.
    21822091
    2183     if { $_changed(glyphOpacity) } {
    2184         set style(-opacity) $_settings(glyphOpacity)
    2185     }
    2186     if { $_changed(colormap) } {
    2187         set style(-colormap) $_settings(colormap)
     2092    if { $_changed(-glyphopacity) } {
     2093        set style(-opacity) [expr $_settings(-glyphopacity) * 0.01]
     2094    }
     2095    if { $_changed(-colormap) } {
     2096        set style(-color) $_settings(-colormap)
    21882097    }
    21892098    if { $_currentColormap == "" } {
    2190         $itk_component(colormap) value $style(-colormap)
    2191     }
    2192     set _currentOpacity $style(-opacity)
     2099        $itk_component(colormap) value $style(-color)
     2100    }
     2101
     2102    SendCmd "outline add $tag"
     2103    SendCmd "outline color [Color2RGB $itk_option(-plotforeground)] $tag"
     2104    SendCmd "outline visible $style(-outline) $tag"
     2105    set _settings(-glyphoutline) $style(-outline)
     2106
    21932107    SendCmd "glyphs add $style(-shape) $tag"
    2194     set _settings(glyphShape) $style(-shape)
    2195     $itk_component(gshape) value $style(-shape)
    21962108    SendCmd "glyphs edges $style(-edges) $tag"
     2109    set _settings(-glyphedges) $style(-edges)
     2110
    21972111    # normscale=1 and gscale=1 are defaults
    21982112    if {$style(-normscale) != 1} {
     
    22022116        SendCmd "glyphs gscale $style(-gscale) $tag"
    22032117    }
    2204     set _settings(glyphNormscale) $style(-normscale)
    2205     set _settings(glyphScale) $style(-gscale)
    2206     SendCmd "outline add $tag"
    2207     SendCmd "outline color [Color2RGB $style(-color)] $tag"
    2208     SendCmd "outline visible $style(-outline) $tag"
    2209     set _settings(glyphOutline) $style(-outline)
    2210     set _settings(glyphEdges) $style(-edges)
    2211     if {$style(-colorMode) == "constant" || $style(-colormap) == "none"} {
    2212         SendCmd "glyphs colormode constant {} $tag"
    2213         set _settings(colormapVisible) 0
    2214         set _settings(colormap) "none"
    2215     } else {
    2216         SendCmd "glyphs colormode $style(-colorMode) $_curFldName $tag"
    2217         set _settings(colormapVisible) 1
    2218         set _settings(colormap) $style(-colormap)
    2219         SetCurrentColormap $style(-colormap)
    2220     }
    2221     $itk_component(colormap) value $_settings(colormap)
    2222     set _colorMode $style(-colorMode)
     2118
    22232119    # constant color only used if colormode set to constant
    2224     SendCmd "glyphs color [Color2RGB $style(-color)] $tag"
     2120    SendCmd "glyphs color [Color2RGB $itk_option(-plotforeground)] $tag"
    22252121    # Omitting field name for gorient and smode commands
    22262122    # defaults to active scalars or vectors depending on mode
    22272123    SendCmd "glyphs gorient $style(-orientGlyphs) {} $tag"
    22282124    SendCmd "glyphs smode $style(-scaleMode) {} $tag"
    2229     set _settings(glyphScaleMode) $style(-scaleMode)
    2230     $itk_component(scaleMode) value "[$itk_component(scaleMode) label $style(-scaleMode)]"
    22312125    SendCmd "glyphs quality $style(-quality) $tag"
    22322126    SendCmd "glyphs lighting $style(-lighting) $tag"
    2233     set _settings(glyphLighting) $style(-lighting)
     2127    set _settings(-glyphlighting) $style(-lighting)
    22342128    SendCmd "glyphs linecolor [Color2RGB $style(-edgecolor)] $tag"
    22352129    SendCmd "glyphs linewidth $style(-linewidth) $tag"
    22362130    SendCmd "glyphs ptsize $style(-ptsize) $tag"
    2237     SendCmd "glyphs opacity $_currentOpacity $tag"
    2238     set _settings(glyphOpacity) $style(-opacity)
     2131    SendCmd "glyphs opacity $style(-opacity) $tag"
     2132    set _settings(-glyphopacity) [expr $style(-opacity) * 100.0]
     2133    SetCurrentColormap $style(-color)
    22392134    SendCmd "glyphs wireframe $style(-wireframe) $tag"
    2240     set _settings(glyphWireframe) $style(-wireframe)
    2241     set _settings(glyphOpacity) [expr $style(-opacity) * 100.0]
     2135    set _settings(-glyphwireframe) $style(-wireframe)
    22422136}
    22432137
     
    22932187
    22942188    if { [string match "component*" $fname] } {
    2295         set title ""
     2189        set title ""
    22962190    } else {
    2297         if { [info exists _fields($fname)] } {
    2298             foreach { title units } $_fields($fname) break
    2299             if { $units != "" } {
    2300                 set title [format "%s (%s)" $title $units]
    2301             }
    2302         } else {
    2303             set title $fname
    2304         }
     2191        if { [info exists _fields($fname)] } {
     2192            foreach { title units } $_fields($fname) break
     2193            if { $units != "" } {
     2194                set title [format "%s (%s)" $title $units]
     2195            }
     2196        } else {
     2197            set title $fname
     2198        }
    23052199    }
    23062200    # If there's a legend title, increase the offset by the line height.
     
    23342228}
    23352229
    2336 
    23372230# ----------------------------------------------------------------------
    23382231# USAGE: Slice move x|y|z <newval>
     
    23682261# ReceiveLegend --
    23692262#
    2370 #       Invoked automatically whenever the "legend" command comes in from
    2371 #       the rendering server.  Indicates that binary image data with the
    2372 #       specified <size> will follow.
     2263#    Invoked automatically whenever the "legend" command comes in from
     2264#    the rendering server.  Indicates that binary image data with the
     2265#    specified <size> will follow.
    23732266#
    23742267itcl::body Rappture::VtkGlyphViewer::ReceiveLegend { colormap title min max size } {
     
    23842277        #puts stderr "read $size bytes for [image width $_image(legend)]x[image height $_image(legend)] legend>"
    23852278        if { [catch {DrawLegend} errs] != 0 } {
    2386             global errorInfo
    2387             puts stderr "errs=$errs errorInfo=$errorInfo"
     2279            global errorInfo
     2280            puts stderr "errs=$errs errorInfo=$errorInfo"
    23882281        }
    23892282    }
     
    23932286# DrawLegend --
    23942287#
    2395 #       Draws the legend in the own canvas on the right side of the plot area.
     2288#    Draws the legend in the own canvas on the right side of the plot area.
    23962289#
    23972290itcl::body Rappture::VtkGlyphViewer::DrawLegend {} {
     
    24042297   
    24052298    if { [string match "component*" $fname] } {
    2406         set title ""
     2299        set title ""
    24072300    } else {
    2408         if { [info exists _fields($fname)] } {
    2409             foreach { title units } $_fields($fname) break
    2410             if { $units != "" } {
    2411                 set title [format "%s (%s)" $title $units]
    2412             }
    2413         } else {
    2414             set title $fname
    2415         }
     2301        if { [info exists _fields($fname)] } {
     2302            foreach { title units } $_fields($fname) break
     2303            if { $units != "" } {
     2304                set title [format "%s (%s)" $title $units]
     2305            }
     2306        } else {
     2307            set title $fname
     2308        }
    24162309    }
    24172310    set x [expr $w - 2]
    2418     if { !$_settings(legendVisible) } {
    2419         $c delete legend
    2420         return
     2311    if { !$_settings(-legendvisible) } {
     2312        $c delete legend
     2313        return
    24212314    }
    24222315    if { [$c find withtag "legend"] == "" } {
    2423         set y 2
    2424         # If there's a legend title, create a text item for the title.
     2316        set y 2
     2317        # If there's a legend title, create a text item for the title.
    24252318        $c create text $x $y \
    2426             -anchor ne \
    2427             -fill $itk_option(-plotforeground) -tags "title legend" \
    2428             -font $font
     2319            -anchor ne \
     2320            -fill $itk_option(-plotforeground) -tags "title legend" \
     2321            -font $font
    24292322        if { $title != "" } {
    24302323            incr y $lineht
    24312324        }
    2432         $c create text $x $y \
    2433             -anchor ne \
    2434             -fill $itk_option(-plotforeground) -tags "vmax legend" \
    2435             -font $font
    2436         incr y $lineht
    2437         $c create image $x $y \
    2438             -anchor ne \
    2439             -image $_image(legend) -tags "colormap legend"
    2440         $c create rectangle $x $y 1 1 \
    2441             -fill "" -outline "" -tags "sensor legend"
    2442         $c create text $x [expr {$h-2}] \
    2443             -anchor se \
    2444             -fill $itk_option(-plotforeground) -tags "vmin legend" \
    2445             -font $font
    2446         $c bind sensor <Enter> [itcl::code $this EnterLegend %x %y]
    2447         $c bind sensor <Leave> [itcl::code $this LeaveLegend]
    2448         $c bind sensor <Motion> [itcl::code $this MotionLegend %x %y]
     2325        $c create text $x $y \
     2326            -anchor ne \
     2327            -fill $itk_option(-plotforeground) -tags "vmax legend" \
     2328            -font $font
     2329        incr y $lineht
     2330        $c create image $x $y \
     2331            -anchor ne \
     2332            -image $_image(legend) -tags "colormap legend"
     2333        $c create rectangle $x $y 1 1 \
     2334            -fill "" -outline "" -tags "sensor legend"
     2335        $c create text $x [expr {$h-2}] \
     2336            -anchor se \
     2337            -fill $itk_option(-plotforeground) -tags "vmin legend" \
     2338            -font $font
     2339        $c bind sensor <Enter> [itcl::code $this EnterLegend %x %y]
     2340        $c bind sensor <Leave> [itcl::code $this LeaveLegend]
     2341        $c bind sensor <Motion> [itcl::code $this MotionLegend %x %y]
    24492342    }
    24502343    set x2 $x
     
    24602353    if { [info exists _limits($_curFldName)] } {
    24612354        foreach { vmin vmax } $_limits($_curFldName) break
    2462         $c itemconfigure vmin -text [format %g $vmin]
    2463         $c itemconfigure vmax -text [format %g $vmax]
     2355        $c itemconfigure vmin -text [format %g $vmin]
     2356        $c itemconfigure vmax -text [format %g $vmax]
    24642357    }
    24652358    set y 2
     
    24672360    if { $title != "" } {
    24682361        $c itemconfigure title -text $title
    2469         $c coords title $x $y
    2470         incr y $lineht
     2362        $c coords title $x $y
     2363        incr y $lineht
    24712364        $c raise title
    24722365    }
     
    25102403        invoke {
    25112404            $itk_component(field) value $_curFldLabel
    2512             AdjustSetting field
     2405            AdjustSetting -field
    25132406        }
    25142407        default {
     
    25342427# BuildColormap --
    25352428#
    2536 #       Build the designated colormap on the server.
     2429#    Build the designated colormap on the server.
    25372430#
    25382431itcl::body Rappture::VtkGlyphViewer::BuildColormap { name } {
     
    25652458    set _view(zoom) 1.0
    25662459}
    2567 
  • branches/r9/gui/scripts/vtkheightmapviewer.tcl

    r4344 r4919  
    123123    private variable _currentColormap ""
    124124    private variable _currentNumIsolines -1
    125     private variable _currentOpacity ""
    126125
    127126    private variable _maxScale 100;     # This is the # of times the x-axis
     
    217216
    218217    array set _settings {
    219         axisFlymode             "static"
    220         axisMinorTicks          1
    221         stretchToFit            0
    222         axisLabels              1
    223         axisVisible             1
    224         axisXGrid               0
    225         axisYGrid               0
    226         axisZGrid               0
    227         colormapVisible         1
    228         colormapDiscrete        0
    229         edges                   0
    230         field                   "Default"
    231         heightmapScale          50
    232         isHeightmap             0
    233         isolineColor            black
    234         isolinesVisible         1
    235         legendVisible           1
    236         lighting                1
    237         saveLighting            1
    238         numIsolines             10
    239         opacity                 100
    240         outline                 0
    241         wireframe               0
    242         saveOpacity             100
    243         saveOutline             0
     218        -axisflymode            "static"
     219        -axislabels             1
     220        -axisminorticks         1
     221        -axisvisible            1
     222        -colormap               BCGYR
     223        -colormapdiscrete       0
     224        -colormapvisible        1
     225        -edges                  0
     226        -field                  "Default"
     227        -heightmapscale         50
     228        -isheightmap            0
     229        -isolinecolor           black
     230        -isolinesvisible        1
     231        -legendvisible          1
     232        -lighting               1
     233        -numisolines            10
     234        -opacity                100
     235        -outline                0
     236        -savelighting           1
     237        -saveopacity            100
     238        -saveoutline            0
     239        -stretchtofit           0
     240        -wireframe              0
     241        -xgrid                  0
     242        -ygrid                  0
     243        -zgrid                  0
    244244    }
    245245    array set _changed {
    246         opacity                 0
    247         colormap                0
    248         numIsolines             0
     246        -colormap               0
     247        -numisolines            0
     248        -opacity                0
    249249    }
    250250    itk_component add view {
     
    325325            -onimage [Rappture::icon surface] \
    326326            -offimage [Rappture::icon surface] \
    327             -variable [itcl::scope _settings(isHeightmap)] \
    328             -command [itcl::code $this AdjustSetting isHeightmap] \
     327            -variable [itcl::scope _settings(-isheightmap)] \
     328            -command [itcl::code $this AdjustSetting -isheightmap] \
    329329    }
    330330    Rappture::Tooltip::for $itk_component(mode) \
     
    336336            -onimage [Rappture::icon stretchtofit] \
    337337            -offimage [Rappture::icon stretchtofit] \
    338             -variable [itcl::scope _settings(stretchToFit)] \
    339             -command [itcl::code $this AdjustSetting stretchToFit] \
     338            -variable [itcl::scope _settings(-stretchtofit)] \
     339            -command [itcl::code $this AdjustSetting -stretchtofit] \
    340340    }
    341341    Rappture::Tooltip::for $itk_component(stretchtofit) \
     
    666666    }
    667667    if { [array size found] > 1 } {
    668         set _settings(stretchToFit) 1
     668        set _settings(-stretchtofit) 1
    669669    } else {
    670670        # Check if the range of the x and y axes requires that we stretch
     
    675675        if { (($xmax - $xmin) > (($ymax -$ymin) * $_maxScale)) ||
    676676             ((($xmax - $xmin) * $_maxScale) < ($ymax -$ymin)) } {
    677             set _settings(stretchToFit) 1
     677            set _settings(-stretchtofit) 1
    678678        }
    679679    }
     
    767767                set session $env(SESSION)
    768768            }
     769            lappend info "version" "$Rappture::version"
     770            lappend info "build" "$Rappture::build"
     771            lappend info "svnurl" "$Rappture::svnurl"
     772            lappend info "installdir" "$Rappture::installdir"
    769773            lappend info "hub" [exec hostname]
    770774            lappend info "client" "vtkheightmapviewer"
     
    924928        $_arcball resize $w $h
    925929        DoResize
    926         if { $_settings(stretchToFit) } {
    927             AdjustSetting stretchToFit
     930        if { $_settings(-stretchtofit) } {
     931            AdjustSetting -stretchtofit
    928932        }
    929933    }
     
    932936        # Reset the camera and other view parameters
    933937        #
    934         InitSettings isHeightmap background
    935 
    936         # Let's see how this goes.  I think it's preferable to overloading the
    937         # axis title with the exponent.
    938         SendCmd "axis exp 0 0 0 1"
     938        InitSettings -isheightmap -background
     939
     940        # Setting a custom exponent and label format for axes is causing
     941        # a problem with rounding.  Near zero ticks aren't rounded by
     942        # the %g format.  The VTK CubeAxes seem to currently work best
     943        # when allowed to automatically set the exponent and precision
     944        # based on the axis ranges.  This does tend to result in less
     945        # visual clutter, so I think it is best to use the automatic
     946        # settings by default.  We can test more fine-grained
     947        # controls on the axis settings tab if necessary.
     948        # -Leif
     949        #SendCmd "axis exp 0 0 0 1"
    939950
    940951        SendCmd "axis lrot z 90"
    941952        set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    942953        $_arcball quaternion $q
    943         if {$_settings(isHeightmap) } {
     954        if {$_settings(-isheightmap) } {
    944955            if { $_view(ortho)} {
    945956                SendCmd "camera mode ortho"
     
    10331044        $itk_component(field) value $_curFldLabel
    10341045    }
    1035     InitSettings stretchToFit outline
     1046    InitSettings -stretchtofit -outline
    10361047
    10371048    if { $_reset } {
     
    10771088        set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    10781089        $_arcball quaternion $q
    1079         if {$_settings(isHeightmap) } {
     1090        if {$_settings(-isheightmap) } {
    10801091            if { $_view(ortho)} {
    10811092                SendCmd "camera mode ortho"
     
    10871098        }
    10881099        PanCamera
    1089         InitSettings axisXGrid axisYGrid axisZGrid \
    1090             axisVisible axisLabels heightmapScale field isHeightmap \
    1091             numIsolines
     1100        InitSettings -xgrid -ygrid -zgrid \
     1101            -axisvisible -axislabels -heightmapscale -field -isheightmap \
     1102            -numisolines
    10921103        if { [array size _fields] < 2 } {
    1093             blt::table forget $itk_component(field) $itk_component(field_l)
     1104            catch {
     1105                blt::table forget $itk_component(field) $itk_component(field_l)
     1106            }
    10941107        }
    10951108        RequestLegend
     
    11691182    set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    11701183    $_arcball quaternion $q
    1171     if {$_settings(isHeightmap) } {
     1184    if {$_settings(-isheightmap) } {
    11721185        DoRotate
    11731186    }
     
    13301343itcl::body Rappture::VtkHeightmapViewer::InitSettings { args } {
    13311344    foreach spec $args {
    1332         if { [info exists _settings($_first-$spec)] } {
     1345        if { [info exists _settings($_first${spec})] } {
    13331346            # Reset global setting with dataobj specific setting
    1334             set _settings($spec) $_settings($_first-$spec)
     1347            set _settings($spec) $_settings($_first${spec})
    13351348        }
    13361349        AdjustSetting $spec
     
    13501363    }
    13511364    switch -- $what {
    1352         "axisFlymode" {
     1365        "-axisflymode" {
    13531366            set mode [$itk_component(axisflymode) value]
    13541367            set mode [$itk_component(axisflymode) translate $mode]
     
    13561369            SendCmd "axis flymode $mode"
    13571370        }
    1358         "axisLabels" {
     1371        "-axislabels" {
    13591372            set bool $_settings($what)
    13601373            SendCmd "axis labels all $bool"
    13611374        }
    1362         "axisMinorTicks" {
     1375        "-axisminorticks" {
    13631376            set bool $_settings($what)
    1364             foreach axis { x y z } {
    1365                 SendCmd "axis minticks ${axis} $bool"
    1366             }
    1367         }
    1368         "axisVisible" {
     1377            SendCmd "axis minticks all $bool"
     1378        }
     1379        "-axisvisible" {
    13691380            set bool $_settings($what)
    13701381            SendCmd "axis visible all $bool"
    13711382        }
    1372         "axisXGrid" - "axisYGrid" - "axisZGrid" {
    1373             set axis [string tolower [string range $what 4 4]]
     1383        "-xgrid" - "-ygrid" - "-zgrid" {
     1384            set axis [string tolower [string range $what 1 1]]
    13741385            set bool $_settings($what)
    13751386            SendCmd "axis grid $axis $bool"
    13761387        }
    1377         "background" {
     1388        "-background" {
    13781389            set bg [$itk_component(background) value]
    13791390            array set fgcolors {
     
    13901401            DrawLegend
    13911402        }
    1392         "colormap" {
     1403        "-colormap" {
    13931404            set _changed($what) 1
    13941405            StartBufferingCommands
     
    13961407            set _settings($what) $color
    13971408            if { $color == "none" } {
    1398                 if { $_settings(colormapVisible) } {
     1409                if { $_settings(-colormapvisible) } {
    13991410                    SendCmd "heightmap surface 0"
    1400                     set _settings(colormapVisible) 0
     1411                    set _settings(-colormapvisible) 0
    14011412                }
    14021413            } else {
    1403                 if { !$_settings(colormapVisible) } {
     1414        &nbs