Changeset 5115


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

whitespace

Location:
branches/1.3/gui/scripts
Files:
3 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
  • branches/1.3/gui/scripts/isomarker.tcl

    r4848 r5115  
    1 # -*- mode: tcl; indent-tabs-mode: nil -*- 
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    22
    33# ----------------------------------------------------------------------
     
    2424    private variable _canvas    ""
    2525    private variable _nvobj     "";     # Parent nanovis object.
    26     private variable _tf        "";     # Transfer function that this marker is 
     26    private variable _tf        "";     # Transfer function that this marker is
    2727                                        # associated with.
    2828    private variable _activeMotion   0
     
    3131    private common   _activeIcon [Rappture::icon nvlegendmark2]
    3232
    33     constructor {c obj tf args} { 
     33    constructor {c obj tf args} {
    3434        set _canvas $c
    3535        set _nvobj $obj
     
    5252            [itcl::code $this HandleEvent "end" %x %y]
    5353    }
    54     destructor { 
     54    destructor {
    5555        $_canvas delete $this
    5656    }
     
    7676        }
    7777    }
    78     public method screenpos { } { 
     78    public method screenpos { } {
    7979        set x [relval]
    8080        if { $x < 0.0 } {
    8181            set x 0.0
    8282        } elseif { $x > 1.0 } {
    83             set x 1.0 
     83            set x 1.0
    8484        }
    85         set low 10 
     85        set low 10
    8686        set w [winfo width $_canvas]
    8787        set high [expr {$w  - 10}]
     
    102102    public method relval  { {x "-get"} } {
    103103        if { $x == "-get" } {
    104             array set limits [$_nvobj limits $_tf] 
     104            array set limits [$_nvobj limits $_tf]
    105105            if { $limits(vmax) == $limits(vmin) } {
    106106                if { $limits(vmax) == 0.0 } {
     
    113113            return [expr {($_value-$limits(vmin))/
    114114                          ($limits(vmax) - $limits(vmin))}]
    115         } 
    116         array set limits [$_nvobj limits $_tf] 
     115        }
     116        array set limits [$_nvobj limits $_tf]
    117117        if { $limits(vmax) == $limits(vmin) } {
    118118            set limits(vmin) 0.0
     
    121121        if { [catch {expr $limits(vmax) - $limits(vmin)} r] != 0 } {
    122122            return 0.0
    123         }           
     123        }
    124124        absval [expr {($x * $r) + $limits(vmin)}]
    125125    }
     
    136136            }
    137137            start {
    138                 $_canvas raise $_tick 
     138                $_canvas raise $_tick
    139139                set _activePress 1
    140140                activate yes
  • branches/1.3/gui/scripts/nanovisviewer.tcl

    r5110 r5115  
    1 # -*- mode: tcl; indent-tabs-mode: nil -*- 
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    22
    33# ----------------------------------------------------------------------
     
    2020#
    2121# FIXME:
    22 #       Need to Add DX readers this client to examine the data before 
     22#       Need to Add DX readers this client to examine the data before
    2323#       it's sent to the server.  This will eliminate 90% of the insanity in
    24 #       computing the limits of all the volumes.  I can rip out all the 
     24#       computing the limits of all the volumes.  I can rip out all the
    2525#       "receive data" "send transfer function" event crap.
    2626#
     
    3030#       when a new volume is drawn (using the default transfer function) and
    3131#       then when the correct transfer function has been sent and linked to
    32 #       the volume. 
     32#       the volume.
    3333#
    3434option add *NanovisViewer.width 4i widgetDefault
     
    7777    public method limits { tf }
    7878    public method overmarker { m x }
    79     public method parameters {title args} { 
    80         # do nothing 
     79    public method parameters {title args} {
     80        # do nothing
    8181    }
    8282    public method rmdupmarker { m x }
     
    110110    private method ResetColormap { color }
    111111    private method ComputeTransferFunc { tf }
    112     private method EventuallyResize { w h } 
    113     private method EventuallyResizeLegend { } 
     112    private method EventuallyResize { w h }
     113    private method EventuallyResizeLegend { }
    114114    private method NameTransferFunc { dataobj comp }
    115115    private method PanCamera {}
     
    125125    private variable _allDataObjs
    126126    private variable _obj2ovride   ;# maps dataobj => style override
    127     private variable _serverDatasets   ;# contains all the dataobj-component 
     127    private variable _serverDatasets   ;# contains all the dataobj-component
    128128                                   ;# to volumes in the server
    129     private variable _serverTfs    ;# contains all the transfer functions 
     129    private variable _serverTfs    ;# contains all the transfer functions
    130130                                   ;# in the server.
    131131    private variable _recvdDatasets    ;# list of data objs to send to server
    132132    private variable _dataset2style    ;# maps dataobj-component to transfunc
    133     private variable _style2datasets   ;# maps tf back to list of 
    134                                     # dataobj-components using the tf.
    135 
    136     private variable _reset 1;          # Connection to server has been reset
     133    private variable _style2datasets   ;# maps tf back to list of
     134                                        # dataobj-components using the tf.
     135
     136    private variable _reset 1      ;# Connection to server has been reset
    137137    private variable _click        ;# info used for rotate operations
    138138    private variable _limits       ;# autoscale min/max for all axes
    139139    private variable _view         ;# view params for 3D view
    140     private variable _isomarkers    ;# array of isosurface level values 0..1
     140    private variable _isomarkers   ;# array of isosurface level values 0..1
    141141    private variable  _settings
    142142    # Array of transfer functions in server.  If 0 the transfer has been
     
    146146    private variable _first ""     ;# This is the topmost volume.
    147147
    148     # This
    149     # indicates which isomarkers and transfer
    150     # function to use when changing markers,
    151     # opacity, or thickness.
    152148    common _downloadPopup          ;# download options from popup
    153149    private common _hardcopy
     
    216212        $this-qy                $_view(qy)
    217213        $this-qz                $_view(qz)
    218         $this-zoom              $_view(zoom)   
     214        $this-zoom              $_view(zoom)
    219215        $this-xpan              $_view(xpan)
    220216        $this-ypan              $_view(ypan)
     
    292288        BuildCameraTab
    293289    } errs] != 0 } {
    294         global errorInfo
     290        global errorInfo
    295291        puts stderr "errs=$errs errorInfo=$errorInfo"
    296292    }
     
    309305        [itcl::code $this EventuallyResizeLegend]
    310306
    311     # Hack around the Tk panewindow.  The problem is that the requested 
     307    # Hack around the Tk panewindow.  The problem is that the requested
    312308    # size of the 3d view isn't set until an image is retrieved from
    313309    # the server.  So the panewindow uses the tiny size.
     
    316312    blt::table $itk_component(plotarea) \
    317313        0,0 $itk_component(3dview) -fill both -reqwidth $w \
    318         1,0 $itk_component(legend) -fill x 
     314        1,0 $itk_component(legend) -fill x
    319315    blt::table configure $itk_component(plotarea) r1 -resize none
    320316
     
    573569            # to the BLT picture image it won't be necessary to decode the
    574570            # image data.
    575             if { [image width $_image(plot)] > 0 && 
     571            if { [image width $_image(plot)] > 0 &&
    576572                 [image height $_image(plot)] > 0 } {
    577573                set bytes [$_image(plot) data -format "jpeg -quality 100"]
     
    599595        return 0
    600596    }
    601     set _reset 1 
     597    set _reset 1
    602598    set result [VisViewer::Connect $_hosts]
    603599    if { $result } {
     
    680676    foreach tag [CurrentDatasets] {
    681677        if { ![info exists _serverDatasets($tag)] || !$_serverDatasets($tag) } {
    682             # The volume hasn't reached the server yet.  How did we get 
     678            # The volume hasn't reached the server yet.  How did we get
    683679            # here?
    684680            puts stderr "Don't have $tag in _serverDatasets"
     
    694690        ComputeTransferFunc $tf
    695691        # FIXME: Need to the send information as to what transfer functions
    696         #        to update so that we only update the transfer function 
    697         #        as necessary.  Right now, all transfer functions are 
     692        #        to update so that we only update the transfer function
     693        #        as necessary.  Right now, all transfer functions are
    698694        #        updated. This makes moving the isomarker slider chunky.
    699695        if { ![info exists _activeTfs($tf)] || !$_activeTfs($tf) } {
     
    722718    ReceiveEcho <<line "<read $info(-bytes) bytes"
    723719    if { $info(-type) == "image" } {
    724         ReceiveEcho "for [image width $_image(plot)]x[image height $_image(plot)] image>"       
     720        ReceiveEcho "for [image width $_image(plot)]x[image height $_image(plot)] image>"
    725721        $_image(plot) configure -data $bytes
    726722    } elseif { $info(-type) == "print" } {
     
    735731#       The procedure is the response from the render server to each "legend"
    736732#       command.  The server sends back a "legend" command invoked our
    737 #       the slave interpreter.  The purpose is to collect data of the image 
     733#       the slave interpreter.  The purpose is to collect data of the image
    738734#       representing the legend in the canvas.  In addition, the isomarkers
    739735#       of the active transfer function are displayed.
    740736#
    741737#       I don't know is this is the right place to display the isomarkers.
    742 #       I don't know all the different paths used to draw the plot. There's 
     738#       I don't know all the different paths used to draw the plot. There's
    743739#       "Rebuild", "add", etc.
    744740#
     
    873869    # Turn on buffering of commands to the server.  We don't want to
    874870    # be preempted by a server disconnect/reconnect (which automatically
    875     # generates a new call to Rebuild).   
     871    # generates a new call to Rebuild).
    876872    StartBufferingCommands
    877873
     
    932928    set _first [lindex [get] 0]
    933929    if { $_reset } {
    934         #
    935         # Reset the camera and other view parameters
    936         #
     930        #
     931        # Reset the camera and other view parameters
     932        #
    937933        set _settings($this-qw)    $_view(qw)
    938934        set _settings($this-qx)    $_view(qx)
    939935        set _settings($this-qy)    $_view(qy)
    940936        set _settings($this-qz)    $_view(qz)
    941         set _settings($this-xpan)  $_view(xpan)
    942         set _settings($this-ypan)  $_view(ypan)
    943         set _settings($this-zoom)  $_view(zoom)
     937        set _settings($this-xpan)  $_view(xpan)
     938        set _settings($this-ypan)  $_view(ypan)
     939        set _settings($this-zoom)  $_view(zoom)
    944940
    945941        set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     
    947943        SendCmd "camera orient $q"
    948944        SendCmd "camera reset"
    949         PanCamera
    950         SendCmd "camera zoom $_view(zoom)"
    951         InitSettings light2side light transp isosurface grid axes 
    952        
     945        PanCamera
     946        SendCmd "camera zoom $_view(zoom)"
     947        InitSettings light2side light transp isosurface grid axes
     948
    953949        foreach axis {x y z} {
    954950            # Turn off cutplanes for all volumes
    955951            SendCmd "cutplane state 0 $axis"
    956952        }
    957         if {"" != $_first} {
    958             set axis [$_first hints updir]
    959             if { "" != $axis } {
    960                 SendCmd "up $axis"
    961             }
    962             set location [$_first hints camera]
    963             if { $location != "" } {
    964                 array set _view $location
    965             }
    966         }
     953        if {"" != $_first} {
     954            set axis [$_first hints updir]
     955            if { "" != $axis } {
     956                SendCmd "up $axis"
     957            }
     958            set location [$_first hints camera]
     959            if { $location != "" } {
     960                array set _view $location
     961            }
     962        }
    967963    }
    968964    # Outline seems to need to be reset every update.
     
    971967    SendCmd "volume state 0"
    972968    if {"" != $_first} {
    973         set datasets [array names _serverDatasets $_first-*] 
     969        set datasets [array names _serverDatasets $_first-*]
    974970        if { $datasets != "" } {
    975971            SendCmd "volume state 1 $datasets"
     
    12641260                blt::table $itk_component(plotarea) \
    12651261                    0,0 $itk_component(3dview) -fill both \
    1266                     1,0 $itk_component(legend) -fill x 
     1262                    1,0 $itk_component(legend) -fill x
    12671263                blt::table configure $itk_component(plotarea) r1 -resize none
    12681264            } else {
     
    12711267        }
    12721268        "volume" {
    1273             set datasets [CurrentDatasets -cutplanes] 
     1269            set datasets [CurrentDatasets -cutplanes]
    12741270            SendCmd "volume data state $_settings($this-volume) $datasets"
    12751271        }
     
    12771273            set axis [string range $what 0 0]
    12781274            set bool $_settings($this-$what)
    1279             set datasets [CurrentDatasets -cutplanes] 
     1275            set datasets [CurrentDatasets -cutplanes]
    12801276            set tag [lindex $datasets 0]
    12811277            SendCmd "cutplane state $bool $axis $tag"
     
    13141310        # Can't do this as this will remove the items associated with the
    13151311        # isomarkers.
    1316        
     1312
    13171313        #$itk_component(legend) delete all
    13181314    }
     
    13761372    # reference.
    13771373    #
    1378     # FIXME: The current way we generate transfer-function names completely 
    1379     #        ignores the -markers option.  The problem is that we are forced 
    1380     #        to compute the name from an increasing complex set of values: 
     1374    # FIXME: The current way we generate transfer-function names completely
     1375    #        ignores the -markers option.  The problem is that we are forced
     1376    #        to compute the name from an increasing complex set of values:
    13811377    #        color, levels, marker, opacity.  I think the cow's out of the
    13821378    #        barn on this one.
     
    15061502            set m [Rappture::IsoMarker \#auto $c $this $tf]
    15071503            $m relval $x
    1508             lappend _isomarkers($tf) $m 
     1504            lappend _isomarkers($tf) $m
    15091505        }
    15101506    } else {
     
    15121508            set m [Rappture::IsoMarker \#auto $c $this $tf]
    15131509            $m relval $x
    1514             lappend _isomarkers($tf) $m 
     1510            lappend _isomarkers($tf) $m
    15151511        }
    15161512    }
     
    15191515#
    15201516# The -markers option takes a list of zero or more values (the values
    1521 # may be separated either by spaces or commas) that have the following 
     1517# may be separated either by spaces or commas) that have the following
    15221518# format:
    15231519#
     
    15351531        set n [scan $marker "%g%s" value suffix]
    15361532        if { $n == 2 && $suffix == "%" } {
    1537             # ${n}% : Set relative value. 
     1533            # ${n}% : Set relative value.
    15381534            set value [expr {$value * 0.01}]
    15391535            set m [Rappture::IsoMarker \#auto $c $this $tf]
     
    15501546
    15511547# ----------------------------------------------------------------------
    1552 # USAGE: UndateTransferFuncs 
     1548# USAGE: UndateTransferFuncs
    15531549# ----------------------------------------------------------------------
    15541550itcl::body Rappture::NanovisViewer::updatetransferfuncs {} {
     
    16341630    if { $min != "" } {
    16351631        set _limits(min) $min
    1636     } 
     1632    }
    16371633    if { $max != "" } {
    16381634        set _limits(max) $max
     
    17051701        2,0 $inner.outline  -cspan 2 -anchor w \
    17061702        3,0 $inner.volume  -cspan 2 -anchor w \
    1707         4,0 $inner.legend  -cspan 2 -anchor w 
     1703        4,0 $inner.legend  -cspan 2 -anchor w
    17081704
    17091705    if 0 {
     
    17701766    label $inner.thick -text "Thick" -font $fg
    17711767
    1772     label $inner.colormap_l -text "Colormap" -font "Arial 9" 
     1768    label $inner.colormap_l -text "Colormap" -font "Arial 9"
    17731769    itk_component add colormap {
    17741770        Rappture::Combobox $inner.colormap -width 10 -editable no
     
    17921788        "grey-to-blue"       "grey-to-blue"     \
    17931789        "orange-to-blue"     "orange-to-blue"   \
    1794         "none"               "none"
     1790        "none"               "none"
    17951791
    17961792    $itk_component(colormap) value "BCGYR"
     
    19091905        0,1 $itk_component(xCutScale) \
    19101906        0,2 $itk_component(yCutScale) \
    1911         0,3 $itk_component(zCutScale) 
     1907        0,3 $itk_component(zCutScale)
    19121908
    19131909    blt::table configure $inner r0 r1 c* -resize none
     
    20242020}
    20252021
    2026 #  camera -- 
     2022#  camera --
    20272023#
    20282024itcl::body Rappture::NanovisViewer::camera {option args} {
    2029     switch -- $option { 
     2025    switch -- $option {
    20302026        "show" {
    20312027            puts [array get _view]
     
    21012097            -font "Arial 9"
    21022098        Rappture::Tooltip::for $inner.vol$row $info(description)
    2103         blt::table $inner $row,0 $inner.vol$row -anchor w 
     2099        blt::table $inner $row,0 $inner.vol$row -anchor w
    21042100        if { !$_settings($this-volume-$name) } {
    21052101            $inner.vol$row select
    2106         } 
     2102        }
    21072103        incr row
    21082104    }
     
    21102106    blt::table configure $inner r$row -resize expand
    21112107    blt::table configure $inner c3 -resize expand
    2112     event generate [winfo parent [winfo parent $w]] <Configure> 
     2108    event generate [winfo parent [winfo parent $w]] <Configure>
    21132109}
    21142110
     
    21182114}
    21192115
    2120 itcl::body Rappture::NanovisViewer::SetOrientation { side } { 
     2116itcl::body Rappture::NanovisViewer::SetOrientation { side } {
    21212117    array set positions {
    21222118        front "1 0 0 0"
     
    21292125    foreach name { qw qx qy qz } value $positions($side) {
    21302126        set _view($name) $value
    2131     } 
     2127    }
    21322128    set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    21332129    $_arcball quaternion $q
    2134     SendCmd "camera orient $q" 
     2130    SendCmd "camera orient $q"
    21352131    SendCmd "camera reset"
    21362132    set _view(xpan) 0
Note: See TracChangeset for help on using the changeset viewer.