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

Last change on this file since 116 was 115, checked in by mmc, 19 years ago

Updated all copyright notices.

File size: 5.6 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  Purdue Research Foundation
9#
10#  See the file "license.terms" for information on usage and
11#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
12# ======================================================================
13package require Itk
14package require BLT
15
16option add *ValueResult.font \
17    -*-helvetica-medium-r-normal-*-*-120-* widgetDefault
18option add *ValueResult.boldFont \
19    -*-helvetica-bold-r-normal-*-*-120-* widgetDefault
20
21itcl::class Rappture::ValueResult {
22    inherit itk::Widget
23
24    constructor {args} { # defined below }
25
26    public method add {dataobj {settings ""}}
27    public method get {}
28    public method delete {args}
29    public method scale {args}
30    public method download {}
31
32    set _dataobj ""  ;# data object currently being displayed
33}
34                                                                               
35itk::usual ValueResult {
36    keep -background -foreground -cursor -font
37}
38
39# ----------------------------------------------------------------------
40# CONSTRUCTOR
41# ----------------------------------------------------------------------
42itcl::body Rappture::ValueResult::constructor {args} {
43    itk_component add label {
44        label $itk_interior.l
45    }
46    pack $itk_component(label) -side left
47
48    itk_component add value {
49        label $itk_interior.value -anchor w
50    } {
51        usual
52        rename -font -boldfont boldFont Font
53        ignore -foreground
54    }
55    pack $itk_component(value) -side left -expand yes -fill both
56
57    eval itk_initialize $args
58}
59
60# ----------------------------------------------------------------------
61# USAGE: add <dataobj> ?<settings>?
62#
63# Clients use this to add a data object to the plot.  If the optional
64# <settings> are specified, then the are applied to the data.  Allowed
65# settings are -color and -brightness, -width, -linestyle and -raise.
66# (Many of these are ignored.)
67# ----------------------------------------------------------------------
68itcl::body Rappture::ValueResult::add {dataobj {settings ""}} {
69    array set params {
70        -color ""
71        -brightness ""
72        -width ""
73        -linestyle ""
74        -raise ""
75    }
76    foreach {opt val} $settings {
77        if {![info exists params($opt)]} {
78            error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]"
79        }
80        set params($opt) $val
81    }
82    if {$params(-color) == "auto" || $params(-color) == "autoreset"} {
83        # can't handle -autocolors yet
84        set params(-color) black
85    }
86
87    $itk_component(label) configure -text ""
88    $itk_component(value) configure -text ""
89
90    if {"" != $dataobj} {
91        set label [$dataobj get about.label]
92        if {"" != $label && [string index $label end] != ":"} {
93            append label ":"
94        }
95        $itk_component(label) configure -text $label
96
97        # find the value and assign it with the proper coloring
98        if {"" != $params(-color) && "" != $params(-brightness)
99              && $params(-brightness) != 0} {
100            set params(-color) [Rappture::color::brightness \
101                $params(-color) $params(-brightness)]
102        }
103        if {$params(-color) != ""} {
104            $itk_component(value) configure -foreground $params(-color)
105        } else {
106            $itk_component(value) configure -foreground $itk_option(-foreground)
107        }
108        $itk_component(value) configure -text [$dataobj get current]
109    }
110    set _dataobj $dataobj
111}
112
113# ----------------------------------------------------------------------
114# USAGE: get
115#
116# Clients use this to query the list of objects being plotted, in
117# order from bottom to top of this result.
118# ----------------------------------------------------------------------
119itcl::body Rappture::ValueResult::get {} {
120    return $_dataobj
121}
122
123# ----------------------------------------------------------------------
124# USAGE: delete ?<curve1> <curve2> ...?
125#
126# Clients use this to delete a curve from the plot.  If no curves
127# are specified, then all curves are deleted.
128# ----------------------------------------------------------------------
129itcl::body Rappture::ValueResult::delete {args} {
130    $itk_component(label) configure -text ""
131    $itk_component(value) configure -text ""
132    set _dataobj ""
133}
134
135# ----------------------------------------------------------------------
136# USAGE: scale ?<curve1> <curve2> ...?
137#
138# Sets the default limits for the overall plot according to the
139# limits of the data for all of the given <curve> objects.  This
140# accounts for all curves--even those not showing on the screen.
141# Because of this, the limits are appropriate for all curves as
142# the user scans through data in the ResultSet viewer.
143# ----------------------------------------------------------------------
144itcl::body Rappture::ValueResult::scale {args} {
145    # nothing to do for values
146}
147
148# ----------------------------------------------------------------------
149# USAGE: download
150#
151# Clients use this method to create a downloadable representation
152# of the plot.  Returns a list of the form {ext string}, where
153# "ext" is the file extension (indicating the type of data) and
154# "string" is the data itself.
155# ----------------------------------------------------------------------
156itcl::body Rappture::ValueResult::download {} {
157    return ""
158}
Note: See TracBrowser for help on using the repository browser.