Changeset 1587 for trunk/gui/scripts/resultviewer.tcl
- Timestamp:
- Oct 23, 2009, 8:46:28 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/resultviewer.tcl
r1550 r1587 57 57 $_dispatcher register !scale 58 58 $_dispatcher dispatch $this !scale \ 59 59 [itcl::code $this _fixScale] 60 60 61 61 eval itk_initialize $args … … 67 67 itcl::body Rappture::ResultViewer::destructor {} { 68 68 foreach slot $_dataslots { 69 70 71 69 foreach obj $slot { 70 itcl::delete object $obj 71 } 72 72 } 73 73 } … … 87 87 # 88 88 for {set i [llength $_dataslots]} {$i <= $index} {incr i} { 89 89 lappend _dataslots "" 90 90 } 91 91 set slot [lindex $_dataslots $index] … … 103 103 itcl::body Rappture::ResultViewer::clear {{index ""}} { 104 104 if {"" != $index} { 105 106 107 108 109 110 111 112 105 # clear one result 106 if {$index >= 0 && $index < [llength $_dataslots]} { 107 set slot [lindex $_dataslots $index] 108 foreach dobj $slot { 109 itcl::delete object $dobj 110 } 111 set _dataslots [lreplace $_dataslots $index $index ""] 112 } 113 113 } else { 114 115 116 117 118 119 120 121 114 # clear all results 115 plot clear 116 foreach slot $_dataslots { 117 foreach dobj $slot { 118 itcl::delete object $dobj 119 } 120 } 121 set _dataslots "" 122 122 } 123 123 } … … 134 134 clear 135 135 if {"" != $xmlobj} { 136 137 136 add 0 $xmlobj "" 137 plot add 0 "" 138 138 } 139 139 } … … 152 152 itcl::body Rappture::ResultViewer::plot {option args} { 153 153 switch -- $option { 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 154 add { 155 set params "" 156 foreach {index opts} $args { 157 if {$index == "params"} { 158 set params $opts 159 continue 160 } 161 set reset "-color autoreset" 162 set slot [lindex $_dataslots $index] 163 foreach dobj $slot { 164 set settings "" 165 # start with color reset, only for first object in series 166 if {"" != $reset} { 167 set settings $reset 168 set reset "" 169 } 170 # add default settings from data object 171 if {[catch {$dobj hints style} style] == 0} { 172 eval lappend settings $style 173 } 174 if {[catch {$dobj hints type} type] == 0} { 175 if {"" != $type} { 176 eval lappend settings "-type $type" 177 } 178 } 179 # add override settings passed in here 180 eval lappend settings $opts 181 182 _plotAdd $dobj $settings 183 } 184 } 185 if {"" != $params && "" != $_mode} { 186 eval $_mode2widget($_mode) parameters $params 187 } 188 } 189 clear { 190 # clear the contents of the current mode 191 if {"" != $_mode} { 192 $_mode2widget($_mode) delete 193 } 194 } 195 default { 196 error "bad option \"$option\": should be add or clear" 197 } 198 198 } 199 199 } … … 209 209 itcl::body Rappture::ResultViewer::_plotAdd {dataobj {settings ""}} { 210 210 switch -- [$dataobj info class] { 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 211 ::Rappture::Histogram { 212 set mode "histogram" 213 if {![info exists _mode2widget($mode)]} { 214 set w $itk_interior.xy 215 Rappture::HistogramResult $w 216 set _mode2widget($mode) $w 217 } 218 } 219 ::Rappture::Curve { 220 set type [$dataobj hints type] 221 set mode "xy" 222 if { $type == "bars" } { 223 if {![info exists _mode2widget($mode)]} { 224 set w $itk_interior.xy 225 Rappture::BarResult $w 226 set _mode2widget($mode) $w 227 } 228 } else { 229 if {![info exists _mode2widget($mode)]} { 230 set w $itk_interior.xy 231 Rappture::XyResult $w 232 set _mode2widget($mode) $w 233 } 234 } 235 } 236 ::Rappture::Field { 237 set dims [lindex [lsort [$dataobj components -dimensions]] end] 238 switch -- $dims { 239 1D { 240 set mode "xy" 241 if {![info exists _mode2widget($mode)]} { 242 set w $itk_interior.xy 243 Rappture::XyResult $w 244 set _mode2widget($mode) $w 245 } 246 } 247 2D { 248 set mode "contour" 249 if {![info exists _mode2widget($mode)]} { 250 if { [$dataobj isunirect2d] } { 251 set resultMode "heightmap" 252 } else { 253 set resultMode "vtk" 254 } 255 set extents [$dataobj extents] 256 if { $extents > 1 } { 257 set resultMode "flowvis" 258 } 259 set w $itk_interior.contour 260 if { ![winfo exists $w] } { 261 Rappture::Field2DResult $w -mode $resultMode 262 } 263 set _mode2widget($mode) $w 264 } 265 } 266 3D { 267 set mode "field3D" 268 if {![info exists _mode2widget($mode)]} { 269 set mesh [$dataobj mesh] 270 set fmt [expr {("" != $mesh) ? "vtk" : "nanovis"}] 271 set extents [$dataobj extents] 272 if { $extents > 1 } { 273 set fmt "flowvis" 274 } 275 set w $itk_interior.field3D 276 Rappture::Field3DResult $w -mode $fmt 277 set _mode2widget($mode) $w 278 } 279 } 280 default { 281 error "can't handle [$dataobj components -dimensions] field" 282 } 283 } 284 } 285 ::Rappture::Mesh { 286 switch -- [$dataobj dimensions] { 287 2 { 288 set mode "mesh" 289 if {![info exists _mode2widget($mode)]} { 290 set w $itk_interior.mesh 291 Rappture::MeshResult $w 292 set _mode2widget($mode) $w 293 } 294 } 295 default { 296 error "can't handle [$dataobj dimensions]D field" 297 } 298 } 299 } 300 ::Rappture::Table { 301 set cols [Rappture::EnergyLevels::columns $dataobj] 302 if {"" != $cols} { 303 set mode "energies" 304 if {![info exists _mode2widget($mode)]} { 305 set w $itk_interior.energies 306 Rappture::EnergyLevels $w 307 set _mode2widget($mode) $w 308 } 309 } 310 } 311 ::Rappture::LibraryObj { 312 switch -- [$dataobj element -as type] { 313 string - log { 314 set mode "log" 315 if {![info exists _mode2widget($mode)]} { 316 set w $itk_interior.log 317 Rappture::TextResult $w 318 set _mode2widget($mode) $w 319 } 320 } 321 structure { 322 set mode "structure" 323 if {![info exists _mode2widget($mode)]} { 324 set w $itk_interior.struct 325 Rappture::DeviceResult $w 326 set _mode2widget($mode) $w 327 } 328 } 329 number - integer { 330 set mode "number" 331 if {![info exists _mode2widget($mode)]} { 332 set w $itk_interior.number 333 Rappture::NumberResult $w 334 set _mode2widget($mode) $w 335 } 336 } 337 boolean - choice { 338 set mode "value" 339 if {![info exists _mode2widget($mode)]} { 340 set w $itk_interior.value 341 Rappture::ValueResult $w 342 set _mode2widget($mode) $w 343 } 344 } 345 } 346 } 347 ::Rappture::Image { 348 set mode "image" 349 if {![info exists _mode2widget($mode)]} { 350 set w $itk_interior.image 351 Rappture::ImageResult $w 352 set _mode2widget($mode) $w 353 } 354 } 355 ::Rappture::Sequence { 356 set mode "sequence" 357 if {![info exists _mode2widget($mode)]} { 358 set w $itk_interior.image 359 Rappture::SequenceResult $w 360 set _mode2widget($mode) $w 361 } 362 } 363 default { 364 error "don't know how to plot <$type> data" 365 } 366 366 } 367 367 368 368 if {$mode != $_mode && $_mode != ""} { 369 370 371 372 369 set nactive [llength [$_mode2widget($_mode) get]] 370 if {$nactive > 0} { 371 return ;# mixing data that doesn't mix -- ignore it! 372 } 373 373 } 374 374 375 375 # are we plotting in a new mode? then change widgets 376 376 if {$_mode2widget($mode) != [pack slaves $itk_interior]} { 377 378 379 380 381 382 383 384 377 # remove any current window 378 foreach w [pack slaves $itk_interior] { 379 pack forget $w 380 } 381 pack $_mode2widget($mode) -expand yes -fill both 382 383 set _mode $mode 384 $_dispatcher event -idle !scale 385 385 } 386 386 $_mode2widget($mode) add $dataobj $settings … … 397 397 itcl::body Rappture::ResultViewer::_fixScale {args} { 398 398 if {"" != $_mode} { 399 400 401 402 403 404 405 399 set dlist "" 400 foreach slot $_dataslots { 401 foreach dobj $slot { 402 lappend dlist $dobj 403 } 404 } 405 eval $_mode2widget($_mode) scale $dlist 406 406 } 407 407 } … … 419 419 itcl::body Rappture::ResultViewer::download {option args} { 420 420 if {"" == $_mode} { 421 421 return "" 422 422 } 423 423 return [eval $_mode2widget($_mode) download $option $args] … … 433 433 set type [$xmlobj element -as type $path] 434 434 switch -- $type { 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 435 curve { 436 return [Rappture::Curve ::#auto $xmlobj $path] 437 } 438 histogram { 439 return [Rappture::Histogram ::#auto $xmlobj $path] 440 } 441 field { 442 return [Rappture::Field ::#auto $xmlobj $path] 443 } 444 mesh { 445 return [Rappture::Mesh ::#auto $xmlobj $path] 446 } 447 table { 448 return [Rappture::Table ::#auto $xmlobj $path] 449 } 450 image { 451 return [Rappture::Image ::#auto $xmlobj $path] 452 } 453 sequence { 454 return [Rappture::Sequence ::#auto $xmlobj $path] 455 } 456 string - log { 457 return [$xmlobj element -as object $path] 458 } 459 structure { 460 return [$xmlobj element -as object $path] 461 } 462 number - integer - boolean - choice { 463 return [$xmlobj element -as object $path] 464 } 465 time - status { 466 return "" 467 } 468 468 } 469 469 error "don't know how to plot <$type> data" … … 477 477 set h [winfo pixels $itk_component(hull) $itk_option(-height)] 478 478 if {$w == 0 || $h == 0} { 479 479 pack propagate $itk_component(hull) yes 480 480 } else { 481 482 481 component hull configure -width $w -height $h 482 pack propagate $itk_component(hull) no 483 483 } 484 484 } … … 491 491 set w [winfo pixels $itk_component(hull) $itk_option(-width)] 492 492 if {$w == 0 || $h == 0} { 493 493 pack propagate $itk_component(hull) yes 494 494 } else { 495 496 497 } 498 } 495 component hull configure -width $w -height $h 496 pack propagate $itk_component(hull) no 497 } 498 }
Note: See TracChangeset
for help on using the changeset viewer.