26 using namespace qstmGesture ; |
26 using namespace qstmGesture ; |
27 using qstmUiEventEngine::QStm_UiEventSpeedIf; |
27 using qstmUiEventEngine::QStm_UiEventSpeedIf; |
28 |
28 |
29 |
29 |
30 QStm_GenericSimpleGesture::QStm_GenericSimpleGesture( |
30 QStm_GenericSimpleGesture::QStm_GenericSimpleGesture( |
31 QStm_GestureUid uid, const QPoint& loc, int type, const QStm_UiEventSpeedIf* speedIf) : |
31 QStm_GestureUid uid, const QPoint& loc, QTime timestamp, int type, const QStm_UiEventSpeedIf* speedIf) : |
32 m_location(loc), m_uid(uid), m_type(type), m_details(0), m_speed(speedIf), m_target(0) |
32 m_location(loc), m_uid(uid), m_type(type), m_details(0), m_speed(speedIf), m_target(0), |
|
33 m_timestamp(timestamp) |
33 { |
34 { |
34 } |
35 } |
35 |
36 |
36 QPoint QStm_GenericSimpleGesture::getLocation() const |
37 QPoint QStm_GenericSimpleGesture::getLocation() const |
37 { |
38 { |
38 return m_location ; |
39 return m_location ; |
|
40 } |
|
41 |
|
42 QPoint QStm_GenericSimpleGesture::getLocation2() const |
|
43 { |
|
44 return m_location2 ; |
39 } |
45 } |
40 |
46 |
41 int QStm_GenericSimpleGesture::getType() const |
47 int QStm_GenericSimpleGesture::getType() const |
42 { |
48 { |
43 return m_type ; |
49 return m_type ; |
57 { |
63 { |
58 return m_name ; |
64 return m_name ; |
59 } |
65 } |
60 |
66 |
61 QStm_DirectionalGesture::QStm_DirectionalGesture( |
67 QStm_DirectionalGesture::QStm_DirectionalGesture( |
62 QStm_GestureUid uid, const QPoint& loc, const QPoint& prevLoc, |
68 QStm_GestureUid uid, const QPoint& loc, const QPoint& prevLoc, QTime timestamp, |
63 const QStm_UiEventSpeedIf* speedIf, bool logging) : |
69 const QStm_UiEventSpeedIf* speedIf, bool logging) : |
64 QStm_GenericSimpleGesture(uid, loc, 0, speedIf), m_loggingEnabled(logging) |
70 QStm_GenericSimpleGesture(uid, loc, timestamp, 0, speedIf), m_loggingEnabled(logging) |
65 { |
71 { |
66 setVector(loc, prevLoc); |
72 setVector(loc, prevLoc); |
67 } |
73 } |
68 |
74 |
69 void QStm_DirectionalGesture::setVector(const QPoint& last, const QPoint& previous) |
75 void QStm_DirectionalGesture::setVector(const QPoint& last, const QPoint& previous) |
70 { |
76 { |
71 m_vector = QPoint(last.x()-previous.x(), previous.y()-last.y()) ; // x > 0 => east, y > 0 => north |
77 m_vector = QPoint(last.x()-previous.x(), previous.y()-last.y()) ; // x > 0 => east, y > 0 => north |
72 if (m_loggingEnabled) { |
|
73 LOGARG("CHoveringGesture: x: %d , %d prev: %d, %d", last.x(), last.y(), previous.x(), previous.y()) ; |
|
74 } |
|
75 } |
78 } |
76 |
79 |
77 QStm_GestureDirection QStm_DirectionalGesture::getDirection() const |
80 QStm_GestureDirection QStm_DirectionalGesture::getDirection() const |
78 { |
81 { |
79 QStm_GestureDirection dir = ENorth ; |
82 QStm_GestureDirection dir = ENorth ; |
80 int x = ABS(m_vector.x()) ; |
83 int x = ABS(m_vector.x()) ; |
81 int y = ABS(m_vector.x()) ; |
84 int y = ABS(m_vector.y()) ; |
82 |
85 |
83 if (y <= x/2) { |
86 if (y == 0 && x == 0) { |
|
87 dir = ENoDirection; |
|
88 } |
|
89 else if (y <= x/2) { |
84 if (m_vector.x() < 0) |
90 if (m_vector.x() < 0) |
85 dir = EWest ; |
91 dir = EWest ; |
86 else |
92 else |
87 dir = EEast ; |
93 dir = EEast ; |
88 } |
94 } |
89 else if (y > x/2 && y <= (x+x/2)) { |
95 else if (y > x/2 && y <= (x+x/2)) { |
90 if (m_vector.x() < 0) { |
96 if (m_vector.x() < 0) { |
91 if (m_vector.y() < 0 ) |
97 if (m_vector.y() < 0 ) |
105 dir = ESouth ; |
111 dir = ESouth ; |
106 else |
112 else |
107 dir = ENorth ; |
113 dir = ENorth ; |
108 } |
114 } |
109 |
115 |
110 if (m_loggingEnabled) { |
|
111 LOGARG("CHoveringGesture: x: %d y: %d direction: %d", m_vector.x(), m_vector.y(), dir) ; |
|
112 } |
|
113 |
|
114 return dir ; |
116 return dir ; |
115 } |
117 } |
116 |
118 |
117 QStm_TwoPointGesture::QStm_TwoPointGesture(QStm_GestureUid uid, const QPoint& loc, const QPoint& prevLoc) : |
119 QStm_TwoPointGesture::QStm_TwoPointGesture(QStm_GestureUid uid, const QPoint& loc, |
118 QStm_DirectionalGesture(uid, loc, prevLoc, NULL), |
120 const QPoint& prevLoc, QTime timestamp) : |
119 m_location2(prevLoc) |
121 QStm_DirectionalGesture(uid, loc, prevLoc, timestamp, NULL) |
120 { |
122 { |
|
123 m_location2 = prevLoc; |
121 } |
124 } |
122 |
125 |
123 |
126 |