Mercurial > mercurial > hgweb_mover2.cgi
diff 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 |
line wrap: on
line diff
--- a/src/myframe.cpp Sun Oct 16 00:18:18 2011 +0900 +++ b/src/myframe.cpp Sun Oct 16 16:21:33 2011 +0900 @@ -99,13 +99,17 @@ m_staticTextName = new wxStaticText( this, wxID_ANY, wxT("氏名"), wxDefaultPosition, wxDefaultSize, 0 ); bSizerGuess->Add( m_staticTextName, 0, wxTOP|wxLEFT, 5 ); - m_bitmapName = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize(320,95), 0 ); + wxString logo = wxGetCwd() + wxFILE_SEP_PATH + wxT("image") + wxFILE_SEP_PATH + wxT("logo.png"); + wxBitmap bmp = wxBitmap( logo, wxBITMAP_TYPE_PNG ); + m_bitmapName = new wxStaticBitmap( this, wxID_ANY, bmp, wxDefaultPosition, wxSize(320,95), 0 ); bSizerGuess->Add( m_bitmapName, 0, wxALL, 5 ); m_staticTextHhsno = new wxStaticText( this, wxID_ANY, wxT("被保険者番号"), wxDefaultPosition, wxDefaultSize, 0 ); bSizerGuess->Add( m_staticTextHhsno, 0, wxTOP|wxLEFT, 5 ); - m_bitmapHHsno = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize(320,54), 0 ); - bSizerGuess->Add( m_bitmapHHsno, 0, wxALL, 5 ); + logo = wxGetCwd() + wxFILE_SEP_PATH + wxT("image") + wxFILE_SEP_PATH + wxT("0123456789.png"); + bmp.LoadFile( logo, wxBITMAP_TYPE_PNG ); + m_bitmapHhsno = new wxStaticBitmap( this, wxID_ANY, bmp, wxDefaultPosition, wxSize(320,54), 0 ); + bSizerGuess->Add( m_bitmapHhsno, 0, wxALL, 5 ); m_staticTextGuess = new wxStaticText( this, wxID_ANY, wxT("推定値"), wxDefaultPosition, wxDefaultSize, 0 ); bSizerGuess->Add( m_staticTextGuess, 0, wxTOP|wxLEFT, 5 ); @@ -127,12 +131,15 @@ bSizerButton->Add( m_buttonDetect, 0, wxALL, 5 ); m_buttonMove = new wxButton( this, ID_BUTTONMOVE, wxT("移動"), wxDefaultPosition, wxDefaultSize, 0 ); bSizerButton->Add( m_buttonMove, 0, wxALL, 5 ); + m_buttonMove->Enable(false); m_buttonMD = new wxButton( this, ID_BUTTONMD, wxT("移動&検知"), wxDefaultPosition, wxDefaultSize, 0 ); bSizerButton->Add( m_buttonMD, 0, wxALL, 5 ); + m_buttonMD->Enable(false); m_buttonDel = new wxButton( this, ID_BUTTONDEL, wxT("削除"), wxDefaultPosition, wxDefaultSize, 0 ); bSizerButton->Add( m_buttonDel, 0, wxALL, 5 ); m_buttonUndo = new wxButton( this, ID_BUTTONUNDO, wxT("戻す"), wxDefaultPosition, wxDefaultSize, 0 ); bSizerButton->Add( m_buttonUndo, 0, wxALL, 5 ); + m_buttonUndo->Enable(false); bSizerManip->Add( bSizerButton, 0, wxALIGN_CENTER_VERTICAL, 5 ); @@ -166,8 +173,8 @@ EVT_BUTTON( ID_BUTTONDETECT, MyFrame::OnDetect ) EVT_BUTTON( ID_BUTTONMOVE, MyFrame::OnMove ) EVT_BUTTON( ID_BUTTONMD, MyFrame::OnMoveAndDetect ) - //EVT_BUTTON( ID_BUTTONDEL, MyFrame::Delete ) - //EVT_BUTTON( ID_BUTTONUNDO, MyFrame::Undo ) + EVT_BUTTON( ID_BUTTONDEL, MyFrame::OnDelete ) + EVT_BUTTON( ID_BUTTONUNDO, MyFrame::OnUndo ) EVT_LIST_ITEM_SELECTED( ID_LISTCTRLVIEW, MyFrame::GetImageInfo ) EVT_LIST_ITEM_ACTIVATED( ID_LISTCTRLVIEW, MyFrame::ViewLarge ) EVT_CLOSE( MyFrame::SaveConfig ) @@ -199,6 +206,8 @@ d.Append( wxFILE_SEP_PATH ); if ( !wxDirExists( d ) ) wxMkdir( d ); } + m_buttonMove->Enable(true); + m_buttonMD->Enable(true); wxMessageBox(wxT("移動先フォルダ準備完了")); wxString cmd = wxT("explorer ") + to; @@ -209,6 +218,7 @@ void MyFrame::OnMove(wxCommandEvent& WXUNUSED(event)) { MoveImage(); + m_buttonUndo->Enable(true); } /* 検知 */ void MyFrame::OnDetect(wxCommandEvent& WXUNUSED(event)) @@ -221,6 +231,55 @@ MoveImage(); ReadyImage(); } +/* 選択したファイルを移動 */ +void MyFrame::MoveImage() +{ + m_undo.Clear(); + wxString workdir = m_dirPickerWork->GetPath(); + wxString distdir = m_textCtrlDist->GetValue(); + long item = -1; + for ( ;; ) { + item = m_listCtrlView->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); + if ( item == -1 ) break; + wxString file = m_listCtrlView->GetItemText( item ); + wxString from = workdir + wxFILE_SEP_PATH + file; + wxString to = distdir + wxFILE_SEP_PATH + file; + wxRenameFile( from, to, true ); + m_undo.Insert( wxT("mv ") + to + wxT(" ") + from, 0 ); + } + ReadyImage(); + m_buttonUndo->Enable(true); +} +/* 選択したファイルを削除 */ +void MyFrame::OnDelete(wxCommandEvent& WXUNUSED(event)) +{ + m_undo.Clear(); + wxString workdir = m_dirPickerWork->GetPath(); + wxString trash = wxGetCwd() + wxFILE_SEP_PATH + wxT("trash"); + long item = -1; + for ( ;; ) { + item = m_listCtrlView->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); + if ( item == -1 ) break; + wxString file = m_listCtrlView->GetItemText( item ); + wxString from = workdir + wxFILE_SEP_PATH + file; + wxString to = trash + wxFILE_SEP_PATH + file; + wxRenameFile( from, to, true ); + m_undo.Insert( wxT("mv ") + to + wxT(" ") + from, 0 ); + } + ReadyImage(); + m_buttonUndo->Enable(true); +} +/* アンドゥ */ +void MyFrame::OnUndo(wxCommandEvent& WXUNUSED(event)) +{ + for ( int i=0; i<m_undo.GetCount(); i++ ) { + wxExecute( m_undo[i] ); + } + wxMessageBox(wxT("戻し完了.")); + m_buttonUndo->Enable(false); + m_undo.Clear(); + ReadyImage(); +} /* 画像をリストコントロールに表示 */ void MyFrame::ReadyImage() @@ -228,6 +287,12 @@ wxString workdir = m_dirPickerWork->GetPath(); wxDir dir( workdir ); if ( !dir.IsOpened() ) return; + wxString notfound = wxGetCwd() + wxFILE_SEP_PATH + wxT("image") + wxFILE_SEP_PATH + wxT("notfound.png"); + wxBitmap bmp = wxBitmap( notfound, wxBITMAP_TYPE_PNG ); + m_bitmapName->SetBitmap( bmp ); + notfound = wxGetCwd() + wxFILE_SEP_PATH + wxT("image") + wxFILE_SEP_PATH + wxT("0000000000.png"); + bmp.LoadFile( notfound, wxBITMAP_TYPE_PNG ); + m_bitmapHhsno->SetBitmap( bmp ); wxString filename; bool cout = dir.GetFirst( &filename, wxT("*.jpg"), wxDIR_FILES ); @@ -237,6 +302,8 @@ m_imageList->RemoveAll(); wxListItem item; wxString first; + wxProgressDialog pd( wxT("進行状況"), wxT("処理開始..."), 7, this, wxPD_APP_MODAL|wxPD_REMAINING_TIME|wxPD_AUTO_HIDE ); + pd.SetSize( wxSize(320,140) ); float b; long l; while ( cout ) { wxString imagefile = workdir + wxFILE_SEP_PATH + filename; @@ -252,6 +319,20 @@ IsMarksheet( imagefile, &b, &l ); first = imagefile; SetStatusText( wxString::Format(wxT("1st image : z = %f, l = %d"),b,l), 1 ); + + wxImage marksheet( first, wxBITMAP_TYPE_JPEG ); + wxImage name_image; + name_image = marksheet.GetSubImage( wxRect( wxPoint(300,550), wxSize(640,190) ) ); + wxBitmap name_bmp = ( name_image.Scale( 320, 95, wxIMAGE_QUALITY_HIGH ) ); + m_bitmapName->SetBitmap( name_bmp ); + + wxImage hhsno_image; + hhsno_image = marksheet.GetSubImage( wxRect( wxPoint(1800,210), wxSize(594,100) ) ); + wxBitmap hhsno_bmp = ( hhsno_image.Scale( 320, 54, wxIMAGE_QUALITY_HIGH ) ); + m_bitmapHhsno->SetBitmap( hhsno_bmp ); + + wxString hhsno = GuessHhs( first ); + m_textCtrlGuess->SetValue( hhsno ); } else { if ( i > 7 || IsMarksheet( imagefile, &b, &l ) ) { @@ -262,44 +343,11 @@ // write log i++; + pd.Update( i, wxT("画像認識中") ); cout = dir.GetNext( &filename ); } - wxImage marksheet( first, wxBITMAP_TYPE_JPEG ); - wxImage name_image; - name_image = marksheet.GetSubImage( wxRect( wxPoint(300,550), wxSize(640,190) ) ); - wxBitmap name_bmp = ( name_image.Scale( 320, 95, wxIMAGE_QUALITY_HIGH ) ); - m_bitmapName->SetBitmap( name_bmp ); - - wxImage hhsno_image; - hhsno_image = marksheet.GetSubImage( wxRect( wxPoint(1800,210), wxSize(594,100) ) ); - wxBitmap hhsno_bmp = ( hhsno_image.Scale( 320, 54, wxIMAGE_QUALITY_HIGH ) ); - m_bitmapHHsno->SetBitmap( hhsno_bmp ); - - wxString hhsno = GuessHhs( first ); - m_textCtrlGuess->SetValue( hhsno ); -} - -/* 画像移動 */ -void MyFrame::MoveImage() -{ - wxString distdir = m_textCtrlDist->GetValue(); - wxString ccn = m_comboBoxCcn->GetValue(); - if ( distdir.IsEmpty() || ccn.IsEmpty() ) { - wxMessageBox(wxT("フォルダを指定してください.")); - return; - } - - distdir.Append( wxFILE_SEP_PATH ); - if ( !wxDirExists( distdir ) ) { - wxMessageBox(wxT("フォルダが存在しません.")); - return; - } - - /* - wxString to = distdir + wxFILE_SEP_PATH + hhs + wxFILE_SEP_PATH + filename; - wxRenameFile( from, to, false ); - */ + SetStatusText( wxEmptyString, 2 ); } /* 画像を選択 */ @@ -314,7 +362,7 @@ float b; long l; wxString msg; if ( IsMarksheet( imagefile, &b, &l ) ) { - msg = wxT("Success detection"); + msg = wxT("perhaps marksheet !"); } SetStatusText( wxString::Format(wxT("selected image : z = %f, l = %d ...")+msg, b, l ), 2 ); }