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

Report clientinfo first thing after connecting to visualization server.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.