Commit dc48af59 authored by Taddeüs Kroes's avatar Taddeüs Kroes

Added a new way of binding handlers to trackers.

parent b7c9d41d
Code:
- Connect to VTK.
- Rotation has a 'bump' at 0.
- tracker.gesture(...) instead of tracker.bind('gesture', ...)
Thesis:
- Network protocol.
......
......@@ -66,6 +66,19 @@ class GestureTracker(Logger):
setattr(self, name, value)
def __getattr__(self, name):
"""
Allow calls like:
tracker.gesture(...)
instead of:
tracker.bind('gesture', ...)
"""
if name not in self.__gesture_types__:
raise AttributeError("'%s' has no attribute '%s'"
% (self.__class__.__name__, name))
return lambda handler: self.bind(name, handler)
class Gesture(object):
"""
......
......@@ -13,9 +13,9 @@ win = FullscreenWindow(server=server)
# Add tracker and handlers
tracker = BasicTracker(win)
tracker.bind('down', lambda g: 0)
tracker.bind('move', lambda g: 0)
tracker.bind('up', lambda g: 0)
tracker.down(lambda g: 0)
tracker.move(lambda g: 0)
tracker.up(lambda g: 0)
# Start listening to TUIO events
try:
......
......@@ -141,13 +141,13 @@ def pinch(gesture):
scale = min(scale * gesture.get_scale(), MAX_SCALE)
transform = TransformationTracker(win)
transform.bind('rotate', rotate)
transform.bind('pinch', pinch)
transform.rotate(rotate)
transform.pinch(pinch)
tap = TapTracker(win)
tap.bind('tap', lambda g: taps.append([coord(*g.xy), FINGER_RADIUS]))
tap.bind('single_tap', lambda g: dtaps.append(list(coord(*g.xy)) + [1]))
tap.bind('double_tap', lambda g: dtaps.append(list(coord(*g.xy)) + [0]))
tap.tap(lambda g: taps.append([coord(*g.xy), FINGER_RADIUS]))
tap.single_tap(lambda g: dtaps.append(list(coord(*g.xy)) + [1]))
tap.double_tap(lambda g: dtaps.append(list(coord(*g.xy)) + [0]))
try:
......
......@@ -18,12 +18,12 @@ win = FullscreenWindow(server=server)
# Add tracker and handlers
tracker = TapTracker(win)
def handler(gesture): pass
#print 'handler:', gesture
def handler(gesture):
pass
tracker.bind('tap', handler)
tracker.bind('single_tap', handler)
tracker.bind('double_tap', handler)
tracker.tap(handler)
tracker.single_tap(handler)
tracker.double_tap(handler)
# Start listening to TUIO events
try:
......
......@@ -13,9 +13,9 @@ win = FullscreenWindow(server=server)
# Add tracker and handlers
tracker = TransformationTracker(win)
tracker.bind('rotate', lambda g: 0)
tracker.bind('pinch', lambda g: 0)
tracker.bind('move', lambda g: 0)
tracker.rotate(lambda g: 0)
tracker.pinch(lambda g: 0)
tracker.move(lambda g: 0)
# Start listening to TUIO events
try:
......
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