-
Notifications
You must be signed in to change notification settings - Fork 16
/
HitTestAttributeGenerator.h
executable file
·48 lines (39 loc) · 1.31 KB
/
HitTestAttributeGenerator.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
* HitTestAttributeGenerator.h
* Proton
*
* Created by Kenrick Kin on 6/21/12.
*
*/
#ifndef HITTESTATTRIBUTEGENERATOR_H
#define HITTESTATTRIBUTEGENERATOR_H
#include "Pt/AttributeGenerator.h"
#include "Pt/TuioTouchSymbol.h"
#include "Scene.h"
/// This attibute generator requires that a scene object that provides hit-testing of the a touch position
class HitTestAttributeGenerator : public PtAttributeGenerator {
Scene *_scene;
public:
HitTestAttributeGenerator(Scene *scene) {
_scene = scene;
}
std::string attributeValue(const PtTouchSymbol &touchSymbol, std::vector<PtTouchSymbols *> *touchStream) const {
const PtTuioTouchSymbol *tS = static_cast<const PtTuioTouchSymbol*>(&touchSymbol);
double x = tS->tuioCursor()->getX();
double y = tS->tuioCursor()->getY();
// query the object type hit by the touch and return a string representation of the objeccct
SceneObjectType objectType = _scene->hitTest(x,y);
switch (objectType) {
case SOT_CIRCLE:
return std::string("C");
break;
case SOT_SQUARE:
return std::string("S");
break;
default:
return std::string("O");
break;
}
}
};
#endif