MythTV  master
Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members

Contains the points in a stroke, and translates them into gestures. More...

#include <mythgesture.h>

Collaboration diagram for MythGesture:
Collaboration graph
[legend]

Public Member Functions

 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. More...
 
void Start ()
 Start recording. More...
 
void Stop (bool Timeout=false)
 Stop recording. More...
 
bool Recording ()
 Determine if the stroke is being recorded. More...
 
MythGestureEventGetGesture () const
 Complete the gesture event of the last completed stroke. More...
 
bool Record (QPoint Point, Qt::MouseButton Button)
 Record a point. More...
 

Private Member Functions

bool HasMinimumPoints () const
 Determine if the stroke has the minimum required points. More...
 
QString Translate (bool Timeout)
 Translate the stroke into a sequence. More...
 
void AdjustExtremes (int X, int Y)
 Adjust horizontal and vertical extremes. More...
 

Private Attributes

bool m_recording { false }
 
int m_minX { 10000 }
 
int m_maxX { -1 }
 
int m_minY { 10000 }
 
int m_maxY { -1 }
 
size_t m_maxPoints { 10000 }
 
size_t m_minPoints { 50 }
 
size_t m_maxSequence { 20 }
 
int m_scaleRatio { 4 }
 
float m_binPercent { 0.07F }
 
MythGestureEvent::Gesture m_lastGesture { MythGestureEvent::Unknown }
 
QList< QPoint > m_points
 
QMutex m_lock
 
Qt::MouseButton m_lastButton { Qt::NoButton }
 

Static Private Attributes

static const std::map< QString, MythGestureEvent::GesturekSequences
 

Detailed Description

Contains the points in a stroke, and translates them into gestures.

Because the indended use of the stop method is to be called by either the expiration of a timer or when an event is called (or both at the same time) it must have a mutex.

Definition at line 99 of file mythgesture.h.

Constructor & Destructor Documentation

◆ MythGesture()

MythGesture::MythGesture ( size_t  MaxPoints = 10000,
size_t  MinPoints = 50,
size_t  MaxSequence = 20,
int  ScaleRatio = 4,
float  BinPercent = 0.07F 
)
explicit

Create a new stroke, specifying tuning values.

Parameters
max_pointsThe maximum number of points to record.
min_pointsThe minimum number of points to record.
max_sequenceThe maximum producible sequence size.
scale_ratioThe stroke scale ratio
bin_percentThe bin count percentage required to add to the sequence.

Definition at line 116 of file mythgesture.cpp.

Member Function Documentation

◆ Start()

void MythGesture::Start ( )

Start recording.

Definition at line 151 of file mythgesture.cpp.

Referenced by MythMainWindow::eventFilter().

◆ Stop()

void MythGesture::Stop ( bool  Timeout = false)

Stop recording.

This method stores the gesture, as it is, and resets all information.

Definition at line 163 of file mythgesture.cpp.

Referenced by MythMainWindow::eventFilter(), and MythMainWindow::MouseTimeout().

◆ Recording()

bool MythGesture::Recording ( )

Determine if the stroke is being recorded.

Returns
True if recording is in progress, otherwise, false.

Definition at line 142 of file mythgesture.cpp.

Referenced by MythMainWindow::eventFilter(), MythMainWindow::MouseTimeout(), and Record().

◆ GetGesture()

MythGestureEvent * MythGesture::GetGesture ( ) const

Complete the gesture event of the last completed stroke.

Returns
A new gesture event, or nullptr on error.

Definition at line 190 of file mythgesture.cpp.

Referenced by MythMainWindow::eventFilter(), and MythMainWindow::MouseTimeout().

◆ Record()

bool MythGesture::Record ( QPoint  Point,
Qt::MouseButton  Button 
)

Record a point.

Parameters
PointThe point to record.
Returns
True if the point was recorded, otherwise, false.

Definition at line 331 of file mythgesture.cpp.

Referenced by MythMainWindow::eventFilter().

◆ HasMinimumPoints()

bool MythGesture::HasMinimumPoints ( ) const
private

Determine if the stroke has the minimum required points.

Returns
true if the gesture can be translated, otherwise, false.

Definition at line 322 of file mythgesture.cpp.

◆ Translate()

QString MythGesture::Translate ( bool  Timeout)
private

Translate the stroke into a sequence.

Returns
The sequence string made by the mouse.
Note
The points will be removed during this method.

Definition at line 217 of file mythgesture.cpp.

Referenced by Stop().

◆ AdjustExtremes()

void MythGesture::AdjustExtremes ( int  X,
int  Y 
)
private

Adjust horizontal and vertical extremes.

Parameters
xThe new horizontal extreme.
yThe new vertical extreme

Definition at line 131 of file mythgesture.cpp.

