source: trunk/gui/scripts/valueresult.tcl @ 54

Last change on this file since 54 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: 5.3 KB
Line 
1# ----------------------------------------------------------------------
2#  COMPONENT: ValueResult - Log output for ResultSet
3#
4#  This widget is used to show text output in a ResultSet.  The log
5#  output from a tool, for example, is rendered as a ValueResult.
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 *ValueResult.font \
15    -*-helvetica-medium-r-normal-*-*-120-* widgetDefault
16option add *ValueResult.boldFont \
17    -*-helvetica-bold-r-normal-*-*-120-* widgetDefault
18
19itcl::class Rappture::ValueResult {
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 ValueResult {
34    keep -background -foreground -cursor -font
35}
36
37# ----------------------------------------------------------------------
38# CONSTRUCTOR
39# ----------------------------------------------------------------------
40itcl::body Rappture::ValueResult::constructor {args} {
41    itk_component add label {
42        label $itk_interior.l
43    }
44    pack $itk_component(label) -side left
45
46    itk_component add value {
47        label $itk_interior.value -anchor w
48    } {
49        usual
50        rename -font -boldfont boldFont Font
51        ignore -foreground
52    }
53    pack $itk_component(value) -side left -expand yes -fill both
54
55    eval itk_initialize $args
56}
57
58# ----------------------------------------------------------------------
59# USAGE: add <dataobj> ?<settings>?
60#
61# Clients use this to add a data object to the plot.  If the optional
62# <settings> are specified, then the are applied to the data.  Allowed
63# settings are -color and -brightness, -width, -linestyle and -raise.
64# (Many of these are ignored.)
65# ----------------------------------------------------------------------
66itcl::body Rappture::ValueResult::add {dataobj {settings ""}} {
67    array set params {
68        -color ""
69        -brightness ""
70        -width ""
71        -linestyle ""
72        -raise ""
73    }
74    foreach {opt val} $settings {
75        if {![info exists params($opt)]} {
76            error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]"
77        }
78        set params($opt) $val
79    }
80
81    $itk_component(label) configure -text ""
82    $itk_component(value) configure -text ""
83
84    if {"" != $dataobj} {
85        set label [$dataobj get about.label]
86        if {"" != $label && [string index $label end] != ":"} {
87            append label ":"
88        }
89        $itk_component(label) configure -text $label
90
91        # find the value and assign it with the proper coloring
92        if {"" != $params(-color) && $params(-brightness) != 0} {
93            set params(-color) [Rappture::color::brightness \
94                $params(-color) $params(-brightness)]
95        }
96        if {$params(-color) != ""} {
97            $itk_component(value) configure -foreground $params(-color)
98        } else {
99            $itk_component(value) configure -foreground $itk_option(-foreground)
100        }
101        $itk_component(value) configure -text [$dataobj get current]
102    }
103    set _dataobj $dataobj
104}
105
106# ----------------------------------------------------------------------
107# USAGE: get
108#
109# Clients use this to query the list of objects being plotted, in
110# order from bottom to top of this result.
111# ----------------------------------------------------------------------
112itcl::body Rappture::ValueResult::get {} {
113    return $_dataobj
114}
115
116# ----------------------------------------------------------------------
117# USAGE: delete ?<curve1> <curve2> ...?
118#
119# Clients use this to delete a curve from the plot.  If no curves
120# are specified, then all curves are deleted.
121# ----------------------------------------------------------------------
122itcl::body Rappture::ValueResult::delete {args} {
123    $itk_component(label) configure -text ""
124    $itk_component(value) configure -text ""
125    set _dataobj ""
126}
127
128# ----------------------------------------------------------------------
129# USAGE: scale ?<curve1> <curve2> ...?
130#
131# Sets the default limits for the overall plot according to the
132# limits of the data for all of the given <curve> objects.  This
133# accounts for all curves--even those not showing on the screen.
134# Because of this, the limits are appropriate for all curves as
135# the user scans through data in the ResultSet viewer.
136# ----------------------------------------------------------------------
137itcl::body Rappture::ValueResult::scale {args} {
138    # nothing to do for values
139}
140
141# ----------------------------------------------------------------------
142# USAGE: download
143#
144# Clients use this method to create a downloadable representation
145# of the plot.  Returns a list of the form {ext string}, where
146# "ext" is the file extension (indicating the type of data) and
147# "string" is the data itself.
148# ----------------------------------------------------------------------
149itcl::body Rappture::ValueResult::download {} {
150    return ""
151}
Note: See TracBrowser for help on using the repository browser.