Changeset 5611 for trunk/gui


Ignore:
Timestamp:
May 27, 2015 2:36:55 PM (9 years ago)
Author:
ldelgass
Message:

Remove old unirect blob encodings for sending data to nanovis. Unirect2d/3d are
now treated as deprecated mesh types that are converted to VTK, like cloud.

Location:
trunk/gui/scripts
Files:
3 edited

Legend:

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

    r5610 r5611  
    152152    private variable _comp2vtk;         # cname => vtk file data
    153153    private variable _comp2dx;          # cname => OpenDX data
    154     private variable _comp2unirect2d;   # cname => unirect2d obj
    155     private variable _comp2unirect3d;   # cname => unirect3d obj
    156154    private variable _comp2style;       # cname => style settings
    157155    private variable _comp2cntls;       # cname => x,y control points (1D only)
     
    160158    private variable _comp2mesh;        # list: mesh obj, BLT vector of values
    161159                                        # valid for cloud,mesh,unirect2d
    162     private variable _values "";        # Only for unirect2d - list of values
    163 
    164160    private common _alwaysConvertDX 0;  # If set, convert DX and store as VTK,
    165161                                        # even if viewer is nanovis/flowvis
     
    221217    foreach name [array names _comp2xy] {
    222218        eval blt::vector destroy $_comp2xy($name)
    223     }
    224     foreach name [array names _comp2unirect2d] {
    225         itcl::delete object $_comp2unirect2d($name)
    226     }
    227     foreach name [array names _comp2unirect3d] {
    228         itcl::delete object $_comp2unirect3d($name)
    229219    }
    230220    foreach name [array names _comp2flowhints] {
     
    324314        error "method \"mesh\" is not implemented for Rappture::Mesh"
    325315    }
    326     if {[info exists _comp2unirect2d($cname)]} {
    327         error "method \"mesh\" is not implemented for unirect2d"
    328     }
    329     if {[info exists _comp2unirect3d($cname)]} {
    330         error "method \"mesh\" is not implemented for unirect3d"
    331     }
    332316    error "can't get field mesh: Unknown component \"$cname\": should be one of [join [lsort [array names _comp2dims]] {, }]"
    333317}
     
    357341        return [lindex $_comp2mesh($cname) 1] ;# return vector
    358342    }
    359     if {[info exists _comp2unirect2d($cname)]} {
    360         error "method \"values\" is not implemented for unirect2d"
    361     }
    362     if {[info exists _comp2unirect3d($cname)]} {
    363         error "method \"values\" is not implemented for unirect3d"
    364     }
    365343    error "can't get field values. Unknown component \"$cname\": should be one of [join [lsort [array names _comp2dims]] {, }]"
    366344}
     
    378356        return $_comp2dx($cname)  ;# return gzipped, base64-encoded DX data
    379357    }
    380     if {[info exists _comp2unirect2d($cname)]} {
    381         set blob [$_comp2unirect2d($cname) blob]
    382         lappend blob "values" $_values
    383         return $blob
    384     }
    385     if {[info exists _comp2unirect3d($cname)]} {
    386         return [$_comp2unirect3d($cname) blob]
    387     }
    388358    if {[info exists _comp2mesh($cname)]} {
    389359        error "method \"blob\" not implemented for Rappture::Mesh"
    390360    }
    391     if { [info exists _comp2vtk($cname)] } {
     361    if {[info exists _comp2vtk($cname)]} {
    392362        error "method \"blob\" not implemented for VTK file data"
    393363    }
     
    750720    }
    751721    array unset _comp2vtk
    752     foreach name [array names _comp2unirect2d] {
    753         eval itcl::delete object $_comp2unirect2d($name)
    754     }
    755     foreach name [array names _comp2unirect3d] {
    756         eval itcl::delete object $_comp2unirect3d($name)
    757     }
    758722    catch {unset _comp2xy}
    759723    catch {unset _comp2dx}
    760724    catch {unset _comp2dims}
    761725    catch {unset _comp2style}
    762     array unset _comp2unirect2d
    763     array unset _comp2unirect3d
    764726    array unset _dataobj2type
    765727    #
     
    13201282        set data [Rappture::encoding::decode -as zb64 $data]
    13211283        return [Rappture::DxToVtk $data]
    1322     }
    1323     # unirect2d (deprecated)
    1324     # This can be removed when the nanovis server with support for loading VTK
    1325     # vector data is released
    1326     if {[info exists _comp2unirect2d($cname)]} {
    1327         set label $cname
    1328         regsub -all { } $label {_} label
    1329         set elemSize [numComponents $cname]
    1330         set numValues [$_comp2unirect2d($cname) numpoints]
    1331         append out "# vtk DataFile Version 3.0\n"
    1332         append out "[hints label]\n"
    1333         append out "ASCII\n"
    1334         append out [$_comp2unirect2d($cname) vtkdata]
    1335         append out "POINT_DATA $numValues\n"
    1336         if {$elemSize == 3} {
    1337             append out "VECTORS $label double\n"
    1338         } else {
    1339             append out "SCALARS $label double $elemSize\n"
    1340             append out "LOOKUP_TABLE default\n"
    1341         }
    1342         # values for VTK are x-fastest
    1343         append out $_values
    1344         append out "\n"
    1345         return $out
    1346     }
    1347     # unirect3d (deprecated)
    1348     if {[info exists _comp2unirect3d($cname)]} {
    1349         set vector [$_comp2unirect3d($cname) values]
    1350         set label $cname
    1351         regsub -all { } $label {_} label
    1352         set elemSize [numComponents $cname]
    1353         set numValues [expr [$vector length] / $elemSize]
    1354         append out "# vtk DataFile Version 3.0\n"
    1355         append out "[hints label]\n"
    1356         append out "ASCII\n"
    1357         append out [$_comp2unirect3d($cname) vtkdata]
    1358         append out "POINT_DATA $numValues\n"
    1359         if {$elemSize == 3} {
    1360             append out "VECTORS $label double\n"
    1361         } else {
    1362             append out "SCALARS $label double $elemSize\n"
    1363             append out "LOOKUP_TABLE default\n"
    1364         }
    1365         # values for VTK are x-fastest
    1366         append out [$vector range 0 end]
    1367         append out "\n"
    1368         return $out
    13691284    }
    13701285    # Points on mesh:  Construct VTK file output.
     
    14581373    lappend _comp2fldName($cname) $name
    14591374
    1460     # Handle bizarre cases that are due to be removed.
    1461     if { $element == "unirect3d" } {
    1462         # Special case: unirect3d (deprecated) + flow.
    1463         set vectorsize [numComponents $cname]
    1464         set _type unirect3d
    1465         set _dim 3
    1466         if { $_viewer == "" } {
    1467             set _viewer flowvis
    1468         }
    1469         set _comp2dims($cname) "3D"
    1470         set _comp2unirect3d($cname) \
    1471             [Rappture::Unirect3d \#auto $_xmlobj $_field $cname $vectorsize]
    1472         set _comp2style($cname) [$_field get $cname.style]
    1473         set limits {}
    1474         foreach axis { x y z } {
    1475             lappend limits $axis [$_comp2unirect3d($cname) limits $axis]
    1476         }
    1477         # Get the data limits
    1478         set vector [$_comp2unirect3d($cname) values]
    1479         set minmax [VectorLimits $vector $vectorsize]
    1480         lappend limits $cname $minmax
    1481         lappend limits v      $minmax
    1482         set _comp2limits($cname) $limits
    1483         if {[$_field element $cname.flow] != ""} {
    1484             set _comp2flowhints($cname) \
    1485                 [Rappture::FlowHints ::\#auto $_field $cname $_units]
    1486         }
    1487         incr _counter
    1488         return 1
    1489     }
    1490     if { $element == "unirect2d" && [$_field element $cname.flow] != "" } {
    1491         # Special case: unirect2d (deprecated) + flow.
    1492         set vectorsize [numComponents $cname]
    1493         set _type unirect2d
    1494         set _dim 2
    1495         if { $_viewer == "" } {
    1496             set _viewer "flowvis"
    1497         }
    1498         set _comp2dims($cname) "2D"
    1499         set _comp2unirect2d($cname) \
    1500             [Rappture::Unirect2d \#auto $_xmlobj $path]
    1501         set _comp2style($cname) [$_field get $cname.style]
    1502         set _comp2flowhints($cname) \
    1503             [Rappture::FlowHints ::\#auto $_field $cname $_units]
    1504         set _values [$_field get $cname.values]
    1505         set limits {}
    1506         foreach axis { x y z } {
    1507             lappend limits $axis [$_comp2unirect2d($cname) limits $axis]
    1508         }
    1509         set xv [blt::vector create \#auto]
    1510         $xv set $_values
    1511         set minmax [VectorLimits $xv $vectorsize]
    1512         lappend limits $cname $minmax
    1513         lappend limits v $minmax
    1514         blt::vector destroy $xv
    1515         set _comp2limits($cname) $limits
    1516         incr _counter
    1517         return 1
    1518     }
    15191375    switch -- $element {
    15201376        "cloud" {
     
    15321388            set mesh [Rappture::Unirect2d::fetch $_xmlobj $path]
    15331389            set _type unirect2d
     1390        }
     1391        "unirect3d" {
     1392            set mesh [Rappture::Unirect3d::fetch $_xmlobj $path]
     1393            set _type unirect3d
    15341394        }
    15351395    }
  • trunk/gui/scripts/unirect2d.tcl

    r5610 r5611  
    2929    public proc release {obj}
    3030
    31     public method blob {}
    3231    public method dimensions {} {
    3332        return 2
     
    4948    private method GetSize { obj path varName }
    5049
    51     private variable _axisOrder  "x y"
    5250    private variable _xMax       0
    5351    private variable _xMin       0
     
    125123    GetSize $m "yaxis.numpoints" _yNum
    126124    foreach {key path} {
    127         group   about.group
    128125        label   about.label
    129126        color   about.color
    130127        style   about.style
    131         type    about.type
    132128        xlabel  xaxis.label
    133129        xdesc   xaxis.description
     
    182178
    183179# ----------------------------------------------------------------------
    184 # method blob
    185 #       Returns a Tcl list that represents the Tcl command and data to
    186 #       recreate the uniform rectangular grid on the nanovis server.
    187 # ----------------------------------------------------------------------
    188 itcl::body Rappture::Unirect2d::blob {} {
    189     set data "unirect2d"
    190     lappend data "xmin" $_xMin "xmax" $_xMax "xnum" $_xNum
    191     lappend data "ymin" $_yMin "ymax" $_yMax "ynum" $_yNum
    192     return $data
    193 }
    194 
    195 # ----------------------------------------------------------------------
    196180# method limits <axis>
    197181#       Returns a list {min max} representing the limits for the
  • trunk/gui/scripts/unirect3d.tcl

    r5610 r5611  
    22
    33# ----------------------------------------------------------------------
    4 #  COMPONENT: unirect3d - represents a uniform rectangular 2-D mesh.
     4#  COMPONENT: unirect3d - represents a uniform rectangular 3-D mesh.
    55#
    66#  This object represents one field in an XML description of a device.
     
    2020
    2121itcl::class Rappture::Unirect3d {
    22     constructor {xmlobj field cname {numComponents 1}} {
     22    constructor {xmlobj path} {
    2323        # defined below
    2424    }
     
    2626        # defined below
    2727    }
    28 
    29     public method blob {}
     28    public proc fetch {xmlobj path}
     29    public proc release {obj}
     30
    3031    public method dimensions {} {
    3132        return 3
     
    4041        return $_numPoints
    4142    }
    42     public method order {} {
    43         return _axisOrder;
    44     }
    4543    public method units { axis }
    46     public method values {}
    4744    public method vtkdata {{what -partial}} {}
    4845
     
    5148    private method GetSize { obj path varName }
    5249
    53     private variable _axisOrder  "x y z"
    5450    private variable _xMax       0
    5551    private variable _xMin       0
     
    6157    private variable _zMin       0
    6258    private variable _zNum       0;     # Number of points along z-axis
    63     private variable _compNum    1;     # Number of components in values
    64     private variable _values     "";    # BLT vector containing the values
    6559    private variable _hints
    6660    private variable _vtkdata    ""
    6761    private variable _numPoints  0
    6862    private variable _isValid    0;     # Indicates if the data is valid.
     63
     64    private common _xp2obj       ;      # used for fetch/release ref counting
     65    private common _obj2ref      ;      # used for fetch/release ref counting
     66}
     67
     68#
     69# fetch <xmlobj> <path>
     70#
     71#    Clients use this instead of a constructor to fetch the Mesh for a
     72#    particular <path> in the <xmlobj>.  When the client is done with the mesh,
     73#    he calls "release" to decrement the reference count.  When the mesh is no
     74#    longer needed, it is cleaned up automatically.
     75#
     76itcl::body Rappture::Unirect3d::fetch {xmlobj path} {
     77    set handle "$xmlobj|$path"
     78    if {[info exists _xp2obj($handle)]} {
     79        set obj $_xp2obj($handle)
     80        incr _obj2ref($obj)
     81        return $obj
     82    }
     83    set obj [Rappture::Unirect3d ::#auto $xmlobj $path]
     84    set _xp2obj($handle) $obj
     85    set _obj2ref($obj) 1
     86    return $obj
     87}
     88
     89# ----------------------------------------------------------------------
     90# USAGE: Rappture::Unirect3d::release <obj>
     91#
     92# Clients call this when they're no longer using a Mesh fetched
     93# previously by the "fetch" proc.  This decrements the reference
     94# count for the mesh and destroys the object when it is no longer
     95# in use.
     96# ----------------------------------------------------------------------
     97itcl::body Rappture::Unirect3d::release { obj } {
     98    if { ![info exists _obj2ref($obj)] } {
     99        error "can't find reference count for $obj"
     100    }
     101    incr _obj2ref($obj) -1
     102    if {$_obj2ref($obj) <= 0} {
     103        unset _obj2ref($obj)
     104        foreach handle [array names _xp2obj] {
     105            if {$_xp2obj($handle) == $obj} {
     106                unset _xp2obj($handle)
     107            }
     108        }
     109        itcl::delete object $obj
     110    }
    69111}
    70112
     
    72114# Constructor
    73115# ----------------------------------------------------------------------
    74 itcl::body Rappture::Unirect3d::constructor {xmlobj field cname {numComponents 1}} {
     116itcl::body Rappture::Unirect3d::constructor {xmlobj path} {
    75117    if {![Rappture::library isvalid $xmlobj]} {
    76118        error "bad value \"$xmlobj\": should be Rappture::library"
    77119    }
    78     set path [$field get $cname.mesh]
    79120    set m [$xmlobj element -as object $path]
    80121    GetValue $m "xaxis.min" _xMin
     
    87128    GetSize $m "yaxis.numpoints" _yNum
    88129    GetSize $m "zaxis.numpoints" _zNum
    89     set _compNum $numComponents
    90130    foreach {key path} {
    91         group   about.group
    92131        label   about.label
    93132        color   about.color
    94133        style   about.style
    95         type    about.type
    96134        xlabel  xaxis.label
    97135        xdesc   xaxis.description
     
    112150        zmin    zaxis.min
    113151        zmax    zaxis.max
    114         order   about.axisorder
    115152    } {
    116153        set str [$m get $path]
    117         if {"" != $str} {
    118             set _hints($key) $str
    119         }
    120     }
    121     foreach {key} { axisorder } {
    122         set str [$field get $cname.$key]
    123154        if {"" != $str} {
    124155            set _hints($key) $str
     
    130161        set _vtkdata ""
    131162        return
    132     }
    133     set _values [blt::vector create #auto]
    134     $_values set [$field get "$cname.values"]
    135     set n [expr $_numPoints * $_compNum]
    136     if { [$_values length] != $n } {
    137         error "wrong \# of values in \"$cname.values\": expected $n values, got [$_values length]"
    138163    }
    139164    append out "DATASET STRUCTURED_POINTS\n"
     
    165190# ----------------------------------------------------------------------
    166191itcl::body Rappture::Unirect3d::destructor {} {
    167     if { $_values != "" } {
    168         blt::vector destroy $_values
    169     }
    170 }
    171 
    172 # ----------------------------------------------------------------------
    173 # method blob
    174 #       Returns a Tcl list that represents the Tcl command and data to
    175 #       recreate the uniform rectangular grid on the nanovis server.
    176 # ----------------------------------------------------------------------
    177 itcl::body Rappture::Unirect3d::blob {} {
    178     set data "unirect3d"
    179     lappend data "xmin" $_xMin "xmax" $_xMax "xnum" $_xNum
    180     lappend data "ymin" $_yMin "ymax" $_yMax "ynum" $_yNum
    181     lappend data "zmin" $_zMin "zmax" $_zMax "znum" $_zNum
    182     lappend data "axisorder" $_axisOrder
    183     if { [$_values length] > 0 } {
    184         lappend data "values" [$_values range 0 end]
    185     }
    186     return $data
    187 }
    188 
    189 # ----------------------------------------------------------------------
    190 # method values
    191 #       Returns a BLT vector that represents the field values
    192 # ----------------------------------------------------------------------
    193 itcl::body Rappture::Unirect3d::values {} {
    194     return $_values
     192    # empty
    195193}
    196194
     
    217215            set max $_zMax
    218216        }
    219         v - vlin - vlog {
    220             if { [$_values length] > 0 } {
    221                set min [blt::vector expr min($_values)]
    222                set max [blt::vector expr max($_values)]
    223             } else {
    224                 set min 0.0
    225                 set max 1.0
    226             }
    227         }
    228217        default {
    229218            error "unknown axis description \"$which\""
     
    277266        set _hints(ylabel) "$_hints(zlabel) ($_hints(zunits))"
    278267    }
    279 
    280268    if {[info exists _hints(group)] && [info exists _hints(label)]} {
    281269        # pop-up help for each curve
Note: See TracChangeset for help on using the changeset viewer.