source: trunk/examples/video/piv/piv.tcl @ 2035

Last change on this file since 2035 was 2035, checked in by dkearney, 14 years ago

adding aspect ratio calculations.
disable analyze button when no movie has been choosen in piv
rename some functions

  • Property svn:executable set to *
File size: 4.8 KB
Line 
1#!/bin/sh
2#\
3exec wish "$0" $*
4# ----------------------------------------------------------------------
5# wish executes everything from here on...
6
7package require RapptureGUI
8package require BLT
9package require Img
10
11
12option add *font -*-helvetica-medium-r-normal-*-12-*
13option add *background #d9d9d9
14option add *Tooltip.background white
15option add *BugReport*banner*foreground white
16option add *BugReport*banner*background #a9a9a9
17option add *BugReport*banner*highlightBackground #a9a9a9
18option add *BugReport*banner*font -*-helvetica-bold-r-normal-*-18-*
19option add *upload*Label*font -*-helvetica-medium-r-normal-*-12-*
20option add *download*Label*font -*-helvetica-medium-r-normal-*-12-*
21
22switch $tcl_platform(platform) {
23    unix - windows {
24        event add <<PopupMenu>> <ButtonPress-3>
25    }
26    macintosh {
27        event add <<PopupMenu>> <Control-ButtonPress-1>
28    }
29}
30
31# install some Rappture support stuff...
32Rappture::bugreport::install
33Rappture::filexfer::init
34Rappture::grab::init
35
36
37wm title . "particle velocity estimate"
38wm withdraw .
39set width 960
40set height 630
41
42set installdir [file dirname [ \
43                Rappture::utils::expandPath [ \
44                file normalize [info script]]]]
45
46
47
48# ------------------------------------------------------------------
49# Main Window
50# ------------------------------------------------------------------
51
52# create a notebook to hold the different pages
53
54set nb [Rappture::Notebook .nb]
55pack .nb -expand yes -fill both
56
57# ------------------------------------------------------------------
58# About Page
59# ------------------------------------------------------------------
60
61set f [$nb insert end about]
62
63
64
65# html intro page
66
67set intro [frame $f.intro]
68
69Rappture::Scroller $intro.scroller -xscrollmode auto -yscrollmode auto
70pack $intro.scroller -expand yes -fill both
71
72Rappture::HTMLviewer $intro.scroller.html
73$intro.scroller contents $intro.scroller.html
74
75set fid [open "intro.html" r]
76set html [read $fid]
77close $fid
78$intro.scroller.html load $html
79
80
81# verticle divider
82set div [frame $f.div -width 1 -background black]
83
84
85set previewVar ""
86
87# movie chooser
88
89set chooser [frame $f.chooser_f]
90
91set fid [open [file join $installdir images step1.png] r]
92fconfigure $fid -translation binary -encoding binary
93set data [read $fid]
94close $fid
95set imh [image create photo]
96$imh put $data
97label $chooser.step1 -image $imh
98
99set vc [Rappture::VideoChooser $chooser.vc -variable ::previewVar]
100#$vc load [glob "/home/derrick/projects/piv/video/*.mp4"]
101$vc load [glob "/apps/video/*.mp4"]
102
103pack $chooser.step1 -side top -anchor w -pady 8
104pack $vc -side bottom -anchor center
105
106
107
108# movie previewer
109
110set preview [frame $f.preview_f]
111
112set fid [open [file join $installdir images step2.png] r]
113fconfigure $fid -translation binary -encoding binary
114set data [read $fid]
115close $fid
116set imh [image create photo]
117$imh put $data
118label $preview.step2 -image $imh
119
120set vp [Rappture::VideoPreview $preview.preview -variable ::previewVar]
121
122pack $preview.step2 -side top -anchor w -pady 8
123pack $vp -side bottom -anchor center
124
125
126
127# analyze button gets us to the analyze page
128
129set analyze [frame $f.analyze_f]
130
131set fid [open [file join $installdir images step3.png] r]
132fconfigure $fid -translation binary -encoding binary
133set data [read $fid]
134close $fid
135set imh [image create photo]
136$imh put $data
137label $analyze.step3 -image $imh
138
139button $analyze.go \
140    -text "Analyze" \
141    -state disabled \
142    -command {
143        $vp video stop
144        $vs load file $previewVar
145        $vs video seek [$vp query framenum]
146        $nb current next>
147        # FIXME: video loaded into memory twice
148    }
149pack $analyze.step3 -side left -anchor w
150pack $analyze.go -anchor center
151
152proc buttonState {b var args} {
153    upvar #0 $var v
154    set state disabled
155    if {"" != $v} {
156       set state normal
157    }
158    $b configure -state $state
159}
160
161trace add variable previewVar write "buttonState $analyze.go previewVar"
162
163
164set reqwidth [expr round($width/2.0)]
165blt::table $f \
166    0,0 $intro -rowspan 3 -fill both -reqwidth $reqwidth\
167    0,1 $div -rowspan 3 -fill y -pady 8 -padx 8\
168    0,2 $chooser -fill x -padx {0 8}\
169    1,2 $preview -fill x \
170    2,2 $analyze -fill x
171
172blt::table configure $f c0 -resize none
173blt::table configure $f c1 -resize none
174blt::table configure $f c2 -resize none
175# blt::table configure $f r0 -pady 1
176
177# ------------------------------------------------------------------
178# VIDEO PAGE
179# ------------------------------------------------------------------
180
181set f [$nb insert end video]
182set vs [Rappture::VideoScreen $f.viewer -fileopen {
183            $vs video stop
184            $nb current about}]
185pack $vs -expand yes -fill both
186
187
188# ------------------------------------------------------------------
189# SHOW WINDOW
190# ------------------------------------------------------------------
191
192
193$nb current about
194wm geometry . ${width}x${height}
195wm deiconify .
196
197#update idletasks
198#image delete $imh
Note: See TracBrowser for help on using the repository browser.