Changeset 5002 for trunk/gui


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

Whitespace: trailing spaces

File:
1 edited

Legend:

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

    r5001 r5002  
    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
     
    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
    7979    private variable _isValid 0;        # Indicates if the field contains
     
    8282    private variable _alwaysConvertDX 0;
    8383
    84     constructor {xmlobj path} { 
    85         # defined below 
    86     }
    87     destructor { 
    88         # defined below 
     84    constructor {xmlobj path} {
     85        # defined below
     86    }
     87    destructor {
     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 {}
    131131    protected method _getValue {expr}
    132132
    133     private variable _path "";          # Path of this object in the XML 
     133    private variable _path "";          # Path of this object in the XML
    134134    private variable _units ""   ;      # system of units for this field
    135135    private variable _zmax 0     ;# length of the device
     
    143143    private variable _comp2style ;# maps component name => style settings
    144144    private variable _comp2cntls ;# maps component name => x,y control points
    145     private variable _comp2extents 
     145    private variable _comp2extents
    146146    private variable _comp2limits;        #  Array of limits per component
    147     private variable _type "" 
    148     private variable _comp2flowhints 
     147    private variable _type ""
     148    private variable _comp2flowhints
    149149    private variable _comp2mesh  ;# list of: mesh object, BLT vector of values
    150150    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} }
    163163}
     
    284284    # Now handle the tests.
    285285    switch -- $params(what) {
    286         -name { 
     286        -name {
    287287            set rlist $components
    288288        }
    289         -style { 
     289        -style {
    290290            foreach cname $components {
    291291                if { [info exists _comp2style($cname)] } {
    292                     lappend rlist $_comp2style($cname) 
     292                    lappend rlist $_comp2style($cname)
    293293                }
    294294            }
     
    399399# USAGE: valueLimits <cname>
    400400#
    401 # 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}
    402402# representing the limits for each axis.
    403403# ----------------------------------------------------------------------
     
    423423            1D {
    424424                switch -- $which {
    425                     x - xlin { 
    426                         set pos 0; set log 0; set axis x 
     425                    x - xlin {
     426                        set pos 0; set log 0; set axis x
    427427                    }
    428                     xlog { 
    429                         set pos 0; set log 1; set axis x 
     428                    xlog {
     429                        set pos 0; set log 1; set axis x
    430430                    }
    431                     y - ylin - v - vlin { 
    432                         set pos 1; set log 0; set axis y 
     431                    y - ylin - v - vlin {
     432                        set pos 1; set log 0; set axis y
    433433                    }
    434                     ylog - vlog { 
    435                         set pos 1; set log 1; set axis y 
     434                    ylog - vlog {
     435                        set pos 1; set log 1; set axis y
    436436                    }
    437437                    default {
     
    471471            default {
    472472                if {[info exists _comp2limits($cname)]} {
    473                     array set limits $_comp2limits($cname) 
     473                    array set limits $_comp2limits($cname)
    474474                    switch -- $which {
    475475                        x - xlin - xlog {
     
    536536itcl::body Rappture::Field::fieldlimits {} {
    537537    foreach cname [array names _comp2limits] {
    538         array set limits $_comp2limits($cname) 
     538        array set limits $_comp2limits($cname)
    539539        foreach fname [fieldnames $cname] {
    540540            if { ![info exists limits($fname)] } {
     
    562562    return ""
    563563}
    564  
     564
    565565# ----------------------------------------------------------------------
    566566# USAGE: controls get ?<name>?
     
    786786            if { [info exists env(VTKVOLUME)] } {
    787787                set _viewer "vtkvolume"
    788             } 
     788            }
    789789            set type "opendx"
    790790        } elseif {[$_field element $cname.dx] != ""} {
     
    808808            set extents [$_field get $cname.extents]
    809809        } else {
    810             set extents 1 
     810            set extents 1
    811811        }
    812812        set _comp2extents($cname) $extents
     
    972972        return 0
    973973    }
    974     # 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
    975975    # dimension.
    976976    set dim ""
     
    989989    #        the label and units for each field will be specified there.
    990990    #
    991     # FIXME: Test that every <field><component> has the same field names, 
     991    # FIXME: Test that every <field><component> has the same field names,
    992992    #        units, components.
    993993    #
     
    10611061# isunirect2d  --
    10621062#
    1063 # Returns if the field is a unirect2d object. 
     1063# Returns if the field is a unirect2d object.
    10641064#
    10651065itcl::body Rappture::Field::isunirect2d { } {
     
    10701070# isunirect3d  --
    10711071#
    1072 # Returns if the field is a unirect3d object. 
     1072# Returns if the field is a unirect3d object.
    10731073#
    10741074itcl::body Rappture::Field::isunirect3d { } {
     
    10791079# flowhints  --
    10801080#
    1081 # Returns the hints associated with a flow vector field. 
     1081# Returns the hints associated with a flow vector field.
    10821082#
    10831083itcl::body Rappture::Field::flowhints { cname } {
     
    10911091# style  --
    10921092#
    1093 # Returns the style associated with a component of the field. 
     1093# Returns the style associated with a component of the field.
    10941094#
    10951095itcl::body Rappture::Field::style { cname } {
     
    11281128# extents --
    11291129#
    1130 # Returns if the field is a unirect2d object. 
     1130# Returns if the field is a unirect2d object.
    11311131#
    11321132itcl::body Rappture::Field::extents {{cname -overall}} {
     
    11441144        }
    11451145        return $max
    1146     } 
     1146    }
    11471147    if { $cname == "component0"} {
    11481148        set cname [lindex [components -name] 0]
     
    11611161    set f [open "$tmpfile" "w"]
    11621162    fconfigure $f -translation binary -encoding binary
    1163     puts $f $contents 
     1163    puts $f $contents
    11641164    close $f
    11651165
     
    11951195    set f [open "$tmpfile" "w"]
    11961196    fconfigure $f -translation binary -encoding binary
    1197     puts $f $contents 
     1197    puts $f $contents
    11981198    close $f
    11991199
     
    12361236        for { set i 0 } { $i < $numPoints } { incr i } {
    12371237            set point [$dataset GetPoint $i]
    1238             $xv append [lindex $point 0] 
     1238            $xv append [lindex $point 0]
    12391239        }
    12401240        set yv [blt::vector create \#auto]
     
    12531253        set numTuples [$array GetNumberOfTuples]
    12541254        for { set i 0 } { $i < $numTuples } { incr i } {
    1255             $yv append [$array GetComponent $i 0] 
     1255            $yv append [$array GetComponent $i 0]
    12561256        }
    12571257        $xv sort $yv
    12581258        set _comp2xy($cname) [list $xv $yv]
    12591259    }
    1260     lappend limits x [list $xmin $xmax] 
    1261     lappend limits y [list $ymin $ymax] 
     1260    lappend limits x [list $xmin $xmax]
     1261    lappend limits y [list $ymin $ymax]
    12621262    lappend limits z [list $zmin $zmax]
    12631263    set dataAttrs [$dataset GetPointData]
     
    12871287        }
    12881288    }
    1289    
     1289
    12901290    lappend limits v [list $vmin $vmax]
    12911291    set _comp2limits($cname) $limits
     
    13041304        set cname "component"
    13051305    }
    1306     # DX: Convert DX to VTK 
     1306    # DX: Convert DX to VTK
    13071307    if {[info exists _comp2dx($cname)]} {
    13081308        set data $_comp2dx($cname)
     
    13101310        return [Rappture::DxToVtk $data]
    13111311    }
    1312     # VTK file data: 
     1312    # VTK file data:
    13131313    if { [info exists _comp2vtk($cname)] } {
    13141314        return $_comp2vtk($cname)
     
    13641364            }
    13651365        }
    1366         append out [$vector range 0 end] 
     1366        append out [$vector range 0 end]
    13671367        append out "\n"
    13681368        if 0 {
     
    14131413            set vectorsize [$_field get $cname.extents]
    14141414        } else {
    1415             set vectorsize 1 
     1415            set vectorsize 1
    14161416        }
    14171417        set _type unirect3d
     
    14281428            lappend limits $axis [$_comp2unirect3d($cname) limits $axis]
    14291429        }
    1430         # Get the data limits 
     1430        # Get the data limits
    14311431        set vector [$_comp2unirect3d($cname) values]
    14321432        set minmax [VectorLimits $vector $vectorsize]
     
    14461446            set vectorsize [$_field get $cname.extents]
    14471447        } else {
    1448             set vectorsize 1 
     1448            set vectorsize 1
    14491449        }
    14501450        set _type unirect2d
     
    14821482            set mesh [Rappture::Mesh::fetch $_xmlobj $path]
    14831483            set _type mesh
    1484         }           
     1484        }
    14851485        "unirect2d" {
    14861486            if { $_viewer == "" } {
     
    14971497    set _dim [$mesh dimensions]
    14981498    if { $_dim == 3 } {
    1499         set dim 0 
     1499        set dim 0
    15001500        foreach axis {x y z} {
    15011501            foreach {min max} [$mesh limits $axis] {
     
    15181518        # Band Structure Lab used to (see isosurface1 test in rappture-bat)
    15191519        #
    1520         # Is there a natural growth path in generating output from 1D to 
     1520        # Is there a natural growth path in generating output from 1D to
    15211521        # higher dimensions?  If there isn't, let's kill this in favor
    15221522        # or explicitly using a <curve> instead.  Otherwise, the features
    1523         # (methods such as xmarkers) or the <curve> need to be added 
     1523        # (methods such as xmarkers) or the <curve> need to be added
    15241524        # to the <field>.
    1525         # 
     1525        #
    15261526        #set xv [blt::vector create x$_counter]
    15271527        #set yv [blt::vector create y$_counter]
     
    15351535        #incr _counter
    15361536        #return 1
    1537     } 
     1537    }
    15381538    if {$_dim == 2} {
    15391539        # 2D data: By default surface or contour plot using heightmap widget.
     
    15821582        lappend _comp2limits($cname) v $minmax
    15831583        return 1
    1584     } 
     1584    }
    15851585    if {$_dim == 3} {
    15861586        # 3D data: By default isosurfaces plot using isosurface widget.
     
    17191719        "tcoords"              2
    17201720        "tensors"              9
    1721         "vectors"              3 
     1721        "vectors"              3
    17221722    }
    17231723    set type [$_field get $cname.elemtype]
    17241724    if { $type == "" } {
    17251725        set type "scalars"
    1726     } 
     1726    }
    17271727    if { ![info exists type2components($type)] } {
    17281728        error "unknown <elemtype> \"$type\" in field"
     
    17411741        set _comp2assoc($cname) "pointdata"
    17421742        return
    1743     } 
     1743    }
    17441744    switch -- $assoc {
    17451745        "pointdata" - "celldata" - "fielddata" {
Note: See TracChangeset for help on using the changeset viewer.