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