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