def _mouseevent(type):
    gl.winset(G.focus._gid)
    orgx, orgy = gl.getorigin()
    sizex, sizey = gl.getsize()
    x = G.mousex - orgx
    y = G.mousey - orgy
    return type, G.focus, ((x, sizey - y), 1, 0, 0)
def _mouseevent(type):
    gl.winset(G.focus._gid)
    orgx, orgy = gl.getorigin()
    sizex, sizey = gl.getsize()
    x = G.mousex - orgx
    y = G.mousey - orgy
    return type, G.focus, ((x, sizey - y), 1, 0, 0)
Beispiel #3
0
	def __init__(self, wid):
		import gl
		gl.winset(wid)
		self.wid = wid
		self.width = gl.getsize()[1]
		self.height = 0
		self.d = GLMeasurerWriter()
		SavingBackEnd.__init__(self)
Beispiel #4
0
 def __init__(self, wid):
     import gl
     gl.winset(wid)
     self.wid = wid
     self.width = gl.getsize()[1]
     self.height = 0
     self.d = GLMeasurerWriter()
     SavingBackEnd.__init__(self)
Beispiel #5
0
 def reset(self):
     if self.wid > 0:
         gl.winset(self.wid)
         gl.clear()
         self.vout.initcolormap()
     self.queue = []
     self.spares = []
     self.written = 0
     self.lastt = 0
Beispiel #6
0
	def putnextpacket(self, pos, data):
		nline = len(data)/self.linewidth()
		if nline*self.linewidth() <> len(data):
			print 'Incorrect-sized video fragment ignored'
			return
		oldwid = gl.winget()
		gl.winset(self.wid)
		self.disp.showpartframe(data, None, (0, pos, self.vw, nline))
		gl.winset(oldwid)
Beispiel #7
0
	def reshapewindow(self):
		oldwid = gl.winget()
		gl.winset(self.wid)
		gl.reshapeviewport()
		w, h = gl.getsize()
		self.disp.xorigin = (w-self.vw)/2
		self.disp.yorigin = (h-self.vh)/2
		self.disp.clear()
		gl.winset(oldwid)
Beispiel #8
0
	def _init(self, win):
		self.fg = win._fg
		self.bg = win._bg
		self.font = win._font
		self.size = win._size
		self.width, self.height = win._area[1]
		gl.winset(win._gid)
		gl.color(self.fg)
		return self
Beispiel #9
0
	def reset(self):
		if self.wid > 0:
			gl.winset(self.wid)
			gl.clear()
			self.vout.initcolormap()
		self.queue = []
		self.spares = []
		self.written = 0
		self.lastt = 0
Beispiel #10
0
	def calcnframes(self, memsize):
		gl.winset(self.window)
		x, y = gl.getsize()
		pixels = x*y
		pixels = pixels/2	# XXX always assume fields
		if self.mono or self.grey:
			n = memsize/pixels
		else:
			n = memsize/(4*pixels)
		return max(1, n)
Beispiel #11
0
	def calcnframes(self, memsize):
		gl.winset(self.window)
		x, y = gl.getsize()
		pixels = x*y
		pixels = pixels/2	# XXX always assume fields
		if self.mono or self.grey:
			n = memsize/pixels
		else:
			n = memsize/(4*pixels)
		return max(1, n)
Beispiel #12
0
 def show(self):
     if self.wid < 0:
         gl.foreground()
         gl.prefsize(self.vout.width, self.vout.height)
         self.wid = gl.winopen(self.title)
         gl.clear()
         self.vout.initcolormap()
     gl.winset(self.wid)
     if not self.queue:
         self.vout.clear()
         return
     dt, d, cd = self.queue[-1]
     self.vout.showframe(d, cd)
Beispiel #13
0
	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, 'Vb Control')
Beispiel #14
0
	def redraw(self):
		import gl
		gl.winset(self.wid)
		width = gl.getsize()[1]
		if width <> self.width:
			setdocsize = 1
			self.width = width
			for p in self.paralist:
				p.top = p.bottom = None
		d = self.d
		v = 0
		for p in self.paralist:
			v = p.render(d, 0, v, width)
Beispiel #15
0
	def show(self):
		if self.wid < 0:
			gl.foreground()
			gl.prefsize(self.vin.width, self.vin.height)
			self.wid = gl.winopen(self.title)
			gl.clear()
			self.vin.initcolormap()
		gl.winset(self.wid)
		if self.qindex >= self.qsize:
			self.vin.clear()
			return
		dt, d, cd = self.vin.getrandomframe(self.qindex)
		self.vin.showframe(d, cd)
