-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainwindow.h
132 lines (104 loc) · 2.98 KB
/
mainwindow.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
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QPushButton>
#include <QGridLayout>
#include <QtGui>
#include <ic_barcode.h>
#include "cgrabber.h"
// Define custom event identifier for new images received
const QEvent::Type NEW_IMAGE_EVENT = static_cast<QEvent::Type>(QEvent::User + 1);
// Define custom event subclass for new image
class NewImageEvent : public QEvent
{
public:
NewImageEvent(const int customData1, const int customData2):
QEvent(NEW_IMAGE_EVENT),
m_customData1(customData1),
m_customData2(customData2)
{
}
int getCustomData1() const
{
return m_customData1;
}
int getCustomData2() const
{
return m_customData2;
}
private:
int m_customData1;
int m_customData2;
};
// Define your custom event identifier
const QEvent::Type BARCODE_FOUND_EVENT = static_cast<QEvent::Type>(QEvent::User + 1);
// Define your custom event subclass
class BarcodeFoundEvent : public QEvent
{
public:
BarcodeFoundEvent(const int customData1, const int customData2):
QEvent(BARCODE_FOUND_EVENT),
m_customData1(customData1),
m_customData2(customData2)
{
}
int getCustomData1() const
{
return m_customData1;
}
int getCustomData2() const
{
return m_customData2;
}
private:
int m_customData1;
int m_customData2;
};
QT_BEGIN_NAMESPACE
namespace Ui
{
class MainWindow;
}
QT_END_NAMESPACE
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = nullptr);
~MainWindow();
void postNewImageEvent(const int customData1, const int customData2);
void postBarcodeFoundEvent(const int customData1, const int customData2);
private slots:
void on_actionSave_Image_triggered();
private:
void OnSelectDevice();
void OnDeviceProperties();
void LoadLastUsedDevice();
private slots:
void on_actionLoad_Configuration_triggered();
void on_actionSave_Configuration_triggered();
void on_actionExit_triggered();
void on_actionSelect_triggered();
void on_actionProperties_triggered();
private:
Ui::MainWindow* _ui = nullptr;
CGrabber _Grabber;
static GstFlowReturn NewImageCallback(GstAppSink *appsink, gpointer user_data);
struct callback_user_data
{
MainWindow *pMainWindow;
int framecount;
ICBarcode_Scanner* pIC_BarcodeScanner;
int FoundBarcodes;
std::vector<ICBarcode_Result> BarCodes;
GstSample *sample;
bool busy;
} _callback_user_data = {};
void customEvent(QEvent * event);
void onNewImageEvent(const NewImageEvent *event);
void handleBarcodeFoundEvent(const BarcodeFoundEvent *event);
std::string getDeviceFile();
void startVideo();
static void findBarcodes(callback_user_data *pData);
};
#endif // MAINWINDOW_H