]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Moved stop button again; default form position next to video window.
authorGuido van Rossum <guido@python.org>
Fri, 7 May 1993 11:20:07 +0000 (11:20 +0000)
committerGuido van Rossum <guido@python.org>
Fri, 7 May 1993 11:20:07 +0000 (11:20 +0000)
Demo/sgi/video/Vb.py
Demo/sgi/video/VbForm.fd

index 2a465712bad1caff024823eae7498bf0b03824e4..92b3e061030d0577c988060dfb3e8b82f2b6062d 100755 (executable)
@@ -2,13 +2,20 @@
 
 # Video bag-of-tricks
 
-# XXX To do: audio; rationalize user interface; ...?
+# XXX To do:
+# - audio
+# - single frame recording
+# - improve user interface
+# - help button?
+# - command line options to set initial settings
+# - save settings in a file
+# - ...?
 
 import sys
 import getopt
 import string
 import os
-sts = os.system('makemap')             # Must be before "import fl"
+sts = os.system('makemap')             # Must be before "import fl" to work
 import sgi
 import gl
 import GL
@@ -28,6 +35,7 @@ WATCH = 1
 watchcursor.defwatch(WATCH)
 
 def main():
+##     fl.set_graphics_mode(0, 1)
        vb = VideoBagOfTricks().init()
        while 1:
                dummy = fl.do_forms()
@@ -46,16 +54,31 @@ class VideoBagOfTricks:
                formdef = flp.parse_form('VbForm', 'form')
                flp.create_full_form(self, formdef)
                self.g_stop.hide_object()
+               self.g_burst.hide_object()
                self.setdefaults()
                self.openvideo()
                self.makewindow()
                self.bindvideo()
                self.capturing = 0
-               self.form.show_form(FL.PLACE_SIZE, FL.TRUE, \
-                                   'Video Bag Of Tricks')
+               self.showform()
                fl.set_event_call_back(self.do_event)
                return self
 
+       def showform(self):
+               # Get position of video window
+               gl.winset(self.window)
+               x, y = gl.getorigin()
+               width, height = gl.getsize()
+               # Calculate position of form window
+               x1 = x + width + 10
+               x2 = x1 + int(self.form.w) - 1
+               y2 = y + height - 1
+               y1 = y2 - int(self.form.h) + 1
+               # Position and show form window
+               gl.prefposition(x1, x2, y1, y2)
+               self.form.show_form(FL.PLACE_FREE, FL.TRUE, \
+                                   'Video Bag Of Tricks')
+
        def setdefaults(self):
                self.mono_thresh = 128
                self.format = 'rgb8'
@@ -152,34 +175,6 @@ class VideoBagOfTricks:
                        self.rebindvideo()
                        self.settitle()
 
-       def get_format(self):
-               i = self.c_format.get_choice()
-               label = Labels[i-1]
-               format = Formats[i-1]
-               self.format = format
-               #
-               self.rgb = (format[:3] == 'rgb')
-               self.mono = (format == 'mono')
-               self.grey = (format[:4] == 'grey')
-               self.mono_use_thresh = (label == 'mono thresh')
-               s = format[4:]
-               if s:
-                       self.greybits = string.atoi(s)
-               else:
-                       self.greybits = 8
-               if label == 'grey2 dith':
-                       self.greybits = -2
-               #
-               convertor = None
-               if self.grey:
-                       if self.greybits == 2:
-                               convertor = imageop.grey2grey2
-                       elif self.greybits == 4:
-                               convertor = imageop.grey2grey4
-                       elif self.greybits == -2:
-                               convertor = imageop.dither2grey2
-               self.convertor = convertor
-
        def cb_format(self, *args):
                self.get_format()
                if self.mono_use_thresh:
@@ -200,7 +195,16 @@ class VideoBagOfTricks:
                self.rebindvideo()
 
        def cb_burst(self, *args):
-               pass
+               if self.b_burst.get_button():
+                       self.in_rate.set_input('1')
+                       self.b_drop.set_button(1)
+##                     self.g_stop.hide_object()
+                       self.g_burst.show_object()
+               else:
+                       self.in_rate.set_input('2')
+                       self.b_drop.set_button(0)
+##                     self.g_stop.show_object()
+                       self.g_burst.hide_object()
 
        def cb_maxmem(self, *args):
                pass
@@ -226,15 +230,6 @@ class VideoBagOfTricks:
                        self.in_file.set_input(filename)
                        self.cb_file()
 
-       def cb_play(self, *args):
-               filename = self.in_file.get_input()
-               sts = os.system('Vplay -q ' + filename + ' &')
-
-       def cb_stop(self, *args):
-               if self.capturing:
-                       raise StopCapture
-               gl.ringbell()
-
        def cb_capture(self, *args):
                if not self.video:
                        gl.ringbell()
@@ -244,6 +239,18 @@ class VideoBagOfTricks:
                else:
                        self.cont_capture()
 