Beispiel #16
0
	def show(self):
		if self.wid < 0:
			gl.foreground()
			gl.prefsize(self.vout.width, self.vout.height)
			self.wid = gl.winopen(self.title)
			gl.clear()
			self.vout.initcolormap()
		gl.winset(self.wid)
		if not self.queue:
			self.vout.clear()
			return
		dt, d, cd = self.queue[-1]
		self.vout.showframe(d, cd)
Beispiel #17
0
 def show(self):
     if self.wid < 0:
         gl.foreground()
         gl.prefsize(self.vin.width, self.vin.height)
         self.wid = gl.winopen(self.title)
         gl.clear()
         self.vin.initcolormap()
     gl.winset(self.wid)
     if self.qindex >= self.qsize:
         self.vin.clear()
         return
     dt, d, cd = self.vin.getrandomframe(self.qindex)
     self.vin.showframe(d, cd)
Beispiel #18
0
	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, 'Vb Control')
Beispiel #19
0
 def redraw(self):
     import gl
     gl.winset(self.wid)
     width = gl.getsize()[1]
     if width <> self.width:
         setdocsize = 1
         self.width = width
         for p in self.paralist:
             p.top = p.bottom = None
     d = self.d
     v = 0
     for p in self.paralist:
         v = p.render(d, 0, v, width)
Beispiel #20
0
	def optfullsizewindow(self):
		if not self.window:
			return
		gl.winset(self.window)
		if self.use_24:
			x, y = self.maxx, self.maxy
		else:
			x, y = self.curx, self.cury
		left, bottom = gl.getorigin()
		width, height = gl.getsize()
		bottom = bottom+height-y
		gl.prefposition(left, left+x-1, bottom, bottom+y-1)
		gl.winconstraints()
		if not self.use_24:
			gl.keepaspect(x, y)
			gl.stepunit(8, 6)
			gl.maxsize(self.maxx, self.maxy)
			gl.winconstraints()
		self.bindvideo()
Beispiel #21
0
	def optfullsizewindow(self):
		if not self.window:
			return
		gl.winset(self.window)
		if self.use_24:
			x, y = self.maxx, self.maxy
		else:
			x, y = self.curx, self.cury
		left, bottom = gl.getorigin()
		width, height = gl.getsize()
		bottom = bottom+height-y
		gl.prefposition(left, left+x-1, bottom, bottom+y-1)
		gl.winconstraints()
		if not self.use_24:
			gl.keepaspect(x, y)
			gl.stepunit(8, 6)
			gl.maxsize(self.maxx, self.maxy)
			gl.winconstraints()
		self.bindvideo()
Beispiel #22
0
	def __init__(self, wid, vw, vh, type):
		##print 'Init', wid, xywh
		##print 'video', vw, vw
		self.vw = vw
		self.vh = vh
		self.disp = Displayer()
		if not type in ('rgb', 'rgb8', 'grey', 'mono', 'grey2', \
			  'grey4'):
			raise 'Incorrent live video output type', type
		if type == 'rgb':
			info = (type, vw, vh, 0, 32, 0, 0, 0, 0)
		else:
			info = (type, vw, vh, 1, 8, 0, 0, 0, 0)
		self.disp.setinfo(info)
		self.wid = wid
		oldwid = gl.winget()
		gl.winset(wid)
		self.disp.initcolormap()
		self.reshapewindow()
		gl.winset(oldwid)
Beispiel #23
0
	def burst_capture(self):
		self.setwatch()
		gl.winset(self.window)
		x, y = gl.getsize()
		if self.use_24:
			fl.show_message('Sorry, no 24 bit continuous capture yet', '', '')
			return
		vformat = SV.RGB8_FRAMES
		nframes = self.getint(self.in_nframes, 0)
		if nframes == 0:
			maxmem = self.getint(self.in_maxmem, 1.0)
			memsize = int(maxmem * 1024 * 1024)
			nframes = self.calcnframes(memsize)
		info = (vformat, x, y, nframes, 1)
		try:
			info2, data, bitvec = self.video.CaptureBurst(info)
		except sv.error, msg:
			self.b_capture.set_button(0)
			self.setarrow()
			fl.show_message('Capture error:', str(msg), '')
			return
