Changeset 1394 for trunk/gui/scripts/sequenceresult.tcl
- Timestamp:
- Apr 14, 2009, 1:48:57 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/sequenceresult.tcl
r1342 r1394 73 73 74 74 itk_component add player { 75 75 frame $itk_interior.player 76 76 } 77 77 pack $itk_component(player) -side bottom -fill x … … 79 79 80 80 itk_component add play { 81 82 83 81 button $itk_component(player).play \ 82 -bitmap [Rappture::icon play] \ 83 -command [itcl::code $this play] 84 84 } 85 85 grid $itk_component(play) -row 0 -rowspan 2 -column 0 \ 86 86 -ipadx 2 -padx {0 4} -pady 4 -sticky nsew 87 87 88 88 itk_component add dial { 89 90 91 92 89 Rappture::Radiodial $itk_component(player).dial \ 90 -length 10 -valuewidth 0 -valuepadding 0 -padding 6 \ 91 -linecolor "" -activelinecolor "" \ 92 -knobimage [Rappture::icon knob2] -knobposition center@middle 93 93 } { 94 95 94 usual 95 keep -dialprogresscolor 96 96 } 97 97 grid $itk_component(dial) -row 1 -column 1 -sticky ew … … 99 99 100 100 itk_component add info { 101 101 frame $itk_component(player).info 102 102 } 103 103 grid $itk_component(info) -row 0 -column 1 -columnspan 2 -sticky ew 104 104 105 105 itk_component add indexLabel { 106 106 label $itk_component(info).ilabel 107 107 } { 108 109 108 usual 109 rename -font -boldfont boldFont Font 110 110 } 111 111 pack $itk_component(indexLabel) -side left 112 112 113 113 itk_component add indexValue { 114 114 label $itk_component(info).ivalue -padx 0 115 115 } 116 116 pack $itk_component(indexValue) -side left … … 118 118 # add an element.about.label stanza 119 119 itk_component add eleLabel { 120 120 label $itk_component(info).elabel -padx 10 121 121 } 122 122 pack $itk_component(eleLabel) -side left 123 123 124 124 itk_component add options { 125 126 125 button $itk_component(player).options -text "Options..." \ 126 -padx 1 -pady 0 -relief flat -overrelief raised 127 127 } 128 128 grid $itk_component(options) -row 1 -column 2 -sticky sw … … 135 135 136 136 Rappture::Balloon $itk_component(hull).popup \ 137 137 -title "Player Settings" -padx 4 -pady 4 138 138 set inner [$itk_component(hull).popup component inner] 139 139 … … 141 141 grid $inner.loopl -row 0 -column 0 -sticky e 142 142 radiobutton $inner.loopOn -text "Play once and stop" -font $fn \ 143 143 -variable ::Rappture::SequenceResult::_play(loop) -value 0 144 144 grid $inner.loopOn -row 0 -column 1 -sticky w 145 145 radiobutton $inner.loopOff -text "Play continuously" -font $fn \ 146 146 -variable ::Rappture::SequenceResult::_play(loop) -value 1 147 147 grid $inner.loopOff -row 1 -column 1 -sticky w 148 148 grid rowconfigure $inner 2 -minsize 8 … … 155 155 pack $inner.speed.slowl -side left 156 156 ::scale $inner.speed.value -from 100 -to 1 \ 157 158 157 -showvalue 0 -orient horizontal \ 158 -variable ::Rappture::SequenceResult::_play(speed) 159 159 pack $inner.speed.value -side left 160 160 label $inner.speed.fastl -text "Faster" -font $fn … … 162 162 163 163 $itk_component(options) configure -command \ 164 164 [list $itk_component(hull).popup activate $itk_component(options) above] 165 165 166 166 # … … 168 168 # 169 169 itk_component add area { 170 170 frame $itk_interior.area 171 171 } 172 172 pack $itk_component(area) -expand yes -fill both … … 193 193 itcl::body Rappture::SequenceResult::add {dataobj {settings ""}} { 194 194 array set params { 195 196 197 198 199 200 201 195 -color auto 196 -brightness 0 197 -width 1 198 -raise 0 199 -linestyle solid 200 -description "" 201 -param "" 202 202 } 203 203 foreach {opt val} $settings { 204 205 206 207 204 if {![info exists params($opt)]} { 205 error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]" 206 } 207 set params($opt) $val 208 208 } 209 209 210 210 if {$params(-raise) && "" == $_topmost} { 211 211 set _topmost $dataobj 212 212 } 213 213 lappend _dlist $dataobj … … 227 227 set i [lsearch $_dlist $_topmost] 228 228 if {$i >= 0} { 229 230 229 set dlist [lreplace $dlist $i $i] 230 set dlist [linsert $dlist 0 $_topmost] 231 231 } 232 232 return $dlist … … 241 241 itcl::body Rappture::SequenceResult::delete {args} { 242 242 if {[llength $args] == 0} { 243 set args $_dlist 244 } 243 set args $_dlist 244 } 245 pause 245 246 246 247 # delete all specified curves 247 248 set changed 0 248 249 foreach dataobj $args { 249 250 251 252 253 254 255 256 257 250 set pos [lsearch -exact $_dlist $dataobj] 251 if {$pos >= 0} { 252 set _dlist [lreplace $_dlist $pos $pos] 253 set changed 1 254 255 if {$dataobj == $_topmost} { 256 set _topmost "" 257 } 258 } 258 259 } 259 260 260 261 # if anything changed, then rebuild the plot 261 262 if {$changed} { 262 263 $_dispatcher event -idle !rebuild 263 264 } 264 265 } … … 292 293 } 293 294 switch $option { 294 295 coming { 295 296 return [$itk_component(area).viewer download coming] 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 297 } 298 controls { 299 return [eval $itk_component(area).viewer download controls $args] 300 } 301 now { 302 if {0} { 303 # produce a movie of results 304 set rval "" 305 if {"" != $_topmost} { 306 set max [$_topmost size] 307 set all "" 308 for {set i 0} {$i < $max} {incr i} { 309 set dataobj [lindex [$_topmost value $i] 0] 310 if {[catch {$dataobj tkimage} imh] == 0} { 311 lappend all $imh 312 } 313 } 314 if {[llength $all] > 0} { 315 set delay [expr {int(ceil(pow($_play(speed)/10.0+2,2.0)*15))}] 316 set rval [eval Rappture::icon::gif_animate $delay $all] 317 } 318 } 319 if {[string length $rval] > 0} { 320 return [list .gif $rval] 321 } 322 return "" 323 } 324 325 # otherwise, return download of single frame 326 return [$itk_component(area).viewer download now] 327 } 328 default { 329 error "bad option \"$option\": should be coming, controls, now" 330 } 330 331 } 331 332 } … … 346 347 # at the end? then restart fresh 347 348 if {$_pos >= [llength $_indices]-1} { 348 349 goto 0 349 350 } 350 351 351 352 # toggle the button to "pause" mode 352 353 $itk_component(play) configure \ 353 354 354 -bitmap [Rappture::icon pause] \ 355 -command [itcl::code $this pause] 355 356 356 357 # schedule the first frame … … 367 368 itcl::body Rappture::SequenceResult::pause {} { 368 369 if {"" != $_afterId} { 369 370 370 catch {after cancel $_afterId} 371 set _afterId "" 371 372 } 372 373 373 374 # toggle the button to "play" mode 374 375 $itk_component(play) configure \ 375 376 376 -bitmap [Rappture::icon play] \ 377 -command [itcl::code $this play] 377 378 } 378 379 … … 386 387 itcl::body Rappture::SequenceResult::goto {{newval ""}} { 387 388 if {"" == $newval} { 388 389 return $_pos 389 390 } 390 391 set _pos $newval … … 402 403 itcl::body Rappture::SequenceResult::_rebuild {args} { 403 404 if {"" == $_topmost && [llength $_dlist] > 0} { 404 405 set _topmost [lindex $_dlist 0] 405 406 } 406 407 … … 411 412 set viewer $itk_component(area).viewer 412 413 if {[winfo exists $viewer]} { 413 414 415 416 417 418 419 420 414 if {"" == $_topmost} { 415 pack forget $viewer 416 pack forget $itk_component(player) 417 return 418 } else { 419 pack $viewer -expand yes -fill both 420 pack $itk_component(player) -side bottom -fill x 421 } 421 422 } else { 422 423 424 425 426 427 428 429 430 431 432 433 434 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 423 if {"" == $_topmost} { 424 return 425 } 426 427 set type "" 428 if {[$_topmost size] > 0} { 429 set dataobj [lindex [$_topmost value 0] 0] 430 set type [$dataobj info class] 431 } 432 switch -- $type { 433 ::Rappture::Curve { 434 Rappture::XyResult $viewer 435 pack $viewer -expand yes -fill both 436 } 437 ::Rappture::Image { 438 Rappture::ImageResult $viewer 439 pack $viewer -expand yes -fill both 440 } 441 ::Rappture::Field { 442 set dimensions "" 443 set dim "" 444 foreach dim [$dataobj components -dimensions] { 445 # check to see if the dimensions are the same 446 # for all elements of the field. i dont think 447 # we can display fields of differing dimensions 448 # within the same field object. 449 if {"" != $dimensions} { 450 if {$dimensions != $dim} { 451 error "don't know how to view sequences of $type\ 452 with dimensions as follows:\ 453 [$dataobj components -dimensions]" 454 } 455 } else { 456 set dimensions $dim 457 } 458 } 459 switch -- $dimensions { 460 2D { 460 461 if { [$dataobj isunirect2d] } { 461 462 set mode "heightmap" … … 464 465 } 465 466 Rappture::Field2DResult $viewer -mode $mode 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 467 } 468 3D { 469 Rappture::Field3DResult $viewer 470 } 471 default { 472 error "don't know how to view sequences of $type\ 473 with $dimensions dimensions" 474 } 475 } 476 pack $viewer -expand yes -fill both 477 } 478 ::Rappture::LibraryObj { 479 switch -- [$dataobj element -as type] { 480 structure { 481 Rappture::DeviceResult $viewer 482 pack $viewer -expand yes -fill both 483 } 484 default { 485 error "don't know how to view sequences of [$dataobj element -as type]" 486 } 487 } 488 } 489 default { 490 puts stderr "don't know how to view sequences of type \"$type\"" 490 491 puts stderr "Is the sequence empty?" 491 492 return 492 493 493 } 494 } 494 495 } 495 496 … … 505 506 set all "" 506 507 for {set i 0} {$i < $max} {incr i} { 507 508 eval lappend all [$_topmost value $i] 508 509 } 509 510 eval $viewer scale $all … … 511 512 set _indices "" 512 513 for {set i 0} {$i < $max} {incr i} { 513 514 515 514 set index [$_topmost index $i] 515 eval $itk_component(dial) add $index 516 lappend _indices [lindex $index 0] 516 517 } 517 518 _fixValue … … 530 531 531 532 if {$_pos > $last} { 532 533 534 535 536 537 538 533 if {$_play(loop)} { 534 set _pos 0 535 } else { 536 set _pos $last 537 pause 538 return 539 } 539 540 } 540 541 goto $_pos … … 553 554 set viewer $itk_component(area).viewer 554 555 if {![winfo exists $viewer]} { 556 return 557 } 558 $viewer delete 559 if { $_topmost == "" } { 555 560 return 556 561 } 557 558 # if the indexLabel is empty, don't show indexValue 559 if {"" != [$_topmost hints indexlabel]} { 560 set val [$itk_component(dial) get -format label current] 561 $itk_component(indexValue) configure -text "= $val" 562 set _pos [lsearch -glob $_indices $val*] 563 } 564 562 if { "" != [$_topmost hints indexlabel] } { 563 set val [$itk_component(dial) get -format label current] 564 $itk_component(indexValue) configure -text "= $val" 565 set _pos [lsearch -glob $_indices $val*] 566 } 565 567 # populate the label for this element 566 568 $itk_component(eleLabel) configure -text "[$_topmost label $_pos]" 567 568 $viewer delete 569 if {"" != $_topmost} { 570 foreach dataobj [$_topmost value $_pos] { 571 set settings "-color autoreset -width 2" 572 if {[catch {$dataobj hints style} style] == 0} { 573 eval lappend settings $style 574 } 575 $viewer add $dataobj $settings 576 } 577 } 578 } 569 foreach dataobj [$_topmost value $_pos] { 570 set settings "-color autoreset -width 2" 571 if {[catch {$dataobj hints style} style] == 0} { 572 eval lappend settings $style 573 } 574 $viewer add $dataobj $settings 575 } 576 }
Note: See TracChangeset
for help on using the changeset viewer.