source: branches/blt4/gui/scripts/deviceresult.tcl @ 1719

Last change on this file since 1719 was 1719, checked in by gah, 14 years ago
File size: 4.8 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  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 *DeviceResult.width 4i widgetDefault
17option add *DeviceResult.height 4i widgetDefault
18option add *DeviceResult.font \
19    -*-courier-medium-r-normal-*-12-* widgetDefault
20
21itcl::class Rappture::DeviceResult {
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 snap {w h}
31    public method parameters {title args} { # do nothing }
32    public method download {option args}
33
34    private variable _dataobj ""  ;# data object currently being displayed
35}
36                                                                               
37itk::usual DeviceResult {
38    keep -background -foreground -cursor -font
39}
40
41# ----------------------------------------------------------------------
42# CONSTRUCTOR
43# ----------------------------------------------------------------------
44itcl::body Rappture::DeviceResult::constructor {args} {
45    option add hull.width hull.height
46    pack propagate $itk_component(hull) no
47
48    itk_component add viewer {
49        # turn off auto-cleanup -- resultset swaps results in and out
50        Rappture::DeviceEditor $itk_interior.dev "" -autocleanup no
51    }
52    pack $itk_component(viewer) -expand yes -fill both
53
54    eval itk_initialize $args
55}
56
57# ----------------------------------------------------------------------
58# USAGE: add <dataobj> ?<settings>?
59#
60# Clients use this to add a data object to the plot.  If the optional
61# <settings> are specified, then the are applied to the data.  Allowed
62# settings are -color and -brightness, -width, -linestyle and -raise.
63# (Many of these are ignored.)
64# ----------------------------------------------------------------------
65itcl::body Rappture::DeviceResult::add {dataobj {settings ""}} {
66    array set params {
67        -color ""
68        -brightness ""
69        -width ""
70        -linestyle ""
71        -raise ""
72        -description ""
73        -param ""
74    }
75    foreach {opt val} $settings {
76        if {![info exists params($opt)]} {
77            error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]"
78        }
79        set params($opt) $val
80    }
81
82    eval $itk_component(viewer) add $dataobj [list $settings]
83
84    set _dataobj $dataobj
85}
86
87# ----------------------------------------------------------------------
88# USAGE: get
89#
90# Clients use this to query the list of objects being plotted, in
91# order from bottom to top of this result.
92# ----------------------------------------------------------------------
93itcl::body Rappture::DeviceResult::get {} {
94    return $_dataobj
95}
96
97# ----------------------------------------------------------------------
98# USAGE: delete ?<dataobj1> <dataobj2> ...?
99#
100# Clients use this to delete a dataobj from the plot.  If no dataobjs
101# are specified, then all dataobjs are deleted.
102# ----------------------------------------------------------------------
103itcl::body Rappture::DeviceResult::delete {args} {
104    eval $itk_component(viewer) delete $args
105    set _dataobj ""
106}
107
108# ----------------------------------------------------------------------
109# USAGE: scale ?<dataobj1> <dataobj2> ...?
110#
111# Sets the default limits for the overall plot according to the
112# limits of the data for all of the given <dataobj> objects.  This
113# accounts for all dataobjs--even those not showing on the screen.
114# Because of this, the limits are appropriate for all dataobjs as
115# the user scans through data in the ResultSet viewer.
116# ----------------------------------------------------------------------
117itcl::body Rappture::DeviceResult::scale {args} {
118    # nothing to do for structures
119}
120
121# ----------------------------------------------------------------------
122# USAGE: download coming
123# USAGE: download controls <downloadCommand>
124# USAGE: download now
125#
126# Clients use this method to create a downloadable representation
127# of the plot.  Returns a list of the form {ext string}, where
128# "ext" is the file extension (indicating the type of data) and
129# "string" is the data itself.
130# ----------------------------------------------------------------------
131itcl::body Rappture::DeviceResult::download {option args} {
132    return [eval $itk_component(viewer) download $option $args]
133}
134
135itcl::body Rappture::DeviceResult::snap { w h } {
136    return [$itk_component(viewer) snap $w $h]
137}
Note: See TracBrowser for help on using the repository browser.