Beispiel #24
0
	def burst_capture(self):
		self.setwatch()
		gl.winset(self.window)
		x, y = gl.getsize()
		if self.use_24:
			fl.show_message('Sorry, no 24 bit continuous capture yet', '', '')
			return
		vformat = SV.RGB8_FRAMES
		nframes = self.getint(self.in_nframes, 0)
		if nframes == 0:
			maxmem = self.getint(self.in_maxmem, 1.0)
			memsize = int(maxmem * 1024 * 1024)
			nframes = self.calcnframes(memsize)
		info = (vformat, x, y, nframes, 1)
		try:
			info2, data, bitvec = self.video.CaptureBurst(info)
		except sv.error, msg:
			self.b_capture.set_button(0)
			self.setarrow()
			fl.show_message('Capture error:', str(msg), '')
			return
Beispiel #25
0
	def _fixviewport(self):
		#
		# Called after redraw or resize, and initially.
		#
		# Fix the coordinate system so that (0, 0) is top left,
		# units are pixels, and positive axes point right and down.
		#
		# Make the viewport slightly larger than the window,
		# and set the screenmask exactly to the window; this
		# help fixing character clipping.
		#
		# Set self._area to the window rectangle in STDWIN coords.
		#
		gl.winset(self._gid)
		gl.reshapeviewport()
		x0, x1, y0, y1 = gl.getviewport()
		width, height = x1-x0, y1-y0
		gl.viewport(x0-MASK, x1+MASK, y0-MASK, y1+MASK)
		gl.scrmask(x0, x1, y0, y1)
		gl.ortho2(-MASK, width+MASK, height+MASK, -MASK)
		self._area = (0, 0), (width, height)
Beispiel #26
0
 def _fixviewport(self):
     #
     # Called after redraw or resize, and initially.
     #
     # Fix the coordinate system so that (0, 0) is top left,
     # units are pixels, and positive axes point right and down.
     #
     # Make the viewport slightly larger than the window,
     # and set the screenmask exactly to the window; this
     # help fixing character clipping.
     #
     # Set self._area to the window rectangle in STDWIN coords.
     #
     gl.winset(self._gid)
     gl.reshapeviewport()
     x0, x1, y0, y1 = gl.getviewport()
     width, height = x1 - x0, y1 - y0
     gl.viewport(x0 - MASK, x1 + MASK, y0 - MASK, y1 + MASK)
     gl.scrmask(x0, x1, y0, y1)
     gl.ortho2(-MASK, width + MASK, height + MASK, -MASK)
     self._area = (0, 0), (width, height)
Beispiel #27
0
	def open_video(self):
		self.close_video()
		gl.winset(self.window)
		x, y = gl.getsize()
		if self.use_24:
			if self.rgb24_size == 2:
				x, y = x/2, y/2
			elif self.rgb24_size == 3:
				x, y = x/4, y/4
		vout = VFile.VoutFile(self.vfile)
		vout.setformat(self.vformat)
		if self.vformat == 'compress':
			cheader = self.init_compressor(x, y)
			vout.setcompressheader(cheader)
		vout.setsize(x, y)
		if self.vmode == VM_BURST:
			vout.setpf((1, -2))
		vout.writeheader()
		self.vout = vout
		self.nframes = 0
		self.speed_factor = 1
		self.t_nframes.label = `self.nframes`
Beispiel #28
0
	def open_video(self):
		self.close_video()
		gl.winset(self.window)
		x, y = gl.getsize()
		if self.use_24:
			if self.rgb24_size == 2:
				x, y = x/2, y/2
			elif self.rgb24_size == 3:
				x, y = x/4, y/4
		vout = VFile.VoutFile(self.vfile)
		vout.setformat(self.vformat)
		if self.vformat == 'compress':
			cheader = self.init_compressor(x, y)
			vout.setcompressheader(cheader)
		vout.setsize(x, y)
		if self.vmode == VM_BURST:
			vout.setpf((1, -2))
		vout.writeheader()
		self.vout = vout
		self.nframes = 0
		self.speed_factor = 1
		self.t_nframes.label = `self.nframes`
Beispiel #29
0
	def settitle(self):
		gl.winset(self.window)
		x, y = gl.getsize()
		title = 'Vb ' + self.vfile + ' (%dx%d)' % (x, y)
		gl.wintitle(title)
