1 | # ---------------------------------------------------------------------- |
---|
2 | # COMPONENT: ValueResult - Log output for ResultSet |
---|
3 | # |
---|
4 | # This widget is used to show text output in a ResultSet. The log |
---|
5 | # output from a tool, for example, is rendered as a ValueResult. |
---|
6 | # ====================================================================== |
---|
7 | # AUTHOR: Michael McLennan, Purdue University |
---|
8 | # Copyright (c) 2004-2005 |
---|
9 | # Purdue Research Foundation, West Lafayette, IN |
---|
10 | # ====================================================================== |
---|
11 | package require Itk |
---|
12 | package require BLT |
---|
13 | |
---|
14 | option add *ValueResult.font \ |
---|
15 | -*-helvetica-medium-r-normal-*-*-120-* widgetDefault |
---|
16 | option add *ValueResult.boldFont \ |
---|
17 | -*-helvetica-bold-r-normal-*-*-120-* widgetDefault |
---|
18 | |
---|
19 | itcl::class Rappture::ValueResult { |
---|
20 | inherit itk::Widget |
---|
21 | |
---|
22 | constructor {args} { # defined below } |
---|
23 | |
---|
24 | public method add {dataobj {settings ""}} |
---|
25 | public method get {} |
---|
26 | public method delete {args} |
---|
27 | public method scale {args} |
---|
28 | |
---|
29 | set _dataobj "" ;# data object currently being displayed |
---|
30 | } |
---|
31 | |
---|
32 | itk::usual ValueResult { |
---|
33 | keep -background -foreground -cursor -font |
---|
34 | } |
---|
35 | |
---|
36 | # ---------------------------------------------------------------------- |
---|
37 | # CONSTRUCTOR |
---|
38 | # ---------------------------------------------------------------------- |
---|
39 | itcl::body Rappture::ValueResult::constructor {args} { |
---|
40 | itk_component add label { |
---|
41 | label $itk_interior.l |
---|
42 | } |
---|
43 | pack $itk_component(label) -side left |
---|
44 | |
---|
45 | itk_component add value { |
---|
46 | label $itk_interior.value -anchor w |
---|
47 | } { |
---|
48 | usual |
---|
49 | rename -font -boldfont boldFont Font |
---|
50 | ignore -foreground |
---|
51 | } |
---|
52 | pack $itk_component(value) -side left -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 | # ---------------------------------------------------------------------- |
---|
65 | itcl::body Rappture::ValueResult::add {dataobj {settings ""}} { |
---|
66 | array set params { |
---|
67 | -color "" |
---|
68 | -brightness "" |
---|
69 | -width "" |
---|
70 | -linestyle "" |
---|
71 | -raise "" |
---|
72 | } |
---|
73 | foreach {opt val} $settings { |
---|
74 | if {![info exists params($opt)]} { |
---|
75 | error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]" |
---|
76 | } |
---|
77 | set params($opt) $val |
---|
78 | } |
---|
79 | |
---|
80 | $itk_component(label) configure -text "" |
---|
81 | $itk_component(value) configure -text "" |
---|
82 | |
---|
83 | if {"" != $dataobj} { |
---|
84 | set label [$dataobj get about.label] |
---|
85 | if {"" != $label && [string index $label end] != ":"} { |
---|
86 | append label ":" |
---|
87 | } |
---|
88 | $itk_component(label) configure -text $label |
---|
89 | |
---|
90 | # find the value and assign it with the proper coloring |
---|
91 | if {"" != $params(-color) && $params(-brightness) != 0} { |
---|
92 | set params(-color) [Rappture::color::brightness \ |
---|
93 | $params(-color) $params(-brightness)] |
---|
94 | } |
---|
95 | if {$params(-color) != ""} { |
---|
96 | $itk_component(value) configure -foreground $params(-color) |
---|
97 | } else { |
---|
98 | $itk_component(value) configure -foreground $itk_option(-foreground) |
---|
99 | } |
---|
100 | $itk_component(value) configure -text [$dataobj get current] |
---|
101 | } |
---|
102 | set _dataobj $dataobj |
---|
103 | } |
---|
104 | |
---|
105 | # ---------------------------------------------------------------------- |
---|
106 | # USAGE: get |
---|
107 | # |
---|
108 | # Clients use this to query the list of objects being plotted, in |
---|
109 | # order from bottom to top of this result. |
---|
110 | # ---------------------------------------------------------------------- |
---|
111 | itcl::body Rappture::ValueResult::get {} { |
---|
112 | return $_dataobj |
---|
113 | } |
---|
114 | |
---|
115 | # ---------------------------------------------------------------------- |
---|
116 | # USAGE: delete ?<curve1> <curve2> ...? |
---|
117 | # |
---|
118 | # Clients use this to delete a curve from the plot. If no curves |
---|
119 | # are specified, then all curves are deleted. |
---|
120 | # ---------------------------------------------------------------------- |
---|
121 | itcl::body Rappture::ValueResult::delete {args} { |
---|
122 | $itk_component(label) configure -text "" |
---|
123 | $itk_component(value) configure -text "" |
---|
124 | set _dataobj "" |
---|
125 | } |
---|
126 | |
---|
127 | # ---------------------------------------------------------------------- |
---|
128 | # USAGE: scale ?<curve1> <curve2> ...? |
---|
129 | # |
---|
130 | # Sets the default limits for the overall plot according to the |
---|
131 | # limits of the data for all of the given <curve> objects. This |
---|
132 | # accounts for all curves--even those not showing on the screen. |
---|
133 | # Because of this, the limits are appropriate for all curves as |
---|
134 | # the user scans through data in the ResultSet viewer. |
---|
135 | # ---------------------------------------------------------------------- |
---|
136 | itcl::body Rappture::ValueResult::scale {args} { |
---|
137 | # nothing to do for values |
---|
138 | } |
---|