Changeset 1463


Ignore:
Timestamp:
May 19, 2009 6:47:11 PM (12 years ago)
Author:
gah
Message:
 
Location:
trunk/gui/scripts
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/gui/scripts/Makefile.in

    r1442 r1463  
    101101                $(srcdir)/tuples.tcl \
    102102                $(srcdir)/unirect2d.tcl \
     103                $(srcdir)/unirect3d.tcl \
    103104                $(srcdir)/units.tcl \
    104105                $(srcdir)/utils.tcl \
  • trunk/gui/scripts/field.tcl

    r1441 r1463  
    4747    private variable _comp2dx    ;# maps component name => OpenDX data
    4848    private variable _comp2unirect2d ;# maps component name => unirect2d obj
     49    private variable _comp2unirect3d ;# maps component name => unirect3d obj
    4950    private variable _comp2style ;# maps component name => style settings
    5051    private variable _comp2cntls ;# maps component name => x,y control points
     
    190191    }
    191192    if {[info exists _comp2unirect2d($what)]} {
     193        set mobj [lindex $_comp2unirect2d($what) 0]
    192194        return [$mobj mesh]
    193195    }
    194196    if {[info exists _comp2unirect3d($what)]} {
     197        set mobj [lindex $_comp2unirect3d($what) 0]
    195198        return [$mobj mesh]
    196199    }
     
    222225    }
    223226    if {[info exists _comp2unirect3d($what)]} {
    224         return [$_comp2unirect3d($what) values]
     227        return [$_comp2unirect3d($what) blob]
    225228    }
    226229    error "bad option \"$what\": should be [join [lsort [array names _comp2dims]] {, }]"
     
    247250    if {[info exists _comp2unirect2d($what)]} {
    248251        set mobj $_comp2unirect2d($what)
     252        return [$mobj blob]
     253    }
     254    if {[info exists _comp2unirect3d($what)]} {
     255        set mobj $_comp2unirect3d($what)
    249256        return [$mobj blob]
    250257    }
     
    307314                if {[info exists _comp2unirect2d($comp)]} {
    308315                    set limits [$_comp2unirect2d($comp) limits $which]
     316                    foreach {vmin vmax} $limits break
     317                    set axis vaxis
     318                } elseif {[info exists _comp2unirect3d($comp)]} {
     319                    set limits [$_comp2unirect3d($comp) limits $which]
    309320                    foreach {vmin vmax} $limits break
    310321                    set axis vaxis
     
    528539    foreach name [array names _comp2unirect2d] {
    529540        eval itcl::delete object $_comp2unirect2d($name)
     541    }
     542    foreach name [array names _comp2unirect3d] {
     543        eval itcl::delete object $_comp2unirect3d($name)
    530544    }
    531545    catch {unset _comp2xy}
     
    625639            if {[$_xmlobj element $path] != ""} {
    626640                set element [$_xmlobj element -as type $path]
     641                puts stderr "element is $element"
    627642                if { $element == "unirect2d" } {
    628643                    set _comp2dims($cname) "2D"
     
    843858        set max 0
    844859        foreach cname [$_field children -type component] {
    845             if { [info exists _comp2extents($cname)] } {
    846                 if { $max < $_comp2extents($cname) } {
    847                     set max $_comp2extents($cname)
    848                 }
     860            if { [info exists _comp2unirect3d($cname)] } {
     861                set value [$_comp2unirect3d($cname) components]
     862            } elseif { [info exists _comp2unirect2d($cname)] } {
     863                set value [$_comp2unirect2d($cname) components]
     864            } elseif { [info exists _comp2extents($cname)] } {
     865                set value $_comp2extents($cname)
     866            } else {
     867                continue
     868            }
     869            if { $max < $value } {
     870                set max $value
    849871            }
    850872        }
     
    853875    if { $what == "component0"} {
    854876        set what [lindex [components -name] 0]
    855         return $_comp2extents($what)
     877        if { [info exists _comp2unirect3d($what)] } {
     878            return [$_comp2unirect3d($what) components]
     879        } elseif { [info exists _comp2unirect2d($what)] } {
     880            return [$_comp2unirect2d($what) components]
     881        } elseif { [info exists _comp2extents($what)] } {
     882            return $_comp2extents($what)
     883        }
    856884    }
    857885    return $_comp2extents($what)
  • trunk/gui/scripts/field2dresult.tcl

    r1342 r1463  
    5555    }
    5656    array set flags $args
    57     if { $flags(-mode) == "heightmap" } {
    58         set servers [Rappture::VisViewer::GetServerList "nanovis"]
    59         if { $servers == "" } {
    60             error "No nanovis servers available"
     57    set servers [Rappture::VisViewer::GetServerList "nanovis"]
     58    if {"" != $servers && $flags(-mode) != "vtk"} {
     59        switch -- $flags(-mode) {
     60            "auto" - "heightmap" {
     61                itk_component add renderer {
     62                    Rappture::HeightmapViewer $itk_interior.ren $servers
     63                }
     64            }
     65            "flowvis" {
     66                itk_component add renderer {
     67                    Rappture::FlowvisViewer $itk_interior.ren $servers
     68                }
     69            }
     70            default {
     71                puts stderr "unknown render mode \"$flags(-mode)\""
     72            }
     73        }               
     74        pack $itk_component(renderer) -expand yes -fill both
     75        # can't connect to rendering farm?  then fall back to older viewer
     76        if {![$itk_component(renderer) isconnected]} {
     77            destroy $itk_component(renderer)
    6178        }
    62         itk_component add renderer {
    63             Rappture::HeightmapViewer $itk_interior.ren $servers
    64         }
    65         pack $itk_component(renderer) -expand yes -fill both
    66     } else {
     79    }
     80
     81    if {![info exists itk_component(renderer)]} {
    6782        itk_component add renderer {
    6883            Rappture::ContourResult $itk_interior.ren
  • trunk/gui/scripts/flowvisviewer.tcl

    r1461 r1463  
    894894        foreach comp [$dataobj components] {
    895895            # Send the data as one huge base64-encoded mess -- yuck!
    896             set data [$dataobj values $comp]
     896            set data [$dataobj blob $comp]
    897897            set nbytes [string length $data]
    898898            set extents [$dataobj extents $comp]
  • trunk/gui/scripts/heightmapviewer.tcl

    r1448 r1463  
    6363    protected method Connect {}
    6464    protected method Disconnect {}
     65    public method isconnected {}
    6566
    6667    protected method SendCmd {string}
     
    461462}
    462463
     464#
     465# isconnected --
     466#
     467#       Indicates if we are currently connected to the visualization server.
     468#
     469itcl::body Rappture::HeightmapViewer::isconnected {} {
     470    return [VisViewer::IsConnected]
     471}
     472
    463473# ----------------------------------------------------------------------
    464474# USAGE: Connect ?<host:port>,<host:port>...?
     
    503513#       sent later.
    504514#
    505 itcl::body Rappture::NanovisViewer::SendCmd {string} {
     515itcl::body Rappture::HeightmapViewer::SendCmd {string} {
    506516    if { $_buffering } {
    507517        append _outbuf $string "\n"
     
    12191229
    12201230itcl::body Rappture::HeightmapViewer::Resize { w h } {
    1221     #puts stderr "w=$w h=$h"
    12221231    SendCmd "screen $w $h"
    12231232}
  • trunk/gui/scripts/resultviewer.tcl

    r1373 r1463  
    244244                            set resultMode "vtk"
    245245                        }
     246                        set extents [$dataobj extents]
     247                        if { $extents > 1 } {
     248                            set resultMode "flowvis"
     249                        }
    246250                        set w $itk_interior.contour
    247251                        Rappture::Field2DResult $w -mode $resultMode
     
    255259                        set fmt [expr {("" != $mesh) ? "vtk" : "nanovis"}]
    256260                        set extents [$dataobj extents]
    257                         if { $extents == 3 } {
     261                        if { $extents > 1 } {
    258262                            set fmt "flowvis"
    259263                        }
  • trunk/gui/scripts/unirect2d.tcl

    r1373 r1463  
    2727    public method values {}
    2828    public method hints {{keyword ""}}
    29 
    30     private variable _xmax 0
    31     private variable _xmin 0
    32     private variable _xnum 0
    33     private variable _ymax 0
    34     private variable _ymin 0
    35     private variable _ynum 0
     29    public method components {} {
     30        return $_components;
     31    }
     32    private method GetString { obj path varName }
     33    private method GetValue { obj path varName }
     34    private method GetSize { obj path varName }
     35
     36    private variable _axisOrder  "x y"
     37    private variable _xMax 0
     38    private variable _xMin 0
     39    private variable _xNum 0
     40    private variable _yMax 0
     41    private variable _yMin 0
     42    private variable _yNum 0
     43    private variable _components 1
    3644    private variable _values "";        # BLT vector containing the z-values
    3745    private variable _hints
     
    4755    set path [$field get $cname.mesh]
    4856
    49     set mobj [$xmlobj element -as object $path]
    50     set _xmin [$mobj get "xaxis.min"]
    51     set _xmax [$mobj get "xaxis.max"]
    52     set _xnum [$mobj get "xaxis.numpoints"]
    53     set _ymin [$mobj get "yaxis.min"]
    54     set _ymax [$mobj get "yaxis.max"]
    55     set _ynum [$mobj get "yaxis.numpoints"]
     57    set m [$xmlobj element -as object $path]
     58    GetSize $m "components" _components
     59    GetValue $m "xaxis.min" _xMin
     60    GetValue $m "xaxis.max" _xMax
     61    GetSize $m "xaxis.numpoints" _xNum
     62    GetValue $m "yaxis.min" _yMin
     63    GetValue $m "yaxis.max" _yMax
     64    GetSize $m "yaxis.numpoints" _yNum
    5665   
    5766    foreach {key path} {
     
    7483        ymax    yaxis.max
    7584    } {
    76         set str [$mobj get $path]
     85        set str [$m get $path]
    7786        if {"" != $str} {
    7887            set _hints($key) $str
    7988        }
    8089    }
    81     foreach {key} { extents axisorder } {
     90    foreach {key} { components axisorder } {
    8291        set str [$field get $cname.$key]
    8392        if {"" != $str} {
     
    8594        }
    8695    }
    87     itcl::delete object $mobj
     96    itcl::delete object $m
    8897   
    8998    set _values [blt::vector create \#auto]
     
    112121itcl::body Rappture::Unirect2d::blob {} {
    113122    set data "unirect2d"
    114     lappend data "xmin" $_xmin "xmax" $_xmax "xnum" $_xnum
    115     lappend data "ymin" $_ymin "ymax" $_ymax "ynum" $_ynum
    116     lappend data "xmin" $_xmin "ymin" $_ymin "xmax" $_xmax "ymax" $_ymax
    117     foreach key { axisorder extents xunits yunits units } {
     123    lappend data "xmin" $_xMin "xmax" $_xMax "xnum" $_xNum
     124    lappend data "ymin" $_yMin "ymax" $_yMax "ynum" $_yNum
     125    lappend data "xmin" $_xMin "ymin" $_yMin "xmax" $_xMax "ymax" $_yMax
     126    lappend data "components" $_components
     127    foreach key { axisorder xunits yunits units } {
    118128        set hint [hints $key]
    119129        if { $hint != "" } {
     
    124134        lappend data "values" [$_values range 0 end]
    125135    }
    126     return [Rappture::encoding::encode -as zb64 $data]
     136    return [Rappture::encoding::encode -as zb64 "$data"]
    127137}
    128138
     
    134144# ----------------------------------------------------------------------
    135145itcl::body Rappture::Unirect2d::mesh {} {
    136     set dx [expr {($_xmax - $_xmin) / double($_xnum)}]
    137     set dy [expr {($_ymax - $_ymin) / double($_ynum)}]
    138     for { set i 0 } { $i < $_xnum } { incr i } {
    139         set x [expr {$_xmin + (double($i) * $dx)}]
    140         for { set j 0 } { $j < $_ynum } { incr j } {
    141             set y [expr {$_ymin + (double($i) * $dy)}]
     146    set dx [expr {($_xMax - $_xMin) / double($_xNum)}]
     147    set dy [expr {($_yMax - $_yMin) / double($_yNum)}]
     148    for { set i 0 } { $i < $_xNum } { incr i } {
     149        set x [expr {$_xMin + (double($i) * $dx)}]
     150        for { set j 0 } { $j < $_yNum } { incr j } {
     151            set y [expr {$_yMin + (double($i) * $dy)}]
    142152            lappend data $x $y
    143153        }
     
    170180    switch -- $which {
    171181        x - xlin - xlog {
    172             set min $_xmin
    173             set max $_xmax
     182            set min $_xMin
     183            set max $_xMax
    174184            set axis "xaxis"
    175185        }
    176186        y - ylin - ylog {
    177             set min $_ymin
    178             set max $_ymax
     187            set min $_yMin
     188            set max $_yMax
    179189            set axis "yaxis"
    180190        }
     
    241251    return [array get _hints]
    242252}
     253
     254
     255itcl::body Rappture::Unirect2d::GetSize { obj path varName } {
     256    set string [$obj get $path]
     257    if { [scan $string "%d" value] != 1 || $value < 0 } {
     258        puts stderr "can't get size \"$string\" of \"$path\""
     259        return
     260    }
     261    upvar $varName size
     262    set size $value
     263}
     264
     265itcl::body Rappture::Unirect2d::GetValue { obj path varName } {
     266    set string [$obj get $path]
     267    if { [scan $string "%g" value] != 1 } {
     268        return
     269    }
     270    upvar $varName number
     271    set number $value
     272}
     273
     274itcl::body Rappture::Unirect2d::GetString { obj path varName } {
     275    set string [$obj get $path]
     276    if { $string == "" } {
     277        puts stderr "can't get string \"$string\" of \"$path\""
     278        return
     279    }
     280    upvar $varName str
     281    set str $string
     282}
  • trunk/gui/scripts/unirect3d.tcl

    r1373 r1463  
    2828    public method hints {{keyword ""}}
    2929    public method order {} {
    30         return _order;
    31     }
    32     public method dimensions {} {
    33         return _dim;
    34     }
    35     private variable _order      "x y z"
    36     private variable _dimensions 1
    37     private variable _xmax       0
    38     private variable _xmin       0
    39     private variable _xnum       0
    40     private variable _ymax       0
    41     private variable _ymin       0
    42     private variable _ynum       0
    43     private variable _zmax       0
    44     private variable _zmin       0
    45     private variable _znum       0
     30        return _axisOrder;
     31    }
     32    public method components {} {
     33        return _components;
     34    }
     35    private method GetString { obj path varName }
     36    private method GetValue { obj path varName }
     37    private method GetSize { obj path varName }
     38
     39    private variable _axisOrder  "x y z"
     40    private variable _xMax       0
     41    private variable _xMin       0
     42    private variable _xNum       0
     43    private variable _yMax       0
     44    private variable _yMin       0
     45    private variable _yNum       0
     46    private variable _zMax       0
     47    private variable _zMin       0
     48    private variable _zNum       0
     49    private variable _components 1
    4650    private variable _values     ""; # BLT vector containing the z-values
    4751    private variable _hints
     
    5660    }
    5761    set path [$field get $cname.mesh]
    58 
    59     set mobj [$xmlobj element -as object $path]
    60     set order [$mobj get "axisorder"]
    61     if { $order != "" } {
    62         set _order $order
    63     }
    64     set dim [$mobj get "dimensions"]
    65     if { $dim != "" } {
    66         set _dimensions $dim
    67     }
    68     set _xmin [$mobj get "xaxis.min"]
    69     set _xmax [$mobj get "xaxis.max"]
    70     set _xnum [$mobj get "xaxis.numpoints"]
    71     set _ymin [$mobj get "yaxis.min"]
    72     set _ymax [$mobj get "yaxis.max"]
    73     set _ynum [$mobj get "yaxis.numpoints"]
    74     set _zmin [$mobj get "zaxis.min"]
    75     set _zmax [$mobj get "zaxis.max"]
    76     set _znum [$mobj get "zaxis.numpoints"]
    77     itcl::delete object $mobj
     62    set m [$xmlobj element -as object $path]
     63    puts stderr [$m children]
     64    GetValue $m "xaxis.max" _xMax
     65    GetValue $m "xaxis.min" _xMin
     66    GetValue $m "yaxis.max" _yMax
     67    GetValue $m "yaxis.min" _yMin
     68    GetValue $m "zaxis.max" _zMax
     69    GetValue $m "zaxis.min" _zMin
     70    GetSize $m "xaxis.numpoints" _xNum
     71    GetSize $m "yaxis.numpoints" _yNum
     72    GetSize $m "zaxis.numpoints" _zNum
     73    GetSize $m "components" _components
     74    itcl::delete object $m
    7875
    7976    set _values [blt::vector create #auto]
     
    9794# ----------------------------------------------------------------------
    9895itcl::body Rappture::Unirect3d::blob {} {
    99     set data "unirect3d"
    100     lappend data "xmin" $_xmin "xmax" $_xmax "xnum" $_xnum
    101     lappend data "ymin" $_ymin "ymax" $_ymax "ynum" $_ynum
    102     lappend data "zmin" $_zmin "zmax" $_zmax "znum" $_znum
    103     lappend data "axisorder" $_axisorder
    104     lappend data "dimensions" $_dim
     96    lappend data "unirect3d"
     97    lappend data "xmin" $_xMin "xmax" $_xMax "xnum" $_xNum
     98    lappend data "ymin" $_yMin "ymax" $_yMax "ynum" $_yNum
     99    lappend data "zmin" $_zMin "zmax" $_zMax "znum" $_zNum
     100    lappend data "axisorder" $_axisOrder
     101    lappend data "components" $_components
    105102    if { [$_values length] > 0 } {
    106103        lappend data "values" [$_values range 0 end]
    107104    }
    108     return [Rappture::encoding::encode -as zb64 $data]
     105    return [Rappture::encoding::encode -as zb64 "$data"]
    109106}
    110107
     
    116113# ----------------------------------------------------------------------
    117114itcl::body Rappture::Unirect3d::mesh {} {
    118     set dx [expr {($_xmax - $_xmin) / double($_xnum)}]
    119     set dy [expr {($_ymax - $_ymin) / double($_ynum)}]
    120     set dz [expr {($_zmax - $_zmin) / double($_znum)}]
    121     foreach {a b c} $_axisorder break
    122     for { set i 0 } { $i < [set _${a}num] } { incr i } {
    123         set v1 [expr {[set _${a}min] + (double($i) * [set d${a}])}]
    124         for { set j 0 } { $j < [set _${b}num] } { incr j } {
    125             set v2 [expr {[set _${b}min] + (double($i) * [set d${b}])}]
    126             for { set k 0 } { $k < [set _{$c}num] } { incr k } {
    127                 set v3 [expr {[set _${c}min] + (double($i) * [set d${c}])}]
     115    set dx [expr {($_xMax - $_xMin) / double($_xNum)}]
     116    set dy [expr {($_yMax - $_yMin) / double($_yNum)}]
     117    set dz [expr {($_zMax - $_zMin) / double($_zNum)}]
     118    foreach {a b c} $_axisOrder break
     119    for { set i 0 } { $i < [set _${a}Num] } { incr i } {
     120        set v1 [expr {[set _${a}Min] + (double($i) * [set d${a}])}]
     121        for { set j 0 } { $j < [set _${b}Num] } { incr j } {
     122            set v2 [expr {[set _${b}Min] + (double($i) * [set d${b}])}]
     123            for { set k 0 } { $k < [set _${c}Num] } { incr k } {
     124                set v3 [expr {[set _${c}Min] + (double($i) * [set d${c}])}]
    128125                lappend data $v1 $v2 $v3
    129126            }
     
    157154    switch -- $which {
    158155        x - xlin - xlog {
    159             set min $_xmin
    160             set max $_xmax
     156            set min $_xMin
     157            set max $_xMax
    161158            set axis "xaxis"
    162159        }
    163160        y - ylin - ylog {
    164             set min $_ymin
    165             set max $_ymax
     161            set min $_yMin
     162            set max $_yMax
    166163            set axis "yaxis"
    167164        }
    168165        z - zlin - zlog {
    169             set min $_zmin
    170             set max $_zmax
     166            set min $_zMin
     167            set max $_zMax
    171168            set axis "zaxis"
    172169        }
     
    216213            zunits  zaxis.units
    217214            zscale  zaxis.scale
    218             dim     about.dimension
    219215            order   about.axisorder
    220216        } {
     
    250246    return [array get _hints]
    251247}
     248
     249itcl::body Rappture::Unirect3d::GetSize { obj path varName } {
     250    set string [$obj get $path]
     251    if { [scan $string "%d" value] != 1 || $value < 0 } {
     252        puts stderr "can't get size \"$string\" of \"$path\""
     253        return
     254    }
     255    upvar $varName size
     256    set size $value
     257}
     258
     259itcl::body Rappture::Unirect3d::GetValue { obj path varName } {
     260    set string [$obj get $path]
     261    if { [scan $string "%g" value] != 1 } {
     262        puts stderr "can't get value \"$string\" of \"$path\""
     263        return
     264    }
     265    upvar $varName number
     266    set number $value
     267}
     268
     269itcl::body Rappture::Unirect3d::GetString { obj path varName } {
     270    set string [$obj get $path]
     271    if { $string == "" } {
     272        puts stderr "can't get string \"$string\" of \"$path\""
     273        return
     274    }
     275    upvar $varName str
     276    set str $string
     277}
Note: See TracChangeset for help on using the changeset viewer.