-
Notifications
You must be signed in to change notification settings - Fork 9
/
qwtThreadManager.cpp
88 lines (77 loc) · 1.48 KB
/
qwtThreadManager.cpp
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
#include "qwtThreadManager.h"
qwtThreadManager::qwtThreadManager(QObject* object /*= 0*/)
: QThread(object)
, m_quit(false)
{
}
void qwtThreadManager::run()
{
int nn = 0;
double *data = (double*)malloc(10000 * sizeof(double));
int hei = 0;
bool over = false;
m_quit = false;
while (!m_quit && nn < 10000)
{
// printf("P: %d\n", nn);
// const QString ttip = QStringLiteral("Image number %1.").arg(nn);
nn++;
// if (!ttip.isEmpty())
// {
for(int i = 0; i < 10000; i++)
data[i] = hei;
hei++;
if(hei > 100) hei = 0;
if(wf) {
if(layer == -1) {
// layer 0
if(nn < 500)
wf->appendT(0, data, 1000, 10);
else
wf->appendB(0, data, 1000, 10);
// layer 1
if(nn < 800)
wf->appendB(1, data, 1000, 10);
else
wf->appendT(1, data, 1000, 10);
// layer 2
if(nn < 500)
wf->appendR(2, data, 10, 500);
else {
if(!over) {
printf("Delete layer #2.\n");
wf->deleteLayer(2);
over = true;
}
}
} else {
if(nn < 500)
wf->appendT(layer, data, 1000, 10);
else
wf->appendB(layer, data, 1000, 10);
}
}
// }
//msleep(10);
usleep(15000);
// sleep(1);
}
// for(;;) {
printf("------------------------------------------------------------------- Thread finished\n");
// usleep(500000);
// }
}
void qwtThreadManager::quit()
{
m_quit = true;
QThread::quit();
}
void qwtThreadManager::stopAndClear()
{
quit();
wait();
}
qwtThreadManager::~qwtThreadManager()
{
stopAndClear();
}