summaryrefslogtreecommitdiff
path: root/examples/triage/entropy.h
blob: a48097c41672629331962c3c75c7ef862b8ac158 (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
#pragma once

#include <QtWidgets/QWidget>
#include <QtGui/QImage>
#include <thread>
#include "uitypes.h"


class EntropyThread
{
	BinaryViewRef m_data;
	QImage* m_image;
	size_t m_blockSize;
	bool m_updated, m_running;
	std::thread m_thread;

  public:
	EntropyThread(BinaryViewRef data, size_t blockSize, QImage* image);
	~EntropyThread();

	void Run();
	bool IsUpdated() { return m_updated; }
	void ResetUpdated() { m_updated = false; }
};


class TriageView;

class EntropyWidget : public QWidget
{
	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;

  protected:
	virtual void paintEvent(QPaintEvent* event) override;
	virtual void mousePressEvent(QMouseEvent* event) override;

  private Q_SLOTS:
	void timerExpired();
};