Referenced by Record().

Member Data Documentation

◆ m_recording

bool MythGesture::m_recording { false }
private

Definition at line 119 of file mythgesture.h.

Referenced by Recording(), Start(), and Stop().

◆ m_minX

int MythGesture::m_minX { 10000 }
private

Definition at line 120 of file mythgesture.h.

Referenced by AdjustExtremes(), Stop(), and Translate().

◆ m_maxX

int MythGesture::m_maxX { -1 }
private

Definition at line 121 of file mythgesture.h.

Referenced by AdjustExtremes(), Stop(), and Translate().

◆ m_minY

int MythGesture::m_minY { 10000 }
private

Definition at line 122 of file mythgesture.h.

Referenced by AdjustExtremes(), Stop(), and Translate().

◆ m_maxY

int MythGesture::m_maxY { -1 }
private

Definition at line 123 of file mythgesture.h.

Referenced by AdjustExtremes(), Stop(), and Translate().

◆ m_maxPoints

size_t MythGesture::m_maxPoints { 10000 }
private

Definition at line 124 of file mythgesture.h.

Referenced by Record(), and Translate().

◆ m_minPoints

size_t MythGesture::m_minPoints { 50 }
private

Definition at line 125 of file mythgesture.h.

Referenced by HasMinimumPoints(), and Translate().

◆ m_maxSequence

size_t MythGesture::m_maxSequence { 20 }
private

Definition at line 126 of file mythgesture.h.

Referenced by Translate().

◆ m_scaleRatio

int MythGesture::m_scaleRatio { 4 }
private

Definition at line 127 of file mythgesture.h.

Referenced by Translate().

◆ m_binPercent

float MythGesture::m_binPercent { 0.07F }
private

Definition at line 128 of file mythgesture.h.

Referenced by Translate().

◆ m_lastGesture

MythGestureEvent::Gesture MythGesture::m_lastGesture { MythGestureEvent::Unknown }
private

Definition at line 129 of file mythgesture.h.

Referenced by GetGesture(), and Stop().

◆ m_points

QList<QPoint> MythGesture::m_points
private

Definition at line 130 of file mythgesture.h.

Referenced by HasMinimumPoints(), Record(), and Translate().

◆ m_lock

QMutex MythGesture::m_lock
private

Definition at line 131 of file mythgesture.h.

Referenced by Recording(), Start(), and Stop().

◆ kSequences

const std::map< QString, MythGestureEvent::Gesture > MythGesture::kSequences
staticprivate

◆ m_lastButton

Qt::MouseButton MythGesture::m_lastButton { Qt::NoButton }
private

Definition at line 133 of file mythgesture.h.

Referenced by GetGesture(), and Record().


The documentation for this class was generated from the following files:
MythGestureEvent::Down
@ Down
Definition: mythgesture.h:50
MythGestureEvent::LeftThenUp
@ LeftThenUp
Definition: mythgesture.h:65
MythGestureEvent::DownThenLeft
@ DownThenLeft
Definition: mythgesture.h:63
MythGestureEvent::UpRight
@ UpRight
Definition: mythgesture.h:56
MythGestureEvent::Up
@ Up
Definition: mythgesture.h:49
MythGestureEvent::RightThenDown
@ RightThenDown
Definition: mythgesture.h:68
MythGestureEvent::LongClick
@ LongClick
Definition: mythgesture.h:76
MythGestureEvent::UpThenLeft
@ UpThenLeft
Definition: mythgesture.h:61
MythGestureEvent::DownThenUp
@ DownThenUp
Definition: mythgesture.h:72
MythGestureEvent::Right
@ Right
Definition: mythgesture.h:52
MythGestureEvent::UpLeft
@ UpLeft
Definition: mythgesture.h:55
MythGestureEvent::DownThenRight
@ DownThenRight
Definition: mythgesture.h:64
MythGestureEvent::Click
@ Click
Definition: mythgesture.h:77
MythGestureEvent::Left
@ Left
Definition: mythgesture.h:51
MythGestureEvent::UpThenDown
@ UpThenDown
Definition: mythgesture.h:71
MythGestureEvent::LeftThenDown
@ LeftThenDown
Definition: mythgesture.h:66
MythGestureEvent::DownLeft
@ DownLeft
Definition: mythgesture.h:57
MythGestureEvent::UpThenRight
@ UpThenRight
Definition: mythgesture.h:62
MythGestureEvent::RightThenLeft
@ RightThenLeft
Definition: mythgesture.h:69
MythGestureEvent::RightThenUp
@ RightThenUp
Definition: mythgesture.h:67
MythGestureEvent::DownRight
@ DownRight
Definition: mythgesture.h:58
MythGestureEvent::LeftThenRight
@ LeftThenRight
Definition: mythgesture.h:70