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

Last change on this file since 57 was 57, checked in by mmc, 19 years ago
  • Fixed x/y graphs to support multiple axes.
  • Added Rappture::result proc for reporting results.
  • Fixed up app-fermi example to be a little cleaner.
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)
93              && $params(-brightness) != 0} {
94            set params(-color) [Rappture::color::brightness \
95                $params(-color) $params(-brightness)]
96        }
97        if {$params(-color) != ""} {
98            $itk_component(value) configure -foreground $params(-color)
99        } else {
100            $itk_component(value) configure -foreground $itk_option(-foreground)
101        }
102        $itk_component(value) configure -text [$dataobj get current]
103    }
104    set _dataobj $dataobj
105}
106
107# ----------------------------------------------------------------------
108# USAGE: get
109#
110# Clients use this to query the list of objects being plotted, in
111# order from bottom to top of this result.
112# ----------------------------------------------------------------------
113itcl::body Rappture::ValueResult::get {} {
114    return $_dataobj
115}
116
117# ----------------------------------------------------------------------
118# USAGE: delete ?<curve1> <curve2> ...?
119#
120# Clients use this to delete a curve from the plot.  If no curves
121# are specified, then all curves are deleted.
122# ----------------------------------------------------------------------
123itcl::body Rappture::ValueResult::delete {args} {
124    $itk_component(label) configure -text ""
125    $itk_component(value) configure -text ""
126    set _dataobj ""
127}
128
129# ----------------------------------------------------------------------
130# USAGE: scale ?<curve1> <curve2> ...?
131#
132# Sets the default limits for the overall plot according to the
133# limits of the data for all of the given <curve> objects.  This
134# accounts for all curves--even those not showing on the screen.
135# Because of this, the limits are appropriate for all curves as
136# the user scans through data in the ResultSet viewer.
137# ----------------------------------------------------------------------
138itcl::body Rappture::ValueResult::scale {args} {
139    # nothing to do for values
140}
141
142# ----------------------------------------------------------------------
143# USAGE: download
144#
145# Clients use this method to create a downloadable representation
146# of the plot.  Returns a list of the form {ext string}, where
147# "ext" is the file extension (indicating the type of data) and
148# "string" is the data itself.
149# ----------------------------------------------------------------------
150itcl::body Rappture::ValueResult::download {} {
151    return ""
152}
Note: See TracBrowser for help on using the repository browser.