# HG changeset patch # User pyon@macmini # Date 1318945426 -32400 # Node ID 9c85d71cad7c6834b6c4a0d25f19896d0266a0cc # Parent 52697c869ce81c3c9fd68fa85dfef830e27131c4 implement drag&drop. diff -r 52697c869ce8 -r 9c85d71cad7c TODO --- a/TODO Tue Oct 18 07:53:48 2011 +0900 +++ b/TODO Tue Oct 18 22:43:46 2011 +0900 @@ -1,3 +1,19 @@ -* backgound workdir check +====================================================================== + TODO +====================================================================== +* backgound workdir check * cache detect result * d&d image + +---------------------------------------------------------------------- + Memo +---------------------------------------------------------------------- +00000000XY +X: omagari 0, nisisen 2, kakudate 3, senhata 4 +Y: 1..6 + +[Param] +lmin=2072393 +lmax=2346082 +zmin=0.095713 +zmax=0.108600 diff -r 52697c869ce8 -r 9c85d71cad7c include/common.h --- a/include/common.h Tue Oct 18 07:53:48 2011 +0900 +++ b/include/common.h Tue Oct 18 22:43:46 2011 +0900 @@ -15,6 +15,7 @@ #include #include #include + #include #include #include #include diff -r 52697c869ce8 -r 9c85d71cad7c include/dndfile.h --- a/include/dndfile.h Tue Oct 18 07:53:48 2011 +0900 +++ b/include/dndfile.h Tue Oct 18 22:43:46 2011 +0900 @@ -1,23 +1,28 @@ -#include "wx/wxprec.h" - -#ifndef WX_PRECOMP - #include "wx/wx.h" - #include "wx/arrstr.h" - #include "wx/textctrl.h" - #include "wx/dnd.h" -#endif +// Filename : param.cpp +// Last Change: 18-Oct-2011. +// class DnDFile : public wxFileDropTarget { public: - DnDFile( wxTextCtrl *owner ) { m_owner = owner; } - virtual bool OnDropFiles( wxCoord x, wxCoord y, const wxArrayString& finenames ) + DnDFile( wxDirPickerCtrl *dir ) + { + m_workdir = dir->GetPath(); + } + virtual bool OnDropFiles( wxCoord x, wxCoord y, const wxArrayString& filenames ) { - m_owner->SetValue( finenames[0] ); + size_t nFiles = filenames.GetCount(); + for ( size_t n=0; nAdd( m_listCtrlView, 1, wxALL|wxEXPAND, 5 ); m_imageList = new wxImageList( 160, 226 ); m_listCtrlView->AssignImageList( m_imageList, wxIMAGE_LIST_NORMAL ); + //m_listCtrlView->SetDropTarget( new DnDFile(m_dirPickerWork) ); + this->SetDropTarget( new DnDFile(m_dirPickerWork) ); wxBoxSizer* bSizerButton = new wxBoxSizer( wxVERTICAL ); @@ -288,10 +291,9 @@ bmp.LoadFile( notfound, wxBITMAP_TYPE_PNG ); m_bitmapHhsno->SetBitmap( bmp ); - wxString filename; - bool cout = dir.GetFirst( &filename, wxT("*.jpg"), wxDIR_FILES ); + wxArrayString filenames; + unsigned int n = dir.GetAllFiles( workdir, &filenames, wxT("*.jpg"), wxDIR_FILES ); - int i = 0; m_listCtrlView->DeleteAllItems(); m_imageList->RemoveAll(); wxListItem item; @@ -299,19 +301,20 @@ 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; + for ( int i=0; iInsertItem( i, filename ); m_listCtrlView->SetItem( i, 0, filename, i ); - wxImage image( imagefile, wxBITMAP_TYPE_JPEG ); + wxImage image( filenames[i], wxBITMAP_TYPE_JPEG ); wxBitmap bmp( image.Scale( 160, 226, wxIMAGE_QUALITY_HIGH ) ); m_imageList->Add( bmp ); if ( i == 0 ) { - IsMarksheet( imagefile, &b, &l ); - first = imagefile; + IsMarksheet( filenames[i], &b, &l ); + first = filenames[i]; SetStatusText( wxString::Format(wxT("1st image : z = %f, l = %d"),b,l), 1 ); wxImage marksheet( first, wxBITMAP_TYPE_JPEG ); @@ -329,16 +332,14 @@ m_textCtrlGuess->SetValue( hhsno ); } else { - if ( i > 7 || IsMarksheet( imagefile, &b, &l ) ) { + if ( IsMarksheet( filenames[i], &b, &l ) ) { break; } } m_listCtrlView->SetItemState( i, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED ); // write log - i++; - pd.Update( i, wxT("画像認識中") ); - cout = dir.GetNext( &filename ); + pd.Update( i+1, wxT("画像認識中") ); } SetStatusText( wxEmptyString, 2 ); @@ -386,10 +387,7 @@ { ParamDialog* pd = new ParamDialog( NULL, wxID_ANY, wxT("Setting Parameters") ); if ( pd->ShowModal() == wxID_OK ) { - wxGetApp().lmin; - wxGetApp().lmax; - wxGetApp().zmin; - wxGetApp().zmax; + pd->NewParam( wxGetApp().lmin, wxGetApp().lmax, wxGetApp().zmin, wxGetApp().zmax ); } pd->Destroy(); } diff -r 52697c869ce8 -r 9c85d71cad7c src/param.cpp --- a/src/param.cpp Tue Oct 18 07:53:48 2011 +0900 +++ b/src/param.cpp Tue Oct 18 22:43:46 2011 +0900 @@ -13,22 +13,22 @@ wxBoxSizer* bSizer = new wxBoxSizer( wxVERTICAL ); wxGridSizer* gSizer = new wxGridSizer( 2, 3, 0, 0 ); - m_textCtrlLMin = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - gSizer->Add( m_textCtrlLMin, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL|wxLeft, 20 ); + m_textCtrlLMin = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_RIGHT ); + gSizer->Add( m_textCtrlLMin, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL|wxLEFT, 20 ); m_staticTextLen = new wxStaticText( this, wxID_ANY, wxT("< レングス(l) <"), wxDefaultPosition, wxDefaultSize, 0 ); gSizer->Add( m_staticTextLen, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 5 ); - m_textCtrlLMax = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + m_textCtrlLMax = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_RIGHT ); gSizer->Add( m_textCtrlLMax, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL|wxRIGHT, 20 ); - m_textCtrlZMin = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + m_textCtrlZMin = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_RIGHT ); gSizer->Add( m_textCtrlZMin, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxLEFT, 20 ); m_staticTextZ = new wxStaticText( this, wxID_ANY, wxT("< 黒色比率(z) <"), wxDefaultPosition, wxDefaultSize, 0 ); gSizer->Add( m_staticTextZ, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 ); - m_textCtrlZmax = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + m_textCtrlZmax = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_RIGHT ); gSizer->Add( m_textCtrlZmax, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxRIGHT, 20 ); m_staticTextlDummy = new wxStaticText( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); @@ -48,7 +48,7 @@ this->Centre( wxBOTH ); - GetParam(); + ReadParam(); } // destructor @@ -60,17 +60,20 @@ END_EVENT_TABLE() /* 現在の設定を読込み */ -void ParamDialog::GetParam(void) +void ParamDialog::ReadParam(void) { - float zmin = 0.095713; - float zmax = 0.108600; - - float lmin = 2072393; - float lmax = 2346082; - m_textCtrlLMin->SetValue( wxGetApp().lmin ); m_textCtrlLMax->SetValue( wxGetApp().lmax ); - //m_textCtrlZMin->SetValue( wxString::Format(wxT("%l"),wxGetApp().zmin) ); - //m_textCtrlZmax->SetValue( wxString::Format(wxT("%l"),wxGetApp().zmax) ); + m_textCtrlZMin->SetValue( wxGetApp().zmin ); + m_textCtrlZmax->SetValue( wxGetApp().zmax ); } +/* 新しいパラメータ値の受渡し */ +void ParamDialog::NewParam( wxString& lmin, wxString& lmax, wxString& zmin, wxString& zmax ) +{ + lmin = m_textCtrlLMin->GetValue(); + lmax = m_textCtrlLMax->GetValue(); + zmin = m_textCtrlZMin->GetValue(); + zmax = m_textCtrlZmax->GetValue(); +} +