Ignore:
Timestamp:
Mar 2, 2015, 7:37:46 PM (9 years ago)
Author:
dkearney
Message:

Merge sync from trunk to uvv branch

Location:
branches/uiuc_vtk_viewers
Files:
22 edited
2 copied

Legend:

Unmodified
Added
Removed
  • branches/uiuc_vtk_viewers

  • branches/uiuc_vtk_viewers/gui/pkgIndex.tcl.in

    r2117 r5053  
    1 
     1# HACK: The Img library needs to be loaded before RapptureGUI
     2# to avoid conflicts with libjpeg, libtiff, etc.
    23package ifneeded RapptureGUI @PACKAGE_VERSION@ [format {
     4    package require Img
    35    set dir [file normalize "%s"]
    46    set version @PACKAGE_VERSION@
     
    1214    package provide RapptureGUI $version
    1315} $dir]
    14 
  • branches/uiuc_vtk_viewers/gui/scripts/analyzer.tcl

    r4519 r5053  
    315315
    316316    itk_component add results {
    317         Rappture::Panes $w.pane -sashwidth 1 -sashrelief solid -sashpadding {4 0}
     317        Rappture::Panes $w.pane \
     318            -sashwidth 2 -sashrelief solid -sashpadding {2 0}
     319    } {
     320        usual
     321        ignore -sashwidth -sashrelief -sashpadding
    318322    }
    319323    pack $itk_component(results) -expand yes -fill both
  • branches/uiuc_vtk_viewers/gui/scripts/field.tcl

    r4992 r5053  
    1 # -*- mode: tcl; indent-tabs-mode: nil -*- 
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    22# ----------------------------------------------------------------------
    33#  COMPONENT: field - extracts data from an XML description of a field
     
    2525#       unirect2d       (deprecated)
    2626#       cloud           (x,y point coordinates) (deprecated)
    27 #       mesh 
     27#       mesh
    2828# 3D Datasets
    29 #       vtk 
     29#       vtk
    3030#       unirect3d       (deprecated)
    3131#       cloud           (x,y,z coordinates) (deprecated)
    32 #       mesh 
     32#       mesh
    3333#       dx              (FIXME: make dx-to-vtk converter work)
    3434#       ucd avs
     
    4646# With <views>, can specify which viewer for specific datasets.  So it's OK
    4747# for the same dataset to be viewed in more than one way.
    48 #  o Any 2D dataset can be viewed as a contour/heightmap. 
     48#  o Any 2D dataset can be viewed as a contour/heightmap.
    4949#  o Any 3D dataset can be viewed as a isosurface.
    50 #  o Any 2D dataset with vector data can be streamlines or flow. 
     50#  o Any 2D dataset with vector data can be streamlines or flow.
    5151#  o Any 3D uniform rectilinear dataset can be viewed as a volume.
    5252#  o Any 3D dataset with vector data can be streamlines or flow.
     
    5959package require BLT
    6060
    61 namespace eval Rappture { 
    62     # forward declaration 
     61namespace eval Rappture {
     62    # forward declaration
    6363}
    6464
     
    6868    private variable _limits;           # maps axis name => {z0 z1} limits
    6969    private variable _field ""
    70     private variable _comp2fldName ;    # cname => field names.
    71     private variable _comp2type ;       # cname => type (e.g. "vectors")
    72     private variable _comp2size ;       # cname => # of components in element
    73     private variable _comp2assoc;       # cname => association (e.g. pointdata)
     70    private variable _comp2fldName ;    # cname => field names.
     71    private variable _comp2type ;       # cname => type (e.g. "vectors")
     72    private variable _comp2size ;       # cname => # of components in element
     73    private variable _comp2assoc;       # cname => association (e.g. pointdata)
    7474    private variable _fld2Components;   # field name => number of components
    7575    private variable _fld2Label;        # field name => label
    7676    private variable _fld2Units;        # field name => units
    77     private variable _hints 
     77    private variable _hints
    7878    private variable _viewer "";        # Hints which viewer to use
    79     private variable _xv "";            # For 1D meshes only.  Holds the points
    8079    private variable _isValid 0;        # Indicates if the field contains
    8180                                        # valid data.
     
    8382    private variable _alwaysConvertDX 0;
    8483
    85     constructor {xmlobj path} { 
    86         # defined below
    87     }
    88     destructor { 
    89         # defined below
     84    constructor {xmlobj path} {
     85        # defined below
     86    }
     87    destructor {
     88        # defined below
    9089    }
    9190    public method blob { cname }
     
    127126    }
    128127    public method viewer {} {
    129         return $_viewer
     128        return $_viewer
    130129    }
    131130    protected method Build {}
    132131    protected method _getValue {expr}
    133132
    134     private variable _path "";          # Path of this object in the XML 
     133    private variable _path "";          # Path of this object in the XML
    135134    private variable _units ""   ;      # system of units for this field
    136135    private variable _zmax 0     ;# length of the device
     
    144143    private variable _comp2style ;# maps component name => style settings
    145144    private variable _comp2cntls ;# maps component name => x,y control points
    146     private variable _comp2extents
    147     private variable _comp2limits;      #  Array of limits per component
    148     private variable _type ""
    149     private variable _comp2flowhints
    150     private variable _comp2mesh
     145    private variable _comp2extents
     146    private variable _comp2limits;        #  Array of limits per component
     147    private variable _type ""
     148    private variable _comp2flowhints
     149    private variable _comp2mesh  ;# list of: mesh object, BLT vector of values
     150    private variable _values ""  ;# Only used for unirect2d - list of values
    151151    private common _counter 0    ;# counter for unique vector names
    152152
    153     private method AvsToVtk { cname contents } 
    154     private method DicomToVtk { cname contents } 
    155     private method BuildPointsOnMesh { cname } 
    156     protected method GetAssociation { cname } 
    157     protected method GetTypeAndSize { cname } 
    158     protected method ReadVtkDataSet { cname contents } 
    159     private method InitHints {} 
    160 
    161     private method VerifyVtkDataSet { contents } 
     153    private method AvsToVtk { cname contents }
     154    private method DicomToVtk { cname contents }
     155    private method BuildPointsOnMesh { cname }
     156    protected method GetAssociation { cname }
     157    protected method GetTypeAndSize { cname }
     158    protected method ReadVtkDataSet { cname contents }
     159    private method InitHints {}
     160
     161    private method VerifyVtkDataSet { contents }
    162162    private method VectorLimits { vector vectorsize {comp -1} }
    163     private variable _values ""
    164163}
    165164
     
    229228    }
    230229    foreach name [array names _comp2mesh] {
    231         # Data is in the form of a mesh and a vector.
    232         foreach { mesh vector } $_comp2mesh($name) break
    233         # Release the mesh (may be shared)
     230        # Data is in the form of a mesh and a vector.
     231        foreach { mesh vector } $_comp2mesh($name) break
     232        # Release the mesh (may be shared)
    234233        set class [$mesh info class]
    235234        ${class}::release $mesh
    236         # Destroy the vector
     235        # Destroy the vector
    237236        blt::vector destroy $vector
    238237    }
     
    285284    # Now handle the tests.
    286285    switch -- $params(what) {
    287         -name { 
     286        -name {
    288287            set rlist $components
    289288        }
    290         -style { 
     289        -style {
    291290            foreach cname $components {
    292291                if { [info exists _comp2style($cname)] } {
    293                     lappend rlist $_comp2style($cname) 
     292                    lappend rlist $_comp2style($cname)
    294293                }
    295294            }
     
    302301# USAGE: mesh ?<name>?
    303302#
    304 # Returns a list {xvec yvec} for the specified field component <name>.
    305 # If the name is not specified, then it returns the vectors for the
    306 # overall field (sum of all components).
     303# For 1D data (curve), returns a BLT vector of x values for the field
     304# component <name>.  Otherwise, this method is unused
    307305# ----------------------------------------------------------------------
    308306itcl::body Rappture::Field::mesh {{cname -overall}} {
     
    313311        return [lindex $_comp2xy($cname) 0]  ;# return xv
    314312    }
    315     if { [info exists _comp2vtk($cname)] } {
    316         # FIXME: extract mesh from VTK file data.
    317         if { $_comp2dims($cname) == "1D" } {
    318             return $_xv
    319         }
     313    if {[info exists _comp2vtk($cname)]} {
     314        # FIXME: extract mesh from VTK file data.
    320315        error "method \"mesh\" is not implemented for VTK file data"
    321316    }
    322317    if {[info exists _comp2dx($cname)]} {
    323         return ""  ;# no mesh -- it's embedded in the blob data
     318        error "method \"mesh\" is not implemented for DX file data"
    324319    }
    325320    if {[info exists _comp2mesh($cname)]} {
    326         return ""  ;# no mesh -- it's embedded in the value data
     321        # FIXME: This only works for cloud
     322        set mesh [lindex $_comp2mesh($cname) 0]
     323        return [$mesh points]
    327324    }
    328325    if {[info exists _comp2unirect2d($cname)]} {
    329         set mobj [lindex $_comp2unirect2d($cname) 0]
    330         return [$mobj mesh]
     326        # FIXME: unirect2d mesh is a list: xMin xMax xNum yMin yMax yNum
     327        return [$_comp2unirect2d($cname) mesh]
    331328    }
    332329    if {[info exists _comp2unirect3d($cname)]} {
    333         set mobj [lindex $_comp2unirect3d($cname) 0]
    334         return [$mobj mesh]
     330        # This returns a list of x,y,z points
     331        return [$_comp2unirect3d($cname) mesh]
    335332    }
    336333    error "can't get field mesh: Unknown component \"$cname\": should be one of [join [lsort [array names _comp2dims]] {, }]"
     
    340337# USAGE: values ?<name>?
    341338#
    342 # Returns a list {xvec yvec} for the specified field component <name>.
    343 # If the name is not specified, then it returns the vectors for the
    344 # overall field (sum of all components).
     339# For 1D data (curve), returns a BLT vector of field values (y coords)
     340# for the field component <name>.  Otherwise, this method is unused
    345341# ----------------------------------------------------------------------
    346342itcl::body Rappture::Field::values {cname} {
     
    351347        return [lindex $_comp2xy($cname) 1]  ;# return yv
    352348    }
    353     # VTK file data
    354349    if { [info exists _comp2vtk($cname)] } {
    355         # FIXME: extract the values from the VTK file data
    356         if { $_comp2dims($cname) == "1D" } {
    357             return $_values
    358         }
    359         error "method \"values\" is not implemented for vtk file data"
    360     }
    361     # Points-on-mesh
     350        # FIXME: extract the values from the VTK file data
     351        error "method \"values\" is not implemented for VTK file data"
     352    }
     353    if {[info exists _comp2dx($cname)]} {
     354        error "method \"values\" is not implemented for DX file data"
     355    }
    362356    if { [info exists _comp2mesh($cname)] } {
    363         set vector [lindex $_comp2mesh($cname) 1]
     357        set vector [lindex $_comp2mesh($cname) 1]
    364358        return [$vector range 0 end]
    365     }
    366     if {[info exists _comp2dx($cname)]} {
    367         error "method \"values\" is not implemented for dx file data"
    368359    }
    369360    if {[info exists _comp2unirect2d($cname)]} {
     
    371362    }
    372363    if {[info exists _comp2unirect3d($cname)]} {
    373         return [$_comp2unirect3d($cname) blob]
    374     }
    375     error "can't get field values. Unknown component \"$cname\": should be [join [lsort [array names _comp2dims]] {, }]"
     364        return [$_comp2unirect3d($cname) values]
     365    }
     366    error "can't get field values. Unknown component \"$cname\": should be one of [join [lsort [array names _comp2dims]] {, }]"
    376367}
    377368
     
    389380    }
    390381    if { [info exists _comp2vtk($cname)] } {
    391         error "blob not implemented for VTK file data"
     382        error "blob not implemented for VTK file data"
    392383    }
    393384    if {[info exists _comp2dx($cname)]} {
     
    408399# USAGE: valueLimits <cname>
    409400#
    410 # Returns an array for the requested component with a list {min max} 
     401# Returns an array for the requested component with a list {min max}
    411402# representing the limits for each axis.
    412403# ----------------------------------------------------------------------
     
    432423            1D {
    433424                switch -- $which {
    434                     x - xlin { 
    435                         set pos 0; set log 0; set axis x
    436                     }
    437                     xlog { 
    438                         set pos 0; set log 1; set axis x
    439                     }
    440                     y - ylin - v - vlin { 
    441                         set pos 1; set log 0; set axis y
    442                     }
    443                     ylog - vlog { 
    444                         set pos 1; set log 1; set axis y
    445                     }
     425                    x - xlin {
     426                        set pos 0; set log 0; set axis x
     427                    }
     428                    xlog {
     429                        set pos 0; set log 1; set axis x
     430                    }
     431                    y - ylin - v - vlin {
     432                        set pos 1; set log 0; set axis y
     433                    }
     434                    ylog - vlog {
     435                        set pos 1; set log 1; set axis y
     436                    }
    446437                    default {
    447438                        error "bad axis \"$which\": should be x, xlin, xlog, y, ylin, ylog, v, vlin, vlog"
     
    480471            default {
    481472                if {[info exists _comp2limits($cname)]} {
    482                     array set limits $_comp2limits($cname)
    483                     switch -- $which {
     473                    array set limits $_comp2limits($cname)
     474                    switch -- $which {
    484475                        x - xlin - xlog {
    485476                            set axis x
    486                             foreach {axisMin axisMax} $limits(x) break
     477                            foreach {axisMin axisMax} $limits(x) break
    487478                        }
    488479                        y - ylin - ylog {
    489480                            set axis y
    490                             foreach {axisMin axisMax} $limits(y) break
     481                            foreach {axisMin axisMax} $limits(y) break
    491482                        }
    492483                        z - zlin - zlog {
    493484                            set axis z
    494                             foreach {axisMin axisMax} $limits(z) break
     485                            foreach {axisMin axisMax} $limits(z) break
    495486                        }
    496487                        v - vlin - vlog {
    497488                            set axis v
    498                             foreach {axisMin axisMax} $limits(v) break
    499                         }
    500                         default {
    501                             if { ![info exists limits($which)] } {
    502                                 error "limits: unknown axis \"$which\""
    503                             }
     489                            foreach {axisMin axisMax} $limits(v) break
     490                        }
     491                        default {
     492                            if { ![info exists limits($which)] } {
     493                                error "limits: unknown axis \"$which\""
     494                            }
    504495                            set axis v
    505                             foreach {axisMin axisMax} $limits($which) break
    506                         }
    507                     }
     496                            foreach {axisMin axisMax} $limits($which) break
     497                        }
     498                    }
    508499                } else {
    509500                    set axisMin 0  ;# HACK ALERT! must be OpenDX data
     
    545536itcl::body Rappture::Field::fieldlimits {} {
    546537    foreach cname [array names _comp2limits] {
    547         array set limits $_comp2limits($cname) 
     538        array set limits $_comp2limits($cname)
    548539        foreach fname [fieldnames $cname] {
    549540            if { ![info exists limits($fname)] } {
     
    571562    return ""
    572563}
    573  
     564
    574565# ----------------------------------------------------------------------
    575566# USAGE: controls get ?<name>?
     
    779770        set type ""
    780771        if { ([$_field element $cname.constant] != "" &&
    781               [$_field element $cname.domain] != "") ||
    782               [$_field element $cname.xy] != "" } {
     772              [$_field element $cname.domain] != "") ||
     773              [$_field element $cname.xy] != "" } {
    783774            set type "1D"
    784775        } elseif { [$_field element $cname.mesh] != "" &&
    785                    [$_field element $cname.values] != ""} {
     776                   [$_field element $cname.values] != ""} {
    786777            set type "points-on-mesh"
    787778        } elseif { [$_field element $cname.vtk] != ""} {
    788             set type "vtk"
    789             set viewer [$_field get "about.view"]
    790             if { $viewer != "" } {
    791                 set _viewer $viewer
    792             }
     779            set type "vtk"
     780            set viewer [$_field get "about.view"]
     781            if { $viewer != "" } {
     782                set _viewer $viewer
     783            }
    793784        } elseif {[$_field element $cname.opendx] != ""} {
    794785            global env
    795786            if { [info exists env(VTKVOLUME)] } {
    796787                set _viewer "vtkvolume"
    797             } 
     788            }
    798789            set type "opendx"
    799790        } elseif {[$_field element $cname.dx] != ""} {
     
    807798        } elseif {[$_field element $cname.dicom] != ""} {
    808799            set type "dicom"
    809         }
     800        }
    810801        set _comp2style($cname) ""
    811802        if { $type == "" } {
     
    817808            set extents [$_field get $cname.extents]
    818809        } else {
    819             set extents 1 
     810            set extents 1
    820811        }
    821812        set _comp2extents($cname) $extents
     
    880871            }
    881872        } elseif {$type == "points-on-mesh"} {
    882             if { ![BuildPointsOnMesh $cname] } {
     873            if { ![BuildPointsOnMesh $cname] } {
    883874                continue;               # Ignore this component
    884875            }
     
    981972        return 0
    982973    }
    983     # Sanity check.  Verify that all components of the field have the same 
     974    # Sanity check.  Verify that all components of the field have the same
    984975    # dimension.
    985976    set dim ""
     
    998989    #        the label and units for each field will be specified there.
    999990    #
    1000     # FIXME: Test that every <field><component> has the same field names, 
     991    # FIXME: Test that every <field><component> has the same field names,
    1001992    #        units, components.
    1002993    #
     
    10701061# isunirect2d  --
    10711062#
    1072 # Returns if the field is a unirect2d object. 
     1063# Returns if the field is a unirect2d object.
    10731064#
    10741065itcl::body Rappture::Field::isunirect2d { } {
     
    10791070# isunirect3d  --
    10801071#
    1081 # Returns if the field is a unirect3d object. 
     1072# Returns if the field is a unirect3d object.
    10821073#
    10831074itcl::body Rappture::Field::isunirect3d { } {
     
    10881079# flowhints  --
    10891080#
    1090 # Returns the hints associated with a flow vector field. 
     1081# Returns the hints associated with a flow vector field.
    10911082#
    10921083itcl::body Rappture::Field::flowhints { cname } {
     
    11001091# style  --
    11011092#
    1102 # Returns the style associated with a component of the field. 
     1093# Returns the style associated with a component of the field.
    11031094#
    11041095itcl::body Rappture::Field::style { cname } {
     
    11371128# extents --
    11381129#
    1139 # Returns if the field is a unirect2d object. 
     1130# Returns if the field is a unirect2d object.
    11401131#
    11411132itcl::body Rappture::Field::extents {{cname -overall}} {
     
    11531144        }
    11541145        return $max
    1155     } 
     1146    }
    11561147    if { $cname == "component0"} {
    11571148        set cname [lindex [components -name] 0]
     
    11701161    set f [open "$tmpfile" "w"]
    11711162    fconfigure $f -translation binary -encoding binary
    1172     puts $f $contents 
     1163    puts $f $contents
    11731164    close $f
    11741165
     
    11871178    set dataAttrs [$dataset GetPointData]
    11881179    if { $dataAttrs == ""} {
    1189         puts stderr "WARNING: No point data found in \"$_path\""
     1180        puts stderr "WARNING: No point data found in \"$_path\""
    11901181        rename $reader ""
    11911182        return 0
     
    12041195    set f [open "$tmpfile" "w"]
    12051196    fconfigure $f -translation binary -encoding binary
    1206     puts $f $contents 
     1197    puts $f $contents
    12071198    close $f
    12081199
     
    12241215    set _dim 0
    12251216    if { $xmax > $xmin } {
    1226         incr _dim
     1217        incr _dim
    12271218    }
    12281219    if { $ymax > $ymin } {
    1229         incr _dim
     1220        incr _dim
    12301221    }
    12311222    if { $zmax > $zmin } {
    1232         incr _dim
     1223        incr _dim
    12331224    }
    12341225    if { $_viewer == "" } {
    1235         if { $_dim == 2 } {
    1236             set _viewer contour
    1237         } else {
    1238             set _viewer isosurface
    1239         }
     1226        if { $_dim == 2 } {
     1227            set _viewer contour
     1228        } else {
     1229            set _viewer isosurface
     1230        }
    12401231    }
    12411232    set _comp2dims($cname) ${_dim}D
     
    12451236        for { set i 0 } { $i < $numPoints } { incr i } {
    12461237            set point [$dataset GetPoint $i]
    1247             $xv append [lindex $point 0] 
     1238            $xv append [lindex $point 0]
    12481239        }
    12491240        set yv [blt::vector create \#auto]
     
    12621253        set numTuples [$array GetNumberOfTuples]
    12631254        for { set i 0 } { $i < $numTuples } { incr i } {
    1264             $yv append [$array GetComponent $i 0] 
     1255            $yv append [$array GetComponent $i 0]
    12651256        }
    12661257        $xv sort $yv
    12671258        set _comp2xy($cname) [list $xv $yv]
    12681259    }
    1269     lappend limits x [list $xmin $xmax] 
    1270     lappend limits y [list $ymin $ymax] 
     1260    lappend limits x [list $xmin $xmax]
     1261    lappend limits y [list $ymin $ymax]
    12711262    lappend limits z [list $zmin $zmax]
    12721263    set dataAttrs [$dataset GetPointData]
    12731264    if { $dataAttrs == ""} {
    1274         puts stderr "WARNING: No point data found in \"$_path\""
     1265        puts stderr "WARNING: No point data found in \"$_path\""
    12751266        rename $reader ""
    12761267        return 0
     
    12801271    set numArrays [$dataAttrs GetNumberOfArrays]
    12811272    if { $numArrays > 0 } {
    1282         for {set i 0} {$i < [$dataAttrs GetNumberOfArrays] } {incr i} {
    1283             set array [$dataAttrs GetArray $i]
    1284             set fname  [$dataAttrs GetArrayName $i]
    1285             foreach {min max} [$array GetRange -1] break
     1273        for {set i 0} {$i < [$dataAttrs GetNumberOfArrays] } {incr i} {
     1274            set array [$dataAttrs GetArray $i]
     1275            set fname  [$dataAttrs GetArrayName $i]
     1276            foreach {min max} [$array GetRange -1] break
    12861277            if {$i == 0} {
    12871278                set vmin $min
    12881279                set vmax $max
    12891280            }
    1290             lappend limits $fname [list $min $max]
     1281            lappend limits $fname [list $min $max]
    12911282            set _fld2Units($fname) ""
    1292             set _fld2Label($fname) $fname
     1283            set _fld2Label($fname) $fname
    12931284            # Let the VTK file override the <type> designated.
    12941285            set _fld2Components($fname) [$array GetNumberOfComponents]
    12951286            lappend _comp2fldName($cname) $fname
    1296         }
    1297     }
    1298    
     1287        }
     1288    }
     1289
    12991290    lappend limits v [list $vmin $vmax]
    13001291    set _comp2limits($cname) $limits
     
    13061297# vtkdata --
    13071298#
    1308 #       Returns a string representing the mesh and field data for a specific
    1309 #       component in the legacy VTK file format.
     1299#        Returns a string representing the mesh and field data for a specific
     1300#        component in the legacy VTK file format.
    13101301#
    13111302itcl::body Rappture::Field::vtkdata {cname} {
     
    13131304        set cname "component"
    13141305    }
    1315     # DX: Convert DX to VTK 
     1306    # DX: Convert DX to VTK
    13161307    if {[info exists _comp2dx($cname)]} {
    13171308        set data $_comp2dx($cname)
     
    13191310        return [Rappture::DxToVtk $data]
    13201311    }
    1321     # Unirect3d: isosurface
    1322     if {[info exists _comp2unirect3d($cname)]} {
    1323         return [$_comp2unirect3d($cname) vtkdata]
    1324     }
    1325     # VTK file data:
     1312    # VTK file data:
    13261313    if { [info exists _comp2vtk($cname)] } {
    13271314        return $_comp2vtk($cname)
     
    13291316    # Points on mesh:  Construct VTK file output.
    13301317    if { [info exists _comp2mesh($cname)] } {
    1331         # Data is in the form mesh and vector
    1332         foreach {mesh vector} $_comp2mesh($cname) break
     1318        # Data is in the form mesh and vector
     1319        foreach {mesh vector} $_comp2mesh($cname) break
    13331320        set label $cname
    13341321        regsub -all { } $label {_} label
    1335         append out "# vtk DataFile Version 3.0\n"
    1336         append out "[hints label]\n"
    1337         append out "ASCII\n"
    1338         append out [$mesh vtkdata]
     1322        append out "# vtk DataFile Version 3.0\n"
     1323        append out "[hints label]\n"
     1324        append out "ASCII\n"
     1325        append out [$mesh vtkdata]
    13391326
    13401327        if { $_comp2assoc($cname) == "pointdata" } {
     
    13771364            }
    13781365        }
    1379         append out [$vector range 0 end] 
     1366        append out [$vector range 0 end]
    13801367        append out "\n"
    13811368        if 0 {
    13821369            VerifyVtkDataSet $out
    13831370        }
    1384         return $out
    1385     }
    1386     error "can't find vtkdata for $cname. This method should only be called by the vtkheightmap widget"
     1371        return $out
     1372    }
     1373    error "can't find vtkdata for $cname"
    13871374}
    13881375
     
    13901377# BuildPointsOnMesh --
    13911378#
    1392 #       Parses the field XML description to build a mesh and values vector
    1393 #       representing the field.  Right now we handle the deprecated types
    1394 #       of "cloud", "unirect2d", and "unirect3d" (mostly for flows).
     1379#        Parses the field XML description to build a mesh and values vector
     1380#        representing the field.  Right now we handle the deprecated types
     1381#        of "cloud", "unirect2d", and "unirect3d" (mostly for flows).
    13951382#
    13961383itcl::body Rappture::Field::BuildPointsOnMesh {cname} {
     
    14011388    set path [$_field get $cname.mesh]
    14021389    if {[$_xmlobj element $path] == ""} {
    1403         # Unknown mesh designated.
    1404         return 0
     1390        # Unknown mesh designated.
     1391        return 0
    14051392    }
    14061393    set viewer [$_field get "about.view"]
     
    14221409    # Handle bizarre cases that hopefully will be deprecated.
    14231410    if { $element == "unirect3d" } {
    1424         # Special case: unirect3d (should be deprecated) + flow.
     1411        # Special case: unirect3d (should be deprecated) + flow.
    14251412        if { [$_field element $cname.extents] != "" } {
    14261413            set vectorsize [$_field get $cname.extents]
    14271414        } else {
    1428             set vectorsize 1 
     1415            set vectorsize 1
    14291416        }
    14301417        set _type unirect3d
    1431         set _dim 3
     1418        set _dim 3
    14321419        if { $_viewer == "" } {
    14331420            set _viewer flowvis
    14341421        }
    1435         set _comp2dims($cname) "3D"
    1436         set _comp2unirect3d($cname) \
    1437             [Rappture::Unirect3d \#auto $_xmlobj $_field $cname $vectorsize]
    1438         set _comp2style($cname) [$_field get $cname.style]
     1422        set _comp2dims($cname) "3D"
     1423        set _comp2unirect3d($cname) \
     1424            [Rappture::Unirect3d \#auto $_xmlobj $_field $cname $vectorsize]
     1425        set _comp2style($cname) [$_field get $cname.style]
    14391426        set limits {}
    14401427        foreach axis { x y z } {
    14411428            lappend limits $axis [$_comp2unirect3d($cname) limits $axis]
    14421429        }
    1443         # Get the data limits 
    1444         set vector [$_comp2unirect3d($cname) valuesObj]
     1430        # Get the data limits
     1431        set vector [$_comp2unirect3d($cname) values]
    14451432        set minmax [VectorLimits $vector $vectorsize]
    14461433        lappend limits $cname $minmax
    14471434        lappend limits v      $minmax
    14481435        set _comp2limits($cname) $limits
    1449         if {[$_field element $cname.flow] != ""} {
    1450             set _comp2flowhints($cname) \
    1451                 [Rappture::FlowHints ::\#auto $_field $cname $_units]
    1452         }
    1453         incr _counter
    1454         return 1
     1436        if {[$_field element $cname.flow] != ""} {
     1437            set _comp2flowhints($cname) \
     1438                [Rappture::FlowHints ::\#auto $_field $cname $_units]
     1439        }
     1440        incr _counter
     1441        return 1
    14551442    }
    14561443    if { $element == "unirect2d" && [$_field element $cname.flow] != "" } {
    1457         # Special case: unirect2d (normally deprecated) + flow.
     1444        # Special case: unirect2d (normally deprecated) + flow.
    14581445        if { [$_field element $cname.extents] != "" } {
    14591446            set vectorsize [$_field get $cname.extents]
    14601447        } else {
    1461             set vectorsize 1 
     1448            set vectorsize 1
    14621449        }
    14631450        set _type unirect2d
    1464         set _dim 2
     1451        set _dim 2
    14651452        if { $_viewer == "" } {
    14661453            set _viewer "flowvis"
    14671454        }
    1468         set _comp2dims($cname) "2D"
    1469         set _comp2unirect2d($cname) \
    1470             [Rappture::Unirect2d \#auto $_xmlobj $path]
    1471         set _comp2style($cname) [$_field get $cname.style]
    1472         set _comp2flowhints($cname) \
    1473             [Rappture::FlowHints ::\#auto $_field $cname $_units]
    1474         set _values [$_field get $cname.values]
     1455        set _comp2dims($cname) "2D"
     1456        set _comp2unirect2d($cname) \
     1457            [Rappture::Unirect2d \#auto $_xmlobj $path]
     1458        set _comp2style($cname) [$_field get $cname.style]
     1459        set _comp2flowhints($cname) \
     1460            [Rappture::FlowHints ::\#auto $_field $cname $_units]
     1461        set _values [$_field get $cname.values]
    14751462        set limits {}
    14761463        foreach axis { x y z } {
     
    14841471        blt::vector destroy $xv
    14851472        set _comp2limits($cname) $limits
    1486         incr _counter
    1487         return 1
     1473        incr _counter
     1474        return 1
    14881475    }
    14891476    switch -- $element {
    1490         "cloud" {
    1491             set mesh [Rappture::Cloud::fetch $_xmlobj $path]
     1477        "cloud" {
     1478            set mesh [Rappture::Cloud::fetch $_xmlobj $path]
    14921479            set _type cloud
    1493         }
    1494         "mesh" {
    1495             set mesh [Rappture::Mesh::fetch $_xmlobj $path]
     1480        }
     1481        "mesh" {
     1482            set mesh [Rappture::Mesh::fetch $_xmlobj $path]
    14961483            set _type mesh
    1497         }           
    1498         "unirect2d" {
     1484        }
     1485        "unirect2d" {
    14991486            if { $_viewer == "" } {
    15001487                set _viewer "heightmap"
    15011488            }
    1502             set mesh [Rappture::Unirect2d::fetch $_xmlobj $path]
     1489            set mesh [Rappture::Unirect2d::fetch $_xmlobj $path]
    15031490            set _type unirect2d
    1504         }
     1491        }
    15051492    }
    15061493    if { ![$mesh isvalid] } {
     
    15101497    set _dim [$mesh dimensions]
    15111498    if { $_dim == 3 } {
    1512         set dim 0 
     1499        set dim 0
    15131500        foreach axis {x y z} {
    15141501            foreach {min max} [$mesh limits $axis] {
     
    15271514        return 0
    15281515
    1529         # 1D data: Create vectors for graph widget.
    1530         # The prophet tool currently outputs 1D clouds with fields
     1516        # 1D data: Create vectors for graph widget.
     1517        # The prophet tool currently outputs 1D clouds with fields
    15311518        # Band Structure Lab used to (see isosurface1 test in rappture-bat)
    1532         #
    1533         # Is there a natural growth path in generating output from 1D to
    1534         # higher dimensions?  If there isn't, let's kill this in favor
    1535         # or explicitly using a <curve> instead.  Otherwise, the features
    1536         # (methods such as xmarkers) or the <curve> need to be added
    1537         # to the <field>.
    1538         #
    1539         #set xv [blt::vector create x$_counter]
    1540         #set yv [blt::vector create y$_counter]
     1519        #
     1520        # Is there a natural growth path in generating output from 1D to
     1521        # higher dimensions?  If there isn't, let's kill this in favor
     1522        # or explicitly using a <curve> instead.  Otherwise, the features
     1523        # (methods such as xmarkers) of the <curve> need to be added
     1524        # to the <field>.
     1525        #
     1526        #set xv [blt::vector create x$_counter]
     1527        #set yv [blt::vector create y$_counter]
    15411528
    15421529        # This only works with a Cloud mesh type, since the points method
    15431530        # is not implemented for the Mesh object
    1544         #$xv set [$mesh points]
     1531        #$xv set [$mesh points]
    15451532        # TODO: Put field values in yv
    1546         #set _comp2dims($cname) "1D"
    1547         #set _comp2xy($cname) [list $xv $yv]
    1548         #incr _counter
    1549         #return 1
    1550     } 
     1533        #set _comp2dims($cname) "1D"
     1534        #set _comp2xy($cname) [list $xv $yv]
     1535        #incr _counter
     1536        #return 1
     1537    }
    15511538    if {$_dim == 2} {
    1552         # 2D data: By default surface or contour plot using heightmap widget.
    1553         set v [blt::vector create \#auto]
    1554         $v set [$_field get $cname.values]
     1539        # 2D data: By default surface or contour plot using heightmap widget.
     1540        set v [blt::vector create \#auto]
     1541        $v set [$_field get $cname.values]
    15551542        if { [$v length] == 0 } {
    15561543            return 0
     
    15791566            }
    15801567        }
    1581         set _comp2dims($cname) "[$mesh dimensions]D"
    1582         set _comp2mesh($cname) [list $mesh $v]
    1583         set _comp2style($cname) [$_field get $cname.style]
     1568        set _comp2dims($cname) "[$mesh dimensions]D"
     1569        set _comp2mesh($cname) [list $mesh $v]
     1570        set _comp2style($cname) [$_field get $cname.style]
    15841571        if {[$_field element $cname.flow] != ""} {
    15851572            set _comp2flowhints($cname) \
    15861573                [Rappture::FlowHints ::\#auto $_field $cname $_units]
    15871574        }
    1588         incr _counter
    1589         array unset _comp2limits $cname
     1575        incr _counter
     1576        array unset _comp2limits $cname
    15901577        foreach axis { x y z } {
    15911578            lappend _comp2limits($cname) $axis [$mesh limits $axis]
     
    15941581        lappend _comp2limits($cname) $cname $minmax
    15951582        lappend _comp2limits($cname) v $minmax
    1596         return 1
    1597     } 
     1583        return 1
     1584    }
    15981585    if {$_dim == 3} {
    1599         # 3D data: By default isosurfaces plot using isosurface widget.
     1586        # 3D data: By default isosurfaces plot using isosurface widget.
    16001587        if { $_viewer == "" } {
    16011588            set _viewer "isosurface"
    16021589        }
    1603         set v [blt::vector create \#auto]
    1604         $v set [$_field get $cname.values]
     1590        set v [blt::vector create \#auto]
     1591        $v set [$_field get $cname.values]
    16051592        if { [$v length] == 0 } {
    16061593            return 0
     
    16401627        lappend _comp2limits($cname) $cname $minmax
    16411628        lappend _comp2limits($cname) v $minmax
    1642         return 1
     1629        return 1
    16431630    }
    16441631    error "unhandled case in field dim=$_dim element=$element"
     
    17321719        "tcoords"              2
    17331720        "tensors"              9
    1734         "vectors"              3 
     1721        "vectors"              3
    17351722    }
    17361723    set type [$_field get $cname.elemtype]
    17371724    if { $type == "" } {
    17381725        set type "scalars"
    1739     } 
     1726    }
    17401727    if { ![info exists type2components($type)] } {
    17411728        error "unknown <elemtype> \"$type\" in field"
     
    17541741        set _comp2assoc($cname) "pointdata"
    17551742        return
    1756     } 
     1743    }
    17571744    switch -- $assoc {
    17581745        "pointdata" - "celldata" - "fielddata" {
  • branches/uiuc_vtk_viewers/gui/scripts/imageresult.tcl

    r3813 r5053  
    7272    pack propagate $itk_component(hull) no
    7373
    74     Rappture::Panes $itk_interior.panes -sashwidth 1 -sashrelief solid -sashpadding 2
     74    Rappture::Panes $itk_interior.panes \
     75        -sashwidth 2 -sashrelief solid -sashpadding 1
     76
    7577    pack $itk_interior.panes -expand yes -fill both
    7678    set main [$itk_interior.panes pane 0]
  • branches/uiuc_vtk_viewers/gui/scripts/isomarker.tcl

    r4403 r5053  
    1 # -*- mode: tcl; indent-tabs-mode: nil -*- 
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    22
    33# ----------------------------------------------------------------------
     
    2424    private variable _canvas    ""
    2525    private variable _nvobj     "";     # Parent nanovis object.
    26     private variable _tf        "";     # Transfer function that this marker is 
     26    private variable _tf        "";     # Transfer function that this marker is
    2727                                        # associated with.
    2828    private variable _activeMotion   0
     
    3030    private common   _normalIcon [Rappture::icon nvlegendmark]
    3131    private common   _activeIcon [Rappture::icon nvlegendmark2]
    32     private method EnterTick {} 
    33     private method LeaveTick {} 
    34     private method StartDrag { x y } 
    35     private method ContinueDrag { x y } 
    36     private method StopDrag { x y } 
     32    private method EnterTick {}
     33    private method LeaveTick {}
     34    private method StartDrag { x y }
     35    private method ContinueDrag { x y }
     36    private method StopDrag { x y }
    3737
    3838    constructor {c obj tf args} {}
    39     destructor {} 
    40     public method transferfunc {} 
    41     public method activate { bool } 
    42     public method visible { bool } 
    43     public method screenpos {} 
    44     public method absval { {x "-get"} } 
     39    destructor {}
     40    public method transferfunc {}
     41    public method activate { bool }
     42    public method visible { bool }
     43    public method screenpos {}
     44    public method absval { {x "-get"} }
    4545    public method relval  { {x "-get"} }
    4646}
    4747
    48 itcl::body Rappture::IsoMarker::constructor {c obj tf args} { 
     48itcl::body Rappture::IsoMarker::constructor {c obj tf args} {
    4949    set _canvas $c
    5050    set _nvobj $obj
     
    9595}
    9696
    97 itcl::body Rappture::IsoMarker::screenpos { } { 
     97itcl::body Rappture::IsoMarker::screenpos { } {
    9898    set x [relval]
    9999    if { $x < 0.0 } {
    100100        set x 0.0
    101101    } elseif { $x > 1.0 } {
    102         set x 1.0 
     102        set x 1.0
    103103    }
    104     set low 10 
     104    set low 10
    105105    set w [winfo width $_canvas]
    106106    set high [expr {$w  - 10}]
     
    133133        }
    134134        return [expr {($_value - $min) / ($max - $min)}]
    135     } 
     135    }
    136136    if { $max == $min } {
    137137        set min 0.0
     
    140140    if { [catch {expr $max - $min} r] != 0 } {
    141141        return 0.0
    142     }           
     142    }
    143143    absval [expr {($x * $r) + $min}]
    144144}
     
    156156
    157157itcl::body Rappture::IsoMarker::StartDrag { x y } {
    158     $_canvas raise $_tick 
     158    $_canvas raise $_tick
    159159    set _activePress 1
    160160    activate yes
     
    165165itcl::body Rappture::IsoMarker::StopDrag { x y } {
    166166    if { ![$_nvobj removeDuplicateMarker $this $x]} {
    167         ContinueDrag $x $y 
     167        ContinueDrag $x $y
    168168    }
    169169    set _activePress 0
     
    178178    $_nvobj overMarker $this $x
    179179    $_nvobj updateTransferFunctions
    180     $_canvas raise $_tick 
     180    $_canvas raise $_tick
    181181    set _activePress 1
    182182    activate yes
  • branches/uiuc_vtk_viewers/gui/scripts/map.tcl

    r4992 r5053  
    1 # -*- mode: tcl; indent-tabs-mode: nil -*- 
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    22
    33# ----------------------------------------------------------------------
     
    1919package require BLT
    2020
    21 namespace eval Rappture { 
    22     # forward declaration 
     21namespace eval Rappture {
     22    # forward declaration
    2323}
    2424
     
    2626    private variable _tree "";         # Tree of information about the map.
    2727    private variable _isValid 0;
    28     private common _nextLayer 0;        # Counter used to generate unique
     28    private common _nextLayer 0;       # Counter used to generate unique
    2929                                       # layer names.
     30    private common _nextViewpoint 0;   # Counter used to generate unique
     31                                       # viewpoint names.
    3032    private common _layerTypes
    3133    private common _mapTypes
     
    4547    protected method Parse { xmlobj path }
    4648
    47     constructor {xmlobj path} {
    48         # defined below
    49     }
    50     destructor {
    51         # defined below
    52     }
    53 
    54     public method isGeocentric {}
    55     public method layers {}
    56     public method layer { layerName }
     49    constructor {xmlobj path} {
     50        # defined below
     51    }
     52    destructor {
     53        # defined below
     54    }
     55
     56    public method earthfile {}
    5757    public method hints { args }
     58    public method isGeocentric {}
    5859    public method isvalid {} {
    5960        return $_isValid;
    6061    }
     62    public method layer { layerName }
     63    public method layers {}
    6164    public method type { layerName }
    62     public method earthfile {}
     65    public method viewpoint { viewpointName }
     66    public method viewpoints {}
    6367}
    6468
     
    8286}
    8387
    84 #
    85 # hints --
    86 #
    8788itcl::body Rappture::Map::hints { args } {
    8889    switch -- [llength $args] {
     
    103104# Parse --
    104105#
    105 #       Parses the map description in the XML object.
     106#   Parses the map description in the XML object.
    106107#
    107108itcl::body Rappture::Map::Parse { xmlobj path } {
     
    119120        set name "layer[incr _nextLayer]"
    120121        set child [$_tree insert $parent -label $name]
    121         set layerType [$layers get $layer.type] 
     122        set layerType [$layers get $layer.type]
    122123        if { ![info exists _layerTypes($layerType)] } {
    123124            error "invalid layer type \"$layerType\": should be one of [array names _layerTypes]"
     
    125126        $_tree set $child "name" $layer
    126127        $_tree set $child "type" $layerType
    127         foreach key { label description } {
    128             $_tree set $child $key [$layers get $layer.$key] 
     128        foreach key { label description attribution } {
     129            $_tree set $child $key [$layers get $layer.$key]
    129130        }
    130131        # Common settings (for all layer types) with defaults
     
    152153                $_tree set $child "gdal.$key" $value
    153154            }
    154             set file [$layers get $layer.gdal.file] 
     155            set file [$layers get $layer.gdal.file]
    155156            if { $file != "" } {
    156157                # FIXME: Add test for valid file path
     
    165166                $_tree set $child "ogr.$key" $value
    166167            }
    167             set file [$layers get $layer.ogr.file] 
     168            set file [$layers get $layer.ogr.file]
    168169            if { $file != "" } {
    169170                # FIXME: Add test for valid file path
     
    214215    }
    215216    $_tree set root "label"       [$map get "about.label"]
     217    $_tree set root "attribution" [$map get "about.attribution"]
    216218    $_tree set root "style"       [$map get "style"]
    217  
     219    $_tree set root "camera"      [$map get "camera"]
     220    set parent [$_tree insert root -label "viewpoints"]
     221    set viewpoints [$map element -as object "viewpoints"]
     222    if { $viewpoints != "" } {
     223        foreach viewpoint [$viewpoints children -type viewpoint] {
     224            set name "viewpoint[incr _nextViewpoint]"
     225            set child [$_tree insert $parent -label $name]
     226            $_tree set $child "name" $viewpoint
     227            foreach key { label description x y z distance heading pitch srs verticalDatum } {
     228                set val [$viewpoints get $viewpoint.$key]
     229                $_tree set $child $key $val
     230            }
     231        }
     232    }
     233
    218234    set projection [$map get "projection"]
    219235    set extents    [$map get "extents"]
    220236    if { $projection  == "" } {
    221         if {$extents != ""} {
     237        if { $extents != "" } {
    222238            error "cannot specify extents without a projection"
    223239        }
     
    233249    if { $mapType == "" } {
    234250        set mapType "projected";           # Default type is "projected".
    235     } 
     251    }
    236252    if { ![info exists _mapTypes($mapType)] } {
    237253        error "unknown map type \"$mapType\": should be one of [array names _mapTypes]"
     
    262278    set list {}
    263279    foreach node [$_tree children root->"layers"] {
    264         lappend list [$_tree label $node]
     280        lappend list [$_tree label $node]
     281    }
     282    return $list
     283}
     284
     285# ----------------------------------------------------------------------
     286# USAGE: viewpoints
     287#
     288# Returns a list of IDs for the viewpoints in the map
     289# ----------------------------------------------------------------------
     290itcl::body Rappture::Map::viewpoints {} {
     291    set list {}
     292    foreach node [$_tree children root->"viewpoints"] {
     293        lappend list [$_tree label $node]
    265294    }
    266295    return $list
     
    281310
    282311# ----------------------------------------------------------------------
     312# USAGE: viewopint <viewopintName>
     313#
     314# Returns an array of settings for the named viewpoint
     315# ----------------------------------------------------------------------
     316itcl::body Rappture::Map::viewpoint { viewopintName } {
     317    set id [$_tree findchild root->"viewpoints" $viewopintName]
     318    if { $id < 0 } {
     319        error "unknown viewpoint \"$viewpointName\""
     320    }
     321    return [$_tree get $id]
     322}
     323
     324# ----------------------------------------------------------------------
    283325# USAGE: type <layerName>
    284326#
     
    296338# USAGE: isGeocentric
    297339#
    298 # Returns if the map is geocentric (1) or projected (0) 
    299 # ---------------------------------------------------------------------- 
    300 itcl::body Rappture::Map::isGeocentric {} { 
     340# Returns if the map is geocentric (1) or projected (0)
     341# ----------------------------------------------------------------------
     342itcl::body Rappture::Map::isGeocentric {} {
    301343    return [expr {[hints "type"] eq "geocentric"}]
    302 } 
    303 
    304 itcl::body Rappture::Map::earthfile {} { 
     344}
     345
     346itcl::body Rappture::Map::earthfile {} {
    305347    array set info [$_tree get root]
    306348    append out "<map"
     
    364406    }
    365407    append out "</map>\n"
    366 } 
     408}
  • branches/uiuc_vtk_viewers/gui/scripts/mapviewer.tcl

    r4992 r5053  
    1 # -*- mode: tcl; indent-tabs-mode: nil -*- 
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    22# ----------------------------------------------------------------------
    33#  COMPONENT: mapviewer - Map object viewer
     
    3939    itk_option define -plotbackground plotBackground Background ""
    4040
    41     private variable _layersFrame "";   # Name of layers frame widget
    42     private variable _mapsettings;      # Global map settings
     41    private variable _layersFrame "";     # Name of layers frame widget
     42    private variable _viewpointsFrame ""; # Name of viewpoints frame widget
     43    private variable _mapsettings;        # Global map settings
    4344
    4445    constructor { hostlist args } {
     
    6061    public method get {args}
    6162    public method isconnected {}
    62     public method parameters {title args} { 
    63         # do nothing 
     63    public method parameters {title args} {
     64        # do nothing
    6465    }
    6566    public method scale {args}
     
    7778    private method AdjustSetting {what {value ""}}
    7879    private method BuildCameraTab {}
    79     private method BuildDownloadPopup { widget command } 
     80    private method BuildDownloadPopup { widget command }
    8081    private method BuildLayerTab {}
    8182    private method BuildMapTab {}
    8283    private method BuildTerrainTab {}
     84    private method BuildViewpointsTab {}
    8385    private method Connect {}
    8486    private method CurrentLayers {args}
     
    8789    private method DoResize {}
    8890    private method DoRotate {}
     91    private method DoSelect {}
    8992    private method EarthFile {}
    9093    private method EventuallyHandleMotionEvent { x y }
    9194    private method EventuallyPan { dx dy }
    92     private method EventuallyResize { w h }
    93     private method EventuallyRotate { dx dy }
    94     private method GetImage { args }
     95    private method EventuallyResize { w h }
     96    private method EventuallyRotate { dx dy }
     97    private method EventuallySelect { x y }
     98    private method GetImage { args }
    9599    private method GetNormalizedMouse { x y }
     100    private method GoToViewpoint { dataobj viewpoint }
    96101    private method InitSettings { args  }
    97102    private method MapIsGeocentric {}
     
    104109    private method Rotate {option x y}
    105110    private method Select {option x y}
    106     private method SetLayerOpacity { dataobj layer {value 100}}
     111    private method SetHeading { {value 0} }
     112    private method SetLayerOpacity { dataobj layer {value 100} }
    107113    private method SetLayerStyle { dataobj layer }
    108114    private method SetLayerVisibility { dataobj layer }
     115    private method SetPitch { {value -89.999} }
    109116    private method SetTerrainStyle { style }
     117    private method ToggleGrid {}
     118    private method ToggleLighting {}
     119    private method ToggleWireframe {}
    110120    private method UpdateLayerControls {}
     121    private method UpdateViewpointControls {}
    111122    private method Zoom {option {x 0} {y 0}}
    112123
    113     private variable _dlist "";         # list of data objects
     124    private variable _dlist "";         # list of data objects
    114125    private variable _obj2datasets
    115     private variable _obj2ovride;       # maps dataobj => style override
    116     private variable _layers;           # Contains the names of all the
    117                                         # layer in the server.
     126    private variable _obj2ovride;       # maps dataobj => style override
     127    private variable _layers;           # Contains the names of all the
     128                                        # layer in the server.
     129    private variable _viewpoints;
    118130    private variable _click;            # info used for rotate operations
    119131    private variable _view;             # view params for 3D view
    120132    private variable _pan;
    121133    private variable _rotate;
     134    private variable _select;
    122135    private variable _motion;
    123136    private variable _settings
     
    158171
    159172    if { [catch {
    160        
     173
    161174    # Rebuild event
    162175    $_dispatcher register !rebuild
     
    174187    $_dispatcher register !rotate
    175188    $_dispatcher dispatch $this !rotate "[itcl::code $this DoRotate]; list"
     189
     190    # Select event
     191    $_dispatcher register !select
     192    $_dispatcher dispatch $this !select "[itcl::code $this DoSelect]; list"
    176193
    177194    # <Motion> event
     
    213230        elevation       0
    214231        pending         0
     232    }
     233    array set _select {
     234        compress        1
     235        delay           100
     236        pending         0
     237        x               0
     238        y               0
    215239    }
    216240    # This array holds the Viewpoint parameters that the
     
    255279
    256280    set c $itk_component(view)
    257     #bind $c <KeyPress-Left>  [list %W xview scroll 10 units]
    258     #bind $c <KeyPress-Right> [list %W xview scroll -10 units]
    259     #bind $c <KeyPress-Up>    [list %W yview scroll 10 units]
    260     #bind $c <KeyPress-Down>  [list %W yview scroll -10 units]
    261281    bind $c <Enter> "focus %W"
    262282    bind $c <Control-F1> [itcl::code $this ToggleConsole]
     
    266286
    267287    set _map(id) [$c create image 0 0 -anchor nw -image $_image(plot)]
    268     set _map(cwidth) -1 
    269     set _map(cheight) -1 
     288    set _map(cwidth) -1
     289    set _map(cheight) -1
    270290    set _map(zoom) 1.0
    271291    set _map(original) ""
     
    310330
    311331    BuildLayerTab
     332    BuildViewpointsTab
    312333    BuildMapTab
    313334    BuildTerrainTab
     
    318339    set _image(legend) [image create photo]
    319340    itk_component add legend {
    320         canvas $itk_component(plotarea).legend -width 50 -highlightthickness 0 
     341        canvas $itk_component(plotarea).legend -width 50 -highlightthickness 0
    321342    } {
    322343        usual
     
    325346    }
    326347
    327     # Hack around the Tk panewindow.  The problem is that the requested 
     348    # Hack around the Tk panewindow.  The problem is that the requested
    328349    # size of the 3d view isn't set until an image is retrieved from
    329350    # the server.  So the panewindow uses the tiny size.
     
    331352    pack forget $itk_component(view)
    332353    blt::table $itk_component(plotarea) \
    333         0,0 $itk_component(view) -fill both -reqwidth $w 
     354        0,0 $itk_component(view) -fill both -reqwidth $w
    334355    blt::table configure $itk_component(plotarea) c1 -resize none
    335356
     
    386407        bind $itk_component(view) <ButtonRelease-1> \
    387408            [itcl::code $this Pan release %x %y]
    388         bind $itk_component(view) <Button-1> \
     409        bind $itk_component(view) <ButtonPress-1> \
    389410            +[itcl::code $this SendCmd "map setpos %x %y"]
    390411        bind $itk_component(view) <Double-1> \
    391412            [itcl::code $this camera go %x %y 0.4]
     413        bind $itk_component(view) <Shift-Double-1> \
     414            [itcl::code $this camera go %x %y 1.0]
    392415
    393416        # Pin placemark annotations
     
    436459            [itcl::code $this Pan set 0 10]
    437460
     461        bind $itk_component(view) <Shift-KeyPress-Left> \
     462            [itcl::code $this Pan set 2 0]
     463        bind $itk_component(view) <Shift-KeyPress-Right> \
     464            [itcl::code $this Pan set -2 0]
     465        bind $itk_component(view) <Shift-KeyPress-Up> \
     466            [itcl::code $this Pan set 0 -2]
     467        bind $itk_component(view) <Shift-KeyPress-Down> \
     468            [itcl::code $this Pan set 0 2]
     469
     470        # Bindings for rotation via keyboard
     471        bind $itk_component(view) <Control-Left> \
     472            [itcl::code $this Rotate set 10 0]
     473        bind $itk_component(view) <Control-Right> \
     474            [itcl::code $this Rotate set -10 0]
     475        bind $itk_component(view) <Control-Up> \
     476            [itcl::code $this Rotate set 0 -10]
     477        bind $itk_component(view) <Control-Down> \
     478            [itcl::code $this Rotate set 0 10]
     479
     480        bind $itk_component(view) <Control-Shift-Left> \
     481            [itcl::code $this Rotate set 2 0]
     482        bind $itk_component(view) <Control-Shift-Right> \
     483            [itcl::code $this Rotate set -2 0]
     484        bind $itk_component(view) <Control-Shift-Up> \
     485            [itcl::code $this Rotate set 0 -2]
     486        bind $itk_component(view) <Control-Shift-Down> \
     487            [itcl::code $this Rotate set 0 2]
     488
     489        # Bindings for zoom via keyboard
     490        bind $itk_component(view) <KeyPress-Prior> \
     491            [itcl::code $this Zoom out]
     492        bind $itk_component(view) <KeyPress-Next> \
     493            [itcl::code $this Zoom in]
     494        bind $itk_component(view) <KeyPress-Home> \
     495            [itcl::code $this camera reset]
     496
     497        # Keyboard shortcuts
     498        # Reset heading to North
     499        bind $itk_component(view) <n> \
     500            [itcl::code $this SetHeading]
     501        # Reset pitch to top-down (2D) view
     502        bind $itk_component(view) <p> \
     503            [itcl::code $this SetPitch]
     504        bind $itk_component(view) <g> \
     505            [itcl::code $this ToggleGrid]
     506        bind $itk_component(view) <l> \
     507            [itcl::code $this ToggleLighting]
     508        bind $itk_component(view) <w> \
     509            [itcl::code $this ToggleWireframe]
     510
    438511        # Binding for mouse motion events
    439512        set _motion(compress) 1
     
    445518        #    +[itcl::code $this SendCmd "map pin hover %x %y"]
    446519    }
    447 
    448     bind $itk_component(view) <Shift-KeyPress-Left> \
    449         [itcl::code $this Pan set 2 0]
    450     bind $itk_component(view) <Shift-KeyPress-Right> \
    451         [itcl::code $this Pan set -2 0]
    452     bind $itk_component(view) <Shift-KeyPress-Up> \
    453         [itcl::code $this Pan set 0 -2]
    454     bind $itk_component(view) <Shift-KeyPress-Down> \
    455         [itcl::code $this Pan set 0 2]
    456 
    457     # Bindings for zoom via keyboard
    458     bind $itk_component(view) <KeyPress-Prior> \
    459         [itcl::code $this Zoom out]
    460     bind $itk_component(view) <KeyPress-Next> \
    461         [itcl::code $this Zoom in]
    462520
    463521    bind $itk_component(view) <Enter> "focus $itk_component(view)"
     
    479537    Connect
    480538} errs] != 0 } {
    481         puts stderr errs=$errs
     539        puts stderr errs=$errs
    482540    }
    483541}
     
    519577}
    520578
     579itcl::body Rappture::MapViewer::DoSelect {} {
     580    SendCmd "map box update $_select(x) $_select(y)"
     581    set _select(x) 0
     582    set _select(y) 0
     583    set _select(pending) 0
     584}
     585
    521586itcl::body Rappture::MapViewer::EventuallyResize { w h } {
    522587    set _width $w
     
    558623        set _rotate(pending) 1
    559624        $_dispatcher event -after $_rotate(delay) !rotate
     625    }
     626}
     627
     628itcl::body Rappture::MapViewer::EventuallySelect { x y } {
     629    set _select(x) $x
     630    set _select(y) $y
     631    if { !$_select(compress) } {
     632        DoSelect
     633        return
     634    }
     635    if { !$_select(pending) } {
     636        set _select(pending) 1
     637        $_dispatcher event -after $_select(delay) !select
    560638    }
    561639}
     
    604682# USAGE: delete ?<dataobj1> <dataobj2> ...?
    605683#
    606 #       Clients use this to delete a dataobj from the plot.  If no dataobjs
    607 #       are specified, then all dataobjs are deleted.  No data objects are
    608 #       deleted.  They are only removed from the display list.
    609 #
     684# Clients use this to delete a dataobj from the plot.  If no dataobjs
     685# are specified, then all dataobjs are deleted.  No data objects are
     686# deleted.  They are only removed from the display list.
    610687# ----------------------------------------------------------------------
    611688itcl::body Rappture::MapViewer::delete {args} {
     
    660737                    continue
    661738                }
    662                 if {[info exists _obj2ovride($dataobj-raise)] && 
     739                if {[info exists _obj2ovride($dataobj-raise)] &&
    663740                    $_obj2ovride($dataobj-raise)} {
    664741                    set dlist [linsert $dlist 0 $dataobj]
     
    688765            }
    689766            return $dlist
    690         }           
     767        }
    691768        -image {
    692769            if {[llength $args] != 2} {
     
    736813            continue
    737814        }
    738         array unset hints 
     815        array unset hints
    739816        array set hints [$dataobj hints]
    740817        if { ![info exists _mapsettings(label)] } {
     
    772849            }
    773850        }
     851        if { [info exists hints(camera)] } {
     852            if { ![info exists _mapsettings(camera)] } {
     853                set _mapsettings(camera) $hints(camera)
     854            }
     855        }
    774856        foreach layer [$dataobj layers] {
    775857            if { [$dataobj type $layer] == "elevation" } {
    776858                set _haveTerrain 1
    777859                break
    778             }
     860            }
     861        }
     862        foreach viewpoint [$dataobj viewpoints] {
     863            set _viewpoints($viewpoint) [$dataobj viewpoint $viewpoint]
     864            array set vp $_viewpoints($viewpoint)
     865            foreach key { label description x y z distance heading pitch srs verticalDatum } {
     866                if { [info exists vp($key)] } {
     867                    puts stderr "$viewpoint $key $vp($key)"
     868                }
     869            }
    779870        }
    780871    }
     
    892983# isconnected --
    893984#
    894 #       Indicates if we are currently connected to the visualization server.
     985#   Indicates if we are currently connected to the visualization server.
    895986#
    896987itcl::body Rappture::MapViewer::isconnected {} {
     
    9091000# Disconnect --
    9101001#
    911 #       Clients use this method to disconnect from the current rendering
    912 #       server.
     1002#   Clients use this method to disconnect from the current rendering
     1003#   server.
    9131004#
    9141005itcl::body Rappture::MapViewer::Disconnect {} {
     
    9221013    # disconnected -- no more data sitting on server
    9231014    array unset _layers
    924     array unset _layersFrame 
     1015    array unset _layersFrame
    9251016    global readyForNextFrame
    9261017    set readyForNextFrame 1
     
    10661157                    $itk_component(time) configure -state disabled
    10671158                    set proj $_mapsettings(projection)
    1068                     if { $proj == "" } { 
     1159                    if { $proj == "" } {
    10691160                        SendCmd "map reset projected global-mercator"
    10701161                    } elseif { ![info exists _mapsettings(extents)] || $_mapsettings(extents) == "" } {
     
    10751166                            set $key $_mapsettings($key)
    10761167                        }
    1077                         SendCmd [list map reset "projected" $proj $x1 $y1 $x2 $y2] 
     1168                        SendCmd [list map reset "projected" $proj $x1 $y1 $x2 $y2]
    10781169                    }
    10791170                }
     
    10831174
    10841175            # Most terrain settings are global to the map and apply even
    1085             # if there is no elevation layer.  The exception is the 
     1176            # if there is no elevation layer.  The exception is the
    10861177            # vertical scale, which only applies if there is an elevation
    10871178            # layer
     
    11051196        set _obj2datasets($dataobj) ""
    11061197        foreach layer [$dataobj layers] {
    1107             array unset info
    1108             array set info [$dataobj layer $layer]
     1198            array unset info
     1199            array set info [$dataobj layer $layer]
    11091200            if { ![info exists _layers($layer)] } {
    11101201                if { $_reportClientInfo }  {
     
    11631254
    11641255    UpdateLayerControls
     1256    UpdateViewpointControls
    11651257    set _reset 0
    11661258    global readyForNextFrame
     
    11841276itcl::body Rappture::MapViewer::CurrentLayers {args} {
    11851277    set flag [lindex $args 0]
    1186     switch -- $flag { 
     1278    switch -- $flag {
    11871279        "-all" {
    11881280            if { [llength $args] > 1 } {
     
    12031295                set dlist [get -visible]
    12041296            }
    1205         }           
     1297        }
    12061298        default {
    12071299            set dlist $args
     
    12711363# EventuallyHandleMotionEvent --
    12721364#
    1273 #       This routine compresses (no button press) motion events.  It
    1274 #       delivers a server mouse command once every 100 milliseconds (if a
    1275 #       motion event is pending).
     1365#   This routine compresses (no button press) motion events.  It
     1366#   delivers a server mouse command once every 100 milliseconds (if a
     1367#   motion event is pending).
    12761368#
    12771369itcl::body Rappture::MapViewer::EventuallyHandleMotionEvent {x y} {
     
    13831475            catch {unset _click}
    13841476        }
     1477        "set" {
     1478            set w [winfo width $itk_component(view)]
     1479            set h [winfo height $itk_component(view)]
     1480            set dx [expr $x / double($w)]
     1481            set dy [expr $y / double($h)]
     1482            if {[expr (abs($dx) > 0.0 || abs($dy) > 0.0)]} {
     1483                EventuallyRotate $dx $dy
     1484            }
     1485        }
    13851486        default {
    13861487            error "bad option \"$option\": should be click, drag, release"
     
    13991500        "drag" {
    14001501            if {$_b1mode == "select"} {
    1401                 SendCmd "map box update $x $y"
     1502                EventuallySelect $x $y
    14021503            }
    14031504        }
     
    14881589}
    14891590
     1591itcl::body Rappture::MapViewer::SetHeading { {value 0} } {
     1592    set _view(heading) $value
     1593    camera set heading
     1594}
     1595
     1596itcl::body Rappture::MapViewer::SetPitch { {value -89.999} } {
     1597    set _view(pitch) $value
     1598    camera set pitch
     1599}
     1600
    14901601# ----------------------------------------------------------------------
    14911602# USAGE: InitSettings <what> ?<value>?
     
    15041615# AdjustSetting --
    15051616#
    1506 #       Changes/updates a specific setting in the widget.  There are
    1507 #       usually user-setable option.  Commands are sent to the render
    1508 #       server.
     1617#   Changes/updates a specific setting in the widget.  There are
     1618#   usually user-setable option.  Commands are sent to the render
     1619#   server.
    15091620#
    15101621itcl::body Rappture::MapViewer::AdjustSetting {what {value ""}} {
     
    15921703        -variable [itcl::scope _settings(coords-visible)] \
    15931704        -command [itcl::code $this AdjustSetting coords-visible] \
    1594         -font "Arial 9" -anchor w 
     1705        -font "Arial 9" -anchor w
    15951706
    15961707    itk_component add grid {
     
    15991710        -variable [itcl::scope _settings(grid)] \
    16001711        -command [itcl::code $this AdjustSetting grid] \
    1601         -font "Arial 9" -anchor w 
     1712        -font "Arial 9" -anchor w
    16021713    } {
    1603         ignore -font
    1604     }
     1714        ignore -font
     1715    }
     1716    Rappture::Tooltip::for $inner.grid "Toggle graticule (grid) display <g>"
    16051717
    16061718    checkbutton $inner.wireframe \
     
    16081720        -variable [itcl::scope _settings(terrain-wireframe)] \
    16091721        -command [itcl::code $this AdjustSetting terrain-wireframe] \
    1610         -font "Arial 9" -anchor w
     1722        -font "Arial 9" -anchor w
     1723    Rappture::Tooltip::for $inner.wireframe "Toggle wireframe rendering of terrain geometry <w>"
    16111724
    16121725    checkbutton $inner.lighting \
     
    16151728        -command [itcl::code $this AdjustSetting terrain-lighting] \
    16161729        -font "Arial 9" -anchor w
     1730    Rappture::Tooltip::for $inner.lighting "Toggle sky lighting of terrain <l>"
    16171731
    16181732    checkbutton $inner.edges \
     
    16311745            -resolution 0.1 \
    16321746            -variable [itcl::scope _settings(time)] \
     1747            -width 10 \
    16331748            -showvalue on \
    16341749            -command [itcl::code $this AdjustSetting time]
     
    16551770    set inner [$itk_component(main) insert end \
    16561771        -title "Terrain Settings" \
    1657         -icon [Rappture::icon surface]]
     1772        -icon [Rappture::icon terrain]]
    16581773    $inner configure -borderwidth 4
    16591774
     
    16851800        0,1 $inner.vscale    -fill x   -pady 2
    16861801#        1,0 $inner.palette_l -anchor w -pady 2 \
    1687 #        1,1 $inner.palette   -fill x   -pady 2 
     1802#        1,1 $inner.palette   -fill x   -pady 2
    16881803
    16891804    blt::table configure $inner r* c* -resize none
     
    16921807
    16931808itcl::body Rappture::MapViewer::BuildLayerTab {} {
    1694 
    16951809    set fg [option get $itk_component(hull) font Font]
    16961810    #set bfg [option get $itk_component(hull) boldFont Font]
     
    17021816    set f [frame $inner.layers]
    17031817    blt::table $inner \
    1704         0,0 $f -fill both 
     1818        0,0 $f -fill both
    17051819    set _layersFrame $inner
     1820}
     1821
     1822itcl::body Rappture::MapViewer::BuildViewpointsTab {} {
     1823    set fg [option get $itk_component(hull) font Font]
     1824    #set bfg [option get $itk_component(hull) boldFont Font]
     1825
     1826    set inner [$itk_component(main) insert end \
     1827        -title "Places" \
     1828        -icon [Rappture::icon placemark16]]
     1829    $inner configure -borderwidth 4
     1830    set f [frame $inner.viewpoints]
     1831    blt::table $inner \
     1832        0,0 $f -fill both
     1833    set _viewpointsFrame $inner
    17061834}
    17071835
     
    17771905    }
    17781906
     1907    label $inner.heading_slider_l -text "Heading" -font "Arial 9"
     1908    ::scale $inner.heading_slider -font "Arial 9" \
     1909        -from -180 -to 180 -orient horizontal \
     1910        -variable [itcl::scope _view(heading)] \
     1911        -width 10 \
     1912        -showvalue on \
     1913        -command [itcl::code $this camera set heading]
     1914
     1915    blt::table $inner \
     1916            $row,0 $inner.heading_slider_l -anchor w -pady 2
     1917    blt::table $inner \
     1918            $row,1 $inner.heading_slider -fill x -anchor w -pady 2
     1919    blt::table configure $inner r$row -resize none
     1920    incr row
     1921
     1922    label $inner.pitch_slider_l -text "Pitch" -font "Arial 9"
     1923    ::scale $inner.pitch_slider -font "Arial 9" \
     1924        -from -10 -to -90 -orient horizontal \
     1925        -variable [itcl::scope _view(pitch)] \
     1926        -width 10 \
     1927        -showvalue on \
     1928        -command [itcl::code $this camera set pitch]
     1929
     1930    blt::table $inner \
     1931            $row,0 $inner.pitch_slider_l -anchor w -pady 2
     1932    blt::table $inner \
     1933            $row,1 $inner.pitch_slider -fill x -anchor w -pady 2
     1934    blt::table configure $inner r$row -resize none
     1935    incr row
     1936
    17791937    blt::table configure $inner c* r* -resize none
    17801938    blt::table configure $inner c2 -resize expand
     
    17831941
    17841942#
    1785 #  camera -- 
     1943#  camera --
    17861944#
    17871945# USAGE: camera get
     
    17921950#
    17931951itcl::body Rappture::MapViewer::camera {option args} {
    1794     switch -- $option { 
     1952    switch -- $option {
    17951953        "get" {
    17961954            # We got the camera settings from the server
     
    18542012}
    18552013
     2014itcl::body Rappture::MapViewer::GoToViewpoint { dataobj viewpoint } {
     2015    if 0 {
     2016    array set view {
     2017        x 0
     2018        y 0
     2019        z 0
     2020        heading 0
     2021        pitch -89.999
     2022        distance 0
     2023        srs ""
     2024        verticalDatum ""
     2025    }
     2026    }
     2027    array set view [$dataobj viewpoint $viewpoint]
     2028    foreach key {x y z heading pitch distance srs verticalDatum} {
     2029        if { [info exists view($key)] } {
     2030            set _view($key) $view($key)
     2031        }
     2032    }
     2033    set duration 2.0
     2034    SendCmd [list camera set $_view(x) $_view(y) $_view(z) $_view(heading) $_view(pitch) $_view(distance) $duration $_view(srs) $_view(verticalDatum)]
     2035}
     2036
    18562037itcl::body Rappture::MapViewer::GetImage { args } {
    1857     if { [image width $_image(download)] > 0 && 
     2038    if { [image width $_image(download)] > 0 &&
    18582039         [image height $_image(download)] > 0 } {
    18592040        set bytes [$_image(download) data -format "jpeg -quality 100"]
     
    18682049        -title "[Rappture::filexfer::label downloadWord] as..."
    18692050    set inner [$popup component inner]
    1870     label $inner.summary -text "" -anchor w 
     2051    label $inner.summary -text "" -anchor w
    18712052
    18722053    radiobutton $inner.image_button -text "Image File" \
    18732054        -variable [itcl::scope _downloadPopup(format)] \
    1874         -value image 
     2055        -value image
    18752056    Rappture::Tooltip::for $inner.image_button \
    18762057        "Save as digital image."
     
    18922073        2,0 $inner.image_button -anchor w -cspan 2 -padx { 4 0 } \
    18932074        4,1 $inner.cancel -width .9i -fill y \
    1894         4,0 $inner.ok -padx 2 -width .9i -fill y 
     2075        4,0 $inner.ok -padx 2 -width .9i -fill y
    18952076    blt::table configure $inner r3 -height 4
    18962077    blt::table configure $inner r4 -pady 4
     
    18982079    $inner.image_button invoke
    18992080    return $inner
     2081}
     2082
     2083itcl::body Rappture::MapViewer::ToggleGrid {} {
     2084    set _settings(grid) [expr !$_settings(grid)]
     2085    AdjustSetting grid
     2086}
     2087
     2088itcl::body Rappture::MapViewer::ToggleLighting {} {
     2089    set _settings(terrain-lighting) [expr !$_settings(terrain-lighting)]
     2090    AdjustSetting terrain-lighting
     2091}
     2092
     2093itcl::body Rappture::MapViewer::ToggleWireframe {} {
     2094    set _settings(terrain-wireframe) [expr !$_settings(terrain-wireframe)]
     2095    AdjustSetting terrain-wireframe
    19002096}
    19012097
     
    19712167                                     $layer]
    19722168                    }
    1973                 }                       
     2169                }
    19742170            }
    19752171            SendCmd "map layer opacity $settings(-opacity) $layer"
     
    20802276}
    20812277
    2082 itcl::body Rappture::MapViewer::UpdateLayerControls {} { 
     2278itcl::body Rappture::MapViewer::UpdateLayerControls {} {
    20832279    set row 0
    20842280    set inner $_layersFrame
     
    20892285    }
    20902286    set f $inner.layers
     2287    set attrib [list]
    20912288    foreach dataobj [get -objects] {
    20922289        foreach layer [$dataobj layers] {
    2093             array unset info
    2094             array set info [$dataobj layer $layer]
    2095             checkbutton $f.${layer}-visible \
     2290            array unset info
     2291            array set info [$dataobj layer $layer]
     2292            checkbutton $f.${layer}_visible \
    20962293                -text $info(label) \
    20972294                -font "Arial 9" -anchor w \
     
    20992296                -command [itcl::code $this \
    21002297                              SetLayerVisibility $dataobj $layer]
    2101             blt::table $f $row,0 $f.${layer}-visible -anchor w -pady 2 -cspan 2
    2102             Rappture::Tooltip::for $f.${layer}-visible $info(description)
     2298            blt::table $f $row,0 $f.${layer}_visible -anchor w -pady 2 -cspan 2
    21032299            incr row
    21042300            if { $info(type) != "elevation" } {
    2105                 label $f.${layer}-opacity_l -text "Opacity" -font "Arial 9"
    2106                 ::scale $f.${layer}-opacity -from 0 -to 100 \
     2301                label $f.${layer}_opacity_l -text "Opacity" -font "Arial 9"
     2302                ::scale $f.${layer}_opacity -from 0 -to 100 \
    21072303                    -orient horizontal -showvalue off \
    21082304                    -variable [itcl::scope _opacity($layer)] \
     2305                    -width 10 \
    21092306                    -command [itcl::code $this \
    21102307                                  SetLayerOpacity $dataobj $layer]
    2111                 blt::table $f $row,0 $f.${layer}-opacity_l -anchor w -pady 2
    2112                 blt::table $f $row,1 $f.${layer}-opacity -anchor w -pady 2
     2308                Rappture::Tooltip::for $f.${layer}_opacity "Set opacity of $info(label) layer"
     2309                blt::table $f $row,0 $f.${layer}_opacity_l -anchor w -pady 2
     2310                blt::table $f $row,1 $f.${layer}_opacity -anchor w -pady 2
    21132311                incr row
    21142312            }
    2115         }
    2116     }
     2313            set tooltip [list $info(description)]
     2314            if { [info exists info(attribution)] &&
     2315                 $info(attribution) != ""} {
     2316                lappend tooltip $info(attribution)
     2317            }
     2318            Rappture::Tooltip::for $f.${layer}_visible [join $tooltip \n]
     2319        }
     2320        set mapAttrib [$dataobj hints "attribution"]
     2321        if { $mapAttrib != "" } {
     2322            lappend attrib $mapAttrib
     2323        }
     2324    }
     2325    SendCmd "[list map attrib [join $attrib ,]]"
     2326    label $f.map_attrib -text [join $attrib \n] -font "Arial 9"
     2327    blt::table $f $row,0 $f.map_attrib -anchor sw -pady 2 -cspan 2
     2328    #incr row
    21172329    if { $row > 0 } {
    21182330        blt::table configure $f r* c* -resize none
     
    21212333}
    21222334
     2335itcl::body Rappture::MapViewer::UpdateViewpointControls {} {
     2336    set row 0
     2337    set inner $_viewpointsFrame
     2338    if { [winfo exists $inner.viewpoints] } {
     2339        foreach w [winfo children $inner.viewpoints] {
     2340            destroy $w
     2341        }
     2342    }
     2343    set f $inner.viewpoints
     2344    foreach dataobj [get -objects] {
     2345        foreach viewpoint [$dataobj viewpoints] {
     2346            array unset info
     2347            array set info [$dataobj viewpoint $viewpoint]
     2348            button $f.${viewpoint}_go \
     2349                -relief flat -compound left \
     2350                -image [Rappture::icon placemark16] \
     2351                -text $info(label) \
     2352                -font "Arial 9" -anchor w \
     2353                -command [itcl::code $this \
     2354                              GoToViewpoint $dataobj $viewpoint]
     2355            label $f.${viewpoint}_label \
     2356                -text $info(label) \
     2357                -font "Arial 9" -anchor w
     2358            blt::table $f $row,0 $f.${viewpoint}_go -anchor w -pady 2 -cspan 2
     2359            #blt::table $f $row,1 $f.${viewpoint}_label -anchor w -pady 2
     2360            Rappture::Tooltip::for $f.${viewpoint}_go $info(description)
     2361            incr row
     2362        }
     2363    }
     2364    if { $row > 0 } {
     2365        blt::table configure $f r* c* -resize none
     2366        blt::table configure $f r$row c1 -resize expand
     2367    }
     2368}
     2369
    21232370#
    21242371# Generate an OSG Earth file to send to server.  This is inteneded
    21252372# as a stopgap and testing tool until the protocol is fleshed out.
    2126 # 
     2373#
    21272374# Note that the lighting settings are required to be "hard-coded"
    21282375# as below for the runtime control to work.  Don't make those user
     
    21322379# the parser in OSG Earth accepts all of Tcl's forms of boolean vals.
    21332380#
    2134 itcl::body Rappture::MapViewer::EarthFile {} { 
     2381itcl::body Rappture::MapViewer::EarthFile {} {
    21352382    append out "<map"
    21362383    append out " name=\"$_mapsettings(label)\""
     
    22022449    append out "</map>\n"
    22032450    return $out
    2204 } 
     2451}
  • branches/uiuc_vtk_viewers/gui/scripts/mesh.tcl

    r4787 r5053  
    1 # -*- mode: tcl; indent-tabs-mode: nil -*- 
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    22
    33# ----------------------------------------------------------------------
     
    1818package require Itcl
    1919
    20 namespace eval Rappture { 
    21     # forward declaration 
     20namespace eval Rappture {
     21    # forward declaration
    2222}
    2323
    2424itcl::class Rappture::Mesh {
    25     private variable _xmlobj ""  ;      # Ref to XML obj with device data
    26     private variable _mesh ""    ;      # Lib obj representing this mesh
    27     private variable _dim       0;      # Dimension of mesh (1, 2, or 3)
    28     private variable _type "";          # Indicates the type of mesh.
    29     private variable _axis2units;       # System of units for x, y, z
    30     private variable _axis2labels;      # 
    31     private variable _hints 
    32     private variable _limits        ;   # Array of mesh limits. Keys are
    33                                         # xmin, xmax, ymin, ymax, ...
    34     private variable _numPoints 0   ;   # # of points in mesh
    35     private variable _numCells 0   ;    # # of cells in mesh
    36     private variable _vtkdata "";       # Mesh in vtk file format.
     25    private variable _xmlobj ""  ;      # Ref to XML obj with device data
     26    private variable _mesh ""    ;      # Lib obj representing this mesh
     27    private variable _dim        0;     # Dimension of mesh (1, 2, or 3)
     28    private variable _type "";          # Indicates the type of mesh.
     29    private variable _axis2units;       # System of units for x, y, z
     30    private variable _axis2labels;      #
     31    private variable _hints
     32    private variable _limits        ;   # Array of mesh limits. Keys are
     33                                        # xmin, xmax, ymin, ymax, ...
     34    private variable _numPoints 0   ;   # # of points in mesh
     35    private variable _numCells 0   ;    # # of cells in mesh
     36    private variable _vtkdata "";       # Mesh in vtk file format.
    3737    private variable _isValid 0;        # Indicates if the mesh is valid.
    38     constructor {xmlobj path} { 
    39         # defined below
    40     }
    41     destructor { 
    42         # defined below
     38    constructor {xmlobj path} {
     39        # defined below
     40    }
     41    destructor {
     42        # defined below
    4343    }
    4444    public method points {}
     
    5858    public method vtkdata {{what -partial}}
    5959    public method type {} {
    60         return $_type
     60        return $_type
    6161    }
    6262    public method numpoints {} {
    63         return $_numPoints
     63        return $_numPoints
    6464    }
    6565    public method numcells {} {
    66         return $_numCells
    67     }
    68 
    69     private common _xp2obj       ;      # used for fetch/release ref counting
    70     private common _obj2ref      ;      # used for fetch/release ref counting
    71     private variable _xv        ""
    72     private variable _yv        ""
    73     private variable _zv        ""
    74     private variable _xCoords   "";     # For the blt contour only
    75     private variable _yCoords   "";     # For the blt contour only
    76    
     66        return $_numCells
     67    }
     68
     69    private common _xp2obj       ;        # used for fetch/release ref counting
     70    private common _obj2ref      ;        # used for fetch/release ref counting
     71    private variable _xv        ""
     72    private variable _yv        ""
     73    private variable _zv        ""
     74    private variable _xCoords        "";  # For the blt contour only
     75    private variable _yCoords        "";  # For the blt contour only
     76
    7777    private method ReadNodesElements {path}
    78     private method GetDimension { path } 
    79     private method GetDouble { path } 
    80     private method GetInt { path } 
    81     private method InitHints {} 
     78    private method GetDimension { path }
     79    private method GetDouble { path }
     80    private method GetInt { path }
     81    private method InitHints {}
    8282    private method ReadGrid { path }
    8383    private method ReadUnstructuredGrid { path }
     
    164164    foreach u $units axis { x y z } {
    165165        if { $u != "" } {
    166             set _axis2units($axis) $u 
     166            set _axis2units($axis) $u
    167167        } else {
    168             set _axis2units($axis) $first 
     168            set _axis2units($axis) $first
    169169        }
    170170    }
     
    179179    # Meshes comes in a variety of flavors
    180180    #
    181     # Dimensionality is determined from the <dimension> tag. 
     181    # Dimensionality is determined from the <dimension> tag.
    182182    #
    183183    # <vtk> described mesh
    184184    # <element> +  <node> definitions
    185     # <grid>            rectangular mesh 
     185    # <grid>            rectangular mesh
    186186    # <unstructured>    homogeneous cell type mesh.
    187187
     
    189189    set subcount 0
    190190    foreach cname [$_mesh children] {
    191         foreach type { vtk grid unstructured } {
    192             if { $cname == $type } {
    193                 incr subcount
    194                 break
    195             }
    196         }
     191        foreach type { vtk grid unstructured } {
     192            if { $cname == $type } {
     193                incr subcount
     194                break
     195            }
     196        }
    197197    }
    198198    if {[$_mesh element "node"] != "" ||
     
    206206    }
    207207    if { $subcount > 1 } {
    208         puts stderr "WARNING: too many mesh types specified for \"$path\"."
     208        puts stderr "WARNING: too many mesh types specified for \"$path\"."
    209209        return
    210210    }
    211211    set result 0
    212212    if { [$_mesh element "vtk"] != ""} {
    213         set result [ReadVtk $path]
     213        set result [ReadVtk $path]
    214214    } elseif {[$_mesh element "grid"] != "" } {
    215         set result [ReadGrid $path]
     215        set result [ReadGrid $path]
    216216    } elseif {[$_mesh element "unstructured"] != "" } {
    217         set result [ReadUnstructuredGrid $path]
     217        set result [ReadUnstructuredGrid $path]
    218218    } elseif {[$_mesh element "node"] != "" && [$_mesh element "element"] != ""} {
    219219        set result [ReadNodesElements $path]
     
    231231
    232232    if { $_xCoords != "" } {
    233         blt::vector destroy $_xCoords
     233        blt::vector destroy $_xCoords
    234234    }
    235235    if { $_yCoords != "" } {
    236         blt::vector destroy $_yCoords
    237     }
    238 }
    239 
    240 #
    241 # vtkdata -- 
    242 #
    243 #       This is called by the field object to generate a VTK file to send to
    244 #       the remote render server.  Returns the vtkDataSet object containing
    245 #       (at this point) just the mesh.  The field object doesn't know (or
    246 #       care) what type of mesh is used.  The field object will add field
    247 #       arrays before generating output to send to the remote render server.
     236        blt::vector destroy $_yCoords
     237    }
     238}
     239
     240#
     241# vtkdata --
     242#
     243#        This is called by the field object to generate a VTK file to send to
     244#        the remote render server.  Returns the vtkDataSet object containing
     245#        (at this point) just the mesh.  The field object doesn't know (or
     246#        care) what type of mesh is used.  The field object will add field
     247#        arrays before generating output to send to the remote render server.
    248248#
    249249itcl::body Rappture::Mesh::vtkdata {{what -partial}} {
    250250    if {$what == "-full"} {
    251251        append out "# vtk DataFile Version 3.0\n"
    252         append out "[hints label]\n"
    253         append out "ASCII\n"
     252        append out "[hints label]\n"
     253        append out "ASCII\n"
    254254        append out $_vtkdata
    255255        return $out
     
    340340itcl::body Rappture::Mesh::mesh { {type "vtk"} } {
    341341    switch $type {
    342         "vtk" {
    343             return ""
    344         }
    345         default {
    346             error "Requested mesh type \"$type\" is unknown."
    347         }
     342        "vtk" {
     343            return ""
     344        }
     345        default {
     346            error "Requested mesh type \"$type\" is unknown."
     347        }
    348348    }
    349349}
     
    443443    set string [$_xmlobj get $path.dim]
    444444    if { $string == "" } {
    445         puts stderr "WARNING: no tag <dim> found in mesh \"$path\"."
     445        puts stderr "WARNING: no tag <dim> found in mesh \"$path\"."
    446446        return 0
    447447    }
     
    479479        return 0
    480480    }
    481     # Create a VTK file with the mesh in it. 
     481    # Create a VTK file with the mesh in it.
    482482    set _vtkdata [$_xmlobj get $path.vtk]
    483483    append out "# vtk DataFile Version 3.0\n"
     
    521521    set numCurvilinear 0
    522522    foreach axis { x y z } {
    523         set min    [$_xmlobj get "$path.grid.${axis}axis.min"]
    524         set max    [$_xmlobj get "$path.grid.${axis}axis.max"]
    525         set num    [$_xmlobj get "$path.grid.${axis}axis.numpoints"]
    526         set coords [$_xmlobj get "$path.grid.${axis}coords"]
    527         set dim    [$_xmlobj get "$path.grid.${axis}dim"]
    528         if { $min != "" && $max != "" && $num != "" && $num > 0 } {
    529             set ${axis}Min $min
    530             set ${axis}Max $max
    531             set ${axis}Num $num
     523        set min    [$_xmlobj get "$path.grid.${axis}axis.min"]
     524        set max    [$_xmlobj get "$path.grid.${axis}axis.max"]
     525        set num    [$_xmlobj get "$path.grid.${axis}axis.numpoints"]
     526        set coords [$_xmlobj get "$path.grid.${axis}coords"]
     527        set dim    [$_xmlobj get "$path.grid.${axis}dim"]
     528        if { $min != "" && $max != "" && $num != "" && $num > 0 } {
     529            set ${axis}Min $min
     530            set ${axis}Max $max
     531            set ${axis}Num $num
    532532            if {$min > $max} {
    533533                puts stderr "ERROR: grid $axis axis minimum larger than maximum"
    534534                return 0
    535535            }
    536             incr numUniform
    537         } elseif { $coords != "" } {
    538             incr numRectilinear
    539             set ${axis}Coords $coords
    540         } elseif { $dim != "" } {
     536            incr numUniform
     537        } elseif { $coords != "" } {
     538            incr numRectilinear
     539            set ${axis}Coords $coords
     540        } elseif { $dim != "" } {
    541541            set ${axis}Num $dim
    542542            incr numCurvilinear
     
    545545    set _dim [expr $numRectilinear + $numUniform + $numCurvilinear]
    546546    if { $_dim == 0 } {
    547         # No data found.
     547        # No data found.
    548548        puts stderr "WARNING: bad grid \"$path\": no data found"
    549         return 0
     549        return 0
    550550    }
    551551    if { $numCurvilinear > 0 } {
     
    560560            return 0
    561561        }
    562         if { ![info exists xNum] } {
     562        if { ![info exists xNum] } {
    563563            puts stderr "WARNING: bad grid \"$path\": invalid dimensions for curvilinear grid: missing <xdim> from grid description."
    564564            return 0
     
    572572        if { [info exists zNum] } {
    573573            set _dim 3
    574             set _numPoints [expr $xNum * $yNum * $zNum]
     574            set _numPoints [expr $xNum * $yNum * $zNum]
    575575            set _numCells [expr ($xNum > 1 ? ($xNum - 1) : 1) * ($yNum > 1 ? ($yNum - 1) : 1) * ($zNum > 1 ? ($zNum - 1) : 1)]
    576576            if { ($_numPoints*3) != $numCoords } {
     
    583583            }
    584584            $all split $xv $yv $zv
    585             foreach axis {x y z} {
     585            foreach axis {x y z} {
    586586                set vector [set ${axis}v]
    587587                set _limits($axis) [$vector limits]
    588             }
    589             append out "DATASET STRUCTURED_GRID\n"
    590             append out "DIMENSIONS $xNum $yNum $zNum\n"
    591             append out "POINTS $_numPoints double\n"
     588            }
     589            append out "DATASET STRUCTURED_GRID\n"
     590            append out "DIMENSIONS $xNum $yNum $zNum\n"
     591            append out "POINTS $_numPoints double\n"
    592592            append out [$all range 0 end]
    593593            append out "\n"
    594             set _vtkdata $out
     594            set _vtkdata $out
    595595        } elseif { [info exists yNum] } {
    596596            set _dim 2
    597             set _numPoints [expr $xNum * $yNum]
     597            set _numPoints [expr $xNum * $yNum]
    598598            set _numCells [expr ($xNum > 1 ? ($xNum - 1) : 1) * ($yNum > 1 ? ($yNum - 1) : 1)]
    599599            if { ($_numPoints*2) != $numCoords } {
     
    605605                return 0
    606606            }
    607             foreach axis {x y} {
     607            foreach axis {x y} {
    608608                set vector [set ${axis}v]
    609609                set _limits($axis) [$vector limits]
    610             }
     610            }
    611611            set _limits(z) [list 0 0]
    612612            $zv seq 0 0 [$xv length]
    613613            $all merge $xv $yv $zv
    614             append out "DATASET STRUCTURED_GRID\n"
    615             append out "DIMENSIONS $xNum $yNum 1\n"
    616             append out "POINTS $_numPoints double\n"
     614            append out "DATASET STRUCTURED_GRID\n"
     615            append out "DIMENSIONS $xNum $yNum 1\n"
     616            append out "POINTS $_numPoints double\n"
    617617            append out [$all range 0 end]
    618618            append out "\n"
    619             set _vtkdata $out
     619            set _vtkdata $out
    620620        } else {
    621621            set _dim 1
     
    632632            $zv seq 0 0 [$xv length]
    633633            $all merge $xv $yv $zv
    634             append out "DATASET STRUCTURED_GRID\n"
    635             append out "DIMENSIONS $xNum 1 1\n"
    636             append out "POINTS $_numPoints double\n"
     634            append out "DATASET STRUCTURED_GRID\n"
     635            append out "DIMENSIONS $xNum 1 1\n"
     636            append out "POINTS $_numPoints double\n"
    637637            append out [$all range 0 end]
    638638            append out "\n"
    639             set _vtkdata $out
    640         }
     639            set _vtkdata $out
     640        }
    641641        blt::vector destroy $all $xv $yv $zv
    642         return 1
     642        return 1
    643643    }
    644644    if { $numRectilinear == 0 && $numUniform > 0} {
    645         # This is the special case where all axes 2D/3D are uniform. 
     645        # This is the special case where all axes 2D/3D are uniform.
    646646        # This results in a STRUCTURED_POINTS
    647647        if { $_dim == 1 } {
     
    651651                set xSpace [expr ($xMax - $xMin) / double($xNum - 1)]
    652652            }
    653             set _numPoints $xNum
     653            set _numPoints $xNum
    654654            set _numCells [expr $xNum - 1]
    655             append out "DATASET STRUCTURED_POINTS\n"
    656             append out "DIMENSIONS $xNum 1 1\n"
    657             append out "ORIGIN $xMin 0 0\n"
    658             append out "SPACING $xSpace 0 0\n"
    659             set _vtkdata $out
     655            append out "DATASET STRUCTURED_POINTS\n"
     656            append out "DIMENSIONS $xNum 1 1\n"
     657            append out "ORIGIN $xMin 0 0\n"
     658            append out "SPACING $xSpace 0 0\n"
     659            set _vtkdata $out
    660660            set _limits(x) [list $xMin $xMax]
    661661            set _limits(y) [list 0 0]
    662662            set _limits(z) [list 0 0]
    663         } elseif { $_dim == 2 } {
     663        } elseif { $_dim == 2 } {
    664664            if {$xNum == 1} {
    665665                set xSpace 0
     
    672672                set ySpace [expr ($yMax - $yMin) / double($yNum - 1)]
    673673            }
    674             set _numPoints [expr $xNum * $yNum]
     674            set _numPoints [expr $xNum * $yNum]
    675675            set _numCells [expr ($xNum > 1 ? ($xNum - 1) : 1) * ($yNum > 1 ? ($yNum - 1) : 1)]
    676             append out "DATASET STRUCTURED_POINTS\n"
    677             append out "DIMENSIONS $xNum $yNum 1\n"
    678             append out "ORIGIN $xMin $yMin 0\n"
    679             append out "SPACING $xSpace $ySpace 0\n"
    680             set _vtkdata $out
    681             foreach axis {x y} {
    682                 set _limits($axis) [list [set ${axis}Min] [set ${axis}Max]]
    683             }
     676            append out "DATASET STRUCTURED_POINTS\n"
     677            append out "DIMENSIONS $xNum $yNum 1\n"
     678            append out "ORIGIN $xMin $yMin 0\n"
     679            append out "SPACING $xSpace $ySpace 0\n"
     680            set _vtkdata $out
     681            foreach axis {x y} {
     682                set _limits($axis) [list [set ${axis}Min] [set ${axis}Max]]
     683            }
    684684            set _limits(z) [list 0 0]
    685         } elseif { $_dim == 3 } {
     685        } elseif { $_dim == 3 } {
    686686            if {$xNum == 1} {
    687687                set xSpace 0
     
    699699                set zSpace [expr ($zMax - $zMin) / double($zNum - 1)]
    700700            }
    701             set _numPoints [expr $xNum * $yNum * $zNum]
     701            set _numPoints [expr $xNum * $yNum * $zNum]
    702702            set _numCells [expr ($xNum > 1 ? ($xNum - 1) : 1) * ($yNum > 1 ? ($yNum - 1) : 1) * ($zNum > 1 ? ($zNum - 1) : 1)]
    703             append out "DATASET STRUCTURED_POINTS\n"
    704             append out "DIMENSIONS $xNum $yNum $zNum\n"
    705             append out "ORIGIN $xMin $yMin $zMin\n"
    706             append out "SPACING $xSpace $ySpace $zSpace\n"
    707             set _vtkdata $out
    708             foreach axis {x y z} {
    709                 set _limits($axis) [list [set ${axis}Min] [set ${axis}Max]]
    710             }
    711         } else {
    712             puts stderr "WARNING: bad grid \"$path\": bad dimension \"$_dim\""
     703            append out "DATASET STRUCTURED_POINTS\n"
     704            append out "DIMENSIONS $xNum $yNum $zNum\n"
     705            append out "ORIGIN $xMin $yMin $zMin\n"
     706            append out "SPACING $xSpace $ySpace $zSpace\n"
     707            set _vtkdata $out
     708            foreach axis {x y z} {
     709                set _limits($axis) [list [set ${axis}Min] [set ${axis}Max]]
     710            }
     711        } else {
     712            puts stderr "WARNING: bad grid \"$path\": bad dimension \"$_dim\""
    713713            return 0
    714         }
    715         return 1
     714        }
     715        return 1
    716716    }
    717717    # This is the hybrid case.  Some axes are uniform, others are nonuniform.
    718718    set xv [blt::vector create \#auto]
    719719    if { [info exists xMin] } {
    720         $xv seq $xMin $xMax $xNum
    721     } else {
    722         $xv set [$_xmlobj get $path.grid.xcoords]
    723         set xMin [$xv min]
    724         set xMax [$xv max]
    725         set xNum [$xv length]
     720        $xv seq $xMin $xMax $xNum
     721    } else {
     722        $xv set [$_xmlobj get $path.grid.xcoords]
     723        set xMin [$xv min]
     724        set xMax [$xv max]
     725        set xNum [$xv length]
    726726    }
    727727    set yv [blt::vector create \#auto]
     
    740740    set zv [blt::vector create \#auto]
    741741    if { $_dim == 3 } {
    742         if { [info exists zMin] } {
    743             $zv seq $zMin $zMax $zNum
    744         }  else {
    745             $zv set [$_xmlobj get $path.grid.zcoords]
    746             set zMin [$zv min]
    747             set zMax [$zv max]
    748             set zNum [$zv length]
    749         }
    750     } else {
    751         set zNum 1
     742        if { [info exists zMin] } {
     743            $zv seq $zMin $zMax $zNum
     744        }  else {
     745            $zv set [$_xmlobj get $path.grid.zcoords]
     746            set zMin [$zv min]
     747            set zMax [$zv max]
     748            set zNum [$zv length]
     749        }
     750    } else {
     751        set zNum 1
    752752    }
    753753    if { $_dim == 3 } {
    754         set _numPoints [expr $xNum * $yNum * $zNum]
     754        set _numPoints [expr $xNum * $yNum * $zNum]
    755755        set _numCells [expr ($xNum > 1 ? ($xNum - 1) : 1) * ($yNum > 1 ? ($yNum - 1) : 1) * ($zNum > 1 ? ($zNum - 1) : 1)]
    756         append out "DATASET RECTILINEAR_GRID\n"
    757         append out "DIMENSIONS $xNum $yNum $zNum\n"
    758         append out "X_COORDINATES $xNum double\n"
    759         append out [$xv range 0 end]
    760         append out "\n"
    761         append out "Y_COORDINATES $yNum double\n"
    762         append out [$yv range 0 end]
    763         append out "\n"
    764         append out "Z_COORDINATES $zNum double\n"
    765         append out [$zv range 0 end]
    766         append out "\n"
    767         set _vtkdata $out
    768         foreach axis {x y z} {
    769             if { [info exists ${axis}Min] } {
    770                 set _limits($axis) [list [set ${axis}Min] [set ${axis}Max]]
    771             }
    772         }
     756        append out "DATASET RECTILINEAR_GRID\n"
     757        append out "DIMENSIONS $xNum $yNum $zNum\n"
     758        append out "X_COORDINATES $xNum double\n"
     759        append out [$xv range 0 end]
     760        append out "\n"
     761        append out "Y_COORDINATES $yNum double\n"
     762        append out [$yv range 0 end]
     763        append out "\n"
     764        append out "Z_COORDINATES $zNum double\n"
     765        append out [$zv range 0 end]
     766        append out "\n"
     767        set _vtkdata $out
     768        foreach axis {x y z} {
     769            if { [info exists ${axis}Min] } {
     770                set _limits($axis) [list [set ${axis}Min] [set ${axis}Max]]
     771            }
     772        }
    773773    } elseif { $_dim == 2 } {
    774         set _numPoints [expr $xNum * $yNum]
     774        set _numPoints [expr $xNum * $yNum]
    775775        set _numCells [expr ($xNum > 1 ? ($xNum - 1) : 1) * ($yNum > 1 ? ($yNum - 1) : 1)]
    776         append out "DATASET RECTILINEAR_GRID\n"
    777         append out "DIMENSIONS $xNum $yNum 1\n"
    778         append out "X_COORDINATES $xNum double\n"
    779         append out [$xv range 0 end]
    780         append out "\n"
    781         append out "Y_COORDINATES $yNum double\n"
    782         append out [$yv range 0 end]
    783         append out "\n"
    784         append out "Z_COORDINATES 1 double\n"
    785         append out "0\n"
    786         foreach axis {x y} {
    787             if { [info exists ${axis}Min] } {
    788                 set _limits($axis) [list [set ${axis}Min] [set ${axis}Max]]
    789             }
    790         }
     776        append out "DATASET RECTILINEAR_GRID\n"
     777        append out "DIMENSIONS $xNum $yNum 1\n"
     778        append out "X_COORDINATES $xNum double\n"
     779        append out [$xv range 0 end]
     780        append out "\n"
     781        append out "Y_COORDINATES $yNum double\n"
     782        append out [$yv range 0 end]
     783        append out "\n"
     784        append out "Z_COORDINATES 1 double\n"
     785        append out "0\n"
     786        foreach axis {x y} {
     787            if { [info exists ${axis}Min] } {
     788                set _limits($axis) [list [set ${axis}Min] [set ${axis}Max]]
     789            }
     790        }
    791791        set _limits(z) [list 0 0]
    792         set _vtkdata $out
     792        set _vtkdata $out
    793793    } elseif { $_dim == 1 } {
    794794        set _numPoints $xNum
    795795        set _numCells [expr $xNum - 1]
    796         append out "DATASET RECTILINEAR_GRID\n"
    797         append out "DIMENSIONS $xNum 1 1\n"
    798         append out "X_COORDINATES $xNum double\n"
    799         append out [$xv range 0 end]
    800         append out "\n"
    801         append out "Y_COORDINATES 1 double\n"
    802         append out "0\n"
    803         append out "Z_COORDINATES 1 double\n"
    804         append out "0\n"
     796        append out "DATASET RECTILINEAR_GRID\n"
     797        append out "DIMENSIONS $xNum 1 1\n"
     798        append out "X_COORDINATES $xNum double\n"
     799        append out [$xv range 0 end]
     800        append out "\n"
     801        append out "Y_COORDINATES 1 double\n"
     802        append out "0\n"
     803        append out "Z_COORDINATES 1 double\n"
     804        append out "0\n"
    805805        if { [info exists xMin] } {
    806806            set _limits(x) [list $xMin $xMax]
     
    808808        set _limits(y) [list 0 0]
    809809        set _limits(z) [list 0 0]
    810         set _vtkdata $out
    811     } else {
    812         puts stderr "WARNING: bad grid \"$path\": invalid dimension \"$_dim\""
     810        set _vtkdata $out
     811    } else {
     812        puts stderr "WARNING: bad grid \"$path\": invalid dimension \"$_dim\""
    813813        return 0
    814814    }
    815     blt::vector destroy $xv $yv $zv 
     815    blt::vector destroy $xv $yv $zv
    816816    return 1
    817817}
     
    847847    set celltypes {}
    848848    foreach { a b c } $triangles {
    849         append data " 3 $a $b $c\n"
    850         append celltypes "5\n"
    851         incr _numCells
     849        append data " 3 $a $b $c\n"
     850        append celltypes "5\n"
     851        incr _numCells
    852852    }
    853853    append out "DATASET UNSTRUCTURED_GRID\n"
    854854    append out "POINTS $_numPoints double\n"
    855855    foreach x [$xv range 0 end] y [$yv range 0 end] z [$zv range 0 end] {
    856         append out " $x $y $z\n"
     856        append out " $x $y $z\n"
    857857    }
    858858    set count [expr $_numCells * 4]
     
    879879    set celltypes {}
    880880    foreach { a b c d } $quads {
    881         append data " 4 $a $b $c $d\n"
    882         append celltypes "9\n"
    883         incr _numCells
     881        append data " 4 $a $b $c $d\n"
     882        append celltypes "9\n"
     883        incr _numCells
    884884    }
    885885    append out "DATASET UNSTRUCTURED_GRID\n"
    886886    append out "POINTS $_numPoints double\n"
    887887    foreach x [$xv range 0 end] y [$yv range 0 end] z [$zv range 0 end] {
    888         append out " $x $y $z\n"
     888        append out " $x $y $z\n"
    889889    }
    890890    set count [expr $_numCells * 5]
     
    916916            continue
    917917        }
    918         append data " $numIndices $line\n"
    919         incr _numCells
     918        append data " $numIndices $line\n"
     919        incr _numCells
    920920        set count [expr $count + $numIndices + 1]
    921921    }
     
    923923    append out "POINTS $_numPoints double\n"
    924924    foreach x [$xv range 0 end] y [$yv range 0 end] z [$zv range 0 end] {
    925         append out " $x $y $z\n"
     925        append out " $x $y $z\n"
    926926    }
    927927    append out "VERTICES $_numCells $count\n"
     
    950950            continue
    951951        }
    952         append data " $numIndices $line\n"
    953         incr _numCells
     952        append data " $numIndices $line\n"
     953        incr _numCells
    954954        set count [expr $count + $numIndices + 1]
    955955    }
     
    957957    append out "POINTS $_numPoints double\n"
    958958    foreach x [$xv range 0 end] y [$yv range 0 end] z [$zv range 0 end] {
    959         append out " $x $y $z\n"
     959        append out " $x $y $z\n"
    960960    }
    961961    append out "LINES $_numCells $count\n"
     
    984984            continue
    985985        }
    986         append data " $numIndices $line\n"
    987         incr _numCells
     986        append data " $numIndices $line\n"
     987        incr _numCells
    988988        set count [expr $count + $numIndices + 1]
    989989    }
     
    991991    append out "POINTS $_numPoints double\n"
    992992    foreach x [$xv range 0 end] y [$yv range 0 end] z [$zv range 0 end] {
    993         append out " $x $y $z\n"
     993        append out " $x $y $z\n"
    994994    }
    995995    append out "POLYGONS $_numCells $count\n"
     
    10181018            continue
    10191019        }
    1020         append data " $numIndices $line\n"
    1021         incr _numCells
     1020        append data " $numIndices $line\n"
     1021        incr _numCells
    10221022        set count [expr $count + $numIndices + 1]
    10231023    }
     
    10251025    append out "POINTS $_numPoints double\n"
    10261026    foreach x [$xv range 0 end] y [$yv range 0 end] z [$zv range 0 end] {
    1027         append out " $x $y $z\n"
     1027        append out " $x $y $z\n"
    10281028    }
    10291029    append out "TRIANGLE_STRIPS $_numCells $count\n"
     
    10471047    set celltypes {}
    10481048    foreach { a b c d } $tetras {
    1049         append data " 4 $a $b $c $d\n"
    1050         append celltypes "10\n"
    1051         incr _numCells
     1049        append data " 4 $a $b $c $d\n"
     1050        append celltypes "10\n"
     1051        incr _numCells
    10521052    }
    10531053    append out "DATASET UNSTRUCTURED_GRID\n"
    10541054    append out "POINTS $_numPoints double\n"
    10551055    foreach x [$xv range 0 end] y [$yv range 0 end] z [$zv range 0 end] {
    1056         append out " $x $y $z\n"
     1056        append out " $x $y $z\n"
    10571057    }
    10581058    set count [expr $_numCells * 5]
     
    10761076    set celltypes {}
    10771077    foreach { a b c d e f g h } $hexas {
    1078         append data " 8 $a $b $c $d $e $f $g $h\n"
    1079         append celltypes "12\n"
    1080         incr _numCells
     1078        append data " 8 $a $b $c $d $e $f $g $h\n"
     1079        append celltypes "12\n"
     1080        incr _numCells
    10811081    }
    10821082    append out "DATASET UNSTRUCTURED_GRID\n"
    10831083    append out "POINTS $_numPoints double\n"
    10841084    foreach x [$xv range 0 end] y [$yv range 0 end] z [$zv range 0 end] {
    1085         append out " $x $y $z\n"
     1085        append out " $x $y $z\n"
    10861086    }
    10871087    set count [expr $_numCells * 9]
     
    11051105    set celltypes {}
    11061106    foreach { a b c d e f } $wedges {
    1107         append data " 6 $a $b $c $d $e $f\n"
    1108         append celltypes "13\n"
    1109         incr _numCells
     1107        append data " 6 $a $b $c $d $e $f\n"
     1108        append celltypes "13\n"
     1109        incr _numCells
    11101110    }
    11111111    append out "DATASET UNSTRUCTURED_GRID\n"
    11121112    append out "POINTS $_numPoints double\n"
    11131113    foreach x [$xv range 0 end] y [$yv range 0 end] z [$zv range 0 end] {
    1114         append out " $x $y $z\n"
     1114        append out " $x $y $z\n"
    11151115    }
    11161116    set count [expr $_numCells * 7]
     
    11341134    set celltypes {}
    11351135    foreach { a b c d e } $pyramids {
    1136         append data " 5 $a $b $c $d $e\n"
    1137         append celltypes "14\n"
    1138         incr _numCells
     1136        append data " 5 $a $b $c $d $e\n"
     1137        append celltypes "14\n"
     1138        incr _numCells
    11391139    }
    11401140    append out "DATASET UNSTRUCTURED_GRID\n"
    11411141    append out "POINTS $_numPoints double\n"
    11421142    foreach x [$xv range 0 end] y [$yv range 0 end] z [$zv range 0 end] {
    1143         append out " $x $y $z\n"
     1143        append out " $x $y $z\n"
    11441144    }
    11451145    set count [expr $_numCells * 6]
     
    11531153
    11541154    set _vtkdata $out
    1155     return 1 
     1155    return 1
    11561156}
    11571157
     
    12411241    set celltypes [$_xmlobj get $path.unstructured.celltypes]
    12421242    if { $numCells == 0 && $celltypes != "" } {
    1243         puts stderr "WARNING: bad unstuctured grid \"$path\": no <cells> description found."
     1243        puts stderr "WARNING: bad unstuctured grid \"$path\": no <cells> description found."
    12441244        return 0
    12451245    }
     
    12661266        }
    12671267    }
    1268     # Step 2: Allow points to be specified as <points> or 
     1268    # Step 2: Allow points to be specified as <points> or
    12691269    #         <xcoords>, <ycoords>, <zcoords>.  Split and convert into
    12701270    #         3 vectors, one for each coordinate.
     
    14141414    set data {}
    14151415    foreach cname [$_xmlobj children -type node $path] {
    1416         append data "[$_xmlobj get $path.$cname]\n"
    1417     }   
     1416        append data "[$_xmlobj get $path.$cname]\n"
     1417    }
    14181418    Rappture::ReadPoints $data _dim points
    14191419    if { $_dim == 2 } {
    1420         set all [blt::vector create \#auto]
    1421         set xv [blt::vector create \#auto]
    1422         set yv [blt::vector create \#auto]
    1423         set zv [blt::vector create \#auto]
    1424         $all set $points
    1425         $all split $xv $yv
    1426         set _numPoints [$xv length]
     1420        set all [blt::vector create \#auto]
     1421        set xv [blt::vector create \#auto]
     1422        set yv [blt::vector create \#auto]
     1423        set zv [blt::vector create \#auto]
     1424        $all set $points
     1425        $all split $xv $yv
     1426        set _numPoints [$xv length]
    14271427        set _limits(x) [$xv limits]
    14281428        set _limits(y) [$yv limits]
    14291429        set _limits(z) [list 0 0]
    1430         # 2D Dataset. All Z coordinates are 0
    1431         $zv seq 0.0 0.0 $_numPoints
    1432         $all merge $xv $yv $zv
    1433         set points [$all range 0 end]
    1434         blt::vector destroy $all $xv $yv $zv
     1430        # 2D Dataset. All Z coordinates are 0
     1431        $zv seq 0.0 0.0 $_numPoints
     1432        $all merge $xv $yv $zv
     1433        set points [$all range 0 end]
     1434        blt::vector destroy $all $xv $yv $zv
    14351435    } elseif { $_dim == 3 } {
    1436         set all [blt::vector create \#auto]
    1437         set xv [blt::vector create \#auto]
    1438         set yv [blt::vector create \#auto]
    1439         set zv [blt::vector create \#auto]
    1440         $all set $points
    1441         $all split $xv $yv $zv
    1442         set _numPoints [$xv length]
     1436        set all [blt::vector create \#auto]
     1437        set xv [blt::vector create \#auto]
     1438        set yv [blt::vector create \#auto]
     1439        set zv [blt::vector create \#auto]
     1440        $all set $points
     1441        $all split $xv $yv $zv
     1442        set _numPoints [$xv length]
    14431443        set _limits(x) [$xv limits]
    14441444        set _limits(y) [$yv limits]
    14451445        set _limits(z) [$zv limits]
    1446         set points [$all range 0 end]
    1447         blt::vector destroy $all $xv $yv $zv
    1448     } else {
    1449         error "bad dimension \"$_dim\" for nodes mesh"
     1446        set points [$all range 0 end]
     1447        blt::vector destroy $all $xv $yv $zv
     1448    } else {
     1449        error "bad dimension \"$_dim\" for nodes mesh"
    14501450    }
    14511451    array set node2celltype {
    1452         3 5
    1453         4 10
    1454         8 12
    1455         6 13
    1456         5 14
     1452        3 5
     1453        4 10
     1454        8 12
     1455        6 13
     1456        5 14
    14571457    }
    14581458    set count 0
     
    14631463    foreach cname [$_xmlobj children -type element $path] {
    14641464        set nodeList [$_mesh get $cname.nodes]
    1465         set numNodes [llength $nodeList]
    1466         if { ![info exists node2celltype($numNodes)] } {
    1467             puts stderr "WARNING: bad nodes/elements mesh \$path\": unknown number of indices \"$_numNodes\": should be 3, 4, 5, 6, or 8"
    1468             return 0
    1469         }
    1470         set celltype $node2celltype($numNodes)
    1471         append celltypes "  $celltype\n"
     1465        set numNodes [llength $nodeList]
     1466        if { ![info exists node2celltype($numNodes)] } {
     1467            puts stderr "WARNING: bad nodes/elements mesh \$path\": unknown number of indices \"$_numNodes\": should be 3, 4, 5, 6, or 8"
     1468            return 0
     1469        }
     1470        set celltype $node2celltype($numNodes)
     1471        append celltypes "  $celltype\n"
    14721472        if { $celltype == 12 } {
    14731473            # Formerly used voxels instead of hexahedrons. We're converting
     
    14791479            }
    14801480            set nodeList $newList
    1481         } 
    1482         append data "  $numNodes $nodeList\n"
    1483         incr _numCells
    1484         incr count $numNodes
    1485         incr count;                     # One extra for the VTK celltype id.
     1481        }
     1482        append data "  $numNodes $nodeList\n"
     1483        incr _numCells
     1484        incr count $numNodes
     1485        incr count;                        # One extra for the VTK celltype id.
    14861486    }
    14871487
     
    14961496    append out "\n"
    14971497    set _vtkdata $out
    1498     set _isValid 1 
     1498    set _isValid 1
    14991499}
    15001500
  • branches/uiuc_vtk_viewers/gui/scripts/moleculeViewer.tcl

    r3813 r5053  
    1 # -*- mode: tcl; indent-tabs-mode: nil -*- 
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    22# ----------------------------------------------------------------------
    33#  COMPONENT: MoleculeViewer - view a molecule in 3D
     
    2727    itk_option define -device device Device ""
    2828
    29     constructor {tool args} { 
    30         # defined below 
    31     }
    32     destructor { 
    33         # defined below 
     29    constructor {tool args} {
     30        # defined below
     31    }
     32    destructor {
     33        # defined below
    3434    }
    3535
     
    3838    public method delete {args}
    3939    public method snap {w h}
    40     public method parameters {title args} { 
    41         # do nothing 
     40    public method parameters {title args} {
     41        # do nothing
    4242    }
    4343    public method emblems {option}
     
    6363    private variable _download "";# snapshot for download
    6464}
    65                                                                                
     65
    6666itk::usual MoleculeViewer {
    6767}
     
    236236    }
    237237    array set params $settings
    238  
     238
    239239    set pos [lsearch -exact $_dlist $dataobj]
    240240
     
    243243            error "bad value \"$dataobj\": should be Rappture::library object"
    244244        }
    245    
     245
    246246        set emblem [$dataobj get components.molecule.about.emblems]
    247247        if {$emblem == "" || ![string is boolean $emblem] || !$emblem} {
  • branches/uiuc_vtk_viewers/gui/scripts/molvisviewer.tcl

    r4669 r5053  
    1 # -*- mode: tcl; indent-tabs-mode: nil -*- 
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    22
    33# ----------------------------------------------------------------------
     
    5252
    5353    private variable _active;           # array of active models.
    54     private variable _obj2models;       # array containing list of models 
     54    private variable _obj2models;       # array containing list of models
    5555                                        # for each data object.
    5656    private variable _view
     
    6363    private variable _imagecache
    6464    private variable _state
    65     private variable _labels  "default"
     65    private variable _labels "default"
    6666    private variable _cacheid ""
    6767    private variable _cacheimage ""
    68     private variable _first     ""
    69 
    70     private common _settings  ;         # Array of settings for all known 
     68    private variable _first ""
     69
     70    private common _settings  ;         # Array of settings for all known
    7171                                        # widgets
    7272    private variable _initialized
     
    8181    private variable _width
    8282    private variable _height
    83     private variable _reset 1;          # Restore camera settings
     83    private variable _reset 1;          # Restore camera settings
    8484    private variable _cell 0;           # Restore camera settings
    8585
     
    9696    }
    9797    private method BuildSettingsTab {}
    98     private method DoResize {} 
    99     private method DoRotate {} 
    100     private method DoUpdate {} 
    101     private method EventuallyResize { w h } 
    102     private method EventuallyRotate { a b c } 
    103     private method EventuallyChangeSettings { args } 
     98    private method DoResize {}
     99    private method DoRotate {}
     100    private method DoUpdate {}
     101    private method EventuallyResize { w h }
     102    private method EventuallyRotate { a b c }
     103    private method EventuallyChangeSettings { args }
    104104    private method GetImage { widget }
    105105    private method ReceiveImage { size cacheid frame rock }
     
    107107    private method AddImageControls { frame widget }
    108108    private method SetWaitVariable { value } {
    109         set _getimage $value 
     109        set _getimage $value
    110110    }
    111111    private method WaitForResponse {} {
     
    125125    public method Connect {}
    126126    public method Disconnect {}
    127     public method ResetView {} 
     127    public method ResetView {}
    128128    public method add {dataobj {options ""}}
    129129    public method delete {args}
     
    132132    public method isconnected {}
    133133    public method labels {option {model "all"}}
    134     public method parameters {title args} { 
    135         # do nothing 
     134    public method parameters {title args} {
     135        # do nothing
    136136    }
    137137
     
    236236        $this-showlabels-initialized no
    237237    }]
    238    
     238
    239239    itk_component add 3dview {
    240240        label $itk_component(plotarea).view -image $_image(plot) \
     
    294294    Rappture::Tooltip::for $itk_component(labels) \
    295295        "Show/hide the labels on atoms"
    296     pack $itk_component(labels) -padx 2 -pady {6 2} 
     296    pack $itk_component(labels) -padx 2 -pady {6 2}
    297297
    298298    itk_component add rock {
     
    303303            -variable [itcl::scope _settings($this-rock)]
    304304    }
    305     pack $itk_component(rock) -padx 2 -pady 2 
     305    pack $itk_component(rock) -padx 2 -pady 2
    306306    Rappture::Tooltip::for $itk_component(rock) "Rock model back and forth"
    307307
     
    319319    BuildSettingsTab
    320320
    321     # HACK ALERT. Initially force a requested width of the 3dview label. 
     321    # HACK ALERT. Initially force a requested width of the 3dview label.
    322322
    323323    # It's a chicken-and-the-egg problem.  The size of the 3dview label is set
     
    463463            if { $showlabels != "" && [string is boolean $showlabels] } {
    464464                set _settings($this-showlabels) $showlabels
    465             } 
     465            }
    466466        }
    467467
     
    567567                    -variable [itcl::scope _downloadPopup(format)] \
    568568                    -font "Arial 10 " \
    569                     -value pdb 
     569                    -value pdb
    570570                Rappture::Tooltip::for $inner.pdb \
    571571                    "Save as PDB Protein Data Bank format file."
     
    573573                    -variable [itcl::scope _downloadPopup(format)] \
    574574                    -font "Arial 10 " \
    575                     -value image 
     575                    -value image
    576576                Rappture::Tooltip::for $inner.image \
    577577                    "Save as image."
     
    589589                blt::table $f \
    590590                    0,0 $f.ok \
    591                     0,1 $f.cancel 
     591                    0,1 $f.cancel
    592592                blt::table $inner \
    593593                    0,0 $inner.summary -anchor w \
     
    628628                    } else {
    629629                        set inner [$popup component inner]
    630                     }                   
     630                    }
    631631                    update
    632632                    # Activate the popup and call for the output.
     
    635635                    $popup activate $widget left
    636636                    set bool [WaitForResponse]
    637                     $popup deactivate 
     637                    $popup deactivate
    638638                    if { $bool } {
    639639                        return [GetImage $widget]
     
    674674        return 0
    675675    }
    676     set _reset 1 
     676    set _reset 1
    677677    set result [VisViewer::Connect $hosts]
    678678    if { $result } {
     
    684684            set info {}
    685685            set user "???"
    686             if { [info exists env(USER)] } {
     686            if { [info exists env(USER)] } {
    687687                set user $env(USER)
    688             }
     688            }
    689689            set session "???"
    690             if { [info exists env(SESSION)] } {
     690            if { [info exists env(SESSION)] } {
    691691                set session $env(SESSION)
    692             }
     692            }
    693693            lappend info "version" "$Rappture::version"
    694694            lappend info "build" "$Rappture::build"
     
    760760    incr count
    761761    if { $cacheid != $_cacheid } {
    762         array unset _imagecache 
     762        array unset _imagecache
    763763        set _cacheid $cacheid
    764764    }
     
    798798        "sticks"      "sticks"          \
    799799        "lines"       "lines"           \
    800         "cartoon"     "cartoon"         
     800        "cartoon"     "cartoon"
    801801
    802802    bind $inner.rep <<Value>> [itcl::code $this Representation]
     
    883883    # Turn on buffering of commands to the server.  We don't want to
    884884    # be preempted by a server disconnect/reconnect (that automatically
    885     # generates a new call to Rebuild).   
     885    # generates a new call to Rebuild).
    886886    StartBufferingCommands
    887887    set _cell 0
     
    897897    set dlist [get]
    898898    foreach dataobj $dlist {
    899         if { $_first == "" } {
    900             set _first $dataobj
    901         }
     899        if { $_first == "" } {
     900            set _first $dataobj
     901        }
    902902        set model [$dataobj get components.molecule.model]
    903903        if {"" == $model } {
     
    906906            set model $model$suffix
    907907        }
    908         lappend _obj2models($dataobj) $model 
     908        lappend _obj2models($dataobj) $model
    909909        set state [$dataobj get components.molecule.state]
    910         if {"" == $state} { 
    911             set state $_state(server) 
     910        if {"" == $state} {
     911            set state $_state(server)
    912912        }
    913913        if { ![info exists _mlist($model)] } {  # new, turn on
    914914            set _mlist($model) 2
    915915        } elseif { $_mlist($model) == 1 } {     # on, leave on
    916             set _mlist($model) 3 
     916            set _mlist($model) 3
    917917        } elseif { $_mlist($model) == 0 } {     # off, turn on
    918918            set _mlist($model) 2
     
    10021002                        set charge     ""
    10031003                        if { "" == $lammpstypemap} {
    1004                             set atom $type 
     1004                            set atom $type
    10051005                        } else {
    10061006                            set atom [lindex $lammpstypemap [expr {$type - 1}]]
     
    10121012                        append data3 $pdbline
    10131013                    }
    1014                     # only read first model 
     1014                    # only read first model
    10151015                    if {[regexp "^ITEM: ATOMS" $lammpsline]} {
    10161016                      incr modelcount
     
    10251025                    set numBytes [string length $data3]
    10261026
    1027                     # We know we're buffered here, so append the "loadpdb" 
     1027                    # We know we're buffered here, so append the "loadpdb"
    10281028                    # command with the data payload immediately afterwards.
    10291029                    ServerCmd "loadpdb -defer follows $model $state $numBytes"
     
    10571057        }
    10581058    }
    1059        
     1059
    10601060    # enable/disable models as required (0=off->off, 1=on->off, 2=off->on,
    10611061    # 3=on->on)
     
    10741074        }
    10751075        if { $_mlist($model) == 1 } {
    1076             if {  [info exists _model($model-newtransparency)] || 
     1076            if {  [info exists _model($model-newtransparency)] ||
    10771077                  [info exists _model($model-newrep)] } {
    10781078                if { ![info exists _model($model-newrep)] } {
     
    11181118        # Set or restore viewing parameters.  We do this for the first
    11191119        # model and assume this works for everything else.
    1120         set w  [winfo width $itk_component(3dview)] 
    1121         set h  [winfo height $itk_component(3dview)] 
    1122         ServerCmd [subst { 
     1120        set w  [winfo width $itk_component(3dview)]
     1121        set h  [winfo height $itk_component(3dview)]
     1122        ServerCmd [subst {
    11231123            reset
    11241124            screen $w $h
     
    11341134    if { $changed } {
    11351135        # Default settings for all models.
    1136         SphereScale update 
     1136        SphereScale update
    11371137        StickRadius update
    1138         labels update 
    1139         Opacity update 
    1140         CartoonTrace update 
     1138        labels update
     1139        Opacity update
     1140        CartoonTrace update
    11411141        Cell update
    1142         OrthoProjection update 
     1142        OrthoProjection update
    11431143        Representation update
    11441144    }
     
    11881188    $_image(plot) configure -width $_width -height $_height
    11891189    # Immediately invalidate cache, defer update until mapped
    1190     array unset _imagecache 
     1190    array unset _imagecache
    11911191    set _resizePending 0
    11921192}
    1193    
     1193
    11941194itcl::body Rappture::MolvisViewer::EventuallyResize { w h } {
    11951195    set _width $w
     
    12031203itcl::body Rappture::MolvisViewer::DoRotate {} {
    12041204    ServerCmd "rotate $_view(a) $_view(b) $_view(c)"
    1205     array unset _imagecache 
     1205    array unset _imagecache
    12061206    set _rotatePending 0
    12071207}
    1208    
     1208
    12091209itcl::body Rappture::MolvisViewer::EventuallyRotate { a b c } {
    1210     set _view(a) $a 
     1210    set _view(a) $a
    12111211    set _view(b) $b
    1212     set _view(c) $c 
     1212    set _view(c) $c
    12131213    if { !$_rotatePending } {
    12141214        $_dispatcher event -after 100 !rotate
     
    12461246        set _view(x) [expr $_view(x) + $dx]
    12471247        set _view(y) [expr $_view(y) + $dy]
    1248         array unset _imagecache 
     1248        array unset _imagecache
    12491249        ServerCmd "pan $dx $dy"
    12501250        return
     
    12531253        set option "click"
    12541254    }
    1255     if { $option == "click" } { 
     1255    if { $option == "click" } {
    12561256        $itk_component(3dview) configure -cursor hand1
    12571257    }
     
    12611261        set _view(x) [expr $_view(x) + $dx]
    12621262        set _view(y) [expr $_view(y) + $dy]
    1263         array unset _imagecache 
     1263        array unset _imagecache
    12641264        ServerCmd "pan $dx $dy"
    12651265    }
     
    12941294        }
    12951295    }
    1296     array unset _imagecache 
     1296    array unset _imagecache
    12971297}
    12981298
     
    13241324        return
    13251325    }
    1326     set _rocker(on) $_settings($this-rock) 
     1326    set _rocker(on) $_settings($this-rock)
    13271327    if { $option == "step"} {
    13281328        if { $_rocker(client) >= 10 } {
     
    15541554    }
    15551555    if { $option == $_mrep } {
    1556         return 
     1556        return
    15571557    }
    15581558    if { $option == "update" } {
    15591559        set option $_settings($this-model)
    15601560    }
    1561     array unset _imagecache 
     1561    array unset _imagecache
    15621562    if { $option == "sticks" } {
    15631563        set _settings($this-modelimg) [Rappture::icon lines]
     
    16591659        return
    16601660    }
    1661     array unset _imagecache 
     1661    array unset _imagecache
    16621662    if { $cell } {
    16631663        Rappture::Tooltip::for $itk_component(ortho) \
     
    17231723    }
    17241724}
    1725            
     1725
    17261726itcl::body Rappture::MolvisViewer::GetImage { widget } {
    17271727    set token "print[incr _nextToken]"
     
    17291729    set $var ""
    17301730
    1731     set controls $_downloadPopup(image_controls) 
     1731    set controls $_downloadPopup(image_controls)
    17321732    set combo $controls.size
    17331733    set size [$combo translate [$combo value]]
     
    17511751    # Setup an automatic timeout procedure.
    17521752    $_dispatcher dispatch $this !pngtimeout "set $var {} ; list"
    1753    
     1753
    17541754    set popup .molvisviewerimagedownload
    17551755    if { ![winfo exists $popup] } {
     
    17651765            1,0 $inner.please -anchor w \
    17661766            1,1 $inner.icon -anchor e  \
    1767             2,0 $inner.cancel -cspan 2 
    1768         blt::table configure $inner r0 -pady 4 
    1769         blt::table configure $inner r2 -pady 4 
     1767            2,0 $inner.cancel -cspan 2
     1768        blt::table configure $inner r0 -pady 4
     1769        blt::table configure $inner r2 -pady 4
    17701770        bind $inner.cancel <Return> [list $inner.cancel invoke]
    17711771        bind $inner.cancel <KP_Enter> [list $inner.cancel invoke]
     
    17751775    set combo $controls.bgcolor
    17761776    set bgcolor [$combo translate [$combo value]]
    1777    
     1777
    17781778    $_dispatcher event -after 60000 !pngtimeout
    17791779    WaitIcon start $inner.icon
    17801780    grab set $inner
    17811781    focus $inner.cancel
    1782    
     1782
    17831783    ServerCmd "print $token $width $height $bgcolor"
    17841784
    17851785    $popup activate $widget below
    1786     # We wait here for either 
    1787     #  1) the png to be delivered or 
    1788     #  2) timeout or 
     1786    # We wait here for either
     1787    #  1) the png to be delivered or
     1788    #  2) timeout or
    17891789    #  3) user cancels the operation.
    17901790    tkwait variable $var
     
    18261826#
    18271827# Used internally to change the molecular atom scale used to render
    1828 # our scene. 
    1829 #
    1830 # Note: Only sets the specified radius for active models.  If the model 
     1828# our scene.
     1829#
     1830# Note: Only sets the specified radius for active models.  If the model
    18311831#       is inactive, then it overridden with the value "0.1".
    18321832# ----------------------------------------------------------------------
     
    18641864# our scene.
    18651865#
    1866 # Note: Only sets the specified radius for active models.  If the model 
     1866# Note: Only sets the specified radius for active models.  If the model
    18671867#       is inactive, then it overridden with the value "0.25".
    18681868# ----------------------------------------------------------------------
     
    19001900# our scene.
    19011901#
    1902 # Note: Only sets the specified transparency for active models.  If the model 
     1902# Note: Only sets the specified transparency for active models.  If the model
    19031903#       is inactive, then it overridden with the value "0.75".
    19041904# ----------------------------------------------------------------------
     
    19711971# ----------------------------------------------------------------------
    19721972itcl::body Rappture::MolvisViewer::CartoonTrace {option {models "all"}} {
    1973     array unset _imagecache 
     1973    array unset _imagecache
    19741974    set trace $_settings($this-cartoontrace)
    19751975    if { $option == "update" } {
     
    19961996
    19971997itcl::body Rappture::MolvisViewer::AddImageControls { inner widget } {
    1998     label $inner.size_l -text "Size:" -font "Arial 9" 
     1998    label $inner.size_l -text "Size:" -font "Arial 9"
    19991999    set _downloadPopup(image_controls) $inner
    20002000    set img $_image(plot)
     
    20062006        "highquality"  "High Quality (2400x2400)"
    20072007
    2008     label $inner.bgcolor_l -text "Background:" -font "Arial 9" 
     2008    label $inner.bgcolor_l -text "Background:" -font "Arial 9"
    20092009    Rappture::Combobox $inner.bgcolor -width 30 -editable no
    20102010    $inner.bgcolor choices insert end \
    20112011        "black"  "Black" \
    20122012        "white"  "White" \
    2013         "none"  "Transparent (PNG only)"         
    2014 
    2015     label $inner.format_l -text "Format:" -font "Arial 9" 
     2013        "none"  "Transparent (PNG only)"
     2014
     2015    label $inner.format_l -text "Format:" -font "Arial 9"
    20162016    Rappture::Combobox $inner.format -width 30 -editable no
    20172017    $inner.format choices insert end \
     
    20342034    blt::table $f \
    20352035        0,0 $f.ok  \
    2036         0,1 $f.cancel 
     2036        0,1 $f.cancel
    20372037
    20382038    blt::table $inner \
     
    20482048    $inner.bgcolor value "Black"
    20492049    $inner.size value "Draft (400x400)"
    2050     $inner.format value  "PNG (Portable Network Graphics format)" 
     2050    $inner.format value  "PNG (Portable Network Graphics format)"
    20512051}
    20522052
     
    20552055        set w [image width $_image(plot)]
    20562056        set h [image height $_image(plot)]
    2057     } 
     2057    }
    20582058    set tag "$_state(client),$_rocker(client)"
    20592059    if { $_image(id) != "$tag" } {
     
    21222122    }
    21232123
    2124     # Scale and translate points 
     2124    # Scale and translate points
    21252125    for { set i 0 } { $i < 8 } { incr i } {
    21262126        point${i} expr "(point${i} * scale) + origin"
  • branches/uiuc_vtk_viewers/gui/scripts/panes.tcl

    r3330 r5053  
    1 # -*- mode: tcl; indent-tabs-mode: nil -*-
    2 
    31# ----------------------------------------------------------------------
    42#  COMPONENT: Panes - creates a series of adjustable panes
     
    97# ======================================================================
    108#  AUTHOR:  Michael McLennan, Purdue University
    11 #  Copyright (c) 2004-2012  HUBzero Foundation, LLC
     9#  Copyright (c) 2004-2015  HUBzero Foundation, LLC
    1210#
    1311#  See the file "license.terms" for information on usage and
     
    2119option add *Panes.sashWidth 2 widgetDefault
    2220option add *Panes.sashPadding 4 widgetDefault
    23 option add *Panes.sashCursor sb_v_double_arrow
     21option add *Panes.orientation vertical widgetDefault
    2422
    2523itcl::class Rappture::Panes {
    2624    inherit itk::Widget
    2725
    28     itk_option define -sashcursor sashCursor SashCursor ""
    2926    itk_option define -sashrelief sashRelief SashRelief ""
    3027    itk_option define -sashwidth sashWidth SashWidth 0
    3128    itk_option define -sashpadding sashPadding SashPadding 0
     29    itk_option define -orientation orientation Orientation ""
    3230
    3331    constructor {args} { # defined below }
     
    3533    public method insert {pos args}
    3634    public method pane {pos}
    37     public method visibility {pos {newval ""}}
    38     public method fraction {pos {newval ""}}
     35    public method visibility {pos args}
     36    public method fraction {pos args}
    3937    public method hilite {state sash}
     38    public method size {}
    4039
    4140    protected method _grab {pane X Y}
     
    4948    private variable _visibility ""  ;# list of visibilities for panes
    5049    private variable _counter 0      ;# counter for auto-generated names
    51     private variable _frac 0.0       ;# list of fractions
    52     public variable orientation "vertical"
     50    private variable _reqfrac 0.0    ;# requested fraction size of each pane
     51    private variable _dragfrom 0     ;# starting coordinate of drag operation
     52    private variable _dragfrac 0     ;# limit on fraction of drag operation
    5353}
    5454
    5555itk::usual Panes {
    56     keep -background -cursor
     56    keep -background -cursor -sashwidth -sashrelief
    5757}
    5858
     
    8080    lappend _panes $pname
    8181    lappend _visibility 1
    82     set _frac 0.5
     82    set _reqfrac 0.5
    8383
    8484    eval itk_initialize $args
     
    107107    } {
    108108        usual
    109         rename -cursor -sashcursor sashCursor SashCursor
     109        ignore -cursor
    110110    }
    111111    bind $itk_component($sash) <Enter> [itcl::code $this hilite on $sash]
     
    116116    } {
    117117        usual
    118         rename -cursor -sashcursor sashCursor SashCursor
    119118        rename -relief -sashrelief sashRelief SashRelief
    120119        ignore -borderwidth
    121120    }
    122     if { $orientation == "vertical" } {
     121    if {$itk_option(-orientation) eq "vertical"} {
    123122        pack $itk_component(${sash}ridge) -fill x
     123        $itk_component($sash) configure -cursor sb_v_double_arrow
     124        $itk_component(${sash}ridge) configure -cursor sb_v_double_arrow
    124125    } else {
    125126        pack $itk_component(${sash}ridge) -fill y -side left
     127        $itk_component($sash) configure -cursor sb_h_double_arrow
     128        $itk_component(${sash}ridge) configure -cursor sb_h_double_arrow
    126129    }
    127130    foreach comp [list $sash ${sash}ridge] {
     
    140143    set _panes [linsert $_panes $pos $pname]
    141144    set _visibility [linsert $_visibility $pos 1]
    142     set _frac [linsert $_frac $pos $params(-fraction)]
     145    set _reqfrac [linsert $_reqfrac $pos $params(-fraction)]
    143146
    144147    # fix sash characteristics
     
    165168
    166169# ----------------------------------------------------------------------
    167 # USAGE: visibility <pos> ?<newval>?
     170# USAGE: visibility <pos> ?<newval>? ?<pos> <newval> ...?
    168171#
    169172# Clients use this to get/set the visibility of the pane at position
    170 # <pos>.
    171 # ----------------------------------------------------------------------
    172 itcl::body Rappture::Panes::visibility {pos {newval ""}} {
    173     if {"" == $newval} {
     173# <pos>.  Can also be used to set the visibility for multiple panes
     174# if multiple <pos>/<newval> pairs are specified in the same command.
     175# ----------------------------------------------------------------------
     176itcl::body Rappture::Panes::visibility {pos args} {
     177    if {[llength $args] == 0} {
    174178        return [lindex $_visibility $pos]
    175179    }
    176     if {![string is boolean $newval]} {
    177         error "bad value \"$newval\": should be boolean"
    178     }
    179     if {$pos == "end" || ($pos >= 0 && $pos < [llength $_visibility])} {
    180         set _visibility [lreplace $_visibility $pos $pos [expr {$newval}]]
    181         $_dispatcher event -idle !layout
    182     } else {
    183         error "bad index \"$pos\": out of range"
    184     }
    185 }
    186 
    187 # ----------------------------------------------------------------------
    188 # USAGE: fraction <pos> ?<newval>?
     180    if {[llength $args] % 2 == 0} {
     181        error "wrong # args: should be \"visibility pos ?val pos val ...?\""
     182    }
     183
     184    set args [linsert $args 0 $pos]
     185    foreach {pos newval} $args {
     186        if {![string is boolean -strict $newval]} {
     187            error "bad value \"$newval\": should be boolean"
     188        }
     189        if {$pos eq "end" || ($pos >= 0 && $pos < [llength $_visibility])} {
     190            set _visibility [lreplace $_visibility $pos $pos [expr {$newval}]]
     191            $_dispatcher event -idle !layout
     192        } else {
     193            error "bad index \"$pos\": out of range"
     194        }
     195    }
     196}
     197
     198# ----------------------------------------------------------------------
     199# USAGE: fraction <pos> ?<newval>? ?<pos> <newval> ...?
    189200#
    190201# Clients use this to get/set the fraction of real estate associated
    191 # with the pane at position <pos>.
    192 # ----------------------------------------------------------------------
    193 itcl::body Rappture::Panes::fraction {pos {newval ""}} {
    194     if {"" == $newval} {
    195         return [lindex $_frac $pos]
    196     }
    197     if {![string is double $newval]} {
    198         error "bad value \"$newval\": should be fraction 0-1"
    199     }
    200     if {$pos == "end" || ($pos >= 0 && $pos < [llength $_frac])} {
    201         set len [llength $_frac]
    202         set _frac [lreplace $_frac $pos $pos xxx]
    203         set total 0
    204         foreach f $_frac {
    205             if {"xxx" != $f} {
    206                 set total [expr {$total+$f}]
    207             }
    208         }
    209         for {set i 0} {$i < $len} {incr i} {
    210             set f [lindex $_frac $i]
    211             if {"xxx" == $f} {
    212                 set f $newval
    213             } else {
    214                 set f [expr {$f/$total - $newval/double($len-1)}]
    215             }
    216             set _frac [lreplace $_frac $i $i $f]
    217         }
    218         $_dispatcher event -idle !layout
    219     } else {
    220         error "bad index \"$pos\": out of range"
     202# with the pane at position <pos>.  Can also be used to set the
     203# fractions for multiple panes if multiple <pos>/<newval> pairs
     204# are specified in the same command.
     205# ----------------------------------------------------------------------
     206itcl::body Rappture::Panes::fraction {pos args} {
     207    if {[llength $args] == 0} {
     208        return [lindex $_reqfrac $pos]
     209    }
     210    if {[llength $args] % 2 == 0} {
     211        error "wrong # args: should be \"fraction pos ?val pos val ...?\""
     212    }
     213
     214    set args [linsert $args 0 $pos]
     215    foreach {pos newval} $args {
     216        if {![string is double -strict $newval]} {
     217            error "bad value \"$newval\": should be fraction 0-1"
     218        }
     219        if {$pos eq "end" || ($pos >= 0 && $pos < [llength $_reqfrac])} {
     220            set _reqfrac [lreplace $_reqfrac $pos $pos $newval]
     221            $_dispatcher event -idle !layout
     222        } else {
     223            error "bad index \"$pos\": out of range"
     224        }
    221225    }
    222226}
     
    230234itcl::body Rappture::Panes::hilite {state sash} {
    231235    switch -- $itk_option(-sashrelief) {
     236      flat {
     237        if {$state} {
     238            $itk_component(${sash}ridge) configure -background black
     239        } else {
     240            $itk_component(${sash}ridge) configure -background $itk_option(-background)
     241        }
     242      }
    232243      sunken {
    233244        if {$state} {
     
    256267
    257268# ----------------------------------------------------------------------
     269# USAGE: size
     270#
     271# Returns the number of panes in this widget.  That makes it easier
     272# to index the various panes, since indices run from 0 to size-1.
     273# ----------------------------------------------------------------------
     274itcl::body Rappture::Panes::size {} {
     275    return [llength $_panes]
     276}
     277
     278# ----------------------------------------------------------------------
    258279# USAGE: _grab <pane> <X> <Y>
    259280#
     
    262283# ----------------------------------------------------------------------
    263284itcl::body Rappture::Panes::_grab {pname X Y} {
     285    set pos [lsearch $_panes $pname]
     286    if {$pos < 0} return
     287    set frac0 [lindex $_reqfrac [expr {$pos-1}]]
     288    set frac1 [lindex $_reqfrac $pos]
     289    set _dragfrac [expr {$frac0+$frac1}]
     290
     291    if {$itk_option(-orientation) eq "vertical"} {
     292        set _dragfrom $Y
     293    } else {
     294        set _dragfrom $X
     295    }
    264296}
    265297
     
    270302# ----------------------------------------------------------------------
    271303itcl::body Rappture::Panes::_drag {pname X Y} {
    272     if { $orientation == "vertical" } {
    273         set realY [expr {$Y-[winfo rooty $itk_component(hull)]}]
     304    set pos [lsearch $_panes $pname]
     305    if {$pos < 0} return
     306    set frac [lindex $_reqfrac $pos]
     307
     308    if {$itk_option(-orientation) eq "vertical"} {
     309        set delY [expr {$_dragfrom-$Y}]
    274310        set Ymax  [winfo height $itk_component(hull)]
    275         set frac [expr double($realY)/$Ymax]
     311        set delta [expr {double($delY)/$Ymax}]
     312        set frac [expr {$frac + $delta}]
     313        set _dragfrom $Y
    276314    } else {
    277         set realX [expr {$X-[winfo rootx $itk_component(hull)]}]
     315        set delX [expr {$_dragfrom-$X}]
    278316        set Xmax  [winfo width $itk_component(hull)]
    279         set frac [expr double($realX)/$Xmax]
    280     }
     317        set delta [expr {double($delX)/$Xmax}]
     318        set frac [expr {$frac + $delta}]
     319        set _dragfrom $X
     320    }
     321    if {$delta == 0.0} {
     322        return
     323    }
     324
     325    # set limits so the pane can't get too large or too small
    281326    if {$frac < 0.05} {
    282327        set frac 0.05
    283328    }
    284     if {$frac > 0.95} {
    285         set frac 0.95
    286     }
    287     if {[llength $_frac] == 2} {
    288         set _frac [list $frac [expr {1-$frac}]]
    289     } else {
    290         set i [expr {[lsearch $_panes $pname]-1}]
    291         if {$i >= 0} {
    292             set _frac [lreplace $_frac $i $i $frac]
    293         }
    294     }
     329    if {$frac > $_dragfrac-0.05} {
     330        set frac [expr {$_dragfrac-0.05}]
     331    }
     332
     333    # replace the fractions for this pane and the one before it
     334    set prevfrac [expr {$_dragfrac-$frac}]
     335    set _reqfrac [lreplace $_reqfrac [expr {$pos-1}] $pos $prevfrac $frac]
     336
     337    # normalize all fractions and fix the layout
    295338    _fixLayout
    296339
     
    314357# ----------------------------------------------------------------------
    315358itcl::body Rappture::Panes::_fixLayout {args} {
    316     if { $orientation == "vertical" } {
     359    # normalize the fractions for all panes to they add to 1.0
     360    set total 0
     361    foreach f $_reqfrac v $_visibility {
     362        if {$v && $f > 0} {
     363            set total [expr {$total + $f}]
     364        }
     365    }
     366    if {$total == 0.0} { set total 1 }
     367
     368    set normfrac ""
     369    foreach f $_reqfrac v $_visibility {
     370        if {$v} {
     371            lappend normfrac [expr {double($f)/$total}]
     372        } else {
     373            lappend normfrac [expr {double($f)/$total}]
     374        }
     375    }
     376
     377    # note that sash padding can be a single number or different on each side
     378    if {[llength $itk_option(-sashpadding)] == 1} {
     379        set pad [expr {2*$itk_option(-sashpadding)}]
     380    } else {
     381        set pad [expr [join $itk_option(-sashpadding) +]]
     382    }
     383
     384    if {$itk_option(-orientation) eq "vertical"} {
    317385        set h [winfo height $itk_component(hull)]
     386        set sh [expr {$itk_option(-sashwidth) + $pad}]
    318387
    319388        set plist ""
    320389        set flist ""
    321         foreach p $_panes f $_frac v $_visibility {
     390        foreach p $_panes f $normfrac v $_visibility {
    322391            set sash ${p}sash
    323392            if {$v} {
     
    326395                lappend flist $f
    327396                if {[info exists itk_component($sash)]} {
    328                     set h [expr {$h - [winfo reqheight $itk_component($sash)]}]
     397                    set h [expr {$h - $sh}]
    329398                }
    330399            } else {
     
    336405            }
    337406        }
    338        
    339         # normalize the fractions so they add up to 1
    340         set total 0
    341         foreach f $flist { set total [expr {$total+$f}] }
    342         set newflist ""
    343         foreach f $flist {
    344             lappend newflist [expr {double($f)/$total}]
    345         }
    346         set flist $newflist
    347        
     407
    348408        # lay out the various panes
    349409        set y 0
     
    351411            set sash ${p}sash
    352412            if {[info exists itk_component($sash)]} {
    353                 set sh [winfo reqheight $itk_component($sash)]
    354413                place $itk_component($sash) -y $y -relx 0.5 -anchor n \
    355414                    -relwidth 1.0 -height $sh
     
    364423    } else {
    365424        set w [winfo width $itk_component(hull)]
     425        set sw [expr {$itk_option(-sashwidth) + $pad}]
    366426
    367427        set plist ""
    368428        set flist ""
    369         foreach p $_panes f $_frac v $_visibility {
     429        foreach p $_panes f $normfrac v $_visibility {
    370430            set sash ${p}sash
    371431            if {$v} {
     
    374434                lappend flist $f
    375435                if {[info exists itk_component($sash)]} {
    376                     set w [expr {$w - [winfo reqwidth $itk_component($sash)]}]
     436                    set w [expr {$w - $sw}]
    377437                }
    378438            } else {
     
    384444            }
    385445        }
    386        
    387         # normalize the fractions so they add up to 1
    388         set total 0
    389         foreach f $flist { set total [expr {$total+$f}] }
    390         set newflist ""
    391         foreach f $flist {
    392             lappend newflist [expr {double($f)/$total}]
    393         }
    394         set flist $newflist
    395        
     446
    396447        # lay out the various panes
    397448        set x 0
     
    399450            set sash ${p}sash
    400451            if {[info exists itk_component($sash)]} {
    401                 set sw [winfo reqwidth $itk_component($sash)]
    402452                place $itk_component($sash) -x $x -rely 0.5 -anchor w \
    403453                    -relheight 1.0 -width $sw
     
    420470# ----------------------------------------------------------------------
    421471itcl::body Rappture::Panes::_fixSashes {args} {
    422     if { $orientation == "vertical" } {
     472    if {$itk_option(-orientation) eq "vertical"} {
    423473        set ht [winfo pixels $itk_component(hull) $itk_option(-sashwidth)]
    424474        set bd [expr {$ht/2}]
     
    426476            set sash "${pane}sashridge"
    427477            if {[info exists itk_component($sash)]} {
    428                 $itk_component($sash) configure -height $ht -borderwidth $bd
    429                 if {$itk_option(-sashrelief) == "solid"} {
    430                     $itk_component($sash) configure -background black
    431                 } else {
    432                     $itk_component($sash) configure \
    433                         -background $itk_option(-background)
    434                 }
    435                 pack $itk_component($sash) -pady $itk_option(-sashpadding)
     478                $itk_component($sash) configure -height $ht \
     479                    -borderwidth $bd -relief $itk_option(-sashrelief)
     480                pack $itk_component($sash) -pady $itk_option(-sashpadding) \
     481                    -side top
    436482            }
    437483        }
     
    442488            set sash "${pane}sashridge"
    443489            if {[info exists itk_component($sash)]} {
    444                 $itk_component($sash) configure -width $w -borderwidth $bd
    445                 if {$itk_option(-sashrelief) == "solid"} {
    446                     $itk_component($sash) configure -background black
    447                 } else {
    448                     $itk_component($sash) configure \
    449                         -background $itk_option(-background)
    450                 }
     490                $itk_component($sash) configure -width $w \
     491                    -borderwidth $bd -relief $itk_option(-sashrelief)
    451492                pack $itk_component($sash) -padx $itk_option(-sashpadding) \
    452493                    -side left
     
    474515# ----------------------------------------------------------------------
    475516itcl::configbody Rappture::Panes::sashpadding {
     517    set count 0
     518    foreach val $itk_option(-sashpadding) {
     519        if {![string is integer -strict $val]} {
     520            error "bad padding value \"$val\": should be integer"
     521        }
     522        incr count
     523    }
     524    if {$count < 1 || $count > 2} {
     525        error "bad padding value \"$itk_option(-sashpadding)\": should be \"#\" or \"# #\""
     526    }
    476527    $_dispatcher event -idle !sashes
    477528}
     529
     530# ----------------------------------------------------------------------
     531# CONFIGURATION OPTION: -orientation
     532# ----------------------------------------------------------------------
     533itcl::configbody Rappture::Panes::orientation {
     534    foreach pname $_panes {
     535        set sash "${pname}sash"
     536        if {$itk_option(-orientation) eq "vertical"} {
     537            place $itk_component($pname) -x 0 -relx 0.5 -relwidth 1 \
     538                -y 0 -rely 0 -relheight 0
     539
     540            if {[info exists itk_component($sash)]} {
     541                place $itk_component($sash) -x 0 -relx 0.5 -relwidth 1 \
     542                    -y 0 -rely 0 -relheight 0
     543                $itk_component($sash) configure \
     544                    -cursor sb_v_double_arrow
     545
     546                pack $itk_component(${sash}ridge) -fill x -side top
     547                $itk_component(${sash}ridge) configure \
     548                    -cursor sb_v_double_arrow
     549            }
     550        } else {
     551            place $itk_component($pname) -y 0 -rely 0.5 -relheight 1 \
     552                -x 0 -relx 0 -relwidth 0
     553
     554            if {[info exists itk_component($sash)]} {
     555                place $itk_component($sash) -y 0 -rely 0.5 -relheight 1 \
     556                    -x 0 -relx 0 -relwidth 0
     557                $itk_component($sash) configure \
     558                    -cursor sb_h_double_arrow
     559
     560                pack $itk_component(${sash}ridge) -fill y -side left
     561                $itk_component(${sash}ridge) configure \
     562                    -cursor sb_h_double_arrow
     563            }
     564        }
     565    }
     566
     567    # fix sash characteristics
     568    $_dispatcher event -idle !sashes
     569
     570    # make sure we fix up the layout at some point
     571    $_dispatcher event -idle !layout
     572}
  • branches/uiuc_vtk_viewers/gui/scripts/sidebarframe.tcl

    r3782 r5053  
    247247    }
    248248
    249     $itk_component(tabs) insert end $pname \
     249    $itk_component(tabs) insert $pos $pname \
    250250        -image $panel(-icon) -text "" -padx 0 -pady 0 \
    251251        -command [itcl::code $this _toggleTab $pname]
     
    264264
    265265    set _panels($pname-title) $panel(-title)
    266     lappend _panels(all) $pname
     266    if { ![info exists _panels(all)] || $pos == "end" } {
     267        lappend _panels(all) $pname
     268    } else {
     269        set _panels(all) [linsert $_panels(all) $pos $pname]
     270    }
    267271    if {$_selected == ""} {
    268272        set _selected $pname
  • branches/uiuc_vtk_viewers/gui/scripts/unirect3d.tcl

    r4791 r5053  
    2727    public method mesh {}
    2828    public method values {}
    29     public method valuesObj {}
    3029    public method units { axis }
    3130    public method label { axis }
     
    141140# ----------------------------------------------------------------------
    142141# method mesh
    143 #       Returns a Tcl list that represents the points  of the uniform
    144 #       grid.
     142#       Returns a Tcl list that represents the points of the uniform
     143#       grid.  Each point has x,y and z values in the list.
    145144# ----------------------------------------------------------------------
    146145itcl::body Rappture::Unirect3d::mesh {} {
     
    163162
    164163# ----------------------------------------------------------------------
    165 # method values 
    166 #       Returns a Tcl list that represents the field values
     164# method values
     165#       Returns a BLT vector that represents the field values
    167166# ----------------------------------------------------------------------
    168167itcl::body Rappture::Unirect3d::values {} {
    169     if { [$_values length] > 0 } {
    170         return [$_values range 0 end]
    171     }
    172     return ""
    173 }
    174 
    175 # ----------------------------------------------------------------------
    176 # method valuesObj
    177 #       Returns a BLT vector that represents the field values
    178 # ----------------------------------------------------------------------
    179 itcl::body Rappture::Unirect3d::valuesObj {} {
    180168    return $_values
    181169}
  • branches/uiuc_vtk_viewers/gui/scripts/visviewer.tcl

    r4692 r5053  
    1 # -*- mode: tcl; indent-tabs-mode: nil -*- 
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    22
    33# ----------------------------------------------------------------------
    4 #  VisViewer - 
    5 #
    6 #  This class is the base class for the various visualization viewers 
     4#  VisViewer -
     5#
     6#  This class is the base class for the various visualization viewers
    77#  that use the nanoserver render farm.
    88#
     
    3232    private common _done            ;   # Used to indicate status of send.
    3333    private variable _buffer        ;   # buffer for incoming/outgoing commands
    34     private variable _initialized 
     34    private variable _initialized
    3535    private variable _isOpen 0
    3636    private variable _afterId -1
     
    7474    private method SendHelper {}
    7575    private method SendHelper.old {}
    76     private method WaitDialog { state } 
    77 
    78     protected method ToggleConsole {} 
    79     private method DebugConsole {} 
    80     private method BuildConsole {} 
    81     private method HideConsole {} 
    82     private method TraceComm { channel {data {}} } 
    83     private method SendDebugCommand {} 
     76    private method WaitDialog { state }
     77
     78    protected method ToggleConsole {}
     79    private method DebugConsole {}
     80    private method BuildConsole {}
     81    private method HideConsole {}
     82    private method TraceComm { channel {data {}} }
     83    private method SendDebugCommand {}
    8484
    8585    protected method CheckConnection {}
     
    8888    protected method Connect { servers }
    8989    protected method Disconnect {}
    90     protected method EnableWaitDialog { timeout } 
     90    protected method EnableWaitDialog { timeout }
    9191    protected method Euler2XYZ { theta phi psi }
    9292    protected method Flush {}
     
    102102    protected method SendEcho { channel {data ""} }
    103103    protected method StartBufferingCommands {}
    104     protected method StartWaiting {} 
     104    protected method StartWaiting {}
    105105    protected method StopBufferingCommands {}
    106     protected method StopWaiting {} 
    107 
    108     private method Waiting { option widget } 
     106    protected method StopWaiting {}
     107
     108    private method Waiting { option widget }
    109109
    110110    private proc CheckNameList { namelist }  {
     
    200200    global env
    201201    if { [info exists env(VISRECORDER)] } {
    202         set _logging 1
    203         if { [file exists /tmp/recording.log] } {
    204             file delete /tmp/recording.log
    205         }
     202        set _logging 1
     203        if { [file exists /tmp/recording.log] } {
     204            file delete /tmp/recording.log
     205        }
    206206    }
    207207    eval itk_initialize $args
     
    259259#    Connect to the visualization server (e.g. nanovis, pymolproxy).
    260260#    Creates an event callback that is triggered when we are idle
    261 #    (no I/O with the server) for some specified time. 
     261#    (no I/O with the server) for some specified time.
    262262#
    263263itcl::body Rappture::VisViewer::Connect { servers } {
     
    282282        set _hostname $server
    283283        fconfigure $_sid -translation binary -encoding binary
    284        
     284
    285285        # Read back the server identification string.
    286286        if { [gets $_sid data] <= 0 } {
     
    318318    after cancel $_afterId
    319319    $_dispatcher cancel !timeout
    320     catch {close $_sid} 
     320    catch {close $_sid}
    321321    set _sid ""
    322322    set _buffer(in) ""
     
    344344# CheckConection --
    345345#
    346 #   This routine is called whenever we're about to send/receive data on 
    347 #   the socket connection to the visualization server.  If we're connected, 
    348 #   then reset the timeout event.  Otherwise try to reconnect to the 
     346#   This routine is called whenever we're about to send/receive data on
     347#   the socket connection to the visualization server.  If we're connected,
     348#   then reset the timeout event.  Otherwise try to reconnect to the
    349349#   visualization server.
    350350#
     
    402402    }
    403403    puts -nonewline $_sid $_buffer(out)
    404     flush $_sid 
     404    flush $_sid
    405405    set _buffer(out) ""
    406406    set _done($this) 1;                 # Success
     
    467467        SendHelper
    468468    } else {
    469         # This can cause us to re-enter SendBytes during the tkwait, which 
     469        # This can cause us to re-enter SendBytes during the tkwait, which
    470470        # is not safe because the _buffer will be clobbered
    471471        blt::busy hold $itk_component(main)
     
    487487# StartWaiting --
    488488#
    489 #    Read some number of bytes from the visualization server. 
     489#    Read some number of bytes from the visualization server.
    490490#
    491491
    492492itcl::body Rappture::VisViewer::StartWaiting {} {
    493493    if { $_waitTimeout > 0 } {
    494         after cancel $_afterId 
     494        after cancel $_afterId
    495495        set _afterId [after $_waitTimeout [itcl::code $this WaitDialog on]]
    496496    }
    497497}
    498498
    499 itcl::body Rappture::VisViewer::StopWaiting {} { 
     499itcl::body Rappture::VisViewer::StopWaiting {} {
    500500    if { $_waitTimeout > 0 } {
    501501        WaitDialog off
     
    503503}
    504504
    505 itcl::body Rappture::VisViewer::EnableWaitDialog { value } { 
     505itcl::body Rappture::VisViewer::EnableWaitDialog { value } {
    506506    set _waitTimeout $value
    507507}
     
    510510# ReceiveBytes --
    511511#
    512 #    Read some number of bytes from the visualization server. 
     512#    Read some number of bytes from the visualization server.
    513513#
    514514itcl::body Rappture::VisViewer::ReceiveBytes { size } {
     
    631631}
    632632
    633 # 
     633#
    634634# ReceiveEcho --
    635635#
     
    654654        }
    655655        set inner [frame $itk_component(plotarea).view.splash]
    656         $inner configure -relief raised -bd 2 
     656        $inner configure -relief raised -bd 2
    657657        label $inner.text1 -text "Working...\nPlease wait." \
    658             -font "Arial 10" 
    659         label $inner.icon 
     658            -font "Arial 10"
     659        label $inner.icon
    660660        pack $inner -expand yes -anchor c
    661661        blt::table $inner \
    662662            0,0 $inner.text1 -anchor w \
    663             0,1 $inner.icon 
     663            0,1 $inner.icon
    664664        Waiting start $inner.icon
    665665    } else {
     
    721721    pack $f.send.l -side left
    722722    itk_component add command {
    723         entry $f.send.e -background white
     723        entry $f.send.e -background white
    724724    } {
    725         ignore -background
     725        ignore -background
    726726    }
    727727    pack $f.send.e -side left -expand yes -fill x
     
    731731    pack $f.sb -side right -fill y
    732732    itk_component add trace {
    733         text $f.comm -wrap char -yscrollcommand "$f.sb set" -background white
     733        text $f.comm -wrap char -yscrollcommand "$f.sb set" -background white
    734734    } {
    735         ignore -background
     735        ignore -background
    736736    }
    737737    pack $f.comm -expand yes -fill both
     
    741741
    742742    $itk_component(trace) tag configure error -foreground red \
    743         -font -*-courier-medium-o-normal-*-*-120-*
     743        -font -*-courier-medium-o-normal-*-*-120-*
    744744    $itk_component(trace) tag configure incoming -foreground blue
    745745}
     
    753753itcl::body Rappture::VisViewer::ToggleConsole {} {
    754754    if { $_debugConsole } {
    755         set _debugConsole 0
     755        set _debugConsole 0
    756756    } else {
    757         set _debugConsole 1
     757        set _debugConsole 1
    758758    }
    759759    DebugConsole
     
    763763# DebugConsole --
    764764#
    765 #    Based on the value of the variable _debugConsole, turns on/off 
    766 #    debugging. This is done by setting/unsetting a procedure that 
    767 #    is called whenever new characters are received or sent on the 
     765#    Based on the value of the variable _debugConsole, turns on/off
     766#    debugging. This is done by setting/unsetting a procedure that
     767#    is called whenever new characters are received or sent on the
    768768#    socket to the render server.  Additionally, the debug console
    769769#    is created if necessary and hidden/shown.
     
    771771itcl::body Rappture::VisViewer::DebugConsole {} {
    772772    if { ![winfo exists .renderconsole] } {
    773         BuildConsole
     773        BuildConsole
    774774    }
    775775    if { $_debugConsole } {
    776         $this configure -sendcommand [itcl::code $this TraceComm]
    777         $this configure -receivecommand [itcl::code $this TraceComm]
    778         wm deiconify .renderconsole
     776        $this configure -sendcommand [itcl::code $this TraceComm]
     777        $this configure -receivecommand [itcl::code $this TraceComm]
     778        wm deiconify .renderconsole
    779779    } else {
    780         $this configure -sendcommand ""
    781         $this configure -receivecommand ""
    782         wm withdraw .renderconsole
     780        $this configure -sendcommand ""
     781        $this configure -receivecommand ""
     782        wm withdraw .renderconsole
    783783    }
    784784}
     
    866866                -title "Render Server Error"
    867867            set inner [$popup component inner]
    868             label $inner.summary -text "" -anchor w 
     868            label $inner.summary -text "" -anchor w
    869869
    870870            Rappture::Scroller $inner.scrl \
    871                 -xscrollmode auto -yscrollmode auto 
     871                -xscrollmode auto -yscrollmode auto
    872872            text $inner.scrl.text \
    873873                -font "Arial 9 " -background white -relief sunken -bd 1 \
     
    878878            blt::table $inner \
    879879                0,0 $inner.scrl -fill both \
    880                 1,0 $inner.ok 
    881             $inner.scrl.text tag configure normal -font "Arial 9" 
    882             $inner.scrl.text tag configure italic -font "Arial 9 italic" 
     880                1,0 $inner.ok
     881            $inner.scrl.text tag configure normal -font "Arial 9"
     882            $inner.scrl.text tag configure italic -font "Arial 9 italic"
    883883            $inner.scrl.text tag configure bold -font "Arial 10 bold"
    884884            $inner.scrl.text tag configure code -font "Courier 10 bold"
     
    889889        set inner [$popup component inner]
    890890        $inner.scrl.text delete 0.0 end
    891        
     891
    892892        $inner.scrl.text configure -state normal
    893893        $inner.scrl.text insert end "The following error was reported by the render server:\n\n" bold
     
    959959        "blue-to-grey" {
    960960            return {
    961                 0.0                     0.000 0.600 0.800 
    962                 0.14285714285714285     0.400 0.900 1.000 
    963                 0.2857142857142857      0.600 1.000 1.000 
    964                 0.42857142857142855     0.800 1.000 1.000 
    965                 0.5714285714285714      0.900 0.900 0.900 
    966                 0.7142857142857143      0.600 0.600 0.600 
    967                 0.8571428571428571      0.400 0.400 0.400 
     961                0.0                     0.000 0.600 0.800
     962                0.14285714285714285     0.400 0.900 1.000
     963                0.2857142857142857      0.600 1.000 1.000
     964                0.42857142857142855     0.800 1.000 1.000
     965                0.5714285714285714      0.900 0.900 0.900
     966                0.7142857142857143      0.600 0.600 0.600
     967                0.8571428571428571      0.400 0.400 0.400
    968968                1.0                     0.200 0.200 0.200
    969969            }
    970970        }
    971971        "white-to-blue" {
    972             return { 
    973                 0.0                     0.900 1.000 1.000 
    974                 0.1111111111111111      0.800 0.983 1.000 
    975                 0.2222222222222222      0.700 0.950 1.000 
    976                 0.3333333333333333      0.600 0.900 1.000 
    977                 0.4444444444444444      0.500 0.833 1.000 
    978                 0.5555555555555556      0.400 0.750 1.000 
    979                 0.6666666666666666      0.300 0.650 1.000 
    980                 0.7777777777777778      0.200 0.533 1.000 
    981                 0.8888888888888888      0.100 0.400 1.000 
     972            return {
     973                0.0                     0.900 1.000 1.000
     974                0.1111111111111111      0.800 0.983 1.000
     975                0.2222222222222222      0.700 0.950 1.000
     976                0.3333333333333333      0.600 0.900 1.000
     977                0.4444444444444444      0.500 0.833 1.000
     978                0.5555555555555556      0.400 0.750 1.000
     979                0.6666666666666666      0.300 0.650 1.000
     980                0.7777777777777778      0.200 0.533 1.000
     981                0.8888888888888888      0.100 0.400 1.000
    982982                1.0                     0.000 0.250 1.000
    983983            }
     
    985985        "brown-to-blue" {
    986986            return {
    987                 0.0                             0.200   0.100   0.000 
    988                 0.09090909090909091             0.400   0.187   0.000 
    989                 0.18181818181818182             0.600   0.379   0.210 
    990                 0.2727272727272727              0.800   0.608   0.480 
    991                 0.36363636363636365             0.850   0.688   0.595 
    992                 0.45454545454545453             0.950   0.855   0.808 
    993                 0.5454545454545454              0.800   0.993   1.000 
    994                 0.6363636363636364              0.600   0.973   1.000 
    995                 0.7272727272727273              0.400   0.940   1.000 
    996                 0.8181818181818182              0.200   0.893   1.000 
    997                 0.9090909090909091              0.000   0.667   0.800 
    998                 1.0                             0.000   0.480   0.600 
     987                0.0                             0.200   0.100   0.000
     988                0.09090909090909091             0.400   0.187   0.000
     989                0.18181818181818182             0.600   0.379   0.210
     990                0.2727272727272727              0.800   0.608   0.480
     991                0.36363636363636365             0.850   0.688   0.595
     992                0.45454545454545453             0.950   0.855   0.808
     993                0.5454545454545454              0.800   0.993   1.000
     994                0.6363636363636364              0.600   0.973   1.000
     995                0.7272727272727273              0.400   0.940   1.000
     996                0.8181818181818182              0.200   0.893   1.000
     997                0.9090909090909091              0.000   0.667   0.800
     998                1.0                             0.000   0.480   0.600
    999999            }
    10001000        }
    10011001        "blue-to-brown" {
    10021002            return {
    1003                 0.0                             0.000   0.480   0.600 
    1004                 0.09090909090909091             0.000   0.667   0.800 
    1005                 0.18181818181818182             0.200   0.893   1.000 
    1006                 0.2727272727272727              0.400   0.940   1.000 
    1007                 0.36363636363636365             0.600   0.973   1.000 
    1008                 0.45454545454545453             0.800   0.993   1.000 
    1009                 0.5454545454545454              0.950   0.855   0.808 
    1010                 0.6363636363636364              0.850   0.688   0.595 
    1011                 0.7272727272727273              0.800   0.608   0.480 
    1012                 0.8181818181818182              0.600   0.379   0.210 
    1013                 0.9090909090909091              0.400   0.187   0.000 
    1014                 1.0                             0.200   0.100   0.000 
     1003                0.0                             0.000   0.480   0.600
     1004                0.09090909090909091             0.000   0.667   0.800
     1005                0.18181818181818182             0.200   0.893   1.000
     1006                0.2727272727272727              0.400   0.940   1.000
     1007                0.36363636363636365             0.600   0.973   1.000
     1008                0.45454545454545453             0.800   0.993   1.000
     1009                0.5454545454545454              0.950   0.855   0.808
     1010                0.6363636363636364              0.850   0.688   0.595
     1011                0.7272727272727273              0.800   0.608   0.480
     1012                0.8181818181818182              0.600   0.379   0.210
     1013                0.9090909090909091              0.400   0.187   0.000
     1014                1.0                             0.200   0.100   0.000
    10151015            }
    10161016        }
     
    10501050            set clist {
    10511051                "#EE82EE"
    1052                 "#4B0082" 
    1053                 "blue" 
    1054                 "#008000" 
    1055                 "yellow" 
    1056                 "#FFA500" 
    1057                 "red" 
     1052                "#4B0082"
     1053                "blue"
     1054                "#008000"
     1055                "yellow"
     1056                "#FFA500"
     1057                "red"
    10581058            }
    10591059        }
    10601060        "BGYOR" {
    10611061            set clist {
    1062                 "blue" 
    1063                 "#008000" 
    1064                 "yellow" 
    1065                 "#FFA500" 
    1066                 "red" 
     1062                "blue"
     1063                "#008000"
     1064                "yellow"
     1065                "#FFA500"
     1066                "red"
    10671067            }
    10681068        }
    10691069        "ROYGB" {
    10701070            set clist {
    1071                 "red" 
    1072                 "#FFA500" 
    1073                 "yellow" 
    1074                 "#008000" 
    1075                 "blue" 
     1071                "red"
     1072                "#FFA500"
     1073                "yellow"
     1074                "#008000"
     1075                "blue"
    10761076            }
    10771077        }
    10781078        "RYGCB" {
    10791079            set clist {
    1080                 "red" 
    1081                 "yellow" 
     1080                "red"
     1081                "yellow"
    10821082                "green"
    10831083                "cyan"
     
    10871087        "BCGYR" {
    10881088            set clist {
    1089                 "blue" 
     1089                "blue"
    10901090                "cyan"
    10911091                "green"
    1092                 "yellow" 
    1093                 "red" 
     1092                "yellow"
     1093                "red"
    10941094            }
    10951095        }
    10961096        "spectral" {
    10971097            return {
    1098                 0.0 0.150 0.300 1.000 
    1099                 0.1 0.250 0.630 1.000 
    1100                 0.2 0.450 0.850 1.000 
    1101                 0.3 0.670 0.970 1.000 
    1102                 0.4 0.880 1.000 1.000 
    1103                 0.5 1.000 1.000 0.750 
    1104                 0.6 1.000 0.880 0.600 
    1105                 0.7 1.000 0.680 0.450 
    1106                 0.8 0.970 0.430 0.370 
    1107                 0.9 0.850 0.150 0.196 
     1098                0.0 0.150 0.300 1.000
     1099                0.1 0.250 0.630 1.000
     1100                0.2 0.450 0.850 1.000
     1101                0.3 0.670 0.970 1.000
     1102                0.4 0.880 1.000 1.000
     1103                0.5 1.000 1.000 0.750
     1104                0.6 1.000 0.880 0.600
     1105                0.7 1.000 0.680 0.450
     1106                0.8 0.970 0.430 0.370
     1107                0.9 0.850 0.150 0.196
    11081108                1.0 0.650 0.000 0.130
    11091109            }
     
    11111111        "green-to-magenta" {
    11121112            return {
    1113                 0.0 0.000 0.316 0.000 
    1114                 0.06666666666666667 0.000 0.526 0.000 
    1115                 0.13333333333333333 0.000 0.737 0.000 
    1116                 0.2 0.000 0.947 0.000 
    1117                 0.26666666666666666 0.316 1.000 0.316 
    1118                 0.3333333333333333 0.526 1.000 0.526 
    1119                 0.4 0.737 1.000 0.737 
    1120                 0.4666666666666667 1.000 1.000 1.000 
    1121                 0.5333333333333333 1.000 0.947 1.000 
    1122                 0.6 1.000 0.737 1.000 
    1123                 0.6666666666666666 1.000 0.526 1.000 
    1124                 0.7333333333333333 1.000 0.316 1.000 
    1125                 0.8 0.947 0.000 0.947 
    1126                 0.8666666666666667 0.737 0.000 0.737 
    1127                 0.9333333333333333 0.526 0.000 0.526 
     1113                0.0 0.000 0.316 0.000
     1114                0.06666666666666667 0.000 0.526 0.000
     1115                0.13333333333333333 0.000 0.737 0.000
     1116                0.2 0.000 0.947 0.000
     1117                0.26666666666666666 0.316 1.000 0.316
     1118                0.3333333333333333 0.526 1.000 0.526
     1119                0.4 0.737 1.000 0.737
     1120                0.4666666666666667 1.000 1.000 1.000
     1121                0.5333333333333333 1.000 0.947 1.000
     1122                0.6 1.000 0.737 1.000
     1123                0.6666666666666666 1.000 0.526 1.000
     1124                0.7333333333333333 1.000 0.316 1.000
     1125                0.8 0.947 0.000 0.947
     1126                0.8666666666666667 0.737 0.000 0.737
     1127                0.9333333333333333 0.526 0.000 0.526
    11281128                1.0 0.316 0.000 0.316
    11291129            }
    11301130        }
    11311131        "greyscale" {
    1132             return { 
     1132            return {
    11331133                0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0
    11341134            }
     
    11611161#
    11621162itcl::body Rappture::VisViewer::StartBufferingCommands { } {
    1163     incr _buffering 
     1163    incr _buffering
    11641164    if { $_buffering == 1 } {
    11651165        set _outbuf ""
     
    11871187#
    11881188#       Send commands off to the rendering server.  If we're currently
    1189 #       sending data objects to the server, buffer the commands to be 
     1189#       sending data objects to the server, buffer the commands to be
    11901190#       sent later.
    11911191#
     
    12061206#
    12071207#       Send commands off to the rendering server.  If we're currently
    1208 #       sending data objects to the server, buffer the commands to be 
     1208#       sending data objects to the server, buffer the commands to be
    12091209#       sent later.
    12101210#
  • branches/uiuc_vtk_viewers/gui/scripts/vtkheightmapviewer.tcl

    r4769 r5053  
    1 # -*- mode: tcl; indent-tabs-mode: nil -*- 
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    22# ----------------------------------------------------------------------
    33#  COMPONENT: vtkheightmapviewer - Vtk heightmap viewer
     
    5858    public method get {args}
    5959    public method isconnected {}
    60     public method parameters {title args} { 
    61         # do nothing 
     60    public method parameters {title args} {
     61        # do nothing
    6262    }
    6363    public method scale {args}
     
    6969    private method BuildColormap { name }
    7070    private method BuildContourTab {}
    71     private method BuildDownloadPopup { widget command } 
     71    private method BuildDownloadPopup { widget command }
    7272    private method CameraReset {}
    7373    private method Combo { option }
     
    7878    private method DoRotate {}
    7979    private method DrawLegend {}
    80     private method EnterLegend { x y } 
    81     private method EventuallyRequestLegend {} 
    82     private method EventuallyResize { w h } 
     80    private method EnterLegend { x y }
     81    private method EventuallyRequestLegend {}
     82    private method EventuallyResize { w h }
    8383    private method EventuallyRotate { q }
    84     private method GetHeightmapScale {} 
    85     private method GetImage { args } 
    86     private method GetVtkData { args } 
     84    private method GetHeightmapScale {}
     85    private method GetImage { args }
     86    private method GetVtkData { args }
    8787    private method InitSettings { args  }
    88     private method IsValidObject { dataobj } 
     88    private method IsValidObject { dataobj }
    8989    private method LeaveLegend {}
    90     private method MotionLegend { x y } 
     90    private method MotionLegend { x y }
    9191    private method Pan {option x y}
    9292    private method PanCamera {}
    9393    private method Pick {x y}
    94     private method QuaternionToView { q } { 
     94    private method QuaternionToView { q } {
    9595        foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break
    9696    }
     
    104104    private method SetCurrentColormap { color }
    105105    private method SetLegendTip { x y }
    106     private method SetObjectStyle { dataobj comp } 
     106    private method SetObjectStyle { dataobj comp }
    107107    private method SetOrientation { side }
    108108    private method UpdateContourList {}
    109     private method ViewToQuaternion {} { 
     109    private method ViewToQuaternion {} {
    110110        return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)]
    111111    }
     
    116116    private variable _obj2datasets
    117117    private variable _obj2ovride   ;    # maps dataobj => style override
    118     private variable _comp2scale;       # maps dataset to the heightmap scale.
    119     private variable _datasets     ;    # contains all the dataobj-component 
     118    private variable _comp2scale;       # maps dataset to the heightmap scale.
     119    private variable _datasets     ;    # contains all the dataobj-component
    120120                                   ;    # datasets in the server
    121121    private variable _colormaps    ;    # contains all the colormaps
     
    133133
    134134    private variable _click        ;    # info used for rotate operations
    135     private variable _limits       ;    # Holds overall limits for all dataobjs 
     135    private variable _limits       ;    # Holds overall limits for all dataobjs
    136136                                        # using the viewer.
    137137    private variable _view         ;    # view params for 3D view
     
    158158    private variable _rotatePending 0
    159159    private variable _legendPending 0
    160     private variable _fieldNames {} 
    161     private variable _fields 
     160    private variable _fieldNames {}
     161    private variable _fields
    162162    private variable _curFldName ""
    163163    private variable _curFldLabel ""
     
    255255    } {
    256256        usual
    257         ignore -highlightthickness -borderwidth -background 
     257        ignore -highlightthickness -borderwidth -background
    258258    }
    259259
     
    261261        menu $itk_component(plotarea).menu \
    262262            -relief flat \
    263             -tearoff no 
     263            -tearoff no
    264264    } {
    265265        usual
     
    281281
    282282    set _map(id) [$c create image 0 0 -anchor nw -image $_image(plot)]
    283     set _map(cwidth) -1 
    284     set _map(cheight) -1 
     283    set _map(cwidth) -1
     284    set _map(cheight) -1
    285285    set _map(zoom) 1.0
    286286    set _map(original) ""
     
    350350        BuildCameraTab
    351351    } errs] != 0 } {
    352         global errorInfo
     352        global errorInfo
    353353        puts stderr "errs=$errs errorInfo=$errorInfo"
    354354    }
    355355
    356     # Hack around the Tk panewindow.  The problem is that the requested 
     356    # Hack around the Tk panewindow.  The problem is that the requested
    357357    # size of the 3d view isn't set until an image is retrieved from
    358358    # the server.  So the panewindow uses the tiny size.
     
    360360    pack forget $itk_component(view)
    361361    blt::table $itk_component(plotarea) \
    362         0,0 $itk_component(view) -fill both -reqwidth $w 
     362        0,0 $itk_component(view) -fill both -reqwidth $w
    363363    blt::table configure $itk_component(plotarea) c1 -resize none
    364364
     
    444444
    445445itcl::body Rappture::VtkHeightmapViewer::DoRotate {} {
    446     SendCmd "camera orient [ViewToQuaternion]" 
     446    SendCmd "camera orient [ViewToQuaternion]"
    447447    set _rotatePending 0
    448448}
     
    471471    if { !$_rotatePending } {
    472472        set _rotatePending 1
    473         global rotate_delay 
     473        global rotate_delay
    474474        $_dispatcher event -after $rotate_delay !rotate
    475475    }
     
    570570                    continue
    571571                }
    572                 if {[info exists _obj2ovride($dataobj-raise)] && 
     572                if {[info exists _obj2ovride($dataobj-raise)] &&
    573573                    $_obj2ovride($dataobj-raise)} {
    574574                    set dlist [linsert $dlist 0 $dataobj]
     
    598598            }
    599599            return $dlist
    600         }           
     600        }
    601601        -image {
    602602            if {[llength $args] != 2} {
     
    618618}
    619619
    620 # 
     620#
    621621# scale  --
    622622#
    623623#       This gets called either incrementally as new simulations are
    624624#       added or all at once as a sequence of heightmaps.
    625 #       This  accounts for all objects--even those not showing on the 
    626 #       screen.  Because of this, the limits are appropriate for all 
     625#       This  accounts for all objects--even those not showing on the
     626#       screen.  Because of this, the limits are appropriate for all
    627627#       objects as the user scans through data in the ResultSet viewer.
    628628#
     
    816816    $_dispatcher cancel !legend
    817817    # disconnected -- no more data sitting on server
    818     array unset _datasets 
    819     array unset _data 
    820     array unset _colormaps 
    821     array unset _obj2datasets 
     818    array unset _datasets
     819    array unset _data
     820    array unset _colormaps
     821    array unset _obj2datasets
    822822    global readyForNextFrame
    823823    set readyForNextFrame 1
     
    851851        set time [clock seconds]
    852852        set date [clock format $time]
    853         #puts stderr "$date: received image [image width $_image(plot)]x[image height $_image(plot)] image>"       
     853        #puts stderr "$date: received image [image width $_image(plot)]x[image height $_image(plot)] image>"
    854854        if { $_start > 0 } {
    855855            set finish [clock clicks -milliseconds]
     
    922922    # Turn on buffering of commands to the server.  We don't want to
    923923    # be preempted by a server disconnect/reconnect (which automatically
    924     # generates a new call to Rebuild).   
     924    # generates a new call to Rebuild).
    925925    StartBufferingCommands
    926926
    927927    if { $_width != $w || $_height != $h || $_reset } {
    928         set _width $w
    929         set _height $h
    930         $_arcball resize $w $h
    931         DoResize
    932         if { $_settings(-stretchtofit) } {
    933             AdjustSetting -stretchtofit
    934         }
     928        set _width $w
     929        set _height $h
     930        $_arcball resize $w $h
     931        DoResize
     932        if { $_settings(-stretchtofit) } {
     933            AdjustSetting -stretchtofit
     934        }
    935935    }
    936936    if { $_reset } {
    937         #
    938         # Reset the camera and other view parameters
    939         #
     937        #
     938        # Reset the camera and other view parameters
     939        #
    940940        InitSettings -isheightmap -background
    941941
    942942        # Setting a custom exponent and label format for axes is causing
    943         # a problem with rounding.  Near zero ticks aren't rounded by 
     943        # a problem with rounding.  Near zero ticks aren't rounded by
    944944        # the %g format.  The VTK CubeAxes seem to currently work best
    945         # when allowed to automatically set the exponent and precision 
    946         # based on the axis ranges.  This does tend to result in less 
    947         # visual clutter, so I think it is best to use the automatic 
     945        # when allowed to automatically set the exponent and precision
     946        # based on the axis ranges.  This does tend to result in less
     947        # visual clutter, so I think it is best to use the automatic
    948948        # settings by default.  We can test more fine-grained
    949949        # controls on the axis settings tab if necessary.
     
    951951        #SendCmd "axis exp 0 0 0 1"
    952952
    953         SendCmd "axis lrot z 90"
    954         $_arcball quaternion [ViewToQuaternion]
     953        SendCmd "axis lrot z 90"
     954        $_arcball quaternion [ViewToQuaternion]
    955955        if {$_settings(-isheightmap) } {
    956956            if { $_view(-ortho)} {
     
    961961            DoRotate
    962962            SendCmd "camera reset"
    963         }
    964         PanCamera
     963        }
     964        PanCamera
    965965        StopBufferingCommands
    966966        SendCmd "imgflush"
     
    981981            if { ![info exists _datasets($tag)] } {
    982982                set bytes [$dataobj vtkdata $comp]
    983                 if 0 {
     983                if 0 {
    984984                    set f [open /tmp/vtkheightmap.vtk "w"]
    985985                    fconfigure $f -translation binary -encoding binary
    986986                    puts -nonewline $f $bytes
    987987                    close $f
    988                 }
     988                }
    989989                set length [string length $bytes]
    990990                if { $_reportClientInfo }  {
     
    10111011                SendCmd "dataset visible 1 $tag"
    10121012            }
    1013             if { ![info exists _comp2scale($tag)] ||
    1014                 $_comp2scale($tag) != $scale } {
    1015                 SendCmd "heightmap heightscale $scale $tag"
    1016                 set _comp2scale($tag) $scale
    1017             }
     1013            if { ![info exists _comp2scale($tag)] ||
     1014                $_comp2scale($tag) != $scale } {
     1015                SendCmd "heightmap heightscale $scale $tag"
     1016                set _comp2scale($tag) $scale
     1017            }
    10181018        }
    10191019    }
    10201020    if { $_first != ""  } {
    1021         $itk_component(field) choices delete 0 end
    1022         $itk_component(fieldmenu) delete 0 end
    1023         array unset _fields
     1021        $itk_component(field) choices delete 0 end
     1022        $itk_component(fieldmenu) delete 0 end
     1023        array unset _fields
    10241024        set _curFldName ""
    10251025        foreach cname [$_first components] {
     
    10501050
    10511051    if { $_reset } {
    1052         SendCmd "axis tickpos outside"
     1052        SendCmd "axis tickpos outside"
    10531053        #SendCmd "axis lformat all %g"
    1054        
    1055         foreach axis { x y z } {
     1054
     1055        foreach axis { x y z } {
    10561056            if { $axis == "z" } {
    10571057                set label [$_first hints label]
     
    10591059                set label [$_first hints ${axis}label]
    10601060            }
    1061             if { $label == "" } {
    1062                 if {$axis == "z"} {
     1061            if { $label == "" } {
     1062                if {$axis == "z"} {
    10631063                    if { [string match "component*" $_curFldName] } {
    10641064                        set label [string toupper $axis]
     
    10661066                        set label $_curFldLabel
    10671067                    }
    1068                 } else {
    1069                     set label [string toupper $axis]
    1070                 }
    1071             }
    1072             # May be a space in the axis label.
    1073             SendCmd [list axis name $axis $label]
    1074 
    1075             if {$axis == "z" && [$_first hints ${axis}units] == ""} {
     1068                } else {
     1069                    set label [string toupper $axis]
     1070                }
     1071            }
     1072            # May be a space in the axis label.
     1073            SendCmd [list axis name $axis $label]
     1074
     1075            set units ""
     1076            if {$axis == "z" && [$_first hints ${axis}units] == ""} {
    10761077                if {$_curFldName != ""} {
    10771078                    set units [lindex $_fields($_curFldName) 1]
    10781079                }
    1079             } else {
    1080                 set units [$_first hints ${axis}units]
    1081             }
    1082             if { $units != "" } {
    1083                 # May be a space in the axis units.
    1084                 SendCmd [list axis units $axis $units]
    1085             }
    1086         }
    1087         #
    1088         # Reset the camera and other view parameters
    1089         #
    1090         ResetAxes
    1091         $_arcball quaternion [ViewToQuaternion]
     1080            } else {
     1081                set units [$_first hints ${axis}units]
     1082            }
     1083            if { $units != "" } {
     1084                # May be a space in the axis units.
     1085                SendCmd [list axis units $axis $units]
     1086            }
     1087        }
     1088        #
     1089        # Reset the camera and other view parameters
     1090        #
     1091        ResetAxes
     1092        $_arcball quaternion [ViewToQuaternion]
    10921093        if {$_settings(-isheightmap) } {
    10931094            if { $_view(-ortho)} {
     
    10991100            SendCmd "camera reset"
    11001101        }
    1101         PanCamera
    1102         InitSettings -xgrid -ygrid -zgrid \
    1103             -axisvisible -axislabels -heightmapscale -field -isheightmap \
     1102        PanCamera
     1103        InitSettings -xgrid -ygrid -zgrid \
     1104            -axisvisible -axislabels -heightmapscale -field -isheightmap \
    11041105            -numisolines
    11051106        if { [array size _fields] < 2 } {
     
    11101111    }
    11111112    global readyForNextFrame
    1112     set readyForNextFrame 0;            # Don't advance to the next frame
     1113    set readyForNextFrame 0;                # Don't advance to the next frame
    11131114
    11141115    # Actually write the commands to the server socket.  If it fails, we don't
     
    11281129itcl::body Rappture::VtkHeightmapViewer::CurrentDatasets {args} {
    11291130    set flag [lindex $args 0]
    1130     switch -- $flag { 
     1131    switch -- $flag {
    11311132        "-all" {
    11321133            if { [llength $args] > 1 } {
     
    11471148                set dlist [get -visible]
    11481149            }
    1149         }           
     1150        }
    11501151        default {
    11511152            set dlist $args
     
    12781279    foreach tag [CurrentDatasets -visible] {
    12791280        SendCmd "dataset getscalar pixel $x $y $tag"
    1280     } 
     1281    }
    12811282}
    12821283
     
    13821383        "-background" {
    13831384            set bg [$itk_component(background) value]
    1384             array set fgcolors {
    1385                 "black" "white"
    1386                 "white" "black"
    1387                 "grey"  "black"
    1388             }
     1385            array set fgcolors {
     1386                "black" "white"
     1387                "white" "black"
     1388                "grey"  "black"
     1389            }
    13891390            set fg $fgcolors($bg)
    13901391            configure -plotbackground $bg -plotforeground $fg
    1391             $itk_component(view) delete "legend"
     1392            $itk_component(view) delete "legend"
    13921393            SendCmd "screen bgcolor [Color2RGB $bg]"
    13931394            SendCmd "outline color [Color2RGB $fg]"
    13941395            SendCmd "axis color all [Color2RGB $fg]"
    1395             DrawLegend
     1396            DrawLegend
    13961397        }
    13971398        "-colormap" {
     
    14001401            set color [$itk_component(colormap) value]
    14011402            set _settings($what) $color
    1402             if { $color == "none" } {
    1403                 if { $_settings(-colormapvisible) } {
    1404                     SendCmd "heightmap surface 0"
    1405                     set _settings(-colormapvisible) 0
    1406                 }
    1407             } else {
    1408                 if { !$_settings(-colormapvisible) } {
    1409                     SendCmd "heightmap surface 1"
    1410                     set _settings(-colormapvisible) 1
    1411                 }
    1412                 SetCurrentColormap $color
     1403            if { $color == "none" } {
     1404                if { $_settings(-colormapvisible) } {
     1405                    SendCmd "heightmap surface 0"
     1406                    set _settings(-colormapvisible) 0
     1407                }
     1408            } else {
     1409                if { !$_settings(-colormapvisible) } {
     1410                    SendCmd "heightmap surface 1"
     1411                    set _settings(-colormapvisible) 1
     1412                }
     1413                SetCurrentColormap $color
    14131414                if {$_settings(-colormapdiscrete)} {
    14141415                    set numColors [expr $_settings(-numisolines) + 1]
    14151416                    SendCmd "colormap res $numColors $color"
    14161417                }
    1417             }
     1418            }
    14181419            StopBufferingCommands
    1419             EventuallyRequestLegend
     1420            EventuallyRequestLegend
    14201421        }
    14211422        "-colormapvisible" {
     
    14601461                return
    14611462            }
    1462             set label [$_first hints label]
    1463             if { $label == "" } {
     1463            set label [$_first hints label]
     1464            if { $label == "" } {
    14641465                if { [string match "component*" $_curFldName] } {
    14651466                    set label Z
     
    14671468                    set label $_curFldLabel
    14681469                }
    1469             }
    1470             # May be a space in the axis label.
    1471             SendCmd [list axis name z $label]
    1472 
    1473             if { [$_first hints zunits] == "" } {
    1474                 set units [lindex $_fields($_curFldName) 1]
    1475             } else {
    1476                 set units [$_first hints zunits]
    1477             }
    1478             if { $units != "" } {
    1479                 # May be a space in the axis units.
    1480                 SendCmd [list axis units z $units]
    1481             }
     1470            }
     1471            # May be a space in the axis label.
     1472            SendCmd [list axis name z $label]
     1473
     1474            if { [$_first hints zunits] == "" } {
     1475                set units [lindex $_fields($_curFldName) 1]
     1476            } else {
     1477                set units [$_first hints zunits]
     1478            }
     1479            if { $units != "" } {
     1480                # May be a space in the axis units.
     1481                SendCmd [list axis units z $units]
     1482            }
    14821483            # Get the new limits because the field changed.
    14831484            ResetAxes
     
    14891490        }
    14901491        "-heightmapscale" {
    1491             if { $_settings(-isheightmap) } {
    1492                 set scale [GetHeightmapScale]
    1493                 # Have to set the datasets individually because we are 
     1492            if { $_settings(-isheightmap) } {
     1493                set scale [GetHeightmapScale]
     1494                # Have to set the datasets individually because we are
    14941495                # tracking them in _comp2scale.
    14951496                foreach dataset [CurrentDatasets -all] {
    1496                     SendCmd "heightmap heightscale $scale $dataset"
    1497                     set _comp2scale($dataset) $scale
    1498                 }
    1499                 ResetAxes
    1500             }
     1497                    SendCmd "heightmap heightscale $scale $dataset"
     1498                    set _comp2scale($dataset) $scale
     1499                }
     1500                ResetAxes
     1501            }
    15011502        }
    15021503        "-isheightmap" {
    1503             set bool $_settings($what)
     1504            set bool $_settings($what)
    15041505            set c $itk_component(view)
    15051506            StartBufferingCommands
     
    15181519            InitSettings -lighting -opacity -outline
    15191520            set scale [GetHeightmapScale]
    1520             # Have to set the datasets individually because we are 
     1521            # Have to set the datasets individually because we are
    15211522            # tracking them in _comp2scale.
    15221523            foreach dataset [CurrentDatasets -all] {
     
    15241525                set _comp2scale($dataset) $scale
    15251526            }
    1526             if { $bool } {
    1527                 $itk_component(lighting) configure -state normal
    1528                 $itk_component(opacity) configure -state normal
    1529                 $itk_component(scale) configure -state normal
    1530                 $itk_component(opacity_l) configure -state normal
    1531                 $itk_component(scale_l) configure -state normal
    1532                 $itk_component(outline) configure -state disabled
     1527            if { $bool } {
     1528                $itk_component(lighting) configure -state normal
     1529                $itk_component(opacity) configure -state normal
     1530                $itk_component(scale) configure -state normal
     1531                $itk_component(opacity_l) configure -state normal
     1532                $itk_component(scale_l) configure -state normal
     1533                $itk_component(outline) configure -state disabled
    15331534                if {$_view(-ortho)} {
    15341535                    SendCmd "camera mode ortho"
     
    15361537                    SendCmd "camera mode persp"
    15371538                }
    1538             } else {
    1539                 $itk_component(lighting) configure -state disabled
    1540                 $itk_component(opacity) configure -state disabled
    1541                 $itk_component(scale) configure -state disabled
    1542                 $itk_component(opacity_l) configure -state disabled
    1543                 $itk_component(scale_l) configure -state disabled
    1544                 $itk_component(outline) configure -state normal
     1539            } else {
     1540                $itk_component(lighting) configure -state disabled
     1541                $itk_component(opacity) configure -state disabled
     1542                $itk_component(scale) configure -state disabled
     1543                $itk_component(opacity_l) configure -state disabled
     1544                $itk_component(scale_l) configure -state disabled
     1545                $itk_component(outline) configure -state normal
    15451546                SendCmd "camera mode image"
    15461547            }
     
    15561557                set q [ViewToQuaternion]
    15571558                $_arcball quaternion $q
    1558                 SendCmd "camera orient $q" 
     1559                SendCmd "camera orient $q"
    15591560            } else {
    15601561                bind $c <ButtonPress-1> {}
     
    15631564            }
    15641565            Zoom reset
    1565             # Fix the mouse bindings for rotation/panning and the 
     1566            # Fix the mouse bindings for rotation/panning and the
    15661567            # camera mode. Ideally we'd create a bindtag for these.
    15671568            if { $bool } {
     
    15781579        "-isolinecolor" {
    15791580            set color [$itk_component(isolinecolor) value]
    1580             if { $color == "none" } {
    1581                 if { $_settings(-isolinesvisible) } {
    1582                     SendCmd "heightmap isolines 0"
    1583                     set _settings(-isolinesvisible) 0
    1584                 }
    1585             } else {
    1586                 if { !$_settings(-isolinesvisible) } {
    1587                     SendCmd "heightmap isolines 1"
    1588                     set _settings(-isolinesvisible) 1
    1589                 }
    1590                 SendCmd "heightmap isolinecolor [Color2RGB $color]"
    1591             }
    1592             DrawLegend
     1581            if { $color == "none" } {
     1582                if { $_settings(-isolinesvisible) } {
     1583                    SendCmd "heightmap isolines 0"
     1584                    set _settings(-isolinesvisible) 0
     1585                }
     1586            } else {
     1587                if { !$_settings(-isolinesvisible) } {
     1588                    SendCmd "heightmap isolines 1"
     1589                    set _settings(-isolinesvisible) 1
     1590                }
     1591                SendCmd "heightmap isolinecolor [Color2RGB $color]"
     1592            }
     1593            DrawLegend
    15931594        }
    15941595        "-isolinesvisible" {
    1595             set bool $_settings($what)
     1596            set bool $_settings($what)
    15961597            SendCmd "heightmap isolines $bool"
    1597             DrawLegend
     1598            DrawLegend
    15981599        }
    15991600        "-legendvisible" {
    16001601            if { !$_settings($what) } {
    1601                 $itk_component(view) delete legend
    1602             }
    1603             DrawLegend
     1602                $itk_component(view) delete legend
     1603            }
     1604            DrawLegend
    16041605        }
    16051606        "-lighting" {
    1606             if { $_settings(-isheightmap) } {
     1607            if { $_settings(-isheightmap) } {
    16071608                set _settings(-savelighting) $_settings($what)
    1608                 set bool $_settings($what)
    1609                 SendCmd "heightmap lighting $bool"
    1610             } else {
    1611                 SendCmd "heightmap lighting 0"
    1612             }
     1609                set bool $_settings($what)
     1610                SendCmd "heightmap lighting $bool"
     1611            } else {
     1612                SendCmd "heightmap lighting 0"
     1613            }
    16131614        }
    16141615        "-numisolines" {
     
    16291630            set _changed($what) 1
    16301631            set val [expr $_settings($what) * 0.01]
    1631             if { $_settings(-isheightmap) } {
     1632            if { $_settings(-isheightmap) } {
    16321633                set _settings(-saveopacity) $_settings($what)
    16331634                SendCmd "heightmap opacity $val"
    16341635            } else {
    1635                 SendCmd "heightmap opacity 1.0"
     1636                SendCmd "heightmap opacity 1.0"
    16361637            }
    16371638        }
    16381639        "-outline" {
    1639             if { $_settings(-isheightmap) } {
    1640                 SendCmd "outline visible 0"
     1640            if { $_settings(-isheightmap) } {
     1641                SendCmd "outline visible 0"
    16411642            } else {
    16421643                set _settings(-saveoutline) $_settings($what)
     
    16441645                SendCmd "outline visible $bool"
    16451646            }
    1646         }
     1647        }
    16471648        "-stretchtofit" {
    1648             set bool $_settings($what)
    1649             if { $bool } {
    1650                 set heightScale [GetHeightmapScale]
    1651                 if {$heightScale == 0} {
    1652                     SendCmd "camera aspect window"
    1653                 } else {
    1654                     SendCmd "camera aspect square"
    1655                 }
    1656             } else {
    1657                 SendCmd "camera aspect native"
    1658             }
     1649            set bool $_settings($what)
     1650            if { $bool } {
     1651                set heightScale [GetHeightmapScale]
     1652                if {$heightScale == 0} {
     1653                    SendCmd "camera aspect window"
     1654                } else {
     1655                    SendCmd "camera aspect square"
     1656                }
     1657            } else {
     1658                SendCmd "camera aspect native"
     1659            }
    16591660            Zoom reset
    1660         }
     1661        }
    16611662        "-wireframe" {
    16621663            set bool $_settings($what)
     
    16681669            SendCmd "axis grid $axis $bool"
    16691670        }
    1670         default {
     1671        default {
    16711672            error "don't know how to fix $what"
    16721673        }
     
    16781679#
    16791680#       Request a new legend from the server.  The size of the legend
    1680 #       is determined from the height of the canvas. 
     1681#       is determined from the height of the canvas.
    16811682#
    16821683# This should be called when
    1683 #       1.  A new current colormap is set.
    1684 #       2.  Window is resized.
    1685 #       3.  The limits of the data have changed.  (Just need a redraw).
    1686 #       4.  Number of isolines have changed. (Just need a redraw).
    1687 #       5.  Legend becomes visible (Just need a redraw).
     1684#        1.  A new current colormap is set.
     1685#        2.  Window is resized.
     1686#        3.  The limits of the data have changed.  (Just need a redraw).
     1687#        4.  Number of isolines have changed. (Just need a redraw).
     1688#        5.  Legend becomes visible (Just need a redraw).
    16881689#
    16891690itcl::body Rappture::VtkHeightmapViewer::RequestLegend {} {
     
    16921693    set w 12
    16931694    set lineht [font metrics $font -linespace]
    1694     # color ramp height = (canvas height) - (min and max value lines) - 2 
     1695    # color ramp height = (canvas height) - (min and max value lines) - 2
    16951696    set h [expr {$_height - 2 * ($lineht + 2)}]
    16961697    set _legendHeight $h
     
    16981699    set fname $_curFldName
    16991700    if { [string match "component*" $fname] } {
    1700         set title ""
     1701        set title ""
    17011702    } else {
    1702         if { [info exists _fields($fname)] } {
    1703             foreach { title units } $_fields($fname) break
    1704             if { $units != "" } {
    1705                 set title [format "%s (%s)" $title $units]
    1706             }
    1707         } else {
    1708             set title $fname
    1709         }
     1703        if { [info exists _fields($fname)] } {
     1704            foreach { title units } $_fields($fname) break
     1705            if { $units != "" } {
     1706                set title [format "%s (%s)" $title $units]
     1707            }
     1708        } else {
     1709            set title $fname
     1710        }
    17101711    }
    17111712    # If there's a title too, substract one more line
    17121713    if { $title != "" } {
    1713         incr h -$lineht 
     1714        incr h -$lineht
    17141715    }
    17151716    if { $h < 1 } {
     
    17181719    # Set the legend on the first heightmap dataset.
    17191720    if { $_currentColormap != ""  } {
    1720         set cmap $_currentColormap
    1721         #SendCmd "legend $cmap scalar $_curFldName {} $w $h 0"
     1721        set cmap $_currentColormap
     1722        #SendCmd "legend $cmap scalar $_curFldName {} $w $h 0"
    17221723        SendCmd "legend2 $cmap $w $h"
    17231724    }
     
    17731774    # Keep track of the colormaps that we build.
    17741775    if { $name != "none" && ![info exists _colormaps($name)] } {
    1775         BuildColormap $name 
     1776        BuildColormap $name
    17761777        set _colormaps($name) 1
    17771778    }
     
    17991800itcl::configbody Rappture::VtkHeightmapViewer::mode {
    18001801    switch -- $itk_option(-mode) {
    1801         "heightmap" {
    1802             set _settings(-isheightmap) 1
    1803         }
    1804         "contour" {
    1805             set _settings(-isheightmap) 0
    1806         }
    1807         default {
    1808             error "unknown mode settings \"$itk_option(-mode)\""
    1809         }
     1802        "heightmap" {
     1803            set _settings(-isheightmap) 1
     1804        }
     1805        "contour" {
     1806            set _settings(-isheightmap) 0
     1807        }
     1808        default {
     1809            error "unknown mode settings \"$itk_option(-mode)\""
     1810        }
    18101811    }
    18111812    if { !$_reset } {
     
    18231824            SendCmd "screen bgcolor $rgb"
    18241825        }
    1825         $itk_component(view) configure -background $itk_option(-plotbackground)
     1826        $itk_component(view) configure -background $itk_option(-plotbackground)
    18261827    }
    18271828}
     
    18631864
    18641865    itk_component add lighting {
    1865         checkbutton $inner.lighting \
    1866             -text "Enable Lighting" \
    1867             -variable [itcl::scope _settings(-lighting)] \
    1868             -command [itcl::code $this AdjustSetting -lighting] \
    1869             -font "Arial 9"
     1866        checkbutton $inner.lighting \
     1867            -text "Enable Lighting" \
     1868            -variable [itcl::scope _settings(-lighting)] \
     1869            -command [itcl::code $this AdjustSetting -lighting] \
     1870            -font "Arial 9"
    18701871    } {
    1871         ignore -font
     1872        ignore -font
    18721873    }
    18731874    checkbutton $inner.edges \
     
    19051906
    19061907    itk_component add field_l {
    1907         label $inner.field_l -text "Field" -font "Arial 9" 
     1908        label $inner.field_l -text "Field" -font "Arial 9"
    19081909    } {
    19091910        ignore -font
     
    19151916        [itcl::code $this AdjustSetting -field]
    19161917
    1917     label $inner.colormap_l -text "Colormap" -font "Arial 9" 
     1918    label $inner.colormap_l -text "Colormap" -font "Arial 9"
    19181919    itk_component add colormap {
    19191920        Rappture::Combobox $inner.colormap -width 10 -editable no
     
    19241925        [itcl::code $this AdjustSetting -colormap]
    19251926
    1926     label $inner.isolinecolor_l -text "Isolines Color" -font "Arial 9" 
     1927    label $inner.isolinecolor_l -text "Isolines Color" -font "Arial 9"
    19271928    itk_component add isolinecolor {
    19281929        Rappture::Combobox $inner.isolinecolor -width 10 -editable no
     
    19381939        "red"                "red"              \
    19391940        "white"              "white"            \
    1940         "none"               "none"
     1941        "none"               "none"
    19411942
    19421943    $itk_component(isolinecolor) value $_settings(-isolinecolor)
    19431944    bind $inner.isolinecolor <<Value>> \
    1944         [itcl::code $this AdjustSetting -isolinecolor]
    1945 
    1946     label $inner.background_l -text "Background Color" -font "Arial 9" 
     1945        [itcl::code $this AdjustSetting -isolinecolor]
     1946
     1947    label $inner.background_l -text "Background Color" -font "Arial 9"
    19471948    itk_component add background {
    19481949        Rappture::Combobox $inner.background -width 10 -editable no
     
    19511952        "black"              "black"            \
    19521953        "white"              "white"            \
    1953         "grey"               "grey"             
     1954        "grey"               "grey"
    19541955
    19551956    $itk_component(background) value "white"
     
    19981999        2,0 $inner.isolinecolor_l  -anchor w -pady 2  \
    19992000        2,1 $inner.isolinecolor    -anchor w -pady 2 -fill x  \
    2000         3,0 $inner.background_l -anchor w -pady 2 \
    2001         3,1 $inner.background -anchor w -pady 2  -fill x \
     2001        3,0 $inner.background_l -anchor w -pady 2 \
     2002        3,1 $inner.background -anchor w -pady 2  -fill x \
    20022003        4,0 $inner.numisolines_l -anchor w -pady 2 \
    20032004        4,1 $inner.numisolines -anchor w -pady 2 \
     
    20412042        -command [itcl::code $this AdjustSetting -axislabels] \
    20422043        -font "Arial 9"
    2043     label $inner.grid_l -text "Grid" -font "Arial 9" 
     2044    label $inner.grid_l -text "Grid" -font "Arial 9"
    20442045    checkbutton $inner.xgrid \
    20452046        -text "X" \
     
    20632064        -font "Arial 9"
    20642065
    2065     label $inner.mode_l -text "Mode" -font "Arial 9" 
     2066    label $inner.mode_l -text "Mode" -font "Arial 9"
    20662067
    20672068    itk_component add axisflymode {
     
    20722073        "closest_triad"   "closest" \
    20732074        "furthest_triad"  "farthest" \
    2074         "outer_edges"     "outer"         
     2075        "outer_edges"     "outer"
    20752076    $itk_component(axisflymode) value $_settings(-axisflymode)
    20762077    bind $inner.mode <<Value>> [itcl::code $this AdjustSetting -axisflymode]
     
    20802081        1,0 $inner.labels  -anchor w -cspan 4 \
    20812082        2,0 $inner.minorticks  -anchor w -cspan 4 \
    2082         4,0 $inner.grid_l  -anchor w \
     2083        4,0 $inner.grid_l  -anchor w \
    20832084        4,1 $inner.xgrid   -anchor w \
    20842085        4,2 $inner.ygrid   -anchor w \
    20852086        4,3 $inner.zgrid   -anchor w \
    20862087        5,0 $inner.mode_l  -anchor w -padx { 2 0 } \
    2087         5,1 $inner.mode    -fill x -cspan 3 
     2088        5,1 $inner.mode    -fill x -cspan 3
    20882089
    20892090    blt::table configure $inner r* c* -resize none
     
    21442145
    21452146#
    2146 #  camera -- 
     2147#  camera --
    21472148#
    21482149itcl::body Rappture::VtkHeightmapViewer::camera {option args} {
    2149     switch -- $option { 
     2150    switch -- $option {
    21502151        "show" {
    21512152            puts [array get _view]
     
    21952196
    21962197itcl::body Rappture::VtkHeightmapViewer::GetImage { args } {
    2197     if { [image width $_image(download)] > 0 && 
     2198    if { [image width $_image(download)] > 0 &&
    21982199         [image height $_image(download)] > 0 } {
    21992200        set bytes [$_image(download) data -format "jpeg -quality 100"]
     
    22082209        -title "[Rappture::filexfer::label downloadWord] as..."
    22092210    set inner [$popup component inner]
    2210     label $inner.summary -text "" -anchor w 
     2211    label $inner.summary -text "" -anchor w
    22112212    radiobutton $inner.vtk_button -text "VTK data file" \
    22122213        -variable [itcl::scope _downloadPopup(format)] \
    22132214        -font "Arial 9 " \
    2214         -value vtk 
     2215        -value vtk
    22152216    Rappture::Tooltip::for $inner.vtk_button "Save as VTK data file."
    22162217    radiobutton $inner.image_button -text "Image File" \
    22172218        -variable [itcl::scope _downloadPopup(format)] \
    22182219        -font "Arial 9 " \
    2219         -value image 
     2220        -value image
    22202221    Rappture::Tooltip::for $inner.image_button \
    22212222        "Save as digital image."
     
    22382239        2,0 $inner.image_button -anchor w -cspan 2 -padx { 4 0 } \
    22392240        4,1 $inner.cancel -width .9i -fill y \
    2240         4,0 $inner.ok -padx 2 -width .9i -fill y 
     2241        4,0 $inner.ok -padx 2 -width .9i -fill y
    22412242    blt::table configure $inner r3 -height 4
    22422243    blt::table configure $inner r4 -pady 4
     
    22492250# SetObjectStyle --
    22502251#
    2251 #       Set the style of the heightmap/contour object.  This gets calls 
     2252#       Set the style of the heightmap/contour object.  This gets calls
    22522253#       for each dataset once as it is loaded.  It can overridden by
    22532254#       the user controls.
     
    23402341        #puts stderr "read $size bytes for [image width $_image(legend)]x[image height $_image(legend)] legend>"
    23412342        if { [catch {DrawLegend} errs] != 0 } {
    2342             global errorInfo
    2343             puts stderr "errs=$errs errorInfo=$errorInfo"
     2343            global errorInfo
     2344            puts stderr "errs=$errs errorInfo=$errorInfo"
    23442345        }
    23452346    }
     
    23582359    set font "Arial 8"
    23592360    set lineht [font metrics $font -linespace]
    2360    
     2361
    23612362    if { [string match "component*" $fname] } {
    2362         set title ""
     2363        set title ""
    23632364    } else {
    2364         if { [info exists _fields($fname)] } {
    2365             foreach { title units } $_fields($fname) break
    2366             if { $units != "" } {
    2367                 set title [format "%s (%s)" $title $units]
    2368             }
    2369         } else {
    2370             set title $fname
    2371         }
     2365        if { [info exists _fields($fname)] } {
     2366            foreach { title units } $_fields($fname) break
     2367            if { $units != "" } {
     2368                set title [format "%s (%s)" $title $units]
     2369            }
     2370        } else {
     2371            set title $fname
     2372        }
    23722373    }
    23732374    set x [expr $w - 2]
    23742375    if { !$_settings(-legendvisible) } {
    2375         $c delete legend
    2376         return
    2377     } 
     2376        $c delete legend
     2377        return
     2378    }
    23782379    if { [$c find withtag "legend"] == "" } {
    2379         set y 2
    2380         # If there's a legend title, create a text item for the title.
     2380        set y 2
     2381        # If there's a legend title, create a text item for the title.
    23812382        $c create text $x $y \
    23822383            -anchor ne \
     
    23862387            incr y $lineht
    23872388        }
    2388         $c create text $x $y \
     2389        $c create text $x $y \
    23892390            -anchor ne \
    23902391            -fill $itk_option(-plotforeground) -tags "vmax legend" \
    23912392            -font $font
    23922393        incr y $lineht
    2393         $c create image $x $y \
    2394             -anchor ne \
    2395             -image $_image(legend) -tags "colormap legend"
    2396         $c create rectangle $x $y 1 1 \
    2397             -fill "" -outline "" -tags "sensor legend"
    2398         $c create text $x [expr {$h-2}] \
    2399             -anchor se \
    2400             -fill $itk_option(-plotforeground) -tags "vmin legend" \
    2401             -font $font
    2402         $c bind sensor <Enter> [itcl::code $this EnterLegend %x %y]
    2403         $c bind sensor <Leave> [itcl::code $this LeaveLegend]
    2404         $c bind sensor <Motion> [itcl::code $this MotionLegend %x %y]
     2394        $c create image $x $y \
     2395            -anchor ne \
     2396            -image $_image(legend) -tags "colormap legend"
     2397        $c create rectangle $x $y 1 1 \
     2398            -fill "" -outline "" -tags "sensor legend"
     2399        $c create text $x [expr {$h-2}] \
     2400            -anchor se \
     2401            -fill $itk_option(-plotforeground) -tags "vmin legend" \
     2402            -font $font
     2403        $c bind sensor <Enter> [itcl::code $this EnterLegend %x %y]
     2404        $c bind sensor <Leave> [itcl::code $this LeaveLegend]
     2405        $c bind sensor <Motion> [itcl::code $this MotionLegend %x %y]
    24052406    }
    24062407    $c delete isoline
     
    24132414    # Draw the isolines on the legend.
    24142415    array unset _isolines
    2415     if { $color != "none"  && [info exists _limits($_curFldName)] && 
     2416    if { $color != "none"  && [info exists _limits($_curFldName)] &&
    24162417         $_settings(-isolinesvisible) && $_currentNumIsolines > 0 } {
    24172418
     
    24222423        }
    24232424        set tags "isoline legend"
    2424         set offset [expr 2 + $lineht]
    2425         if { $title != "" } {
    2426             incr offset $lineht
    2427         }
     2425        set offset [expr 2 + $lineht]
     2426        if { $title != "" } {
     2427            incr offset $lineht
     2428        }
    24282429        foreach value $_contourList {
    24292430            set norm [expr 1.0 - (($value - $vmin) / $range)]
     
    24332434                set _isolines([expr $y1 - $off]) $value
    24342435            }
    2435             $c create line $x1 $y1 $x2 $y1 -fill $color -tags $tags
    2436         }
     2436            $c create line $x1 $y1 $x2 $y1 -fill $color -tags $tags
     2437        }
    24372438    }
    24382439
     
    24432444    if { [info exists _limits($_curFldName)] } {
    24442445        foreach { vmin vmax } $_limits($_curFldName) break
    2445         $c itemconfigure vmin -text [format %g $vmin]
    2446         $c itemconfigure vmax -text [format %g $vmax]
     2446        $c itemconfigure vmin -text [format %g $vmin]
     2447        $c itemconfigure vmax -text [format %g $vmax]
    24472448    }
    24482449    set y 2
     
    24502451    if { $title != "" } {
    24512452        $c itemconfigure title -text $title
    2452         $c coords title $x $y
    2453         incr y $lineht
     2453        $c coords title $x $y
     2454        incr y $lineht
    24542455    }
    24552456    $c coords vmax $x $y
     
    24992500    set font "Arial 8"
    25002501    set lineht [font metrics $font -linespace]
    2501    
     2502
    25022503    set ih [image height $_image(legend)]
    25032504    # Subtract off the offset of the color ramp from the top of the canvas
     
    25052506
    25062507    if { [string match "component*" $fname] } {
    2507         set title ""
     2508        set title ""
    25082509    } else {
    2509         if { [info exists _fields($fname)] } {
    2510             foreach { title units } $_fields($fname) break
    2511             if { $units != "" } {
    2512                 set title [format "%s (%s)" $title $units]
    2513             }
    2514         } else {
    2515             set title $fname
    2516         }
     2510        if { [info exists _fields($fname)] } {
     2511            foreach { title units } $_fields($fname) break
     2512            if { $units != "" } {
     2513                set title [format "%s (%s)" $title $units]
     2514            }
     2515        } else {
     2516            set title $fname
     2517        }
    25172518    }
    25182519    # If there's a legend title, increase the offset by the line height.
     
    25302531    }
    25312532    set color [eval format "\#%02x%02x%02x" $pixel]
    2532     $_image(swatch) put black  -to 0 0 23 23 
    2533     $_image(swatch) put $color -to 1 1 22 22 
     2533    $_image(swatch) put black  -to 0 0 23 23
     2534    $_image(swatch) put $color -to 1 1 22 22
    25342535
    25352536    # Compute the value of the point
     
    25412542        set value 0.0
    25422543    }
    2543     set tipx [expr $x + 15] 
     2544    set tipx [expr $x + 15]
    25442545    set tipy [expr $y - 5]
    25452546    .rappturetooltip configure -icon $_image(swatch)
     
    25492550        Rappture::Tooltip::text $c [format "$title %g" $value]
    25502551    }
    2551     Rappture::Tooltip::tooltip show $c +$tipx,+$tipy   
     2552    Rappture::Tooltip::tooltip show $c +$tipx,+$tipy
    25522553}
    25532554
     
    25642565# ----------------------------------------------------------------------
    25652566itcl::body Rappture::VtkHeightmapViewer::Combo {option} {
    2566     set c $itk_component(view) 
     2567    set c $itk_component(view)
    25672568    switch -- $option {
    25682569        post {
     
    25772578        }
    25782579        deactivate {
    2579             $c itemconfigure title -fill $itk_option(-plotforeground) 
     2580            $c itemconfigure title -fill $itk_option(-plotforeground)
    25802581        }
    25812582        invoke {
     
    25912592itcl::body Rappture::VtkHeightmapViewer::GetHeightmapScale {} {
    25922593    if {  $_settings(-isheightmap) } {
    2593         set val $_settings(-heightmapscale)
    2594         set sval [expr { $val >= 50 ? double($val)/50.0 : 1.0/(2.0-(double($val)/50.0)) }]
    2595         return $sval
    2596     }
    2597     return 0 
    2598 }
    2599 
    2600 itcl::body Rappture::VtkHeightmapViewer::SetOrientation { side } { 
     2594        set val $_settings(-heightmapscale)
     2595        set sval [expr { $val >= 50 ? double($val)/50.0 : 1.0/(2.0-(double($val)/50.0)) }]
     2596        return $sval
     2597    }
     2598    return 0
     2599}
     2600
     2601itcl::body Rappture::VtkHeightmapViewer::SetOrientation { side } {
    26012602    array set positions {
    26022603        front  "0.707107 0.707107 0 0"
     
    26092610    foreach name { -qw -qx -qy -qz } value $positions($side) {
    26102611        set _view($name) $value
    2611     } 
     2612    }
    26122613    set q [ViewToQuaternion]
    26132614    $_arcball quaternion $q
     
    26192620}
    26202621
    2621 itcl::body Rappture::VtkHeightmapViewer::UpdateContourList {} { 
     2622itcl::body Rappture::VtkHeightmapViewer::UpdateContourList {} {
    26222623    if {$_currentNumIsolines == 0} {
    26232624        set _contourList ""
  • branches/uiuc_vtk_viewers/gui/scripts/vtkimageviewer.tcl

    r4769 r5053  
    1 # -*- mode: tcl; indent-tabs-mode: nil -*- 
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    22# ----------------------------------------------------------------------
    33#  COMPONENT: vtkimageviewer - Vtk image viewer
     
    5858    public method get {args}
    5959    public method isconnected {}
    60     public method parameters {title args} { 
    61         # do nothing 
     60    public method parameters {title args} {
     61        # do nothing
    6262    }
    6363    public method scale {args}
     
    6969    private method BuildColormap { name }
    7070    private method BuildImageTab {}
    71     private method BuildDownloadPopup { widget command } 
     71    private method BuildDownloadPopup { widget command }
    7272    private method Combo { option }
    7373    private method Connect {}
     
    7777    private method DoRotate {}
    7878    private method DrawLegend {}
    79     private method EnterLegend { x y } 
    80     private method EventuallyRequestLegend {} 
    81     private method EventuallyResize { w h } 
     79    private method EnterLegend { x y }
     80    private method EventuallyRequestLegend {}
     81    private method EventuallyResize { w h }
    8282    private method EventuallyRotate { q }
    83     private method GetImage { args } 
    84     private method GetVtkData { args } 
     83    private method GetImage { args }
     84    private method GetVtkData { args }
    8585    private method InitSettings { args  }
    86     private method IsValidObject { dataobj } 
     86    private method IsValidObject { dataobj }
    8787    private method LeaveLegend {}
    88     private method MotionLegend { x y } 
     88    private method MotionLegend { x y }
    8989    private method Pan {option x y}
    9090    private method PanCamera {}
    9191    private method Pick {x y}
    92     private method QuaternionToView { q } { 
     92    private method QuaternionToView { q } {
    9393        foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break
    9494    }
     
    101101    private method SetCurrentColormap { color }
    102102    private method SetLegendTip { x y }
    103     private method SetObjectStyle { dataobj comp } 
     103    private method SetObjectStyle { dataobj comp }
    104104    private method SetOrientation { side }
    105     private method ViewToQuaternion {} { 
     105    private method ViewToQuaternion {} {
    106106        return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)]
    107107    }
     
    112112    private variable _obj2datasets
    113113    private variable _obj2ovride   ;    # maps dataobj => style override
    114     private variable _datasets     ;    # contains all the dataobj-component 
     114    private variable _datasets     ;    # contains all the dataobj-component
    115115                                   ;    # datasets in the server
    116116    private variable _colormaps    ;    # contains all the colormaps
     
    128128
    129129    private variable _click        ;    # info used for rotate operations
    130     private variable _limits       ;    # Holds overall limits for all dataobjs 
     130    private variable _limits       ;    # Holds overall limits for all dataobjs
    131131                                        # using the viewer.
    132132    private variable _view         ;    # view params for 3D view
     
    153153    private variable _rotatePending 0
    154154    private variable _legendPending 0
    155     private variable _fieldNames {} 
    156     private variable _fields 
     155    private variable _fieldNames {}
     156    private variable _fields
    157157    private variable _curFldName ""
    158158    private variable _curFldLabel ""
     
    243243    } {
    244244        usual
    245         ignore -highlightthickness -borderwidth -background 
     245        ignore -highlightthickness -borderwidth -background
    246246    }
    247247
     
    249249        menu $itk_component(plotarea).menu \
    250250            -relief flat \
    251             -tearoff no 
     251            -tearoff no
    252252    } {
    253253        usual
     
    269269
    270270    set _map(id) [$c create image 0 0 -anchor nw -image $_image(plot)]
    271     set _map(cwidth) -1 
    272     set _map(cheight) -1 
     271    set _map(cwidth) -1
     272    set _map(cheight) -1
    273273    set _map(zoom) 1.0
    274274    set _map(original) ""
     
    338338        BuildCameraTab
    339339    } errs] != 0 } {
    340         global errorInfo
     340        global errorInfo
    341341        puts stderr "errs=$errs errorInfo=$errorInfo"
    342342    }
    343343
    344     # Hack around the Tk panewindow.  The problem is that the requested 
     344    # Hack around the Tk panewindow.  The problem is that the requested
    345345    # size of the 3d view isn't set until an image is retrieved from
    346346    # the server.  So the panewindow uses the tiny size.
     
    348348    pack forget $itk_component(view)
    349349    blt::table $itk_component(plotarea) \
    350         0,0 $itk_component(view) -fill both -reqwidth $w 
     350        0,0 $itk_component(view) -fill both -reqwidth $w
    351351    blt::table configure $itk_component(plotarea) c1 -resize none
    352352
     
    432432
    433433itcl::body Rappture::VtkImageViewer::DoRotate {} {
    434     SendCmd "camera orient [ViewToQuaternion]" 
     434    SendCmd "camera orient [ViewToQuaternion]"
    435435    set _rotatePending 0
    436436}
     
    459459    if { !$_rotatePending } {
    460460        set _rotatePending 1
    461         global rotate_delay 
     461        global rotate_delay
    462462        $_dispatcher event -after $rotate_delay !rotate
    463463    }
     
    558558                    continue
    559559                }
    560                 if {[info exists _obj2ovride($dataobj-raise)] && 
     560                if {[info exists _obj2ovride($dataobj-raise)] &&
    561561                    $_obj2ovride($dataobj-raise)} {
    562562                    set dlist [linsert $dlist 0 $dataobj]
     
    586586            }
    587587            return $dlist
    588         }           
     588        }
    589589        -image {
    590590            if {[llength $args] != 2} {
     
    606606}
    607607
    608 # 
     608#
    609609# scale  --
    610610#
    611611#       This gets called either incrementally as new simulations are
    612612#       added or all at once as a sequence of images.
    613 #       This  accounts for all objects--even those not showing on the 
    614 #       screen.  Because of this, the limits are appropriate for all 
     613#       This  accounts for all objects--even those not showing on the
     614#       screen.  Because of this, the limits are appropriate for all
    615615#       objects as the user scans through data in the ResultSet viewer.
    616616#
     
    804804    $_dispatcher cancel !legend
    805805    # disconnected -- no more data sitting on server
    806     array unset _datasets 
    807     array unset _data 
    808     array unset _colormaps 
    809     array unset _obj2datasets 
     806    array unset _datasets
     807    array unset _data
     808    array unset _colormaps
     809    array unset _obj2datasets
    810810    global readyForNextFrame
    811811    set readyForNextFrame 1
     
    839839        set time [clock seconds]
    840840        set date [clock format $time]
    841         #puts stderr "$date: received image [image width $_image(plot)]x[image height $_image(plot)] image>"       
     841        #puts stderr "$date: received image [image width $_image(plot)]x[image height $_image(plot)] image>"
    842842        if { $_start > 0 } {
    843843            set finish [clock clicks -milliseconds]
     
    910910    # Turn on buffering of commands to the server.  We don't want to
    911911    # be preempted by a server disconnect/reconnect (which automatically
    912     # generates a new call to Rebuild).   
     912    # generates a new call to Rebuild).
    913913    StartBufferingCommands
    914914
    915915    if { $_width != $w || $_height != $h || $_reset } {
    916         set _width $w
    917         set _height $h
    918         $_arcball resize $w $h
    919         DoResize
    920         if { $_settings(-stretchtofit) } {
    921             AdjustSetting -stretchToFit
    922         }
     916        set _width $w
     917        set _height $h
     918        $_arcball resize $w $h
     919        DoResize
     920        if { $_settings(-stretchtofit) } {
     921            AdjustSetting -stretchToFit
     922        }
    923923    }
    924924    if { $_reset } {
    925         #
    926         # Reset the camera and other view parameters
    927         #
     925        #
     926        # Reset the camera and other view parameters
     927        #
    928928        InitSettings -view3d -background
    929929
    930         SendCmd "axis lrot z 90"
    931         $_arcball quaternion [ViewToQuaternion]
     930        SendCmd "axis lrot z 90"
     931        $_arcball quaternion [ViewToQuaternion]
    932932        if {$_settings(-view3d) } {
    933933            if { $_view(-ortho)} {
     
    938938            DoRotate
    939939            SendCmd "camera reset"
    940         }
    941         PanCamera
     940        }
     941        PanCamera
    942942        StopBufferingCommands
    943943        SendCmd "imgflush"
     
    957957            if { ![info exists _datasets($tag)] } {
    958958                set bytes [$dataobj vtkdata $comp]
    959                 if 0 {
     959                if 0 {
    960960                    set f [open /tmp/vtkimage.vtk "w"]
    961961                    fconfigure $f -translation binary -encoding binary
    962962                    puts -nonewline $f $bytes
    963963                    close $f
    964                 }
     964                }
    965965                set length [string length $bytes]
    966966                if { $_reportClientInfo }  {
     
    990990    }
    991991    if { $_first != ""  } {
    992         $itk_component(field) choices delete 0 end
    993         $itk_component(fieldmenu) delete 0 end
    994         array unset _fields
     992        $itk_component(field) choices delete 0 end
     993        $itk_component(fieldmenu) delete 0 end
     994        array unset _fields
    995995        set _curFldName ""
    996996        foreach cname [$_first components] {
     
    10211021
    10221022    if { $_reset } {
    1023         SendCmd "axis tickpos outside"
     1023        SendCmd "axis tickpos outside"
    10241024        #SendCmd "axis lformat all %g"
    1025        
    1026         foreach axis { x y z } {
     1025
     1026        foreach axis { x y z } {
    10271027            set label [$_first hints ${axis}label]
    1028             if { $label == "" } {
    1029                 set label [string toupper $axis]
    1030             }
    1031             # May be a space in the axis label.
    1032             SendCmd [list axis name $axis $label]
    1033 
    1034             if {$axis == "z" && [$_first hints ${axis}units] == ""} {
     1028            if { $label == "" } {
     1029                set label [string toupper $axis]
     1030            }
     1031            # May be a space in the axis label.
     1032            SendCmd [list axis name $axis $label]
     1033
     1034            if {$axis == "z" && [$_first hints ${axis}units] == ""} {
    10351035                if {$_curFldName != ""} {
    10361036                    set units [lindex $_fields($_curFldName) 1]
    10371037                }
    1038             } else {
    1039                 set units [$_first hints ${axis}units]
    1040             }
    1041             if { $units != "" } {
    1042                 # May be a space in the axis units.
    1043                 SendCmd [list axis units $axis $units]
    1044             }
    1045         }
    1046         #
    1047         # Reset the camera and other view parameters
    1048         #
    1049         $_arcball quaternion [ViewToQuaternion]
     1038            } else {
     1039                set units [$_first hints ${axis}units]
     1040            }
     1041            if { $units != "" } {
     1042                # May be a space in the axis units.
     1043                SendCmd [list axis units $axis $units]
     1044            }
     1045        }
     1046        #
     1047        # Reset the camera and other view parameters
     1048        #
     1049        $_arcball quaternion [ViewToQuaternion]
    10501050        if {$_settings(-view3d) } {
    10511051            if { $_view(-ortho)} {
     
    10571057            SendCmd "camera reset"
    10581058        }
    1059         PanCamera
    1060         InitSettings -xgrid -ygrid -zgrid \
     1059        PanCamera
     1060        InitSettings -xgrid -ygrid -zgrid \
    10611061            -axisvisible -axislabels -field -view3d
    10621062        if { [array size _fields] < 2 } {
     
    10671067    }
    10681068    global readyForNextFrame
    1069     set readyForNextFrame 0;            # Don't advance to the next frame
     1069    set readyForNextFrame 0;                # Don't advance to the next frame
    10701070
    10711071    # Actually write the commands to the server socket.  If it fails, we don't
     
    10851085itcl::body Rappture::VtkImageViewer::CurrentDatasets {args} {
    10861086    set flag [lindex $args 0]
    1087     switch -- $flag { 
     1087    switch -- $flag {
    10881088        "-all" {
    10891089            if { [llength $args] > 1 } {
     
    11041104                set dlist [get -visible]
    11051105            }
    1106         }           
     1106        }
    11071107        default {
    11081108            set dlist $args
     
    12261226    foreach tag [CurrentDatasets -visible] {
    12271227        SendCmd "dataset getscalar pixel $x $y $tag"
    1228     } 
     1228    }
    12291229}
    12301230
     
    13301330        "-background" {
    13311331            set bg [$itk_component(background) value]
    1332             array set fgcolors {
    1333                 "black" "white"
    1334                 "white" "black"
    1335                 "grey"  "black"
    1336             }
     1332            array set fgcolors {
     1333                "black" "white"
     1334                "white" "black"
     1335                "grey"  "black"
     1336            }
    13371337            set fg $fgcolors($bg)
    13381338            configure -plotbackground $bg -plotforeground $fg
    1339             $itk_component(view) delete "legend"
     1339            $itk_component(view) delete "legend"
    13401340            SendCmd "screen bgcolor [Color2RGB $bg]"
    13411341            SendCmd "outline color [Color2RGB $fg]"
    13421342            SendCmd "axis color all [Color2RGB $fg]"
    1343             DrawLegend
     1343            DrawLegend
    13441344        }
    13451345        "-backingcolor" {
    13461346            set color [$itk_component(backingcolor) value]
    1347             if { $color == "none" } {
    1348                 if { $_settings(-backingvisible) } {
    1349                     SendCmd "image backing 0"
    1350                     set _settings(-backingvisible) 0
    1351                 }
    1352             } else {
    1353                 if { !$_settings(-backingvisible) } {
    1354                     SendCmd "image backing 1"
    1355                     set _settings(-backingvisible) 1
    1356                 }
    1357                 SendCmd "image color [Color2RGB $color]"
    1358             }
     1347            if { $color == "none" } {
     1348                if { $_settings(-backingvisible) } {
     1349                    SendCmd "image backing 0"
     1350                    set _settings(-backingvisible) 0
     1351                }
     1352            } else {
     1353                if { !$_settings(-backingvisible) } {
     1354                    SendCmd "image backing 1"
     1355                    set _settings(-backingvisible) 1
     1356                }
     1357                SendCmd "image color [Color2RGB $color]"
     1358            }
    13591359        }
    13601360        "-backingvisible" {
    1361             set bool $_settings($what)
     1361            set bool $_settings($what)
    13621362            SendCmd "image backing $bool"
    13631363        }
     
    13721372            }
    13731373            StopBufferingCommands
    1374             EventuallyRequestLegend
     1374            EventuallyRequestLegend
    13751375        }
    13761376        "-colormapdiscrete" {
     
    14101410        }
    14111411        "-view3d" {
    1412             set bool $_settings($what)
     1412            set bool $_settings($what)
    14131413            set c $itk_component(view)
    14141414            StartBufferingCommands
     
    14201420            }
    14211421            AdjustSetting -opacity
    1422             if { $bool } {
    1423                 $itk_component(opacity) configure -state normal
    1424                 $itk_component(opacity_l) configure -state normal
     1422            if { $bool } {
     1423                $itk_component(opacity) configure -state normal
     1424                $itk_component(opacity_l) configure -state normal
    14251425                if {$_view(-ortho)} {
    14261426                    SendCmd "camera mode ortho"
     
    14291429                }
    14301430                SendCmd "camera aspect native"
    1431             } else {
    1432                 $itk_component(opacity) configure -state disabled
    1433                 $itk_component(opacity_l) configure -state disabled
     1431            } else {
     1432                $itk_component(opacity) configure -state disabled
     1433                $itk_component(opacity_l) configure -state disabled
    14341434                SendCmd "camera mode image"
    14351435                if {$_settings(-stretchtofit)} {
     
    14401440                set q [ViewToQuaternion]
    14411441                $_arcball quaternion $q
    1442                 SendCmd "camera orient $q" 
     1442                SendCmd "camera orient $q"
    14431443            } else {
    14441444                bind $c <ButtonPress-1> {}
     
    14471447            }
    14481448            SendCmd "camera reset"
    1449             # Fix the mouse bindings for rotation/panning and the 
     1449            # Fix the mouse bindings for rotation/panning and the
    14501450            # camera mode. Ideally we'd create a bindtag for these.
    14511451            if { $bool } {
     
    14701470        "-legendvisible" {
    14711471            if { !$_settings($what) } {
    1472                 $itk_component(view) delete legend
    1473             }
    1474             DrawLegend
     1472                $itk_component(view) delete legend
     1473            }
     1474            DrawLegend
    14751475        }
    14761476        "-opacity" {
    14771477            set _changed($what) 1
    1478             if { $_settings(-view3d) } {
     1478            if { $_settings(-view3d) } {
    14791479                set _settings(-saveopacity) $_settings($what)
    14801480                set val [expr $_settings($what) * 0.01]
    14811481                SendCmd "image opacity $val"
    14821482            } else {
    1483                 SendCmd "image opacity 1.0"
     1483                SendCmd "image opacity 1.0"
    14841484            }
    14851485        }
     
    14871487            set bool $_settings($what)
    14881488            SendCmd "outline visible $bool"
    1489         }
     1489        }
    14901490        "-stretchtofit" {
    1491             set bool $_settings($what)
    1492             if { $bool } {
    1493                 if { $_settings(-view3d) } {
    1494                     SendCmd "camera aspect native"
    1495                 } else {
    1496                     SendCmd "camera aspect window"
    1497                 }
    1498             } else {
    1499                 SendCmd "camera aspect native"
    1500             }
    1501         }
     1491            set bool $_settings($what)
     1492            if { $bool } {
     1493                if { $_settings(-view3d) } {
     1494                    SendCmd "camera aspect native"
     1495                } else {
     1496                    SendCmd "camera aspect window"
     1497                }
     1498            } else {
     1499                SendCmd "camera aspect native"
     1500            }
     1501        }
    15021502        "-xgrid" - "-ygrid" - "-zgrid" {
    15031503            set axis [string tolower [string range $what 1 1]]
     
    15051505            SendCmd "axis grid $axis $bool"
    15061506        }
    1507         default {
     1507        default {
    15081508            error "don't know how to fix $what"
    15091509        }
     
    15151515#
    15161516#       Request a new legend from the server.  The size of the legend
    1517 #       is determined from the height of the canvas. 
     1517#       is determined from the height of the canvas.
    15181518#
    15191519# This should be called when
    1520 #       1.  A new current colormap is set.
    1521 #       2.  Window is resized.
    1522 #       3.  The limits of the data have changed.  (Just need a redraw).
    1523 #       4.  Number of isolines have changed. (Just need a redraw).
    1524 #       5.  Legend becomes visible (Just need a redraw).
     1520#        1.  A new current colormap is set.
     1521#        2.  Window is resized.
     1522#        3.  The limits of the data have changed.  (Just need a redraw).
     1523#        4.  Number of isolines have changed. (Just need a redraw).
     1524#        5.  Legend becomes visible (Just need a redraw).
    15251525#
    15261526itcl::body Rappture::VtkImageViewer::RequestLegend {} {
     
    15291529    set w 12
    15301530    set lineht [font metrics $font -linespace]
    1531     # color ramp height = (canvas height) - (min and max value lines) - 2 
     1531    # color ramp height = (canvas height) - (min and max value lines) - 2
    15321532    set h [expr {$_height - 2 * ($lineht + 2)}]
    15331533    set _legendHeight $h
     
    15351535    set fname $_curFldName
    15361536    if { [string match "component*" $fname] } {
    1537         set title ""
     1537        set title ""
    15381538    } else {
    1539         if { [info exists _fields($fname)] } {
    1540             foreach { title units } $_fields($fname) break
    1541             if { $units != "" } {
    1542                 set title [format "%s (%s)" $title $units]
    1543             }
    1544         } else {
    1545             set title $fname
    1546         }
     1539        if { [info exists _fields($fname)] } {
     1540            foreach { title units } $_fields($fname) break
     1541            if { $units != "" } {
     1542                set title [format "%s (%s)" $title $units]
     1543            }
     1544        } else {
     1545            set title $fname
     1546        }
    15471547    }
    15481548    # If there's a title too, substract one more line
    15491549    if { $title != "" } {
    1550         incr h -$lineht 
     1550        incr h -$lineht
    15511551    }
    15521552    if { $h < 1 } {
     
    15551555    # Set the legend on the first image dataset.
    15561556    if { $_currentColormap != "" && $_currentColormap != "none" } {
    1557         #SendCmd "legend $_currentColormap scalar $_curFldName {} $w $h 0"
     1557        #SendCmd "legend $_currentColormap scalar $_curFldName {} $w $h 0"
    15581558        SendCmd "legend2 $_currentColormap $w $h"
    15591559    }
     
    15661566    # Keep track of the colormaps that we build.
    15671567    if { $name != "none" && ![info exists _colormaps($name)] } {
    1568         BuildColormap $name 
     1568        BuildColormap $name
    15691569        set _colormaps($name) 1
    15701570    }
     
    15931593itcl::configbody Rappture::VtkImageViewer::mode {
    15941594    switch -- $itk_option(-mode) {
    1595         "volume" {
    1596             set _settings(-view3d) 1
    1597         }
    1598         "vtkimage" {
    1599             set _settings(-view3d) 0
    1600         }
    1601         default {
    1602             error "unknown mode settings \"$itk_option(-mode)\""
    1603         }
     1595        "volume" {
     1596            set _settings(-view3d) 1
     1597        }
     1598        "vtkimage" {
     1599            set _settings(-view3d) 0
     1600        }
     1601        default {
     1602            error "unknown mode settings \"$itk_option(-mode)\""
     1603        }
    16041604    }
    16051605    if { !$_reset } {
     
    16171617            SendCmd "screen bgcolor $rgb"
    16181618        }
    1619         $itk_component(view) configure -background $itk_option(-plotbackground)
     1619        $itk_component(view) configure -background $itk_option(-plotbackground)
    16201620    }
    16211621}
     
    16751675
    16761676    itk_component add field_l {
    1677         label $inner.field_l -text "Field" -font "Arial 9" 
     1677        label $inner.field_l -text "Field" -font "Arial 9"
    16781678    } {
    16791679        ignore -font
     
    16851685        [itcl::code $this AdjustSetting -field]
    16861686
    1687     label $inner.colormap_l -text "Colormap" -font "Arial 9" 
     1687    label $inner.colormap_l -text "Colormap" -font "Arial 9"
    16881688    itk_component add colormap {
    16891689        Rappture::Combobox $inner.colormap -width 10 -editable no
     
    16951695        [itcl::code $this AdjustSetting -colormap]
    16961696
    1697     label $inner.backingcolor_l -text "Backing Color" -font "Arial 9" 
     1697    label $inner.backingcolor_l -text "Backing Color" -font "Arial 9"
    16981698    itk_component add backingcolor {
    16991699        Rappture::Combobox $inner.backingcolor -width 10 -editable no
     
    17091709        "red"                "red"              \
    17101710        "white"              "white"            \
    1711         "none"               "none"
     1711        "none"               "none"
    17121712
    17131713    $itk_component(backingcolor) value $_settings(-backingcolor)
    17141714    bind $inner.backingcolor <<Value>> \
    1715         [itcl::code $this AdjustSetting -backingcolor]
    1716 
    1717     label $inner.background_l -text "Background Color" -font "Arial 9" 
     1715        [itcl::code $this AdjustSetting -backingcolor]
     1716
     1717    label $inner.background_l -text "Background Color" -font "Arial 9"
    17181718    itk_component add background {
    17191719        Rappture::Combobox $inner.background -width 10 -editable no
     
    17221722        "black"              "black"            \
    17231723        "white"              "white"            \
    1724         "grey"               "grey"             
     1724        "grey"               "grey"
    17251725
    17261726    $itk_component(background) value "white"
     
    17731773        2,0 $inner.backingcolor_l  -anchor w -pady 2  \
    17741774        2,1 $inner.backingcolor    -anchor w -pady 2 -fill x  \
    1775         3,0 $inner.background_l -anchor w -pady 2 \
    1776         3,1 $inner.background -anchor w -pady 2  -fill x \
     1775        3,0 $inner.background_l -anchor w -pady 2 \
     1776        3,1 $inner.background -anchor w -pady 2  -fill x \
    17771777        4,0 $inner.backing -anchor w -pady 2 -cspan 2 \
    17781778        5,0 $inner.stretch    -anchor w -pady 2 -cspan 2 \
     
    17871787        16,1 $inner.window   -fill x   -pady 2 \
    17881788        17,0 $inner.level_l -anchor w -pady 2 \
    1789         17,1 $inner.level   -fill x   -pady 2 
     1789        17,1 $inner.level   -fill x   -pady 2
    17901790
    17911791    blt::table configure $inner r* c* -resize none
     
    18131813        -command [itcl::code $this AdjustSetting -axislabels] \
    18141814        -font "Arial 9"
    1815     label $inner.grid_l -text "Grid" -font "Arial 9" 
     1815    label $inner.grid_l -text "Grid" -font "Arial 9"
    18161816    checkbutton $inner.xgrid \
    18171817        -text "X" \
     
    18351835        -font "Arial 9"
    18361836
    1837     label $inner.mode_l -text "Mode" -font "Arial 9" 
     1837    label $inner.mode_l -text "Mode" -font "Arial 9"
    18381838
    18391839    itk_component add axisflymode {
     
    18441844        "closest_triad"   "closest" \
    18451845        "furthest_triad"  "farthest" \
    1846         "outer_edges"     "outer"         
     1846        "outer_edges"     "outer"
    18471847    $itk_component(axisflymode) value $_settings(-axisflymode)
    18481848    bind $inner.mode <<Value>> [itcl::code $this AdjustSetting -axisflymode]
     
    18521852        1,0 $inner.labels  -anchor w -cspan 4 \
    18531853        2,0 $inner.minorticks  -anchor w -cspan 4 \
    1854         4,0 $inner.grid_l  -anchor w \
     1854        4,0 $inner.grid_l  -anchor w \
    18551855        4,1 $inner.xgrid   -anchor w \
    18561856        4,2 $inner.ygrid   -anchor w \
    18571857        4,3 $inner.zgrid   -anchor w \
    18581858        5,0 $inner.mode_l  -anchor w -padx { 2 0 } \
    1859         5,1 $inner.mode    -fill x -cspan 3 
     1859        5,1 $inner.mode    -fill x -cspan 3
    18601860
    18611861    blt::table configure $inner r* c* -resize none
     
    19161916
    19171917#
    1918 #  camera -- 
     1918#  camera --
    19191919#
    19201920itcl::body Rappture::VtkImageViewer::camera {option args} {
    1921     switch -- $option { 
     1921    switch -- $option {
    19221922        "show" {
    19231923            puts [array get _view]
     
    19671967
    19681968itcl::body Rappture::VtkImageViewer::GetImage { args } {
    1969     if { [image width $_image(download)] > 0 && 
     1969    if { [image width $_image(download)] > 0 &&
    19701970         [image height $_image(download)] > 0 } {
    19711971        set bytes [$_image(download) data -format "jpeg -quality 100"]
     
    19801980        -title "[Rappture::filexfer::label downloadWord] as..."
    19811981    set inner [$popup component inner]
    1982     label $inner.summary -text "" -anchor w 
     1982    label $inner.summary -text "" -anchor w
    19831983    radiobutton $inner.vtk_button -text "VTK data file" \
    19841984        -variable [itcl::scope _downloadPopup(format)] \
    19851985        -font "Arial 9 " \
    1986         -value vtk 
     1986        -value vtk
    19871987    Rappture::Tooltip::for $inner.vtk_button "Save as VTK data file."
    19881988    radiobutton $inner.image_button -text "Image File" \
    19891989        -variable [itcl::scope _downloadPopup(format)] \
    19901990        -font "Arial 9 " \
    1991         -value image 
     1991        -value image
    19921992    Rappture::Tooltip::for $inner.image_button \
    19931993        "Save as digital image."
     
    20102010        2,0 $inner.image_button -anchor w -cspan 2 -padx { 4 0 } \
    20112011        4,1 $inner.cancel -width .9i -fill y \
    2012         4,0 $inner.ok -padx 2 -width .9i -fill y 
     2012        4,0 $inner.ok -padx 2 -width .9i -fill y
    20132013    blt::table configure $inner r3 -height 4
    20142014    blt::table configure $inner r4 -pady 4
     
    20212021# SetObjectStyle --
    20222022#
    2023 #       Set the style of the image/contour object.  This gets calls 
     2023#       Set the style of the image/contour object.  This gets calls
    20242024#       for each dataset once as it is loaded.  It can overridden by
    20252025#       the user controls.
     
    20632063    SendCmd "outline visible $_settings(-outline) $tag"
    20642064    SendCmd "image add $tag"
    2065     SetCurrentColormap $style(-color) 
     2065    SetCurrentColormap $style(-color)
    20662066    set color [$itk_component(backingcolor) value]
    20672067    SendCmd "image color [Color2RGB $color] $tag"
     
    20942094        #puts stderr "read $size bytes for [image width $_image(legend)]x[image height $_image(legend)] legend>"
    20952095        if { [catch {DrawLegend} errs] != 0 } {
    2096             global errorInfo
    2097             puts stderr "errs=$errs errorInfo=$errorInfo"
     2096            global errorInfo
     2097            puts stderr "errs=$errs errorInfo=$errorInfo"
    20982098        }
    20992099    }
     
    21122112    set font "Arial 8"
    21132113    set lineht [font metrics $font -linespace]
    2114    
     2114
    21152115    if { [string match "component*" $fname] } {
    2116         set title ""
     2116        set title ""
    21172117    } else {
    2118         if { [info exists _fields($fname)] } {
    2119             foreach { title units } $_fields($fname) break
    2120             if { $units != "" } {
    2121                 set title [format "%s (%s)" $title $units]
    2122             }
    2123         } else {
    2124             set title $fname
    2125         }
     2118        if { [info exists _fields($fname)] } {
     2119            foreach { title units } $_fields($fname) break
     2120            if { $units != "" } {
     2121                set title [format "%s (%s)" $title $units]
     2122            }
     2123        } else {
     2124            set title $fname
     2125        }
    21262126    }
    21272127    set x [expr $w - 2]
    21282128    if { !$_settings(-legendvisible) } {
    2129         $c delete legend
    2130         return
    2131     } 
     2129        $c delete legend
     2130        return
     2131    }
    21322132    if { [$c find withtag "legend"] == "" } {
    2133         set y 2
    2134         # If there's a legend title, create a text item for the title.
     2133        set y 2
     2134        # If there's a legend title, create a text item for the title.
    21352135        $c create text $x $y \
    21362136            -anchor ne \
     
    21402140            incr y $lineht
    21412141        }
    2142         $c create text $x $y \
     2142        $c create text $x $y \
    21432143            -anchor ne \
    21442144            -fill $itk_option(-plotforeground) -tags "vmax legend" \
    21452145            -font $font
    21462146        incr y $lineht
    2147         $c create image $x $y \
    2148             -anchor ne \
    2149             -image $_image(legend) -tags "colormap legend"
    2150         $c create rectangle $x $y 1 1 \
    2151             -fill "" -outline "" -tags "sensor legend"
    2152         $c create text $x [expr {$h-2}] \
    2153             -anchor se \
    2154             -fill $itk_option(-plotforeground) -tags "vmin legend" \
    2155             -font $font
    2156         $c bind sensor <Enter> [itcl::code $this EnterLegend %x %y]
    2157         $c bind sensor <Leave> [itcl::code $this LeaveLegend]
    2158         $c bind sensor <Motion> [itcl::code $this MotionLegend %x %y]
     2147        $c create image $x $y \
     2148            -anchor ne \
     2149            -image $_image(legend) -tags "colormap legend"
     2150        $c create rectangle $x $y 1 1 \
     2151            -fill "" -outline "" -tags "sensor legend"
     2152        $c create text $x [expr {$h-2}] \
     2153            -anchor se \
     2154            -fill $itk_option(-plotforeground) -tags "vmin legend" \
     2155            -font $font
     2156        $c bind sensor <Enter> [itcl::code $this EnterLegend %x %y]
     2157        $c bind sensor <Leave> [itcl::code $this LeaveLegend]
     2158        $c bind sensor <Motion> [itcl::code $this MotionLegend %x %y]
    21592159    }
    21602160
     
    21702170    if { [info exists _limits($_curFldName)] } {
    21712171        foreach { vmin vmax } $_limits($_curFldName) break
    2172         $c itemconfigure vmin -text [format %g $vmin]
    2173         $c itemconfigure vmax -text [format %g $vmax]
     2172        $c itemconfigure vmin -text [format %g $vmin]
     2173        $c itemconfigure vmax -text [format %g $vmax]
    21742174    }
    21752175    set y 2
     
    21772177    if { $title != "" } {
    21782178        $c itemconfigure title -text $title
    2179         $c coords title $x $y
    2180         incr y $lineht
     2179        $c coords title $x $y
     2180        incr y $lineht
    21812181    }
    21822182    $c coords vmax $x $y
     
    22262226    set font "Arial 8"
    22272227    set lineht [font metrics $font -linespace]
    2228    
     2228
    22292229    set ih [image height $_image(legend)]
    22302230    # Subtract off the offset of the color ramp from the top of the canvas
     
    22322232
    22332233    if { [string match "component*" $fname] } {
    2234         set title ""
     2234        set title ""
    22352235    } else {
    2236         if { [info exists _fields($fname)] } {
    2237             foreach { title units } $_fields($fname) break
    2238             if { $units != "" } {
    2239                 set title [format "%s (%s)" $title $units]
    2240             }
    2241         } else {
    2242             set title $fname
    2243         }
     2236        if { [info exists _fields($fname)] } {
     2237            foreach { title units } $_fields($fname) break
     2238            if { $units != "" } {
     2239                set title [format "%s (%s)" $title $units]
     2240            }
     2241        } else {
     2242            set title $fname
     2243        }
    22442244    }
    22452245    # If there's a legend title, increase the offset by the line height.
     
    22572257    }
    22582258    set color [eval format "\#%02x%02x%02x" $pixel]
    2259     $_image(swatch) put black  -to 0 0 23 23 
    2260     $_image(swatch) put $color -to 1 1 22 22 
     2259    $_image(swatch) put black  -to 0 0 23 23
     2260    $_image(swatch) put $color -to 1 1 22 22
    22612261
    22622262    # Compute the value of the point
     
    22682268        set value 0.0
    22692269    }
    2270     set tipx [expr $x + 15] 
     2270    set tipx [expr $x + 15]
    22712271    set tipy [expr $y - 5]
    22722272    .rappturetooltip configure -icon $_image(swatch)
     
    22762276        Rappture::Tooltip::text $c [format "$title %g" $value]
    22772277    }
    2278     Rappture::Tooltip::tooltip show $c +$tipx,+$tipy   
     2278    Rappture::Tooltip::tooltip show $c +$tipx,+$tipy
    22792279}
    22802280
     
    22912291# ----------------------------------------------------------------------
    22922292itcl::body Rappture::VtkImageViewer::Combo {option} {
    2293     set c $itk_component(view) 
     2293    set c $itk_component(view)
    22942294    switch -- $option {
    22952295        post {
     
    23042304        }
    23052305        deactivate {
    2306             $c itemconfigure title -fill $itk_option(-plotforeground) 
     2306            $c itemconfigure title -fill $itk_option(-plotforeground)
    23072307        }
    23082308        invoke {
     
    23162316}
    23172317
    2318 itcl::body Rappture::VtkImageViewer::SetOrientation { side } { 
     2318itcl::body Rappture::VtkImageViewer::SetOrientation { side } {
    23192319    array set positions {
    23202320        front  "0.707107 0.707107 0 0"
     
    23272327    foreach name { -qw -qx -qy -qz } value $positions($side) {
    23282328        set _view($name) $value
    2329     } 
     2329    }
    23302330    set q [ViewToQuaternion]
    23312331    $_arcball quaternion $q
  • branches/uiuc_vtk_viewers/gui/scripts/vtkmeshviewer.tcl

    r4771 r5053  
    1 # -*- mode: tcl; indent-tabs-mode: nil -*- 
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    22# ----------------------------------------------------------------------
    33#  COMPONENT: vtkmeshviewer - Vtk mesh viewer
     
    5858    public method isconnected {}
    5959    public method limits { dataobj }
    60     public method parameters {title args} { 
    61         # do nothing 
     60    public method parameters {title args} {
     61        # do nothing
    6262    }
    6363    public method scale {args}
     
    6767    private method BuildAxisTab {}
    6868    private method BuildCameraTab {}
    69     private method BuildDownloadPopup { widget command } 
     69    private method BuildDownloadPopup { widget command }
    7070    private method BuildPolydataTab {}
    7171    private method Connect {}
     
    7474    private method DoResize {}
    7575    private method DoRotate {}
    76     private method EventuallyResize { w h } 
    77     private method EventuallyRotate { q } 
    78     private method EventuallySetPolydataOpacity {} 
    79     private method GetImage { args } 
    80     private method GetVtkData { args } 
     76    private method EventuallyResize { w h }
     77    private method EventuallyRotate { q }
     78    private method EventuallySetPolydataOpacity {}
     79    private method GetImage { args }
     80    private method GetVtkData { args }
    8181    private method InitSettings { args  }
    82     private method IsValidObject { dataobj } 
     82    private method IsValidObject { dataobj }
    8383    private method Pan {option x y}
    8484    private method PanCamera {}
    8585    private method Pick {x y}
    86     private method QuaternionToView { q } { 
     86    private method QuaternionToView { q } {
    8787        foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break
    8888    }
     
    9191    private method ReceiveImage { args }
    9292    private method Rotate {option x y}
    93     private method SetObjectStyle { dataobj } 
     93    private method SetObjectStyle { dataobj }
    9494    private method SetOrientation { side }
    9595    private method SetPolydataOpacity {}
    96     private method ViewToQuaternion {} { 
     96    private method ViewToQuaternion {} {
    9797        return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)]
    9898    }
     
    100100
    101101    private variable _arcball ""
    102     private variable _dlist "";         # list of data objects
     102    private variable _dlist "";         # list of data objects
    103103    private variable _obj2datasets
    104     private variable _obj2ovride;       # maps dataobj => style override
    105     private variable _datasets;         # contains all the dataobj-component
    106                                         # datasets in the server
    107     private variable _dataset2style;    # maps dataobj-component to transfunc
    108     private variable _style2datasets;   # maps tf back to list of
    109                                         # dataobj-components using the tf.
     104    private variable _obj2ovride;       # maps dataobj => style override
     105    private variable _datasets;         # contains all the dataobj-component
     106                                        # datasets in the server
     107    private variable _dataset2style;    # maps dataobj-component to transfunc
     108    private variable _style2datasets;   # maps tf back to list of
     109                                        # dataobj-components using the tf.
    110110    private variable _click;            # info used for rotate operations
    111111    private variable _limits;           # autoscale min/max for all axes
     
    200200    array set _widget {
    201201        -polydataopacity        100
    202     }       
     202    }
    203203    itk_component add view {
    204204        canvas $itk_component(plotarea).view \
     
    211211    itk_component add fieldmenu {
    212212        menu $itk_component(plotarea).menu -bg black -fg white -relief flat \
    213             -tearoff no 
     213            -tearoff no
    214214    } {
    215215        usual
     
    232232
    233233    set _map(id) [$c create image 0 0 -anchor nw -image $_image(plot)]
    234     set _map(cwidth) -1 
    235     set _map(cheight) -1 
     234    set _map(cwidth) -1
     235    set _map(cheight) -1
    236236    set _map(zoom) 1.0
    237237    set _map(original) ""
     
    279279    BuildCameraTab
    280280
    281     # Hack around the Tk panewindow.  The problem is that the requested 
     281    # Hack around the Tk panewindow.  The problem is that the requested
    282282    # size of the 3d view isn't set until an image is retrieved from
    283283    # the server.  So the panewindow uses the tiny size.
     
    285285    pack forget $itk_component(view)
    286286    blt::table $itk_component(plotarea) \
    287         0,0 $itk_component(view) -fill both -reqwidth $w 
     287        0,0 $itk_component(view) -fill both -reqwidth $w
    288288    blt::table configure $itk_component(plotarea) c1 -resize none
    289289
     
    372372
    373373itcl::body Rappture::VtkMeshViewer::DoRotate {} {
    374     SendCmd "camera orient [ViewToQuaternion]" 
     374    SendCmd "camera orient [ViewToQuaternion]"
    375375    set _rotatePending 0
    376376}
     
    497497                    continue
    498498                }
    499                 if {[info exists _obj2ovride($dataobj-raise)] && 
     499                if {[info exists _obj2ovride($dataobj-raise)] &&
    500500                    $_obj2ovride($dataobj-raise)} {
    501501                    set dlist [linsert $dlist 0 $dataobj]
     
    525525            }
    526526            return $dlist
    527         }           
     527        }
    528528        -image {
    529529            if {[llength $args] != 2} {
     
    814814    # Turn on buffering of commands to the server.  We don't want to
    815815    # be preempted by a server disconnect/reconnect (which automatically
    816     # generates a new call to Rebuild).   
     816    # generates a new call to Rebuild).
    817817    StartBufferingCommands
    818818
     
    897897        InitSettings -polydataedges -polydatalighting -polydataopacity \
    898898            -polydatavisible -polydatawireframe
    899  
     899
    900900        #SendCmd "axis lformat all %g"
    901901
     
    933933itcl::body Rappture::VtkMeshViewer::CurrentDatasets {args} {
    934934    set flag [lindex $args 0]
    935     switch -- $flag { 
     935    switch -- $flag {
    936936        "-all" {
    937937            if { [llength $args] > 1 } {
     
    952952                set dlist [get -visible]
    953953            }
    954         }           
     954        }
    955955        default {
    956956            set dlist $args
     
    10681068    foreach tag [CurrentDatasets -visible] {
    10691069        SendCmd "dataset getscalar pixel $x $y $tag"
    1070     } 
     1070    }
    10711071}
    10721072
     
    12451245        set f [open "$tmpfile" "w"]
    12461246        fconfigure $f -translation binary -encoding binary
    1247         puts $f $data 
     1247        puts $f $data
    12481248        close $f
    12491249        set reader [vtkDataSetReader $tag-xvtkDataSetReader]
     
    12931293        -variable [itcl::scope _settings(-polydatavisible)] \
    12941294        -command [itcl::code $this AdjustSetting -polydatavisible] \
    1295         -font "Arial 9" -anchor w 
     1295        -font "Arial 9" -anchor w
    12961296
    12971297    checkbutton $inner.outline \
     
    12991299        -variable [itcl::scope _settings(-outline)] \
    13001300        -command [itcl::code $this AdjustSetting -outline] \
    1301         -font "Arial 9" -anchor w 
     1301        -font "Arial 9" -anchor w
    13021302
    13031303    checkbutton $inner.wireframe \
     
    13051305        -variable [itcl::scope _settings(-polydatawireframe)] \
    13061306        -command [itcl::code $this AdjustSetting -polydatawireframe] \
    1307         -font "Arial 9" -anchor w 
     1307        -font "Arial 9" -anchor w
    13081308
    13091309    checkbutton $inner.lighting \
     
    13201320
    13211321    itk_component add field_l {
    1322         label $inner.field_l -text "Field" -font "Arial 9" 
     1322        label $inner.field_l -text "Field" -font "Arial 9"
    13231323    } {
    13241324        ignore -font
     
    13301330        [itcl::code $this AdjustSetting -field]
    13311331
    1332     label $inner.opacity_l -text "Opacity" -font "Arial 9" -anchor w 
     1332    label $inner.opacity_l -text "Opacity" -font "Arial 9" -anchor w
    13331333    ::scale $inner.opacity -from 0 -to 100 -orient horizontal \
    13341334        -variable [itcl::scope _widget(-polydataopacity)] \
     
    13451345        4,0 $inner.edges     -cspan 2  -anchor w -pady 2 \
    13461346        5,0 $inner.opacity_l -anchor w -pady 2 \
    1347         5,1 $inner.opacity   -fill x   -pady 2 
     1347        5,1 $inner.opacity   -fill x   -pady 2
    13481348
    13491349    blt::table configure $inner r* c* -resize none
     
    13721372        -command [itcl::code $this AdjustSetting -axislabels] \
    13731373        -font "Arial 9"
    1374     label $inner.grid_l -text "Grid" -font "Arial 9" 
     1374    label $inner.grid_l -text "Grid" -font "Arial 9"
    13751375    checkbutton $inner.xgrid \
    13761376        -text "X" \
     
    13941394        -font "Arial 9"
    13951395
    1396     label $inner.mode_l -text "Mode" -font "Arial 9" 
     1396    label $inner.mode_l -text "Mode" -font "Arial 9"
    13971397
    13981398    itk_component add axismode {
     
    14031403        "closest_triad"   "closest" \
    14041404        "furthest_triad"  "farthest" \
    1405         "outer_edges"     "outer"         
     1405        "outer_edges"     "outer"
    14061406    $itk_component(axismode) value "static"
    14071407    bind $inner.mode <<Value>> [itcl::code $this AdjustSetting -axismode]
     
    14751475
    14761476#
    1477 #  camera -- 
     1477#  camera --
    14781478#
    14791479itcl::body Rappture::VtkMeshViewer::camera {option args} {
    1480     switch -- $option { 
     1480    switch -- $option {
    14811481        "show" {
    14821482            puts [array get _view]
     
    15231523
    15241524itcl::body Rappture::VtkMeshViewer::GetImage { args } {
    1525     if { [image width $_image(download)] > 0 && 
     1525    if { [image width $_image(download)] > 0 &&
    15261526         [image height $_image(download)] > 0 } {
    15271527        set bytes [$_image(download) data -format "jpeg -quality 100"]
     
    15361536        -title "[Rappture::filexfer::label downloadWord] as..."
    15371537    set inner [$popup component inner]
    1538     label $inner.summary -text "" -anchor w 
     1538    label $inner.summary -text "" -anchor w
    15391539    radiobutton $inner.vtk_button -text "VTK data file" \
    15401540        -variable [itcl::scope _downloadPopup(format)] \
    15411541        -font "Helvetica 9 " \
    1542         -value vtk 
     1542        -value vtk
    15431543    Rappture::Tooltip::for $inner.vtk_button "Save as VTK data file."
    15441544    radiobutton $inner.image_button -text "Image File" \
    15451545        -variable [itcl::scope _downloadPopup(format)] \
    1546         -value image 
     1546        -value image
    15471547    Rappture::Tooltip::for $inner.image_button \
    15481548        "Save as digital image."
     
    15651565        2,0 $inner.image_button -anchor w -cspan 2 -padx { 4 0 } \
    15661566        4,1 $inner.cancel -width .9i -fill y \
    1567         4,0 $inner.ok -padx 2 -width .9i -fill y 
     1567        4,0 $inner.ok -padx 2 -width .9i -fill y
    15681568    blt::table configure $inner r3 -height 4
    15691569    blt::table configure $inner r4 -pady 4
     
    16341634}
    16351635
    1636 itcl::body Rappture::VtkMeshViewer::SetOrientation { side } { 
     1636itcl::body Rappture::VtkMeshViewer::SetOrientation { side } {
    16371637    array set positions {
    16381638        front "1 0 0 0"
     
    16451645    foreach name { -qw -qx -qy -qz } value $positions($side) {
    16461646        set _view($name) $value
    1647     } 
     1647    }
    16481648    set q [ViewToQuaternion]
    16491649    $_arcball quaternion $q
  • branches/uiuc_vtk_viewers/gui/scripts/vtkstreamlinesviewer.tcl

    r4942 r5053  
    1 # -*- mode: tcl; indent-tabs-mode: nil -*- 
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    22# ----------------------------------------------------------------------
    33#  COMPONENT: vtkstreamlinesviewer - Vtk streamlines object viewer
     
    5757    public method get {args}
    5858    public method isconnected {}
    59     public method parameters {title args} { 
    60         # do nothing 
     59    public method parameters {title args} {
     60        # do nothing
    6161    }
    6262    public method scale {args}
     
    6868    private method BuildColormap { name colors }
    6969    private method BuildCutplaneTab {}
    70     private method BuildDownloadPopup { widget command } 
     70    private method BuildDownloadPopup { widget command }
    7171    private method BuildStreamsTab {}
    7272    private method BuildVolumeTab {}
     
    7979    private method DoReseed {}
    8080    private method DoRotate {}
    81     private method EnterLegend { x y } 
    82     private method EventuallyResize { w h } 
    83     private method EventuallyReseed { numPoints } 
    84     private method EventuallyRotate { q } 
    85     private method EventuallySetCutplane { axis args } 
    86     private method GetImage { args } 
    87     private method GetVtkData { args } 
     81    private method EnterLegend { x y }
     82    private method EventuallyResize { w h }
     83    private method EventuallyReseed { numPoints }
     84    private method EventuallyRotate { q }
     85    private method EventuallySetCutplane { axis args }
     86    private method GetImage { args }
     87    private method GetVtkData { args }
    8888    private method InitSettings { args  }
    89     private method IsValidObject { dataobj } 
     89    private method IsValidObject { dataobj }
    9090    private method LeaveLegend {}
    91     private method MotionLegend { x y } 
     91    private method MotionLegend { x y }
    9292    private method Pan {option x y}
    9393    private method PanCamera {}
    9494    private method Pick {x y}
    95     private method QuaternionToView { q } { 
     95    private method QuaternionToView { q } {
    9696        foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break
    9797    }
     
    105105    private method ChangeColormap { dataobj comp color }
    106106    private method SetLegendTip { x y }
    107     private method SetObjectStyle { dataobj comp } 
    108     private method Slice {option args} 
     107    private method SetObjectStyle { dataobj comp }
     108    private method Slice {option args}
    109109    private method SetOrientation { side }
    110     private method ViewToQuaternion {} { 
     110    private method ViewToQuaternion {} {
    111111        return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)]
    112112    }
     
    118118    private variable _obj2datasets
    119119    private variable _obj2ovride   ;    # maps dataobj => style override
    120     private variable _datasets     ;    # contains all the dataobj-component 
     120    private variable _datasets     ;    # contains all the dataobj-component
    121121                                   ;    # datasets in the server
    122122    private variable _colormaps    ;    # contains all the colormaps
     
    147147    private variable _cutplanePending 0
    148148    private variable _legendPending 0
    149     private variable _vectorFields 
    150     private variable _scalarFields 
    151     private variable _fields 
     149    private variable _vectorFields
     150    private variable _scalarFields
     151    private variable _fields
    152152    private variable _curFldName ""
    153153    private variable _curFldLabel ""
     
    271271    itk_component add fieldmenu {
    272272        menu $itk_component(plotarea).menu -bg black -fg white -relief flat \
    273             -tearoff no 
     273            -tearoff no
    274274    } {
    275275        usual
     
    291291
    292292    set _map(id) [$c create image 0 0 -anchor nw -image $_image(plot)]
    293     set _map(cwidth) -1 
    294     set _map(cheight) -1 
     293    set _map(cwidth) -1
     294    set _map(cheight) -1
    295295    set _map(zoom) 1.0
    296296    set _map(original) ""
     
    338338            -offimage [Rappture::icon volume-off] \
    339339            -variable [itcl::scope _settings(-volumevisible)] \
    340             -command [itcl::code $this AdjustSetting -volumevisible] 
     340            -command [itcl::code $this AdjustSetting -volumevisible]
    341341    }
    342342    $itk_component(volume) select
     
    362362            -offimage [Rappture::icon cutbutton] \
    363363            -variable [itcl::scope _settings(-cutplanevisible)] \
    364             -command [itcl::code $this AdjustSetting -cutplanevisible] 
     364            -command [itcl::code $this AdjustSetting -cutplanevisible]
    365365    }
    366366    Rappture::Tooltip::for $itk_component(cutplane) \
     
    382382    set _image(legend) [image create photo]
    383383    itk_component add legend {
    384         canvas $itk_component(plotarea).legend -width 50 -highlightthickness 0 
     384        canvas $itk_component(plotarea).legend -width 50 -highlightthickness 0
    385385    } {
    386386        usual
     
    389389    }
    390390
    391     # Hack around the Tk panewindow.  The problem is that the requested 
     391    # Hack around the Tk panewindow.  The problem is that the requested
    392392    # size of the 3d view isn't set until an image is retrieved from
    393393    # the server.  So the panewindow uses the tiny size.
     
    395395    pack forget $itk_component(view)
    396396    blt::table $itk_component(plotarea) \
    397         0,0 $itk_component(view) -fill both -reqwidth $w 
     397        0,0 $itk_component(view) -fill both -reqwidth $w
    398398    blt::table configure $itk_component(plotarea) c1 -resize none
    399399
     
    480480
    481481itcl::body Rappture::VtkStreamlinesViewer::DoRotate {} {
    482     SendCmd "camera orient [ViewToQuaternion]" 
     482    SendCmd "camera orient [ViewToQuaternion]"
    483483    set _rotatePending 0
    484484}
     
    517517    if { !$_rotatePending } {
    518518        set _rotatePending 1
    519         global rotate_delay 
     519        global rotate_delay
    520520        $_dispatcher event -after $rotate_delay !rotate
    521521    }
     
    621621                    continue
    622622                }
    623                 if {[info exists _obj2ovride($dataobj-raise)] && 
     623                if {[info exists _obj2ovride($dataobj-raise)] &&
    624624                    $_obj2ovride($dataobj-raise)} {
    625625                    set dlist [linsert $dlist 0 $dataobj]
     
    649649            }
    650650            return $dlist
    651         }           
     651        }
    652652        -image {
    653653            if {[llength $args] != 2} {
     
    791791            set info {}
    792792            set user "???"
    793             if { [info exists env(USER)] } {
     793            if { [info exists env(USER)] } {
    794794                set user $env(USER)
    795             }
     795            }
    796796            set session "???"
    797             if { [info exists env(SESSION)] } {
     797            if { [info exists env(SESSION)] } {
    798798                set session $env(SESSION)
    799             }
     799            }
    800800            lappend info "version" "$Rappture::version"
    801801            lappend info "build" "$Rappture::build"
     
    851851    $_dispatcher cancel !legend
    852852    # disconnected -- no more data sitting on server
    853     array unset _datasets 
    854     array unset _data 
    855     array unset _colormaps 
    856     array unset _seeds 
    857     array unset _dataset2style 
    858     array unset _obj2datasets 
     853    array unset _datasets
     854    array unset _data
     855    array unset _colormaps
     856    array unset _seeds
     857    array unset _dataset2style
     858    array unset _obj2datasets
    859859}
    860860
     
    884884        set time [clock seconds]
    885885        set date [clock format $time]
    886         #puts stderr "$date: received image [image width $_image(plot)]x[image height $_image(plot)] image>"       
     886        #puts stderr "$date: received image [image width $_image(plot)]x[image height $_image(plot)] image>"
    887887        if { $_start > 0 } {
    888888            set finish [clock clicks -milliseconds]
     
    964964    set _first ""
    965965    if { $_reset } {
    966         set _width $w
    967         set _height $h
    968         $_arcball resize $w $h
    969         DoResize
    970         InitSettings -xgrid -ygrid -zgrid -axismode \
    971             -axesvisible -axislabelsvisible -axisminorticks
     966        set _width $w
     967        set _height $h
     968        $_arcball resize $w $h
     969        DoResize
     970        InitSettings -xgrid -ygrid -zgrid -axismode \
     971            -axesvisible -axislabelsvisible -axisminorticks
    972972        # This "imgflush" is to force an image returned before vtkvis starts
    973973        # reading a (big) dataset.  This will display an empty plot with axes
     
    988988                set bytes [$dataobj vtkdata $comp]
    989989                set length [string length $bytes]
    990                 if 0 {
     990                if 0 {
    991991                    set f [open /tmp/vtkstreamlines.vtk "w"]
    992992                    fconfigure $f -translation binary -encoding binary
    993993                    puts -nonewline $f $bytes
    994994                    close $f
    995                 }
     995                }
    996996                if { $_reportClientInfo }  {
    997997                    set info {}
     
    10321032            }
    10331033        }
    1034         $itk_component(field) choices delete 0 end
    1035         $itk_component(fieldmenu) delete 0 end
    1036         array unset _fields
     1034        $itk_component(field) choices delete 0 end
     1035        $itk_component(fieldmenu) delete 0 end
     1036        array unset _fields
    10371037        set _curFldName ""
    10381038        foreach cname [$_first components] {
     
    10681068            -volumevisible -volumeedges -volumelighting -volumeopacity \
    10691069            -volumewireframe \
    1070             -cutplanevisible \
    1071             -cutplanexposition -cutplaneyposition -cutplanezposition \
    1072             -cutplanexvisible -cutplaneyvisible -cutplanezvisible
    1073 
    1074         # Reset the camera and other view parameters
    1075         $_arcball quaternion [ViewToQuaternion]
    1076         if {$_view(-ortho)} {
    1077             SendCmd "camera mode ortho"
    1078         } else {
    1079             SendCmd "camera mode persp"
    1080         }
    1081         DoRotate
    1082         PanCamera
     1070            -cutplanevisible \
     1071            -cutplanexposition -cutplaneyposition -cutplanezposition \
     1072            -cutplanexvisible -cutplaneyvisible -cutplanezvisible
     1073
     1074        # Reset the camera and other view parameters
     1075        $_arcball quaternion [ViewToQuaternion]
     1076        if {$_view(-ortho)} {
     1077            SendCmd "camera mode ortho"
     1078        } else {
     1079            SendCmd "camera mode persp"
     1080        }
     1081        DoRotate
     1082        PanCamera
    10831083        Zoom reset
    10841084        SendCmd "camera reset"
     
    11011101itcl::body Rappture::VtkStreamlinesViewer::CurrentDatasets {args} {
    11021102    set flag [lindex $args 0]
    1103     switch -- $flag { 
     1103    switch -- $flag {
    11041104        "-all" {
    11051105            if { [llength $args] > 1 } {
     
    11201120                set dlist [get -visible]
    11211121            }
    1122         }           
     1122        }
    11231123        default {
    11241124            set dlist $args
     
    12391239    foreach tag [CurrentDatasets -visible] {
    12401240        SendCmdNoWait "dataset getscalar pixel $x $y $tag"
    1241     } 
     1241    }
    12421242}
    12431243
     
    16661666        2,0 $inner.edges     -anchor w -pady 2 -cspan 3 \
    16671667        3,0 $inner.opacity_l -anchor w -pady 2 \
    1668         3,1 $inner.opacity   -fill x   -pady 2 
     1668        3,1 $inner.opacity   -fill x   -pady 2
    16691669
    16701670    blt::table configure $inner r* c* -resize none
     
    16871687        -command [itcl::code $this AdjustSetting -streamlinesvisible] \
    16881688        -font "Arial 9"
    1689    
     1689
    16901690    checkbutton $inner.lighting \
    16911691        -text "Enable Lighting" \
     
    17001700        -font "Arial 9"
    17011701
    1702     label $inner.mode_l -text "Mode" -font "Arial 9" 
     1702    label $inner.mode_l -text "Mode" -font "Arial 9"
    17031703    itk_component add streammode {
    17041704        Rappture::Combobox $inner.mode -width 10 -editable no
     
    17071707        "lines"    "lines" \
    17081708        "ribbons"   "ribbons" \
    1709         "tubes"     "tubes" 
     1709        "tubes"     "tubes"
    17101710    $itk_component(streammode) value $_settings(-streamlinesmode)
    17111711    bind $inner.mode <<Value>> [itcl::code $this AdjustSetting -streamlinesmode]
     
    17321732        -command [itcl::code $this AdjustSetting -streamlinesscale]
    17331733
    1734     label $inner.field_l -text "Color by" -font "Arial 9" 
     1734    label $inner.field_l -text "Color by" -font "Arial 9"
    17351735    itk_component add field {
    17361736        Rappture::Combobox $inner.field -width 10 -editable no
     
    17391739        [itcl::code $this AdjustSetting -field]
    17401740
    1741     label $inner.colormap_l -text "Colormap" -font "Arial 9" 
     1741    label $inner.colormap_l -text "Colormap" -font "Arial 9"
    17421742    itk_component add colormap {
    17431743        Rappture::Combobox $inner.colormap -width 10 -editable no
     
    17881788        -command [itcl::code $this AdjustSetting -axislabelsvisible] \
    17891789        -font "Arial 9"
    1790     label $inner.grid_l -text "Grid" -font "Arial 9" 
     1790    label $inner.grid_l -text "Grid" -font "Arial 9"
    17911791    checkbutton $inner.xgrid \
    17921792        -text "X" \
     
    18101810        -font "Arial 9"
    18111811
    1812     label $inner.mode_l -text "Mode" -font "Arial 9" 
     1812    label $inner.mode_l -text "Mode" -font "Arial 9"
    18131813
    18141814    itk_component add axismode {
     
    18191819        "closest_triad"   "closest" \
    18201820        "furthest_triad"  "farthest" \
    1821         "outer_edges"     "outer"         
     1821        "outer_edges"     "outer"
    18221822    $itk_component(axismode) value $_settings(-axismode)
    18231823    bind $inner.mode <<Value>> [itcl::code $this AdjustSetting -axismode]
     
    18931893
    18941894    set fg [option get $itk_component(hull) font Font]
    1895    
     1895
    18961896    set inner [$itk_component(main) insert end \
    18971897        -title "Cutplane Settings" \
    1898         -icon [Rappture::icon cutbutton]] 
     1898        -icon [Rappture::icon cutbutton]]
    18991899
    19001900    $inner configure -borderwidth 4
     
    19501950            -command [itcl::code $this EventuallySetCutplane x] \
    19511951            -variable [itcl::scope _settings(-cutplanexposition)] \
    1952             -foreground red3 -font "Arial 9 bold"
     1952            -foreground red3 -font "Arial 9 bold"
    19531953    } {
    19541954        usual
     
    19791979            -command [itcl::code $this EventuallySetCutplane y] \
    19801980            -variable [itcl::scope _settings(-cutplaneyposition)] \
    1981             -foreground green3 -font "Arial 9 bold"
     1981            -foreground green3 -font "Arial 9 bold"
    19821982    } {
    19831983        usual
     
    20082008            -command [itcl::code $this EventuallySetCutplane z] \
    20092009            -variable [itcl::scope _settings(-cutplanezposition)] \
    2010             -foreground blue3 -font "Arial 9 bold"
     2010            -foreground blue3 -font "Arial 9 bold"
    20112011    } {
    20122012        usual
     
    20242024        3,0 $inner.opacity_l            -anchor w -pady 2 -cspan 1 \
    20252025        3,1 $inner.opacity              -fill x   -pady 2 -cspan 3 \
    2026         4,0 $itk_component(xCutButton)  -anchor w -padx 2 -pady 2 \
     2026        4,0 $itk_component(xCutButton)  -anchor w -padx 2 -pady 2 \
    20272027        5,0 $itk_component(yCutButton)  -anchor w -padx 2 -pady 2 \
    20282028        6,0 $itk_component(zCutButton)  -anchor w -padx 2 -pady 2 \
     
    20362036
    20372037#
    2038 #  camera -- 
     2038#  camera --
    20392039#
    20402040itcl::body Rappture::VtkStreamlinesViewer::camera {option args} {
    2041     switch -- $option { 
     2041    switch -- $option {
    20422042        "show" {
    20432043            puts [array get _view]
     
    20872087
    20882088itcl::body Rappture::VtkStreamlinesViewer::GetImage { args } {
    2089     if { [image width $_image(download)] > 0 && 
     2089    if { [image width $_image(download)] > 0 &&
    20902090         [image height $_image(download)] > 0 } {
    20912091        set bytes [$_image(download) data -format "jpeg -quality 100"]
     
    21002100        -title "[Rappture::filexfer::label downloadWord] as..."
    21012101    set inner [$popup component inner]
    2102     label $inner.summary -text "" -anchor w 
     2102    label $inner.summary -text "" -anchor w
    21032103    radiobutton $inner.vtk_button -text "VTK data file" \
    21042104        -variable [itcl::scope _downloadPopup(format)] \
    21052105        -font "Helvetica 9 " \
    2106         -value vtk 
     2106        -value vtk
    21072107    Rappture::Tooltip::for $inner.vtk_button "Save as VTK data file."
    21082108    radiobutton $inner.image_button -text "Image File" \
    21092109        -variable [itcl::scope _downloadPopup(format)] \
    2110         -value image 
     2110        -value image
    21112111    Rappture::Tooltip::for $inner.image_button \
    21122112        "Save as digital image."
     
    21292129        2,0 $inner.image_button -anchor w -cspan 2 -padx { 4 0 } \
    21302130        4,1 $inner.cancel -width .9i -fill y \
    2131         4,0 $inner.ok -padx 2 -width .9i -fill y 
     2131        4,0 $inner.ok -padx 2 -width .9i -fill y
    21322132    blt::table configure $inner r3 -height 4
    21332133    blt::table configure $inner r4 -pady 4
     
    21962196    set _legendPending 0
    21972197    set _title $title
    2198     regsub {\(mag\)} $title "" _title 
     2198    regsub {\(mag\)} $title "" _title
    21992199    if { [IsConnected] } {
    22002200        set bytes [ReceiveBytes $size]
     
    22232223    set font "Arial 8"
    22242224    set lineht [font metrics $font -linespace]
    2225    
     2225
    22262226    if { [info exists _fields($fname)] } {
    22272227        foreach { title units } $_fields($fname) break
     
    22352235        set x [expr $w - 2]
    22362236        if { [$c find withtag "legend"] == "" } {
    2237             set y 2 
     2237            set y 2
    22382238            $c create text $x $y \
    22392239                -anchor ne \
     
    23102310    set font "Arial 8"
    23112311    set lineht [font metrics $font -linespace]
    2312    
     2312
    23132313    set imgHeight [image height $_image(legend)]
    23142314    set coords [$c coords colormap]
     
    23332333    }
    23342334    set color [eval format "\#%02x%02x%02x" $pixel]
    2335     $_image(swatch) put black  -to 0 0 23 23 
    2336     $_image(swatch) put $color -to 1 1 22 22 
     2335    $_image(swatch) put black  -to 0 0 23 23
     2336    $_image(swatch) put $color -to 1 1 22 22
    23372337    .rappturetooltip configure -icon $_image(swatch)
    23382338
     
    23452345        set value 0.0
    23462346    }
    2347     set tipx [expr $x + 15] 
     2347    set tipx [expr $x + 15]
    23482348    set tipy [expr $y - 5]
    23492349    Rappture::Tooltip::text $c "$title $value"
    2350     Rappture::Tooltip::tooltip show $c +$tipx,+$tipy   
     2350    Rappture::Tooltip::tooltip show $c +$tipx,+$tipy
    23512351}
    23522352
     
    23932393# ----------------------------------------------------------------------
    23942394itcl::body Rappture::VtkStreamlinesViewer::Combo {option} {
    2395     set c $itk_component(view) 
     2395    set c $itk_component(view)
    23962396    switch -- $option {
    23972397        post {
     
    24062406        }
    24072407        deactivate {
    2408             $c itemconfigure title -fill white 
     2408            $c itemconfigure title -fill white
    24092409        }
    24102410        invoke {
     
    24182418}
    24192419
    2420 itcl::body Rappture::VtkStreamlinesViewer::SetOrientation { side } { 
     2420itcl::body Rappture::VtkStreamlinesViewer::SetOrientation { side } {
    24212421    array set positions {
    24222422        front "1 0 0 0"
     
    24292429    foreach name { -qw -qx -qy -qz } value $positions($side) {
    24302430        set _view($name) $value
    2431     } 
     2431    }
    24322432    set q [ViewToQuaternion]
    24332433    $_arcball quaternion $q
    2434     SendCmd "camera orient $q" 
     2434    SendCmd "camera orient $q"
    24352435    SendCmd "camera reset"
    24362436    set _view(-xpan) 0
  • branches/uiuc_vtk_viewers/gui/scripts/vtksurfaceviewer.tcl

    r4767 r5053  
    1 # -*- mode: tcl; indent-tabs-mode: nil -*- 
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    22# ----------------------------------------------------------------------
    33#  COMPONENT: vtksurfaceviewer - Vtk 3D boundary surface viewer
     
    5757    public method get {args}
    5858    public method isconnected {}
    59     public method parameters {title args} { 
    60         # do nothing 
     59    public method parameters {title args} {
     60        # do nothing
    6161    }
    6262    public method scale {args}
     
    6767    private method BuildCameraTab {}
    6868    private method BuildColormap { name }
    69     private method BuildDownloadPopup { widget command } 
     69    private method BuildDownloadPopup { widget command }
    7070    private method BuildSurfaceTab {}
    7171    private method Combo { option }
     
    7676    private method DoRotate {}
    7777    private method DrawLegend {}
    78     private method EnterLegend { x y } 
    79     private method EventuallyRequestLegend {} 
    80     private method EventuallyResize { w h } 
    81     private method EventuallyRotate { q } 
    82     private method GetImage { args } 
    83     private method GetVtkData { args } 
     78    private method EnterLegend { x y }
     79    private method EventuallyRequestLegend {}
     80    private method EventuallyResize { w h }
     81    private method EventuallyRotate { q }
     82    private method GetImage { args }
     83    private method GetVtkData { args }
    8484    private method InitSettings { args  }
    85     private method IsValidObject { dataobj } 
     85    private method IsValidObject { dataobj }
    8686    private method LeaveLegend {}
    87     private method MotionLegend { x y } 
     87    private method MotionLegend { x y }
    8888    private method Pan {option x y}
    8989    private method PanCamera {}
    9090    private method Pick {x y}
    91     private method QuaternionToView { q } { 
     91    private method QuaternionToView { q } {
    9292        foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break
    9393    }
     
    103103    private method SetOrientation { side }
    104104    private method UpdateContourList {}
    105     private method ViewToQuaternion {} { 
     105    private method ViewToQuaternion {} {
    106106        return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)]
    107107    }
     
    113113    private variable _obj2datasets
    114114    private variable _obj2ovride   ;    # maps dataobj => style override
    115     private variable _datasets     ;    # contains all the dataobj-component 
     115    private variable _datasets     ;    # contains all the dataobj-component
    116116                                   ;    # datasets in the server
    117117    private variable _colormaps    ;    # contains all the colormaps
     
    148148    private variable _legendPending 0
    149149    private variable _field      ""
    150     private variable _colorMode "scalar";       #  Mode of colormap (vmag or scalar)
    151     private variable _fieldNames {} 
    152     private variable _fields 
     150    private variable _colorMode "scalar";        #  Mode of colormap (vmag or scalar)
     151    private variable _fieldNames {}
     152    private variable _fields
    153153    private variable _curFldName ""
    154154    private variable _curFldLabel ""
     
    243243    itk_component add fieldmenu {
    244244        menu $itk_component(plotarea).menu -bg black -fg white -relief flat \
    245             -tearoff 0 
     245            -tearoff 0
    246246    } {
    247247        usual
     
    263263
    264264    set _map(id) [$c create image 0 0 -anchor nw -image $_image(plot)]
    265     set _map(cwidth) -1 
    266     set _map(cheight) -1 
     265    set _map(cwidth) -1
     266    set _map(cheight) -1
    267267    set _map(zoom) 1.0
    268268    set _map(original) ""
     
    311311            -offimage [Rappture::icon volume-off] \
    312312            -variable [itcl::scope _settings(-surfacevisible)] \
    313             -command [itcl::code $this AdjustSetting -surfacevisible] 
     313            -command [itcl::code $this AdjustSetting -surfacevisible]
    314314    }
    315315    $itk_component(surface) select
     
    329329    set _image(legend) [image create photo]
    330330    itk_component add legend {
    331         canvas $itk_component(plotarea).legend -width 50 -highlightthickness 0 
     331        canvas $itk_component(plotarea).legend -width 50 -highlightthickness 0
    332332    } {
    333333        usual
     
    336336    }
    337337
    338     # Hack around the Tk panewindow.  The problem is that the requested 
     338    # Hack around the Tk panewindow.  The problem is that the requested
    339339    # size of the 3d view isn't set until an image is retrieved from
    340340    # the server.  So the panewindow uses the tiny size.
     
    342342    pack forget $itk_component(view)
    343343    blt::table $itk_component(plotarea) \
    344         0,0 $itk_component(view) -fill both -reqwidth $w 
     344        0,0 $itk_component(view) -fill both -reqwidth $w
    345345    blt::table configure $itk_component(plotarea) c1 -resize none
    346346
     
    429429
    430430itcl::body Rappture::VtkSurfaceViewer::DoRotate {} {
    431     SendCmd "camera orient [ViewToQuaternion]" 
     431    SendCmd "camera orient [ViewToQuaternion]"
    432432    set _rotatePending 0
    433433}
     
    456456    if { !$_rotatePending } {
    457457        set _rotatePending 1
    458         global rotate_delay 
     458        global rotate_delay
    459459        $_dispatcher event -after $rotate_delay !rotate
    460460    }
     
    555555                    continue
    556556                }
    557                 if {[info exists _obj2ovride($dataobj-raise)] && 
     557                if {[info exists _obj2ovride($dataobj-raise)] &&
    558558                    $_obj2ovride($dataobj-raise)} {
    559559                    set dlist [linsert $dlist 0 $dataobj]
     
    583583            }
    584584            return $dlist
    585         }           
     585        }
    586586        -image {
    587587            if {[llength $args] != 2} {
     
    819819        #set w [image width $_image(plot)]
    820820        #set h [image height $_image(plot)]
    821         #puts stderr "$date: received image ${w}x${h} image"       
     821        #puts stderr "$date: received image ${w}x${h} image"
    822822        if { $_start > 0 } {
    823823            set finish [clock clicks -milliseconds]
     
    890890    # Turn on buffering of commands to the server.  We don't want to
    891891    # be preempted by a server disconnect/reconnect (which automatically
    892     # generates a new call to Rebuild).   
     892    # generates a new call to Rebuild).
    893893    StartBufferingCommands
    894894
     
    960960
    961961    if { $_first != "" } {
    962         $itk_component(field) choices delete 0 end
    963         $itk_component(fieldmenu) delete 0 end
    964         array unset _fields
     962        $itk_component(field) choices delete 0 end
     963        $itk_component(fieldmenu) delete 0 end
     964        array unset _fields
    965965        set _curFldName ""
    966966        foreach cname [$_first components] {
     
    990990    InitSettings -isolinesvisible -surfacevisible -outline
    991991    if { $_reset } {
    992         # These are settings that rely on a dataset being loaded.
     992        # These are settings that rely on a dataset being loaded.
    993993        InitSettings \
    994994            -surfacelighting \
    995995            -field \
    996996            -surfaceedges -surfacelighting -surfaceopacity \
    997             -surfacewireframe \
     997            -surfacewireframe \
    998998            -numcontours
    999999
    10001000        Zoom reset
    1001         foreach axis { x y z } {
     1001        foreach axis { x y z } {
    10021002            # Another problem fixed by a <view>. We looking into a data
    10031003            # object for the name of the axes. This should be global to
    10041004            # the viewer itself.
    1005             set label [$_first hints ${axis}label]
    1006             if { $label == "" } {
     1005            set label [$_first hints ${axis}label]
     1006            if { $label == "" } {
    10071007                set label [string toupper $axis]
    1008             }
    1009             # May be a space in the axis label.
    1010             SendCmd [list axis name $axis $label]
     1008            }
     1009            # May be a space in the axis label.
     1010            SendCmd [list axis name $axis $label]
    10111011        }
    10121012        if { [array size _fields] < 2 } {
     
    10321032itcl::body Rappture::VtkSurfaceViewer::CurrentDatasets {args} {
    10331033    set flag [lindex $args 0]
    1034     switch -- $flag { 
     1034    switch -- $flag {
    10351035        "-all" {
    10361036            if { [llength $args] > 1 } {
     
    10511051                set dlist [get -visible]
    10521052            }
    1053         }           
     1053        }
    10541054        default {
    10551055            set dlist $args
     
    11701170    foreach tag [CurrentDatasets -visible] {
    11711171        SendCmd "dataset getscalar pixel $x $y $tag"
    1172     } 
     1172    }
    11731173}
    11741174
     
    12741274        "-background" {
    12751275            set bgcolor [$itk_component(background) value]
    1276             array set fgcolors {
    1277                 "black" "white"
    1278                 "white" "black"
    1279                 "grey"  "black"
    1280             }
     1276            array set fgcolors {
     1277                "black" "white"
     1278                "white" "black"
     1279                "grey"  "black"
     1280            }
    12811281            configure -plotbackground $bgcolor \
    1282                 -plotforeground $fgcolors($bgcolor)
    1283             $itk_component(view) delete "legend"
    1284             DrawLegend
     1282                -plotforeground $fgcolors($bgcolor)
     1283            $itk_component(view) delete "legend"
     1284            DrawLegend
    12851285        }
    12861286        "-colormap" {
     
    12891289            set color [$itk_component(colormap) value]
    12901290            set _settings($what) $color
    1291             if { $color == "none" } {
    1292                 if { $_settings(-colormapvisible) } {
    1293                     SendCmd "contour2d colormode constant {}"
     1291            if { $color == "none" } {
     1292                if { $_settings(-colormapvisible) } {
     1293                    SendCmd "contour2d colormode constant {}"
    12941294                    SendCmd "polydata colormode constant {}"
    1295                     set _settings(-colormapvisible) 0
    1296                 }
    1297             } else {
    1298                 if { !$_settings(-colormapvisible) } {
    1299                     #SendCmd "contour2d colormode $_colorMode $_curFldName"
     1295                    set _settings(-colormapvisible) 0
     1296                }
     1297            } else {
     1298                if { !$_settings(-colormapvisible) } {
     1299                    #SendCmd "contour2d colormode $_colorMode $_curFldName"
    13001300                    SendCmd "polydata colormode $_colorMode $_curFldName"
    1301                     set _settings(-colormapvisible) 1
    1302                 }
    1303                 SetCurrentColormap $color
     1301                    set _settings(-colormapvisible) 1
     1302                }
     1303                SetCurrentColormap $color
    13041304                if {$_settings(-colormapdiscrete)} {
    13051305                    set numColors [expr $_settings(-numcontours) + 1]
    13061306                    SendCmd "colormap res $numColors $color"
    13071307                }
    1308             }
     1308            }
    13091309            StopBufferingCommands
    1310             EventuallyRequestLegend
     1310            EventuallyRequestLegend
    13111311        }
    13121312        "-colormapdiscrete" {
     
    13571357        "-isolinecolor" {
    13581358            set color [$itk_component(isolineColor) value]
    1359             set _settings($what) $color
     1359            set _settings($what) $color
    13601360            SendCmd "contour2d linecolor [Color2RGB $color]"
    1361             DrawLegend
     1361            DrawLegend
    13621362        }
    13631363        "-isolinesvisible" {
    13641364            set bool $_settings($what)
    1365             SendCmd "contour2d visible $bool"
    1366             DrawLegend
     1365            SendCmd "contour2d visible $bool"
     1366            DrawLegend
    13671367        }
    13681368        "-legendvisible" {
    13691369            if { !$_settings($what) } {
    13701370                $itk_component(view) delete legend
    1371             }
    1372             DrawLegend
     1371            }
     1372            DrawLegend
    13731373        }
    13741374        "-numcontours" {
     
    13881388        "-outline" {
    13891389            set bool $_settings($what)
    1390             SendCmd "outline visible $bool"
     1390            SendCmd "outline visible $bool"
    13911391        }
    13921392        "-surfaceedges" {
    13931393            set bool $_settings($what)
    1394             SendCmd "polydata edges $bool"
     1394            SendCmd "polydata edges $bool"
    13951395        }
    13961396        "-surfacelighting" {
    13971397            set bool $_settings($what)
    1398             SendCmd "polydata lighting $bool"
     1398            SendCmd "polydata lighting $bool"
    13991399        }
    14001400        "-surfaceopacity" {
    14011401            set val $_settings($what)
    14021402            set sval [expr { 0.01 * double($val) }]
    1403             SendCmd "polydata opacity $sval"
     1403            SendCmd "polydata opacity $sval"
    14041404        }
    14051405        "-surfacevisible" {
    14061406            set bool $_settings($what)
    1407             SendCmd "polydata visible $bool"
     1407            SendCmd "polydata visible $bool"
    14081408            if { $bool } {
    14091409                Rappture::Tooltip::for $itk_component(surface) \
     
    14131413                    "Show the surface"
    14141414            }
    1415             DrawLegend
     1415            DrawLegend
    14161416        }
    14171417        "-surfacewireframe" {
    14181418            set bool $_settings($what)
    1419             SendCmd "polydata wireframe $bool"
     1419            SendCmd "polydata wireframe $bool"
    14201420        }
    14211421        "-xgrid" - "-ygrid" - "-zgrid" {
     
    14341434#
    14351435#       Request a new legend from the server.  The size of the legend
    1436 #       is determined from the height of the canvas. 
     1436#       is determined from the height of the canvas.
    14371437#
    14381438# This should be called when
    1439 #       1.  A new current colormap is set.
    1440 #       2.  Window is resized.
    1441 #       3.  The limits of the data have changed.  (Just need a redraw).
    1442 #       4.  Number of isolines have changed. (Just need a redraw).
    1443 #       5.  Legend becomes visible (Just need a redraw).
     1439#        1.  A new current colormap is set.
     1440#        2.  Window is resized.
     1441#        3.  The limits of the data have changed.  (Just need a redraw).
     1442#        4.  Number of isolines have changed. (Just need a redraw).
     1443#        5.  Legend becomes visible (Just need a redraw).
    14441444#
    14451445itcl::body Rappture::VtkSurfaceViewer::RequestLegend {} {
     
    14571457    }
    14581458    if { [string match "component*" $fname] } {
    1459         set title ""
     1459        set title ""
    14601460    } else {
    1461         if { [info exists _fields($fname)] } {
    1462             foreach { title units } $_fields($fname) break
    1463             if { $units != "" } {
    1464                 set title [format "%s (%s)" $title $units]
    1465             }
    1466         } else {
    1467             set title $fname
    1468         }
     1461        if { [info exists _fields($fname)] } {
     1462            foreach { title units } $_fields($fname) break
     1463            if { $units != "" } {
     1464                set title [format "%s (%s)" $title $units]
     1465            }
     1466        } else {
     1467            set title $fname
     1468        }
    14691469    }
    14701470    # If there's a title too, subtract one more line
    14711471    if { $title != "" } {
    1472         incr h -$lineht 
     1472        incr h -$lineht
    14731473    }
    14741474    # Set the legend on the first heightmap dataset.
    14751475    if { $_currentColormap != ""  } {
    1476         set cmap $_currentColormap
    1477         SendCmdNoWait "legend $cmap scalar $_curFldName {} $w $h 0"
     1476        set cmap $_currentColormap
     1477        SendCmdNoWait "legend $cmap scalar $_curFldName {} $w $h 0"
    14781478    }
    14791479}
     
    14951495    if { [isconnected] } {
    14961496        set rgb [Color2RGB $itk_option(-plotforeground)]
    1497         SendCmd "axis color all $rgb"
     1497        SendCmd "axis color all $rgb"
    14981498        SendCmd "outline color $rgb"
    14991499    }
     
    15581558        -font "Arial 9"
    15591559
    1560     label $inner.linecolor_l -text "Isolines" -font "Arial 9" 
     1560    label $inner.linecolor_l -text "Isolines" -font "Arial 9"
    15611561    itk_component add isolineColor {
    15621562        Rappture::Combobox $inner.linecolor -width 10 -editable 0
     
    15721572        "red"                "red"              \
    15731573        "white"              "white"            \
    1574         "none"               "none"
     1574        "none"               "none"
    15751575
    15761576    $itk_component(isolineColor) value "white"
    15771577    bind $inner.linecolor <<Value>> \
    1578         [itcl::code $this AdjustSetting -isolinecolor]
    1579 
    1580     label $inner.background_l -text "Background" -font "Arial 9" 
     1578        [itcl::code $this AdjustSetting -isolinecolor]
     1579
     1580    label $inner.background_l -text "Background" -font "Arial 9"
    15811581    itk_component add background {
    15821582        Rappture::Combobox $inner.background -width 10 -editable 0
     
    15851585        "black"              "black"            \
    15861586        "white"              "white"            \
    1587         "grey"               "grey"             
     1587        "grey"               "grey"
    15881588
    15891589    $itk_component(background) value $_settings(-background)
     
    15991599
    16001600    itk_component add field_l {
    1601         label $inner.field_l -text "Field" -font "Arial 9" 
     1601        label $inner.field_l -text "Field" -font "Arial 9"
    16021602    } {
    16031603        ignore -font
     
    16091609        [itcl::code $this AdjustSetting -field]
    16101610
    1611     label $inner.colormap_l -text "Colormap" -font "Arial 9" 
     1611    label $inner.colormap_l -text "Colormap" -font "Arial 9"
    16121612    itk_component add colormap {
    16131613        Rappture::Combobox $inner.colormap -width 10 -editable 0
     
    16351635        2,0 $inner.linecolor_l  -anchor w -pady 2  \
    16361636        2,1 $inner.linecolor    -anchor w -pady 2 -fill x  \
    1637         3,0 $inner.background_l -anchor w -pady 2 \
    1638         3,1 $inner.background -anchor w -pady 2  -fill x \
     1637        3,0 $inner.background_l -anchor w -pady 2 \
     1638        3,1 $inner.background -anchor w -pady 2  -fill x \
    16391639        4,0 $inner.numcontours_l -anchor w -pady 2 \
    16401640        4,1 $inner.numcontours -anchor w -pady 2 \
     
    16741674        -command [itcl::code $this AdjustSetting -axislabels] \
    16751675        -font "Arial 9"
    1676     label $inner.grid_l -text "Grid" -font "Arial 9" 
     1676    label $inner.grid_l -text "Grid" -font "Arial 9"
    16771677    checkbutton $inner.xgrid \
    16781678        -text "X" \
     
    16961696        -font "Arial 9"
    16971697
    1698     label $inner.mode_l -text "Mode" -font "Arial 9" 
     1698    label $inner.mode_l -text "Mode" -font "Arial 9"
    16991699
    17001700    itk_component add axisMode {
     
    17051705        "closest_triad"   "closest" \
    17061706        "furthest_triad"  "farthest" \
    1707         "outer_edges"     "outer"         
     1707        "outer_edges"     "outer"
    17081708    $itk_component(axisMode) value $_settings(-axismode)
    17091709    bind $inner.mode <<Value>> [itcl::code $this AdjustSetting -axismode]
     
    17771777
    17781778#
    1779 #  camera -- 
     1779#  camera --
    17801780#
    17811781itcl::body Rappture::VtkSurfaceViewer::camera {option args} {
    1782     switch -- $option { 
     1782    switch -- $option {
    17831783        "show" {
    17841784            puts [array get _view]
     
    18281828
    18291829itcl::body Rappture::VtkSurfaceViewer::GetImage { args } {
    1830     if { [image width $_image(download)] > 0 && 
     1830    if { [image width $_image(download)] > 0 &&
    18311831         [image height $_image(download)] > 0 } {
    18321832        set bytes [$_image(download) data -format "jpeg -quality 100"]
     
    18411841        -title "[Rappture::filexfer::label downloadWord] as..."
    18421842    set inner [$popup component inner]
    1843     label $inner.summary -text "" -anchor w 
     1843    label $inner.summary -text "" -anchor w
    18441844    radiobutton $inner.vtk_button -text "VTK data file" \
    18451845        -variable [itcl::scope _downloadPopup(format)] \
    18461846        -font "Arial 9 " \
    1847         -value vtk 
     1847        -value vtk
    18481848    Rappture::Tooltip::for $inner.vtk_button "Save as VTK data file."
    18491849    radiobutton $inner.image_button -text "Image File" \
    18501850        -variable [itcl::scope _downloadPopup(format)] \
    18511851        -font "Arial 9 " \
    1852         -value image 
     1852        -value image
    18531853    Rappture::Tooltip::for $inner.image_button \
    18541854        "Save as digital image."
     
    18711871        2,0 $inner.image_button -anchor w -cspan 2 -padx { 4 0 } \
    18721872        4,1 $inner.cancel -width .9i -fill y \
    1873         4,0 $inner.ok -padx 2 -width .9i -fill y 
     1873        4,0 $inner.ok -padx 2 -width .9i -fill y
    18741874    blt::table configure $inner r3 -height 4
    18751875    blt::table configure $inner r4 -pady 4
     
    19321932    set _settings(-isolinesvisible) $style(-isolinesvisible)
    19331933    set _settings(-surfacevisible) $style(-surfacevisible)
    1934  
     1934
    19351935    SendCmd "outline add $tag"
    19361936    SendCmd "outline color [Color2RGB $itk_option(-plotforeground)] $tag"
     
    19481948    SendCmd "polydata opacity $style(-opacity) $tag"
    19491949    set _settings(-surfaceopacity) [expr $style(-opacity) * 100.0]
    1950     SetCurrentColormap $style(-color) 
     1950    SetCurrentColormap $style(-color)
    19511951    SendCmd "polydata wireframe $style(-wireframe) $tag"
    19521952    set _settings(-surfacewireframe) $style(-wireframe)
     
    20032003    set font "Arial 8"
    20042004    set lineht [font metrics $font -linespace]
    2005    
     2005
    20062006    set ih [image height $_image(legend)]
    20072007    set iy [expr $y - ($lineht + 2)]
    20082008
    20092009    if { [string match "component*" $fname] } {
    2010         set title ""
     2010        set title ""
    20112011    } else {
    2012         if { [info exists _fields($fname)] } {
    2013             foreach { title units } $_fields($fname) break
    2014             if { $units != "" } {
    2015                 set title [format "%s (%s)" $title $units]
    2016             }
    2017         } else {
    2018             set title $fname
    2019         }
     2012        if { [info exists _fields($fname)] } {
     2013            foreach { title units } $_fields($fname) break
     2014            if { $units != "" } {
     2015                set title [format "%s (%s)" $title $units]
     2016            }
     2017        } else {
     2018            set title $fname
     2019        }
    20202020    }
    20212021    # If there's a legend title, increase the offset by the line height.
     
    20312031    }
    20322032    set color [eval format "\#%02x%02x%02x" $pixel]
    2033     $_image(swatch) put black  -to 0 0 23 23 
    2034     $_image(swatch) put $color -to 1 1 22 22 
     2033    $_image(swatch) put black  -to 0 0 23 23
     2034    $_image(swatch) put $color -to 1 1 22 22
    20352035    .rappturetooltip configure -icon $_image(swatch)
    20362036
     
    20432043        set value 0.0
    20442044    }
    2045     set tx [expr $x + 15] 
     2045    set tx [expr $x + 15]
    20462046    set ty [expr $y - 5]
    20472047    if { [info exists _isolines($y)] } {
     
    20502050        Rappture::Tooltip::text $c [format "$title %g" $value]
    20512051    }
    2052     Rappture::Tooltip::tooltip show $c +$tx,+$ty   
    2053 }
    2054 
    2055 #
    2056 # ReceiveLegend -- 
    2057 #
    2058 #       Invoked automatically whenever the "legend" command comes in from
    2059 #       the rendering server.  Indicates that binary image data with the
    2060 #       specified <size> will follow.
     2052    Rappture::Tooltip::tooltip show $c +$tx,+$ty
     2053}
     2054
     2055#
     2056# ReceiveLegend --
     2057#
     2058#        Invoked automatically whenever the "legend" command comes in from
     2059#        the rendering server.  Indicates that binary image data with the
     2060#        specified <size> will follow.
    20612061#
    20622062itcl::body Rappture::VtkSurfaceViewer::ReceiveLegend { colormap title min max size } {
    20632063    #puts stderr "ReceiveLegend colormap=$colormap title=$title range=$min,$max size=$size"
    20642064    set _title $title
    2065     regsub {\(mag\)} $title "" _title 
     2065    regsub {\(mag\)} $title "" _title
    20662066    if { [IsConnected] } {
    20672067        set bytes [ReceiveBytes $size]
     
    20722072        #puts stderr "read $size bytes for [image width $_image(legend)]x[image height $_image(legend)] legend>"
    20732073        if { [catch {DrawLegend} errs] != 0 } {
    2074             global errorInfo
    2075             puts stderr "errs=$errs errorInfo=$errorInfo"
     2074            global errorInfo
     2075            puts stderr "errs=$errs errorInfo=$errorInfo"
    20762076        }
    20772077    }
     
    20922092
    20932093    if { [string match "component*" $fname] } {
    2094         set title ""
     2094        set title ""
    20952095    } else {
    2096         if { [info exists _fields($fname)] } {
    2097             foreach { title units } $_fields($fname) break
    2098             if { $units != "" } {
    2099                 set title [format "%s (%s)" $title $units]
    2100             }
    2101         } else {
    2102             set title $fname
    2103         }
     2096        if { [info exists _fields($fname)] } {
     2097            foreach { title units } $_fields($fname) break
     2098            if { $units != "" } {
     2099                set title [format "%s (%s)" $title $units]
     2100            }
     2101        } else {
     2102            set title $fname
     2103        }
    21042104    }
    21052105    set x [expr $w - 2]
    21062106    if { !$_settings(-legendvisible) } {
    2107         $c delete legend
    2108         return
    2109     } 
     2107        $c delete legend
     2108        return
     2109    }
    21102110    if { [$c find withtag "legend"] == "" } {
    2111         set y 2
    2112         # If there's a legend title, create a text item for the title.
     2111        set y 2
     2112        # If there's a legend title, create a text item for the title.
    21132113        $c create text $x $y \
    2114             -anchor ne \
    2115             -fill $itk_option(-plotforeground) -tags "title legend" \
    2116             -font $font
     2114            -anchor ne \
     2115            -fill $itk_option(-plotforeground) -tags "title legend" \
     2116            -font $font
    21172117        if { $title != "" } {
    21182118            incr y $lineht
    21192119        }
    2120         $c create text $x $y \
    2121             -anchor ne \
    2122             -fill $itk_option(-plotforeground) -tags "vmax legend" \
    2123             -font $font
    2124         incr y $lineht
    2125         $c create image $x $y \
    2126             -anchor ne \
    2127             -image $_image(legend) -tags "colormap legend"
    2128         $c create rectangle $x $y 1 1 \
    2129             -fill "" -outline "" -tags "sensor legend"
    2130         $c create text $x [expr {$h-2}] \
    2131             -anchor se \
    2132             -fill $itk_option(-plotforeground) -tags "vmin legend" \
    2133             -font $font
    2134         $c bind sensor <Enter> [itcl::code $this EnterLegend %x %y]
    2135         $c bind sensor <Leave> [itcl::code $this LeaveLegend]
    2136         $c bind sensor <Motion> [itcl::code $this MotionLegend %x %y]
     2120        $c create text $x $y \
     2121            -anchor ne \
     2122            -fill $itk_option(-plotforeground) -tags "vmax legend" \
     2123            -font $font
     2124        incr y $lineht
     2125        $c create image $x $y \
     2126            -anchor ne \
     2127            -image $_image(legend) -tags "colormap legend"
     2128        $c create rectangle $x $y 1 1 \
     2129            -fill "" -outline "" -tags "sensor legend"
     2130        $c create text $x [expr {$h-2}] \
     2131            -anchor se \
     2132            -fill $itk_option(-plotforeground) -tags "vmin legend" \
     2133            -font $font
     2134        $c bind sensor <Enter> [itcl::code $this EnterLegend %x %y]
     2135        $c bind sensor <Leave> [itcl::code $this LeaveLegend]
     2136        $c bind sensor <Motion> [itcl::code $this MotionLegend %x %y]
    21372137    }
    21382138    $c delete isoline
     
    21532153        }
    21542154        set tags "isoline legend"
    2155         set offset [expr 2 + $lineht]
    2156         if { $title != "" } {
    2157             incr offset $lineht
    2158         }
     2155        set offset [expr 2 + $lineht]
     2156        if { $title != "" } {
     2157            incr offset $lineht
     2158        }
    21592159        foreach value $_contourList {
    21602160            set norm [expr 1.0 - (($value - $vmin) / $range)]
     
    21752175    if { [info exists _limits($_curFldName)] } {
    21762176        foreach { vmin vmax } $_limits($_curFldName) break
    2177         $c itemconfigure vmin -text [format %g $vmin]
    2178         $c itemconfigure vmax -text [format %g $vmax]
     2177        $c itemconfigure vmin -text [format %g $vmin]
     2178        $c itemconfigure vmax -text [format %g $vmax]
    21792179    }
    21802180    set y 2
     
    21822182    if { $title != "" } {
    21832183        $c itemconfigure title -text $title
    2184         $c coords title $x $y
    2185         incr y $lineht
     2184        $c coords title $x $y
     2185        incr y $lineht
    21862186        $c raise title
    21872187    }
     
    22062206# ----------------------------------------------------------------------
    22072207itcl::body Rappture::VtkSurfaceViewer::Combo {option} {
    2208     set c $itk_component(view) 
     2208    set c $itk_component(view)
    22092209    switch -- $option {
    22102210        post {
     
    22212221        }
    22222222        deactivate {
    2223             $c itemconfigure title -fill $itk_option(-plotforeground) 
     2223            $c itemconfigure title -fill $itk_option(-plotforeground)
    22242224        }
    22252225        invoke {
     
    22392239    # Keep track of the colormaps that we build.
    22402240    if { ![info exists _colormaps($name)] } {
    2241         BuildColormap $name 
     2241        BuildColormap $name
    22422242        set _colormaps($name) 1
    22432243    }
     
    22612261}
    22622262
    2263 itcl::body Rappture::VtkSurfaceViewer::SetOrientation { side } { 
     2263itcl::body Rappture::VtkSurfaceViewer::SetOrientation { side } {
    22642264    array set positions {
    22652265        front "1 0 0 0"
     
    22822282}
    22832283
    2284 itcl::body Rappture::VtkSurfaceViewer::UpdateContourList {} { 
     2284itcl::body Rappture::VtkSurfaceViewer::UpdateContourList {} {
    22852285    if { ![info exists _limits($_curFldName)] } {
    22862286        return
  • branches/uiuc_vtk_viewers/gui/scripts/vtkviewer.tcl

    r4773 r5053  
    1 # -*- mode: tcl; indent-tabs-mode: nil -*- 
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    22# ----------------------------------------------------------------------
    33#  COMPONENT: vtkviewer - Vtk drawing object viewer
     
    5858    public method isconnected {}
    5959    public method limits { dataobj }
    60     public method parameters {title args} { 
    61         # do nothing 
     60    public method parameters {title args} {
     61        # do nothing
    6262    }
    6363    public method scale {args}
     
    6969    private method BuildColormap { name styles }
    7070    private method BuildCutawayTab {}
    71     private method BuildDownloadPopup { widget command } 
     71    private method BuildDownloadPopup { widget command }
    7272    private method BuildGlyphsTab {}
    7373    private method BuildMoleculeTab {}
     
    8080    private method DoRotate {}
    8181    private method DrawLegend {}
    82     private method EnterLegend { x y } 
    83     private method EventuallyResize { w h } 
    84     private method EventuallyRotate { q } 
    85     private method EventuallySetAtomScale { args } 
    86     private method EventuallySetBondScale { args } 
    87     private method EventuallySetGlyphsOpacity { args } 
    88     private method EventuallySetMoleculeOpacity { args } 
    89     private method EventuallySetMoleculeQuality { args } 
    90     private method EventuallySetPolydataOpacity { args } 
    91     private method GetImage { args } 
    92     private method GetVtkData { args } 
     82    private method EnterLegend { x y }
     83    private method EventuallyResize { w h }
     84    private method EventuallyRotate { q }
     85    private method EventuallySetAtomScale { args }
     86    private method EventuallySetBondScale { args }
     87    private method EventuallySetGlyphsOpacity { args }
     88    private method EventuallySetMoleculeOpacity { args }
     89    private method EventuallySetMoleculeQuality { args }
     90    private method EventuallySetPolydataOpacity { args }
     91    private method GetImage { args }
     92    private method GetVtkData { args }
    9393    private method InitSettings { args  }
    94     private method IsValidObject { dataobj } 
     94    private method IsValidObject { dataobj }
    9595    private method LeaveLegend {}
    96     private method MotionLegend { x y } 
     96    private method MotionLegend { x y }
    9797    private method Pan {option x y}
    9898    private method PanCamera {}
    9999    private method Pick {x y}
    100     private method QuaternionToView { q } { 
     100    private method QuaternionToView { q } {
    101101        foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break
    102102    }
     
    114114    private method SetMoleculeOpacity {}
    115115    private method SetMoleculeQuality {}
    116     private method SetObjectStyle { dataobj comp } 
     116    private method SetObjectStyle { dataobj comp }
    117117    private method SetOpacity { dataset }
    118118    private method SetOrientation { side }
    119119    private method SetPolydataOpacity {}
    120     private method Slice {option args} 
    121     private method ViewToQuaternion {} { 
     120    private method Slice {option args}
     121    private method ViewToQuaternion {} {
    122122        return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)]
    123123    }
     
    125125
    126126    private variable _arcball ""
    127     private variable _dlist "";         # list of data objects
     127    private variable _dlist "";         # list of data objects
    128128    private variable _obj2datasets
    129     private variable _obj2ovride;       # maps dataobj => style override
    130     private variable _datasets;         # contains all the dataobj-component
    131                                         # datasets in the server
    132     private variable _colormaps;        # contains all the colormaps
    133                                         # in the server.
    134     private variable _dataset2style;    # maps dataobj-component to transfunc
    135     private variable _style2datasets;   # maps tf back to list of
    136                                         # dataobj-components using the tf.
     129    private variable _obj2ovride;       # maps dataobj => style override
     130    private variable _datasets;         # contains all the dataobj-component
     131                                        # datasets in the server
     132    private variable _colormaps;        # contains all the colormaps
     133                                        # in the server.
     134    private variable _dataset2style;    # maps dataobj-component to transfunc
     135    private variable _style2datasets;   # maps tf back to list of
     136                                        # dataobj-components using the tf.
    137137    private variable _click;            # info used for rotate operations
    138138    private variable _limits;           # autoscale min/max for all axes
     
    319319
    320320    set _map(id) [$c create image 0 0 -anchor nw -image $_image(plot)]
    321     set _map(cwidth) -1 
    322     set _map(cheight) -1 
     321    set _map(cwidth) -1
     322    set _map(cheight) -1
    323323    set _map(zoom) 1.0
    324324    set _map(original) ""
     
    373373    set _image(legend) [image create photo]
    374374    itk_component add legend {
    375         canvas $itk_component(plotarea).legend -width 50 -highlightthickness 0 
     375        canvas $itk_component(plotarea).legend -width 50 -highlightthickness 0
    376376    } {
    377377        usual
     
    380380    }
    381381
    382     # Hack around the Tk panewindow.  The problem is that the requested 
     382    # Hack around the Tk panewindow.  The problem is that the requested
    383383    # size of the 3d view isn't set until an image is retrieved from
    384384    # the server.  So the panewindow uses the tiny size.
     
    386386    pack forget $itk_component(view)
    387387    blt::table $itk_component(plotarea) \
    388         0,0 $itk_component(view) -fill both -reqwidth $w 
     388        0,0 $itk_component(view) -fill both -reqwidth $w
    389389    blt::table configure $itk_component(plotarea) c1 -resize none
    390390
     
    473473
    474474itcl::body Rappture::VtkViewer::DoRotate {} {
    475     SendCmd "camera orient [ViewToQuaternion]" 
     475    SendCmd "camera orient [ViewToQuaternion]"
    476476    set _rotatePending 0
    477477}
     
    674674                    continue
    675675                }
    676                 if {[info exists _obj2ovride($dataobj-raise)] && 
     676                if {[info exists _obj2ovride($dataobj-raise)] &&
    677677                    $_obj2ovride($dataobj-raise)} {
    678678                    set dlist [linsert $dlist 0 $dataobj]
     
    702702            }
    703703            return $dlist
    704         }           
     704        }
    705705        -image {
    706706            if {[llength $args] != 2} {
     
    925925    # disconnected -- no more data sitting on server
    926926    set _outbuf ""
    927     array unset _datasets 
    928     array unset _data 
    929     array unset _colormaps 
     927    array unset _datasets
     928    array unset _data
     929    array unset _colormaps
    930930    global readyForNextFrame
    931931    set readyForNextFrame 1
     
    10291029    # Turn on buffering of commands to the server.  We don't want to
    10301030    # be preempted by a server disconnect/reconnect (which automatically
    1031     # generates a new call to Rebuild).   
     1031    # generates a new call to Rebuild).
    10321032    StartBufferingCommands
    10331033
     
    11231123        if { $_haveGlyphs } {
    11241124            InitSettings glyphs-edges glyphs-lighting glyphs-opacity \
    1125                 glyphs-visible glyphs-wireframe 
     1125                glyphs-visible glyphs-wireframe
    11261126        }
    11271127        if { $_havePolydata } {
    11281128            InitSettings polydata-edges polydata-lighting polydata-opacity \
    1129                 polydata-visible polydata-wireframe 
     1129                polydata-visible polydata-wireframe
    11301130        }
    11311131        if { $_haveMolecules } {
     
    11471147
    11481148    if { $_haveMolecules } {
    1149         #InitSettings molecule-representation 
     1149        #InitSettings molecule-representation
    11501150    }
    11511151    set _reset 0
     
    11701170itcl::body Rappture::VtkViewer::CurrentDatasets {args} {
    11711171    set flag [lindex $args 0]
    1172     switch -- $flag { 
     1172    switch -- $flag {
    11731173        "-all" {
    11741174            if { [llength $args] > 1 } {
     
    11891189                set dlist [get -visible]
    11901190            }
    1191         }           
     1191        }
    11921192        default {
    11931193            set dlist $args
     
    13081308    foreach tag [CurrentDatasets -visible] {
    13091309        SendCmd "dataset getscalar pixel $x $y $tag"
    1310     } 
     1310    }
    13111311}
    13121312
     
    17541754            }
    17551755        }
    1756         "axis-xposition" - "axis-yposition" - "axis-zposition" - 
     1756        "axis-xposition" - "axis-yposition" - "axis-zposition" -
    17571757        "axis-xdirection" - "axis-ydirection" - "axis-zdirection" {
    17581758            set axis [string range $what 5 5]
     
    19121912            set f [open "$tmpfile" "w"]
    19131913            fconfigure $f -translation binary -encoding binary
    1914             puts $f $data 
     1914            puts $f $data
    19151915            close $f
    19161916            set reader [vtkDataSetReader $tag-xvtkDataSetReader]
     
    20062006        -variable [itcl::scope _settings(glyphs-visible)] \
    20072007        -command [itcl::code $this AdjustSetting glyphs-visible] \
    2008         -font "Arial 9" -anchor w 
     2008        -font "Arial 9" -anchor w
    20092009
    20102010    checkbutton $inner.outline \
     
    20122012        -variable [itcl::scope _settings(glyphs-outline)] \
    20132013        -command [itcl::code $this AdjustSetting glyphs-outline] \
    2014         -font "Arial 9" -anchor w 
     2014        -font "Arial 9" -anchor w
    20152015
    20162016    checkbutton $inner.wireframe \
     
    20182018        -variable [itcl::scope _settings(glyphs-wireframe)] \
    20192019        -command [itcl::code $this AdjustSetting glyphs-wireframe] \
    2020         -font "Arial 9" -anchor w 
     2020        -font "Arial 9" -anchor w
    20212021
    20222022    checkbutton $inner.lighting \
     
    20322032        -font "Arial 9" -anchor w
    20332033
    2034     label $inner.palette_l -text "Palette" -font "Arial 9" -anchor w 
     2034    label $inner.palette_l -text "Palette" -font "Arial 9" -anchor w
    20352035    itk_component add glyphspalette {
    20362036        Rappture::Combobox $inner.palette -width 10 -editable no
     
    20412041        [itcl::code $this AdjustSetting glyphs-palette]
    20422042
    2043     label $inner.opacity_l -text "Opacity" -font "Arial 9" -anchor w 
     2043    label $inner.opacity_l -text "Opacity" -font "Arial 9" -anchor w
    20442044    ::scale $inner.opacity -from 0 -to 100 -orient horizontal \
    20452045        -variable [itcl::scope _settings(glyphs-opacity)] \
     
    20582058        5,1 $inner.opacity   -fill x   -pady 2 \
    20592059        6,0 $inner.palette_l -anchor w -pady 2 \
    2060         6,1 $inner.palette   -fill x   -pady 2 
     2060        6,1 $inner.palette   -fill x   -pady 2
    20612061
    20622062    blt::table configure $inner r* c* -resize none
     
    20782078        -variable [itcl::scope _settings(polydata-visible)] \
    20792079        -command [itcl::code $this AdjustSetting polydata-visible] \
    2080         -font "Arial 9" -anchor w 
     2080        -font "Arial 9" -anchor w
    20812081
    20822082    checkbutton $inner.outline \
     
    20842084        -variable [itcl::scope _settings(polydata-outline)] \
    20852085        -command [itcl::code $this AdjustSetting polydata-outline] \
    2086         -font "Arial 9" -anchor w 
     2086        -font "Arial 9" -anchor w
    20872087
    20882088    checkbutton $inner.wireframe \
     
    20902090        -variable [itcl::scope _settings(polydata-wireframe)] \
    20912091        -command [itcl::code $this AdjustSetting polydata-wireframe] \
    2092         -font "Arial 9" -anchor w 
     2092        -font "Arial 9" -anchor w
    20932093
    20942094    checkbutton $inner.lighting \
     
    21042104        -font "Arial 9" -anchor w
    21052105
    2106     label $inner.palette_l -text "Palette" -font "Arial 9" -anchor w 
     2106    label $inner.palette_l -text "Palette" -font "Arial 9" -anchor w
    21072107    itk_component add meshpalette {
    21082108        Rappture::Combobox $inner.palette -width 10 -editable no
     
    21132113        [itcl::code $this AdjustSetting polydata-palette]
    21142114
    2115     label $inner.opacity_l -text "Opacity" -font "Arial 9" -anchor w 
     2115    label $inner.opacity_l -text "Opacity" -font "Arial 9" -anchor w
    21162116    ::scale $inner.opacity -from 0 -to 100 -orient horizontal \
    21172117        -variable [itcl::scope _settings(polydata-opacity)] \
     
    21302130        5,1 $inner.opacity   -fill x   -pady 2 \
    21312131        6,0 $inner.palette_l -anchor w -pady 2 \
    2132         6,1 $inner.palette   -fill x   -pady 2 
     2132        6,1 $inner.palette   -fill x   -pady 2
    21332133
    21342134    blt::table configure $inner r* c* -resize none
     
    21572157        -command [itcl::code $this AdjustSetting axis-labels] \
    21582158        -font "Arial 9"
    2159     label $inner.grid_l -text "Grid" -font "Arial 9" 
     2159    label $inner.grid_l -text "Grid" -font "Arial 9"
    21602160    checkbutton $inner.xgrid \
    21612161        -text "X" \
     
    21792179        -font "Arial 9"
    21802180
    2181     label $inner.mode_l -text "Mode" -font "Arial 9" 
     2181    label $inner.mode_l -text "Mode" -font "Arial 9"
    21822182
    21832183    itk_component add axismode {
     
    21882188        "closest_triad"   "closest" \
    21892189        "furthest_triad"  "farthest" \
    2190         "outer_edges"     "outer"         
     2190        "outer_edges"     "outer"
    21912191    $itk_component(axismode) value "static"
    21922192    bind $inner.mode <<Value>> [itcl::code $this AdjustSetting axis-mode]
     
    22622262
    22632263    set fg [option get $itk_component(hull) font Font]
    2264    
     2264
    22652265    set inner [$itk_component(main) insert end \
    22662266        -title "Cutaway Along Axis" \
    2267         -icon [Rappture::icon cutbutton]] 
     2267        -icon [Rappture::icon cutbutton]]
    22682268
    22692269    $inner configure -borderwidth 4
     
    23052305            -variable [itcl::scope _axis(xdirection)]
    23062306    }
    2307     set _axis(xdirection) -1 
     2307    set _axis(xdirection) -1
    23082308    Rappture::Tooltip::for $itk_component(xDirButton) \
    23092309        "Toggle the direction of the X-axis cutaway"
     
    23472347    Rappture::Tooltip::for $itk_component(yDirButton) \
    23482348        "Toggle the direction of the Y-axis cutaway"
    2349     set _axis(ydirection) -1 
     2349    set _axis(ydirection) -1
    23502350
    23512351    # Z-value slicer...
     
    23842384            -variable [itcl::scope _axis(zdirection)]
    23852385    }
    2386     set _axis(zdirection) -1 
     2386    set _axis(zdirection) -1
    23872387    Rappture::Tooltip::for $itk_component(zDirButton) \
    23882388        "Toggle the direction of the Z-axis cutaway"
     
    24522452    $inner.rep choices insert end \
    24532453        "ballandstick"  "Ball and Stick" \
    2454         "spheres"       "Spheres"        \
    2455         "sticks"        "Sticks"        \
    2456         "rods"          "Rods"           \
    2457         "wireframe"     "Wireframe"      \
    2458         "spacefilling"  "Space Filling" 
     2454        "spheres"       "Spheres"        \
     2455        "sticks"        "Sticks"        \
     2456        "rods"          "Rods"           \
     2457        "wireframe"     "Wireframe"      \
     2458        "spacefilling"  "Space Filling"
    24592459
    24602460    bind $inner.rep <<Value>> \
     
    24692469    }
    24702470    $inner.rscale choices insert end \
    2471         "atomic"        "Atomic"   \
    2472         "covalent"      "Covalent" \
    2473         "van_der_waals" "VDW"      \
    2474         "none"          "Constant"
     2471        "atomic"        "Atomic"   \
     2472        "covalent"      "Covalent" \
     2473        "van_der_waals" "VDW"      \
     2474        "none"          "Constant"
    24752475
    24762476    bind $inner.rscale <<Value>> \
     
    24782478    $inner.rscale value "Covalent"
    24792479
    2480     label $inner.palette_l -text "Palette" -font "Arial 9" 
     2480    label $inner.palette_l -text "Palette" -font "Arial 9"
    24812481    itk_component add moleculepalette {
    24822482        Rappture::Combobox $inner.palette -width 10 -editable no
     
    25432543        16,0 $inner.quality_l   -anchor w -pady {3 0} \
    25442544        17,0 $inner.quality     -fill x    -padx 2
    2545    
     2545
    25462546    blt::table configure $inner r* -resize none
    25472547    blt::table configure $inner r18 -resize expand
     
    25492549
    25502550#
    2551 #  camera -- 
     2551#  camera --
    25522552#
    25532553itcl::body Rappture::VtkViewer::camera {option args} {
    2554     switch -- $option { 
     2554    switch -- $option {
    25552555        "show" {
    25562556            puts [array get _view]
     
    26002600
    26012601itcl::body Rappture::VtkViewer::GetImage { args } {
    2602     if { [image width $_image(download)] > 0 && 
     2602    if { [image width $_image(download)] > 0 &&
    26032603         [image height $_image(download)] > 0 } {
    26042604        set bytes [$_image(download) data -format "jpeg -quality 100"]
     
    26132613        -title "[Rappture::filexfer::label downloadWord] as..."
    26142614    set inner [$popup component inner]
    2615     label $inner.summary -text "" -anchor w 
     2615    label $inner.summary -text "" -anchor w
    26162616    radiobutton $inner.vtk_button -text "VTK data file" \
    26172617        -variable [itcl::scope _downloadPopup(format)] \
    26182618        -font "Helvetica 9 " \
    2619         -value vtk 
     2619        -value vtk
    26202620    Rappture::Tooltip::for $inner.vtk_button "Save as VTK data file."
    26212621    radiobutton $inner.image_button -text "Image File" \
    26222622        -variable [itcl::scope _downloadPopup(format)] \
    2623         -value image 
     2623        -value image
    26242624    Rappture::Tooltip::for $inner.image_button \
    26252625        "Save as digital image."
     
    26422642        2,0 $inner.image_button -anchor w -cspan 2 -padx { 4 0 } \
    26432643        4,1 $inner.cancel -width .9i -fill y \
    2644         4,0 $inner.ok -padx 2 -width .9i -fill y 
     2644        4,0 $inner.ok -padx 2 -width .9i -fill y
    26452645    blt::table configure $inner r3 -height 4
    26462646    blt::table configure $inner r4 -pady 4
     
    29192919    set font "Arial 8"
    29202920    set lineht [font metrics $font -linespace]
    2921    
     2921
    29222922    if { $_settings(legend) } {
    29232923        set x [expr $w - 2]
     
    29842984    set font "Arial 8"
    29852985    set lineht [font metrics $font -linespace]
    2986    
     2986
    29872987    set imgHeight [image height $_image(legend)]
    29882988    set coords [$c coords colormap]
     
    29982998    }
    29992999    set color [eval format "\#%02x%02x%02x" $pixel]
    3000     $_image(swatch) put black  -to 0 0 23 23 
    3001     $_image(swatch) put $color -to 1 1 22 22 
     3000    $_image(swatch) put black  -to 0 0 23 23
     3001    $_image(swatch) put $color -to 1 1 22 22
    30023002    .rappturetooltip configure -icon $_image(swatch)
    30033003
     
    30053005    set t [expr 1.0 - (double($imgY) / double($imgHeight-1))]
    30063006    set value [expr $t * ($_limits(vmax) - $_limits(vmin)) + $_limits(vmin)]
    3007     set tipx [expr $x + 15] 
     3007    set tipx [expr $x + 15]
    30083008    set tipy [expr $y - 5]
    30093009    Rappture::Tooltip::text $c "$_title $value"
    3010     Rappture::Tooltip::tooltip show $c +$tipx,+$tipy   
     3010    Rappture::Tooltip::tooltip show $c +$tipx,+$tipy
    30113011}
    30123012
     
    30413041}
    30423042
    3043 itcl::body Rappture::VtkViewer::SetOrientation { side } { 
     3043itcl::body Rappture::VtkViewer::SetOrientation { side } {
    30443044    array set positions {
    30453045        front "1 0 0 0"
     
    30523052    foreach name { -qw -qx -qy -qz } value $positions($side) {
    30533053        set _view($name) $value
    3054     } 
     3054    }
    30553055    set q [ViewToQuaternion]
    30563056    $_arcball quaternion $q
     
    30623062}
    30633063
    3064 itcl::body Rappture::VtkViewer::SetOpacity { dataset } { 
     3064itcl::body Rappture::VtkViewer::SetOpacity { dataset } {
    30653065    foreach {dataobj comp} [split $dataset -] break
    30663066    set type [$dataobj type $comp]
  • branches/uiuc_vtk_viewers/gui/scripts/vtkvolumeviewer.tcl

    r4776 r5053  
    19811981    set labels { qx qy qz qw xpan ypan zoom }
    19821982    foreach tag $labels {
    1983         label $inner.${tag}-label -text $tag -font "Arial 9"
     1983        label $inner.${tag}label -text $tag -font "Arial 9"
    19841984        entry $inner.${tag} -font "Arial 9"  -bg white \
    19851985            -textvariable [itcl::scope _view(-$tag)]
     
    19891989            [itcl::code $this camera set -${tag}]
    19901990        blt::table $inner \
    1991             $row,0 $inner.${tag}-label -anchor e -pady 2 \
     1991            $row,0 $inner.${tag}label -anchor e -pady 2 \
    19921992            $row,1 $inner.${tag} -anchor w -pady 2
    19931993        blt::table configure $inner r$row -resize none
Note: See TracChangeset for help on using the changeset viewer.