Commit 27d097aa authored by Taddeus Kroes's avatar Taddeus Kroes

Added tracker for 'basic' events.

parent 72d93bef
...@@ -26,8 +26,7 @@ class GestureTracker(Logger): ...@@ -26,8 +26,7 @@ class GestureTracker(Logger):
passed to the handler along with a Gesture object can be specified. passed to the handler along with a Gesture object can be specified.
""" """
if gesture_type not in self.__gesture_types__: if gesture_type not in self.__gesture_types__:
raise AttributeError('Unsupported gesture type "%s".' \ raise ValueError('Unsupported gesture type "%s".' % gesture_type)
% gesture_type)
h = handler, args, kwargs h = handler, args, kwargs
......
from ..tracker import GestureTracker, Gesture
from ..geometry import Positionable
from utils import PointGesture
class BasicTracker(GestureTracker):
"""
The main goal of this class is to provide a triggering mechanism for the
low-level point-down, point-move and point-up events.
"""
__gesture_types__ = ['down', 'move', 'up']
def on_point_down(self, point):
self.trigger(DownGesture(point))
def on_point_move(self, point):
self.trigger(MoveGesture(point))
def on_point_up(self, point):
self.trigger(UpGesture(point))
class DownGesture(PointGesture):
__type__ = 'down'
class MoveGesture(PointGesture):
__type__ = 'move'
class UpGesture(PointGesture):
__type__ = 'up'
import argparse
import logging
from src.server import GestureServer
from src.window import FullscreenWindow
from src.trackers.basic import BasicTracker
from src.logger import Logger
# Parse arguments
parser = argparse.ArgumentParser(description='Basic test program for usage '
'of multi-touch API.')
parser.add_argument('--log', metavar='LOG_LEVEL', default='INFO',
choices=['DEBUG', 'INFO', 'WARNING'],
help='set log level (defaults to INFO)')
parser.add_argument('--logfile', metavar='FILENAME',
help='filename for the log file (the log is printed to '
'stdout by default)')
args = parser.parse_args()
# Configure logger
log_config = {'level': getattr(logging, args.log)}
if args.logfile:
log_config['filename'] = args.logfile
Logger.configure(**log_config)
# Create server
server = GestureServer()
# Create a window to add trackers to
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)
# Start listening to TUIO events
try:
server.start()
except KeyboardInterrupt:
server.stop()
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