Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qtuiotoken_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QTUIOOBJECT_P_H
5#define QTUIOOBJECT_P_H
6
7#include <Qt>
8#include <qmath.h>
9
11
20{
21public:
22 QTuioToken(int id = -1)
23 : m_id(id)
24 , m_classId(-1)
25 , m_x(0)
26 , m_y(0)
27 , m_vx(0)
28 , m_vy(0)
29 , m_acceleration(0)
30 , m_angle(0)
31 , m_angularVelocity(0)
32 , m_angularAcceleration(0)
33 , m_state(QEventPoint::State::Pressed)
34 {
35 }
36
37 int id() const { return m_id; }
38
39 int classId() const { return m_classId; }
40 void setClassId(int classId) { m_classId = classId; }
41
42 void setX(float x)
43 {
45 !qFuzzyCompare(m_x + 2.0, x + 2.0)) { // +2 because 1 is a valid value, and qFuzzyCompare can't cope with 0.0
47 }
48 m_x = x;
49 }
50 float x() const { return m_x; }
51
52 void setY(float y)
53 {
55 !qFuzzyCompare(m_y + 2.0, y + 2.0)) { // +2 because 1 is a valid value, and qFuzzyCompare can't cope with 0.0
57 }
58 m_y = y;
59 }
60 float y() const { return m_y; }
61
62 void setVX(float vx) { m_vx = vx; }
63 float vx() const { return m_vx; }
64
65 void setVY(float vy) { m_vy = vy; }
66 float vy() const { return m_vy; }
67
68 void setAcceleration(float acceleration) { m_acceleration = acceleration; }
69 float acceleration() const { return m_acceleration; }
70
71 float angle() const { return m_angle; }
72 void setAngle(float angle)
73 {
74 if (angle > M_PI)
75 angle = angle - M_PI * 2.0; // zero is pointing upwards, and is the default; but we want to have negative angles when rotating left
77 !qFuzzyCompare(m_angle + 2.0, angle + 2.0)) { // +2 because 1 is a valid value, and qFuzzyCompare can't cope with 0.0
79 }
80 m_angle = angle;
81 }
82
83 float angularVelocity() const { return m_angularVelocity; }
84 void setAngularVelocity(float angularVelocity) { m_angularVelocity = angularVelocity; }
85
86 float angularAcceleration() const { return m_angularAcceleration; }
87 void setAngularAcceleration(float angularAcceleration) { m_angularAcceleration = angularAcceleration; }
88
89 void setState(const QEventPoint::State &state) { m_state = state; }
90 QEventPoint::State state() const { return m_state; }
91
92private:
93 int m_id; // sessionID, temporary object ID
94 int m_classId; // classID (e.g. marker ID)
95 float m_x;
96 float m_y;
97 float m_vx;
98 float m_vy;
99 float m_acceleration;
100 float m_angle;
101 float m_angularVelocity;
102 float m_angularAcceleration;
103 QEventPoint::State m_state;
104};
105Q_DECLARE_TYPEINFO(QTuioToken, Q_RELOCATABLE_TYPE); // Q_PRIMITIVE_TYPE: not possible: m_id, m_classId == -1
106
108
109#endif // QTUIOOBJECT_P_H
The QEventPoint class provides information about a point in a QPointerEvent.
Definition qeventpoint.h:20
State
Specifies the state of this event point.
Definition qeventpoint.h:48
QTuioToken(int id=-1)
void setAngularAcceleration(float angularAcceleration)
void setX(float x)
void setAcceleration(float acceleration)
float y() const
float angularAcceleration() const
float vy() const
int id() const
float angularVelocity() const
int classId() const
void setVY(float vy)
QEventPoint::State state() const
void setState(const QEventPoint::State &state)
void setAngle(float angle)
void setClassId(int classId)
void setY(float y)
float acceleration() const
float angle() const
void setAngularVelocity(float angularVelocity)
float x() const
float vx() const
void setVX(float vx)
Combined button and popup list for selecting options.
bool qFuzzyCompare(qfloat16 p1, qfloat16 p2) noexcept
Definition qfloat16.h:333
#define M_PI
Definition qmath.h:209
GLint GLint GLint GLint GLint x
[0]
GLenum GLuint id
[7]
GLfloat angle
GLint y
@ Q_RELOCATABLE_TYPE
Definition qtypeinfo.h:158
#define Q_DECLARE_TYPEINFO(TYPE, FLAGS)
Definition qtypeinfo.h:180