source: trunk/gui/scripts/deviceresult.tcl @ 65

Last change on this file since 65 was 50, checked in by mmc, 19 years ago

Added support for file transfer with the desktop. Each Rappture
application acts like an http server, configured to listen on
a particular port according to the parameters found in the file
~/data/sessions/$SESSION/resources. When the server is active,
the GUI has a "Download..." button in the results area. A Java
client (in the filexfer directory) connects to the server and
listens for download requests. When the user clicks on "Download...",
the desired result is spooled to a file, and a Java client pops up
a web page requesting the file. This downloads the result to the
user's desktop.

Note that if the $SESSION environment variable is not set, these
changes do nothing.

File size: 4.4 KB
Line 
1# ----------------------------------------------------------------------
2#  COMPONENT: DeviceResult - output for <structure>
3#
4#  This widget is used to show <structure> output.  It is similar
5#  to a DeviceEditor, but does not allow editing.
6# ======================================================================
7#  AUTHOR:  Michael McLennan, Purdue University
8#  Copyright (c) 2004-2005
9#  Purdue Research Foundation, West Lafayette, IN
10# ======================================================================
11package require Itk
12package require BLT
13
14option add *DeviceResult.width 4i widgetDefault
15option add *DeviceResult.height 4i widgetDefault
16option add *DeviceResult.font \
17    -*-courier-medium-r-normal-*-*-120-* widgetDefault
18
19itcl::class Rappture::DeviceResult {
20    inherit itk::Widget
21
22    constructor {args} { # defined below }
23
24    public method add {dataobj {settings ""}}
25    public method get {}
26    public method delete {args}
27    public method scale {args}
28    public method download {}
29
30    set _dataobj ""  ;# data object currently being displayed
31}
32                                                                               
33itk::usual DeviceResult {
34    keep -background -foreground -cursor -font
35}
36
37# ----------------------------------------------------------------------
38# CONSTRUCTOR
39# ----------------------------------------------------------------------
40itcl::body Rappture::DeviceResult::constructor {args} {
41    option add hull.width hull.height
42    pack propagate $itk_component(hull) no
43
44    itk_component add viewer {
45        # turn off auto-cleanup -- resultset swaps results in and out
46        Rappture::DeviceEditor $itk_interior.dev "" -autocleanup no
47    }
48    pack $itk_component(viewer) -expand yes -fill both
49
50    eval itk_initialize $args
51}
52
53# ----------------------------------------------------------------------
54# USAGE: add <dataobj> ?<settings>?
55#
56# Clients use this to add a data object to the plot.  If the optional
57# <settings> are specified, then the are applied to the data.  Allowed
58# settings are -color and -brightness, -width, -linestyle and -raise.
59# (Many of these are ignored.)
60# ----------------------------------------------------------------------
61itcl::body Rappture::DeviceResult::add {dataobj {settings ""}} {
62    array set params {
63        -color ""
64        -brightness ""
65        -width ""
66        -linestyle ""
67        -raise ""
68    }
69    foreach {opt val} $settings {
70        if {![info exists params($opt)]} {
71            error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]"
72        }
73        set params($opt) $val
74    }
75
76    $itk_component(viewer) value $dataobj
77
78    set _dataobj $dataobj
79}
80
81# ----------------------------------------------------------------------
82# USAGE: get
83#
84# Clients use this to query the list of objects being plotted, in
85# order from bottom to top of this result.
86# ----------------------------------------------------------------------
87itcl::body Rappture::DeviceResult::get {} {
88    return $_dataobj
89}
90
91# ----------------------------------------------------------------------
92# USAGE: delete ?<dataobj1> <dataobj2> ...?
93#
94# Clients use this to delete a dataobj from the plot.  If no dataobjs
95# are specified, then all dataobjs are deleted.
96# ----------------------------------------------------------------------
97itcl::body Rappture::DeviceResult::delete {args} {
98    $itk_component(viewer) value ""
99    set _dataobj ""
100}
101
102# ----------------------------------------------------------------------
103# USAGE: scale ?<dataobj1> <dataobj2> ...?
104#
105# Sets the default limits for the overall plot according to the
106# limits of the data for all of the given <dataobj> objects.  This
107# accounts for all dataobjs--even those not showing on the screen.
108# Because of this, the limits are appropriate for all dataobjs as
109# the user scans through data in the ResultSet viewer.
110# ----------------------------------------------------------------------
111itcl::body Rappture::DeviceResult::scale {args} {
112    # nothing to do for structures
113}
114
115# ----------------------------------------------------------------------
116# USAGE: download
117#
118# Clients use this method to create a downloadable representation
119# of the plot.  Returns a list of the form {ext string}, where
120# "ext" is the file extension (indicating the type of data) and
121# "string" is the data itself.
122# ----------------------------------------------------------------------
123itcl::body Rappture::DeviceResult::download {} {
124    return ""
125}
Note: See TracBrowser for help on using the repository browser.