Changeset 3585


Ignore:
Timestamp:
Mar 25, 2013 7:03:02 PM (7 years ago)
Author:
gah
Message:

fix regression: set default viewer for 2D data sets

Location:
trunk/gui/scripts
Files:
2 edited

Legend:

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

    r3581 r3585  
    150150    private method ConvertToVtkData { cname }
    151151    private method ReadVtkDataSet { cname contents }
     152    private method VerifyVtkDataSet { contents }
    152153    private method AvsToVtk { cname contents }
    153154    private variable _values ""
     
    745746            set type "points-on-mesh"
    746747        } elseif { [$_field element $cname.vtk] != ""} {
     748            set type "vtk"
    747749            set viewer [$_field get "about.view"]
    748             set type "vtk"
    749750            if { $viewer != "" } {
    750751                set _viewer $viewer
     
    11441145}
    11451146
     1147itcl::body Rappture::Field::VerifyVtkDataSet { contents } {
     1148    package require vtk
     1149
     1150    set reader $this-datasetreader
     1151    vtkDataSetReader $reader
     1152
     1153    # Write the contents to a file just in case it's binary.
     1154    set tmpfile file[pid].vtk
     1155    set f [open "$tmpfile" "w"]
     1156    fconfigure $f -translation binary -encoding binary
     1157    puts $f $contents
     1158    close $f
     1159
     1160    $reader SetFileName $tmpfile
     1161    $reader ReadAllScalarsOn
     1162    $reader ReadAllVectorsOn
     1163    $reader ReadAllFieldsOn
     1164    $reader Update
     1165    set dataset [$reader GetOutput]
     1166    set points [$dataset GetPoints]
     1167    set numPoints [$points GetNumberOfPoints]
     1168    set dataAttrs [$dataset GetPointData]
     1169    if { $_dim == 1 } {
     1170        set numArrays [$dataAttrs GetNumberOfArrays]
     1171    }
     1172    if { $dataAttrs == ""} {
     1173        puts stderr "WARNING: no point data found in \"$_path\""
     1174        return 0
     1175    }
     1176    set numArrays [$dataAttrs GetNumberOfArrays]
     1177    file delete $tmpfile
     1178    rename $reader ""
     1179}
     1180
    11461181itcl::body Rappture::Field::ReadVtkDataSet { cname contents } {
    11471182    package require vtk
     
    12671302        append out "LOOKUP_TABLE default\n"
    12681303        append out "[$vector range 0 end]\n"
     1304        if 0 {
     1305            VerifyVtkDataSet $out
     1306        }
    12691307        return $out
    12701308    }
     
    13751413    set _dim [$mesh dimensions]
    13761414    if {$_dim == 1} {
     1415        # 1D data: Create vectors for graph widget.
    13771416        # Is this used anywhere?
    13781417        #
     
    14001439    }
    14011440    if {$_dim == 2} {
     1441        # 2D data: By default surface or contour plot using heightmap widget.
    14021442        set _type "heightmap"
    14031443        set v [blt::vector create \#auto]
     
    14051445        if { [$v length] == 0 } {
    14061446            return 0
     1447        }
     1448        if { $_viewer == "" } {
     1449            set _viewer "contour"
    14071450        }
    14081451        set _comp2dims($cname) "[$mesh dimensions]D"
     
    14181461    }
    14191462    if {$_dim == 3} {
    1420         #
    1421         # 3D data: Store cloud/field as components
    1422         #
     1463        # 3D data: By default isosurfaces plot using isosurface widget.
    14231464        set values [$_field get $cname.values]
    14241465        set farray [vtkFloatArray ::vals$_counter]
  • trunk/gui/scripts/vtkheightmapviewer.tcl

    r3571 r3585  
    547547        set args "-objects"
    548548    }
    549 
    550549    set op [lindex $args 0]
    551550    switch -- $op {
Note: See TracChangeset for help on using the changeset viewer.