+       def cb_stop(self, *args):
+               if self.capturing:
+                       raise StopCapture
+               gl.ringbell()
+
+       def cb_play(self, *args):
+               filename = self.in_file.get_input()
+               sts = os.system('Vplay -q ' + filename + ' &')
+
+       def cb_quit(self, *args):
+               raise SystemExit, 0
+
        def burst_capture(self):
                self.setwatch()
                gl.winset(self.window)
@@ -264,7 +271,6 @@ class VideoBagOfTricks:
                                  self.mono or self.grey, memsize)
                        print 'nframes =', nframes
                rate = string.atoi(self.in_rate.get_input())
-               # XXX Should check ranges and not crash if non-integer
                info = (vformat, x, y, nframes, rate)
                try:
                        info2, data, bitvec = self.video.CaptureBurst(info)
@@ -272,7 +278,7 @@ class VideoBagOfTricks:
                        fl.show_message('Capture error:', str(msg), '')
                        self.setarrow()
                        return
-               print info2
+               if info <> info2: print info, '<>', info2
                self.save_burst(info2, data, bitvec)
                self.setarrow()
 
@@ -361,6 +367,34 @@ class VideoBagOfTricks:
                self.g_main.show_object()
                self.setarrow()
 
+       def get_format(self):
+               i = self.c_format.get_choice()
+               label = Labels[i-1]
+               format = Formats[i-1]
+               self.format = format
+               #
+               self.rgb = (format[:3] == 'rgb')
+               self.mono = (format == 'mono')
+               self.grey = (format[:4] == 'grey')
+               self.mono_use_thresh = (label == 'mono thresh')
+               s = format[4:]
+               if s:
+                       self.greybits = string.atoi(s)
+               else:
+                       self.greybits = 8
+               if label == 'grey2 dith':
+                       self.greybits = -2
+               #
+               convertor = None
+               if self.grey:
+                       if self.greybits == 2:
+                               convertor = imageop.grey2grey2
+                       elif self.greybits == 4:
+                               convertor = imageop.grey2grey4
+                       elif self.greybits == -2:
+                               convertor = imageop.dither2grey2
+               self.convertor = convertor
+
        def open_file(self):
                gl.winset(self.window)
                x, y = gl.getsize()
@@ -374,15 +408,6 @@ class VideoBagOfTricks:
                vout.writeheader()
                self.vout = vout
 
-       def close_file(self):
-               try:
-                       self.vout.close()
-               except IOError, msg:
-                       if msg == (0, 'Error 0'):
-                               msg = 'disk full??'
-                       fl.show_message('IOError', str(msg), '')
-               del self.vout
-
        def write_frame(self, t, data):
                if self.convertor:
                        data = self.convertor(data, len(data), 1)
@@ -403,8 +428,14 @@ class VideoBagOfTricks:
                        return 0
                return 1
 
-       def cb_quit(self, *args):
-               raise SystemExit, 0
+       def close_file(self):
+               try:
+                       self.vout.close()
+               except IOError, msg:
+                       if msg == (0, 'Error 0'):
+                               msg = 'disk full??'
+                       fl.show_message('IOError', str(msg), '')
+               del self.vout
 
        def setwatch(self):
                gl.winset(self.form.window)
index 8c53257a1d3aea6dec5c6aa4b1b71f323d2694a2..e3056122a6d1dace860fb852c6c1e3f7803294e1 100644 (file)
@@ -9,7 +9,7 @@ Number of forms: 1
 Name: form
 Width: 350.000000
 Height: 240.000000
-Number of Objects: 21
+Number of Objects: 23
 
 --------------------
 class: 1
@@ -31,95 +31,125 @@ class: 10000
 type: 0
 box: 0.000000 0.000000 0.000000 0.000000
 boxtype: 0
-colors: 0 0
+colors: 5487 512
 alignment: 4
 style: 0
 size: 11.000000
 lcol: 0
 label: 
-name: g_main
+name: g_burst
 callback: 
 argument: 
 
 --------------------
 class: 1
-type: 2
-box: 140.000000 10.000000 120.000000 160.000000
-boxtype: 2
+type: 1
+box: 140.000000 10.000000 120.000000 120.000000
+boxtype: 1
 colors: 47 47
 alignment: 0
 style: 0
 size: 11.000000
 lcol: 0
-label: Burst mode:
+label: 
 name: 
 callback: 
 argument: 
 
 --------------------
-class: 1
-type: 2
-box: 10.000000 10.000000 120.000000 160.000000
+class: 31
+type: 1
+box: 150.000000 70.000000 100.000000 30.000000
 boxtype: 2
-colors: 47 47
+colors: 13 5
 alignment: 0
 style: 0
 size: 11.000000
 lcol: 0
-label: Options:
-name: 
-callback: 
-argument: 
+label: Max Mbytes:
+name: in_maxmem
+callback: cb_maxmem
+argument: 0
 
 --------------------
 class: 31
 type: 2
-box: 60.000000 50.000000 40.000000 30.000000
+box: 150.000000 20.000000 100.000000 30.000000
 boxtype: 2
 colors: 13 5
 alignment: 0
 style: 0
 size: 11.000000
 lcol: 0
