Ignore:
Timestamp:
Oct 25, 2010 3:16:06 PM (14 years ago)
Author:
gah
Message:
 
Location:
branches/blt4/gui/scripts
Files:
7 added
5 edited

Legend:

Unmodified
Added
Removed
  • branches/blt4/gui/scripts/filexfer.tcl

    r1897 r1932  
    9191            }
    9292        }
     93        uploadWord {
     94            if {[Rappture::filexfer::enabled]} {
     95                return "Upload"
     96            } else {
     97                return "Browse"
     98            }
     99        }
    93100        download {
    94101            if {[Rappture::filexfer::enabled]} {
     
    106113        }
    107114        default {
    108             error "bad option \"$operation\": should be upload, download, or downloadWord"
     115            error "bad option \"$operation\": should be upload, uploadWord, download, or downloadWord"
    109116        }
    110117    }
  • branches/blt4/gui/scripts/imageentry.tcl

    r1923 r1932  
    151151        set newval [lindex $args 0]
    152152        if {[string length $newval] > 0} {
    153             set imh [image create photo -data $newval]
     153            set imh [image create picture -data $newval]
    154154        } else {
    155155            set imh ""
     
    176176    set fmt [$_owner xml get $_path.convert]
    177177    if {"" != $fmt && "" != $_imh} {
    178         if {"pgm" == $fmt} { set fmt "ppm -grayscale" }
    179         set bytes [eval $_imh data -format $fmt]
    180         set bytes [Rappture::encoding::decode -as b64 $bytes]
     178        switch -- $fmt {
     179            "pgm" - "ppm" {
     180                $_imh export pbm -data bytes
     181            }
     182            "jpeg" {
     183                $_imh export jpg -data bytes
     184            }
     185            "tiff" {
     186                $_imh export tif -data bytes
     187            }
     188            "bmp" - "png" - "xbm" - "xpm" {
     189                $_imh export $fmt -data bytes
     190            }
     191            default {
     192                error "unknown image format \"$fmt\""
     193            }
     194        }
    181195    }
    182196    return $bytes
  • branches/blt4/gui/scripts/videoviewer.tcl

    r1919 r1932  
    1616package require RapptureGUI
    1717
    18 option add *VideoViewer.width 5i widgetDefault
     18#option add *VideoViewer.width 5i widgetDefault
    1919option add *VideoViewer*cursor crosshair widgetDefault
    20 option add *VideoViewer.height 4i widgetDefault
     20#option add *VideoViewer.height 4i widgetDefault
    2121option add *VideoViewer.foreground black widgetDefault
    2222option add *VideoViewer.controlBackground gray widgetDefault
     
    3434    itk_option define -plotbackground plotBackground Background ""
    3535    itk_option define -plotoutline plotOutline PlotOutline ""
     36    itk_option define -width width Width -1
     37    itk_option define -height height Height -1
     38    itk_option define -controls controls Controls "show"
    3639
    3740    constructor { args } {
     
    4447    public method load {filename}
    4548    public method video {args}
     49    public method query {type}
    4650
    4751    protected method togglePtrBind {pbvar}
     
    5862    protected method updateMeasurements {}
    5963    protected method calculateTrajectory {args}
     64    protected method fixSize {}
     65
     66
    6067
    6168    private common   _settings
    6269
    63     private variable _width 0
    64     private variable _height 0
     70    private variable _width -1
     71    private variable _height -1
     72    private variable _controls ""
    6573    private variable _x0 0          ;# start x for rubberbanding
    6674    private variable _y0 0          ;# start y for rubberbanding
     
    399407# ----------------------------------------------------------------------
    400408itcl::body Rappture::VideoViewer::load {filename} {
    401     set _movie [Rappture::Video $filename]
     409
     410    # open the file
     411
     412    set _movie [Rappture::Video "file" $filename]
    402413    set _framerate [${_movie} get framerate]
    403414    set _mspf [expr round(((1.0/${_framerate})*1000)/pow(2,[$itk_component(speed) value]-1))]
    404     # set _mspf 7
    405415    puts "framerate = ${_framerate}"
    406416    puts "mspf = ${_mspf}"
    407417
     418    ${_movie} seek 0
     419
     420    # setup the image display
     421
    408422    set _imh [image create photo]
    409     $_imh put [$_movie next]
     423    foreach {w h} [query dimensions] break
     424    if {${_width} == -1} {
     425        set _width $w
     426    }
     427    if {${_height} == -1} {
     428        set _height $h
     429    }
     430#    ${_imh} put [$_movie get image ${_width} ${_height}]
    410431    $itk_component(main) create image 0 0 -anchor nw -image $_imh
     432
     433    # setup timings for playing video
    411434
    412435    set _lastFrame [$_movie get position end]
     
    424447    $itk_component(framenum) configure -max ${_lastFrame} -width $cnt
    425448
    426     set pch [$itk_component(pointercontrols) cget -height]
    427     set mch [$itk_component(moviecontrols) cget -height]
    428     set pch 30
    429     set mch 30
     449    fixSize
     450}
     451
     452# ----------------------------------------------------------------------
     453# fixSize
     454# ----------------------------------------------------------------------
     455itcl::body Rappture::VideoViewer::fixSize {} {
     456
     457    if {[string compare "" ${_movie}] == 0} {
     458        return
     459    }
     460
     461    # get an image with the new size
     462    ${_imh} put [${_movie} get image ${_width} ${_height}]
     463
     464    # fix the dimesions of the canvas
     465    $itk_component(main) configure -width ${_width} -height ${_height}
     466
    430467    $itk_component(main) configure -scrollregion [$itk_component(main) bbox all]
    431     foreach { x0 y0 x1 y1 } [$itk_component(main) bbox all] break
    432     set w [expr abs($x1-$x0)]
    433     set h [expr abs($y1-$y0+$pch+$mch)]
    434     # $itk_component(main) configure -width $w -height $h
    435     .main configure -width $w -height $h
    436 
     468    #foreach { x0 y0 x1 y1 } [$itk_component(main) bbox all] break
     469    #set w [expr abs($x1-$x0)]
     470    #set h [expr abs($y1-$y0)]
     471    #$itk_component(main) configure -width $w -height $h
     472    # component hull configure -width $w -height $h
    437473}
    438474
     
    483519
    484520# ----------------------------------------------------------------------
     521# query - query things about the video
     522# ----------------------------------------------------------------------
     523itcl::body Rappture::VideoViewer::query { type } {
     524    set ret ""
     525    switch -- $type {
     526        "dimensions" {
     527            set ret [${_movie} size]
     528        }
     529        default {
     530            error "bad type \"$type\": should be dimensions."
     531        }
     532    }
     533    return $ret
     534}
     535
     536# ----------------------------------------------------------------------
    485537# togglePtrCtrl - choose pointer mode:
    486538#                 rectangle, distance, measure, particlemark
     
    617669
    618670    # display the next frame
    619     $_imh put [$_movie next]
     671    $_movie next
     672    $_imh put [$_movie get image ${_width} ${_height}]
    620673
    621674    # update the dial and framenum widgets
     
    670723        error "bad value: \"$val\": should be \"seek \[-percent\] value\""
    671724    }
    672     $_imh put [$_movie seek $val]
    673     set cur [$_movie get position cur]
     725    ${_movie} seek $val
     726    ${_imh} put [${_movie} get image ${_width} ${_height}]
     727    set cur [${_movie} get position cur]
    674728    set _settings($this-currenttime) [expr double($cur) / double(${_lastFrame})]
    675729}
     
    10061060}
    10071061
     1062# ----------------------------------------------------------------------
     1063# OPTION: -width
     1064# ----------------------------------------------------------------------
     1065itcl::configbody Rappture::VideoViewer::width {
     1066    # $_dispatcher event -idle !fixsize
     1067    if {[string is integer $itk_option(-width)] == 0} {
     1068        error "bad value: \"$itk_option(-width)\": width should be an integer"
     1069    }
     1070    set _width $itk_option(-width)
     1071    after idle [itcl::code $this fixSize]
     1072}
     1073
     1074# ----------------------------------------------------------------------
     1075# OPTION: -height
     1076# ----------------------------------------------------------------------
     1077itcl::configbody Rappture::VideoViewer::height {
     1078    # $_dispatcher event -idle !fixsize
     1079    if {[string is integer $itk_option(-height)] == 0} {
     1080        error "bad value: \"$itk_option(-height)\": height should be an integer"
     1081    }
     1082    set _height $itk_option(-height)
     1083    after idle [itcl::code $this fixSize]
     1084}
     1085
     1086# ----------------------------------------------------------------------
     1087# OPTION: -controls
     1088# ----------------------------------------------------------------------
     1089itcl::configbody Rappture::VideoViewer::controls {
     1090    switch $itk_option(-controls) {
     1091        show {
     1092        }
     1093        hide {
     1094        }
     1095        default {
     1096            error "bad value: \"$itk_option(-height)\": height should be an integer"
     1097        }
     1098    }
     1099    set _height $itk_option(-height)
     1100    after idle [itcl::code $this fixSize]
     1101}
     1102
  • branches/blt4/gui/scripts/xyprint.tcl

    r1923 r1932  
    219219        return [list .gif $bytes]
    220220    }
    221    
     221
    222222    # Handle encapsulated postscript or portable document format.
    223223
     
    12241224
    12251225    blt::table configure $page  c0 c7 c8 -resize none
    1226    
    12271226}
    12281227
  • branches/blt4/gui/scripts/xyresult.tcl

    r1923 r1932  
    2525
    2626set autocolors {
    27     #0000ff #ff0000 #00cc00
    28     #cc00cc #ff9900 #cccc00
    29     #000080 #800000 #006600
    30     #660066 #996600 #666600
    31 }
    32 set autocolors {
    33 #0000cd
    34 #cd0000
    35 #00cd00
    36 #3a5fcd
    37 #cdcd00
    38 #cd1076
    39 #009acd
    40 #00c5cd
    41 #a2b5cd
    42 #7ac5cd
    43 #66cdaa
    44 #a2cd5a
    45 #cd9b9b
    46 #cdba96
    47 #cd3333
    48 #cd6600
    49 #cd8c95
    50 #cd00cd
    51 #9a32cd
    52 #6ca6cd
    53 #9ac0cd
    54 #9bcd9b
    55 #00cd66
    56 #cdc673
    57 #cdad00
    58 #cd5555
    59 #cd853f
    60 #cd7054
    61 #cd5b45
    62 #cd6889
    63 #cd69c9
    64 #551a8b
     27    #0000cd
     28    #cd0000
     29    #00cd00
     30    #3a5fcd
     31    #cdcd00
     32    #cd1076
     33    #009acd
     34    #00c5cd
     35    #a2b5cd
     36    #7ac5cd
     37    #66cdaa
     38    #a2cd5a
     39    #cd9b9b
     40    #cdba96
     41    #cd3333
     42    #cd6600
     43    #cd8c95
     44    #cd00cd
     45    #9a32cd
     46    #6ca6cd
     47    #9ac0cd
     48    #9bcd9b
     49    #00cd66
     50    #cdc673
     51    #cdad00
     52    #cd5555
     53    #cd853f
     54    #cd7054
     55    #cd5b45
     56    #cd6889
     57    #cd69c9
     58    #551a8b
    6559}
    6660
     
    15051499itcl::body Rappture::XyResult::_getTextMarkerOptions {style} {
    15061500    array set textOptions {
    1507         "-color"  "-outline"
    1508         "-textcolor"  "-outline"
    1509         "-font"   "-font"
    1510         "-xoffset" "-xoffset"
    1511         "-yoffset" "-yoffset"
    1512         "-anchor" "-anchor"
    1513         "-rotate" "-rotate"
     1501        "-color"        "-outline"
     1502        "-textcolor"    "-outline"
     1503        "-font"         "-font"
     1504        "-xoffset"      "-xoffset"
     1505        "-yoffset"      "-yoffset"
     1506        "-anchor"       "-anchor"
     1507        "-rotate"       "-rotate"
    15141508    }
    15151509    set options {}
Note: See TracChangeset for help on using the changeset viewer.