Ignore:
Timestamp:
Mar 9, 2015 8:04:58 PM (6 years ago)
Author:
ldelgass
Message:

whitespace

File:
1 edited

Legend:

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

    r5110 r5115  
    1 # -*- mode: tcl; indent-tabs-mode: nil -*- 
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    22# ----------------------------------------------------------------------
    33#  COMPONENT: flowvisviewer - 3D flow rendering
     
    6565    public method limits { tf }
    6666    public method overmarker { m x }
    67     public method parameters {title args} { 
    68         # do nothing 
     67    public method parameters {title args} {
     68        # do nothing
    6969    }
    7070    public method rmdupmarker { m x }
     
    105105    private method BuildVolumeTab {}
    106106    private method ComputeTransferFunc { tf }
    107     private method EventuallyResize { w h } 
    108     private method EventuallyGoto { nSteps } 
    109     private method EventuallyResizeLegend { } 
     107    private method EventuallyResize { w h }
     108    private method EventuallyGoto { nSteps }
     109    private method EventuallyResizeLegend { }
    110110    private method FlowCmd { dataobj comp nbytes extents }
    111111    private method GetMovie { widget width height }
     
    116116    private method ParseMarkersOption { tf markers }
    117117    private method WaitIcon { option widget }
    118     private method str2millisecs { value } 
    119     private method millisecs2str { value } 
     118    private method str2millisecs { value }
     119    private method millisecs2str { value }
    120120    private method GetFlowInfo { widget }
    121     private method particles { tag name } 
    122     private method box { tag name } 
    123     private method streams { tag name } 
    124     private method arrows { tag name } 
     121    private method particles { tag name }
     122    private method box { tag name }
     123    private method streams { tag name }
     124    private method arrows { tag name }
    125125    private method SetOrientation { side }
    126126
     
    129129    private variable _allDataObjs
    130130    private variable _obj2ovride   ;# maps dataobj => style override
    131     private variable _serverObjs   ;# maps dataobj-component to volume ID 
     131    private variable _serverObjs   ;# maps dataobj-component to volume ID
    132132                                    # in the server
    133133    private variable _sendobjs ""  ;# list of data objs to send to server
    134     private variable _recvObjs  ;# list of data objs to send to server
     134    private variable _recvObjs     ;# list of data objs to send to server
    135135    private variable _obj2style    ;# maps dataobj-component to transfunc
    136     private variable _style2objs   ;# maps tf back to list of 
     136    private variable _style2objs   ;# maps tf back to list of
    137137                                    # dataobj-components using the tf.
    138     private variable _obj2flow;         # Maps dataobj-component to a flow.
    139 
    140     private variable _reset 1;          # Connection to server has been reset
     138    private variable _obj2flow;     # Maps dataobj-component to a flow.
     139
     140    private variable _reset 1      ;# Connection to server has been reset
    141141    private variable _click        ;# info used for rotate operations
    142142    private variable _limits       ;# autoscale min/max for all axes
    143143    private variable _view         ;# view params for 3D view
    144     private variable _isomarkers    ;# array of isosurface level values 0..1
     144    private variable _isomarkers   ;# array of isosurface level values 0..1
    145145    private common   _settings
    146146    private variable _activeTf ""  ;# The currently active transfer function.
     
    149149    private variable _icon 0
    150150    private variable _flow
    151     # This
    152     # indicates which isomarkers and transfer
    153     # function to use when changing markers,
    154     # opacity, or thickness.
    155151    private common _downloadPopup          ;# download options from popup
    156152
     
    198194    $_dispatcher register !play
    199195    $_dispatcher dispatch $this !play "[itcl::code $this flow next]; list"
    200    
     196
    201197    # Draw legend event
    202198    $_dispatcher register !goto
     
    241237        $this-qy                $_view(qy)
    242238        $this-qz                $_view(qz)
    243         $this-zoom              $_view(zoom)   
     239        $this-zoom              $_view(zoom)
    244240        $this-xpan              $_view(xpan)
    245241        $this-ypan              $_view(ypan)
     
    345341        [itcl::code $this EventuallyResizeLegend]
    346342
    347     # Hack around the Tk panewindow.  The problem is that the requested 
     343    # Hack around the Tk panewindow.  The problem is that the requested
    348344    # size of the 3d view isn't set until an image is retrieved from
    349345    # the server.  So the panewindow uses the tiny size.
     
    353349        0,0 $itk_component(3dview) -fill both -reqwidth $w \
    354350        1,0 $itk_component(legend) -fill x
    355     blt::table configure $itk_component(plotarea) r1 -resize none   
     351    blt::table configure $itk_component(plotarea) r1 -resize none
    356352    # Create flow controls...
    357353
    358354    itk_component add flowcontrols {
    359         frame $itk_interior.flowcontrols 
     355        frame $itk_interior.flowcontrols
    360356    } {
    361357        usual
     
    404400            -offimage [Rappture::icon flow-play] \
    405401            -variable [itcl::scope _settings($this-play)] \
    406             -command [itcl::code $this flow toggle] 
     402            -command [itcl::code $this flow toggle]
    407403    }
    408404    set fg [option get $itk_component(hull) font Font]
     
    456452    } {
    457453        usual
    458         ignore -highlightthickness 
     454        ignore -highlightthickness
    459455        rename -background -controlbackground controlBackground Background
    460456    }
     
    465461    } {
    466462        usual
    467         ignore -highlightthickness 
     463        ignore -highlightthickness
    468464        rename -background -controlbackground controlBackground Background
    469465    }
     
    475471    } {
    476472        usual
    477         ignore -highlightthickness 
     473        ignore -highlightthickness
    478474        rename -background -controlbackground controlBackground Background
    479475    }
     
    492488        0,4 $itk_component(dial) -fill x -padx {2 0 } \
    493489        0,5 $itk_component(duration) -padx { 0 0} \
    494         0,7 $itk_component(speed) -padx {2 3} 
    495 
    496 #        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}
    497493    blt::table configure $itk_component(flowcontrols) c* -resize none
    498494    blt::table configure $itk_component(flowcontrols) c4 -resize both
     
    696692    # If anything changed, then rebuild the plot
    697693    if {$changed} {
    698         # Repair the reverse lookup 
     694        # Repair the reverse lookup
    699695        foreach tf [array names _style2objs] {
    700696            set list {}
     
    853849        return 0
    854850    }
    855     set _reset 1 
     851    set _reset 1
    856852    set result [VisViewer::Connect $_hosts]
    857853    if { $result } {
     
    863859            set info {}
    864860            set user "???"
    865             if { [info exists env(USER)] } {
     861            if { [info exists env(USER)] } {
    866862                set user $env(USER)
    867             }
     863            }
    868864            set session "???"
    869             if { [info exists env(SESSION)] } {
     865            if { [info exists env(SESSION)] } {
    870866                set session $env(SESSION)
    871             }
     867            }
    872868            lappend info "version" "$Rappture::version"
    873869            lappend info "build" "$Rappture::build"
     
    961957    # Turn on buffering of commands to the server.  We don't want to
    962958    # be preempted by a server disconnect/reconnect (which automatically
    963     # generates a new call to Rebuild).   
     959    # generates a new call to Rebuild).
    964960    StartBufferingCommands
    965961
     
    10571053            $_image(plot) configure -data $bytes
    10581054            #puts stderr "image received [image width $_image(plot)] by [image height $_image(plot)]"
    1059         } 
     1055        }
    10601056        "print" {
    10611057            set tag $this-$info(-token)
    10621058            set _hardcopy($tag) $bytes
    1063         } 
     1059        }
    10641060        "movie" {
    10651061            set tag $this-$info(-token)
     
    10771073#       The procedure is the response from the render server to each "legend"
    10781074#       command.  The server sends back a "legend" command invoked our
    1079 #       the slave interpreter.  The purpose is to collect data of the image 
     1075#       the slave interpreter.  The purpose is to collect data of the image
    10801076#       representing the legend in the canvas.  In addition, the isomarkers
    10811077#       of the active transfer function are displayed.
    10821078#
    10831079#       I don't know is this is the right place to display the isomarkers.
    1084 #       I don't know all the different paths used to draw the plot. There's 
     1080#       I don't know all the different paths used to draw the plot. There's
    10851081#       "Rebuild", "add", etc.
    10861082#
     
    11741170# Called automatically whenever something changes that affects the data
    11751171# in the widget.  Clears any existing data and rebuilds the widget to
    1176 # display new data. 
     1172# display new data.
    11771173#
    11781174itcl::body Rappture::FlowvisViewer::Rebuild {} {
     
    11871183    # Turn on buffering of commands to the server.  We don't want to
    11881184    # be preempted by a server disconnect/reconnect (which automatically
    1189     # generates a new call to Rebuild).   
     1185    # generates a new call to Rebuild).
    11901186    StartBufferingCommands
    11911187
     
    12471243    # Reset the camera and other view parameters
    12481244    InitSettings light2side light transp isosurface grid axes volume outline
    1249    
     1245
    12501246    # nothing to send -- activate the proper volume
    12511247    if {"" != $_first} {
     
    15311527                record {
    15321528                    if { [$itk_component(rewind) cget -relief] != "sunken" } {
    1533                         $itk_component(rewind) configure -relief sunken 
    1534                         $itk_component(stop) configure -relief raised 
    1535                         $itk_component(play) configure -relief raised 
     1529                        $itk_component(rewind) configure -relief sunken
     1530                        $itk_component(stop) configure -relief raised
     1531                        $itk_component(play) configure -relief raised
    15361532                        set inner $itk_component(settingsFrame)
    15371533                        set frames [$inner.framecnt value]
     
    15431539                stop {
    15441540                    if { [$itk_component(stop) cget -relief] != "sunken" } {
    1545                         $itk_component(rewind) configure -relief raised 
    1546                         $itk_component(stop) configure -relief sunken 
    1547                         $itk_component(play) configure -relief raised 
     1541                        $itk_component(rewind) configure -relief raised
     1542                        $itk_component(stop) configure -relief sunken
     1543                        $itk_component(play) configure -relief raised
    15481544                        _pause
    15491545                        set cmds "flow reset"
     
    15541550                    if { [$itk_component(play) cget -relief] != "sunken" } {
    15551551                        $itk_component(rewind) configure -relief raised
    1556                         $itk_component(stop) configure -relief raised 
     1552                        $itk_component(stop) configure -relief raised
    15571553                        $itk_component(play) configure \
    15581554                            -image [Rappture::icon flow-pause] \
    1559                             -relief sunken 
     1555                            -relief sunken
    15601556                        bind $itk_component(play) <ButtonPress> \
    15611557                            [itcl::code $this _pause]
     
    15971593    $itk_component(play) configure \
    15981594        -image [Rappture::icon flow-start] \
    1599         -relief raised 
     1595        -relief raised
    16001596    bind $itk_component(play) <ButtonPress> \
    16011597        [itcl::code $this Flow movie play toggle]
     
    16251621    switch -- $what {
    16261622        colormap {
    1627             set color [$itk_component(colormap) value] 
    1628             set _settings(colormap) $color 
    1629             #ResetColormap $color 
     1623            set color [$itk_component(colormap) value]
     1624            set _settings(colormap) $color
     1625            #ResetColormap $color
    16301626        }
    16311627        light {
     
    17011697                blt::table $itk_component(plotarea) \
    17021698                    0,0 $itk_component(3dview) -fill both \
    1703                     1,0 $itk_component(legend) -fill x 
     1699                    1,0 $itk_component(legend) -fill x
    17041700                blt::table configure $itk_component(plotarea) r1 -resize none
    17051701            } else {
     
    17181714            set bool $_settings($this-$what)
    17191715            if { [isconnected] } {
    1720                 set vols [CurrentVolumeIds -cutplanes] 
     1716                set vols [CurrentVolumeIds -cutplanes]
    17211717                SendCmd "cutplane state $bool $axis $vols"
    17221718            }
     
    18301826    # reference.
    18311827    #
    1832     # FIXME: The current way we generate transfer-function names completely 
    1833     #        ignores the -markers option.  The problem is that we are forced 
    1834     #        to compute the name from an increasing complex set of values: 
     1828    # FIXME: The current way we generate transfer-function names completely
     1829    #        ignores the -markers option.  The problem is that we are forced
     1830    #        to compute the name from an increasing complex set of values:
    18351831    #        color, levels, marker, opacity.  I think the cow's out of the
    18361832    #        barn on this one.
     
    18571853    }
    18581854    set max 1.0 ;#$_settings($tag-opacity)
    1859    
     1855
    18601856    set isovalues {}
    18611857    foreach m $_isomarkers($tf) {
     
    19671963            set m [Rappture::IsoMarker \#auto $c $this $tf]
    19681964            $m relval $x
    1969             lappend _isomarkers($tf) $m 
     1965            lappend _isomarkers($tf) $m
    19701966        }
    19711967    } else {
     
    19731969            set m [Rappture::IsoMarker \#auto $c $this $tf]
    19741970            $m relval $x
    1975             lappend _isomarkers($tf) $m 
     1971            lappend _isomarkers($tf) $m
    19761972        }
    19771973    }
     
    19801976#
    19811977# The -markers option takes a list of zero or more values (the values
    1982 # may be separated either by spaces or commas) that have the following 
     1978# may be separated either by spaces or commas) that have the following
    19831979# format:
    19841980#
     
    19961992        set n [scan $marker "%g%s" value suffix]
    19971993        if { $n == 2 && $suffix == "%" } {
    1998             # ${n}% : Set relative value. 
     1994            # ${n}% : Set relative value.
    19991995            set value [expr {$value * 0.01}]
    20001996            set m [Rappture::IsoMarker \#auto $c $this $tf]
     
    20112007
    20122008# ----------------------------------------------------------------------
    2013 # USAGE: UndateTransferFuncs 
     2009# USAGE: UndateTransferFuncs
    20142010# ----------------------------------------------------------------------
    20152011itcl::body Rappture::FlowvisViewer::updatetransferfuncs {} {
     
    20212017        error "active transfer function isn't set"
    20222018    }
    2023     set tf $_activeTf 
     2019    set tf $_activeTf
    20242020    set c $itk_component(legend)
    20252021    set m [Rappture::IsoMarker \#auto $c $this $tf]
     
    20982094    if { $min != "" } {
    20992095        set _limits(vmin) $min
    2100     } 
     2096    }
    21012097    if { $max != "" } {
    21022098        set _limits(vmax) $max
     
    21822178        2,0 $inner.outline  -cspan 2 -anchor w \
    21832179        3,0 $inner.volume  -cspan 2 -anchor w \
    2184         4,0 $inner.legend  -cspan 2 -anchor w 
     2180        4,0 $inner.legend  -cspan 2 -anchor w
    21852181
    21862182    bind $inner <Map> [itcl::code $this GetFlowInfo $inner]
     
    22492245    label $inner.thick -text "Thick" -font $fg
    22502246
    2251     label $inner.colormap_l -text "Colormap" -font "Arial 9" 
     2247    label $inner.colormap_l -text "Colormap" -font "Arial 9"
    22522248    itk_component add colormap {
    22532249        Rappture::Combobox $inner.colormap -width 10 -editable no
     
    22712267        "grey-to-blue"       "grey-to-blue"     \
    22722268        "orange-to-blue"     "orange-to-blue"   \
    2273         "none"               "none"
     2269        "none"               "none"
    22742270
    22752271    $itk_component(colormap) value "BCGYR"
     
    24022398    $inner configure -borderwidth 4
    24032399
    2404     label $inner.view_l -text "view" -font "Arial 9" 
    2405     set f [frame $inner.view] 
    2406     foreach side { front back left right top bottom } { 
     2400    label $inner.view_l -text "view" -font "Arial 9"
     2401    set f [frame $inner.view]
     2402    foreach side { front back left right top bottom } {
    24072403        button $f.$side  -image [Rappture::icon view$side] \
    2408             -command [itcl::code $this SetOrientation $side] 
    2409         Rappture::Tooltip::for $f.$side "Change the view to $side" 
    2410         pack $f.$side -side left 
     2404            -command [itcl::code $this SetOrientation $side]
     2405        Rappture::Tooltip::for $f.$side "Change the view to $side"
     2406        pack $f.$side -side left
    24112407    }
    24122408
    24132409    blt::table $inner \
    24142410        0,0 $inner.view_l -anchor e -pady 2 \
    2415         0,1 $inner.view -anchor w -pady 2 
    2416 
    2417     set row 1 
     2411        0,1 $inner.view -anchor w -pady 2
     2412
     2413    set row 1
    24182414    set labels { qw qx qy qz xpan ypan zoom }
    24192415    foreach tag $labels {
     
    24672463    blt::table $inner \
    24682464        1,0 $inner.showstreams  -anchor w \
    2469         2,0 $inner.showarrows  -anchor w 
     2465        2,0 $inner.showarrows  -anchor w
    24702466    blt::table configure $inner c0 c1 -resize none
    24712467    blt::table configure $inner c2 -resize expand
     
    24902486            -font "Arial 9"
    24912487        Rappture::Tooltip::for $inner.part$row $info(description)
    2492         blt::table $inner $row,0 $inner.part$row -anchor w 
     2488        blt::table $inner $row,0 $inner.part$row -anchor w
    24932489        if { !$_settings($this-particles-$name) } {
    24942490            $inner.part$row select
    2495         } 
     2491        }
    24962492        incr row
    24972493    }
     
    25172513        if { !$_settings($this-box-$name) } {
    25182514            $inner.box$row select
    2519         } 
     2515        }
    25202516        incr row
    25212517    }
     
    25232519    blt::table configure $inner r$row -resize expand
    25242520    blt::table configure $inner c3 -resize expand
    2525     event generate [winfo parent [winfo parent $w]] <Configure> 
     2521    event generate [winfo parent [winfo parent $w]] <Configure>
    25262522}
    25272523
     
    26202616}
    26212617
    2622 #  camera -- 
     2618#  camera --
    26232619itcl::body Rappture::FlowvisViewer::camera {option args} {
    2624     switch -- $option { 
     2620    switch -- $option {
    26252621        "show" {
    26262622            puts [array get _view]
     
    27072703        append cmd " -corner1 {$info(corner1)} "
    27082704        append cmd " -corner2 {$info(corner2)}\n"
    2709     }   
     2705    }
    27102706    append cmd "$tag data follows $nbytes $extents\n"
    27112707    return $cmd
     
    27752771        "stop" {
    27762772            if { $_flow(state) } {
    2777                 flow off 
     2773                flow off
    27782774                flow reset
    27792775            }
     
    27812777        "pause" {
    27822778            if { $_flow(state) } {
    2783                 flow off 
     2779                flow off
    27842780            }
    27852781        }
     
    27942790                    set _settings($this-step) 1
    27952791                    SendCmd "flow reset"
    2796                 } 
     2792                }
    27972793                flow next
    27982794            }
     
    28012797            if { $_settings($this-play) } {
    28022798                flow play
    2803             } else { 
     2799            } else {
    28042800                flow pause
    28052801            }
     
    28262822            }
    28272823            $_dispatcher event -after $_flow(delay) !play
    2828         } 
     2824        }
    28292825        default {
    28302826            error "bad option \"$option\": should be play, stop, toggle, or reset."
     
    28772873            1,0 $inner.please -anchor w \
    28782874            1,1 $inner.icon -anchor e  \
    2879             2,0 $inner.cancel -cspan 2 
    2880         blt::table configure $inner r0 -pady 4 
    2881         blt::table configure $inner r2 -pady 4 
     2875            2,0 $inner.cancel -cspan 2
     2876        blt::table configure $inner r0 -pady 4
     2877        blt::table configure $inner r2 -pady 4
    28822878        bind $inner.cancel <KeyPress-Return> [list $inner.cancel invoke]
    28832879    } else {
     
    28952891    update idletasks
    28962892    update
    2897     # We wait here for either 
    2898     #  1) the png to be delivered or 
    2899     #  2) timeout or 
     2893    # We wait here for either
     2894    #  1) the png to be delivered or
     2895    #  2) timeout or
    29002896    #  3) user cancels the operation.
    29012897    tkwait variable $var
     
    29362932            1,0 $inner.please -anchor w \
    29372933            1,1 $inner.icon -anchor e  \
    2938             2,0 $inner.cancel -cspan 2 
    2939         blt::table configure $inner r0 -pady 4 
    2940         blt::table configure $inner r2 -pady 4 
     2934            2,0 $inner.cancel -cspan 2
     2935        blt::table configure $inner r0 -pady 4
     2936        blt::table configure $inner r2 -pady 4
    29412937        bind $inner.cancel <KeyPress-Return> [list $inner.cancel invoke]
    29422938    } else {
    29432939        set inner [$popup component inner]
    29442940    }
    2945     update 
     2941    update
    29462942    # Timeout is set to 10 minutes.
    29472943    $_dispatcher event -after 600000 !movietimeout
     
    29492945    grab set $inner
    29502946    focus $inner.cancel
    2951    
     2947
    29522948    flow duration
    29532949    flow speed
     
    29612957    set start [clock seconds]
    29622958    SendCmd "flow video $token -width $w -height $h -numframes $nframes "
    2963    
     2959
    29642960    $popup activate $widget below
    2965     update idletasks 
     2961    update idletasks
    29662962    update
    29672963    # We wait here until
    2968     #  1. the movie is delivered or 
    2969     #  2. we've timed out or 
     2964    #  1. the movie is delivered or
     2965    #  2. we've timed out or
    29702966    #  3. the user has canceled the operation.b
    29712967    tkwait variable $var
     
    29822978
    29832979    # This will both cancel the movie generation (if it hasn't already
    2984     # completed) and reset the flow. 
     2980    # completed) and reset the flow.
    29852981    SendCmd "flow reset"
    29862982    if { $_hardcopy($this-$token) != "" } {
     
    30163012}
    30173013
    3018 itcl::body Rappture::FlowvisViewer::SetOrientation { side } { 
    3019     array set positions { 
    3020         front "1 0 0 0" 
    3021         back  "0 0 1 0" 
    3022         left  "0.707107 0 -0.707107 0" 
    3023         right "0.707107 0 0.707107 0" 
    3024         top   "0.707107 -0.707107 0 0" 
    3025         bottom "0.707107 0.707107 0 0" 
    3026     } 
    3027     foreach name { qw qx qy qz } value $positions($side) { 
     3014itcl::body Rappture::FlowvisViewer::SetOrientation { side } {
     3015    array set positions {
     3016        front "1 0 0 0"
     3017        back  "0 0 1 0"
     3018        left  "0.707107 0 -0.707107 0"
     3019        right "0.707107 0 0.707107 0"
     3020        top   "0.707107 -0.707107 0 0"
     3021        bottom "0.707107 0.707107 0 0"
     3022    }
     3023    foreach name { qw qx qy qz } value $positions($side) {
    30283024        set _view($name) $value
    3029     } 
     3025    }
    30303026    set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    30313027    $_arcball quaternion $q
    3032     SendCmd "camera orient $q" 
     3028    SendCmd "camera orient $q"
    30333029    SendCmd "camera reset"
    30343030    set _view(xpan) 0.0
Note: See TracChangeset for help on using the changeset viewer.