def getevent():
    while 1:
        #
        # Get next event from the processed queue, if any
        #
        if G.queue:
            event = G.queue[0]
            del G.queue[0]
            # print 'getevent from queue -->', event
            return event
            #
            # Get next event from the draw queue, if any,
            # but only if there is nothing in the system queue.
            #
        if G.drawqueue and not gl.qtest():
            win = G.drawqueue[0]
            del G.drawqueue[0]
            gl.winset(win._gid)
            gl.color(win._bg)
            gl.clear()
            event = WE_DRAW, win, win._area
            # print 'getevent from drawqueue -->', event
            return event
            #
            # Get next event from system queue, blocking if necessary
            # until one is available.
            # Some cases immediately return the event, others do nothing
            # or append one or more events to the processed queue.
            #
        dev, val = gl.qread()
        #
        if dev == REDRAW:
            win = G.windowmap[` val `]
            old_area = win._area
            win._fixviewport()
            win._needredraw()
            if old_area <> win._area:
                # print 'getevent --> WE_SIZE'
                return WE_SIZE, win, None
        elif dev == KEYBD:
            if val == 3:
                raise KeyboardInterrupt  # Control-C in window
            character = chr(val)
            if commands.has_key(character):
                return WE_COMMAND, G.focus, commands[character]
            return WE_CHAR, G.focus, character
        elif dev == LEFTARROWKEY:
            if val:
                return WE_COMMAND, G.focus, WC_LEFT
        elif dev == RIGHTARROWKEY:
            if val:
                return WE_COMMAND, G.focus, WC_RIGHT
        elif dev == UPARROWKEY:
            if val:
                return WE_COMMAND, G.focus, WC_UP
        elif dev == DOWNARROWKEY:
            if val:
                return WE_COMMAND, G.focus, WC_DOWN
        elif dev in (LEFTALTKEY, RIGHTALTKEY):
            if val:
                for code in codelist:
                    gl.qdevice(code)
            else:
                for code in codelist:
                    gl.unqdevice(code)
        elif dev in codelist:
            if val:
                event = G.focus._doshortcut(code2key[` dev `])
                if event:
                    return event
        elif dev == LEFTMOUSE:
            G.mousex = gl.getvaluator(MOUSEX)
            G.mousey = gl.getvaluator(MOUSEY)
            if val:
                type = WE_MOUSE_DOWN
                gl.qdevice(MOUSEX)
                gl.qdevice(MOUSEY)
            else:
                type = WE_MOUSE_UP
                gl.unqdevice(MOUSEX)
                gl.unqdevice(MOUSEY)
            return _mouseevent(type)
        elif dev == MOUSEX:
            G.mousex = val
            return _mouseevent(WE_MOUSE_MOVE)
        elif dev == MOUSEY:
            G.mousey = val
            return _mouseevent(WE_MOUSE_MOVE)
        elif dev == RIGHTMOUSE:  # Menu button press/release
            if val:  # Press
                event = G.focus._domenu()
                if event:
                    return event
        elif dev == INPUTCHANGE:
            if G.focus:
                G.queue.append(WE_DEACTIVATE, G.focus, None)
            G.focus = G.windowmap[` val `]
            if G.focus:
                G.queue.append(WE_ACTIVATE, G.focus, None)
        elif dev in (WINSHUT, WINQUIT):
            return WE_CLOSE, G.windowmap[` val `], None
        else:
            print "*** qread() --> dev:", dev, "val:", val
Beispiel #31
0
# Text formatting abstractions
Beispiel #32
0
 def redraw(self, wid):
     if wid == self.wid >= 0:
         gl.winset(self.wid)
         gl.reshapeviewport()
         self.vin.clear()
         self.show()
Beispiel #33
0
	def settitle(self):
		gl.winset(self.window)
		x, y = gl.getsize()
		title = 'Vb ' + self.vfile + ' (%dx%d)' % (x, y)
		gl.wintitle(title)
Beispiel #34
0
# Live video output (display video on the screen, presumably from the net)
Beispiel #35
0
import sys
Beispiel #36
0
#! /usr/bin/env python
Beispiel #37
0
	def setwatch(self):
		gl.winset(self.form.window)
		gl.setcursor(WATCH, 0, 0)
		gl.winset(self.window)
		gl.setcursor(WATCH, 0, 0)
Beispiel #38
0
	def rebindvideo(self):
		gl.winset(self.window)
		self.bindvideo()
Beispiel #39
0
	def setarrow(self):
		gl.winset(self.form.window)
		gl.setcursor(ARROW, 0, 0)
		gl.winset(self.window)
		gl.setcursor(ARROW, 0, 0)
Beispiel #40
0
	def ready(self):
		gl.winset(self.form.window)
		gl.setcursor(ARROW, 0, 0)
Beispiel #41
0
import gl, GL
Beispiel #42
0
	def setarrow(self):
		gl.winset(self.form.window)
		gl.setcursor(ARROW, 0, 0)
		gl.winset(self.window)
		gl.setcursor(ARROW, 0, 0)
