Mercurial > mercurial > hgweb_mover2.cgi
comparison src/myframe.cpp @ 35:405e08552527 v2.4 v2.6
auto-detect on/off
| author | pyon@macmini |
|---|---|
| date | Thu, 17 Nov 2011 21:03:30 +0900 |
| parents | 51e522f34598 |
| children | 3b54f3deeed9 |
comparison
equal
deleted
inserted
replaced
| 34:51e522f34598 | 35:405e08552527 |
|---|---|
| 1 // Filename : myframe.cpp | 1 // Filename : myframe.cpp |
| 2 // Last Change: 12-Nov-2011. | 2 // Last Change: 17-Nov-2011. |
| 3 // | 3 // |
| 4 | 4 |
| 5 #include "main.h" | 5 #include "main.h" |
| 6 #include "myframe.h" | 6 #include "myframe.h" |
| 7 #include "param.h" | 7 #include "param.h" |
| 13 #define HHSN_W 288 | 13 #define HHSN_W 288 |
| 14 #define HHSN_H 49 | 14 #define HHSN_H 49 |
| 15 #define THUMB_W 160 | 15 #define THUMB_W 160 |
| 16 #define THUMB_H 226 | 16 #define THUMB_H 226 |
| 17 | 17 |
| 18 #if defined(__WXMSW__) | |
| 19 #define MOVECMD wxT("move") | |
| 20 #else | |
| 21 #define MOVECMD wxT("mv") | |
| 22 #endif | |
| 23 | |
| 24 | |
| 18 // resources | 25 // resources |
| 19 // the application icon (under Windows and OS/2 it is in resources and even | 26 // the application icon (under Windows and OS/2 it is in resources and even |
| 20 // though we could still include the XPM here it would be unused) | 27 // though we could still include the XPM here it would be unused) |
| 21 #if !defined(__WXMSW__) && !defined(__WXPM__) | 28 #if !defined(__WXMSW__) && !defined(__WXPM__) |
| 22 #include "sample.xpm" | 29 #include "sample.xpm" |
| 39 m_menuFile->Append( m_menuItemDetect ); | 46 m_menuFile->Append( m_menuItemDetect ); |
| 40 | 47 |
| 41 wxMenuItem* m_menuItemMove; | 48 wxMenuItem* m_menuItemMove; |
| 42 m_menuItemMove = new wxMenuItem( m_menuFile, ID_MENUITEMMOVE, wxString( wxT("移動\tF7") ) , wxEmptyString, wxITEM_NORMAL ); | 49 m_menuItemMove = new wxMenuItem( m_menuFile, ID_MENUITEMMOVE, wxString( wxT("移動\tF7") ) , wxEmptyString, wxITEM_NORMAL ); |
| 43 m_menuFile->Append( m_menuItemMove ); | 50 m_menuFile->Append( m_menuItemMove ); |
| 51 | |
| 52 m_menuFile->AppendSeparator(); // ---- | |
| 53 wxMenuItem* m_menuItemAutoDetect; | |
| 54 m_menuItemAutoDetect = new wxMenuItem( m_menuFile, ID_MENUITEMAUTOD, wxString( wxT("自動検知\tF2") ) , wxEmptyString, wxITEM_CHECK ); | |
| 55 m_menuFile->Append( m_menuItemAutoDetect ); | |
| 56 m_menuItemAutoDetect->Check(true); | |
| 44 | 57 |
| 45 m_menuFile->AppendSeparator(); // ---- | 58 m_menuFile->AppendSeparator(); // ---- |
| 46 wxMenuItem* m_menuItemParam; | 59 wxMenuItem* m_menuItemParam; |
| 47 m_menuItemParam = new wxMenuItem( m_menuFile, ID_MENUITEMPARAM, wxString( wxT("パラメータ\tAlt+P") ) , wxEmptyString, wxITEM_NORMAL ); | 60 m_menuItemParam = new wxMenuItem( m_menuFile, ID_MENUITEMPARAM, wxString( wxT("パラメータ\tAlt+P") ) , wxEmptyString, wxITEM_NORMAL ); |
| 48 m_menuFile->Append( m_menuItemParam ); | 61 m_menuFile->Append( m_menuItemParam ); |
| 205 m_statusBar = this->CreateStatusBar( WXSIZEOF(widths), wxST_SIZEGRIP ); | 218 m_statusBar = this->CreateStatusBar( WXSIZEOF(widths), wxST_SIZEGRIP ); |
| 206 m_statusBar->SetStatusWidths( WXSIZEOF(widths), widths ); | 219 m_statusBar->SetStatusWidths( WXSIZEOF(widths), widths ); |
| 207 m_statusBar->SetStatusText( wxEmptyString, 0 ); | 220 m_statusBar->SetStatusText( wxEmptyString, 0 ); |
| 208 | 221 |
| 209 this->Centre( wxBOTH ); | 222 this->Centre( wxBOTH ); |
| 223 | |
| 224 autodetect_mode = true; | |
| 210 m_timer.SetOwner( this, ID_TIMER ); | 225 m_timer.SetOwner( this, ID_TIMER ); |
| 226 | |
| 227 pd = new wxProgressDialog( wxT("進行状況"), wxT("処理開始..."), 100, this, wxPD_APP_MODAL|wxPD_REMAINING_TIME|wxPD_AUTO_HIDE ); | |
| 228 pd->SetSize( wxSize(320,140) ); | |
| 229 pd->Update( 100, wxEmptyString ); | |
| 211 } | 230 } |
| 212 | 231 |
| 213 // destructor | 232 // destructor |
| 214 MyFrame::~MyFrame() | 233 MyFrame::~MyFrame() |
| 215 { | 234 { |
| 221 EVT_TIMER( ID_TIMER, MyFrame::OnTimer ) | 240 EVT_TIMER( ID_TIMER, MyFrame::OnTimer ) |
| 222 EVT_SIZE( MyFrame::OnWinSize ) | 241 EVT_SIZE( MyFrame::OnWinSize ) |
| 223 EVT_MOVE( MyFrame::OnWinMove ) | 242 EVT_MOVE( MyFrame::OnWinMove ) |
| 224 EVT_MENU( ID_MENUITEMDETECT, MyFrame::OnDetect ) | 243 EVT_MENU( ID_MENUITEMDETECT, MyFrame::OnDetect ) |
| 225 EVT_MENU( ID_MENUITEMMOVE, MyFrame::OnMove ) | 244 EVT_MENU( ID_MENUITEMMOVE, MyFrame::OnMove ) |
| 245 EVT_MENU( ID_MENUITEMAUTOD, MyFrame::ToggleAutoDetect ) | |
| 226 EVT_MENU( ID_MENUITEMPARAM, MyFrame::OnParam ) | 246 EVT_MENU( ID_MENUITEMPARAM, MyFrame::OnParam ) |
| 227 EVT_MENU( ID_MENUITEMAPPDIR, MyFrame::OnOpenAppDir ) | 247 EVT_MENU( ID_MENUITEMAPPDIR, MyFrame::OnOpenAppDir ) |
| 228 EVT_MENU( wxID_EXIT, MyFrame::OnQuit ) | 248 EVT_MENU( wxID_EXIT, MyFrame::OnQuit ) |
| 229 EVT_LIST_ITEM_SELECTED( ID_LISTCTRLVIEW, MyFrame::OnItemSelected ) | 249 EVT_LIST_ITEM_SELECTED( ID_LISTCTRLVIEW, MyFrame::OnItemSelected ) |
| 230 EVT_LIST_ITEM_DESELECTED( ID_LISTCTRLVIEW, MyFrame::OnItemDeselected ) | 250 EVT_LIST_ITEM_DESELECTED( ID_LISTCTRLVIEW, MyFrame::OnItemDeselected ) |
| 238 EVT_LIST_ITEM_ACTIVATED( ID_LISTCTRLDIR, MyFrame::OnOpenHhsDir ) | 258 EVT_LIST_ITEM_ACTIVATED( ID_LISTCTRLDIR, MyFrame::OnOpenHhsDir ) |
| 239 EVT_CLOSE( MyFrame::SaveConfig ) | 259 EVT_CLOSE( MyFrame::SaveConfig ) |
| 240 END_EVENT_TABLE() | 260 END_EVENT_TABLE() |
| 241 | 261 |
| 242 // Event Handlers & Functions | 262 // Event Handlers & Functions |
| 263 void MyFrame::ToggleAutoDetect(wxCommandEvent& event) | |
| 264 { | |
| 265 if ( event.IsChecked() ) autodetect_mode = true; | |
| 266 else autodetect_mode = false; | |
| 267 } | |
| 268 | |
| 243 void MyFrame::GetCCnArrayInfo(wxArrayString& array , int n, wxString& nName, wxString& nDir) | 269 void MyFrame::GetCCnArrayInfo(wxArrayString& array , int n, wxString& nName, wxString& nDir) |
| 244 { | 270 { |
| 245 if ( n == -1 ) { | 271 if ( n == -1 ) { |
| 246 array.Add(wxT("角館1")); array.Add(wxT("角館2")); array.Add(wxT("角館3")); array.Add(wxT("角館4")); | 272 array.Add(wxT("角館1")); array.Add(wxT("角館2")); array.Add(wxT("角館3")); array.Add(wxT("角館4")); |
| 247 array.Add(wxT("西仙1")); array.Add(wxT("西仙2")); array.Add(wxT("西仙3")); | 273 array.Add(wxT("西仙1")); array.Add(wxT("西仙2")); array.Add(wxT("西仙3")); |
| 314 d.Append( ccndir ); | 340 d.Append( ccndir ); |
| 315 d.Append( wxFILE_SEP_PATH ); | 341 d.Append( wxFILE_SEP_PATH ); |
| 316 if ( !wxDirExists( d ) ) wxMkdir( d ); | 342 if ( !wxDirExists( d ) ) wxMkdir( d ); |
| 317 | 343 |
| 318 m_buttonMove->Enable(true); | 344 m_buttonMove->Enable(true); |
| 345 m_listCtrlHhsDir->DeleteAllItems(); | |
| 319 | 346 |
| 320 wxMessageBox(wxT("移動先フォルダ準備完了")); | 347 wxMessageBox(wxT("移動先フォルダ準備完了")); |
| 321 wxString cmd = wxT("explorer ") + to; | 348 wxString cmd = wxT("explorer ") + to; |
| 322 wxExecute( cmd ); | 349 wxExecute( cmd ); |
| 323 } | 350 } |
| 324 /* 検知 */ | 351 /* 検知 */ |
| 325 void MyFrame::OnDetect(wxCommandEvent& WXUNUSED(event)) | 352 void MyFrame::OnDetect(wxCommandEvent& WXUNUSED(event)) |
| 326 { | 353 { |
| 354 by_autodetect = false; | |
| 327 UpdateCache(); | 355 UpdateCache(); |
| 356 ClearGuess(); | |
| 328 UpdateListImage(); | 357 UpdateListImage(); |
| 358 } | |
| 359 void MyFrame::ClearGuess() | |
| 360 { | |
| 361 // start-up iamge | |
| 362 wxString notfound = wxGetCwd() + wxFILE_SEP_PATH + wxT("image") + wxFILE_SEP_PATH + wxT("notfound.png"); | |
| 363 wxBitmap bmp = wxBitmap( notfound, wxBITMAP_TYPE_PNG ); | |
| 364 m_bitmapName->SetBitmap( bmp ); | |
| 365 notfound = wxGetCwd() + wxFILE_SEP_PATH + wxT("image") + wxFILE_SEP_PATH + wxT("0000000000.png"); | |
| 366 bmp.LoadFile( notfound, wxBITMAP_TYPE_PNG ); | |
| 367 m_bitmapHhsno->SetBitmap( bmp ); | |
| 329 } | 368 } |
| 330 | 369 |
| 331 /* 移動 */ | 370 /* 移動 */ |
| 332 void MyFrame::OnMove(wxCommandEvent& WXUNUSED(event)) | 371 void MyFrame::OnMove(wxCommandEvent& WXUNUSED(event)) |
| 333 { | 372 { |
| 334 wxString distdir = m_textCtrlDist->GetValue(); | 373 wxString distdir = m_textCtrlDist->GetValue(); |
| 335 if ( distdir.IsEmpty() ) return; | 374 if ( distdir.IsEmpty() ) return; |
| 336 | 375 |
| 337 MoveImages(); | 376 MoveImages(); |
| 338 UpdateCache(); | 377 UpdateCache(); |
| 378 ClearGuess(); | |
| 339 UpdateListImage(); | 379 UpdateListImage(); |
| 340 ListHhsDir(); | 380 ListHhsDir(); |
| 341 m_buttonUndo->Enable(true); | 381 m_buttonUndo->Enable(true); |
| 342 } | 382 } |
| 343 | 383 |
| 345 void MyFrame::MoveImages() | 385 void MyFrame::MoveImages() |
| 346 { | 386 { |
| 347 m_undo.Clear(); | 387 m_undo.Clear(); |
| 348 wxString workdir = m_dirPickerWork->GetPath(); | 388 wxString workdir = m_dirPickerWork->GetPath(); |
| 349 wxString distdir = m_textCtrlDist->GetValue(); | 389 wxString distdir = m_textCtrlDist->GetValue(); |
| 350 wxString hhsno = m_textCtrlGuess->GetValue(); | 390 wxString hhsno = m_textCtrlGuess->GetValue(); |
| 391 | |
| 392 wxString hhsdir = distdir + wxFILE_SEP_PATH + hhsno; | |
| 393 if ( !wxDirExists( hhsdir ) ) { | |
| 394 wxMkdir( hhsdir ); | |
| 395 wxGetApp().WriteLog( wxT("created distination directory - ") + hhsdir ); | |
| 396 } | |
| 397 else { | |
| 398 wxGetApp().WriteLog( wxT("set distination directory - ") + hhsdir ); | |
| 399 } | |
| 351 | 400 |
| 352 m_hhsList.Remove(hhsno); | 401 m_hhsList.Remove(hhsno); |
| 353 m_hhsList.Add(hhsno); | 402 m_hhsList.Add(hhsno); |
| 354 long item = -1; | 403 long item = -1; |
| 355 for ( ;; ) { | 404 for ( ;; ) { |
| 356 item = m_listCtrlView->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); | 405 item = m_listCtrlView->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); |
| 357 if ( item == -1 ) break; | 406 if ( item == -1 ) break; |
| 358 if ( !wxDirExists( distdir + wxFILE_SEP_PATH + hhsno ) ) wxMkdir( distdir + wxFILE_SEP_PATH + hhsno ); | 407 |
| 359 | 408 wxString file = m_listCtrlView->GetItemText( item ); |
| 360 wxString file = m_listCtrlView->GetItemText( item ); | |
| 361 wxString from = workdir + wxFILE_SEP_PATH + file; | 409 wxString from = workdir + wxFILE_SEP_PATH + file; |
| 362 wxString to = distdir + wxFILE_SEP_PATH + hhsno + wxFILE_SEP_PATH + file; | 410 wxString to = hhsdir + wxFILE_SEP_PATH + file; |
| 363 wxRenameFile( from, to, true ); | 411 wxRenameFile( from, to, true ); |
| 412 wxGetApp().WriteLog( wxT("moved : ") + file ); | |
| 364 | 413 |
| 365 wxString movecmd = MOVECMD; | 414 wxString movecmd = MOVECMD; |
| 415 from.Replace( wxT("\\"), wxT("\\\\"), true ); | |
| 416 to.Replace( wxT("\\"), wxT("\\\\"), true ); | |
| 366 m_undo.Insert( movecmd + wxT(" ") + to + wxT(" ") + from, 0 ); | 417 m_undo.Insert( movecmd + wxT(" ") + to + wxT(" ") + from, 0 ); |
| 367 } | 418 } |
| 368 } | 419 } |
| 369 /* 選択したファイルを削除 */ | 420 /* 選択したファイルを削除 */ |
| 370 void MyFrame::OnDelete(wxCommandEvent& WXUNUSED(event)) | 421 void MyFrame::OnDelete(wxCommandEvent& WXUNUSED(event)) |
| 378 if ( item == -1 ) break; | 429 if ( item == -1 ) break; |
| 379 wxString file = m_listCtrlView->GetItemText( item ); | 430 wxString file = m_listCtrlView->GetItemText( item ); |
| 380 wxString from = workdir + wxFILE_SEP_PATH + file; | 431 wxString from = workdir + wxFILE_SEP_PATH + file; |
| 381 wxString to = trash + wxFILE_SEP_PATH + file; | 432 wxString to = trash + wxFILE_SEP_PATH + file; |
| 382 wxRenameFile( from, to, true ); | 433 wxRenameFile( from, to, true ); |
| 434 wxGetApp().WriteLog( wxT("deleted : ") + file ); | |
| 383 | 435 |
| 384 wxString movecmd = MOVECMD; | 436 wxString movecmd = MOVECMD; |
| 437 from.Replace( wxT("\\"), wxT("\\\\"), true ); | |
| 438 to.Replace( wxT("\\"), wxT("\\\\"), true ); | |
| 385 m_undo.Insert( movecmd + wxT(" ") + to + wxT(" ") + from, 0 ); | 439 m_undo.Insert( movecmd + wxT(" ") + to + wxT(" ") + from, 0 ); |
| 386 } | 440 } |
| 387 UpdateCache(); | 441 UpdateCache(); |
| 442 ClearGuess(); | |
| 388 UpdateListImage(); | 443 UpdateListImage(); |
| 389 m_buttonUndo->Enable(true); | 444 m_buttonUndo->Enable(true); |
| 390 } | 445 } |
| 391 /* アンドゥ */ | 446 /* アンドゥ */ |
| 392 void MyFrame::OnUndo(wxCommandEvent& WXUNUSED(event)) | 447 void MyFrame::OnUndo(wxCommandEvent& WXUNUSED(event)) |
| 403 } | 458 } |
| 404 | 459 |
| 405 /* 画像をリストコントロールに表示 */ | 460 /* 画像をリストコントロールに表示 */ |
| 406 void MyFrame::UpdateListImage() | 461 void MyFrame::UpdateListImage() |
| 407 { | 462 { |
| 408 // start-up iamge | 463 if ( !cache_changed && by_autodetect ) return; |
| 409 wxString notfound = wxGetCwd() + wxFILE_SEP_PATH + wxT("image") + wxFILE_SEP_PATH + wxT("notfound.png"); | |
| 410 wxBitmap bmp = wxBitmap( notfound, wxBITMAP_TYPE_PNG ); | |
| 411 m_bitmapName->SetBitmap( bmp ); | |
| 412 notfound = wxGetCwd() + wxFILE_SEP_PATH + wxT("image") + wxFILE_SEP_PATH + wxT("0000000000.png"); | |
| 413 bmp.LoadFile( notfound, wxBITMAP_TYPE_PNG ); | |
| 414 m_bitmapHhsno->SetBitmap( bmp ); | |
| 415 | 464 |
| 416 // 本処理 | 465 // 本処理 |
| 417 m_listCtrlView->DeleteAllItems(); | 466 m_listCtrlView->DeleteAllItems(); |
| 418 m_imageList->RemoveAll(); | 467 m_imageList->RemoveAll(); |
| 419 wxListItem item; | 468 wxListItem item; |
| 420 m_textCtrlGuess->SetBackgroundColour(*wxWHITE); | 469 m_textCtrlGuess->SetBackgroundColour(*wxWHITE); |
| 421 | 470 |
| 422 wxProgressDialog pd( wxT("進行状況"), wxT("処理開始..."), 7, this, wxPD_APP_MODAL|wxPD_REMAINING_TIME|wxPD_AUTO_HIDE ); | 471 if ( by_autodetect ) pd->Update( 0, wxT("処理開始") ); |
| 423 pd.SetSize( wxSize(320,140) ); | |
| 424 | 472 |
| 425 wxArrayString keys; | 473 wxArrayString keys; |
| 426 for ( CacheHash::iterator it=CH.begin(); it != CH.end(); ++it ) { | 474 for ( CacheHash::iterator it=CH.begin(); it != CH.end(); ++it ) { |
| 427 keys.Add(it->first); | 475 keys.Add(it->first); |
| 428 } | 476 } |
| 429 keys.Sort(); | 477 keys.Sort(); |
| 430 // イメージリストを作成 | 478 int kc = keys.GetCount(); |
| 431 for ( int i=0; i<keys.GetCount(); i++ ) { // item image | 479 // イメージリストを作成(サムネイル) |
| 480 for ( int i=0; i<kc; i++ ) { // item image | |
| 432 CacheItem* ci = new CacheItem; | 481 CacheItem* ci = new CacheItem; |
| 433 ci = CH[keys[i]]; | 482 ci = CH[keys[i]]; |
| 434 m_imageList->Add( ci->thumbnail ); | 483 m_imageList->Add( ci->thumbnail ); |
| 435 } | 484 } |
| 436 for ( int i=0; i<keys.GetCount(); i++ ) { // item selected image | 485 for ( int i=0; i<kc; i++ ) { // item selected image |
| 437 CacheItem* ci = new CacheItem; | 486 CacheItem* ci = new CacheItem; |
| 438 ci = CH[keys[i]]; | 487 ci = CH[keys[i]]; |
| 439 m_imageList->Add( ci->selthumbnail ); | 488 m_imageList->Add( ci->selthumbnail ); |
| 440 } | 489 } |
| 441 // アイテム作成 | 490 // アイテム作成 |
| 442 bool select = true; // flag | 491 bool select = true; // flag |
| 443 for ( int i=0; i<keys.GetCount(); i++ ) { | 492 for ( int i=0; i<kc; i++ ) { |
| 444 CacheItem* ci = new CacheItem; | 493 CacheItem* ci = new CacheItem; |
| 445 ci = CH[keys[i]]; | 494 ci = CH[keys[i]]; |
| 446 m_listCtrlView->InsertItem( i, ci->filename, i ); | 495 m_listCtrlView->InsertItem( i, ci->filename, i ); |
| 447 m_listCtrlView->SetItem( i, 0, ci->filename, i ); | 496 m_listCtrlView->SetItem( i, 0, ci->filename, i ); |
| 448 | 497 |
| 475 else { // 2枚目以降で初めてマークシートを認識したら,それ以降は選択しない | 524 else { // 2枚目以降で初めてマークシートを認識したら,それ以降は選択しない |
| 476 if ( ci->marksheet ) select = false; | 525 if ( ci->marksheet ) select = false; |
| 477 if ( select ) m_listCtrlView->SetItemState( i, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED ); | 526 if ( select ) m_listCtrlView->SetItemState( i, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED ); |
| 478 } | 527 } |
| 479 | 528 |
| 480 pd.Update( i+1, wxT("画像認識中") ); | 529 if ( !by_autodetect ) pd->Update( (int)(100/kc*(i+1)), wxT("画像認識中") ); |
| 481 } | 530 } |
| 482 // 画像ファイル数が多ければ,おそらく申請書 | 531 // 画像ファイル数が多ければ,おそらく申請書 |
| 483 if ( keys.GetCount() > 32 ) { | 532 if ( kc > 32 ) { |
| 484 int n = m_comboBoxCcn->GetCurrentSelection(); | 533 int n = m_comboBoxCcn->GetCurrentSelection(); |
| 485 wxString ccndir, dummy; wxArrayString array; | 534 wxString ccndir, dummy; wxArrayString array; |
| 486 GetCCnArrayInfo( array, n, dummy, ccndir ); | 535 GetCCnArrayInfo( array, n, dummy, ccndir ); |
| 487 m_textCtrlGuess->SetValue( ccndir ); | 536 m_textCtrlGuess->SetValue( ccndir ); |
| 488 } | 537 } |
| 493 i = m_listCtrlView->GetNextItem(i, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); | 542 i = m_listCtrlView->GetNextItem(i, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); |
| 494 if ( i == -1 ) break; | 543 if ( i == -1 ) break; |
| 495 m_listCtrlView->SetItemImage( i, i+m_listCtrlView->GetItemCount() ); | 544 m_listCtrlView->SetItemImage( i, i+m_listCtrlView->GetItemCount() ); |
| 496 } | 545 } |
| 497 | 546 |
| 547 by_autodetect = false; | |
| 498 SetStatusText( wxEmptyString, 2 ); | 548 SetStatusText( wxEmptyString, 2 ); |
| 499 } | 549 } |
| 500 | 550 |
| 501 /* 画像を選択したとき画像の情報をステータスバーに表示 */ | 551 /* 画像を選択したとき画像の情報をステータスバーに表示 */ |
| 502 void MyFrame::OnItemSelected(wxListEvent& event) | 552 void MyFrame::OnItemSelected(wxListEvent& event) |
| 537 | 587 |
| 538 wxImage image( imagefile, wxBITMAP_TYPE_JPEG ); | 588 wxImage image( imagefile, wxBITMAP_TYPE_JPEG ); |
| 539 wxBitmap bmp( image.Scale( 707, 1000, wxIMAGE_QUALITY_HIGH ) ); | 589 wxBitmap bmp( image.Scale( 707, 1000, wxIMAGE_QUALITY_HIGH ) ); |
| 540 wxSplashScreen* splash = new wxSplashScreen( bmp, | 590 wxSplashScreen* splash = new wxSplashScreen( bmp, |
| 541 wxSPLASH_CENTRE_ON_SCREEN|wxSPLASH_TIMEOUT, | 591 wxSPLASH_CENTRE_ON_SCREEN|wxSPLASH_TIMEOUT, |
| 542 3000, NULL, -1, wxDefaultPosition, wxDefaultSize, | 592 2500, NULL, -1, wxDefaultPosition, wxDefaultSize, |
| 543 wxSIMPLE_BORDER|wxSTAY_ON_TOP ); | 593 wxSIMPLE_BORDER|wxSTAY_ON_TOP ); |
| 544 wxYield(); | 594 wxYield(); |
| 545 } | 595 } |
| 546 | 596 |
| 547 /* パラメータダイアログ */ | 597 /* パラメータダイアログ */ |
| 548 void MyFrame::OnParam(wxCommandEvent& WXUNUSED(event)) | 598 void MyFrame::OnParam(wxCommandEvent& WXUNUSED(event)) |
| 549 { | 599 { |
| 550 ParamDialog* pd = new ParamDialog( NULL, wxID_ANY, wxT("Setting Parameters") ); | 600 ParamDialog* parad = new ParamDialog( NULL, wxID_ANY, wxT("Setting Parameters") ); |
| 551 if ( pd->ShowModal() == wxID_OK ) { | 601 if ( parad->ShowModal() == wxID_OK ) { |
| 552 pd->NewParam( wxGetApp().lmin, wxGetApp().lmax, wxGetApp().zmin, wxGetApp().zmax ); | 602 parad->NewParam( wxGetApp().lmin, wxGetApp().lmax, wxGetApp().zmin, wxGetApp().zmax ); |
| 553 } | 603 } |
| 554 pd->Destroy(); | 604 parad->Destroy(); |
| 555 } | 605 } |
| 556 | 606 |
| 557 /* キャッシュ作成&更新 */ | 607 /* キャッシュ作成&更新 */ |
| 558 void MyFrame::UpdateCache() | 608 void MyFrame::UpdateCache() |
| 559 { | 609 { |
| 578 wxString workdir = m_dirPickerWork->GetPath(); | 628 wxString workdir = m_dirPickerWork->GetPath(); |
| 579 wxArrayString filenames; | 629 wxArrayString filenames; |
| 580 wxListItem item; | 630 wxListItem item; |
| 581 | 631 |
| 582 /* キャッシュ作成 */ | 632 /* キャッシュ作成 */ |
| 633 cache_changed = false; | |
| 583 unsigned int n = wxDir::GetAllFiles( workdir, &filenames, wxT("*.jpg"), wxDIR_FILES ); | 634 unsigned int n = wxDir::GetAllFiles( workdir, &filenames, wxT("*.jpg"), wxDIR_FILES ); |
| 584 for ( int i=0; i<n; i++ ) { | 635 for ( int i=0; i<n; i++ ) { |
| 585 wxString fullpath = filenames[i]; | 636 wxString fullpath = filenames[i]; |
| 586 wxFileName f( fullpath ); | 637 wxFileName f( fullpath ); |
| 587 wxString file = f.GetFullName(); | 638 wxString file = f.GetFullName(); |
| 592 ci = CH[file]; | 643 ci = CH[file]; |
| 593 ci->exists = true; | 644 ci->exists = true; |
| 594 continue; | 645 continue; |
| 595 } | 646 } |
| 596 /* 新しいファイルはキャッシュ */ | 647 /* 新しいファイルはキャッシュ */ |
| 597 //float z; long l; bool m = IsMarksheet( fullpath, &z, &l ); | |
| 598 float z; long l; bool m = IsMarksheet( fullpath, &z, &l, zmin, zmax, lmin, lmax ); | 648 float z; long l; bool m = IsMarksheet( fullpath, &z, &l, zmin, zmax, lmin, lmax ); |
| 599 wxImage image( fullpath, wxBITMAP_TYPE_JPEG ); | 649 wxImage image( fullpath, wxBITMAP_TYPE_JPEG ); |
| 600 wxImage thumbnail = image.Scale( THUMB_W, THUMB_H, wxIMAGE_QUALITY_HIGH ); | 650 wxImage thumbnail = image.Scale( THUMB_W, THUMB_H, wxIMAGE_QUALITY_HIGH ); |
| 601 wxBitmap bmp( thumbnail ); | 651 wxBitmap bmp( thumbnail ); |
| 602 unsigned char *data = thumbnail.GetData(); | 652 unsigned char *data = thumbnail.GetData(); |
| 612 ci->thumbnail = bmp; | 662 ci->thumbnail = bmp; |
| 613 ci->selthumbnail = bmp_mask; | 663 ci->selthumbnail = bmp_mask; |
| 614 ci->modtime = wxEmptyString; // TODO. | 664 ci->modtime = wxEmptyString; // TODO. |
| 615 | 665 |
| 616 CH[ci->filename] = ci; // add hash | 666 CH[ci->filename] = ci; // add hash |
| 667 cache_changed = true; | |
| 617 SetStatusText( wxString::Format( wxT("rebuiling cache...( %d/%d :%.1fsec passed )"), i+1, n, (float)sw.Time()/1000 ), 0 ); | 668 SetStatusText( wxString::Format( wxT("rebuiling cache...( %d/%d :%.1fsec passed )"), i+1, n, (float)sw.Time()/1000 ), 0 ); |
| 618 wxGetApp().WriteLog( file + wxT(" appended.") + wxString::Format(wxT(" ( m=%d z=%f l=%d )"), m ? 1 : 0, z, l ) ); | 669 wxGetApp().WriteLog( file + wxT(" appended.") + wxString::Format(wxT(" ( m=%d z=%f l=%d )"), m ? 1 : 0, z, l ) ); |
| 619 } | 670 } |
| 620 | 671 |
| 621 /* 存在しないファイルはキャッシュから削除 */ | 672 /* 存在しないファイルはキャッシュから削除 */ |
| 625 ci = it->second; | 676 ci = it->second; |
| 626 if ( !ci->exists ) removelist.Add( ci->filename ); | 677 if ( !ci->exists ) removelist.Add( ci->filename ); |
| 627 } | 678 } |
| 628 for ( int i=0; i<removelist.GetCount(); i++ ) { | 679 for ( int i=0; i<removelist.GetCount(); i++ ) { |
| 629 CH.erase(removelist[i]); | 680 CH.erase(removelist[i]); |
| 681 cache_changed = true; | |
| 630 wxGetApp().WriteLog( removelist[i] + wxT(" removed.") ); | 682 wxGetApp().WriteLog( removelist[i] + wxT(" removed.") ); |
| 631 } | 683 } |
| 632 | 684 |
| 633 m_buttonDetect->Enable(true); | 685 m_buttonDetect->Enable(true); |
| 634 SetStatusText( wxEmptyString, 0 ); | 686 SetStatusText( wxEmptyString, 0 ); |
| 635 m_timer.Start( 20*1000, wxTIMER_ONE_SHOT ); // restart | 687 m_timer.Start( 2*1000, wxTIMER_ONE_SHOT ); // restart |
| 636 } | 688 } |
| 637 | 689 |
| 638 /* 被保険者フォルダを列挙 */ | 690 /* 被保険者フォルダを列挙 */ |
| 639 void MyFrame::ListHhsDir() | 691 void MyFrame::ListHhsDir() |
| 640 { | 692 { |
| 642 wxString hhsdir; | 694 wxString hhsdir; |
| 643 wxString buf; | 695 wxString buf; |
| 644 | 696 |
| 645 m_listCtrlHhsDir->DeleteAllItems(); | 697 m_listCtrlHhsDir->DeleteAllItems(); |
| 646 for ( int i=0; i<m_hhsList.GetCount(); i++ ) { | 698 for ( int i=0; i<m_hhsList.GetCount(); i++ ) { |
| 699 unsigned int n = 0; | |
| 700 wxArrayString dummy; | |
| 647 hhsdir = distdir + wxFILE_SEP_PATH + m_hhsList[i]; | 701 hhsdir = distdir + wxFILE_SEP_PATH + m_hhsList[i]; |
| 648 wxArrayString filenames; | 702 if ( wxDirExists( hhsdir ) ) n = wxDir::GetAllFiles( hhsdir, &dummy, wxT("*.jpg"), wxDIR_FILES ); |
| 649 unsigned int n = 0; | |
| 650 if ( wxDirExists( hhsdir ) ) n = wxDir::GetAllFiles( hhsdir, &filenames, wxT("*.jpg"), wxDIR_FILES ); | |
| 651 | 703 |
| 652 m_listCtrlHhsDir->InsertItem( i, -1 ); | 704 m_listCtrlHhsDir->InsertItem( i, -1 ); |
| 653 buf.Printf(wxT("%d"),i+1); | 705 buf.Printf(wxT("%d"),i+1); |
| 654 m_listCtrlHhsDir->SetItem( i, 0, buf, -1 ); | 706 m_listCtrlHhsDir->SetItem( i, 0, buf, -1 ); // No |
| 655 m_listCtrlHhsDir->SetItem( i, 1, m_hhsList[i], -1 ); | 707 m_listCtrlHhsDir->SetItem( i, 1, m_hhsList[i], -1 ); // Hhsno |
| 656 buf.Printf(wxT("%d"),n); | 708 buf.Printf(wxT("%d"),n); |
| 657 m_listCtrlHhsDir->SetItem( i, 2, buf, -1 ); | 709 m_listCtrlHhsDir->SetItem( i, 2, buf, -1 ); // file count |
| 658 m_listCtrlHhsDir->SetItem( i, 3, GetHhsName( m_hhsList[i]), -1 ); | 710 m_listCtrlHhsDir->SetItem( i, 3, GetHhsName( m_hhsList[i]), -1 ); // name |
| 659 if ( i % 2 ) m_listCtrlHhsDir->SetItemBackgroundColour( i, wxColour(wxT("WHEAT")) ); | 711 if ( i % 2 ) m_listCtrlHhsDir->SetItemBackgroundColour( i, wxColour(wxT("WHEAT")) ); |
| 660 } | 712 } |
| 661 } | 713 } |
| 662 | 714 |
| 663 /* 被保険者フォルダを開く */ | 715 /* 被保険者フォルダを開く */ |
| 664 void MyFrame::OnOpenHhsDir(wxListEvent& event) | 716 void MyFrame::OnOpenHhsDir(wxListEvent& event) |
| 665 { | 717 { |
| 666 wxString hhsdir; | 718 wxString hhsdir; |
| 667 hhsdir.Append( m_textCtrlDist->GetValue() ); | 719 hhsdir = m_textCtrlDist->GetValue() + wxFILE_SEP_PATH; |
| 668 hhsdir.Append( wxFILE_SEP_PATH ); | |
| 669 | 720 |
| 670 int i = event.GetIndex(); | 721 int i = event.GetIndex(); |
| 671 wxListItem item; | 722 wxListItem item; |
| 672 item.SetId(i); | 723 item.SetId(i); |
| 673 | 724 |
| 680 } | 731 } |
| 681 | 732 |
| 682 /* 以下,定型もの ***********************************************/ | 733 /* 以下,定型もの ***********************************************/ |
| 683 void MyFrame::OnTimer(wxTimerEvent& event) | 734 void MyFrame::OnTimer(wxTimerEvent& event) |
| 684 { | 735 { |
| 736 if ( !autodetect_mode ) return; | |
| 737 by_autodetect = true; | |
| 685 UpdateCache(); | 738 UpdateCache(); |
| 739 UpdateListImage(); | |
| 686 } | 740 } |
| 687 | 741 |
| 688 /* アイドリング */ | 742 /* アイドリング */ |
| 689 void MyFrame::OnIdle(wxIdleEvent& event) | 743 void MyFrame::OnIdle(wxIdleEvent& event) |
| 690 { | 744 { |
