Mercurial > mercurial > hgweb_mover2.cgi
changeset 6:9c85d71cad7c
implement drag&drop.
author | pyon@macmini |
---|---|
date | Tue, 18 Oct 2011 22:43:46 +0900 |
parents | 52697c869ce8 |
children | a43adb9537b2 |
files | TODO include/common.h include/dndfile.h include/param.h makefile src/myframe.cpp src/param.cpp |
diffstat | 7 files changed, 71 insertions(+), 48 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- 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 <wx/menu.h> #include <wx/string.h> #include <wx/statusbr.h> + #include <wx/dnd.h> #include <wx/stattext.h> #include <wx/button.h> #include <wx/datectrl.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; n<nFiles; n++ ) { + wxFileName filename( filenames[n] ); + wxString from = filenames[n]; + wxString to = m_workdir + wxFILE_SEP_PATH + filename.GetFullName(); + wxRenameFile( from, to, true ); + //wxMessageBox( wxT("move ") + filenames[n] + to ); + } return true; } private: - wxTextCtrl *m_owner; + wxString m_workdir; };
--- a/include/param.h Tue Oct 18 07:53:48 2011 +0900 +++ b/include/param.h Tue Oct 18 22:43:46 2011 +0900 @@ -1,5 +1,5 @@ // Filename : param.h -// Last Change: 17-Oct-2011. +// Last Change: 18-Oct-2011. // #ifndef __param__ @@ -31,9 +31,9 @@ ParamDialog( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("パラメータ設定"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxCAPTION|wxDEFAULT_DIALOG_STYLE ); ~ParamDialog(); - void GetParam(void); + void ReadParam(void); void SaveParam(wxCommandEvent& event); - + void NewParam( wxString& lmin, wxString& lmax, wxString& zmin, wxString& zmax ); }; #endif //__param.h__
--- a/makefile Tue Oct 18 07:53:48 2011 +0900 +++ b/makefile Tue Oct 18 22:43:46 2011 +0900 @@ -102,7 +102,7 @@ -mkdir -p $(OBJDIR) $(CXX) -c $< -o $@ $(CPPFLAGS) -$(OBJDIR)/myframe.o: myframe.cpp myframe.h common.h main.h marksheet.h +$(OBJDIR)/myframe.o: myframe.cpp myframe.h common.h main.h marksheet.h dndfile.h $(CXX) -c $< -o $@ $(CPPFLAGS) $(OBJDIR)/param.o: param.cpp param.h common.h main.h
--- a/src/myframe.cpp Tue Oct 18 07:53:48 2011 +0900 +++ b/src/myframe.cpp Tue Oct 18 22:43:46 2011 +0900 @@ -6,6 +6,7 @@ #include "myframe.h" #include "param.h" #include "marksheet.h" +#include "dndfile.h" // resources // the application icon (under Windows and OS/2 it is in resources and even @@ -131,6 +132,8 @@ bSizerManip->Add( 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; i<n; i++ ) { + wxFileName f( filenames[i] ); + wxString filename = f.GetFullName(); m_listCtrlView->InsertItem( 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(); }
--- 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(); +} +