Beispiel #43
0
# Text formatting abstractions
def getevent():
    while 1:
        #
        # Get next event from the processed queue, if any
        #
        if G.queue:
            event = G.queue[0]
            del G.queue[0]
            #print 'getevent from queue -->', event
            return event
        #
        # Get next event from the draw queue, if any,
        # but only if there is nothing in the system queue.
        #
        if G.drawqueue and not gl.qtest():
            win = G.drawqueue[0]
            del G.drawqueue[0]
            gl.winset(win._gid)
            gl.color(win._bg)
            gl.clear()
            event = WE_DRAW, win, win._area
            #print 'getevent from drawqueue -->', event
            return event
        #
        # Get next event from system queue, blocking if necessary
        # until one is available.
        # Some cases immediately return the event, others do nothing
        # or append one or more events to the processed queue.
        #
        dev, val = gl.qread()
        #
        if dev == REDRAW:
            win = G.windowmap[ ` val `]
            old_area = win._area
            win._fixviewport()
            win._needredraw()
            if old_area <> win._area:
                #print 'getevent --> WE_SIZE'
                return WE_SIZE, win, None
        elif dev == KEYBD:
            if val == 3:
                raise KeyboardInterrupt  # Control-C in window
            character = chr(val)
            if commands.has_key(character):
                return WE_COMMAND, G.focus, commands[character]
            return WE_CHAR, G.focus, character
        elif dev == LEFTARROWKEY:
            if val:
                return WE_COMMAND, G.focus, WC_LEFT
        elif dev == RIGHTARROWKEY:
            if val:
                return WE_COMMAND, G.focus, WC_RIGHT
        elif dev == UPARROWKEY:
            if val:
                return WE_COMMAND, G.focus, WC_UP
        elif dev == DOWNARROWKEY:
            if val:
                return WE_COMMAND, G.focus, WC_DOWN
        elif dev in (LEFTALTKEY, RIGHTALTKEY):
            if val:
                for code in codelist:
                    gl.qdevice(code)
            else:
                for code in codelist:
                    gl.unqdevice(code)
        elif dev in codelist:
            if val:
                event = G.focus._doshortcut(code2key[ ` dev `])
                if event:
                    return event
        elif dev == LEFTMOUSE:
            G.mousex = gl.getvaluator(MOUSEX)
            G.mousey = gl.getvaluator(MOUSEY)
            if val:
                type = WE_MOUSE_DOWN
                gl.qdevice(MOUSEX)
                gl.qdevice(MOUSEY)
            else:
                type = WE_MOUSE_UP
                gl.unqdevice(MOUSEX)
                gl.unqdevice(MOUSEY)
            return _mouseevent(type)
        elif dev == MOUSEX:
            G.mousex = val
            return _mouseevent(WE_MOUSE_MOVE)
        elif dev == MOUSEY:
            G.mousey = val
            return _mouseevent(WE_MOUSE_MOVE)
        elif dev == RIGHTMOUSE:  # Menu button press/release
            if val:  # Press
                event = G.focus._domenu()
                if event:
                    return event
        elif dev == INPUTCHANGE:
            if G.focus:
                G.queue.append(WE_DEACTIVATE, G.focus, None)
            G.focus = G.windowmap[ ` val `]
            if G.focus:
                G.queue.append(WE_ACTIVATE, G.focus, None)
        elif dev in (WINSHUT, WINQUIT):
            return WE_CLOSE, G.windowmap[ ` val `], None
        else:
            print '*** qread() --> dev:', dev, 'val:', val
Beispiel #45
0
	def setwatch(self):
		gl.winset(self.form.window)
		gl.setcursor(WATCH, 0, 0)
		gl.winset(self.window)
		gl.setcursor(WATCH, 0, 0)
Beispiel #46
0
import gl, GL
Beispiel #47
0
	def rebindvideo(self):
		gl.winset(self.window)
		self.bindvideo()
Beispiel #48
0
	def redraw(self, wid):
		if wid == self.wid >= 0:
			gl.winset(self.wid)
			gl.reshapeviewport()
			self.vin.clear()
			self.show()
Beispiel #49
0
# Live video output (display video on the screen, presumably from the net)
Beispiel #50
0
	def busy(self):
		gl.winset(self.form.window)
		gl.setcursor(WATCH, 0, 0)
Beispiel #51
0
	def reset(self):
		if self.wid > 0:
			gl.winset(self.wid)
			gl.clear()
			self.vin.initcolormap()
		self.qindex = 0
Beispiel #52
0
import sys
Beispiel #53
0
 def reset(self):
     if self.wid > 0:
         gl.winset(self.wid)
         gl.clear()
         self.vin.initcolormap()
     self.qindex = 0
Beispiel #54
0
#! /usr/bin/env python
Beispiel #55
0
#! /usr/bin/env python