-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGUIMyFrame1.cpp
More file actions
162 lines (107 loc) · 3.18 KB
/
GUIMyFrame1.cpp
File metadata and controls
162 lines (107 loc) · 3.18 KB
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
#include "GUIMyFrame1.h"
#include "minimalize.hpp"
#include "rotate.hpp"
#include "graph.hpp"
#include <string>
#include <wx/log.h>
// for wxGraphicContext
// #include <wx/graphics.h>
static constexpr int depth = 3;
GUIMyFrame1::GUIMyFrame1( wxWindow* parent )
:
MyFrame1( parent )
{
wxInitAllImageHandlers();
m_file_dialog = std::make_shared<wxFileDialog>(this, _("Choose a file"), _(""), _(""), _("."), wxFD_OPEN);
}
void GUIMyFrame1::MainFormClose(wxCloseEvent& event)
{
this->Destroy();
}
void GUIMyFrame1::repaint() {
if (image.image.IsOk() == false)
return;
wxClientDC dc(Panel);
dc.Clear();
auto bitmap = wxBitmap(image.image, depth);
dc.DrawBitmap(bitmap, 0, 0);
// image.image.SaveFile("test.png", wxBITMAP_TYPE_PNG);
}
void GUIMyFrame1::repaint_graph() {
if (graph.IsOk() == false)
return;
wxClientDC dc(m_panel2);
dc.Clear();
auto bitmap = wxBitmap(graph, depth);
dc.DrawBitmap(bitmap, 0, 0);
}
void GUIMyFrame1::Panel_Repaint(wxUpdateUIEvent& event)
{
//repaint();
}
void GUIMyFrame1::click_button_load(wxCommandEvent& event)
{
// FIXME:
// temporarly loading fixed photo
wxString filename;
m_file_dialog->SetWildcard("BMP files (*.bmp)|*.bmp");
if (m_file_dialog->ShowModal() == wxID_OK) {
filename = m_file_dialog->GetPath();
wxImage tmpimg;
tmpimg.LoadFile(filename, wxBITMAP_TYPE_BMP);
image = tmpimg;
}
repaint();
}
void GUIMyFrame1::Wage_1_Update(wxCommandEvent& event)
{
}
void GUIMyFrame1::Wage_2_Update(wxCommandEvent& event)
{
}
void GUIMyFrame1::Wage_3_Update(wxCommandEvent& event)
{
}
void GUIMyFrame1::Wage_4_Update(wxCommandEvent& event)
{
}
void GUIMyFrame1::Angle_Update(wxCommandEvent& event)
{
}
void GUIMyFrame1::Wages_Calculate(wxCommandEvent& event)
{
auto angle_value = std::stof(value_angle_control->GetLineText(0).ToStdString());
auto angle = AngleDeg(angle_value);
auto result = minimalize(image, angle);
auto factrs = result.first;
auto error_vec = result.second;
graph = draw_graph(error_vec, m_panel2->GetSize());
auto text1 = std::to_string(factrs[0]);
auto text2 = std::to_string(factrs[1]);
auto text3 = std::to_string(factrs[2]);
auto text4 = std::to_string(factrs[3]);
value_wage_1->SetValue(text1);
value_wage_2->SetValue(text2);
value_wage_3->SetValue(text3);
value_wage_4->SetValue(text4);
value_variation->SetLabel(std::to_string(*error_vec.rbegin()));
repaint_graph();
}
void GUIMyFrame1::Rotate_Bitmap(wxCommandEvent& event)
{
auto value1 = std::stof(value_wage_1->GetLineText(0).ToStdString());
auto value2 = std::stof(value_wage_2->GetLineText(0).ToStdString());
auto value3 = std::stof(value_wage_3->GetLineText(0).ToStdString());
auto value4 = std::stof(value_wage_4->GetLineText(0).ToStdString());
auto factrs = Factors(value1, value2, value3, value4);
auto angle_value = std::stof(value_angle_control->GetLineText(0).ToStdString());
auto angle = AngleDeg(angle_value);
image = rotate(image, angle, factrs);
repaint();
}
void GUIMyFrame1::Graph_Paint(wxUpdateUIEvent& event)
{
}
void GUIMyFrame1::Variation_Update()
{
}