Mercurial > mercurial > hgweb_mover2.cgi
comparison src/myframe.cpp @ 6:9c85d71cad7c
implement drag&drop.
author | pyon@macmini |
---|---|
date | Tue, 18 Oct 2011 22:43:46 +0900 |
parents | 52697c869ce8 |
children | 550c143ab194 |
comparison
equal
deleted
inserted
replaced
5:52697c869ce8 | 6:9c85d71cad7c |
---|---|
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" |
8 #include "marksheet.h" | 8 #include "marksheet.h" |
9 #include "dndfile.h" | |
9 | 10 |
10 // resources | 11 // resources |
11 // the application icon (under Windows and OS/2 it is in resources and even | 12 // the application icon (under Windows and OS/2 it is in resources and even |
12 // though we could still include the XPM here it would be unused) | 13 // though we could still include the XPM here it would be unused) |
13 #if !defined(__WXMSW__) && !defined(__WXPM__) | 14 #if !defined(__WXMSW__) && !defined(__WXPM__) |
129 m_listCtrlView = new wxListCtrl( this, ID_LISTCTRLVIEW, wxDefaultPosition, wxDefaultSize, wxLC_ICON ); | 130 m_listCtrlView = new wxListCtrl( this, ID_LISTCTRLVIEW, wxDefaultPosition, wxDefaultSize, wxLC_ICON ); |
130 m_listCtrlView->SetBackgroundColour(wxT("LIGHT GREY")); | 131 m_listCtrlView->SetBackgroundColour(wxT("LIGHT GREY")); |
131 bSizerManip->Add( m_listCtrlView, 1, wxALL|wxEXPAND, 5 ); | 132 bSizerManip->Add( m_listCtrlView, 1, wxALL|wxEXPAND, 5 ); |
132 m_imageList = new wxImageList( 160, 226 ); | 133 m_imageList = new wxImageList( 160, 226 ); |
133 m_listCtrlView->AssignImageList( m_imageList, wxIMAGE_LIST_NORMAL ); | 134 m_listCtrlView->AssignImageList( m_imageList, wxIMAGE_LIST_NORMAL ); |
135 //m_listCtrlView->SetDropTarget( new DnDFile(m_dirPickerWork) ); | |
136 this->SetDropTarget( new DnDFile(m_dirPickerWork) ); | |
134 | 137 |
135 wxBoxSizer* bSizerButton = new wxBoxSizer( wxVERTICAL ); | 138 wxBoxSizer* bSizerButton = new wxBoxSizer( wxVERTICAL ); |
136 | 139 |
137 m_buttonDetect = new wxButton( this, ID_BUTTONDETECT, wxT("検知"), wxDefaultPosition, wxDefaultSize, 0 ); | 140 m_buttonDetect = new wxButton( this, ID_BUTTONDETECT, wxT("検知"), wxDefaultPosition, wxDefaultSize, 0 ); |
138 bSizerButton->Add( m_buttonDetect, 0, wxALL, 5 ); | 141 bSizerButton->Add( m_buttonDetect, 0, wxALL, 5 ); |
286 m_bitmapName->SetBitmap( bmp ); | 289 m_bitmapName->SetBitmap( bmp ); |
287 notfound = wxGetCwd() + wxFILE_SEP_PATH + wxT("image") + wxFILE_SEP_PATH + wxT("0000000000.png"); | 290 notfound = wxGetCwd() + wxFILE_SEP_PATH + wxT("image") + wxFILE_SEP_PATH + wxT("0000000000.png"); |
288 bmp.LoadFile( notfound, wxBITMAP_TYPE_PNG ); | 291 bmp.LoadFile( notfound, wxBITMAP_TYPE_PNG ); |
289 m_bitmapHhsno->SetBitmap( bmp ); | 292 m_bitmapHhsno->SetBitmap( bmp ); |
290 | 293 |
291 wxString filename; | 294 wxArrayString filenames; |
292 bool cout = dir.GetFirst( &filename, wxT("*.jpg"), wxDIR_FILES ); | 295 unsigned int n = dir.GetAllFiles( workdir, &filenames, wxT("*.jpg"), wxDIR_FILES ); |
293 | 296 |
294 int i = 0; | |
295 m_listCtrlView->DeleteAllItems(); | 297 m_listCtrlView->DeleteAllItems(); |
296 m_imageList->RemoveAll(); | 298 m_imageList->RemoveAll(); |
297 wxListItem item; | 299 wxListItem item; |
298 wxString first; | 300 wxString first; |
299 wxProgressDialog pd( wxT("進行状況"), wxT("処理開始..."), 7, this, wxPD_APP_MODAL|wxPD_REMAINING_TIME|wxPD_AUTO_HIDE ); | 301 wxProgressDialog pd( wxT("進行状況"), wxT("処理開始..."), 7, this, wxPD_APP_MODAL|wxPD_REMAINING_TIME|wxPD_AUTO_HIDE ); |
300 pd.SetSize( wxSize(320,140) ); | 302 pd.SetSize( wxSize(320,140) ); |
301 float b; long l; | 303 float b; long l; |
302 while ( cout ) { | 304 for ( int i=0; i<n; i++ ) { |
303 wxString imagefile = workdir + wxFILE_SEP_PATH + filename; | 305 wxFileName f( filenames[i] ); |
306 wxString filename = f.GetFullName(); | |
304 | 307 |
305 m_listCtrlView->InsertItem( i, filename ); | 308 m_listCtrlView->InsertItem( i, filename ); |
306 m_listCtrlView->SetItem( i, 0, filename, i ); | 309 m_listCtrlView->SetItem( i, 0, filename, i ); |
307 | 310 |
308 wxImage image( imagefile, wxBITMAP_TYPE_JPEG ); | 311 wxImage image( filenames[i], wxBITMAP_TYPE_JPEG ); |
309 wxBitmap bmp( image.Scale( 160, 226, wxIMAGE_QUALITY_HIGH ) ); | 312 wxBitmap bmp( image.Scale( 160, 226, wxIMAGE_QUALITY_HIGH ) ); |
310 m_imageList->Add( bmp ); | 313 m_imageList->Add( bmp ); |
311 | 314 |
312 if ( i == 0 ) { | 315 if ( i == 0 ) { |
313 IsMarksheet( imagefile, &b, &l ); | 316 IsMarksheet( filenames[i], &b, &l ); |
314 first = imagefile; | 317 first = filenames[i]; |
315 SetStatusText( wxString::Format(wxT("1st image : z = %f, l = %d"),b,l), 1 ); | 318 SetStatusText( wxString::Format(wxT("1st image : z = %f, l = %d"),b,l), 1 ); |
316 | 319 |
317 wxImage marksheet( first, wxBITMAP_TYPE_JPEG ); | 320 wxImage marksheet( first, wxBITMAP_TYPE_JPEG ); |
318 wxImage name_image; | 321 wxImage name_image; |
319 name_image = marksheet.GetSubImage( wxRect( wxPoint(300,550), wxSize(640,190) ) ); | 322 name_image = marksheet.GetSubImage( wxRect( wxPoint(300,550), wxSize(640,190) ) ); |
327 | 330 |
328 wxString hhsno = GuessHhs( first ); | 331 wxString hhsno = GuessHhs( first ); |
329 m_textCtrlGuess->SetValue( hhsno ); | 332 m_textCtrlGuess->SetValue( hhsno ); |
330 } | 333 } |
331 else { | 334 else { |
332 if ( i > 7 || IsMarksheet( imagefile, &b, &l ) ) { | 335 if ( IsMarksheet( filenames[i], &b, &l ) ) { |
333 break; | 336 break; |
334 } | 337 } |
335 } | 338 } |
336 m_listCtrlView->SetItemState( i, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED ); | 339 m_listCtrlView->SetItemState( i, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED ); |
337 | 340 |
338 // write log | 341 // write log |
339 i++; | 342 pd.Update( i+1, wxT("画像認識中") ); |
340 pd.Update( i, wxT("画像認識中") ); | |
341 cout = dir.GetNext( &filename ); | |
342 } | 343 } |
343 | 344 |
344 SetStatusText( wxEmptyString, 2 ); | 345 SetStatusText( wxEmptyString, 2 ); |
345 } | 346 } |
346 | 347 |
384 /* パラメータダイアログ */ | 385 /* パラメータダイアログ */ |
385 void MyFrame::OnParam(wxCommandEvent& WXUNUSED(event)) | 386 void MyFrame::OnParam(wxCommandEvent& WXUNUSED(event)) |
386 { | 387 { |
387 ParamDialog* pd = new ParamDialog( NULL, wxID_ANY, wxT("Setting Parameters") ); | 388 ParamDialog* pd = new ParamDialog( NULL, wxID_ANY, wxT("Setting Parameters") ); |
388 if ( pd->ShowModal() == wxID_OK ) { | 389 if ( pd->ShowModal() == wxID_OK ) { |
389 wxGetApp().lmin; | 390 pd->NewParam( wxGetApp().lmin, wxGetApp().lmax, wxGetApp().zmin, wxGetApp().zmax ); |
390 wxGetApp().lmax; | |
391 wxGetApp().zmin; | |
392 wxGetApp().zmax; | |
393 } | 391 } |
394 pd->Destroy(); | 392 pd->Destroy(); |
395 } | 393 } |
396 | 394 |
397 // 以下,定型もの | 395 // 以下,定型もの |