comparison src/myframe.cpp @ 24:5c99c6fa50df v2.2dev v2.2

fix changing selected image color
author pyon@macmini
date Wed, 02 Nov 2011 20:47:18 +0900
parents a2dd16b70c08
children 5a934c8e1b95
comparison
equal deleted inserted replaced
23:a2dd16b70c08 24:5c99c6fa50df
1 // Filename : myframe.cpp 1 // Filename : myframe.cpp
2 // Last Change: 01-Nov-2011. 2 // Last Change: 02-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"
175 175
176 this->SetSizer( bSizerTop ); 176 this->SetSizer( bSizerTop );
177 this->Layout(); 177 this->Layout();
178 178
179 // ステータスバー 179 // ステータスバー
180 int widths[] = { 150, 250, -1, 120 }; 180 int widths[] = { 250, 250, -1, 120 };
181 m_statusBar = this->CreateStatusBar( WXSIZEOF(widths), wxST_SIZEGRIP ); 181 m_statusBar = this->CreateStatusBar( WXSIZEOF(widths), wxST_SIZEGRIP );
182 m_statusBar->SetStatusWidths( WXSIZEOF(widths), widths ); 182 m_statusBar->SetStatusWidths( WXSIZEOF(widths), widths );
183 m_statusBar->SetStatusText( wxEmptyString, 0 ); 183 m_statusBar->SetStatusText( wxEmptyString, 0 );
184 184
185 this->Centre( wxBOTH ); 185 this->Centre( wxBOTH );
338 338
339 // 本処理 339 // 本処理
340 m_listCtrlView->DeleteAllItems(); 340 m_listCtrlView->DeleteAllItems();
341 m_imageList->RemoveAll(); 341 m_imageList->RemoveAll();
342 wxListItem item; 342 wxListItem item;
343 m_textCtrlGuess->SetBackgroundColour(*wxWHITE);
343 344
344 wxProgressDialog pd( wxT("進行状況"), wxT("処理開始..."), 7, this, wxPD_APP_MODAL|wxPD_REMAINING_TIME|wxPD_AUTO_HIDE ); 345 wxProgressDialog pd( wxT("進行状況"), wxT("処理開始..."), 7, this, wxPD_APP_MODAL|wxPD_REMAINING_TIME|wxPD_AUTO_HIDE );
345 pd.SetSize( wxSize(320,140) ); 346 pd.SetSize( wxSize(320,140) );
346 347
347 wxArrayString keys; 348 wxArrayString keys;
381 wxBitmap hhsno_bmp = ( hhsno_image.Scale( 320, 54, wxIMAGE_QUALITY_HIGH ) ); 382 wxBitmap hhsno_bmp = ( hhsno_image.Scale( 320, 54, wxIMAGE_QUALITY_HIGH ) );
382 m_bitmapHhsno->SetBitmap( hhsno_bmp ); 383 m_bitmapHhsno->SetBitmap( hhsno_bmp );
383 384
384 wxString hhsno = GuessHhs( ci->fullpath ); 385 wxString hhsno = GuessHhs( ci->fullpath );
385 m_textCtrlGuess->SetValue( hhsno ); 386 m_textCtrlGuess->SetValue( hhsno );
387 wxString name;
388 int judge = IsHhsno( hhsno, name );
389 if ( judge == 0 ) m_textCtrlGuess->SetBackgroundColour(*wxRED); // not hhsno-style
390 //else if ( judge == 1 ) m_textCtrlGuess->SetBackgroundColour(wxT("YELLOW")); // not in DB
386 SetStatusText( wxString::Format(wxT("1st image : z = %f, l = %d"),ci->z,ci->l), 1 ); 391 SetStatusText( wxString::Format(wxT("1st image : z = %f, l = %d"),ci->z,ci->l), 1 );
387 m_listCtrlView->SetItemState( i, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED ); 392 m_listCtrlView->SetItemState( i, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
388 } 393 }
389 else { // 2枚目以降で初めてマークシートを認識したら,それ以降は選択しない 394 else { // 2枚目以降で初めてマークシートを認識したら,それ以降は選択しない
390 if ( ci->marksheet ) select = false; 395 if ( ci->marksheet ) select = false;
458 } 463 }
459 464
460 /* キャッシュ作成&更新 */ 465 /* キャッシュ作成&更新 */
461 void MyFrame::UpdateCache() 466 void MyFrame::UpdateCache()
462 { 467 {
468 double zmin, zmax; long lmin, lmax;
469 wxGetApp().zmin.ToDouble( &zmin );
470 wxGetApp().zmax.ToDouble( &zmax );
471 wxGetApp().lmin.ToLong( &lmin );
472 wxGetApp().lmax.ToLong( &lmax );
473
463 m_buttonDetect->Enable(false); 474 m_buttonDetect->Enable(false);
464 wxGetApp().WriteLog( wxT("start updating cache") ); 475 wxGetApp().WriteLog( wxT("start updating cache") );
465 SetStatusText( wxT("rebuiling cache..."), 0 ); 476 SetStatusText( wxT("rebuiling cache..."), 0 );
477 wxStopWatch sw;
478 sw.Start(0);
466 479
467 /* キャッシュ存在フラグOFF */ 480 /* キャッシュ存在フラグOFF */
468 for ( CacheHash::iterator it=CH.begin(); it != CH.end(); ++it ) { 481 for ( CacheHash::iterator it=CH.begin(); it != CH.end(); ++it ) {
469 CacheItem* ci = new CacheItem; 482 CacheItem* ci = new CacheItem;
470 ci = it->second; 483 ci = it->second;
491 ci = CH[file]; 504 ci = CH[file];
492 ci->exists = true; 505 ci->exists = true;
493 continue; 506 continue;
494 } 507 }
495 /* 新しいファイルはキャッシュ */ 508 /* 新しいファイルはキャッシュ */
496 float z; long l; bool m = IsMarksheet( fullpath, &z, &l ); 509 //float z; long l; bool m = IsMarksheet( fullpath, &z, &l );
510 float z; long l; bool m = IsMarksheet( fullpath, &z, &l, zmin, zmax, lmin, lmax );
497 wxImage image( fullpath, wxBITMAP_TYPE_JPEG ); 511 wxImage image( fullpath, wxBITMAP_TYPE_JPEG );
498 wxImage thumbnail = image.Scale( 160, 226, wxIMAGE_QUALITY_HIGH ); 512 wxImage thumbnail = image.Scale( 160, 226, wxIMAGE_QUALITY_HIGH );
499 wxBitmap bmp( thumbnail ); 513 wxBitmap bmp( thumbnail );
500 unsigned char *data = thumbnail.GetData(); 514 unsigned char *data = thumbnail.GetData();
501 for ( int y=0; y<226; y++ ) for ( int x=0; x<160; x++ ) data[(y*226+x)*3+2] = 255; // 文字色:黒(0,0,0)->青(0,0.255) 515 for ( int y=0; y<226; y++ ) for ( int x=0; x<160; x++ ) data[(y*160+x)*3+2] = 255; // 文字色:黒(0,0,0)->青(0,0.255)
502 wxBitmap bmp_mask( thumbnail ); 516 wxBitmap bmp_mask( thumbnail );
503 517
504 ci->filename = file; 518 ci->filename = file;
505 ci->fullpath = fullpath; 519 ci->fullpath = fullpath;
506 ci->marksheet = m; 520 ci->marksheet = m;
510 ci->thumbnail = bmp; 524 ci->thumbnail = bmp;
511 ci->selthumbnail = bmp_mask; 525 ci->selthumbnail = bmp_mask;
512 ci->modtime = wxEmptyString; // TODO. 526 ci->modtime = wxEmptyString; // TODO.
513 527
514 CH[ci->filename] = ci; // add hash 528 CH[ci->filename] = ci; // add hash
529 SetStatusText( wxString::Format( wxT("rebuiling cache...(%.1fsec passed)"), (float)sw.Time()/1000 ), 0 );
515 wxGetApp().WriteLog( file + wxT(" appended.") + wxString::Format(wxT(" ( m=%d z=%f l=%d )"), m ? 1 : 0, z, l ) ); 530 wxGetApp().WriteLog( file + wxT(" appended.") + wxString::Format(wxT(" ( m=%d z=%f l=%d )"), m ? 1 : 0, z, l ) );
516 } 531 }
517 532
518 /* 存在しないファイルはキャッシュから削除 */ 533 /* 存在しないファイルはキャッシュから削除 */
519 wxArrayString removelist; 534 wxArrayString removelist;