Mercurial > mercurial > hgweb_mover2.cgi
comparison src/myframe.cpp @ 4:964129946db6
Release : v2.0 finished !!!
author | pyon@macmini |
---|---|
date | Sun, 16 Oct 2011 16:21:33 +0900 |
parents | 870860d435a1 |
children | 52697c869ce8 |
comparison
equal
deleted
inserted
replaced
3:870860d435a1 | 4:964129946db6 |
---|---|
97 | 97 |
98 wxBoxSizer* bSizerGuess = new wxBoxSizer( wxVERTICAL ); | 98 wxBoxSizer* bSizerGuess = new wxBoxSizer( wxVERTICAL ); |
99 | 99 |
100 m_staticTextName = new wxStaticText( this, wxID_ANY, wxT("氏名"), wxDefaultPosition, wxDefaultSize, 0 ); | 100 m_staticTextName = new wxStaticText( this, wxID_ANY, wxT("氏名"), wxDefaultPosition, wxDefaultSize, 0 ); |
101 bSizerGuess->Add( m_staticTextName, 0, wxTOP|wxLEFT, 5 ); | 101 bSizerGuess->Add( m_staticTextName, 0, wxTOP|wxLEFT, 5 ); |
102 m_bitmapName = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize(320,95), 0 ); | 102 wxString logo = wxGetCwd() + wxFILE_SEP_PATH + wxT("image") + wxFILE_SEP_PATH + wxT("logo.png"); |
103 wxBitmap bmp = wxBitmap( logo, wxBITMAP_TYPE_PNG ); | |
104 m_bitmapName = new wxStaticBitmap( this, wxID_ANY, bmp, wxDefaultPosition, wxSize(320,95), 0 ); | |
103 bSizerGuess->Add( m_bitmapName, 0, wxALL, 5 ); | 105 bSizerGuess->Add( m_bitmapName, 0, wxALL, 5 ); |
104 | 106 |
105 m_staticTextHhsno = new wxStaticText( this, wxID_ANY, wxT("被保険者番号"), wxDefaultPosition, wxDefaultSize, 0 ); | 107 m_staticTextHhsno = new wxStaticText( this, wxID_ANY, wxT("被保険者番号"), wxDefaultPosition, wxDefaultSize, 0 ); |
106 bSizerGuess->Add( m_staticTextHhsno, 0, wxTOP|wxLEFT, 5 ); | 108 bSizerGuess->Add( m_staticTextHhsno, 0, wxTOP|wxLEFT, 5 ); |
107 m_bitmapHHsno = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize(320,54), 0 ); | 109 logo = wxGetCwd() + wxFILE_SEP_PATH + wxT("image") + wxFILE_SEP_PATH + wxT("0123456789.png"); |
108 bSizerGuess->Add( m_bitmapHHsno, 0, wxALL, 5 ); | 110 bmp.LoadFile( logo, wxBITMAP_TYPE_PNG ); |
111 m_bitmapHhsno = new wxStaticBitmap( this, wxID_ANY, bmp, wxDefaultPosition, wxSize(320,54), 0 ); | |
112 bSizerGuess->Add( m_bitmapHhsno, 0, wxALL, 5 ); | |
109 | 113 |
110 m_staticTextGuess = new wxStaticText( this, wxID_ANY, wxT("推定値"), wxDefaultPosition, wxDefaultSize, 0 ); | 114 m_staticTextGuess = new wxStaticText( this, wxID_ANY, wxT("推定値"), wxDefaultPosition, wxDefaultSize, 0 ); |
111 bSizerGuess->Add( m_staticTextGuess, 0, wxTOP|wxLEFT, 5 ); | 115 bSizerGuess->Add( m_staticTextGuess, 0, wxTOP|wxLEFT, 5 ); |
112 m_textCtrlGuess = new wxTextCtrl( this, ID_TEXTCTRLGUESS, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); | 116 m_textCtrlGuess = new wxTextCtrl( this, ID_TEXTCTRLGUESS, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); |
113 m_textCtrlGuess->SetMaxLength( 10 ); | 117 m_textCtrlGuess->SetMaxLength( 10 ); |
125 | 129 |
126 m_buttonDetect = new wxButton( this, ID_BUTTONDETECT, wxT("検知"), wxDefaultPosition, wxDefaultSize, 0 ); | 130 m_buttonDetect = new wxButton( this, ID_BUTTONDETECT, wxT("検知"), wxDefaultPosition, wxDefaultSize, 0 ); |
127 bSizerButton->Add( m_buttonDetect, 0, wxALL, 5 ); | 131 bSizerButton->Add( m_buttonDetect, 0, wxALL, 5 ); |
128 m_buttonMove = new wxButton( this, ID_BUTTONMOVE, wxT("移動"), wxDefaultPosition, wxDefaultSize, 0 ); | 132 m_buttonMove = new wxButton( this, ID_BUTTONMOVE, wxT("移動"), wxDefaultPosition, wxDefaultSize, 0 ); |
129 bSizerButton->Add( m_buttonMove, 0, wxALL, 5 ); | 133 bSizerButton->Add( m_buttonMove, 0, wxALL, 5 ); |
134 m_buttonMove->Enable(false); | |
130 m_buttonMD = new wxButton( this, ID_BUTTONMD, wxT("移動&検知"), wxDefaultPosition, wxDefaultSize, 0 ); | 135 m_buttonMD = new wxButton( this, ID_BUTTONMD, wxT("移動&検知"), wxDefaultPosition, wxDefaultSize, 0 ); |
131 bSizerButton->Add( m_buttonMD, 0, wxALL, 5 ); | 136 bSizerButton->Add( m_buttonMD, 0, wxALL, 5 ); |
137 m_buttonMD->Enable(false); | |
132 m_buttonDel = new wxButton( this, ID_BUTTONDEL, wxT("削除"), wxDefaultPosition, wxDefaultSize, 0 ); | 138 m_buttonDel = new wxButton( this, ID_BUTTONDEL, wxT("削除"), wxDefaultPosition, wxDefaultSize, 0 ); |
133 bSizerButton->Add( m_buttonDel, 0, wxALL, 5 ); | 139 bSizerButton->Add( m_buttonDel, 0, wxALL, 5 ); |
134 m_buttonUndo = new wxButton( this, ID_BUTTONUNDO, wxT("戻す"), wxDefaultPosition, wxDefaultSize, 0 ); | 140 m_buttonUndo = new wxButton( this, ID_BUTTONUNDO, wxT("戻す"), wxDefaultPosition, wxDefaultSize, 0 ); |
135 bSizerButton->Add( m_buttonUndo, 0, wxALL, 5 ); | 141 bSizerButton->Add( m_buttonUndo, 0, wxALL, 5 ); |
142 m_buttonUndo->Enable(false); | |
136 | 143 |
137 bSizerManip->Add( bSizerButton, 0, wxALIGN_CENTER_VERTICAL, 5 ); | 144 bSizerManip->Add( bSizerButton, 0, wxALIGN_CENTER_VERTICAL, 5 ); |
138 | 145 |
139 bSizerTop->Add( bSizerManip, 1, wxEXPAND, 5 ); | 146 bSizerTop->Add( bSizerManip, 1, wxEXPAND, 5 ); |
140 | 147 |
164 EVT_MENU( wxID_EXIT, MyFrame::OnQuit ) | 171 EVT_MENU( wxID_EXIT, MyFrame::OnQuit ) |
165 EVT_BUTTON( ID_BUTTONMKDIR, MyFrame::OnMakeDir ) | 172 EVT_BUTTON( ID_BUTTONMKDIR, MyFrame::OnMakeDir ) |
166 EVT_BUTTON( ID_BUTTONDETECT, MyFrame::OnDetect ) | 173 EVT_BUTTON( ID_BUTTONDETECT, MyFrame::OnDetect ) |
167 EVT_BUTTON( ID_BUTTONMOVE, MyFrame::OnMove ) | 174 EVT_BUTTON( ID_BUTTONMOVE, MyFrame::OnMove ) |
168 EVT_BUTTON( ID_BUTTONMD, MyFrame::OnMoveAndDetect ) | 175 EVT_BUTTON( ID_BUTTONMD, MyFrame::OnMoveAndDetect ) |
169 //EVT_BUTTON( ID_BUTTONDEL, MyFrame::Delete ) | 176 EVT_BUTTON( ID_BUTTONDEL, MyFrame::OnDelete ) |
170 //EVT_BUTTON( ID_BUTTONUNDO, MyFrame::Undo ) | 177 EVT_BUTTON( ID_BUTTONUNDO, MyFrame::OnUndo ) |
171 EVT_LIST_ITEM_SELECTED( ID_LISTCTRLVIEW, MyFrame::GetImageInfo ) | 178 EVT_LIST_ITEM_SELECTED( ID_LISTCTRLVIEW, MyFrame::GetImageInfo ) |
172 EVT_LIST_ITEM_ACTIVATED( ID_LISTCTRLVIEW, MyFrame::ViewLarge ) | 179 EVT_LIST_ITEM_ACTIVATED( ID_LISTCTRLVIEW, MyFrame::ViewLarge ) |
173 EVT_CLOSE( MyFrame::SaveConfig ) | 180 EVT_CLOSE( MyFrame::SaveConfig ) |
174 END_EVENT_TABLE() | 181 END_EVENT_TABLE() |
175 | 182 |
197 while ( tkz.HasMoreTokens() ) { | 204 while ( tkz.HasMoreTokens() ) { |
198 d.Append( tkz.GetNextToken() ); | 205 d.Append( tkz.GetNextToken() ); |
199 d.Append( wxFILE_SEP_PATH ); | 206 d.Append( wxFILE_SEP_PATH ); |
200 if ( !wxDirExists( d ) ) wxMkdir( d ); | 207 if ( !wxDirExists( d ) ) wxMkdir( d ); |
201 } | 208 } |
209 m_buttonMove->Enable(true); | |
210 m_buttonMD->Enable(true); | |
202 | 211 |
203 wxMessageBox(wxT("移動先フォルダ準備完了")); | 212 wxMessageBox(wxT("移動先フォルダ準備完了")); |
204 wxString cmd = wxT("explorer ") + to; | 213 wxString cmd = wxT("explorer ") + to; |
205 wxExecute( cmd ); | 214 wxExecute( cmd ); |
206 } | 215 } |
207 | 216 |
208 /* 移動 */ | 217 /* 移動 */ |
209 void MyFrame::OnMove(wxCommandEvent& WXUNUSED(event)) | 218 void MyFrame::OnMove(wxCommandEvent& WXUNUSED(event)) |
210 { | 219 { |
211 MoveImage(); | 220 MoveImage(); |
221 m_buttonUndo->Enable(true); | |
212 } | 222 } |
213 /* 検知 */ | 223 /* 検知 */ |
214 void MyFrame::OnDetect(wxCommandEvent& WXUNUSED(event)) | 224 void MyFrame::OnDetect(wxCommandEvent& WXUNUSED(event)) |
215 { | 225 { |
216 ReadyImage(); | 226 ReadyImage(); |
217 } | 227 } |
218 /* 移動し検知 */ | 228 /* 移動し検知 */ |
219 void MyFrame::OnMoveAndDetect(wxCommandEvent& WXUNUSED(event)) | 229 void MyFrame::OnMoveAndDetect(wxCommandEvent& WXUNUSED(event)) |
220 { | 230 { |
221 MoveImage(); | 231 MoveImage(); |
232 ReadyImage(); | |
233 } | |
234 /* 選択したファイルを移動 */ | |
235 void MyFrame::MoveImage() | |
236 { | |
237 m_undo.Clear(); | |
238 wxString workdir = m_dirPickerWork->GetPath(); | |
239 wxString distdir = m_textCtrlDist->GetValue(); | |
240 long item = -1; | |
241 for ( ;; ) { | |
242 item = m_listCtrlView->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); | |
243 if ( item == -1 ) break; | |
244 wxString file = m_listCtrlView->GetItemText( item ); | |
245 wxString from = workdir + wxFILE_SEP_PATH + file; | |
246 wxString to = distdir + wxFILE_SEP_PATH + file; | |
247 wxRenameFile( from, to, true ); | |
248 m_undo.Insert( wxT("mv ") + to + wxT(" ") + from, 0 ); | |
249 } | |
250 ReadyImage(); | |
251 m_buttonUndo->Enable(true); | |
252 } | |
253 /* 選択したファイルを削除 */ | |
254 void MyFrame::OnDelete(wxCommandEvent& WXUNUSED(event)) | |
255 { | |
256 m_undo.Clear(); | |
257 wxString workdir = m_dirPickerWork->GetPath(); | |
258 wxString trash = wxGetCwd() + wxFILE_SEP_PATH + wxT("trash"); | |
259 long item = -1; | |
260 for ( ;; ) { | |
261 item = m_listCtrlView->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); | |
262 if ( item == -1 ) break; | |
263 wxString file = m_listCtrlView->GetItemText( item ); | |
264 wxString from = workdir + wxFILE_SEP_PATH + file; | |
265 wxString to = trash + wxFILE_SEP_PATH + file; | |
266 wxRenameFile( from, to, true ); | |
267 m_undo.Insert( wxT("mv ") + to + wxT(" ") + from, 0 ); | |
268 } | |
269 ReadyImage(); | |
270 m_buttonUndo->Enable(true); | |
271 } | |
272 /* アンドゥ */ | |
273 void MyFrame::OnUndo(wxCommandEvent& WXUNUSED(event)) | |
274 { | |
275 for ( int i=0; i<m_undo.GetCount(); i++ ) { | |
276 wxExecute( m_undo[i] ); | |
277 } | |
278 wxMessageBox(wxT("戻し完了.")); | |
279 m_buttonUndo->Enable(false); | |
280 m_undo.Clear(); | |
222 ReadyImage(); | 281 ReadyImage(); |
223 } | 282 } |
224 | 283 |
225 /* 画像をリストコントロールに表示 */ | 284 /* 画像をリストコントロールに表示 */ |
226 void MyFrame::ReadyImage() | 285 void MyFrame::ReadyImage() |
227 { | 286 { |
228 wxString workdir = m_dirPickerWork->GetPath(); | 287 wxString workdir = m_dirPickerWork->GetPath(); |
229 wxDir dir( workdir ); | 288 wxDir dir( workdir ); |
230 if ( !dir.IsOpened() ) return; | 289 if ( !dir.IsOpened() ) return; |
290 wxString notfound = wxGetCwd() + wxFILE_SEP_PATH + wxT("image") + wxFILE_SEP_PATH + wxT("notfound.png"); | |
291 wxBitmap bmp = wxBitmap( notfound, wxBITMAP_TYPE_PNG ); | |
292 m_bitmapName->SetBitmap( bmp ); | |
293 notfound = wxGetCwd() + wxFILE_SEP_PATH + wxT("image") + wxFILE_SEP_PATH + wxT("0000000000.png"); | |
294 bmp.LoadFile( notfound, wxBITMAP_TYPE_PNG ); | |
295 m_bitmapHhsno->SetBitmap( bmp ); | |
231 | 296 |
232 wxString filename; | 297 wxString filename; |
233 bool cout = dir.GetFirst( &filename, wxT("*.jpg"), wxDIR_FILES ); | 298 bool cout = dir.GetFirst( &filename, wxT("*.jpg"), wxDIR_FILES ); |
234 | 299 |
235 int i = 0; | 300 int i = 0; |
236 m_listCtrlView->DeleteAllItems(); | 301 m_listCtrlView->DeleteAllItems(); |
237 m_imageList->RemoveAll(); | 302 m_imageList->RemoveAll(); |
238 wxListItem item; | 303 wxListItem item; |
239 wxString first; | 304 wxString first; |
305 wxProgressDialog pd( wxT("進行状況"), wxT("処理開始..."), 7, this, wxPD_APP_MODAL|wxPD_REMAINING_TIME|wxPD_AUTO_HIDE ); | |
306 pd.SetSize( wxSize(320,140) ); | |
240 float b; long l; | 307 float b; long l; |
241 while ( cout ) { | 308 while ( cout ) { |
242 wxString imagefile = workdir + wxFILE_SEP_PATH + filename; | 309 wxString imagefile = workdir + wxFILE_SEP_PATH + filename; |
243 | 310 |
244 m_listCtrlView->InsertItem( i, filename ); | 311 m_listCtrlView->InsertItem( i, filename ); |
250 | 317 |
251 if ( i == 0 ) { | 318 if ( i == 0 ) { |
252 IsMarksheet( imagefile, &b, &l ); | 319 IsMarksheet( imagefile, &b, &l ); |
253 first = imagefile; | 320 first = imagefile; |
254 SetStatusText( wxString::Format(wxT("1st image : z = %f, l = %d"),b,l), 1 ); | 321 SetStatusText( wxString::Format(wxT("1st image : z = %f, l = %d"),b,l), 1 ); |
322 | |
323 wxImage marksheet( first, wxBITMAP_TYPE_JPEG ); | |
324 wxImage name_image; | |
325 name_image = marksheet.GetSubImage( wxRect( wxPoint(300,550), wxSize(640,190) ) ); | |
326 wxBitmap name_bmp = ( name_image.Scale( 320, 95, wxIMAGE_QUALITY_HIGH ) ); | |
327 m_bitmapName->SetBitmap( name_bmp ); | |
328 | |
329 wxImage hhsno_image; | |
330 hhsno_image = marksheet.GetSubImage( wxRect( wxPoint(1800,210), wxSize(594,100) ) ); | |
331 wxBitmap hhsno_bmp = ( hhsno_image.Scale( 320, 54, wxIMAGE_QUALITY_HIGH ) ); | |
332 m_bitmapHhsno->SetBitmap( hhsno_bmp ); | |
333 | |
334 wxString hhsno = GuessHhs( first ); | |
335 m_textCtrlGuess->SetValue( hhsno ); | |
255 } | 336 } |
256 else { | 337 else { |
257 if ( i > 7 || IsMarksheet( imagefile, &b, &l ) ) { | 338 if ( i > 7 || IsMarksheet( imagefile, &b, &l ) ) { |
258 break; | 339 break; |
259 } | 340 } |
260 } | 341 } |
261 m_listCtrlView->SetItemState( i, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED ); | 342 m_listCtrlView->SetItemState( i, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED ); |
262 | 343 |
263 // write log | 344 // write log |
264 i++; | 345 i++; |
346 pd.Update( i, wxT("画像認識中") ); | |
265 cout = dir.GetNext( &filename ); | 347 cout = dir.GetNext( &filename ); |
266 } | 348 } |
267 | 349 |
268 wxImage marksheet( first, wxBITMAP_TYPE_JPEG ); | 350 SetStatusText( wxEmptyString, 2 ); |
269 wxImage name_image; | |
270 name_image = marksheet.GetSubImage( wxRect( wxPoint(300,550), wxSize(640,190) ) ); | |
271 wxBitmap name_bmp = ( name_image.Scale( 320, 95, wxIMAGE_QUALITY_HIGH ) ); | |
272 m_bitmapName->SetBitmap( name_bmp ); | |
273 | |
274 wxImage hhsno_image; | |
275 hhsno_image = marksheet.GetSubImage( wxRect( wxPoint(1800,210), wxSize(594,100) ) ); | |
276 wxBitmap hhsno_bmp = ( hhsno_image.Scale( 320, 54, wxIMAGE_QUALITY_HIGH ) ); | |
277 m_bitmapHHsno->SetBitmap( hhsno_bmp ); | |
278 | |
279 wxString hhsno = GuessHhs( first ); | |
280 m_textCtrlGuess->SetValue( hhsno ); | |
281 } | |
282 | |
283 /* 画像移動 */ | |
284 void MyFrame::MoveImage() | |
285 { | |
286 wxString distdir = m_textCtrlDist->GetValue(); | |
287 wxString ccn = m_comboBoxCcn->GetValue(); | |
288 if ( distdir.IsEmpty() || ccn.IsEmpty() ) { | |
289 wxMessageBox(wxT("フォルダを指定してください.")); | |
290 return; | |
291 } | |
292 | |
293 distdir.Append( wxFILE_SEP_PATH ); | |
294 if ( !wxDirExists( distdir ) ) { | |
295 wxMessageBox(wxT("フォルダが存在しません.")); | |
296 return; | |
297 } | |
298 | |
299 /* | |
300 wxString to = distdir + wxFILE_SEP_PATH + hhs + wxFILE_SEP_PATH + filename; | |
301 wxRenameFile( from, to, false ); | |
302 */ | |
303 } | 351 } |
304 | 352 |
305 /* 画像を選択 */ | 353 /* 画像を選択 */ |
306 void MyFrame::GetImageInfo(wxListEvent& event) | 354 void MyFrame::GetImageInfo(wxListEvent& event) |
307 { | 355 { |
312 wxString workdir = m_dirPickerWork->GetPath(); | 360 wxString workdir = m_dirPickerWork->GetPath(); |
313 wxString imagefile = workdir + wxFILE_SEP_PATH + filename; | 361 wxString imagefile = workdir + wxFILE_SEP_PATH + filename; |
314 float b; long l; | 362 float b; long l; |
315 wxString msg; | 363 wxString msg; |
316 if ( IsMarksheet( imagefile, &b, &l ) ) { | 364 if ( IsMarksheet( imagefile, &b, &l ) ) { |
317 msg = wxT("Success detection"); | 365 msg = wxT("perhaps marksheet !"); |
318 } | 366 } |
319 SetStatusText( wxString::Format(wxT("selected image : z = %f, l = %d ...")+msg, b, l ), 2 ); | 367 SetStatusText( wxString::Format(wxT("selected image : z = %f, l = %d ...")+msg, b, l ), 2 ); |
320 } | 368 } |
321 | 369 |
322 /* 画像のスクリーン表示*/ | 370 /* 画像のスクリーン表示*/ |