-label: Capture rate:
-name: in_rate
-callback: cb_rate
+label: Nr. of fields:
+name: in_nframes
+callback: cb_nframes
 argument: 0
 
 --------------------
-class: 31
+class: 20000
+type: 0
+box: 0.000000 0.000000 0.000000 0.000000
+boxtype: 0
+colors: -322390740 -895472437
+alignment: 4
+style: 0
+size: 11.000000
+lcol: 0
+label: 
+name: 
+callback: 
+argument: 
+
+--------------------
+class: 10000
+type: 0
+box: 0.000000 0.000000 0.000000 0.000000
+boxtype: 0
+colors: 1147496041 1852404841
+alignment: 4
+style: 0
+size: 11.000000
+lcol: 0
+label: 
+name: g_main
+callback: 
+argument: 
+
+--------------------
+class: 1
 type: 1
-box: 150.000000 70.000000 100.000000 30.000000
-boxtype: 2
-colors: 13 5
+box: 10.000000 10.000000 120.000000 120.000000
+boxtype: 1
+colors: 47 47
 alignment: 0
 style: 0
 size: 11.000000
 lcol: 0
-label: Max Mbytes:
-name: in_maxmem
-callback: cb_maxmem
-argument: 0
+label: 
+name: 
+callback: 
+argument: 
 
 --------------------
 class: 31
 type: 2
-box: 150.000000 20.000000 100.000000 30.000000
+box: 50.000000 70.000000 40.000000 30.000000
 boxtype: 2
 colors: 13 5
 alignment: 0
 style: 0
 size: 11.000000
 lcol: 0
-label: Nr. of fields:
-name: in_nframes
-callback: cb_nframes
+label: Capture rate:
+name: in_rate
+callback: cb_rate
 argument: 0
 
 --------------------
 class: 12
 type: 1
-box: 150.000000 130.000000 100.000000 30.000000
+box: 140.000000 140.000000 120.000000 30.000000
 boxtype: 1
 colors: 39 3
 alignment: 4
@@ -164,7 +194,7 @@ argument: 0
 --------------------
 class: 11
 type: 0
-box: 270.000000 110.000000 70.000015 60.000004
+box: 270.000000 140.000000 70.000015 30.000002
 boxtype: 1
 colors: 47 47
 alignment: 4
@@ -176,25 +206,10 @@ name: b_capture
 callback: cb_capture
 argument: 0
 
---------------------
-class: 13
-type: 1
-box: 20.000000 20.000000 110.000000 30.000000
-boxtype: 0
-colors: 7 3
-alignment: 4
-style: 0
-size: 11.000000
-lcol: 0
-label: "Fielddrop"
-name: b_drop
-callback: cb_drop
-argument: 0
-
 --------------------
 class: 2
 type: 0
-box: 30.000000 50.000000 30.000000 30.000000
+box: 20.000000 70.000000 30.000000 30.000000
 boxtype: 0
 colors: 47 47
 alignment: 2
@@ -209,7 +224,7 @@ argument:
 --------------------
 class: 2
 type: 0
-box: 100.000000 50.000000 30.000000 30.000000
+box: 90.000000 70.000000 30.000000 30.000000
 boxtype: 0
 colors: 47 47
 alignment: 2
@@ -254,7 +269,7 @@ argument: 0
 --------------------
 class: 42
 type: 0
-box: 20.000000 110.000000 100.000000 30.000000
+box: 10.000000 140.000000 120.000000 30.000000
 boxtype: 5
 colors: 7 0
 alignment: 0
@@ -266,12 +281,27 @@ name: c_format
 callback: cb_format
 argument: 0
 
+--------------------
+class: 12
+type: 1
+box: 20.000000 20.000000 100.000000 30.000000
+boxtype: 1
+colors: 39 3
+alignment: 4
+style: 0
+size: 11.000000
+lcol: 0
+label: Fielddrop
+name: b_drop
+callback: cb_drop
+argument: 0
+
 --------------------
 class: 20000
 type: 0
 box: 0.000000 0.000000 0.000000 0.000000
 boxtype: 0
-colors: 0 0
+colors: 544171552 1331849829
 alignment: 4
 style: 0
 size: 11.000000
@@ -286,7 +316,7 @@ class: 10000
 type: 0
 box: 0.000000 0.000000 0.000000 0.000000
 boxtype: 0
-colors: 0 0
+colors: 1147496041 1852404841
 alignment: 4
 style: 0
 size: 11.000000
@@ -299,14 +329,14 @@ argument:
 --------------------
 class: 11
 type: 0
-box: 10.000000 10.000000 330.000000 220.000000
+box: 270.000000 140.000000 70.000000 30.000000
 boxtype: 1
 colors: 47 47
 alignment: 4
 style: 0
 size: 11.000000
 lcol: 0
-label: Stop capture
+label: Stop
 name: b_stop
 callback: cb_stop
 argument: 0
@@ -316,7 +346,7 @@ class: 20000
 type: 0
 box: 0.000000 0.000000 0.000000 0.000000
 boxtype: 0
-colors: 0 0
+colors: 544171552 1331849829
 alignment: 4
 style: 0
 size: 11.000000