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

Last change on this file since 689 was 689, checked in by nkissebe, 17 years ago

add support for multiple devices (for molecule viewer)

File size: 4.7 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 download {option args}
31
32    private variable _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        -description ""
71    }
72    foreach {opt val} $settings {
73        if {![info exists params($opt)]} {
74            error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]"
75        }
76        set params($opt) $val
77    }
78
79    eval $itk_component(viewer) add $dataobj [list $settings]
80
81    set _dataobj $dataobj
82}
83
84# ----------------------------------------------------------------------
85# USAGE: get
86#
87# Clients use this to query the list of objects being plotted, in
88# order from bottom to top of this result.
89# ----------------------------------------------------------------------
90itcl::body Rappture::DeviceResult::get {} {
91    return $_dataobj
92}
93
94# ----------------------------------------------------------------------
95# USAGE: delete ?<dataobj1> <dataobj2> ...?
96#
97# Clients use this to delete a dataobj from the plot.  If no dataobjs
98# are specified, then all dataobjs are deleted.
99# ----------------------------------------------------------------------
100itcl::body Rappture::DeviceResult::delete {args} {
101    eval $itk_component(viewer) delete $args
102    set _dataobj ""
103}
104
105# ----------------------------------------------------------------------
106# USAGE: scale ?<dataobj1> <dataobj2> ...?
107#
108# Sets the default limits for the overall plot according to the
109# limits of the data for all of the given <dataobj> objects.  This
110# accounts for all dataobjs--even those not showing on the screen.
111# Because of this, the limits are appropriate for all dataobjs as
112# the user scans through data in the ResultSet viewer.
113# ----------------------------------------------------------------------
114itcl::body Rappture::DeviceResult::scale {args} {
115    # nothing to do for structures
116}
117
118# ----------------------------------------------------------------------
119# USAGE: download coming
120# USAGE: download controls <downloadCommand>
121# USAGE: download now
122#
123# Clients use this method to create a downloadable representation
124# of the plot.  Returns a list of the form {ext string}, where
125# "ext" is the file extension (indicating the type of data) and
126# "string" is the data itself.
127# ----------------------------------------------------------------------
128itcl::body Rappture::DeviceResult::download {option args} {
129    return [eval $itk_component(viewer) download $option $args]
130}
Note: See TracBrowser for help on using the repository browser.