Mercurial > mercurial > hgweb_kaigo.hg.cgi
comparison horori/eraline/src/geraline.cpp @ 0:aaaa401818a1 draft
first commit.
author | pyon <pyon@macmini> |
---|---|
date | Mon, 24 May 2021 21:32:58 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:aaaa401818a1 |
---|---|
1 // Filename : geraline.cpp | |
2 // Last Change: 2021-01-29 金 16:30:52. | |
3 // | |
4 #include <wx/dir.h> | |
5 #include <wx/msgdlg.h> | |
6 #include <wx/textfile.h> | |
7 #include <wx/filename.h> | |
8 #include <wx/datetime.h> | |
9 #include "geraline.h" | |
10 | |
11 #define GRID_SZ 9 | |
12 #define GRID_W 100 | |
13 #define GRID_H 60 | |
14 #define GRID_DY 30 // offset | |
15 #define ORGIMG_W 2480 | |
16 #define ORGIMG_H 3508 | |
17 #define THUMB_W 400 | |
18 #define THUMB_H 560 | |
19 | |
20 EralineFrame::EralineFrame(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style) | |
21 : wxFrame(parent, id, title, pos, size, style) | |
22 { | |
23 CreateControls(); | |
24 | |
25 // Connect Events | |
26 this->Connect(wxEVT_SIZE, wxSizeEventHandler(EralineFrame::OnSize)); | |
27 m_dirPickerInDir->Connect(wxEVT_COMMAND_DIRPICKER_CHANGED, wxFileDirPickerEventHandler(EralineFrame::OnInDirChanged), NULL, this); | |
28 m_dataViewListCtrl->Connect(wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED, wxDataViewEventHandler(EralineFrame::OnItemSelected), NULL, this); | |
29 m_bitmapThumb->Connect(wxEVT_LEFT_DCLICK, wxMouseEventHandler(EralineFrame::OnThumbDClicked), NULL, this); | |
30 m_bitmapZoom->Connect(wxEVT_LEFT_DCLICK, wxMouseEventHandler(EralineFrame::OnZoomDClicked), NULL, this); | |
31 m_gridView->Connect(wxEVT_GRID_RANGE_SELECT, wxGridRangeSelectEventHandler(EralineFrame::OnRangeSelect), NULL, this); | |
32 /* | |
33 m_spinCtrlY->Connect( wxEVT_COMMAND_SPINCTRL_UPDATED, wxSpinEventHandler( EralineFrame::OnSpinY ), NULL, this ); | |
34 m_spinCtrlY->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( EralineFrame::OnSpinYText ), NULL, this ); | |
35 m_spinCtrlH->Connect( wxEVT_COMMAND_SPINCTRL_UPDATED, wxSpinEventHandler( EralineFrame::OnSpinH ), NULL, this ); | |
36 m_spinCtrlH->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( EralineFrame::OnSpinHText ), NULL, this ); | |
37 */ | |
38 m_buttonErase->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(EralineFrame::OnErase), NULL, this); | |
39 | |
40 m_textCtrlMsg->AppendText(wxString::Format(wxT("Scale = %2.4f x %2.4f\n"), 1.0 * THUMB_W / ORGIMG_W, 1.0 * THUMB_H / ORGIMG_H)); | |
41 | |
42 m_file = wxT("image/eraline.tif"); | |
43 LoadFile(); | |
44 } | |
45 | |
46 EralineFrame::~EralineFrame() | |
47 { | |
48 // Disconnect Events | |
49 this->Disconnect(wxEVT_SIZE, wxSizeEventHandler(EralineFrame::OnSize)); | |
50 m_dirPickerInDir->Disconnect(wxEVT_COMMAND_DIRPICKER_CHANGED, wxFileDirPickerEventHandler(EralineFrame::OnInDirChanged), NULL, this); | |
51 m_dataViewListCtrl->Disconnect(wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED, wxDataViewEventHandler(EralineFrame::OnItemSelected), NULL, this); | |
52 m_bitmapThumb->Disconnect(wxEVT_LEFT_DCLICK, wxMouseEventHandler(EralineFrame::OnThumbDClicked), NULL, this); | |
53 m_bitmapZoom->Disconnect(wxEVT_LEFT_DCLICK, wxMouseEventHandler(EralineFrame::OnZoomDClicked), NULL, this); | |
54 m_gridView->Disconnect(wxEVT_GRID_RANGE_SELECT, wxGridRangeSelectEventHandler(EralineFrame::OnRangeSelect), NULL, this); | |
55 /* | |
56 m_spinCtrlY->Disconnect( wxEVT_COMMAND_SPINCTRL_UPDATED, wxSpinEventHandler( EralineFrame::OnSpinY ), NULL, this ); | |
57 m_spinCtrlY->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( EralineFrame::OnSpinYText ), NULL, this ); | |
58 m_spinCtrlH->Disconnect( wxEVT_COMMAND_SPINCTRL_UPDATED, wxSpinEventHandler( EralineFrame::OnSpinH ), NULL, this ); | |
59 m_spinCtrlH->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( EralineFrame::OnSpinHText ), NULL, this ); | |
60 */ | |
61 m_buttonErase->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(EralineFrame::OnErase), NULL, this); | |
62 } | |
63 | |
64 // Event-Handlers | |
65 void EralineFrame::OnSize(wxSizeEvent& event) | |
66 { | |
67 event.Skip(); | |
68 } | |
69 | |
70 void EralineFrame::OnInDirChanged(wxFileDirPickerEvent& event) | |
71 { | |
72 m_dataViewListCtrl->DeleteAllItems(); | |
73 wxString path = m_dirPickerInDir->GetPath(); | |
74 wxDir dir(path); | |
75 if (!dir.IsOpened()) return; | |
76 | |
77 int n = 0; | |
78 wxString file; | |
79 bool cont = dir.GetFirst(&file, wxT("*.tif"), wxDIR_FILES); | |
80 | |
81 wxVector<wxVariant> data; | |
82 while (cont) { | |
83 wxFileName fname(path + wxFILE_SEP_PATH + file); | |
84 wxString sz = wxString::Format(wxT("%s KB"), (fname.GetSize() / 1024).ToString()); | |
85 wxString dt = fname.GetModificationTime().Format(wxT("%Y-%m-%d %H:%M:%S")); | |
86 | |
87 data.push_back(wxVariant(file)); | |
88 data.push_back(wxVariant(sz)); | |
89 data.push_back(wxVariant(dt)); | |
90 m_dataViewListCtrl->AppendItem(data); | |
91 data.clear(); | |
92 n++; | |
93 cont = dir.GetNext(&file); | |
94 } | |
95 | |
96 m_textCtrlMsg->AppendText(wxString::Format(wxT("Input Directory Changed (%d files).\n"), n)); | |
97 m_dirPickerOutDir->SetPath(path); | |
98 } | |
99 | |
100 void EralineFrame::OnErase(wxCommandEvent& WXUNUSED(event)) | |
101 { | |
102 wxString indir = m_dirPickerInDir->GetPath(); | |
103 wxString outdir = m_dirPickerOutDir->GetPath(); | |
104 if (indir.IsSameAs(outdir)) { | |
105 m_textCtrlMsg->AppendText(wxT("Error: Output direcoty is same Input directory.\n")); | |
106 wxMessageBox(wxT("Bad Folder")); | |
107 return; | |
108 } | |
109 | |
110 wxString cmd, infile, outfile; | |
111 | |
112 wxTextFile textfile; | |
113 wxString batchfile = outdir + wxFILE_SEP_PATH + wxT("a.bat"); | |
114 textfile.Create(batchfile); | |
115 | |
116 textfile.AddLine(wxT("SET INDIR=") + indir); | |
117 textfile.AddLine(wxT("SET OUTDIR=") + outdir); | |
118 textfile.AddLine(wxT("SET ERALINE=") + wxGetCwd() + wxFILE_SEP_PATH + wxT("eraline.exe")); | |
119 | |
120 // > eraline.exe y h in.tif out.tif | |
121 for (int r = 0; r < m_dataViewListCtrl->GetItemCount(); r++) { | |
122 cmd = wxString::Format(wxT("%%ERALINE%% %d %d %%INDIR%%%s %%OUTDIR%%%s"), | |
123 //m_spinCtrlY->GetValue(), 1, | |
124 m_spinCtrlY->GetValue(), m_spinCtrlH->GetValue(), | |
125 wxFILE_SEP_PATH + m_dataViewListCtrl->GetTextValue(r, 0), | |
126 wxFILE_SEP_PATH + m_dataViewListCtrl->GetTextValue(r, 0) | |
127 ); | |
128 textfile.AddLine(cmd); | |
129 } | |
130 | |
131 wxCSConv cust(wxT("cp932")); | |
132 textfile.Write(wxTextFileType_Dos, cust); | |
133 textfile.Close(); | |
134 | |
135 wxExecute(batchfile, wxEXEC_SYNC|wxEXEC_HIDE_CONSOLE, NULL, NULL); | |
136 m_textCtrlMsg->AppendText(wxT("Process done.\n")); | |
137 wxMessageBox(wxT("Process done.")); | |
138 } | |
139 | |
140 void EralineFrame::OnThumbDClicked(wxMouseEvent& event) | |
141 { | |
142 int x, y; | |
143 event.GetPosition(&x, &y); | |
144 m_x0 = (int)(1.0 * ORGIMG_W / THUMB_W * x); | |
145 m_y0 = (int)(1.0 * ORGIMG_H / THUMB_H * y); | |
146 m_textCtrlMsg->AppendText(wxString::Format(wxT("Preview: (%d, %d) Double-Clicked. -> [%d, %d]\n"), x, y, m_x0, m_y0)); | |
147 | |
148 int dy = 40; // for centering | |
149 m_scrolledWindow->Scroll(m_x0 / 10 - dy, m_y0 / 10 - dy); | |
150 } | |
151 | |
152 void EralineFrame::OnZoomDClicked(wxMouseEvent& event) | |
153 { | |
154 int x, y; | |
155 event.GetPosition(&x, &y); | |
156 m_x1 = x; | |
157 m_y1 = y; | |
158 m_textCtrlMsg->AppendText(wxString::Format(wxT("Zoom: (%d, %d) Double-Clicked.\n"), x, y)); | |
159 | |
160 ViewDot(); | |
161 } | |
162 | |
163 void EralineFrame::OnItemSelected(wxDataViewEvent& WXUNUSED(event)) | |
164 { | |
165 int r = m_dataViewListCtrl->GetSelectedRow(); | |
166 wxString file = m_dataViewListCtrl->GetTextValue(r, 0); | |
167 | |
168 m_file = m_dirPickerInDir->GetPath() + wxFILE_SEP_PATH + file; | |
169 LoadFile(); | |
170 } | |
171 | |
172 void EralineFrame::OnRangeSelect(wxGridRangeSelectEvent& event) | |
173 { | |
174 int c0 = event.GetLeftCol(); | |
175 int c1 = event.GetRightCol(); | |
176 int r0 = event.GetTopRow(); | |
177 int r1 = event.GetBottomRow(); | |
178 | |
179 m_spinCtrlY->SetValue(m_y1 + r0 - GRID_DY); | |
180 m_spinCtrlH->SetValue(r1 - r0 + 1); | |
181 m_textCtrlMsg->AppendText(wxString::Format(wxT("Grid: (%d, %d) - (%d, %d) [%d x %d], Selected.\n"), r0, c0, r1, c1, c1 - c0 + 1, r1 - r0 + 1)); | |
182 } | |
183 | |
184 // Functions | |
185 void EralineFrame::CreateControls() | |
186 { | |
187 this->SetIcon(wxIcon(wxT("sample"))); | |
188 this->SetSizeHints(wxDefaultSize, wxDefaultSize); | |
189 this->SetBackgroundColour(wxColour(230, 230, 45)); | |
190 | |
191 wxGridBagSizer* gbSizer = new wxGridBagSizer(0, 0); | |
192 gbSizer->SetFlexibleDirection(wxBOTH); | |
193 gbSizer->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED); | |
194 | |
195 // Col 0 | |
196 m_staticTextInDir = new wxStaticText(this, wxID_ANY, wxT("Input Folder"), wxDefaultPosition, wxDefaultSize, 0); | |
197 gbSizer->Add(m_staticTextInDir, wxGBPosition(0, 0), wxGBSpan(1, 1), wxALL|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 5); | |
198 | |
199 m_staticTextList = new wxStaticText(this, wxID_ANY, wxT("Files"), wxDefaultPosition, wxDefaultSize, 0); | |
200 gbSizer->Add(m_staticTextList, wxGBPosition(1, 0), wxGBSpan(1, 1), wxALL|wxALIGN_RIGHT, 5); | |
201 | |
202 m_staticTextThumb = new wxStaticText(this, wxID_ANY, wxT("Preview"), wxDefaultPosition, wxDefaultSize, 0); | |
203 gbSizer->Add(m_staticTextThumb, wxGBPosition(2, 0), wxGBSpan(1, 1), wxALL|wxALIGN_RIGHT, 5); | |
204 | |
205 m_bitmapLogo = new wxStaticBitmap(this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize(300, 1), 0); | |
206 gbSizer->Add(m_bitmapLogo, wxGBPosition(8, 0), wxGBSpan(1, 2), wxALL, 5); | |
207 | |
208 // Col 1 | |
209 m_dirPickerInDir = new wxDirPickerCtrl(this, wxID_ANY, wxEmptyString, wxT("Select a folder"), wxDefaultPosition, wxSize(280, -1), wxDIRP_DEFAULT_STYLE|wxDIRP_DIR_MUST_EXIST|wxDIRP_SMALL|wxDIRP_USE_TEXTCTRL); | |
210 gbSizer->Add(m_dirPickerInDir, wxGBPosition(0, 1), wxGBSpan(1, 1), wxALL|wxALIGN_CENTER_VERTICAL, 5); | |
211 | |
212 m_dataViewListCtrl = new wxDataViewListCtrl(this, wxID_ANY, wxDefaultPosition, wxSize(THUMB_W, 500), wxDV_ROW_LINES|wxDV_SINGLE); | |
213 m_dataViewListColumnName = m_dataViewListCtrl->AppendTextColumn(wxT(" Name"), wxDATAVIEW_CELL_INERT, 180, static_cast<wxAlignment>(wxALIGN_LEFT), wxDATAVIEW_COL_RESIZABLE); | |
214 m_dataViewListColumnSize = m_dataViewListCtrl->AppendTextColumn(wxT("Size "), wxDATAVIEW_CELL_INERT, 80, static_cast<wxAlignment>(wxALIGN_RIGHT), wxDATAVIEW_COL_RESIZABLE); | |
215 m_dataViewListColumnTime = m_dataViewListCtrl->AppendTextColumn(wxT("Time"), wxDATAVIEW_CELL_INERT, -1, static_cast<wxAlignment>(wxALIGN_CENTER), wxDATAVIEW_COL_RESIZABLE); | |
216 gbSizer->Add(m_dataViewListCtrl, wxGBPosition(1, 1), wxGBSpan(1, 1), wxALL|wxEXPAND, 5); | |
217 | |
218 m_bitmapThumb = new wxStaticBitmap(this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize(THUMB_W, THUMB_H), 0); | |
219 gbSizer->Add(m_bitmapThumb, wxGBPosition(2, 1), wxGBSpan(6, 1), wxALL, 5); | |
220 | |
221 // Col 2 | |
222 m_staticTextZoom = new wxStaticText(this, wxID_ANY, wxT("-->> Zoom"), wxDefaultPosition, wxDefaultSize, 0); | |
223 gbSizer->Add(m_staticTextZoom, wxGBPosition(2, 2), wxGBSpan(1, 1), wxALL|wxALIGN_TOP|wxALIGN_RIGHT, 5); | |
224 | |
225 // Col 3 | |
226 m_scrolledWindow = new wxScrolledWindow(this, wxID_ANY, wxDefaultPosition, wxSize(600, 500), wxHSCROLL|wxVSCROLL); | |
227 m_scrolledWindow->SetScrollRate(5, 5); | |
228 m_scrolledWindow->SetScrollbars(10, 10, ORGIMG_W / 10, ORGIMG_H / 10); | |
229 m_scrolledWindow->SetBackgroundColour(wxColour(200, 200, 200)); | |
230 m_bitmapZoom = new wxStaticBitmap(m_scrolledWindow, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize(300, 400), 0); | |
231 gbSizer->Add(m_scrolledWindow, wxGBPosition(0, 3), wxGBSpan(8, 1), wxEXPAND | wxALL, 5); | |
232 | |
233 // Col 4 | |
234 m_staticTextDot = new wxStaticText(this, wxID_ANY, wxT("-->> Dot"), wxDefaultPosition, wxDefaultSize, 0); | |
235 gbSizer->Add(m_staticTextDot, wxGBPosition(0, 4), wxGBSpan(1, 1), wxALL|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 5); | |
236 | |
237 m_staticTextY = new wxStaticText(this, wxID_ANY, wxT("y"), wxDefaultPosition, wxDefaultSize, 0); | |
238 gbSizer->Add(m_staticTextY, wxGBPosition(3, 4), wxGBSpan(1, 1), wxALL|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 5); | |
239 | |
240 m_staticTextH = new wxStaticText(this, wxID_ANY, wxT("h"), wxDefaultPosition, wxDefaultSize, 0); | |
241 gbSizer->Add(m_staticTextH, wxGBPosition(4, 4), wxGBSpan(1, 1), wxALL|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 5); | |
242 | |
243 m_staticTextOutDir = new wxStaticText(this, wxID_ANY, wxT("Output Folder"), wxDefaultPosition, wxDefaultSize, 0); | |
244 gbSizer->Add(m_staticTextOutDir, wxGBPosition(5, 4), wxGBSpan(1, 1), wxALL|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 5); | |
245 | |
246 m_staticTextMsg = new wxStaticText(this, wxID_ANY, wxT("Message"), wxDefaultPosition, wxDefaultSize, 0); | |
247 gbSizer->Add(m_staticTextMsg, wxGBPosition(6, 4), wxGBSpan(1, 1), wxALL|wxALIGN_RIGHT, 5); | |
248 | |
249 // Col 5 | |
250 m_gridView = new wxGrid(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0); | |
251 m_gridView->CreateGrid(GRID_W, GRID_H); | |
252 m_gridView->EnableEditing(false); | |
253 m_gridView->EnableGridLines(true); | |
254 m_gridView->EnableDragGridSize(false); | |
255 m_gridView->EnableDragRowSize(false); | |
256 m_gridView->SetMargins(0, 0); | |
257 m_gridView->EnableDragColMove(false); | |
258 m_gridView->EnableDragColSize(false); | |
259 m_gridView->SetRowMinimalAcceptableHeight(GRID_SZ); | |
260 m_gridView->SetColMinimalAcceptableWidth(GRID_SZ); | |
261 m_gridView->SetDefaultColSize(GRID_SZ, true); | |
262 m_gridView->SetDefaultRowSize(GRID_SZ, true); | |
263 m_gridView->SetColLabelSize(25); | |
264 m_gridView->SetRowLabelSize(25); | |
265 m_gridView->SetColLabelAlignment(wxALIGN_CENTER, wxALIGN_CENTER); | |
266 m_gridView->SetRowLabelAlignment(wxALIGN_RIGHT, wxALIGN_CENTER); | |
267 m_gridView->SetDefaultCellAlignment(wxALIGN_LEFT, wxALIGN_TOP); | |
268 m_gridView->SetLabelFont(wxFont(5, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, wxEmptyString)); | |
269 m_gridView->SetSelectionBackground(*wxRED); | |
270 gbSizer->Add(m_gridView, wxGBPosition(0, 5), wxGBSpan(3, 3), wxALL, 5); | |
271 | |
272 m_spinCtrlY = new wxSpinCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(80, -1), wxALIGN_RIGHT|wxSP_ARROW_KEYS, 0, 3500, 0); | |
273 gbSizer->Add(m_spinCtrlY, wxGBPosition(3, 5), wxGBSpan(1, 1), wxALL|wxALIGN_CENTER_VERTICAL, 5); | |
274 | |
275 m_spinCtrlH = new wxSpinCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(80, -1), wxALIGN_RIGHT|wxSP_ARROW_KEYS, 1, 10, 1); | |
276 gbSizer->Add(m_spinCtrlH, wxGBPosition(4, 5), wxGBSpan(1, 1), wxALL, 5); | |
277 | |
278 m_dirPickerOutDir = new wxDirPickerCtrl(this, wxID_ANY, wxEmptyString, wxT("Select a folder"), wxDefaultPosition, wxSize(280, -1), wxDIRP_DEFAULT_STYLE|wxDIRP_DIR_MUST_EXIST|wxDIRP_SMALL|wxDIRP_USE_TEXTCTRL); | |
279 gbSizer->Add(m_dirPickerOutDir, wxGBPosition(5, 5), wxGBSpan(1, 2), wxALL|wxALIGN_CENTER_VERTICAL, 5); | |
280 | |
281 m_textCtrlMsg = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(500, 60), wxTE_MULTILINE); | |
282 gbSizer->Add(m_textCtrlMsg, wxGBPosition(6, 5), wxGBSpan(2, 3), wxALL, 5); | |
283 | |
284 // Col 6 | |
285 m_textCtrlRGB = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY); | |
286 gbSizer->Add(m_textCtrlRGB, wxGBPosition(3, 6), wxGBSpan(1, 1), wxALL, 5); | |
287 | |
288 // Col 7 | |
289 m_buttonErase = new wxButton(this, wxID_ANY, wxT("Erase"), wxDefaultPosition, wxSize(60, -1), 0); | |
290 gbSizer->Add(m_buttonErase, wxGBPosition(5, 7), wxGBSpan(1, 1), wxALL|wxALIGN_CENTER_VERTICAL, 5); | |
291 | |
292 // | |
293 this->SetSizer(gbSizer); | |
294 this->Layout(); | |
295 | |
296 this->Centre(wxBOTH); | |
297 } | |
298 | |
299 void EralineFrame::LoadFile() | |
300 { | |
301 if (!wxFileExists(m_file)) return; | |
302 m_image.LoadFile(m_file, wxBITMAP_TYPE_TIFF, 0); | |
303 | |
304 wxBitmap bitmap = wxBitmap(m_image.Scale(THUMB_W, THUMB_H, wxIMAGE_QUALITY_HIGH)); | |
305 m_bitmapThumb->SetBitmap(bitmap); | |
306 | |
307 bitmap = wxBitmap(m_image); | |
308 m_bitmapZoom->SetBitmap(bitmap); | |
309 | |
310 m_textCtrlMsg->AppendText(wxString::Format(wxT("Image-Size: %d x %d\n"), m_image.GetWidth(), m_image.GetHeight())); | |
311 } | |
312 | |
313 void EralineFrame::ViewDot() | |
314 { | |
315 wxGridUpdateLocker noUpdates(m_gridView); | |
316 /* | |
317 if (m_image.GetWidth() != m_gridView->GetNumberCols() || m_image.GetHeight() != m_gridView->GetNumberRows()) { | |
318 m_gridView->DeleteCols(0, m_gridView->GetNumberCols(), true); | |
319 m_gridView->DeleteRows(0, m_gridView->GetNumberRows(), true); | |
320 m_gridView->AppendCols(m_image.GetWidth(), true); | |
321 m_gridView->AppendRows(m_image.GetHeight(), true); | |
322 } | |
323 */ | |
324 int rn = m_gridView->GetNumberRows(); | |
325 int cn = m_gridView->GetNumberCols(); | |
326 | |
327 int dy = GRID_DY; // for centering | |
328 if (m_y1 < dy) m_y1 = dy; | |
329 if (m_x1 + cn > ORGIMG_W) m_x1 = ORGIMG_W - cn; | |
330 if (m_y1 + rn > ORGIMG_H) m_y1 = ORGIMG_H - rn; | |
331 | |
332 unsigned char r, g, b; | |
333 for (int y = 0; y < rn; y++) { | |
334 for (int x = 0; x < cn; x++) { | |
335 r = m_image.GetRed(m_x1 + x, m_y1 + y - dy); | |
336 g = m_image.GetGreen(m_x1 + x, m_y1 + y - dy); | |
337 b = m_image.GetBlue(m_x1 + x, m_y1 + y - dy); | |
338 m_gridView->SetCellBackgroundColour(y, x, wxColour(r, g, b)); | |
339 } | |
340 } | |
341 m_textCtrlMsg->AppendText(wxString::Format(wxT("Refresh Grid (%d x %d).\n"), m_gridView->GetNumberCols(), m_gridView->GetNumberRows())); | |
342 } | |
343 |