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

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

Lots of fixes for app-pntoy and other tools:

  • Fixed plotting to recognize "-color name" in the style section, and to use auto colors for overlayed plots.
  • Fixed x-y plotting to keep axes instead of resetting when flipping back and forth between plots.
  • Fixed 1D fields to support new lin/log limits queries, so it plots properly.
  • Added support for <string> output values.
  • Fixed molecular viewer so that 3D rotation is unconstrained and more intuitive.
  • Fixed Rappture::exec to handle newlines properly. Sometimes output would get all mixed together without newlines. Works better now.
File size: 5.5 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    if {$params(-color) == "auto" || $params(-color) == "autoreset"} {
81        # can't handle -autocolors yet
82        set params(-color) black
83    }
84
85    $itk_component(label) configure -text ""
86    $itk_component(value) configure -text ""
87
88    if {"" != $dataobj} {
89        set label [$dataobj get about.label]
90        if {"" != $label && [string index $label end] != ":"} {
91            append label ":"
92        }
93        $itk_component(label) configure -text $label
94
95        # find the value and assign it with the proper coloring
96        if {"" != $params(-color) && "" != $params(-brightness)
97              && $params(-brightness) != 0} {
98            set params(-color) [Rappture::color::brightness \
99                $params(-color) $params(-brightness)]
100        }
101        if {$params(-color) != ""} {
102            $itk_component(value) configure -foreground $params(-color)
103        } else {
104            $itk_component(value) configure -foreground $itk_option(-foreground)
105        }
106        $itk_component(value) configure -text [$dataobj get current]
107    }
108    set _dataobj $dataobj
109}
110
111# ----------------------------------------------------------------------
112# USAGE: get
113#
114# Clients use this to query the list of objects being plotted, in
115# order from bottom to top of this result.
116# ----------------------------------------------------------------------
117itcl::body Rappture::ValueResult::get {} {
118    return $_dataobj
119}
120
121# ----------------------------------------------------------------------
122# USAGE: delete ?<curve1> <curve2> ...?
123#
124# Clients use this to delete a curve from the plot.  If no curves
125# are specified, then all curves are deleted.
126# ----------------------------------------------------------------------
127itcl::body Rappture::ValueResult::delete {args} {
128    $itk_component(label) configure -text ""
129    $itk_component(value) configure -text ""
130    set _dataobj ""
131}
132
133# ----------------------------------------------------------------------
134# USAGE: scale ?<curve1> <curve2> ...?
135#
136# Sets the default limits for the overall plot according to the
137# limits of the data for all of the given <curve> objects.  This
138# accounts for all curves--even those not showing on the screen.
139# Because of this, the limits are appropriate for all curves as
140# the user scans through data in the ResultSet viewer.
141# ----------------------------------------------------------------------
142itcl::body Rappture::ValueResult::scale {args} {
143    # nothing to do for values
144}
145
146# ----------------------------------------------------------------------
147# USAGE: download
148#
149# Clients use this method to create a downloadable representation
150# of the plot.  Returns a list of the form {ext string}, where
151# "ext" is the file extension (indicating the type of data) and
152# "string" is the data itself.
153# ----------------------------------------------------------------------
154itcl::body Rappture::ValueResult::download {} {
155    return ""
156}
Note: See TracBrowser for help on using the repository browser.