Ignore:
Timestamp:
Jan 10, 2011, 8:00:24 PM (14 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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# ----------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.