forked from karlphillip/GraphicsProgramming
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathipc_window.cpp
More file actions
131 lines (106 loc) · 3.67 KB
/
Copy pathipc_window.cpp
File metadata and controls
131 lines (106 loc) · 3.67 KB
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
/* Copyright (C) 2013 Karl Phillip Buhr <karlphillip@gmail.com>
*
* This work is licensed under the Creative Commons Attribution-ShareAlike License.
* To view a copy of this license, visit:
* https://creativecommons.org/licenses/by-sa/2.5/legalcode
*
* Or to read the human-readable summary of the license:
* https://creativecommons.org/licenses/by-sa/2.5/
*/
#include "ipc_window.h"
#include <iostream>
#include <QApplication>
IPCWindow::IPCWindow()
{
setStyleSheet("background-color: black;");
setFixedSize(640, 480);
_label = new QLabel(this);
_label->setGeometry(QRect(0, 0, 640, 480));
QSize img_sz = _gesture_handler.image_size();
if (img_sz.width() && img_sz.height())
{
setFixedSize(img_sz.width(), img_sz.height());
_label->setGeometry(QRect(0, 0, img_sz.width(), img_sz.height()));
}
_status_label = new QLabel(statusBar());
_status_label->setAlignment(Qt::AlignCenter);
_status_label->setStyleSheet("color: orange; background-color: black;");
QFont sb_font("Arial", 11);
sb_font.setBold(true);
_status_label->setFont(sb_font);
_status_label->setText("Running...");
statusBar()->addWidget(_status_label, 1);
QObject::connect(&_gesture_handler, SIGNAL(notify_gesture(PXCGesture::Gesture)),
this, SLOT(_gesture_evt(PXCGesture::Gesture)));
QObject::connect(&_gesture_handler, SIGNAL(notify_image(QPixmap)),
this, SLOT(_image_evt(QPixmap)));
if (!_gesture_handler.start())
{
_status_label->setText("!!! Failed to start gesture handler.");
qApp->quit();
}
}
IPCWindow::~IPCWindow()
{
}
void IPCWindow::_gesture_evt(PXCGesture::Gesture g_evt)
{
switch (g_evt.label)
{
case PXCGesture::Gesture::LABEL_HAND_WAVE:
_status_label->setText("WAVE");
break;
case PXCGesture::Gesture::LABEL_NAV_SWIPE_LEFT:
_status_label->setText("SWIPE LEFT");
break;
case PXCGesture::Gesture::LABEL_NAV_SWIPE_RIGHT:
_status_label->setText("SWIPE RIGHT");
break;
case PXCGesture::Gesture::LABEL_NAV_SWIPE_UP:
_status_label->setText("SWIPE UP");
break;
case PXCGesture::Gesture::LABEL_NAV_SWIPE_DOWN:
_status_label->setText("SWIPE DOWN");
break;
case PXCGesture::Gesture::LABEL_HAND_CIRCLE:
_status_label->setText("CIRCLE");
break;
case PXCGesture::Gesture::LABEL_POSE_THUMB_UP:
_status_label->setText("THUMB UP");
//std::cout << "THUMB UP" << std::endl;
break;
case PXCGesture::Gesture::LABEL_POSE_THUMB_DOWN:
_status_label->setText("THUMB DOWN");
//std::cout << "THUMB DOWN" << std::endl;
break;
case PXCGesture::Gesture::LABEL_POSE_PEACE:
_status_label->setText("PEACE");
//std::cout << "PEACE" << std::endl;
break;
case PXCGesture::Gesture::LABEL_POSE_BIG5:
_status_label->setText("BIG5");
//std::cout << "BIG5" << std::endl;
break;
default:
QString str("UNKNOWN: ");
str += g_evt.label;
_status_label->setText(str);
break;
}
}
void IPCWindow::_image_evt(QPixmap pixmap)
{
_label->setPixmap(pixmap);
}
void IPCWindow::keyPressEvent(QKeyEvent* evt)
{
switch (evt->key())
{
case Qt::Key_Escape:
qApp->quit();
break;
default:
evt->ignore();
break;
}
}