Commit b7c9d41d authored by Taddeus Kroes's avatar Taddeus Kroes

Moved translation of TUIO to pixel coordinates to TUIO server instead of gesture server.

parent 740a5e5b
......@@ -2,7 +2,6 @@ Code:
- Connect to VTK.
- Rotation has a 'bump' at 0.
- tracker.gesture(...) instead of tracker.bind('gesture', ...)
- TODO: vertaling coordinaten doen in InputServer ipv GestureServer
Thesis:
- Network protocol.
......
......@@ -2,7 +2,6 @@ from input_server import InputServerHandler
from tuio_server import TuioServer2D
from window import FullscreenWindow
from point import TouchPoint
from screen import pixel_coords
class GestureServer(InputServerHandler):
......@@ -33,11 +32,8 @@ class GestureServer(InputServerHandler):
if sid in self.points:
raise ValueError('Point with sid %d already exists.' % sid)
# Translate to pixel coordinates
px, py = pixel_coords(x, y)
# Create a new touch point
self.points[sid] = point = TouchPoint(px, py, sid)
self.points[sid] = point = TouchPoint(x, y, sid)
# Save the windows containing the point in a dictionary, and update
# their trackers
......@@ -50,12 +46,9 @@ class GestureServer(InputServerHandler):
if sid not in self.points:
raise KeyError('No point with sid %d exists.' % sid)
# Translate to pixel coordinates
px, py = pixel_coords(x, y)
# Update point position and corresponding window trackers
point = self.points[sid]
point.set_position(px, py)
point.set_position(x, y)
point.update_window_trackers('move')
def on_point_up(self, sid):
......
......@@ -2,6 +2,7 @@ from OSC import OSCServer
OSCServer.print_tracebacks = True
from input_server import InputServer
from screen import pixel_coords
class TuioServer2D(InputServer):
......@@ -51,15 +52,20 @@ class TuioServer2D(InputServer):
if sid not in self.alive:
raise ValueError('Point with sid "%d" is not alive.' % sid)
# Translate to pixel coordinates
px, py = pixel_coords(x, y)
# Check if 'point_down' has already been triggered. If so, trigger
# a 'point_move' event instead
if sid in self.down:
self.debug('Moved %d to (%s, %s).' % (sid, x, y))
self.handler_obj.on_point_move(sid, x, y)
self.debug('Moved %d to (%.4f, %.4f) or (%d, %d).'
% (sid, x, y, px, py))
self.handler_obj.on_point_move(sid, px, py)
else:
self.debug('Down %d at (%s, %s).' % (sid, x, y))
self.debug('Down %d at (%.4f, %.4f) or (%d, %d).'
% (sid, x, y, px, py))
self.down.add(sid)
self.handler_obj.on_point_down(sid, x, y)
self.handler_obj.on_point_down(sid, px, py)
def run(self):
self.server.handle_request()
......@@ -98,13 +104,13 @@ if __name__ == '__main__':
# Define handlers
class Handler(InputServerHandler, Logger):
def on_point_down(self, sid, x, y):
self.info('Point down: sid=%d (%s, %s)' % (sid, x, y))
self.info('Point down: sid=%d (%.4f, %.4f)' % (sid, x, y))
def on_point_up(self, sid):
self.info('Point up: sid=%d' % sid)
def on_point_move(self, sid, x, y):
self.info('Point move: sid=%d (%s, %s)' % (sid, x, y))
self.info('Point move: sid=%d (%.4f, %.4f)' % (sid, x, y))
server = TuioServer2D(Handler())
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment