point.py 1012 B

123456789101112131415161718192021222324252627282930313233
  1. from geometry import AcceleratedPositionable
  2. class TouchPoint(AcceleratedPositionable):
  3. """
  4. Representation of an object touching the screen. The simplest form of a
  5. touch object is a 'point', represented by an (x, y) position and a TUIO
  6. session id (sid). All dimensions are in pixels.
  7. """
  8. def __init__(self, x, y, sid):
  9. super(TouchPoint, self).__init__(x, y)
  10. self.sid = sid
  11. # List of all windows this point is located in
  12. self.windows = []
  13. def __str__(self):
  14. return '<%s at (%s, %s) sid=%d>' \
  15. % (self.__class__.__name__, self.x, self.y, self.sid)
  16. def add_window(self, window):
  17. self.windows.append(window)
  18. def remove_window(self, window):
  19. self.windows.remove(window)
  20. def update_window_trackers(self, event_type):
  21. for window in self.windows:
  22. window.update_trackers(event_type, self)
  23. # TODO: Extend with more complex touch object, e.g.:
  24. #class TouchFiducial(TouchPoint): ...