Touch: Base for all touch objects
Every touch in PyMT derives from the abstract Touch class. A touch can have more or less attributes, depending on the provider. For example, the TUIO provider can give you a lot of information about the touch, like position, acceleration, width/height of the shape and so on. Another provider might just give you x/y coordinates and pressure.
We call these attributes “capabilities”. Every touch indicates its capabilities in its “profile” property. A profile is just a simple list with strings, containing for example:
- pos (property x, y)
- pos3d (property x, y, z)
- mov (tuio/property X, Y)
- mov3d (tuio/property X, Y, Z)
- dim (tuio/property w, h)
- dim3d (tuio/property w, h, d)
- markerid (tuio/property i (fid property))
- sessionid (tuio/property s (id property))
- angle (tuio/property a)
- angle3D (tuio/property a, b, c)
- rotacc (tuio/property A)
- rotacc3d (tuio/property A, B, C)
- motacc (tuio/property m)
- shape (property shape)
- kinetic
- ... and others could be added by new classes
If you’re only interested in a certain kind of touches, check the profile:
def on_touch_down(self, touch):
if 'markerid' not in touch.profile:
# not a fiducial, not interesting
return
Bases: object
Abstract class to represent a touch, and support TUIO 1.0 definition.
| Parameters : |
|
|---|
Apply a transformation on x, y, dxpos, dypos, oxpos, oypos
Copy some attribute to another touch object.
Depack args into attributes in class
Return previous position of the touch in the screen coordinate system (self.dxpos, self.dypos)
Grab a touch. You can grab a touch if you absolutly want to receive on_touch_move() and on_touch_up(), even if the touch is not dispatched by your parent
def on_touch_down(self, touch):
touch.grab(self)
def on_touch_move(self, touch):
if touch.grab_current == self:
# i receive my grabbed touch
else:
# it's a normal touch
def on_touch_up(self, touch):
if touch.grab_current == self:
# i receive my grabbed touch, i must ungrab it !
touch.ungrab(self)
else:
# it's a normal touch
Move the touch to another position.
Return the initial position of the touch in the screen coordinate system (self.oxpos, self.oypos)
Pop attributes values from the stack
Return position of the touch in the screen coordinate system (self.x, self.y)
Push attributes values in attrs in the stack
Scale position for the screen
Return the position in the 0-1 coordinate system (self.sx, self.sy)
Ungrab a previous grabbed touch