Ignore:
Timestamp:
Mar 8, 2015, 3:23:52 AM (10 years ago)
Author:
ldelgass
Message:

whitespace

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/1.4/gui/scripts/flowvisviewer.tcl

    r5095 r5101  
    1 # -*- mode: tcl; indent-tabs-mode: nil -*- 
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    22# ----------------------------------------------------------------------
    33#  COMPONENT: flowvisviewer - 3D flow rendering
    4 #
    54#
    65# This widget performs volume and flow rendering on 3D scalar/vector datasets.
     
    6564    public method limits { cname }
    6665    public method overMarker { m x }
    67     public method parameters {title args} { 
    68         # do nothing 
     66    public method parameters {title args} {
     67        # do nothing
    6968    }
    7069    public method removeDuplicateMarker { m x }
     
    8988    private method CurrentVolumeIds {{what -all}}
    9089    private method Disconnect {}
    91     private method EventuallyResize { w h } 
    92     private method EventuallyGoto { nSteps } 
    93     private method EventuallyResizeLegend { } 
     90    private method EventuallyResize { w h }
     91    private method EventuallyGoto { nSteps }
     92    private method EventuallyResizeLegend { }
    9493    private method FlowCmd { dataobj comp nbytes extents }
    95     private method GetDatasetsWithComponent { cname } 
     94    private method GetDatasetsWithComponent { cname }
    9695    private method GetFlowInfo { widget }
    9796    private method GetMovie { widget width height }
     
    103102    private method ParseLevelsOption { tf levels }
    104103    private method ParseMarkersOption { tf markers }
    105     private method QuaternionToView { q } { 
     104    private method QuaternionToView { q } {
    106105        foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break
    107106    }
     
    117116    private method Slice {option args}
    118117    private method SlicerTip {axis}
    119     private method ViewToQuaternion {} { 
     118    private method ViewToQuaternion {} {
    120119        return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)]
    121120    }
    122121    private method WaitIcon { option widget }
    123122    private method Zoom {option}
    124     private method arrows { tag name } 
    125     private method box { tag name } 
    126     private method millisecs2str { value } 
    127     private method particles { tag name } 
    128     private method str2millisecs { value } 
    129     private method streams { tag name } 
     123    private method arrows { tag name }
     124    private method box { tag name }
     125    private method millisecs2str { value }
     126    private method particles { tag name }
     127    private method str2millisecs { value }
     128    private method streams { tag name }
    130129
    131130    private variable _arcball ""
     
    133132    private variable _allDataObjs
    134133    private variable _obj2ovride   ;# maps dataobj => style override
    135     private variable _serverObjs   ;# maps dataobj-component to volume ID 
     134    private variable _serverObjs   ;# maps dataobj-component to volume ID
    136135                                    # in the server
    137     private variable _recvObjs  ;# list of data objs to send to server
     136    private variable _recvObjs     ;# list of data objs to send to server
    138137    private variable _obj2style    ;# maps dataobj-component to transfunc
    139     private variable _style2objs   ;# maps tf back to list of 
     138    private variable _style2objs   ;# maps tf back to list of
    140139                                    # dataobj-components using the tf.
    141     private variable _obj2flow;         # Maps dataobj-component to a flow.
    142 
    143     private variable _reset 1;          # Connection to server has been reset
     140    private variable _obj2flow;     # Maps dataobj-component to a flow.
     141
     142    private variable _reset 1      ;# Connection to server has been reset
    144143    private variable _click        ;# info used for rotate operations
    145144    private variable _limits       ;# autoscale min/max for all axes
    146145    private variable _view         ;# view params for 3D view
    147     private variable _isomarkers    ;# array of isosurface level values 0..1
     146    private variable _isomarkers   ;# array of isosurface level values 0..1
    148147    private common   _settings
    149148    private variable _activeTf ""  ;# The currently active transfer function.
    150149    private variable _first ""     ;# This is the topmost volume.
    151     private variable _volcomponents   ; # Array of components found
    152     private variable _componentsList   ; # Array of components found
     150    private variable _volcomponents   ;# Array of components found
     151    private variable _componentsList  ;# Array of components found
    153152    private variable _nextToken 0
    154153    private variable _icon 0
    155154    private variable _flow
    156     # This
    157     # indicates which isomarkers and transfer
    158     # function to use when changing markers,
    159     # opacity, or thickness.
    160155    private common _downloadPopup          ;# download options from popup
    161156
     
    198193    $_dispatcher register !play
    199194    $_dispatcher dispatch $this !play "[itcl::code $this flow next]; list"
    200    
     195
    201196    # Draw legend event
    202197    $_dispatcher register !goto
     
    239234        $this-qy                $_view(-qy)
    240235        $this-qz                $_view(-qz)
    241         $this-zoom              $_view(-zoom)   
     236        $this-zoom              $_view(-zoom)
    242237        $this-xpan              $_view(-xpan)
    243238        $this-ypan              $_view(-ypan)
     
    346341        [itcl::code $this EventuallyResizeLegend]
    347342
    348     # Hack around the Tk panewindow.  The problem is that the requested 
     343    # Hack around the Tk panewindow.  The problem is that the requested
    349344    # size of the 3d view isn't set until an image is retrieved from
    350345    # the server.  So the panewindow uses the tiny size.
     
    354349        0,0 $itk_component(3dview) -fill both -reqwidth $w \
    355350        1,0 $itk_component(legend) -fill x
    356     blt::table configure $itk_component(plotarea) r1 -resize none   
     351    blt::table configure $itk_component(plotarea) r1 -resize none
    357352    # Create flow controls...
    358353
    359354    itk_component add flowcontrols {
    360         frame $itk_interior.flowcontrols 
     355        frame $itk_interior.flowcontrols
    361356    } {
    362357        usual
     
    405400            -offimage [Rappture::icon flow-play] \
    406401            -variable [itcl::scope _settings($this-play)] \
    407             -command [itcl::code $this flow toggle] 
     402            -command [itcl::code $this flow toggle]
    408403    }
    409404    set fg [option get $itk_component(hull) font Font]
     
    457452    } {
    458453        usual
    459         ignore -highlightthickness 
     454        ignore -highlightthickness
    460455        rename -background -controlbackground controlBackground Background
    461456    }
     
    466461    } {
    467462        usual
    468         ignore -highlightthickness 
     463        ignore -highlightthickness
    469464        rename -background -controlbackground controlBackground Background
    470465    }
     
    476471    } {
    477472        usual
    478         ignore -highlightthickness 
     473        ignore -highlightthickness
    479474        rename -background -controlbackground controlBackground Background
    480475    }
     
    493488        0,4 $itk_component(dial) -fill x -padx {2 0 } \
    494489        0,5 $itk_component(duration) -padx { 0 0} \
    495         0,7 $itk_component(speed) -padx {2 3} 
    496 
    497 #        0,6 $itk_component(speedlabel) -padx {2 0} 
     490        0,7 $itk_component(speed) -padx {2 3}
     491
     492#        0,6 $itk_component(speedlabel) -padx {2 0}
    498493    blt::table configure $itk_component(flowcontrols) c* -resize none
    499494    blt::table configure $itk_component(flowcontrols) c4 -resize both
     
    695690    # If anything changed, then rebuild the plot
    696691    if {$changed} {
    697         # Repair the reverse lookup 
     692        # Repair the reverse lookup
    698693        foreach tf [array names _style2objs] {
    699694            set list {}
     
    728723        -opacity 0.5
    729724    }
    730     array unset _limits 
    731     array unset _volcomponents 
     725    array unset _limits
     726    array unset _volcomponents
    732727    foreach dataobj $args {
    733728        if { ![$dataobj isvalid] } {
     
    873868        return 0
    874869    }
    875     set _reset 1 
     870    set _reset 1
    876871    set result [VisViewer::Connect $_hosts]
    877872    if { $result } {
     
    883878            set info {}
    884879            set user "???"
    885             if { [info exists env(USER)] } {
     880            if { [info exists env(USER)] } {
    886881                set user $env(USER)
    887             }
     882            }
    888883            set session "???"
    889             if { [info exists env(SESSION)] } {
     884            if { [info exists env(SESSION)] } {
    890885                set session $env(SESSION)
    891             }
     886            }
    892887            lappend info "version" "$Rappture::version"
    893888            lappend info "build" "$Rappture::build"
     
    990985            $_image(plot) configure -data $bytes
    991986            #puts stderr "image received [image width $_image(plot)] by [image height $_image(plot)]"
    992         } 
     987        }
    993988        "print" {
    994989            set tag $this-$info(-token)
    995990            set _hardcopy($tag) $bytes
    996         } 
     991        }
    997992        "movie" {
    998993            set tag $this-$info(-token)
     
    10101005#       The procedure is the response from the render server to each "legend"
    10111006#       command.  The server sends back a "legend" command invoked our
    1012 #       the slave interpreter.  The purpose is to collect data of the image 
     1007#       the slave interpreter.  The purpose is to collect data of the image
    10131008#       representing the legend in the canvas.  In addition, the isomarkers
    10141009#       of the active transfer function are displayed.
    10151010#
    10161011#       I don't know is this is the right place to display the isomarkers.
    1017 #       I don't know all the different paths used to draw the plot. There's 
     1012#       I don't know all the different paths used to draw the plot. There's
    10181013#       "Rebuild", "add", etc.
    10191014#
     
    11001095# Called automatically whenever something changes that affects the data
    11011096# in the widget.  Clears any existing data and rebuilds the widget to
    1102 # display new data. 
     1097# display new data.
    11031098#
    11041099itcl::body Rappture::FlowvisViewer::Rebuild {} {
     
    11131108    # Turn on buffering of commands to the server.  We don't want to
    11141109    # be preempted by a server disconnect/reconnect (which automatically
    1115     # generates a new call to Rebuild).   
     1110    # generates a new call to Rebuild).
    11161111    StartBufferingCommands
    11171112
     
    14611456                record {
    14621457                    if { [$itk_component(rewind) cget -relief] != "sunken" } {
    1463                         $itk_component(rewind) configure -relief sunken 
    1464                         $itk_component(stop) configure -relief raised 
    1465                         $itk_component(play) configure -relief raised 
     1458                        $itk_component(rewind) configure -relief sunken
     1459                        $itk_component(stop) configure -relief raised
     1460                        $itk_component(play) configure -relief raised
    14661461                        set inner $itk_component(settingsFrame)
    14671462                        set frames [$inner.framecnt value]
     
    14731468                stop {
    14741469                    if { [$itk_component(stop) cget -relief] != "sunken" } {
    1475                         $itk_component(rewind) configure -relief raised 
    1476                         $itk_component(stop) configure -relief sunken 
    1477                         $itk_component(play) configure -relief raised 
     1470                        $itk_component(rewind) configure -relief raised
     1471                        $itk_component(stop) configure -relief sunken
     1472                        $itk_component(play) configure -relief raised
    14781473                        _pause
    14791474                        set cmds "flow reset"
     
    14841479                    if { [$itk_component(play) cget -relief] != "sunken" } {
    14851480                        $itk_component(rewind) configure -relief raised
    1486                         $itk_component(stop) configure -relief raised 
     1481                        $itk_component(stop) configure -relief raised
    14871482                        $itk_component(play) configure \
    14881483                            -image [Rappture::icon flow-pause] \
    1489                             -relief sunken 
     1484                            -relief sunken
    14901485                        bind $itk_component(play) <ButtonPress> \
    14911486                            [itcl::code $this _pause]
     
    15271522    $itk_component(play) configure \
    15281523        -image [Rappture::icon flow-start] \
    1529         -relief raised 
     1524        -relief raised
    15301525    bind $itk_component(play) <ButtonPress> \
    15311526        [itcl::code $this Flow movie play toggle]
     
    15551550    switch -- $what {
    15561551        colormap {
    1557             set color [$itk_component(colormap) value] 
    1558             set _settings(colormap) $color 
    1559             #ResetColormap $color 
     1552            set color [$itk_component(colormap) value]
     1553            set _settings(colormap) $color
     1554            #ResetColormap $color
    15601555        }
    15611556        light {
     
    16221617                blt::table $itk_component(plotarea) \
    16231618                    0,0 $itk_component(3dview) -fill both \
    1624                     1,0 $itk_component(legend) -fill x 
     1619                    1,0 $itk_component(legend) -fill x
    16251620                blt::table configure $itk_component(plotarea) r1 -resize none
    16261621            } else {
     
    16391634            set bool $_settings($this-$what)
    16401635            if { [isconnected] } {
    1641                 set vols [CurrentVolumeIds -cutplanes] 
     1636                set vols [CurrentVolumeIds -cutplanes]
    16421637                SendCmd "cutplane state $bool $axis $vols"
    16431638            }
     
    17431738    # reference.
    17441739    #
    1745     # FIXME: The current way we generate transfer-function names completely 
    1746     #        ignores the -markers option.  The problem is that we are forced 
    1747     #        to compute the name from an increasing complex set of values: 
     1740    # FIXME: The current way we generate transfer-function names completely
     1741    #        ignores the -markers option.  The problem is that we are forced
     1742    #        to compute the name from an increasing complex set of values:
    17481743    #        color, levels, marker, opacity.  I think the cow's out of the
    17491744    #        barn on this one.
     
    18911886            $itk_component(legend) itemconfigure labels -fill $itk_option(-plotforeground)
    18921887            $m relval $x
    1893             lappend _isomarkers($tf) $m 
     1888            lappend _isomarkers($tf) $m
    18941889        }
    18951890    } else {
     
    18981893            $itk_component(legend) itemconfigure labels -fill $itk_option(-plotforeground)
    18991894            $m relval $x
    1900             lappend _isomarkers($tf) $m 
     1895            lappend _isomarkers($tf) $m
    19011896        }
    19021897    }
     
    19051900#
    19061901# The -markers option takes a list of zero or more values (the values
    1907 # may be separated either by spaces or commas) that have the following 
     1902# may be separated either by spaces or commas) that have the following
    19081903# format:
    19091904#
     
    19211916        set n [scan $marker "%g%s" value suffix]
    19221917        if { $n == 2 && $suffix == "%" } {
    1923             # ${n}% : Set relative value. 
     1918            # ${n}% : Set relative value.
    19241919            set value [expr {$value * 0.01}]
    19251920            set m [Rappture::IsoMarker \#auto $c $this $tf]
     
    19381933
    19391934# ----------------------------------------------------------------------
    1940 # USAGE: UndateTransferFuncs 
     1935# USAGE: UndateTransferFuncs
    19411936# ----------------------------------------------------------------------
    19421937itcl::body Rappture::FlowvisViewer::updateTransferFunctions {} {
     
    19481943        error "active transfer function isn't set"
    19491944    }
    1950     set tf $_activeTf 
     1945    set tf $_activeTf
    19511946    set c $itk_component(legend)
    19521947    set m [Rappture::IsoMarker \#auto $c $this $tf]
     
    21072102        2,0 $inner.outline  -cspan 2 -anchor w \
    21082103        3,0 $inner.volume  -cspan 2 -anchor w \
    2109         4,0 $inner.legend  -cspan 2 -anchor w 
     2104        4,0 $inner.legend  -cspan 2 -anchor w
    21102105
    21112106    bind $inner <Map> [itcl::code $this GetFlowInfo $inner]
     
    21572152    label $inner.thick -text "Thick" -font $fg
    21582153
    2159     label $inner.colormap_l -text "Colormap" -font "Arial 9" 
     2154    label $inner.colormap_l -text "Colormap" -font "Arial 9"
    21602155    itk_component add colormap {
    21612156        Rappture::Combobox $inner.colormap -width 10 -editable no
     
    22922287    $inner configure -borderwidth 4
    22932288
    2294     label $inner.view_l -text "view" -font "Arial 9" 
    2295     set f [frame $inner.view] 
    2296     foreach side { front back left right top bottom } { 
     2289    label $inner.view_l -text "view" -font "Arial 9"
     2290    set f [frame $inner.view]
     2291    foreach side { front back left right top bottom } {
    22972292        button $f.$side  -image [Rappture::icon view$side] \
    2298             -command [itcl::code $this SetOrientation $side] 
    2299         Rappture::Tooltip::for $f.$side "Change the view to $side" 
    2300         pack $f.$side -side left 
     2293            -command [itcl::code $this SetOrientation $side]
     2294        Rappture::Tooltip::for $f.$side "Change the view to $side"
     2295        pack $f.$side -side left
    23012296    }
    23022297
    23032298    blt::table $inner \
    23042299        0,0 $inner.view_l -anchor e -pady 2 \
    2305         0,1 $inner.view -anchor w -pady 2 
     2300        0,1 $inner.view -anchor w -pady 2
    23062301    blt::table configure $inner r0 -resize none
    23072302
    2308     set row 1 
     2303    set row 1
    23092304    set labels { qw qx qy qz xpan ypan zoom }
    23102305    foreach tag $labels {
     
    23602355    blt::table $inner \
    23612356        1,0 $inner.showstreams  -anchor w \
    2362         2,0 $inner.showarrows  -anchor w 
     2357        2,0 $inner.showarrows  -anchor w
    23632358    blt::table configure $inner c0 c1 -resize none
    23642359    blt::table configure $inner c2 -resize expand
     
    23832378            -font "Arial 9"
    23842379        Rappture::Tooltip::for $inner.part$row $info(description)
    2385         blt::table $inner $row,0 $inner.part$row -anchor w 
     2380        blt::table $inner $row,0 $inner.part$row -anchor w
    23862381        if { !$_settings($this-particles-$name) } {
    23872382            $inner.part$row select
    2388         } 
     2383        }
    23892384        incr row
    23902385    }
     
    24102405        if { !$_settings($this-box-$name) } {
    24112406            $inner.box$row select
    2412         } 
     2407        }
    24132408        incr row
    24142409    }
     
    24162411    blt::table configure $inner r$row -resize expand
    24172412    blt::table configure $inner c3 -resize expand
    2418     event generate [winfo parent [winfo parent $w]] <Configure> 
     2413    event generate [winfo parent [winfo parent $w]] <Configure>
    24192414}
    24202415
     
    25102505}
    25112506
    2512 #  camera -- 
     2507#  camera --
    25132508itcl::body Rappture::FlowvisViewer::camera {option args} {
    2514     switch -- $option { 
     2509    switch -- $option {
    25152510        "show" {
    25162511            puts [array get _view]
     
    25972592        append cmd " -corner1 {$info(corner1)} "
    25982593        append cmd " -corner2 {$info(corner2)}\n"
    2599     }   
     2594    }
    26002595    append cmd "$tag data follows $nbytes $extents\n"
    26012596    return $cmd
     
    26652660        "stop" {
    26662661            if { $_flow(state) } {
    2667                 flow off 
     2662                flow off
    26682663                flow reset
    26692664            }
     
    26712666        "pause" {
    26722667            if { $_flow(state) } {
    2673                 flow off 
     2668                flow off
    26742669            }
    26752670        }
     
    26842679                    set _settings($this-step) 1
    26852680                    SendCmd "flow reset"
    2686                 } 
     2681                }
    26872682                flow next
    26882683            }
     
    26912686            if { $_settings($this-play) } {
    26922687                flow play
    2693             } else { 
     2688            } else {
    26942689                flow pause
    26952690            }
     
    27162711            }
    27172712            $_dispatcher event -after $_flow(delay) !play
    2718         } 
     2713        }
    27192714        default {
    27202715            error "bad option \"$option\": should be play, stop, toggle, or reset."
     
    27672762            1,0 $inner.please -anchor w \
    27682763            1,1 $inner.icon -anchor e  \
    2769             2,0 $inner.cancel -cspan 2 
    2770         blt::table configure $inner r0 -pady 4 
    2771         blt::table configure $inner r2 -pady 4 
     2764            2,0 $inner.cancel -cspan 2
     2765        blt::table configure $inner r0 -pady 4
     2766        blt::table configure $inner r2 -pady 4
    27722767        bind $inner.cancel <KeyPress-Return> [list $inner.cancel invoke]
    27732768    } else {
     
    27852780    update idletasks
    27862781    update
    2787     # We wait here for either 
    2788     #  1) the png to be delivered or 
    2789     #  2) timeout or 
     2782    # We wait here for either
     2783    #  1) the png to be delivered or
     2784    #  2) timeout or
    27902785    #  3) user cancels the operation.
    27912786    tkwait variable $var
     
    28262821            1,0 $inner.please -anchor w \
    28272822            1,1 $inner.icon -anchor e  \
    2828             2,0 $inner.cancel -cspan 2 
    2829         blt::table configure $inner r0 -pady 4 
    2830         blt::table configure $inner r2 -pady 4 
     2823            2,0 $inner.cancel -cspan 2
     2824        blt::table configure $inner r0 -pady 4
     2825        blt::table configure $inner r2 -pady 4
    28312826        bind $inner.cancel <KeyPress-Return> [list $inner.cancel invoke]
    28322827    } else {
    28332828        set inner [$popup component inner]
    28342829    }
    2835     update 
     2830    update
    28362831    # Timeout is set to 10 minutes.
    28372832    $_dispatcher event -after 600000 !movietimeout
     
    28392834    grab set $inner
    28402835    focus $inner.cancel
    2841    
     2836
    28422837    flow duration
    28432838    flow speed
     
    28512846    set start [clock seconds]
    28522847    SendCmd "flow video $token -width $w -height $h -numframes $nframes "
    2853    
     2848
    28542849    $popup activate $widget below
    2855     update idletasks 
     2850    update idletasks
    28562851    update
    28572852    # We wait here until
    2858     #  1. the movie is delivered or 
    2859     #  2. we've timed out or 
     2853    #  1. the movie is delivered or
     2854    #  2. we've timed out or
    28602855    #  3. the user has canceled the operation.b
    28612856    tkwait variable $var
     
    28722867
    28732868    # This will both cancel the movie generation (if it hasn't already
    2874     # completed) and reset the flow. 
     2869    # completed) and reset the flow.
    28752870    SendCmd "flow reset"
    28762871    if { $_hardcopy($this-$token) != "" } {
     
    29062901}
    29072902
    2908 itcl::body Rappture::FlowvisViewer::SetOrientation { side } { 
    2909     array set positions { 
    2910         front "1 0 0 0" 
    2911         back  "0 0 1 0" 
    2912         left  "0.707107 0 -0.707107 0" 
    2913         right "0.707107 0 0.707107 0" 
    2914         top   "0.707107 -0.707107 0 0" 
    2915         bottom "0.707107 0.707107 0 0" 
    2916     } 
    2917     foreach name { -qw -qx -qy -qz } value $positions($side) { 
     2903itcl::body Rappture::FlowvisViewer::SetOrientation { side } {
     2904    array set positions {
     2905        front "1 0 0 0"
     2906        back  "0 0 1 0"
     2907        left  "0.707107 0 -0.707107 0"
     2908        right "0.707107 0 0.707107 0"
     2909        top   "0.707107 -0.707107 0 0"
     2910        bottom "0.707107 0.707107 0 0"
     2911    }
     2912    foreach name { -qw -qx -qy -qz } value $positions($side) {
    29182913        set _view($name) $value
    2919     } 
     2914    }
    29202915    set q [ViewToQuaternion]
    29212916    $_arcball quaternion $q
    2922     SendCmd "camera orient $q" 
     2917    SendCmd "camera orient $q"
    29232918    SendCmd "camera reset"
    29242919    set _view(-xpan) 0.0
     
    29312926
    29322927# Reset global settings from dataset's settings.
    2933 itcl::body Rappture::FlowvisViewer::BuildVolumeComponents {} { 
     2928itcl::body Rappture::FlowvisViewer::BuildVolumeComponents {} {
    29342929    $itk_component(volcomponents) choices delete 0 end
    29352930    foreach name $_componentsList {
     
    29412936
    29422937# Reset global settings from dataset's settings.
    2943 itcl::body Rappture::FlowvisViewer::GetDatasetsWithComponent { cname } { 
     2938itcl::body Rappture::FlowvisViewer::GetDatasetsWithComponent { cname } {
    29442939    if { ![info exists _volcomponents($cname)] } {
    29452940        return ""
Note: See TracChangeset for help on using the changeset viewer.