-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtransform.h
84 lines (73 loc) · 1.83 KB
/
transform.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#ifndef MICKEY_TRANSFORM__H
#define MICKEY_TRANSFORM__H
#include <QWidget>
#include <QBoxLayout>
#include <QSettings>
#include <QPixmap>
#include "mickey.h"
class MickeyCurveShow : public QWidget
{
Q_OBJECT
public:
MickeyCurveShow(QWidget *parent = 0);
void updatePixmap(QPointF curPoints[], QPointF newPoints[], int pointCount);
private:
QPixmap *img;
virtual void paintEvent(QPaintEvent * /* event */);
virtual void resizeEvent(QResizeEvent * event){emit resized(); QWidget::resizeEvent(event);};
signals:
void resized();
};
typedef struct {
int sensitivity, deadzone, curvature, smoothing;
bool stepOnly;
} setup_t;
class MickeysAxis : public QObject
{
Q_OBJECT
public:
MickeysAxis();
~MickeysAxis();
void step(float valX, float valY, int elapsed, float &accX, float &accY);
void smooth(float &valX, float &valY);
void applySettings();
void revertSettings();
void keepSettings();
private:
int sensitivity;
float prevX, prevY;
float response(float mag, setup_t *s = NULL);
float getSpeed(int sens);
void updatePixmap();
setup_t oldSetup, newSetup, setup;
MickeyCurveShow *curveShow;
// public slots:
// void redraw(){update();};
private slots:
void axisChanged();
void curveShow_resized(){updatePixmap();};
signals:
void newSettings();
};
class MickeyTransform : public QObject
{
Q_OBJECT
public:
MickeyTransform();
~MickeyTransform();
void update(float valX, float valY, Mickey::Mode mode, int elapsed, float &x, float &y);
void startCalibration();
void finishCalibration();
void cancelCalibration();
void applySettings();
void revertSettings();
void keepSettings();
private:
float accX, accY;
bool calibrating;
MickeysAxis axis;
float prevValX, prevValY;
float maxValX, minValX, maxValY, minValY, prevMaxValX, prevMaxValY;
float currMaxValX, currMaxValY;
};
#endif