Changeset 2025


Ignore:
Timestamp:
Jan 10, 2011 8:00:24 PM (10 years ago)
Author:
dkearney
Message:

updated menus for video particle and video distance widgets, fixing interaction between video widgets, making the drawing tools more responsible for talking to the dial2 object.

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/examples/video/piv/piv.tcl

    r2024 r2025  
    9999set vc [Rappture::VideoChooser $chooser.vc -variable ::previewVar]
    100100#$vc load [glob "/home/derrick/projects/piv/video/*.mp4"]
    101 $vc load [glob "/apps/piv/video/*.mp4"]
     101$vc load [glob "/apps/video/*.mp4"]
    102102
    103103pack $chooser.step1 -side top -anchor w -pady 8
     
    168168
    169169set f [$nb insert end video]
    170 set vs [Rappture::VideoScreen $f.viewer -fileopen {$nb current about}]
     170set vs [Rappture::VideoScreen $f.viewer -fileopen {
     171            $vs video stop
     172            $nb current about}]
    171173pack $vs -expand yes -fill both
    172174
  • trunk/gui/scripts/videodial2.tcl

    r2023 r2025  
    243243#
    244244# Clients use this to add a mark to the timeline
    245 #   type can be any one of loopstart, loopend, particle, arrow
     245#   type can be any one of loopstart, loopend, particle, measure
    246246#   where is interpreted based on the preceeding flag if available.
    247247#       in the default case, <where> is interpreted as a frame number
     
    459459
    460460        }
    461         "arrow" {
     461        "measure*" {
    462462            set radius 3
    463463            set amx0 $frx0
  • trunk/gui/scripts/videodistance.tcl

    r1979 r2025  
    2727    itk_option define -units units Units "m"
    2828    itk_option define -bindings bindings Bindings "enable"
     29    itk_option define -ondelete ondelete Ondelete ""
     30    itk_option define -onframe onframe Onframe ""
     31
    2932
    3033    constructor { name win args } {
     
    5659    protected method _fixBindings {status}
    5760
    58     private method _controls {args}
    59 
    6061    private variable _canvas        ""  ;# canvas which owns the object
    6162    private variable _name          ""  ;# id of the object
     
    6364    private variable _frame         0   ;# frame number where the object lives
    6465    private variable _coords        ""  ;# coords of the object, x0 y0 x1 y1
    65     private variable _menu          ""  ;# controls balloon widget
    6666    private variable _x             0   ;# x coord when "pressed" for motion
    6767    private variable _y             0   ;# y coord when "pressed" for motion
     
    8585
    8686    # setup the control menu
    87     set _menu $itk_component(hull).distancecontrols
    88     Rappture::Balloon ${_menu} -title "Controls"
    89     set controls [${_menu} component inner]
     87    set menu $itk_component(hull).distancecontrols
     88    itk_component add menu {
     89        Rappture::Balloon $itk_interior.menu -title "Controls"
     90    }
     91    set controls [$itk_component(menu) component inner]
    9092
    9193    set fg [option get $itk_component(hull) font Font]
     
    9799        -highlightthickness 0
    98100    entry $controls.measuremente -width 5 -background white
     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"
    99107
    100108    # x0
     
    126134            -min 0 -max [winfo height ${_canvas}] -width 4 -font "arial 9"
    127135
    128     # Hide control
    129     label $controls.hidel -text "Hide" -font $fg \
     136    # Delete control
     137    label $controls.deletel -text "Delete" -font $fg \
    130138        -highlightthickness 0
    131     Rappture::Switch $controls.hideb -showtext "false"
    132     $controls.hideb value false
     139    Rappture::Switch $controls.deleteb -showtext "false"
     140    $controls.deleteb value false
    133141
    134142    button $controls.saveb -text Save \
    135143        -relief raised -pady 0 -padx 0  -font "Arial 9" \
    136         -command [itcl::code $this _controls save] \
     144        -command [itcl::code $this Menu deactivate save] \
    137145        -activebackground grey90
    138146
    139147    button $controls.cancelb -text Cancel \
    140148        -relief raised -pady 0 -padx 0  -font "Arial 9" \
    141         -command [itcl::code $this _controls cancel] \
     149        -command [itcl::code $this Menu deactivate cancel] \
    142150        -activebackground grey90
    143151
    144152    grid $controls.measurementl    -column 0 -row 0 -sticky e
    145153    grid $controls.measuremente    -column 1 -row 0 -sticky w
     154    grid $controls.framenuml       -column 2 -row 0 -sticky e
     155    grid $controls.framenume       -column 3 -row 0 -sticky w
    146156    grid $controls.x0l             -column 0 -row 1 -sticky e
    147157    grid $controls.x0e             -column 1 -row 1 -sticky w
     
    152162    grid $controls.y1l             -column 2 -row 2 -sticky e
    153163    grid $controls.y1e             -column 3 -row 2 -sticky w
    154     grid $controls.hidel           -column 2 -row 3 -sticky e
    155     grid $controls.hideb           -column 3 -row 3 -sticky w
     164    grid $controls.deletel         -column 2 -row 3 -sticky e
     165    grid $controls.deleteb         -column 3 -row 3 -sticky w
    156166    grid $controls.saveb           -column 0 -row 4 -sticky e -columnspan 2
    157167    grid $controls.cancelb         -column 2 -row 4 -sticky w -columnspan 2
     
    161171    eval itk_initialize $args
    162172
    163     set _frame [uplevel \#0 $fncallback]
    164 
     173    # set the frame for the particle
     174    Frame [uplevel \#0 $fncallback]
    165175    bind ${_name}-FrameEvent <<Frame>> [itcl::code $this CatchEvent Frame]
    166176}
     
    171181itcl::body Rappture::VideoDistance::destructor {} {
    172182    configure -px2dist ""  ;# remove variable trace
     183
     184    Hide object
     185    _fixBindings disable
     186
     187    if {"" != $itk_option(-ondelete)} {
     188        uplevel \#0 $itk_option(-ondelete)
     189    }
     190
    173191}
    174192
     
    183201        }
    184202        set _frame $val
     203
     204        if {"" != $itk_option(-onframe)} {
     205            uplevel \#0 $itk_option(-onframe) ${_frame}
     206        }
    185207    } elseif {[llength $args] != 0} {
    186208        error "wrong # args: should be \"Frame ?<frameNumber>?\""
     
    224246    _fixValue
    225247    return ${_coords}
    226 }
    227 
    228 # ----------------------------------------------------------------------
    229 #   _controls - save or cancel adjustments made in the controls menu
    230 # ----------------------------------------------------------------------
    231 itcl::body Rappture::VideoDistance::_controls {args} {
    232     Menu deactivate $args
    233248}
    234249
     
    363378            set x [expr $x0+$x]
    364379            set y [expr $y0+$y]
    365             ${_menu} activate @$x,$y $dir
     380            $itk_component(menu) activate @$x,$y $dir
    366381
    367382            # update the values in the menu
    368             set controls [${_menu} component inner]
     383            set controls [$itk_component(menu) component inner]
    369384            foreach {x0 y0 x1 y1} ${_coords} break
    370385            $controls.measuremente delete 0 end
    371386            $controls.measuremente insert 0 "${_dist} ${_units}"
     387            $controls.framenume value ${_frame}
    372388            $controls.x0e value $x0
    373389            $controls.y0e value $y0
    374390            $controls.x1e value $x1
    375391            $controls.y1e value $y1
    376             $controls.hideb value false
     392            $controls.deleteb value false
    377393        }
    378394        "deactivate" {
    379             ${_menu} deactivate
     395            $itk_component(menu) deactivate
    380396            if {[llength $args] != 2} {
    381397                error "wrong # args: should be \"deactivate <status>\""
     
    384400            switch -- $status {
    385401                "save" {
    386                     set controls [${_menu} component inner]
     402                    set controls [$itk_component(menu) component inner]
     403
     404                    set newframenum [$controls.framenume value]
     405                    if {${_frame} != $newframenum} {
     406                        Frame $newframenum
     407                    }
    387408
    388409                    foreach {oldx0 oldy0 oldx1 oldy1} ${_coords} break
     
    413434                    }
    414435
    415                     if {[$controls.hideb value]} {
    416                         # FIXME: might need to do this in an after idle
    417                         #        if the value is updated, and the object
    418                         #        is scheduled to be hidden, writing
    419                         #        the new value to the screen will
    420                         #        occur after the object has been hidden,
    421                         #        resulting in a floating value.
    422                         Hide object
     436                    if {[$controls.deleteb value]} {
     437                        itcl::delete object $this
    423438                    }
    424439                }
     
    471486            set tagnum [lsearch [bindtags ${_canvas}] "${_name}-FrameEvent"]
    472487            if {$tagnum >= 0} {
    473                 bindtags ${_canvas} [lreplace [bindtags ${_canvas} $tagnum $tagnum]]
     488                bindtags ${_canvas} [lreplace [bindtags ${_canvas}] $tagnum $tagnum]
    474489            }
    475490        }
     
    533548    ${_canvas} delete ${_name}-val
    534549
    535     set controls [${_menu} component inner]
    536     if {![$controls.hideb value]} {
     550    set controls [$itk_component(menu) component inner]
     551    if {![$controls.deleteb value]} {
    537552        # if the object is not hidden, write _dist to the canvas
    538553        uplevel \#0 $writetextcb $args
  • trunk/gui/scripts/videoparticle.tcl

    r1979 r2025  
    2828    itk_option define -units units Units "m/s"
    2929    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 ""
    3033
    3134    constructor { name win args } {
     
    3639    }
    3740
    38     public method Delete {args}
    3941    public method Show {args}
    4042    public method Hide {args}
     
    6971    private variable _coords        ""  ;# list of coords where the object lives
    7072    private variable _halo           0  ;# about the diameter of the particle
    71     private variable _menu          ""  ;# particle controls balloon widget
    7273    private variable _x              0  ;# x coord when "pressed" for motion
    7374    private variable _y              0  ;# y coord when "pressed" for motion
     
    9394
    9495    # 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"
    104107
    105108    # 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] \
    109118        -activebackground grey90
    110119
    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
    117136
    118137    # finish configuring the particle
    119138    eval itk_initialize $args
    120139
    121     set _frame [uplevel \#0 $fncallback]
    122 
     140    # set the frame for the particle
     141    Frame [uplevel \#0 $fncallback]
    123142    bind ${_name}-FrameEvent <<Frame>> [itcl::code $this CatchEvent Frame]
    124143}
     
    129148itcl::body Rappture::VideoParticle::destructor {} {
    130149    configure -px2dist ""  ;# remove variable trace
    131 }
    132 
    133 # ----------------------------------------------------------------------
    134 # Delete - remove the particle
    135 # ----------------------------------------------------------------------
    136 itcl::body Rappture::VideoParticle::Delete {args} {
    137 
    138     Menu deactivate
    139150
    140151    Hide object
     
    151162        ${_prevnode} drawVectors
    152163    }
    153 }
    154 
     164
     165    _fixBindings disable
     166
     167    if {"" != $itk_option(-ondelete)} {
     168        uplevel \#0 $itk_option(-ondelete)
     169    }
     170}
    155171
    156172# ----------------------------------------------------------------------
     
    271287#   create
    272288#   activate x y
    273 #   deactivate
     289#   deactivate status
    274290# ----------------------------------------------------------------------
    275291itcl::body Rappture::VideoParticle::Menu {args} {
     
    288304            set x [expr $x0+$x]
    289305            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
    291312        }
    292313        "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            }
    294338        }
    295339        default {
     
    365409        }
    366410        set _frame $val
     411
     412        if {"" != $itk_option(-onframe)} {
     413            uplevel \#0 $itk_option(-onframe) ${_frame}
     414        }
    367415    } elseif {[llength $args] != 0} {
    368416        error "wrong # args: should be \"Frame ?<number>?\""
     
    466514            set tagnum [lsearch [bindtags ${_canvas}] "${_name}-FrameEvent"]
    467515            if {$tagnum >= 0} {
    468                 bindtags ${_canvas} [lreplace [bindtags ${_canvas} $tagnum $tagnum]]
     516                bindtags ${_canvas} [lreplace [bindtags ${_canvas}] $tagnum $tagnum]
    469517            }
    470518        }
     
    539587
    540588# ----------------------------------------------------------------------
     589# CONFIGURE: -framerange
     590# ----------------------------------------------------------------------
     591itcl::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# ----------------------------------------------------------------------
  • trunk/gui/scripts/videoscreen.tcl

    r2024 r2025  
    554554        }
    555555        "update" {
    556             # eventually seek [expr round($_settings($this-framenum))]
    557             Seek [expr round($_settings($this-framenum))]
     556            eventually seek [expr round($_settings($this-framenum))]
     557            # Seek [expr round($_settings($this-framenum))]
    558558        }
    559559        default {
     
    867867                        -bindleavecb [itcl::code $this togglePtrBind current] \
    868868                        -writetextcb [itcl::code $this writeText] \
     869                        -ondelete [itcl::code $itk_component(dialminor) mark remove $name] \
     870                        -onframe [itcl::code $itk_component(dialminor) mark add $name] \
    869871                        -px2dist [itcl::scope _px2dist] \
    870872                        -units "m" \
     
    873875            ${_obj} Coords $x $y $x $y
    874876            ${_obj} Show object
    875             $itk_component(dialminor) mark add arrow current
    876877        }
    877878        "drag" {
     
    929930                        -bindleavecb [itcl::code $this togglePtrBind current] \
    930931                        -trajcallback [itcl::code $this Trajectory] \
     932                        -ondelete [itcl::code $itk_component(dialminor) mark remove $name] \
     933                        -onframe [itcl::code $itk_component(dialminor) mark add $name] \
     934                        -framerange "0 ${_lastFrame}" \
    931935                        -halo 5 \
    932936                        -color green \
     
    935939            ${_obj} Coords $x $y
    936940            ${_obj} Show object
    937             $itk_component(dialminor) mark add $name current
     941            #$itk_component(dialminor) mark add $name current
    938942            # bind $itk_component(hull) <<Frame>> [itcl::code $itk_component(main).$name UpdateFrame]
    939943
    940             # link the new particle to the last particle added
    941             if {[llength ${_particles}] > 0} {
     944            # link the new particle to the last particle added, if it exists
     945            set lastp [lindex ${_particles} end]
     946            while {"" == [info commands $lastp]} {
     947                set _particles [lreplace ${_particles} end end]
     948                if {[llength ${_particles}] == 0} {
     949                    break
     950                }
    942951                set lastp [lindex ${_particles} end]
     952            }
     953            if {"" != [info commands $lastp]} {
    943954                $lastp Link ${_obj}
    944955            }
     
    946957            # add the particle to the list
    947958            lappend _particles ${_obj}
    948 
    949 #            set pm [Rappture::VideoParticleManager]
    950 #            $pm add $p0
    951 #            set plist [$pm list]
    952959        }
    953960        default {
Note: See TracChangeset for help on using the changeset viewer.