-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmainwindow.h
115 lines (98 loc) · 3.44 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
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QtWidgets>
#include "opencv2/core/core.hpp"
#include <functional>
#include "ImgStore.h"
#include "ImgProc.h"
#include "histogramEqualization.h"
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE
typedef std::function<void(const cv::Mat&, cv::Mat&)> filterFunction;
class MainWindow : public QMainWindow {
Q_OBJECT
public:
MainWindow(QWidget *parent = nullptr);
~MainWindow() noexcept;
private:
enum mode {
GreyScale,
RGB
};
enum theme {
dark,
light
};
ImgStore& store;
ImgProc* imgProc;
std::string currentFileName = "";
Ui::MainWindow *ui;
std::vector<filterFunction> filterFunctions = {
[=](const cv::Mat& src, cv::Mat& dst) {
this->imgProc->gaussianFilter(src, dst);
},
[=](const cv::Mat& src, cv::Mat& dst) {
this->imgProc->medianFilter(src, dst);
},
[=](const cv::Mat& src, cv::Mat& dst) {
this->imgProc->lowPassFilter(src, dst);
},
[=](const cv::Mat& src, cv::Mat& dst) {
this->imgProc->highPassFilter(src, dst);
},
[=](const cv::Mat& src, cv::Mat& dst) {
this->imgProc->histEqualize(src, dst);
}
};
void resizeEvent(QResizeEvent* event);
void applyFilter(const std::function<void(const cv::Mat&, cv::Mat&)>& filter);
void displaySpatialandFreq(const cv::Mat& spatialImage, cv::Mat& freqImage);
void imageLoader(const mode& flag);
void changeTheme(const theme& themeName);
private slots:
void autoUpadateLabelSize();
void loadImage();
void loadGreyScaleImage();
void setLoadedImage(bool loaded, const cv::Mat& image);
void resetImage();
void saveFilteredImage();
void updateFileName(const QString& fileName);
void showPreview(const cv::Mat& image);
void deleteCurrentImage();
void changeFilters();
void showHist();
void applyGaussianFilter();
void applyMedianFilter();
void applyLowPassFilter();
void applyHighPassFilter();
void applyHistEqualization();
signals:
void imageLoaded(bool loaded, const cv::Mat& image);
void setPreview(const cv::Mat& image);
protected:
QPoint pressPos;
bool isMoving{false};
void mousePressEvent(QMouseEvent* event){
//save the press position (this is relative to the current widget)
pressPos= event->pos();
isMoving= true;
}
void mouseMoveEvent(QMouseEvent* event){
//isMoving flag makes sure that the drag and drop event originated
//from within the titlebar, because otherwise the window shouldn't be moved
if(isMoving){
//calculate difference between the press position and the new Mouse position
//(this is relative to the current widget)
QPoint diff= event->pos() - pressPos;
//move the window by diff
window()->move(window()->pos()+diff);
}
}
void mouseReleaseEvent(QMouseEvent* /*event*/){
//drag and drop operation end
isMoving= false;
}
};
#endif // MAINWINDOW_H