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

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

Updated all copyright notices.

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