blob: bd50081de21afbcc070a5c31674d7011657f8590 (
plain)
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
|
#pragma once
#include <QtWidgets/QWidget>
#include <QtGui/QImage>
#include <thread>
#include <mutex>
#include "uitypes.h"
class EntropyThread
{
BinaryViewRef m_data;
QImage* m_image;
size_t m_blockSize;
bool m_updated, m_running;
std::thread m_thread;
double m_averageEntropy;
int m_sampleCount;
mutable std::mutex m_mutex;
public:
EntropyThread(BinaryViewRef data, size_t blockSize, QImage* image);
~EntropyThread();
void Run();
bool IsUpdated() { return m_updated; }
void ResetUpdated() { m_updated = false; }
double GetAverageEntropy() const;
};
class TriageView;
class EntropyWidget : public QWidget
{
Q_OBJECT
TriageView* m_view;
BinaryViewRef m_data, m_rawData;
size_t m_blockSize;
int m_width;
QImage m_image;
EntropyThread* m_thread;
public:
EntropyWidget(QWidget* parent, TriageView* view, BinaryViewRef data);
virtual ~EntropyWidget();
virtual QSize sizeHint() const override;
double getAverageEntropy() const;
Q_SIGNALS:
void entropyUpdated(double avgEntropy);
protected:
virtual void paintEvent(QPaintEvent* event) override;
virtual void mousePressEvent(QMouseEvent* event) override;
virtual void mouseMoveEvent(QMouseEvent* event) override;
private Q_SLOTS:
void timerExpired();
};
|