89 return QMetaEnum::fromType<Gesture>().valueToKey(
m_gesture);
94 return QMetaEnum::fromType<Qt::MouseButtons>().valueToKey(
static_cast<int>(
m_button));
117 size_t MaxSequence,
int ScaleRatio,
119 : m_maxPoints(MaxPoints),
120 m_minPoints(MinPoints),
121 m_maxSequence(MaxSequence),
122 m_scaleRatio(ScaleRatio),
123 m_binPercent(BinPercent)
172 const QString gesture =
Translate(Timeout);
219 auto total_points =
static_cast<size_t>(
m_points.count());
240 size_t sequence_count = 0;
248 bool first_bin =
true;
255 int bound_x_1 =
m_minX + (delta_x / 3);
256 int bound_x_2 =
m_minX + (2 * (delta_x / 3));
258 int bound_y_1 =
m_minY + (delta_y / 3);
259 int bound_y_2 =
m_minY + (2 * (delta_y / 3));
263 bound_y_1 = ((
m_maxY +
m_minY - delta_x) / 2) + (delta_x / 3);
264 bound_y_2 = ((
m_maxY +
m_minY - delta_x) / 2) + (2 * (delta_x / 3));
268 bound_x_1 = ((
m_maxX +
m_minX - delta_y) / 2) + (delta_y / 3);
269 bound_x_2 = ((
m_maxX +
m_minX - delta_y) / 2) + (2 * (delta_y / 3));
281 current_bin =
determineBin(pt, bound_x_1, bound_x_2, bound_y_1,
285 prev_bin = (prev_bin == 0) ? current_bin : prev_bin;
287 if (prev_bin == current_bin)
294 if ((bin_count > (total_points *
m_binPercent)) || first_bin)
297 sequence +=
'0' + QChar(prev_bin);
303 prev_bin = current_bin;
308 sequence +=
'0' + QChar(current_bin);
346 int delx = Point.x() -
m_points.back().x();
347 int dely = Point.y() -
m_points.back().y();
350 if (abs(delx) > abs(dely))
357 (delx > 0) ? (ix < Point.x()) : (ix > Point.x());
358 ix += (delx > 0) ? 1 : -1)
361 fy += std::fabs(
static_cast<float>(dely) /
static_cast<float>(delx))
362 * ((dely < 0) ? -1.0F : 1.0F);
363 int iy =
static_cast<int>(fy);
377 (dely > 0) ? (iy < Point.y()) : (iy > Point.y());
378 iy += (dely > 0) ? 1 : -1)
381 fx += std::fabs(
static_cast<float>(delx) /
static_cast<float>(dely))
382 * ((delx < 0) ? -1.0F : 1.0F);
383 int ix =
static_cast<int>(fx);
A custom event that represents a mouse gesture.
static const Type kEventType
MythGestureEvent(Gesture gesture, Qt::MouseButton Button)
Create a MythGesture.
QString GetButtonName() const
QString GetName() const
Get the symbolic name of the gesture.
bool Record(QPoint Point, Qt::MouseButton Button)
Record a point.
bool HasMinimumPoints() const
Determine if the stroke has the minimum required points.
MythGestureEvent * GetGesture() const
Complete the gesture event of the last completed stroke.
bool Recording()
Determine if the stroke is being recorded.
MythGestureEvent::Gesture m_lastGesture
void Start()
Start recording.
static const std::map< QString, MythGestureEvent::Gesture > kSequences
MythGesture(size_t MaxPoints=10000, size_t MinPoints=50, size_t MaxSequence=20, int ScaleRatio=4, float BinPercent=0.07F)
Create a new stroke, specifying tuning values.
Qt::MouseButton m_lastButton
void Stop(bool Timeout=false)
Stop recording.
void AdjustExtremes(int X, int Y)
Adjust horizontal and vertical extremes.
QString Translate(bool Timeout)
Translate the stroke into a sequence.
static int determineBin(QPoint p, int x1, int x2, int y1, int y2)
A C++ ripoff of the stroke library for MythTV.