-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettings_dialog.cpp.h
183 lines (153 loc) · 3.64 KB
/
settings_dialog.cpp.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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
#pragma once
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/button.h>
#include <wx/string.h>
#include <wx/bitmap.h>
#include <wx/image.h>
#include <wx/icon.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/sizer.h>
#include <wx/statbox.h>
#include <wx/stattext.h>
#include <wx/textctrl.h>
#include <wx/dialog.h>
#include <sstream>
#include <string>
struct SobelSettings
{
int depth = 1;
int type = 1;
double delta = 10.0;
};
struct LaplacianSettings
{
int scale = 1;
int delta = 1;
int ddepth = 1;
};
struct CannySettings
{
int lowthreshold = 125;
int highthreshold = 350;
};
struct GaussianSettings
{
double sigmaX = 1.0;
double sigmaY = 1.0;
};
struct Settings
{
SobelSettings sobel;
LaplacianSettings laplacian;
CannySettings canny;
GaussianSettings gaussian;
static double convertWxStringToDouble(wxString _s)
{
std::stringstream os;
os << _s;
return std::stod(os.str());
}
static int convertWxStringToInt(wxString _s)
{
std::stringstream os;
os << _s;
return std::stoi(os.str());
}
template<typename T>
static wxString convertDoubleToWxString(T t)
{
std::stringstream os;
os << t;
return os.str().c_str();
}
static std::string convertWxStringToString(wxString _s)
{
std::stringstream os;
os << _s;
return os.str();
}
bool empty = true;
Settings clone()
{
Settings _settings;
_settings.canny.highthreshold = this->canny.highthreshold;
_settings.canny.lowthreshold = this->canny.lowthreshold;
_settings.laplacian.ddepth = this->laplacian.ddepth;
_settings.laplacian.delta = this->laplacian.delta;
_settings.laplacian.scale = this->laplacian.scale;
_settings.gaussian.sigmaX = this->gaussian.sigmaX;
_settings.gaussian.sigmaY = this->gaussian.sigmaY;
_settings.sobel.delta = this->sobel.delta;
_settings.sobel.depth = this->sobel.depth;
_settings.sobel.type = this->sobel.type;
_settings.empty = this->empty;
return _settings;
}
};
class CSettingsDialog final : public wxDialog
{
private:
int getValueInt(wxTextCtrl* txtcrtl)
{
return Settings::convertWxStringToInt(txtcrtl->GetValue());
}
double getValueDouble(wxTextCtrl* txtcrtl)
{
return Settings::convertWxStringToDouble(txtcrtl->GetValue());
}
void setValueInt(int v, wxTextCtrl* txtcrtl)
{
wxString s = Settings::convertDoubleToWxString<int>(v);
txtcrtl->SetValue(s);
}
void setValueDouble(double v, wxTextCtrl* txtcrtl)
{
wxString s = Settings::convertDoubleToWxString<double>(v);
txtcrtl->SetValue(s);
}
protected:
wxButton* m_button6;
wxButton* m_button7;
wxButton* m_button8;
wxStaticText* m_staticText18;
wxTextCtrl* m_textCtrl16;
wxStaticText* m_staticText19;
wxTextCtrl* m_textCtrl17;
wxStaticText* m_staticText20;
wxTextCtrl* m_textCtrl18;
wxStaticText* m_staticText21;
wxTextCtrl* m_textCtrl19;
wxStaticText* m_staticText22;
wxTextCtrl* m_textCtrl20;
wxStaticText* m_staticText23;
wxTextCtrl* m_textCtrl21;
wxStaticText* m_staticText24;
wxTextCtrl* m_textCtrl22;
wxStaticText* m_staticText25;
wxTextCtrl* m_textCtrl23;
wxStaticText* m_staticText26;
wxTextCtrl* m_textCtrl24;
wxStaticText* m_staticText27;
wxTextCtrl* m_textCtrl25;
Settings _settings;
public:
CSettingsDialog( wxWindow* parent,
wxWindowID id = wxID_ANY,
const wxString& title = wxT("Settings"),
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxSize(559, 473),
long style = wxCAPTION | wxDEFAULT_DIALOG_STYLE);
~CSettingsDialog();
Settings getSettings() { return _settings; };
void setSettings(Settings& s)
{
_settings = s.clone();
};
void setValuesInTheUI();
void initSettings();
void getValuesFromUI();
};