[22] | 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 |
---|
[115] | 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. |
---|
[22] | 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 \ |
---|
[676] | 19 | -*-courier-medium-r-normal-*-12-* widgetDefault |
---|
[22] | 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} |
---|
[472] | 30 | public method download {option args} |
---|
[22] | 31 | |
---|
[641] | 32 | private variable _dataobj "" ;# data object currently being displayed |
---|
[22] | 33 | } |
---|
| 34 | |
---|
| 35 | itk::usual DeviceResult { |
---|
| 36 | keep -background -foreground -cursor -font |
---|
| 37 | } |
---|
| 38 | |
---|
| 39 | # ---------------------------------------------------------------------- |
---|
| 40 | # CONSTRUCTOR |
---|
| 41 | # ---------------------------------------------------------------------- |
---|
| 42 | itcl::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 | # ---------------------------------------------------------------------- |
---|
| 63 | itcl::body Rappture::DeviceResult::add {dataobj {settings ""}} { |
---|
| 64 | array set params { |
---|
| 65 | -color "" |
---|
| 66 | -brightness "" |
---|
| 67 | -width "" |
---|
| 68 | -linestyle "" |
---|
| 69 | -raise "" |
---|
[471] | 70 | -description "" |
---|
[22] | 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 | |
---|
[689] | 79 | eval $itk_component(viewer) add $dataobj [list $settings] |
---|
[22] | 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 | # ---------------------------------------------------------------------- |
---|
| 90 | itcl::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 | # ---------------------------------------------------------------------- |
---|
| 100 | itcl::body Rappture::DeviceResult::delete {args} { |
---|
[689] | 101 | eval $itk_component(viewer) delete $args |
---|
[22] | 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 | # ---------------------------------------------------------------------- |
---|
| 114 | itcl::body Rappture::DeviceResult::scale {args} { |
---|
| 115 | # nothing to do for structures |
---|
| 116 | } |
---|
[50] | 117 | |
---|
| 118 | # ---------------------------------------------------------------------- |
---|
[193] | 119 | # USAGE: download coming |
---|
[472] | 120 | # USAGE: download controls <downloadCommand> |
---|
[193] | 121 | # USAGE: download now |
---|
[50] | 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 | # ---------------------------------------------------------------------- |
---|
[472] | 128 | itcl::body Rappture::DeviceResult::download {option args} { |
---|
| 129 | return [eval $itk_component(viewer) download $option $args] |
---|
[50] | 130 | } |
---|