Changeset 1448 for trunk/gui


Ignore:
Timestamp:
May 18, 2009 11:45:37 AM (15 years ago)
Author:
gah
Message:
 
Location:
trunk/gui/scripts
Files:
6 edited

Legend:

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

    r1442 r1448  
    3434
    3535    private method ConvertUnits { value }
    36     private method GetAxis { path varName }
    37     private method GetPosition { path varName }
    38     private method GetCorner { path varName }
    39     private method GetBoolean { path varName }
    40 
    41     private variable _boxes;            # List of boxes for the flow.
    42     private variable _particles;        # List of particle injection planes.
     36    private method GetAxis { obj path varName }
     37    private method GetPosition { obj path varName }
     38    private method GetCorner { obj path varName }
     39    private method GetBoolean { obj path varName }
     40
     41    private variable _boxes "";         # List of boxes for the flow.
     42    private variable _particles "";     # List of particle injection planes.
    4343    private variable _hints;            # Array of settings for the flow.
    44     private variable _flowobj
    45     private variable _units
     44    private variable _units ""
    4645}
    4746
     
    6261    }
    6362    set _units $units
    64     set _flowobj [$field element -as object $cname.flow]
     63    set f [$field element -as object $cname.flow]
    6564    set _hints(name) [$field element -as id $cname.flow]
    66     foreach child [$_flowobj children] {
    67         set value [$_flowobj get $child]
     65    foreach child [$f children] {
     66        set value [$f get $child]
    6867        switch -glob -- $child {
    69             "outline"  { GetBoolean $child _hints(outline) }
    70             "volume"   { GetBoolean $child _hints(volume) }
    71             "streams"  { GetBoolean $child _hints(streams) }
    72             "axis"     { GetAxis  $child _hints(axis) }
    73             "position" { GetPosition $child _hints(position) }
     68            "label"    { set _hints(label) [$f get $child] }
     69            "outline"  { GetBoolean $f $child _hints(outline) }
     70            "volume"   { GetBoolean $f $child _hints(volume) }
     71            "streams"  { GetBoolean $f $child _hints(streams) }
     72            "axis"     { GetAxis $f  $child _hints(axis) }
     73            "position" { GetPosition $f $child _hints(position) }
    7474            "particles*" {
    7575                array unset data
     
    7979                    "position"  "0.0%"
    8080                    "color"     "blue"
    81                 }
    82                 set data(name) [$_flowobj element -as id $child]
    83                 set data(color) [$_flowobj get $child.color]
    84                 GetAxis $child.axis data(axis)
    85                 GetPosition $child.position data(position)
     81                    "label"     ""
     82                }
     83                set p [$f element -as object $child]
     84                set data(name) [$f element -as id $child]
     85                foreach child [$p children] {
     86                    set value [$p get $child]
     87                    switch -exact -- $child {
     88                        "label" { set data(label) $value }
     89                        "color" { set data(color) $value }
     90                        "hide"  { GetBoolean $p hide data(hide) }
     91                        "axis"  { GetAxis $p axis data(axis) }
     92                        "position" { GetPosition $p position data(position)}
     93                    }
     94                }
     95                if { $data(label) == "" } {
     96                    set data(label) $data(name)
     97                }
     98                itcl::delete object $p
    8699                lappend _particles [array get data]
    87100            }
     
    89102                array unset data
    90103                array set data {
    91                     "axis"      "x"
    92104                    "hide"      "no"
    93105                    "color"     "green"
    94                 }
    95                 set boxobj [$_flowobj element -as object $child]
     106                    "label"     ""
     107                }
     108                set b [$f element -as object $child]
     109                set name [$f element -as id $child]
    96110                set count 0
    97                 set data(name) [$_flowobj element -as id $child]
    98                 set data(color) [$_flowobj get $child.color]
    99                 foreach corner [$boxobj children -type corner] {
    100                     incr count
    101                     GetCorner $child.$corner data(corner$count)
    102                 }
    103                 itcl::delete object $boxobj
     111                set data(name) $name
     112                set data(color) [$f get $child.color]
     113                foreach child [$b children] {
     114                    set value [$b get $child]
     115                    switch -glob -- $child {
     116                        "label" { set data(label) $value }
     117                        "color" { set data(color) $value }
     118                        "hide"  { GetBoolean $b hide data(hide) }
     119                        "corner*" {
     120                            incr count
     121                            GetCorner $b $child data(corner$count)
     122                        }
     123                    }
     124                }
     125                if { $data(label) == "" } {
     126                    set data(label) $data(name)
     127                }
     128                itcl::delete object $b
    104129                lappend _boxes [array get data]
    105130            }
    106131        }
    107132    }
    108     itcl::delete  object $_flowobj
     133    itcl::delete  object $f
    109134}
    110135
     
    113138    set n  [scan $value "%g%s" number suffix]
    114139    if { $n == 2 } {
    115         puts stderr "number=$number suffix=$suffix"
    116140        if { $suffix == "%" } {
    117141            return $value
    118142        } else {
    119             puts stderr "$cmd $number -context $suffix -to $_units -units off"
    120143            return [$cmd $number -context $suffix -to $_units -units off]
    121144        }
     
    124147            return $number
    125148        }
    126         puts stderr "$cmd $number -context $_units -to $_units -units off"
    127149        return [$cmd $number -context $_units -to $_units -units off]
    128150    }
     
    130152}
    131153
    132 itcl::body Rappture::FlowHints::GetPosition { path varName } {
    133     set value [$_flowobj get $path]
     154itcl::body Rappture::FlowHints::GetPosition { obj path varName } {
     155    set value [$obj get $path]
    134156    set pos [ConvertUnits $value]
    135157    if { $pos == "" } {
     
    140162}
    141163
    142 itcl::body Rappture::FlowHints::GetAxis { path varName } {
    143     set value [$_flowobj get $path]
     164itcl::body Rappture::FlowHints::GetAxis { obj path varName } {
     165    set value [$obj get $path]
    144166    set value [string tolower $value]
    145167    switch -- $value {
     
    153175}
    154176
    155 itcl::body Rappture::FlowHints::GetCorner { path varName } {
    156     set value [$_flowobj get $path]
     177itcl::body Rappture::FlowHints::GetCorner { obj path varName } {
     178    set value [$obj get $path]
    157179    set coords ""
    158180    if { [llength $value] != 3 } {
     
    172194}
    173195
    174 itcl::body Rappture::FlowHints::GetBoolean { path varName } {
    175     set value [$_flowobj get $path]
     196itcl::body Rappture::FlowHints::GetBoolean { obj path varName } {
     197    set value [$obj get $path]
    176198    if { [string is boolean $value] } {
    177199        upvar $varName bool
  • trunk/gui/scripts/flowvisviewer.tcl

    r1444 r1448  
    1919package require Img
    2020
    21 option add *FlowvisViewer.width 4i widgetDefault
     21option add *FlowvisViewer.width 5i widgetDefault
    2222option add *FlowvisViewer*cursor crosshair widgetDefault
    2323option add *FlowvisViewer.height 4i widgetDefault
     
    7575    protected method Disconnect {}
    7676    protected method DoResize {}
    77     protected method FixLegend {}
     77    protected method ResizeLegend {}
    7878    protected method FixSettings {what {value ""}}
    7979    protected method Pan {option x y}
     
    128128    private variable _id2obj       ;# maps dataobj => volume ID in server
    129129    private variable _sendobjs ""  ;# list of data objs to send to server
    130     private variable _receiveIds   ;# list of data objs to send to server
     130    private variable _recvObjs  ;# list of data objs to send to server
    131131    private variable _obj2style    ;# maps dataobj-component to transfunc
    132132    private variable _style2objs   ;# maps tf back to list of
     
    152152    private variable _width 0
    153153    private variable _height 0
     154    private variable _resizePending 0
     155    private variable _resizeLegendPending 0
    154156}
    155157
     
    166168    # Draw legend event
    167169    $_dispatcher register !legend
    168     $_dispatcher dispatch $this !legend "[itcl::code $this FixLegend]; list"
     170    $_dispatcher dispatch $this !legend "[itcl::code $this ResizeLegend]; list"
    169171
    170172    # Send dataobjs event
     
    189191    $_dispatcher dispatch $this !play "[itcl::code $this flow next]; list"
    190192   
    191     set _flow(frame) 0
    192193    set _flow(state) 0
    193194
     
    226227        $this-psi               $_view(psi)
    227228        $this-speed             500
     229        $this-step              0
     230        $this-nsteps            100
    228231        $this-theta             $_view(theta)
    229232        $this-volume            1
     
    291294    BuildCameraTab
    292295
     296
     297    bind $itk_component(3dview) <Configure> \
     298        [itcl::code $this EventuallyResize %w %h]
     299
    293300    # Legend
    294 
    295301    set _image(legend) [image create photo]
    296302    itk_component add legend {
     
    315321    # Create flow controls...
    316322
    317     itk_component add flowcontrol {
    318         frame $itk_interior.flowcontrol
     323    itk_component add flowcontrols {
     324        frame $itk_interior.flowcontrols
    319325    } {
    320326        usual
     
    324330    blt::table $itk_interior \
    325331        0,0 $itk_component(main) -fill both  \
    326         1,0 $itk_component(flowcontrol) -fill x
     332        1,0 $itk_component(flowcontrols) -fill x
    327333    blt::table configure $itk_interior r1 -resize none
    328334
    329     # flow record button...
     335    # Rewind
    330336    itk_component add rewind {
    331         button $itk_component(flowcontrol).reset \
     337        button $itk_component(flowcontrols).reset \
    332338            -borderwidth 1 -padx 1 -pady 1 \
    333339            -image [Rappture::icon flow-rewind] \
     
    336342        usual
    337343        ignore -borderwidth
    338         rename -highlightbackground -controlbackground controlBackground Background
     344        rename -highlightbackground -controlbackground controlBackground \
     345            Background
    339346    }
    340347    Rappture::Tooltip::for $itk_component(rewind) \
    341348        "Rewind flow"
    342349
    343     # flow stop button...
     350    # Stop
    344351    itk_component add stop {
    345         button $itk_component(flowcontrol).stop \
     352        button $itk_component(flowcontrols).stop \
    346353            -borderwidth 1 -padx 1 -pady 1 \
    347354            -image [Rappture::icon flow-stop] \
     
    350357        usual
    351358        ignore -borderwidth
    352         rename -highlightbackground -controlbackground controlBackground Background
     359        rename -highlightbackground -controlbackground controlBackground \
     360            Background
    353361    }
    354362    Rappture::Tooltip::for $itk_component(stop) \
    355363        "Stop flow"
    356364
    357     #
    358     # flow play/pause button...
    359     #
     365    # Play
    360366    itk_component add play {
    361         Rappture::PushButton $itk_component(flowcontrol).play \
     367        Rappture::PushButton $itk_component(flowcontrols).play \
    362368            -onimage [Rappture::icon flow-pause] \
    363369            -offimage [Rappture::icon flow-play] \
     
    369375        "Play/Pause flow"
    370376
     377    # Loop
    371378    itk_component add loop {
    372         Rappture::PushButton $itk_component(flowcontrol).loop \
     379        Rappture::PushButton $itk_component(flowcontrols).loop \
    373380            -onimage [Rappture::icon loop] \
    374381            -offimage [Rappture::icon loop] \
     
    378385        "Play continuously"
    379386
    380     # how do we know when to make something an itk component?
    381 
    382     itk_component add numframes {
    383         Rappture::Spinint $itk_component(flowcontrol).numframes \
    384             -min 0 -max 10000
     387    # Frame
     388    itk_component add frame {
     389        ::scale $itk_component(flowcontrols).frame -from 1 -to 100 \
     390            -showvalue 0 -orient horizontal -width 14 \
     391            -state disabled \
     392            -variable [itcl::scope _settings($this-step)]  \
     393            -highlightthickness 0
     394    } {
     395        usual
     396        ignore -highlightthickness
     397        rename -background -controlbackground controlBackground Background
     398    }
     399    $itk_component(frame) set 1
     400
     401    # Number of steps
     402    itk_component add nsteps {
     403        Rappture::Spinint $itk_component(flowcontrols).nsteps \
     404            -min 0 -max 10000 -width 4
    385405    } {
    386406        usual
     
    388408        rename -background -controlbackground controlBackground Background
    389409    }
    390     $itk_component(numframes) value 100
    391 
    392     itk_component add numframeslabel {
    393         label $itk_component(flowcontrol).framel -text "# Steps:" -font $fg \
     410    $itk_component(nsteps) value 100
     411
     412    itk_component add nstepslabel {
     413        label $itk_component(flowcontrols).framel -text "# Steps:" -font $fg \
    394414            -highlightthickness 0
    395415    } {
     
    400420
    401421    itk_component add speedlabel {
    402         label $itk_component(flowcontrol).speedl -text "Speed:" -font $fg \
     422        label $itk_component(flowcontrols).speedl -text "Speed:" -font $fg \
    403423            -highlightthickness 0
    404424    } {
     
    408428    }
    409429
     430    # Speed
    410431    itk_component add speed {
    411         ::scale $itk_component(flowcontrol).speed -from 500 -to 50 \
    412             -showvalue 0 -orient horizontal -width 14 -length 150 \
    413             -variable [itcl::scope _settings(speed)]  \
    414             -highlightthickness 0
     432        Rappture::Spinint $itk_component(flowcontrols).speed \
     433            -min 1 -max 10 -width 2
    415434    } {
    416         usual
     435        usual
    417436        ignore -highlightthickness
    418437        rename -background -controlbackground controlBackground Background
    419438    }
    420     $itk_component(speed) set 500
    421 
    422     blt::table $itk_component(flowcontrol) \
     439    $itk_component(speed) value 1
     440    bind $itk_component(speed) <<Value>> [itcl::code $this flow speed]
     441
     442
     443    blt::table $itk_component(flowcontrols) \
    423444        0,0 $itk_component(rewind) -padx {3 0} \
    424445        0,1 $itk_component(stop) -padx {2 0} \
    425446        0,2 $itk_component(play) -padx {2 0} \
    426447        0,3 $itk_component(loop) -padx {2 0} \
     448        0,4 $itk_component(frame) -fill x -padx {2 0 } \
    427449        0,5 $itk_component(speedlabel) -padx {2 0} \
    428         0,6 $itk_component(speed) -fill x \
    429         0,7 $itk_component(numframeslabel) -padx {2 0} \
    430         0,8 $itk_component(numframes) -fill x -padx { 0 3}
    431     blt::table configure $itk_component(flowcontrol) c* -resize none
    432     blt::table configure $itk_component(flowcontrol) c4 c6 -resize both
    433     blt::table configure $itk_component(flowcontrol) r0 -pady 1
     450        0,6 $itk_component(speed) -padx {2 0} \
     451        0,7 $itk_component(nstepslabel) -padx {2 0} \
     452        0,8 $itk_component(nsteps) -padx { 2 3}
     453
     454    blt::table configure $itk_component(flowcontrols) c* -resize none
     455    blt::table configure $itk_component(flowcontrols) c4 -resize both
     456    blt::table configure $itk_component(flowcontrols) r0 -pady 1
    434457    # Bindings for rotation via mouse
    435458    bind $itk_component(3dview) <ButtonPress-1> \
     
    439462    bind $itk_component(3dview) <ButtonRelease-1> \
    440463        [itcl::code $this Rotate release %x %y]
     464
    441465    bind $itk_component(3dview) <Configure> \
    442466        [itcl::code $this EventuallyResize %w %h]
     
    609633# ----------------------------------------------------------------------
    610634itcl::body Rappture::FlowvisViewer::delete {args} {
     635     flow stop
    611636    if {[llength $args] == 0} {
    612637        set args $_dlist
     
    880905
    881906            NameTransferFunc $dataobj $comp
    882             set _receiveIds($ivol) 1
     907            set _recvObjs($dataobj-$comp) 1
    883908        }
    884909    }
     
    898923            SendCmd "up $axis"
    899924        }
     925
     926        if 0 {
     927        set location [$_first hints camera]
     928        if { $location != "" } {
     929            array set _view $location
     930        }
     931        set _settings($this-theta) $_view(theta)
     932        set _settings($this-phi)   $_view(phi)
     933        set _settings($this-psi)   $_view(psi)
     934        set _settings($this-pan-x) $_view(pan-x)
     935        set _settings($this-pan-y) $_view(pan-y)
     936        set _settings($this-zoom)  $_view(zoom)
     937        set xyz [Euler2XYZ $_view(theta) $_view(phi) $_view(psi)]
     938        SendCmd "camera angle $xyz"
     939        PanCamera
     940        SendCmd "camera zoom $_view(zoom)"
     941        }
    900942        # The active transfer function is by default the first component of
    901943        # the first data object.  This assumes that the data is always
     
    943985itcl::body Rappture::FlowvisViewer::SendTransferFuncs {} {
    944986    if { $_activeTf == "" } {
     987        puts stderr "no active tf"
    945988        return
    946989    }
    947990    set tf $_activeTf
    948991    if { $_first == "" } {
     992        puts stderr "no first"
    949993        return
    950994    }
     
    9681012        }
    9691013    }
    970     FixLegend
     1014    ResizeLegend
    9711015}
    9721016
     
    9791023# ----------------------------------------------------------------------
    9801024itcl::body Rappture::FlowvisViewer::ReceiveImage { args } {
    981     if {![isconnected]} {
    982         return
    983     }
    9841025    array set info {
    9851026        -token "???"
     
    9911032    ReceiveEcho <<line "<read $info(-bytes) bytes"
    9921033    if { $info(-type) == "image" } {
    993         ReceiveEcho "for [image width $_image(plot)]x[image height $_image(plot)] image>"       
    9941034        $_image(plot) configure -data $bytes
    9951035    } elseif { $info(type) == "print" } {
     
    10661106#       doesn't parse 3D data formats, we rely on the server (flowvis) to
    10671107#       tell us what the limits are.  Once we've received the limits to all
    1068 #       the data we've sent (tracked by _receiveIds) we can then determine
     1108#       the data we've sent (tracked by _recvObjs) we can then determine
    10691109#       what the transfer functions are for these # volumes.
    10701110#
     
    11031143    set _limits(vmax)      $info(vmax); # Overall maximum value.
    11041144
    1105     unset _receiveIds($ivol)
    1106     if { [array size _receiveIds] == 0 } {
     1145    unset _recvObjs($tag)
     1146    if { [array size _recvObjs] == 0 } {
    11071147        updatetransferfuncs
    11081148    }
     
    11171157#
    11181158itcl::body Rappture::FlowvisViewer::Rebuild {} {
    1119     puts stderr "in Rebuild"
     1159    #puts stderr "in Rebuild"
    11201160    # Hide all the isomarkers. Can't remove them. Have to remember the
    11211161    # settings since the user may have created/deleted/moved markers.
     
    11291169    # in the midst of sending data? then bail out
    11301170    if {[llength $_sendobjs] > 0} {
     1171        $_dispatcher event -idle !rebuild
    11311172        return
    11321173    }
     
    11361177    # generates a new call to Rebuild).   
    11371178    set _buffering 1
     1179
     1180    set w [winfo width $itk_component(3dview)]
     1181    set h [winfo height $itk_component(3dview)]
     1182    EventuallyResize $w $h
    11381183
    11391184    # Find any new data that needs to be sent to the server.  Queue this up on
     
    11481193        }
    11491194    }
    1150     set w [winfo width $itk_component(3dview)]
    1151     set h [winfo height $itk_component(3dview)]
    1152     EventuallyResize $w $h
    11531195
    11541196    #
    11551197    # Reset the camera and other view parameters
    11561198    #
    1157     set xyz [Euler2XYZ $_view(theta) $_view(phi) $_view(psi)]
    1158     SendCmd "camera angle $xyz"
    1159     PanCamera
    1160     SendCmd "camera zoom $_view(zoom)"
    1161 
     1199    FixSettings light
     1200    FixSettings transp
     1201    FixSettings isosurface
     1202    FixSettings grid
     1203    FixSettings axes
     1204    FixSettings outline
     1205    # nothing to send -- activate the proper ivol
     1206    set _first [lindex [get] 0]
     1207    if {"" != $_first} {
     1208        set axis [$_first hints updir]
     1209        if {"" != $axis} {
     1210            SendCmd "up $axis"
     1211        }
     1212        set location [$_first hints camera]
     1213        if { $location != "" } {
     1214            array set _view $location
     1215        }
     1216    }
    11621217    set _settings($this-theta) $_view(theta)
    11631218    set _settings($this-phi)   $_view(phi)
     
    11671222    set _settings($this-zoom)  $_view(zoom)
    11681223
    1169     FixSettings light
    1170     FixSettings transp
    1171     FixSettings isosurface
    1172     FixSettings grid
    1173     FixSettings axes
    1174     FixSettings outline
     1224    set xyz [Euler2XYZ $_view(theta) $_view(phi) $_view(psi)]
     1225    SendCmd "camera angle $xyz"
     1226    PanCamera
     1227    SendCmd "camera zoom $_view(zoom)"
    11751228
    11761229    if {[llength $_sendobjs] > 0} {
    11771230        # send off new data objects
    11781231        $_dispatcher event -idle !send_dataobjs
     1232        puts stderr "more sendobjs "
    11791233        return
    11801234    }
     
    11871241            SendCmd "up $axis"
    11881242        }
     1243        set location [$_first hints camera]
     1244        if { $location != "" } {
     1245            array set _view $location
     1246        }
    11891247        if { 0 && $_settings($this-volume) }  {
    11901248            SendCmd "volume state 0"
     
    12241282    set _buffering 0;                   # Turn off buffering.
    12251283    set _outbuf "";                     # Clear the buffer.             
    1226     puts stderr "exit Rebuild"
     1284    #puts stderr "exit Rebuild"
    12271285}
    12281286
     
    14681526                        set inner $itk_component(settingsFrame)
    14691527                        set frames [$inner.framecnt value]
    1470                         set _settings(numframes) $frames
     1528                        set _settings(nsteps) $frames
    14711529                        set cmds "flow capture $frames"
    14721530                        SendCmd $cmds
     
    16371695
    16381696# ----------------------------------------------------------------------
    1639 # USAGE: FixLegend
     1697# USAGE: ResizeLegend
    16401698#
    16411699# Used internally to update the legend area whenever it changes size
     
    16431701# for the current field.
    16441702# ----------------------------------------------------------------------
    1645 itcl::body Rappture::FlowvisViewer::FixLegend {} {
     1703itcl::body Rappture::FlowvisViewer::ResizeLegend {} {
     1704    set _resizeLegendPending 0
    16461705    set lineht [font metrics $itk_option(-font) -linespace]
    16471706    set w [expr {$_width-20}]
     
    16811740    set tf "$style(-color):$style(-levels):$style(-opacity)"
    16821741    lappend _obj2style($dataobj-$comp) $tf
    1683     puts stderr "creating tf=$tf $dataobj-$comp"
    1684     parray _obj2style
    16851742    lappend _style2objs($tf) $dataobj $comp
    16861743    return $tf
     
    23112368            set _settings($this-particles-$name) $info(hide)
    23122369        }
    2313         checkbutton $inner.part$row -text $name \
     2370        checkbutton $inner.part$row -text $info(label) \
    23142371            -variable [itcl::scope _settings($this-particles-$name)] \
    23152372            -onvalue 0 -offvalue 1 \
     
    23342391            set _settings($this-box-$name) $info(hide)
    23352392        }
    2336         checkbutton $inner.box$row -text $info(name) \
     2393        checkbutton $inner.box$row -text $info(label) \
    23372394            -variable [itcl::scope _settings($this-box-$name)] \
    23382395            -onvalue 0 -offvalue 1 \
     
    23532410itcl::body Rappture::FlowvisViewer::particles { tag name } {
    23542411    set bool $_settings($this-particles-$name)
    2355     SendCmd "$tag particles configure $name -hide $bool"
     2412    SendCmd "$tag particles configure {$name} -hide $bool"
    23562413}
    23572414
    23582415itcl::body Rappture::FlowvisViewer::box { tag name } {
    23592416    set bool $_settings($this-box-$name)
    2360     SendCmd "$tag box configure $name -hide $bool"
     2417    SendCmd "$tag box configure {$name} -hide $bool"
    23612418}
    23622419
     
    24122469itcl::body Rappture::FlowvisViewer::DoResize {} {
    24132470    SendCmd "screen $_width $_height"
     2471    set _resizePending 0
    24142472}
    24152473
    24162474itcl::body Rappture::FlowvisViewer::EventuallyResize { w h } {
    2417     if { $_width != $w || $_height != $h } {
    2418         set _width $w
    2419         set _height $h
     2475    set _width $w
     2476    set _height $h
     2477    if { !$_resizePending } {
    24202478        $_dispatcher event -idle !resize
     2479        set _resizePending 1
    24212480    }
    24222481}
    24232482
    24242483itcl::body Rappture::FlowvisViewer::EventuallyResizeLegend {} {
    2425     $_dispatcher event -idle !legend
     2484    if { !$_resizeLegendPending } {
     2485        $_dispatcher event -idle !legend
     2486        set _resizeLegendPending 1
     2487    }
    24262488}
    24272489
     
    24832545        append cmd "-axis $info(axis) -color {$color}\n"
    24842546    }
    2485     puts stderr "boxes=[$flowobj boxes]"
    24862547    foreach box [$flowobj boxes] {
    24872548        array unset info
     
    25152576#       $this flow next
    25162577#
    2517 itcl::body Rappture::FlowvisViewer::flow {option} {
     2578itcl::body Rappture::FlowvisViewer::flow { args } {
     2579    set option [lindex $args 0]
    25182580    switch -- $option {
     2581        "speed" {
     2582            set speed [$itk_component(speed) value]
     2583            set _settings($this-speed) [expr int(round(500.0/$speed))]
     2584        }
     2585        "nsteps" {
     2586            set n [$itk_component(nsteps) value]
     2587            $itk_component(frame) configure -max $n
     2588            set settings($this-nsteps) $n
     2589        }
    25192590        "off" {
    25202591            set _flow(state) 0
     
    25422613                flow on
    25432614                # If we're at the end of the flow, reset the flow.
    2544                 set count [$itk_component(numframes) value]
    2545                 if { $_flow(frame) >= $count } {
    2546                     set _flow(frame) 1
     2615                set n $_settings($this-step)
     2616                if { $n >= $_settings($this-nsteps) } {
     2617                    set _settings($this-step) 1
    25472618                    SendCmd "flow reset"
    25482619                }
     
    25582629        }
    25592630        "reset" {
    2560             set _flow(frame) 0
     2631            set _settings($this-step) 0
    25612632            SendCmd "flow reset"
    25622633            if { !$_flow(state) } {
     
    25652636        }
    25662637        "next" {
    2567             set count [$itk_component(numframes) value]
    2568             incr _flow(frame)
    2569             if { $_flow(frame) >= $count } {
     2638            set w $itk_component(3dview)
     2639            while { $w != "" }  {
     2640                if { ![winfo ismapped $w] } {
     2641                    flow stop
     2642                    puts stderr "$w isn't mapped"
     2643                    return
     2644                }
     2645                set w [winfo parent $w]
     2646                if { [winfo toplevel $w] == $w } {
     2647                    break
     2648                }
     2649            }
     2650            set n [incr _settings($this-step)]
     2651            if { $n >= $_settings($this-nsteps) } {
    25702652                if { !$_settings($this-loop) } {
    25712653                    flow off
     
    25762658                SendCmd "flow next"
    25772659            }
    2578             set delay [expr {int(ceil(pow($_settings(speed)/10.0+2,2.0)*15))}]
    2579             set delay2 [expr round(log($_settings(speed)+0.00001)*100.0)]
    2580             $_dispatcher event -after $_settings(speed) !play
     2660            $_dispatcher event -after $_settings($this-speed) !play
    25812661        }
    25822662        default {
     
    26382718    focus $inner.cancel
    26392719
    2640     SendCmd "flow video $width $height $_settings(numframes) 2.0 1000"
     2720    SendCmd "flow video $width $height $_settings($this-nsteps) 2.0 1000"
    26412721   
    26422722    $popup activate $widget below
  • trunk/gui/scripts/heightmapviewer.tcl

    r1437 r1448  
    296296        set params(-color) black
    297297    }
    298     set location [$dataobj hints camera]
    299     if { $location != "" } {
    300         array set _view $location
    301     }
    302298    set pos [lsearch -exact $dataobj $_dlist]
    303299    if {$pos < 0} {
     
    583579        if {"" != $axis} {
    584580            SendCmd "up $axis"
     581        }
     582        set location [$first hints camera]
     583        if { $location != "" } {
     584            array set _view $location
    585585        }
    586586    }
  • trunk/gui/scripts/nanovisviewer.tcl

    r1444 r1448  
    132132    private variable _width 0
    133133    private variable _height 0
     134    private variable _resizePending 0
     135    private variable _resizeLegendPending 0
    134136}
    135137
     
    347349    $_dispatcher cancel !send_dataobjs
    348350    $_dispatcher cancel !send_transfunc
     351    $_dispatcher cancel !resize
    349352    image delete $_image(plot)
    350353    image delete $_image(legend)
     
    380383        set params(-color) black
    381384    }
    382 
    383385    set pos [lsearch -exact $dataobj $_dlist]
    384386    if {$pos < 0} {
     
    674676            SendCmd "up $axis"
    675677        }
     678        set location [$_first hints camera]
     679        if { $location != "" } {
     680            array set _view $location
     681        }
    676682        # The active transfer function is by default the first component of
    677683        # the first data object.  This assumes that the data is always
     
    762768# ----------------------------------------------------------------------
    763769itcl::body Rappture::NanovisViewer::ReceiveImage { args } {
    764     if { ![isconnected] } {
    765         return
    766     }
    767770    array set info {
    768771        -token "???"
     
    906909        }
    907910    }
    908 
    909911    # in the midst of sending data? then bail out
    910912    if {[llength $_sendobjs] > 0} {
     
    916918    # generates a new call to Rebuild).   
    917919    set _buffering 1
     920
     921    set w [winfo width $itk_component(3dview)]
     922    set h [winfo height $itk_component(3dview)]
     923    EventuallyResize $w $h
     924
     925    #
     926    # Reset the camera and other view parameters
     927    #
     928    set xyz [Euler2XYZ $_view(theta) $_view(phi) $_view(psi)]
     929    SendCmd "camera angle $xyz"
     930    PanCamera
     931    SendCmd "camera zoom $_view(zoom)"
    918932
    919933    # Find any new data that needs to be sent to the server.  Queue this up on
     
    929943        }
    930944    }
    931     set w [winfo width $itk_component(3dview)]
    932     set h [winfo height $itk_component(3dview)]
    933     EventuallyResize $w $h
    934 
    935     #
    936     # Reset the camera and other view parameters
    937     #
    938     set xyz [Euler2XYZ $_view(theta) $_view(phi) $_view(psi)]
    939     SendCmd "camera angle $xyz"
    940     PanCamera
    941     SendCmd "camera zoom $_view(zoom)"
     945    if {[llength $_sendobjs] > 0} {
     946        # send off new data objects
     947        $_dispatcher event -idle !send_dataobjs
     948        return
     949    }
    942950
    943951    set _settings($this-theta) $_view(theta)
     
    955963    FixSettings outline
    956964
    957     if {[llength $_sendobjs] > 0} {
    958         # send off new data objects
    959         $_dispatcher event -idle !send_dataobjs
    960         return
    961     }
    962 
    963965    # nothing to send -- activate the proper ivol
    964966    set _first [lindex [get] 0]
     
    968970            SendCmd "up $axis"
    969971        }
    970         foreach key [array names _obj2id *-*] {
    971             set state [string match $_first-* $key]
    972             SendCmd "volume state $state $_obj2id($key)"
     972        SendCmd "volume state 0"
     973        foreach key [array names _obj2id $_first-*] {
     974            SendCmd "volume state 1 $_obj2id($key)"
    973975        }
    974976        #
     
    13201322# ----------------------------------------------------------------------
    13211323itcl::body Rappture::NanovisViewer::FixLegend {} {
     1324    set _resizeLegendPending 0
    13221325    set lineht [font metrics $itk_option(-font) -linespace]
    13231326    set w [expr {$_width-20}]
     
    19811984itcl::body Rappture::NanovisViewer::DoResize {} {
    19821985    SendCmd "screen $_width $_height"
     1986    set _resizePending 0
    19831987}
    19841988
    19851989itcl::body Rappture::NanovisViewer::EventuallyResize { w h } {
    1986     if { $_width != $w || $_height != $h } {
    1987         set _width $w
    1988         set _height $h
     1990    set _width $w
     1991    set _height $h
     1992    if { !$_resizePending } {
    19891993        $_dispatcher event -idle !resize
     1994        set _resizePending 1
    19901995    }
    19911996}
    19921997
    19931998itcl::body Rappture::NanovisViewer::EventuallyResizeLegend {} {
    1994     $_dispatcher event -idle !legend
     1999    if { !$_resizeLegendPending } {
     2000        $_dispatcher event -idle !legend
     2001        set _resizeLegendPending 1
     2002    }
    19952003}
    19962004
  • trunk/gui/scripts/spinint.tcl

    r1342 r1448  
    4242    public method value {args}
    4343    public method bump {{delta up}}
    44 
    4544    protected method _validate {char}
    4645}
  • trunk/gui/scripts/visviewer.tcl

    r1439 r1448  
    314314        $_dispatcher event -idle !rebuild
    315315        Rappture::Tooltip::cue hide
    316         return 0;                       # Fail even though we've reconnected.
    317316    } else {
    318317        Rappture::Tooltip::cue @$x,$y "Can't connect to visualization server.  This may be a network problem.  Wait a few moments and try resetting the view."
    319318        return 0
    320319    }
     320    return 1
    321321}
    322322
     
    409409        flush $_sid
    410410    }
     411    if 0 {
    411412    if { ![CheckConnection] } {
    412         return 0
     413        puts stderr "connection is now down"
     414        return 0
     415    }
    413416    }
    414417    return $_done($this)
Note: See TracChangeset for help on using the changeset viewer.