Changeset 5001 for trunk


Ignore:
Timestamp:
Feb 11, 2015 2:15:48 PM (9 years ago)
Author:
ldelgass
Message:

Whitespace: tabs to spaces

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gui/scripts/field.tcl

    r5000 r5001  
    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
     
    8383
    8484    constructor {xmlobj path} {
    85         # defined below
     85        # defined below
    8686    }
    8787    destructor {
    88         # defined below
     88        # defined below
    8989    }
    9090    public method blob { cname }
     
    126126    }
    127127    public method viewer {} {
    128         return $_viewer
     128        return $_viewer
    129129    }
    130130    protected method Build {}
     
    144144    private variable _comp2cntls ;# maps component name => x,y control points
    145145    private variable _comp2extents
    146     private variable _comp2limits;      #  Array of limits per component
     146    private variable _comp2limits;        #  Array of limits per component
    147147    private variable _type ""
    148148    private variable _comp2flowhints
     
    228228    }
    229229    foreach name [array names _comp2mesh] {
    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)
     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)
    233233        set class [$mesh info class]
    234234        ${class}::release $mesh
    235         # Destroy the vector
     235        # Destroy the vector
    236236        blt::vector destroy $vector
    237237    }
     
    312312    }
    313313    if {[info exists _comp2vtk($cname)]} {
    314         # FIXME: extract mesh from VTK file data.
     314        # FIXME: extract mesh from VTK file data.
    315315        error "method \"mesh\" is not implemented for VTK file data"
    316316    }
     
    348348    }
    349349    if { [info exists _comp2vtk($cname)] } {
    350         # FIXME: extract the values from the VTK file data
     350        # FIXME: extract the values from the VTK file data
    351351        error "method \"values\" is not implemented for VTK file data"
    352352    }
     
    355355    }
    356356    if { [info exists _comp2mesh($cname)] } {
    357         set vector [lindex $_comp2mesh($cname) 1]
     357        set vector [lindex $_comp2mesh($cname) 1]
    358358        return [$vector range 0 end]
    359359    }
     
    380380    }
    381381    if { [info exists _comp2vtk($cname)] } {
    382         error "blob not implemented for VTK file data"
     382        error "blob not implemented for VTK file data"
    383383    }
    384384    if {[info exists _comp2dx($cname)]} {
     
    424424                switch -- $which {
    425425                    x - xlin {
    426                         set pos 0; set log 0; set axis x
    427                     }
     426                        set pos 0; set log 0; set axis x
     427                    }
    428428                    xlog {
    429                         set pos 0; set log 1; set axis x
    430                     }
     429                        set pos 0; set log 1; set axis x
     430                    }
    431431                    y - ylin - v - vlin {
    432                         set pos 1; set log 0; set axis y
    433                     }
     432                        set pos 1; set log 0; set axis y
     433                    }
    434434                    ylog - vlog {
    435                         set pos 1; set log 1; set axis y
    436                     }
     435                        set pos 1; set log 1; set axis y
     436                    }
    437437                    default {
    438438                        error "bad axis \"$which\": should be x, xlin, xlog, y, ylin, ylog, v, vlin, vlog"
     
    471471            default {
    472472                if {[info exists _comp2limits($cname)]} {
    473                     array set limits $_comp2limits($cname)
    474                     switch -- $which {
     473                    array set limits $_comp2limits($cname)
     474                    switch -- $which {
    475475                        x - xlin - xlog {
    476476                            set axis x
    477                             foreach {axisMin axisMax} $limits(x) break
     477                            foreach {axisMin axisMax} $limits(x) break
    478478                        }
    479479                        y - ylin - ylog {
    480480                            set axis y
    481                             foreach {axisMin axisMax} $limits(y) break
     481                            foreach {axisMin axisMax} $limits(y) break
    482482                        }
    483483                        z - zlin - zlog {
    484484                            set axis z
    485                             foreach {axisMin axisMax} $limits(z) break
     485                            foreach {axisMin axisMax} $limits(z) break
    486486                        }
    487487                        v - vlin - vlog {
    488488                            set axis v
    489                             foreach {axisMin axisMax} $limits(v) break
    490                         }
    491                         default {
    492                             if { ![info exists limits($which)] } {
    493                                 error "limits: unknown axis \"$which\""
    494                             }
     489                            foreach {axisMin axisMax} $limits(v) break
     490                        }
     491                        default {
     492                            if { ![info exists limits($which)] } {
     493                                error "limits: unknown axis \"$which\""
     494                            }
    495495                            set axis v
    496                             foreach {axisMin axisMax} $limits($which) break
    497                         }
    498                     }
     496                            foreach {axisMin axisMax} $limits($which) break
     497                        }
     498                    }
    499499                } else {
    500500                    set axisMin 0  ;# HACK ALERT! must be OpenDX data
     
    770770        set type ""
    771771        if { ([$_field element $cname.constant] != "" &&
    772               [$_field element $cname.domain] != "") ||
    773               [$_field element $cname.xy] != "" } {
     772              [$_field element $cname.domain] != "") ||
     773              [$_field element $cname.xy] != "" } {
    774774            set type "1D"
    775775        } elseif { [$_field element $cname.mesh] != "" &&
    776                    [$_field element $cname.values] != ""} {
     776                   [$_field element $cname.values] != ""} {
    777777            set type "points-on-mesh"
    778778        } elseif { [$_field element $cname.vtk] != ""} {
    779             set type "vtk"
    780             set viewer [$_field get "about.view"]
    781             if { $viewer != "" } {
    782                 set _viewer $viewer
    783             }
     779            set type "vtk"
     780            set viewer [$_field get "about.view"]
     781            if { $viewer != "" } {
     782                set _viewer $viewer
     783            }
    784784        } elseif {[$_field element $cname.opendx] != ""} {
    785785            global env
     
    798798        } elseif {[$_field element $cname.dicom] != ""} {
    799799            set type "dicom"
    800         }
     800        }
    801801        set _comp2style($cname) ""
    802802        if { $type == "" } {
     
    871871            }
    872872        } elseif {$type == "points-on-mesh"} {
    873             if { ![BuildPointsOnMesh $cname] } {
     873            if { ![BuildPointsOnMesh $cname] } {
    874874                continue;               # Ignore this component
    875875            }
     
    11781178    set dataAttrs [$dataset GetPointData]
    11791179    if { $dataAttrs == ""} {
    1180         puts stderr "WARNING: No point data found in \"$_path\""
     1180        puts stderr "WARNING: No point data found in \"$_path\""
    11811181        rename $reader ""
    11821182        return 0
     
    12151215    set _dim 0
    12161216    if { $xmax > $xmin } {
    1217         incr _dim
     1217        incr _dim
    12181218    }
    12191219    if { $ymax > $ymin } {
    1220         incr _dim
     1220        incr _dim
    12211221    }
    12221222    if { $zmax > $zmin } {
    1223         incr _dim
     1223        incr _dim
    12241224    }
    12251225    if { $_viewer == "" } {
    1226         if { $_dim == 2 } {
    1227             set _viewer contour
    1228         } else {
    1229             set _viewer isosurface
    1230         }
     1226        if { $_dim == 2 } {
     1227            set _viewer contour
     1228        } else {
     1229            set _viewer isosurface
     1230        }
    12311231    }
    12321232    set _comp2dims($cname) ${_dim}D
     
    12631263    set dataAttrs [$dataset GetPointData]
    12641264    if { $dataAttrs == ""} {
    1265         puts stderr "WARNING: No point data found in \"$_path\""
     1265        puts stderr "WARNING: No point data found in \"$_path\""
    12661266        rename $reader ""
    12671267        return 0
     
    12711271    set numArrays [$dataAttrs GetNumberOfArrays]
    12721272    if { $numArrays > 0 } {
    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
     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
    12771277            if {$i == 0} {
    12781278                set vmin $min
    12791279                set vmax $max
    12801280            }
    1281             lappend limits $fname [list $min $max]
     1281            lappend limits $fname [list $min $max]
    12821282            set _fld2Units($fname) ""
    1283             set _fld2Label($fname) $fname
     1283            set _fld2Label($fname) $fname
    12841284            # Let the VTK file override the <type> designated.
    12851285            set _fld2Components($fname) [$array GetNumberOfComponents]
    12861286            lappend _comp2fldName($cname) $fname
    1287         }
     1287        }
    12881288    }
    12891289   
     
    12971297# vtkdata --
    12981298#
    1299 #       Returns a string representing the mesh and field data for a specific
    1300 #       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.
    13011301#
    13021302itcl::body Rappture::Field::vtkdata {cname} {
     
    13161316    # Points on mesh:  Construct VTK file output.
    13171317    if { [info exists _comp2mesh($cname)] } {
    1318         # Data is in the form mesh and vector
    1319         foreach {mesh vector} $_comp2mesh($cname) break
     1318        # Data is in the form mesh and vector
     1319        foreach {mesh vector} $_comp2mesh($cname) break
    13201320        set label $cname
    13211321        regsub -all { } $label {_} label
    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]
     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]
    13261326
    13271327        if { $_comp2assoc($cname) == "pointdata" } {
     
    13691369            VerifyVtkDataSet $out
    13701370        }
    1371         return $out
     1371        return $out
    13721372    }
    13731373    error "can't find vtkdata for $cname"
     
    13771377# BuildPointsOnMesh --
    13781378#
    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).
     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).
    13821382#
    13831383itcl::body Rappture::Field::BuildPointsOnMesh {cname} {
     
    13881388    set path [$_field get $cname.mesh]
    13891389    if {[$_xmlobj element $path] == ""} {
    1390         # Unknown mesh designated.
    1391         return 0
     1390        # Unknown mesh designated.
     1391        return 0
    13921392    }
    13931393    set viewer [$_field get "about.view"]
     
    14091409    # Handle bizarre cases that hopefully will be deprecated.
    14101410    if { $element == "unirect3d" } {
    1411         # Special case: unirect3d (should be deprecated) + flow.
     1411        # Special case: unirect3d (should be deprecated) + flow.
    14121412        if { [$_field element $cname.extents] != "" } {
    14131413            set vectorsize [$_field get $cname.extents]
     
    14161416        }
    14171417        set _type unirect3d
    1418         set _dim 3
     1418        set _dim 3
    14191419        if { $_viewer == "" } {
    14201420            set _viewer flowvis
    14211421        }
    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]
     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]
    14261426        set limits {}
    14271427        foreach axis { x y z } {
     
    14341434        lappend limits v      $minmax
    14351435        set _comp2limits($cname) $limits
    1436         if {[$_field element $cname.flow] != ""} {
    1437             set _comp2flowhints($cname) \
    1438                 [Rappture::FlowHints ::\#auto $_field $cname $_units]
    1439         }
    1440         incr _counter
    1441         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
    14421442    }
    14431443    if { $element == "unirect2d" && [$_field element $cname.flow] != "" } {
    1444         # Special case: unirect2d (normally deprecated) + flow.
     1444        # Special case: unirect2d (normally deprecated) + flow.
    14451445        if { [$_field element $cname.extents] != "" } {
    14461446            set vectorsize [$_field get $cname.extents]
     
    14491449        }
    14501450        set _type unirect2d
    1451         set _dim 2
     1451        set _dim 2
    14521452        if { $_viewer == "" } {
    14531453            set _viewer "flowvis"
    14541454        }
    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]
     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]
    14621462        set limits {}
    14631463        foreach axis { x y z } {
     
    14711471        blt::vector destroy $xv
    14721472        set _comp2limits($cname) $limits
    1473         incr _counter
    1474         return 1
     1473        incr _counter
     1474        return 1
    14751475    }
    14761476    switch -- $element {
    1477         "cloud" {
    1478             set mesh [Rappture::Cloud::fetch $_xmlobj $path]
     1477        "cloud" {
     1478            set mesh [Rappture::Cloud::fetch $_xmlobj $path]
    14791479            set _type cloud
    1480         }
    1481         "mesh" {
    1482             set mesh [Rappture::Mesh::fetch $_xmlobj $path]
     1480        }
     1481        "mesh" {
     1482            set mesh [Rappture::Mesh::fetch $_xmlobj $path]
    14831483            set _type mesh
    1484         }          
    1485         "unirect2d" {
     1484        }           
     1485        "unirect2d" {
    14861486            if { $_viewer == "" } {
    14871487                set _viewer "heightmap"
    14881488            }
    1489             set mesh [Rappture::Unirect2d::fetch $_xmlobj $path]
     1489            set mesh [Rappture::Unirect2d::fetch $_xmlobj $path]
    14901490            set _type unirect2d
    1491         }
     1491        }
    14921492    }
    14931493    if { ![$mesh isvalid] } {
     
    15141514        return 0
    15151515
    1516         # 1D data: Create vectors for graph widget.
    1517         # 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
    15181518        # Band Structure Lab used to (see isosurface1 test in rappture-bat)
    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) or 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]
     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) or 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]
    15281528
    15291529        # This only works with a Cloud mesh type, since the points method
    15301530        # is not implemented for the Mesh object
    1531         #$xv set [$mesh points]
     1531        #$xv set [$mesh points]
    15321532        # TODO: Put field values in yv
    1533         #set _comp2dims($cname) "1D"
    1534         #set _comp2xy($cname) [list $xv $yv]
    1535         #incr _counter
    1536         #return 1
     1533        #set _comp2dims($cname) "1D"
     1534        #set _comp2xy($cname) [list $xv $yv]
     1535        #incr _counter
     1536        #return 1
    15371537    }
    15381538    if {$_dim == 2} {
    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]
     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]
    15421542        if { [$v length] == 0 } {
    15431543            return 0
     
    15661566            }
    15671567        }
    1568         set _comp2dims($cname) "[$mesh dimensions]D"
    1569         set _comp2mesh($cname) [list $mesh $v]
    1570         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]
    15711571        if {[$_field element $cname.flow] != ""} {
    15721572            set _comp2flowhints($cname) \
    15731573                [Rappture::FlowHints ::\#auto $_field $cname $_units]
    15741574        }
    1575         incr _counter
    1576         array unset _comp2limits $cname
     1575        incr _counter
     1576        array unset _comp2limits $cname
    15771577        foreach axis { x y z } {
    15781578            lappend _comp2limits($cname) $axis [$mesh limits $axis]
     
    15811581        lappend _comp2limits($cname) $cname $minmax
    15821582        lappend _comp2limits($cname) v $minmax
    1583         return 1
     1583        return 1
    15841584    }
    15851585    if {$_dim == 3} {
    1586         # 3D data: By default isosurfaces plot using isosurface widget.
     1586        # 3D data: By default isosurfaces plot using isosurface widget.
    15871587        if { $_viewer == "" } {
    15881588            set _viewer "isosurface"
    15891589        }
    1590         set v [blt::vector create \#auto]
    1591         $v set [$_field get $cname.values]
     1590        set v [blt::vector create \#auto]
     1591        $v set [$_field get $cname.values]
    15921592        if { [$v length] == 0 } {
    15931593            return 0
     
    16271627        lappend _comp2limits($cname) $cname $minmax
    16281628        lappend _comp2limits($cname) v $minmax
    1629         return 1
     1629        return 1
    16301630    }
    16311631    error "unhandled case in field dim=$_dim element=$element"
Note: See TracChangeset for help on using the changeset viewer.