Changeset 3592


Ignore:
Timestamp:
Mar 27, 2013, 2:01:06 PM (12 years ago)
Author:
ldelgass
Message:

Report clientinfo first thing after connecting to visualization server.

Location:
trunk/gui/scripts
Files:
9 edited

Legend:

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

    r3330 r3592  
    5656    }
    5757    array set flags $args
    58    switch -- $flags(-mode) {
     58    set servers ""
     59    switch -- $flags(-mode) {
    5960        "auto" - "nanovis" - "flowvis" {
    6061            set servers [Rappture::VisViewer::GetServerList "nanovis"]
     
    6566        "vtk" {
    6667            # Old vtk contour widget
    67             set servers ""
    6868        }
    6969        default {
  • trunk/gui/scripts/flowvisviewer.tcl

    r3555 r3592  
    860860    set result [VisViewer::Connect $_hosts]
    861861    if { $result } {
     862        if { $_reportClientInfo }  {
     863            # Tell the server the viewer, hub, user and session.
     864            # Do this immediately on connect before buffing any commands
     865            global env
     866
     867            set info {}
     868            set user "???"
     869            if { [info exists env(USER)] } {
     870                set user $env(USER)
     871            }
     872            set session "???"
     873            if { [info exists env(SESSION)] } {
     874                set session $env(SESSION)
     875            }
     876            lappend info "hub" [exec hostname]
     877            lappend info "client" "flowvisviewer"
     878            lappend info "user" $user
     879            lappend info "session" $session
     880            SendCmd "clientinfo [list $info]"
     881        }
     882
    862883        set w [winfo width $itk_component(3dview)]
    863884        set h [winfo height $itk_component(3dview)]
     
    11851206
    11861207    set _first ""
    1187 
    1188     if { $_reset } {
    1189         if { $_reportClientInfo }  {
    1190             # Tell the server the name of the tool, the version, and
    1191             # dataset that we are rendering.  Have to do it here because
    1192             # we don't know what data objects are using the renderer until
    1193             # be get here.
    1194             global env
    1195 
    1196             set info {}
    1197             set user "???"
    1198             if { [info exists env(USER)] } {
    1199                 set user $env(USER)
    1200             }
    1201             set session "???"
    1202             if { [info exists env(SESSION)] } {
    1203                 set session $env(SESSION)
    1204             }
    1205             lappend info "hub" [exec hostname]
    1206             lappend info "client" "flowvisviewer"
    1207             lappend info "user" $user
    1208             lappend info "session" $session
    1209             SendCmd "clientinfo [list $info]"
    1210         }
    1211     }
    12121208    foreach dataobj [get] {
    12131209        foreach comp [$dataobj components] {
  • trunk/gui/scripts/molvisviewer.tcl

    r3454 r3592  
    683683    set result [VisViewer::Connect $hosts]
    684684    if { $result } {
    685         $_dispatcher event -idle !rebuild
    686     }
    687     return $result
    688 }
    689 
    690 #
    691 # Disconnect --
    692 #
    693 #       Clients use this method to disconnect from the current rendering
    694 #       server.
    695 #
    696 itcl::body Rappture::MolvisViewer::Disconnect {} {
    697     VisViewer::Disconnect
    698 
    699     # disconnected -- no more data sitting on server
    700     catch { after cancel $_rocker(afterid) }
    701     catch { after cancel $_mevent(afterid) }
    702     array unset _dataobjs
    703     array unset _model
    704     array unset _mlist
    705     array unset _imagecache
    706 
    707     set _state(server) 1
    708     set _state(client) 1
    709     global readyForNextFrame
    710     set readyForNextFrame 1
    711     set _reset 1
    712 }
    713 
    714 itcl::body Rappture::MolvisViewer::ServerCmd { cmd } {
    715     debug "in ServerCmd ($cmd)\n"
    716 
    717     if { $_state(server) != $_state(client) } {
    718         SendCmd "frame -defer $_state(client)"
    719         set _state(server) $_state(client)
    720     }
    721     if { $_rocker(server) != $_rocker(client) } {
    722         SendCmd "rock -defer $_rocker(client)"
    723         set _rocker(server) $_rocker(client)
    724     }
    725     SendCmd "$cmd"
    726 }
    727 
    728 #
    729 # ReceiveImage -bytes <size>
    730 #
    731 #     Invoked automatically whenever the "image" command comes in from
    732 #     the rendering server.  Indicates that binary image data with the
    733 #     specified <size> will follow.
    734 #
    735 set count 0
    736 itcl::body Rappture::MolvisViewer::ReceiveImage { size cacheid frame rock } {
    737     global readyForNextFrame
    738     set readyForNextFrame 1
    739     set tag "$frame,$rock"
    740     global count
    741     incr count
    742     if { $cacheid != $_cacheid } {
    743         array unset _imagecache
    744         set _cacheid $cacheid
    745     }
    746     #debug "reading $size bytes from proxy\n"
    747     set data [ReceiveBytes $size]
    748     #debug "success: reading $size bytes from proxy\n"
    749     if { [string match "print*" $cacheid] } {
    750         # $frame is the token that we sent to the proxy.
    751         set _hardcopy($this-$cacheid) $data
    752         puts stderr "setting _hardcopy($this-$cacheid)"
    753     } else {
    754         set _imagecache($tag) $data
    755         #debug "CACHED: $tag,$cacheid"
    756         $_image(plot) configure -data $data
    757         set _image(id) $tag
    758     }
    759 }
    760 
    761 itcl::body Rappture::MolvisViewer::BuildSettingsTab {} {
    762     set fg [option get $itk_component(hull) font Font]
    763 
    764     set inner [$itk_component(main) insert end \
    765         -title "Settings" \
    766         -icon [Rappture::icon wrench]]
    767     $inner configure -borderwidth 4
    768 
    769     label $inner.pict -image $_settings($this-modelimg)
    770 
    771     label $inner.rep_l -text "Molecule Representation" \
    772         -font "Arial 9"
    773 
    774     itk_component add representation {
    775         Rappture::Combobox $inner.rep -width 20 -editable no
    776     }
    777     $inner.rep choices insert end \
    778         "ballnstick"  "ball and stick" \
    779         "spheres"     "spheres"         \
    780         "sticks"      "sticks"          \
    781         "lines"       "lines"           \
    782         "cartoon"     "cartoon"         
    783 
    784     bind $inner.rep <<Value>> [itcl::code $this Representation]
    785     $inner.rep value "ball and stick"
    786 
    787     scale $inner.spherescale -width 10 -font "Arial 9" \
    788         -from 0.1 -to 2.0 -resolution 0.05 -label "Sphere Scale" \
    789         -showvalue true -orient horizontal \
    790         -command [itcl::code $this EventuallyChangeSettings] \
    791         -variable Rappture::MolvisViewer::_settings($this-spherescale)
    792     $inner.spherescale set $_settings($this-spherescale)
    793     Rappture::Tooltip::for $inner.spherescale \
    794         "Adjust scale of atoms (spheres or balls). 1.0 is the full VDW radius."
    795 
    796     scale $inner.stickradius -width 10 -font "Arial 9" \
    797         -from 0.1 -to 1.0 -resolution 0.025 -label "Stick Radius" \
    798         -showvalue true -orient horizontal \
    799         -command [itcl::code $this EventuallyChangeSettings] \
    800         -variable Rappture::MolvisViewer::_settings($this-stickradius)
    801     Rappture::Tooltip::for $inner.stickradius \
    802         "Adjust scale of bonds (sticks)."
    803     $inner.stickradius set $_settings($this-stickradius)
    804 
    805     checkbutton $inner.labels -text "Show labels on atoms" \
    806         -command [itcl::code $this labels update] \
    807         -variable [itcl::scope _settings($this-showlabels)] \
    808         -font "Arial 9"
    809     Rappture::Tooltip::for $inner.labels \
    810         "Display atom symbol and serial number."
    811 
    812     checkbutton $inner.rock -text "Rock model back and forth" \
    813         -command [itcl::code $this Rock toggle] \
    814         -variable Rappture::MolvisViewer::_settings($this-rock) \
    815         -font "Arial 9"
    816     Rappture::Tooltip::for $inner.rock \
    817         "Rotate the object back and forth around the y-axis."
    818 
    819     checkbutton $inner.ortho -text "Orthoscopic projection" \
    820         -command [itcl::code $this OrthoProjection update] \
    821         -variable Rappture::MolvisViewer::_settings($this-ortho) \
    822          -font "Arial 9"
    823     Rappture::Tooltip::for $inner.ortho \
    824         "Toggle between orthoscopic/perspective projection modes."
    825 
    826     checkbutton $inner.cartoontrace -text "Cartoon Trace" \
    827         -command [itcl::code $this CartoonTrace update] \
    828         -variable [itcl::scope _settings($this-cartoontrace)] \
    829         -font "Arial 9"
    830     Rappture::Tooltip::for $inner.cartoontrace \
    831         "Set cartoon representation of bonds (sticks)."
    832 
    833     checkbutton $inner.cell -text "Parallelepiped" \
    834         -command [itcl::code $this Cell toggle] \
    835         -font "Arial 9"
    836     $inner.cell select
    837 
    838     label $inner.spacer
    839     blt::table $inner \
    840         0,0 $inner.labels -anchor w -pady {1 0} \
    841         1,0 $inner.rock -anchor w -pady {1 0} \
    842         2,0 $inner.ortho -anchor w -pady {1 0} \
    843         3,0 $inner.cartoontrace -anchor w -pady {1 0} \
    844         4,0 $inner.cell -anchor w  -pady {1 0} \
    845         5,0 $inner.rep_l -anchor w -pady { 2 0 } \
    846         6,0 $inner.rep -anchor w  \
    847         7,0 $inner.spherescale -fill x -pady {3 0} \
    848         8,0 $inner.stickradius -fill x -pady {1 0} \
    849 
    850     blt::table configure $inner r* -resize none
    851     blt::table configure $inner r10 -resize expand
    852 }
    853 
    854 # ----------------------------------------------------------------------
    855 # USAGE: Rebuild
    856 #
    857 # Called automatically whenever something changes that affects the
    858 # data in the widget.  Clears any existing data and rebuilds the
    859 # widget to display new data.
    860 # ----------------------------------------------------------------------
    861 itcl::body Rappture::MolvisViewer::Rebuild {} {
    862     debug "in rebuild"
    863     set changed 0
    864 
    865     # Turn on buffering of commands to the server.  We don't want to
    866     # be preempted by a server disconnect/reconnect (that automatically
    867     # generates a new call to Rebuild).   
    868     StartBufferingCommands
    869     set _cell 0
    870 
    871     if { $_reset } {
    872         set _rocker(server) 0
    873         set _cacheid 0
    874 
    875685        if { $_reportClientInfo }  {
    876             # Tell the server the name of the tool, the version, and dataset
    877             # that we are rendering.  Have to do it here because we don't know
    878             # what data objects are using the renderer until be get here.
     686            # Tell the server the viewer, hub, user and session.
     687            # Do this immediately on connect before buffing any commands
    879688            global env
    880689
     
    894703            ServerCmd "clientinfo [list $info]"
    895704        }
     705
     706        $_dispatcher event -idle !rebuild
     707    }
     708    return $result
     709}
     710
     711#
     712# Disconnect --
     713#
     714#       Clients use this method to disconnect from the current rendering
     715#       server.
     716#
     717itcl::body Rappture::MolvisViewer::Disconnect {} {
     718    VisViewer::Disconnect
     719
     720    # disconnected -- no more data sitting on server
     721    catch { after cancel $_rocker(afterid) }
     722    catch { after cancel $_mevent(afterid) }
     723    array unset _dataobjs
     724    array unset _model
     725    array unset _mlist
     726    array unset _imagecache
     727
     728    set _state(server) 1
     729    set _state(client) 1
     730    global readyForNextFrame
     731    set readyForNextFrame 1
     732    set _reset 1
     733}
     734
     735itcl::body Rappture::MolvisViewer::ServerCmd { cmd } {
     736    debug "in ServerCmd ($cmd)\n"
     737
     738    if { $_state(server) != $_state(client) } {
     739        SendCmd "frame -defer $_state(client)"
     740        set _state(server) $_state(client)
     741    }
     742    if { $_rocker(server) != $_rocker(client) } {
     743        SendCmd "rock -defer $_rocker(client)"
     744        set _rocker(server) $_rocker(client)
     745    }
     746    SendCmd "$cmd"
     747}
     748
     749#
     750# ReceiveImage -bytes <size>
     751#
     752#     Invoked automatically whenever the "image" command comes in from
     753#     the rendering server.  Indicates that binary image data with the
     754#     specified <size> will follow.
     755#
     756set count 0
     757itcl::body Rappture::MolvisViewer::ReceiveImage { size cacheid frame rock } {
     758    global readyForNextFrame
     759    set readyForNextFrame 1
     760    set tag "$frame,$rock"
     761    global count
     762    incr count
     763    if { $cacheid != $_cacheid } {
     764        array unset _imagecache
     765        set _cacheid $cacheid
     766    }
     767    #debug "reading $size bytes from proxy\n"
     768    set data [ReceiveBytes $size]
     769    #debug "success: reading $size bytes from proxy\n"
     770    if { [string match "print*" $cacheid] } {
     771        # $frame is the token that we sent to the proxy.
     772        set _hardcopy($this-$cacheid) $data
     773        puts stderr "setting _hardcopy($this-$cacheid)"
     774    } else {
     775        set _imagecache($tag) $data
     776        #debug "CACHED: $tag,$cacheid"
     777        $_image(plot) configure -data $data
     778        set _image(id) $tag
     779    }
     780}
     781
     782itcl::body Rappture::MolvisViewer::BuildSettingsTab {} {
     783    set fg [option get $itk_component(hull) font Font]
     784
     785    set inner [$itk_component(main) insert end \
     786        -title "Settings" \
     787        -icon [Rappture::icon wrench]]
     788    $inner configure -borderwidth 4
     789
     790    label $inner.pict -image $_settings($this-modelimg)
     791
     792    label $inner.rep_l -text "Molecule Representation" \
     793        -font "Arial 9"
     794
     795    itk_component add representation {
     796        Rappture::Combobox $inner.rep -width 20 -editable no
     797    }
     798    $inner.rep choices insert end \
     799        "ballnstick"  "ball and stick" \
     800        "spheres"     "spheres"         \
     801        "sticks"      "sticks"          \
     802        "lines"       "lines"           \
     803        "cartoon"     "cartoon"         
     804
     805    bind $inner.rep <<Value>> [itcl::code $this Representation]
     806    $inner.rep value "ball and stick"
     807
     808    scale $inner.spherescale -width 10 -font "Arial 9" \
     809        -from 0.1 -to 2.0 -resolution 0.05 -label "Sphere Scale" \
     810        -showvalue true -orient horizontal \
     811        -command [itcl::code $this EventuallyChangeSettings] \
     812        -variable Rappture::MolvisViewer::_settings($this-spherescale)
     813    $inner.spherescale set $_settings($this-spherescale)
     814    Rappture::Tooltip::for $inner.spherescale \
     815        "Adjust scale of atoms (spheres or balls). 1.0 is the full VDW radius."
     816
     817    scale $inner.stickradius -width 10 -font "Arial 9" \
     818        -from 0.1 -to 1.0 -resolution 0.025 -label "Stick Radius" \
     819        -showvalue true -orient horizontal \
     820        -command [itcl::code $this EventuallyChangeSettings] \
     821        -variable Rappture::MolvisViewer::_settings($this-stickradius)
     822    Rappture::Tooltip::for $inner.stickradius \
     823        "Adjust scale of bonds (sticks)."
     824    $inner.stickradius set $_settings($this-stickradius)
     825
     826    checkbutton $inner.labels -text "Show labels on atoms" \
     827        -command [itcl::code $this labels update] \
     828        -variable [itcl::scope _settings($this-showlabels)] \
     829        -font "Arial 9"
     830    Rappture::Tooltip::for $inner.labels \
     831        "Display atom symbol and serial number."
     832
     833    checkbutton $inner.rock -text "Rock model back and forth" \
     834        -command [itcl::code $this Rock toggle] \
     835        -variable Rappture::MolvisViewer::_settings($this-rock) \
     836        -font "Arial 9"
     837    Rappture::Tooltip::for $inner.rock \
     838        "Rotate the object back and forth around the y-axis."
     839
     840    checkbutton $inner.ortho -text "Orthoscopic projection" \
     841        -command [itcl::code $this OrthoProjection update] \
     842        -variable Rappture::MolvisViewer::_settings($this-ortho) \
     843         -font "Arial 9"
     844    Rappture::Tooltip::for $inner.ortho \
     845        "Toggle between orthoscopic/perspective projection modes."
     846
     847    checkbutton $inner.cartoontrace -text "Cartoon Trace" \
     848        -command [itcl::code $this CartoonTrace update] \
     849        -variable [itcl::scope _settings($this-cartoontrace)] \
     850        -font "Arial 9"
     851    Rappture::Tooltip::for $inner.cartoontrace \
     852        "Set cartoon representation of bonds (sticks)."
     853
     854    checkbutton $inner.cell -text "Parallelepiped" \
     855        -command [itcl::code $this Cell toggle] \
     856        -font "Arial 9"
     857    $inner.cell select
     858
     859    label $inner.spacer
     860    blt::table $inner \
     861        0,0 $inner.labels -anchor w -pady {1 0} \
     862        1,0 $inner.rock -anchor w -pady {1 0} \
     863        2,0 $inner.ortho -anchor w -pady {1 0} \
     864        3,0 $inner.cartoontrace -anchor w -pady {1 0} \
     865        4,0 $inner.cell -anchor w  -pady {1 0} \
     866        5,0 $inner.rep_l -anchor w -pady { 2 0 } \
     867        6,0 $inner.rep -anchor w  \
     868        7,0 $inner.spherescale -fill x -pady {3 0} \
     869        8,0 $inner.stickradius -fill x -pady {1 0} \
     870
     871    blt::table configure $inner r* -resize none
     872    blt::table configure $inner r10 -resize expand
     873}
     874
     875# ----------------------------------------------------------------------
     876# USAGE: Rebuild
     877#
     878# Called automatically whenever something changes that affects the
     879# data in the widget.  Clears any existing data and rebuilds the
     880# widget to display new data.
     881# ----------------------------------------------------------------------
     882itcl::body Rappture::MolvisViewer::Rebuild {} {
     883    debug "in rebuild"
     884    set changed 0
     885
     886    # Turn on buffering of commands to the server.  We don't want to
     887    # be preempted by a server disconnect/reconnect (that automatically
     888    # generates a new call to Rebuild).   
     889    StartBufferingCommands
     890    set _cell 0
     891
     892    if { $_reset } {
     893        set _rocker(server) 0
     894        set _cacheid 0
     895
    896896        ServerCmd "raw -defer {set auto_color,0}"
    897897        ServerCmd "raw -defer {set auto_show_lines,0}"
  • trunk/gui/scripts/nanovisviewer.tcl

    r3571 r3592  
    606606    set result [VisViewer::Connect $_hosts]
    607607    if { $result } {
     608        if { $_reportClientInfo }  {
     609            # Tell the server the viewer, hub, user and session.
     610            # Do this immediately on connect before buffing any commands
     611            global env
     612
     613            set info {}
     614            set user "???"
     615            if { [info exists env(USER)] } {
     616                set user $env(USER)
     617            }
     618            set session "???"
     619            if { [info exists env(SESSION)] } {
     620                set session $env(SESSION)
     621            }
     622            lappend info "hub" [exec hostname]
     623            lappend info "client" "nanovisviewer"
     624            lappend info "user" $user
     625            lappend info "session" $session
     626            SendCmd "clientinfo [list $info]"
     627        }
     628
    608629        set w [winfo width $itk_component(3dview)]
    609630        set h [winfo height $itk_component(3dview)]
     
    868889        $_arcball resize $w $h
    869890        DoResize
    870     }
    871     if { $_reset } {
    872         if { $_reportClientInfo }  {
    873             # Tell the server the name of the tool, the version, and
    874             # dataset that we are rendering.  Have to do it here because
    875             # we don't know what data objects are using the renderer until
    876             # be get here.
    877             global env
    878 
    879             set info {}
    880             set user "???"
    881             if { [info exists env(USER)] } {
    882                 set user $env(USER)
    883             }
    884             set session "???"
    885             if { [info exists env(SESSION)] } {
    886                 set session $env(SESSION)
    887             }
    888             lappend info "hub" [exec hostname]
    889             lappend info "client" "nanovisviewer"
    890             lappend info "user" $user
    891             lappend info "session" $session
    892             SendCmd "clientinfo [list $info]"
    893         }
    894891    }
    895892    foreach dataobj [get] {
  • trunk/gui/scripts/vtkheightmapviewer.tcl

    r3587 r3592  
    725725    set result [VisViewer::Connect $_hosts]
    726726    if { $result } {
     727        if { $_reportClientInfo }  {
     728            # Tell the server the viewer, hub, user and session.
     729            # Do this immediately on connect before buffing any commands
     730            global env
     731
     732            set info {}
     733            set user "???"
     734            if { [info exists env(USER)] } {
     735                set user $env(USER)
     736            }
     737            set session "???"
     738            if { [info exists env(SESSION)] } {
     739                set session $env(SESSION)
     740            }
     741            lappend info "hub" [exec hostname]
     742            lappend info "client" "vtkheightmapviewer"
     743            lappend info "user" $user
     744            lappend info "session" $session
     745            SendCmd "clientinfo [list $info]"
     746        }
     747
    727748        set w [winfo width $itk_component(view)]
    728749        set h [winfo height $itk_component(view)]
     
    864885        $_dispatcher event -idle !rebuild
    865886        return
    866     }
    867 
    868     if { $_reset && $_reportClientInfo }  {
    869         # Tell the server the name of the tool, the version, and dataset
    870         # that we are rendering.  Have to do it here because we don't know
    871         # what data objects are using the renderer until be get here.
    872         global env
    873        
    874         set info {}
    875         set user "???"
    876         if { [info exists env(USER)] } {
    877             set user $env(USER)
    878         }
    879         set session "???"
    880         if { [info exists env(SESSION)] } {
    881             set session $env(SESSION)
    882         }
    883         lappend info "hub" [exec hostname]
    884         lappend info "client" "vtkheightmapviewer"
    885         lappend info "user" $user
    886         lappend info "session" $session
    887         SendCmd "clientinfo [list $info]"
    888887    }
    889888
  • trunk/gui/scripts/vtkisosurfaceviewer.tcl

    r3571 r3592  
    777777    set result [VisViewer::Connect $_hosts]
    778778    if { $result } {
     779        if { $_reportClientInfo }  {
     780            # Tell the server the viewer, hub, user and session.
     781            # Do this immediately on connect before buffing any commands
     782            global env
     783
     784            set info {}
     785            set user "???"
     786            if { [info exists env(USER)] } {
     787                set user $env(USER)
     788            }
     789            set session "???"
     790            if { [info exists env(SESSION)] } {
     791                set session $env(SESSION)
     792            }
     793            lappend info "hub" [exec hostname]
     794            lappend info "client" "vtkisosurfaceviewer"
     795            lappend info "user" $user
     796            lappend info "session" $session
     797            SendCmd "clientinfo [list $info]"
     798        }
     799
    779800        set w [winfo width $itk_component(view)]
    780801        set h [winfo height $itk_component(view)]
     
    927948
    928949    if { $_reset } {
    929         if { $_reportClientInfo }  {
    930             # Tell the server the name of the tool, the version, and dataset
    931             # that we are rendering.  Have to do it here because we don't know
    932             # what data objects are using the renderer until be get here.
    933             global env
    934 
    935             set info {}
    936             set user "???"
    937             if { [info exists env(USER)] } {
    938                 set user $env(USER)
    939             }
    940             set session "???"
    941             if { [info exists env(SESSION)] } {
    942                 set session $env(SESSION)
    943             }
    944             lappend info "hub" [exec hostname]
    945             lappend info "client" "vtkisosurfaceviewer"
    946             lappend info "user" $user
    947             lappend info "session" $session
    948             SendCmd "clientinfo [list $info]"
    949         }
    950950        set _width $w
    951951        set _height $h
  • trunk/gui/scripts/vtkstreamlinesviewer.tcl

    r3571 r3592  
    802802    set result [VisViewer::Connect $_hosts]
    803803    if { $result } {
     804        if { $_reportClientInfo }  {
     805            # Tell the server the viewer, hub, user and session.
     806            # Do this immediately on connect before buffing any commands
     807            global env
     808
     809            set info {}
     810            set user "???"
     811            if { [info exists env(USER)] } {
     812                set user $env(USER)
     813            }
     814            set session "???"
     815            if { [info exists env(SESSION)] } {
     816                set session $env(SESSION)
     817            }
     818            lappend info "hub" [exec hostname]
     819            lappend info "client" "vtkstreamlinesviewer"
     820            lappend info "user" $user
     821            lappend info "session" $session
     822            SendCmd "clientinfo [list $info]"
     823        }
     824
    804825        set w [winfo width $itk_component(view)]
    805826        set h [winfo height $itk_component(view)]
     
    957978    set _first ""
    958979    if { $_reset } {
    959         if { $_reportClientInfo }  {
    960             # Tell the server the name of the tool, the version, and dataset
    961             # that we are rendering.  Have to do it here because we don't know
    962             # what data objects are using the renderer until be get here.
    963             global env
    964 
    965             set info {}
    966             set user "???"
    967             if { [info exists env(USER)] } {
    968                 set user $env(USER)
    969             }
    970             set session "???"
    971             if { [info exists env(SESSION)] } {
    972                 set session $env(SESSION)
    973             }
    974             lappend info "hub" [exec hostname]
    975             lappend info "client" "vtkstreamlinesviewer"
    976             lappend info "user" $user
    977             lappend info "session" $session
    978             SendCmd "clientinfo [list $info]"
    979         }
    980980        set _width $w
    981981        set _height $h
  • trunk/gui/scripts/vtkviewer.tcl

    r3571 r3592  
    707707    set result [VisViewer::Connect $_hosts]
    708708    if { $result } {
    709         set w [winfo width $itk_component(view)]
    710         set h [winfo height $itk_component(view)]
    711         EventuallyResize $w $h
    712     }
    713     return $result
    714 }
    715 
    716 #
    717 # isconnected --
    718 #
    719 #       Indicates if we are currently connected to the visualization server.
    720 #
    721 itcl::body Rappture::VtkViewer::isconnected {} {
    722     return [VisViewer::IsConnected]
    723 }
    724 
    725 #
    726 # disconnect --
    727 #
    728 itcl::body Rappture::VtkViewer::disconnect {} {
    729     Disconnect
    730     set _reset 1
    731 }
    732 
    733 #
    734 # Disconnect --
    735 #
    736 #       Clients use this method to disconnect from the current rendering
    737 #       server.
    738 #
    739 itcl::body Rappture::VtkViewer::Disconnect {} {
    740     VisViewer::Disconnect
    741 
    742     # disconnected -- no more data sitting on server
    743     array unset _datasets
    744     array unset _data
    745     array unset _colormaps
    746 }
    747 
    748 # ----------------------------------------------------------------------
    749 # USAGE: ReceiveImage -bytes <size> -type <type> -token <token>
    750 #
    751 # Invoked automatically whenever the "image" command comes in from
    752 # the rendering server.  Indicates that binary image data with the
    753 # specified <size> will follow.
    754 # ----------------------------------------------------------------------
    755 itcl::body Rappture::VtkViewer::ReceiveImage { args } {
    756     array set info {
    757         -token "???"
    758         -bytes 0
    759         -type image
    760     }
    761     array set info $args
    762     set bytes [ReceiveBytes $info(-bytes)]
    763     if { $info(-type) == "image" } {
    764         if 0 {
    765             set f [open "last.ppm" "w"]
    766             puts $f $bytes
    767             close $f
    768         }
    769         $_image(plot) configure -data $bytes
    770         set time [clock seconds]
    771         set date [clock format $time]
    772         if { $_start > 0 } {
    773             set finish [clock clicks -milliseconds]
    774             set _start 0
    775         }
    776     } elseif { $info(type) == "print" } {
    777         set tag $this-print-$info(-token)
    778         set _hardcopy($tag) $bytes
    779     }
    780 }
    781 
    782 #
    783 # ReceiveDataset --
    784 #
    785 itcl::body Rappture::VtkViewer::ReceiveDataset { args } {
    786     if { ![isconnected] } {
    787         return
    788     }
    789     set option [lindex $args 0]
    790     switch -- $option {
    791         "scalar" {
    792             set option [lindex $args 1]
    793             switch -- $option {
    794                 "world" {
    795                     foreach { x y z value tag } [lrange $args 2 end] break
    796                 }
    797                 "pixel" {
    798                     foreach { x y value tag } [lrange $args 2 end] break
    799                 }
    800             }
    801         }
    802         "vector" {
    803             set option [lindex $args 1]
    804             switch -- $option {
    805                 "world" {
    806                     foreach { x y z vx vy vz tag } [lrange $args 2 end] break
    807                 }
    808                 "pixel" {
    809                     foreach { x y vx vy vz tag } [lrange $args 2 end] break
    810                 }
    811             }
    812         }
    813         "names" {
    814             foreach { name } [lindex $args 1] {
    815                 #puts stderr "Dataset: $name"
    816             }
    817         }
    818         default {
    819             error "unknown dataset option \"$option\" from server"
    820         }
    821     }
    822 }
    823 
    824 # ----------------------------------------------------------------------
    825 # USAGE: Rebuild
    826 #
    827 # Called automatically whenever something changes that affects the
    828 # data in the widget.  Clears any existing data and rebuilds the
    829 # widget to display new data.
    830 # ----------------------------------------------------------------------
    831 itcl::body Rappture::VtkViewer::Rebuild {} {
    832 
    833     set w [winfo width $itk_component(view)]
    834     set h [winfo height $itk_component(view)]
    835     if { $w < 2 || $h < 2 } {
    836         $_dispatcher event -idle !rebuild
    837         return
    838     }
    839 
    840     # Turn on buffering of commands to the server.  We don't want to
    841     # be preempted by a server disconnect/reconnect (which automatically
    842     # generates a new call to Rebuild).   
    843     StartBufferingCommands
    844 
    845     if { $_reset } {
    846709        if { $_reportClientInfo }  {
    847             # Tell the server the name of the tool, the version, and dataset
    848             # that we are rendering.  Have to do it here because we don't know
    849             # what data objects are using the renderer until be get here.
     710            # Tell the server the viewer, hub, user and session.
     711            # Do this immediately on connect before buffing any commands
    850712            global env
    851713
     
    866728        }
    867729
     730        set w [winfo width $itk_component(view)]
     731        set h [winfo height $itk_component(view)]
     732        EventuallyResize $w $h
     733    }
     734    return $result
     735}
     736
     737#
     738# isconnected --
     739#
     740#       Indicates if we are currently connected to the visualization server.
     741#
     742itcl::body Rappture::VtkViewer::isconnected {} {
     743    return [VisViewer::IsConnected]
     744}
     745
     746#
     747# disconnect --
     748#
     749itcl::body Rappture::VtkViewer::disconnect {} {
     750    Disconnect
     751    set _reset 1
     752}
     753
     754#
     755# Disconnect --
     756#
     757#       Clients use this method to disconnect from the current rendering
     758#       server.
     759#
     760itcl::body Rappture::VtkViewer::Disconnect {} {
     761    VisViewer::Disconnect
     762
     763    # disconnected -- no more data sitting on server
     764    array unset _datasets
     765    array unset _data
     766    array unset _colormaps
     767}
     768
     769# ----------------------------------------------------------------------
     770# USAGE: ReceiveImage -bytes <size> -type <type> -token <token>
     771#
     772# Invoked automatically whenever the "image" command comes in from
     773# the rendering server.  Indicates that binary image data with the
     774# specified <size> will follow.
     775# ----------------------------------------------------------------------
     776itcl::body Rappture::VtkViewer::ReceiveImage { args } {
     777    array set info {
     778        -token "???"
     779        -bytes 0
     780        -type image
     781    }
     782    array set info $args
     783    set bytes [ReceiveBytes $info(-bytes)]
     784    if { $info(-type) == "image" } {
     785        if 0 {
     786            set f [open "last.ppm" "w"]
     787            puts $f $bytes
     788            close $f
     789        }
     790        $_image(plot) configure -data $bytes
     791        set time [clock seconds]
     792        set date [clock format $time]
     793        if { $_start > 0 } {
     794            set finish [clock clicks -milliseconds]
     795            set _start 0
     796        }
     797    } elseif { $info(type) == "print" } {
     798        set tag $this-print-$info(-token)
     799        set _hardcopy($tag) $bytes
     800    }
     801}
     802
     803#
     804# ReceiveDataset --
     805#
     806itcl::body Rappture::VtkViewer::ReceiveDataset { args } {
     807    if { ![isconnected] } {
     808        return
     809    }
     810    set option [lindex $args 0]
     811    switch -- $option {
     812        "scalar" {
     813            set option [lindex $args 1]
     814            switch -- $option {
     815                "world" {
     816                    foreach { x y z value tag } [lrange $args 2 end] break
     817                }
     818                "pixel" {
     819                    foreach { x y value tag } [lrange $args 2 end] break
     820                }
     821            }
     822        }
     823        "vector" {
     824            set option [lindex $args 1]
     825            switch -- $option {
     826                "world" {
     827                    foreach { x y z vx vy vz tag } [lrange $args 2 end] break
     828                }
     829                "pixel" {
     830                    foreach { x y vx vy vz tag } [lrange $args 2 end] break
     831                }
     832            }
     833        }
     834        "names" {
     835            foreach { name } [lindex $args 1] {
     836                #puts stderr "Dataset: $name"
     837            }
     838        }
     839        default {
     840            error "unknown dataset option \"$option\" from server"
     841        }
     842    }
     843}
     844
     845# ----------------------------------------------------------------------
     846# USAGE: Rebuild
     847#
     848# Called automatically whenever something changes that affects the
     849# data in the widget.  Clears any existing data and rebuilds the
     850# widget to display new data.
     851# ----------------------------------------------------------------------
     852itcl::body Rappture::VtkViewer::Rebuild {} {
     853
     854    set w [winfo width $itk_component(view)]
     855    set h [winfo height $itk_component(view)]
     856    if { $w < 2 || $h < 2 } {
     857        $_dispatcher event -idle !rebuild
     858        return
     859    }
     860
     861    # Turn on buffering of commands to the server.  We don't want to
     862    # be preempted by a server disconnect/reconnect (which automatically
     863    # generates a new call to Rebuild).   
     864    StartBufferingCommands
     865
     866    if { $_reset } {
    868867        set _width $w
    869868        set _height $h
  • trunk/gui/scripts/vtkvolumeviewer.tcl

    r3571 r3592  
    773773    set result [VisViewer::Connect $_hosts]
    774774    if { $result } {
     775        if { $_reportClientInfo }  {
     776            # Tell the server the viewer, hub, user and session.
     777            # Do this immediately on connect before buffing any commands
     778            global env
     779
     780            set info {}
     781            set user "???"
     782            if { [info exists env(USER)] } {
     783                set user $env(USER)
     784            }
     785            set session "???"
     786            if { [info exists env(SESSION)] } {
     787                set session $env(SESSION)
     788            }
     789            lappend info "hub" [exec hostname]
     790            lappend info "client" "vtkvolumeviewer"
     791            lappend info "user" $user
     792            lappend info "session" $session
     793            SendCmd "clientinfo [list $info]"
     794        }
     795
    775796        set w [winfo width $itk_component(view)]
    776797        set h [winfo height $itk_component(view)]
     
    930951
    931952    if { $_reset } {
    932         if { $_reportClientInfo }  {
    933             # Tell the server the name of the tool, the version, and dataset
    934             # that we are rendering.  Have to do it here because we don't know
    935             # what data objects are using the renderer until be get here.
    936             global env
    937 
    938             set info {}
    939             set user "???"
    940             if { [info exists env(USER)] } {
    941                 set user $env(USER)
    942             }
    943             set session "???"
    944             if { [info exists env(SESSION)] } {
    945                 set session $env(SESSION)
    946             }
    947             lappend info "hub" [exec hostname]
    948             lappend info "client" "vtkvolumeviewer"
    949             lappend info "user" $user
    950             lappend info "session" $session
    951             SendCmd "clientinfo [list $info]"
    952         }
    953        
    954953        set _width $w
    955954        set _height $h
Note: See TracChangeset for help on using the changeset viewer.