-
Notifications
You must be signed in to change notification settings - Fork 0
/
SensitivityModule.h
142 lines (131 loc) · 3.11 KB
/
SensitivityModule.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#ifndef SENSITIVITYMODULE_H
#define SENSITIVITYMODULE_H
#include <windows.h>
#include <QRect>
#include <map>
#include <QDebug>
#include <QMutex>
#include <memory>
typedef struct winData
{
HWND hwnd;
char title[256];
char className[256];
int showCmd;
long left, right, top, bottom;
winData()
: hwnd(NULL), showCmd(-1), left(-100), right(-100), top(-100), bottom(-100)
{
strcpy_s(title, "");
strcpy_s(className, "");
}
winData(const winData& arg)
:hwnd(arg.hwnd), showCmd(arg.showCmd), left(arg.left), right(arg.right), top(arg.top), bottom(arg.bottom)
{
strcpy_s(title, arg.title);
strcpy_s(className, arg.className);
}
} winData;
typedef struct winAssociation
{
winData win;
std::vector<QRect> boxes;
winAssociation()
{
boxes.clear();
memset(&win, 0, sizeof(win));
}
winAssociation(winData& arg)
{
memcpy(&win, &arg, sizeof(winData));
}
}winAssociation;
struct ocrData
{
//private:
// static std::shared_ptr<ocrData> prevInstance = nullptr;
// static std::shared_ptr<ocrData> currInstance;
//public:
// static std::shared_ptr<ocrData> getPrev()
// {
// if (!prevInstance)
// {
// prevInstance = std::make_shared<ocrData>(true);
// }
// return prevInstance;
// }
// static std::shared_ptr<ocrData> getCurr()
// {
// if (!currInstance)
// {
// currInstance = std::make_shared<ocrData>(true);
// }
// return currInstance;
// }
bool contains;
bool classified;
bool secondary;
int cycleCount;
int confidence;
std::vector<QRect> uBoxes;
std::vector<std::shared_ptr<winAssociation>> association;
void classify();
void clearAssociation();
bool present(HWND hwnd);
void updatePosition();
ocrData(bool sec) : cycleCount(0), confidence(0), contains(false), classified(false), secondary(sec)
{
uBoxes.clear();
association.clear();
}
ocrData(ocrData& arg) :cycleCount(arg.cycleCount), confidence(arg.confidence),
contains(arg.contains), classified(arg.classified), secondary(arg.secondary)
{
uBoxes.clear();
association.clear();
for (auto& box : arg.uBoxes)
{
uBoxes.push_back(box);
}
for (auto& assn : arg.association)
{
association.push_back(assn);
}
}
};
enum event
{
MOVED = 0,
RESIZED = 1,
MINMIZED = 2,
MAXIMIZED = 3,
HIDDEN = 4,
UNCHANGED = 5,
UNKNOWN = 6
};
class SensitivityModule
{
public:
SensitivityModule();
SensitivityModule(const SensitivityModule&) = delete;
static SensitivityModule& Get()
{
static SensitivityModule mInstance;
return mInstance;
}
std::map<HWND, winData> mMapWinInfo;
void update(bool& secondary);
bool updateRelative(bool& secondary);
void getList(bool secondary, std::vector<QRect>& boxes);
void fillAndClassify(bool& secondary, std::vector<QRect>& boxes);
std::vector<winData> getWinList(bool prev, bool secondary);
event trackEvent(winData& prev, winData& curr);
private:
QMutex mutex;
bool mReady;
void makeList(std::vector<QRect>& boxes);
std::map<HWND, winData> mPrevMapWinInfo;
std::map<HWND, std::vector<QRect>> mMapBoxInfo;
void updateWinInfo(bool& secondary);
};
#endif