Mercurial > mercurial > hgweb_mover2.cgi
changeset 4:964129946db6
Release : v2.0 finished !!!
author | pyon@macmini |
---|---|
date | Sun, 16 Oct 2011 16:21:33 +0900 |
parents | 870860d435a1 |
children | 52697c869ce8 |
files | .hgignore image/0000000000.png image/0123456789.png image/logo.png image/notfound.png include/myframe.h sample.ico sample.rc src/main.cpp src/myframe.cpp |
diffstat | 10 files changed, 128 insertions(+), 43 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgignore Sun Oct 16 00:18:18 2011 +0900 +++ b/.hgignore Sun Oct 16 16:21:33 2011 +0900 @@ -4,6 +4,7 @@ tmp/* db/* work/* +trash/* *.app/* .DS_Store *.conf
--- a/include/myframe.h Sun Oct 16 00:18:18 2011 +0900 +++ b/include/myframe.h Sun Oct 16 16:21:33 2011 +0900 @@ -12,6 +12,7 @@ DECLARE_EVENT_TABLE() private: wxImageList* m_imageList; + wxArrayString m_undo; protected: wxMenuBar* m_menubarFile; @@ -33,7 +34,7 @@ wxStaticText* m_staticTextName; wxStaticBitmap* m_bitmapName; wxStaticText* m_staticTextHhsno; - wxStaticBitmap* m_bitmapHHsno; + wxStaticBitmap* m_bitmapHhsno; wxStaticText* m_staticTextGuess; wxTextCtrl* m_textCtrlGuess; @@ -56,6 +57,8 @@ void OnDetect(wxCommandEvent& event); void OnMove(wxCommandEvent& event); void OnMoveAndDetect(wxCommandEvent& event); + void OnDelete(wxCommandEvent& event); + void OnUndo(wxCommandEvent& event); void ReadyImage(void); void MoveImage(void); // $B0J2<!$Dj7?$b$N(B
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sample.rc Sun Oct 16 16:21:33 2011 +0900 @@ -0,0 +1,32 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: samples/samples.rc +// Purpose: a standard Win32 .rc file for the wxWindows samples +// Author: Vadim Zeitlin +// Modified by: +// Created: 04.08.03 +// RCS-ID: $Id: sample.rc 22863 2003-08-14 14:08:53Z VS $ +// Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwindows.org> +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +// this minimal resource file is all what is needed for most of the wxWindows +// samples + +// note that the icon used by the Explorer (i.e. the programs icon) is the +// first icon in the executable and the icons are sorted both by their order +// (Win9x) and by alphabetically (!) (NT), so put this icon first and give it +// a name starting with "a" +aaaaaaaa ICON "sample.ico" + +// this icon is used with wxFrame::SetIcon() +sample ICON "sample.ico" + +// set this to 1 if you don't want to use manifest resource (manifest resource +// is needed to enable visual styles on Windows XP - see docs/msw/winxp.txt +// for more information) +#define wxUSE_NO_MANIFEST 0 + +// this is not always needed but doesn't hurt (except making the executable +// very slightly larger): this file contains the standard icons, cursors, ... +#include "wx/msw/wx.rc" +
--- a/src/main.cpp Sun Oct 16 00:18:18 2011 +0900 +++ b/src/main.cpp Sun Oct 16 16:21:33 2011 +0900 @@ -1,5 +1,5 @@ // Filename : main.cpp -// Last Change: 15-Oct-2011. +// Last Change: 16-Oct-2011. // #include "common.h" @@ -23,6 +23,7 @@ if ( !wxApp::OnInit() ) return false; wxImage::AddHandler( new wxJPEGHandler ); + wxImage::AddHandler( new wxPNGHandler ); ConfInit();
--- 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 ); }