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

Last change on this file since 4042 was 3799, checked in by gah, 11 years ago

add -simulation to plotadd calls

File size: 4.7 KB
Line 
1# -*- mode: tcl; indent-tabs-mode: nil -*-
2# ----------------------------------------------------------------------
3#  COMPONENT: DeviceResult - output for <structure>
4#
5#  This widget is used to show <structure> output.  It is similar
6#  to a DeviceEditor, but does not allow editing.
7# ======================================================================
8#  AUTHOR:  Michael McLennan, Purdue University
9#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
10#
11#  See the file "license.terms" for information on usage and
12#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
13# ======================================================================
14package require Itk
15package require BLT
16
17option add *DeviceResult.width 4i widgetDefault
18option add *DeviceResult.height 4i widgetDefault
19option add *DeviceResult.font \
20    -*-courier-medium-r-normal-*-12-* widgetDefault
21
22itcl::class Rappture::DeviceResult {
23    inherit itk::Widget
24
25    constructor {args} { # defined below }
26
27    public method add {dataobj {settings ""}}
28    public method get {}
29    public method delete {args}
30    public method scale {args}
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    array set params $settings
76
77    eval $itk_component(viewer) add $dataobj [list $settings]
78
79    set _dataobj $dataobj
80}
81
82# ----------------------------------------------------------------------
83# USAGE: get
84#
85# Clients use this to query the list of objects being plotted, in
86# order from bottom to top of this result.
87# ----------------------------------------------------------------------
88itcl::body Rappture::DeviceResult::get {} {
89    return $_dataobj
90}
91
92# ----------------------------------------------------------------------
93# USAGE: delete ?<dataobj1> <dataobj2> ...?
94#
95# Clients use this to delete a dataobj from the plot.  If no dataobjs
96# are specified, then all dataobjs are deleted.
97# ----------------------------------------------------------------------
98itcl::body Rappture::DeviceResult::delete {args} {
99    eval $itk_component(viewer) delete $args
100    set _dataobj ""
101}
102
103# ----------------------------------------------------------------------
104# USAGE: scale ?<dataobj1> <dataobj2> ...?
105#
106# Sets the default limits for the overall plot according to the
107# limits of the data for all of the given <dataobj> objects.  This
108# accounts for all dataobjs--even those not showing on the screen.
109# Because of this, the limits are appropriate for all dataobjs as
110# the user scans through data in the ResultSet viewer.
111# ----------------------------------------------------------------------
112itcl::body Rappture::DeviceResult::scale {args} {
113    # nothing to do for structures
114}
115
116# ----------------------------------------------------------------------
117# USAGE: download coming
118# USAGE: download controls <downloadCommand>
119# USAGE: download now
120#
121# Clients use this method to create a downloadable representation
122# of the plot.  Returns a list of the form {ext string}, where
123# "ext" is the file extension (indicating the type of data) and
124# "string" is the data itself.
125# ----------------------------------------------------------------------
126itcl::body Rappture::DeviceResult::download {option args} {
127    return [eval $itk_component(viewer) download $option $args]
128}
Note: See TracBrowser for help on using the repository browser.