Changeset 2025 for trunk/gui/scripts/videoparticle.tcl
- Timestamp:
- Jan 10, 2011, 8:00:24 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/videoparticle.tcl
r1979 r2025 28 28 itk_option define -units units Units "m/s" 29 29 itk_option define -bindings bindings Bindings "enable" 30 itk_option define -ondelete ondelete Ondelete "" 31 itk_option define -onframe onframe Onframe "" 32 itk_option define -framerange framerange Framerange "" 30 33 31 34 constructor { name win args } { … … 36 39 } 37 40 38 public method Delete {args}39 41 public method Show {args} 40 42 public method Hide {args} … … 69 71 private variable _coords "" ;# list of coords where the object lives 70 72 private variable _halo 0 ;# about the diameter of the particle 71 private variable _menu "" ;# particle controls balloon widget72 73 private variable _x 0 ;# x coord when "pressed" for motion 73 74 private variable _y 0 ;# y coord when "pressed" for motion … … 93 94 94 95 # setup the particle control menu 95 set _menu $itk_component(hull).particlecontrols 96 Rappture::Balloon ${_menu} -title "Particle Controls" 97 set controls [${_menu} component inner] 98 99 # Link control 100 #button $controls.link -text Link \ 101 # -relief flat -pady 0 -padx 0 -font "Arial 9" \ 102 # -command [itcl::code $this Link] -overrelief flat \ 103 # -activebackground grey90 96 itk_component add menu { 97 Rappture::Balloon $itk_interior.particlecontrols -title "Particle Controls" 98 } 99 100 set controls [$itk_component(menu) component inner] 101 102 # Frame number control 103 label $controls.framenuml -text "Frame" -font "Arial 9"\ 104 -highlightthickness 0 105 Rappture::Spinint $controls.framenume \ 106 -min 0 -width 5 -font "arial 9" 104 107 105 108 # Delete control 106 button $controls.delete -text Delete \ 107 -relief flat -pady 0 -padx 0 -font "Arial 9" \ 108 -command [itcl::code $this Delete frame] -overrelief flat \ 109 label $controls.deletel -text "Delete" -font "Arial 9" \ 110 -highlightthickness 0 111 Rappture::Switch $controls.deleteb -showtext "false" 112 $controls.deleteb value false 113 114 # Save button 115 button $controls.saveb -text Save \ 116 -relief raised -pady 0 -padx 0 -font "Arial 9" \ 117 -command [itcl::code $this Menu deactivate save] \ 109 118 -activebackground grey90 110 119 111 #grid $controls.link -column 0 -row 0 -sticky w 112 grid $controls.delete -column 0 -row 1 -sticky w 113 # grid $controls.rename -column 0 -row 2 -sticky w 114 # grid $controls.recolor -column 0 -row 3 -sticky w 115 116 grid columnconfigure $controls 0 -weight 1 120 # Cancel button 121 button $controls.cancelb -text Cancel \ 122 -relief raised -pady 0 -padx 0 -font "Arial 9" \ 123 -command [itcl::code $this Menu deactivate cancel] \ 124 -activebackground grey90 125 126 127 grid $controls.framenuml -column 0 -row 0 -sticky e 128 grid $controls.framenume -column 1 -row 0 -sticky w 129 grid $controls.deletel -column 0 -row 1 -sticky e 130 grid $controls.deleteb -column 1 -row 1 -sticky w 131 grid $controls.saveb -column 0 -row 2 -sticky e 132 grid $controls.cancelb -column 1 -row 2 -sticky w 133 134 135 grid columnconfigure $controls 0 -weight 1 117 136 118 137 # finish configuring the particle 119 138 eval itk_initialize $args 120 139 121 set _frame [uplevel \#0 $fncallback]122 140 # set the frame for the particle 141 Frame [uplevel \#0 $fncallback] 123 142 bind ${_name}-FrameEvent <<Frame>> [itcl::code $this CatchEvent Frame] 124 143 } … … 129 148 itcl::body Rappture::VideoParticle::destructor {} { 130 149 configure -px2dist "" ;# remove variable trace 131 }132 133 # ----------------------------------------------------------------------134 # Delete - remove the particle135 # ----------------------------------------------------------------------136 itcl::body Rappture::VideoParticle::Delete {args} {137 138 Menu deactivate139 150 140 151 Hide object … … 151 162 ${_prevnode} drawVectors 152 163 } 153 } 154 164 165 _fixBindings disable 166 167 if {"" != $itk_option(-ondelete)} { 168 uplevel \#0 $itk_option(-ondelete) 169 } 170 } 155 171 156 172 # ---------------------------------------------------------------------- … … 271 287 # create 272 288 # activate x y 273 # deactivate 289 # deactivate status 274 290 # ---------------------------------------------------------------------- 275 291 itcl::body Rappture::VideoParticle::Menu {args} { … … 288 304 set x [expr $x0+$x] 289 305 set y [expr $y0+$y] 290 ${_menu} activate @$x,$y $dir 306 $itk_component(menu) activate @$x,$y $dir 307 308 # update the values in the menu 309 set controls [$itk_component(menu) component inner] 310 $controls.framenume value ${_frame} 311 $controls.deleteb value false 291 312 } 292 313 "deactivate" { 293 ${_menu} deactivate 314 $itk_component(menu) deactivate 315 if {[llength $args] != 2} { 316 error "wrong # args: should be \"deactivate <status>\"" 317 } 318 set status [lindex $args 1] 319 switch -- $status { 320 "save" { 321 set controls [$itk_component(menu) component inner] 322 323 set newframenum [$controls.framenume value] 324 if {${_frame} != $newframenum} { 325 Frame $newframenum 326 } 327 328 if {[$controls.deleteb value]} { 329 itcl::delete object $this 330 } 331 } 332 "cancel" { 333 } 334 "default" { 335 error "bad value \"$status\": should be one of save, cancel" 336 } 337 } 294 338 } 295 339 default { … … 365 409 } 366 410 set _frame $val 411 412 if {"" != $itk_option(-onframe)} { 413 uplevel \#0 $itk_option(-onframe) ${_frame} 414 } 367 415 } elseif {[llength $args] != 0} { 368 416 error "wrong # args: should be \"Frame ?<number>?\"" … … 466 514 set tagnum [lsearch [bindtags ${_canvas}] "${_name}-FrameEvent"] 467 515 if {$tagnum >= 0} { 468 bindtags ${_canvas} [lreplace [bindtags ${_canvas} $tagnum $tagnum]]516 bindtags ${_canvas} [lreplace [bindtags ${_canvas}] $tagnum $tagnum] 469 517 } 470 518 } … … 539 587 540 588 # ---------------------------------------------------------------------- 589 # CONFIGURE: -framerange 590 # ---------------------------------------------------------------------- 591 itcl::configbody Rappture::VideoParticle::framerange { 592 if {"" == $itk_option(-framerange)} { 593 return 594 } 595 if {[llength $itk_option(-framerange)] != 2} { 596 error "bad value \"$itk_option(-framerange)\": should be 2 integers" 597 } 598 foreach {min max} $itk_option(-framerange) break 599 if {!([string is integer $min]) || !([string is integer $max])} { 600 error "bad value \"$itk_option(-framerange)\": should be 2 integers" 601 } 602 set controls [$itk_component(menu) component inner] 603 $controls.framenume configure -min $min -max $max 604 } 605 606 # ----------------------------------------------------------------------
Note: See TracChangeset
for help on using the changeset viewer.