Changeset 1929 for trunk/gui/scripts/unirect2d.tcl
- Timestamp:
- Oct 22, 2010, 4:06:10 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/unirect2d.tcl
r1525 r1929 48 48 itcl::body Rappture::Unirect2d::constructor {xmlobj field cname {extents 1}} { 49 49 if {![Rappture::library isvalid $xmlobj]} { 50 50 error "bad value \"$xmlobj\": should be Rappture::library" 51 51 } 52 52 set path [$field get $cname.mesh] … … 61 61 set _compNum $extents 62 62 foreach {key path} { 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 63 group about.group 64 label about.label 65 color about.color 66 style about.style 67 type about.type 68 xlabel xaxis.label 69 xdesc xaxis.description 70 xunits xaxis.units 71 xscale xaxis.scale 72 xmin xaxis.min 73 xmax xaxis.max 74 ylabel yaxis.label 75 ydesc yaxis.description 76 yunits yaxis.units 77 yscale yaxis.scale 78 ymin yaxis.min 79 ymax yaxis.max 80 80 } { 81 82 83 84 81 set str [$m get $path] 82 if {"" != $str} { 83 set _hints($key) $str 84 } 85 85 } 86 86 foreach {key} { axisorder } { 87 88 89 90 87 set str [$field get $cname.$key] 88 if {"" != $str} { 89 set _hints($key) $str 90 } 91 91 } 92 92 itcl::delete object $m … … 95 95 set values [$field get "$cname.values"] 96 96 if { $values == "" } { 97 97 set values [$field get "$cname.zvalues"] 98 98 } 99 99 $_values set $values 100 100 set n [expr $_xNum * $_yNum * $_compNum] 101 101 if { [$_values length] != $n } { 102 102 error "wrong \# of values in \"$cname.values\": expected $n values" 103 103 } 104 104 } … … 109 109 itcl::body Rappture::Unirect2d::destructor {} { 110 110 if { $_values != "" } { 111 111 blt::vector destroy $_values 112 112 } 113 113 } … … 125 125 lappend data "xmin" $_xMin "ymin" $_yMin "xmax" $_xMax "ymax" $_yMax 126 126 foreach key { axisorder xunits yunits units } { 127 128 129 130 127 set hint [hints $key] 128 if { $hint != "" } { 129 lappend data $key $hint 130 } 131 131 } 132 132 if { [$_values length] > 0 } { 133 133 lappend data "values" [$_values range 0 end] 134 134 } 135 135 return [Rappture::encoding::encode -as zb64 "$data"] … … 146 146 set dy [expr {($_yMax - $_yMin) / double($_yNum)}] 147 147 for { set i 0 } { $i < $_xNum } { incr i } { 148 149 150 151 152 148 set x [expr {$_xMin + (double($i) * $dx)}] 149 for { set j 0 } { $j < $_yNum } { incr j } { 150 set y [expr {$_yMin + (double($i) * $dy)}] 151 lappend data $x $y 152 } 153 153 } 154 154 return $data … … 163 163 itcl::body Rappture::Unirect2d::values {} { 164 164 if { [$_values length] > 0 } { 165 165 return [$_values range 0 end] 166 166 } 167 167 return "" … … 178 178 179 179 switch -- $which { 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 180 x - xlin - xlog { 181 set min $_xMin 182 set max $_xMax 183 set axis "xaxis" 184 } 185 y - ylin - ylog { 186 set min $_yMin 187 set max $_yMax 188 set axis "yaxis" 189 } 190 v - vlin - vlog - z - zlin - zlog { 191 if { [$_values length] > 0 } { 192 set min [blt::vector expr min($_values)] 193 set max [blt::vector expr max($_values)] 194 } else { 195 set min 0.0 196 set max 1.0 197 } 198 set axis "zaxis" 199 } 200 default { 201 error "unknown axis description \"$which\"" 202 } 203 203 } 204 204 # set val [$_field get $axis.min] … … 230 230 itcl::body Rappture::Unirect2d::hints { {keyword ""} } { 231 231 if {[info exists _hints(xlabel)] && "" != $_hints(xlabel) 232 233 232 && [info exists _hints(xunits)] && "" != $_hints(xunits)} { 233 set _hints(xlabel) "$_hints(xlabel) ($_hints(xunits))" 234 234 } 235 235 if {[info exists _hints(ylabel)] && "" != $_hints(ylabel) 236 237 236 && [info exists _hints(yunits)] && "" != $_hints(yunits)} { 237 set _hints(ylabel) "$_hints(ylabel) ($_hints(yunits))" 238 238 } 239 239 240 240 if {[info exists _hints(group)] && [info exists _hints(label)]} { 241 242 241 # pop-up help for each curve 242 set _hints(tooltip) $_hints(label) 243 243 } 244 244 if {$keyword != ""} { 245 246 247 248 245 if {[info exists _hints($keyword)]} { 246 return $_hints($keyword) 247 } 248 return "" 249 249 } 250 250 return [array get _hints] … … 255 255 set string [$obj get $path] 256 256 if { [scan $string "%d" value] != 1 || $value < 0 } { 257 258 257 puts stderr "can't get size \"$string\" of \"$path\"" 258 return 259 259 } 260 260 upvar $varName size … … 265 265 set string [$obj get $path] 266 266 if { [scan $string "%g" value] != 1 } { 267 267 return 268 268 } 269 269 upvar $varName number … … 274 274 set string [$obj get $path] 275 275 if { $string == "" } { 276 277 276 puts stderr "can't get string \"$string\" of \"$path\"" 277 return 278 278 } 279 279 upvar $varName str
Note: See TracChangeset
for help on using the changeset viewer.