touch_objects.py 933 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. from geometry import AcceleratedPositionable
  2. class TouchObject(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 unique
  6. object id. All dimensions are in pixels.
  7. """
  8. def __init__(self, x, y):
  9. super(TouchObject, self).__init__(x, y)
  10. self.object_id = self.create_object_id()
  11. def get_id(self):
  12. return self.object_id
  13. object_id_count = 0
  14. @classmethod
  15. def create_object_id(cls):
  16. cls.object_id_count += 1
  17. return cls.object_id_count
  18. class TouchPoint(TouchObject):
  19. """
  20. Simple point touchin the scree, consisting only of an (x, y) position.
  21. """
  22. pass
  23. # TODO: Extend with more complex touch object, e.g.:
  24. #class TouchFiducial(TouchObject): ...
  25. OBJECT_NAMES = {
  26. 'point': TouchPoint,
  27. #'fiducial': TouchFiducial,
  28. }