Mercurial > mercurial > hgweb_mover2.cgi
changeset 1:b47bd4618c16
design done.
author | pyon@macmini |
---|---|
date | Sat, 15 Oct 2011 20:07:12 +0900 |
parents | 7bf900d47e9e |
children | e4ba3cc9b4b1 |
files | include/common.h include/marksheet.h include/myframe.h makefile src/main.cpp src/myframe.cpp |
diffstat | 6 files changed, 123 insertions(+), 79 deletions(-) [+] |
line wrap: on
line diff
--- a/include/common.h Sat Oct 15 13:24:27 2011 +0900 +++ b/include/common.h Sat Oct 15 20:07:12 2011 +0900 @@ -9,6 +9,7 @@ #ifndef WX_PRECOMP #include "wx/wx.h" #include <wx/icon.h> + #include <wx/imaglist.h> #include <wx/dir.h> #include <wx/menu.h> #include <wx/string.h> @@ -46,7 +47,9 @@ ID_TEXTCTRLGUESS, ID_LISTCTRLVIEW, + ID_BUTTONDETECT, ID_BUTTONMOVE, + ID_BUTTONMD, ID_BUTTONDEL, ID_BUTTONUNDO,
--- a/include/marksheet.h Sat Oct 15 13:24:27 2011 +0900 +++ b/include/marksheet.h Sat Oct 15 20:07:12 2011 +0900 @@ -1,5 +1,5 @@ // Filename : marksheet.h -// Last Change: 06-Oct-2011. +// Last Change: 15-Oct-2011. // #ifndef __MARKSHEET__ #define __MARKSHEET__ @@ -62,7 +62,7 @@ return hhs; }; -bool IsMarksheet( wxString& file ) +bool IsMarksheet( wxString& file, float* brate, long* len ) { wxImage img( file, wxBITMAP_TYPE_JPEG ); int black = 0; @@ -85,6 +85,8 @@ float lmin = 2072393; float lmax = 2346082; + *brate = z; + *len = l; //wxPuts(wxString::Format(wxT("z = %f, len = %d"),z,len)); if ( zmin < z && z < zmax && lmin < l && l < lmax ) {
--- a/include/myframe.h Sat Oct 15 13:24:27 2011 +0900 +++ b/include/myframe.h Sat Oct 15 20:07:12 2011 +0900 @@ -38,7 +38,10 @@ wxTextCtrl* m_textCtrlGuess; wxListCtrl* m_listCtrlView; + + wxButton* m_buttonDetect; wxButton* m_buttonMove; + wxButton* m_buttonMD; wxButton* m_buttonDel; wxButton* m_buttonUndo; @@ -46,17 +49,20 @@ MyFrame( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL ); ~MyFrame(); - void SetDir(wxCommandEvent& event); + void OnParam(wxCommandEvent& event); void MakeDir(wxCommandEvent& event); - void Do(wxCommandEvent& event); + void ToggleSelect(wxListEvent& event); + void OnDetect(wxCommandEvent& event); + void OnMove(wxCommandEvent& event); + void OnMoveAndDetect(wxCommandEvent& event); void ReadyImage(void); void MoveImage(void); // $B0J2<!$Dj7?$b$N(B - void OnSize(wxSizeEvent& event); - void OnMove(wxMoveEvent& event); + void OnWinSize(wxSizeEvent& event); + void OnWinMove(wxMoveEvent& event); void TellLocation( void ); + void OnOpenAppDir(wxCommandEvent& event); void OnQuit(wxCommandEvent& event); - void OnOpenAppDir(wxCommandEvent& event); void SaveConfig(wxCloseEvent& event); };
--- a/makefile Sat Oct 15 13:24:27 2011 +0900 +++ b/makefile Sat Oct 15 20:07:12 2011 +0900 @@ -102,7 +102,7 @@ -mkdir -p $(OBJDIR) $(CXX) -c $< -o $@ $(CPPFLAGS) -$(OBJDIR)/myframe.o: myframe.cpp myframe.h common.h main.h +$(OBJDIR)/myframe.o: myframe.cpp myframe.h common.h main.h marksheet.h $(CXX) -c $< -o $@ $(CPPFLAGS) $(OBJDIR)/param.o: param.cpp param.h common.h main.h
--- a/src/main.cpp Sat Oct 15 13:24:27 2011 +0900 +++ b/src/main.cpp Sat Oct 15 20:07:12 2011 +0900 @@ -32,7 +32,7 @@ MyFrame *mainframe = new MyFrame( NULL, ID_MAIN, title ); mainframe->SetSize( rect ); - mainframe->SetMinSize( wxSize( 580, 680 ) ); + mainframe->SetMinSize( wxSize( 1200, 500 ) ); mainframe->Show(true); /* TestFrame *tf = new TestFrame( NULL, ID_TEST, wxT("A Test") );
--- a/src/myframe.cpp Sat Oct 15 13:24:27 2011 +0900 +++ b/src/myframe.cpp Sat Oct 15 20:07:12 2011 +0900 @@ -4,6 +4,7 @@ #include "main.h" #include "myframe.h" +#include "marksheet.h" ////////////////////////////////////////////////////////////////////////// // frame constructor @@ -48,26 +49,34 @@ bSizerTop->Add( bSizerFrom, 0, wxEXPAND, 5 ); - wxBoxSizer* bSizerCcn = new wxBoxSizer( wxHORIZONTAL ); + wxBoxSizer* bSizerDist = new wxBoxSizer( wxHORIZONTAL ); + + m_staticTextDist = new wxStaticText( this, wxID_ANY, wxT("保存フォルダ"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizerDist->Add( m_staticTextDist, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + + m_textCtrlDist = new wxTextCtrl( this, ID_TEXTCTRLDIST, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + m_textCtrlDist->SetMaxLength( 15 ); + bSizerDist->Add( m_textCtrlDist, 1, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + bSizerDist->Add( 0, 0, 1, wxEXPAND, 5 ); m_staticTextDrive = new wxStaticText( this, wxID_ANY, wxT("ドライブ"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizerCcn->Add( m_staticTextDrive, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + bSizerDist->Add( m_staticTextDrive, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); wxArrayString drives; drives.Add(wxT("C:")); drives.Add(wxT("Y:")); drives.Add(wxT("Z:")); m_comboBoxDrive = new wxComboBox( this, wxID_ANY, wxT("C:"), wxDefaultPosition, wxSize(50,-1), drives, 0 ); - bSizerCcn->Add( m_comboBoxDrive, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + bSizerDist->Add( m_comboBoxDrive, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); m_staticTextDate = new wxStaticText( this, wxID_ANY, wxT("開催日"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizerCcn->Add( m_staticTextDate, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + bSizerDist->Add( m_staticTextDate, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); m_datePicker = new wxDatePickerCtrl( this, wxID_ANY, wxDefaultDateTime, wxDefaultPosition, wxDefaultSize, wxDP_DROPDOWN ); - bSizerCcn->Add( m_datePicker, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + bSizerDist->Add( m_datePicker, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); m_staticTextCcn = new wxStaticText( this, wxID_ANY, wxT("合議体"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizerCcn->Add( m_staticTextCcn, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + bSizerDist->Add( m_staticTextCcn, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); wxArrayString ccns; ccns.Add(wxT("角館1")); ccns.Add(wxT("角館2")); ccns.Add(wxT("角館3")); ccns.Add(wxT("角館4")); @@ -76,23 +85,11 @@ ccns.Add(wxT("大曲1")); ccns.Add(wxT("大曲2")); ccns.Add(wxT("大曲3")); ccns.Add(wxT("大曲4")); ccns.Add(wxT("大曲5")); ccns.Add(wxT("大曲6")); ccns.Add(wxT("六郷1")); ccns.Add(wxT("六郷2")); ccns.Add(wxT("六郷3")); m_comboBoxCcn = new wxComboBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(100,-1), ccns, 0 ); - bSizerCcn->Add( m_comboBoxCcn, 0, wxALL, 5 ); + bSizerDist->Add( m_comboBoxCcn, 0, wxALL, 5 ); m_buttonMkDir = new wxButton( this, ID_BUTTONMKDIR, wxT("適用"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizerCcn->Add( m_buttonMkDir, 0, wxALL, 5 ); - - bSizerTop->Add( bSizerCcn, 0, wxEXPAND, 5 ); - - wxBoxSizer* bSizerDist = new wxBoxSizer( wxHORIZONTAL ); + bSizerDist->Add( m_buttonMkDir, 0, wxALL, 5 ); - m_staticTextDist = new wxStaticText( this, wxID_ANY, wxT("保存フォルダ"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizerDist->Add( m_staticTextDist, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); - - m_textCtrlDist = new wxTextCtrl( this, ID_TEXTCTRLDIST, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - m_textCtrlDist->SetMaxLength( 15 ); - bSizerDist->Add( m_textCtrlDist, 1, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); - - bSizerDist->Add( 0, 0, 1, wxEXPAND, 5 ); bSizerTop->Add( bSizerDist, 0, wxEXPAND, 5 ); @@ -101,17 +98,17 @@ wxBoxSizer* bSizerGuess = new wxBoxSizer( wxVERTICAL ); m_staticTextName = new wxStaticText( this, wxID_ANY, wxT("氏名"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizerGuess->Add( m_staticTextName, 0, wxALL, 5 ); - m_bitmapName = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 ); + bSizerGuess->Add( m_staticTextName, 0, wxTOP|wxLEFT, 5 ); + m_bitmapName = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, 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, wxALL, 5 ); - m_bitmapHHsno = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, 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 ); m_staticTextGuess = new wxStaticText( this, wxID_ANY, wxT("推定値"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizerGuess->Add( m_staticTextGuess, 0, wxALL, 5 ); + bSizerGuess->Add( m_staticTextGuess, 0, wxTOP|wxLEFT, 5 ); m_textCtrlGuess = new wxTextCtrl( this, ID_TEXTCTRLGUESS, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); m_textCtrlGuess->SetMaxLength( 10 ); bSizerGuess->Add( m_textCtrlGuess, 0, wxALL, 5 ); @@ -119,14 +116,19 @@ bSizerManip->Add( bSizerGuess, 0, wxEXPAND, 5 ); m_listCtrlView = new wxListCtrl( this, ID_LISTCTRLVIEW, wxDefaultPosition, wxDefaultSize, wxLC_ICON ); + m_listCtrlView->SetBackgroundColour(wxT("LIGHT GREY")); bSizerManip->Add( m_listCtrlView, 1, wxALL|wxEXPAND, 5 ); - m_imageList = new wxImageList( 63, 89 ); + m_imageList = new wxImageList( 189, 267 ); m_listCtrlView->AssignImageList( m_imageList, wxIMAGE_LIST_NORMAL ); wxBoxSizer* bSizerButton = new wxBoxSizer( wxVERTICAL ); + m_buttonDetect = new wxButton( this, ID_BUTTONDETECT, wxT("検知"), wxDefaultPosition, wxDefaultSize, 0 ); + 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_buttonMD = new wxButton( this, ID_BUTTONMD, wxT("移動&検知"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizerButton->Add( m_buttonMD, 0, wxALL, 5 ); 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 ); @@ -140,14 +142,12 @@ this->Layout(); // ステータスバー - int widths[] = { -1, 150, 120, 120 }; + int widths[] = { -1, 150, 200, 120 }; m_statusBar = this->CreateStatusBar( WXSIZEOF(widths), wxST_SIZEGRIP ); m_statusBar->SetStatusWidths( WXSIZEOF(widths), widths ); m_statusBar->SetStatusText( wxEmptyString, 0 ); this->Centre( wxBOTH ); - - ReadyImage(); } // destructor @@ -157,45 +157,42 @@ // Event Table BEGIN_EVENT_TABLE( MyFrame, wxFrame ) - EVT_SIZE( MyFrame::OnSize ) - EVT_MOVE( MyFrame::OnMove ) - /* - EVT_MENU( wxID_EXIT, MyFrame::OnQuit ) - EVT_MENU( wxID_ABOUT, MyFrame::OnAbout ) - EVT_MENU( ID_OPWORK, MyFrame::OnOpenWorkDir ) - EVT_BUTTON( ID_STDIR, MyFrame::SetDir ) - EVT_BUTTON( ID_MKDIR, MyFrame::MakeDir ) - EVT_BUTTON( ID_DOMOVE, MyFrame::MoveImages ) - EVT_LIST_ITEM_ACTIVATED( ID_LIST, MyFrame::OnOpenHhsDir ) - */ + EVT_SIZE( MyFrame::OnWinSize ) + EVT_MOVE( MyFrame::OnWinMove ) + EVT_MENU( ID_MENUITEMPARAM, MyFrame::OnParam ) + EVT_MENU( ID_MENUITEMAPPDIR, MyFrame::OnOpenAppDir ) + EVT_MENU( wxID_EXIT, MyFrame::OnQuit ) + 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_LIST_ITEM_MIDDLE_CLICK( ID_LISTCTRLVIEW, MyFrame::ToggleSelect ) + EVT_LIST_ITEM_RIGHT_CLICK( ID_LISTCTRLVIEW, MyFrame::ToggleSelect ) + //EVT_LIST_ITEM_ACTIVATED( ID_LIST, MyFrame::OnOpenHhsDir ) EVT_CLOSE( MyFrame::SaveConfig ) END_EVENT_TABLE() // Event Handlers -/* 移動先フォルダセット */ -void MyFrame::SetDir(wxCommandEvent& WXUNUSED(event)) -{ - wxString dir; - dir.Append( m_comboBoxDrive->GetValue() ); - dir.Append( wxFILE_SEP_PATH ); - wxDateTime dt = m_datePicker->GetValue(); - dir.Append( dt.Format(wxT("%Y%m%d")) ); - dir.Append( wxFILE_SEP_PATH ); - dir.Append( m_comboBoxCcn->GetValue() ); - m_textCtrlDist->SetValue( dir ); -} - /* 移動先フォルダ作成 */ void MyFrame::MakeDir(wxCommandEvent& WXUNUSED(event)) { - wxString distdir = m_textCtrlDist->GetValue(); + wxString to; + to.Append( m_comboBoxDrive->GetValue() ); + to.Append( wxFILE_SEP_PATH ); + wxDateTime dt = m_datePicker->GetValue(); + to.Append( dt.Format(wxT("%Y%m%d")) ); + to.Append( wxFILE_SEP_PATH ); + to.Append( m_comboBoxCcn->GetValue() ); + m_textCtrlDist->SetValue( to ); + wxString ccn = m_comboBoxCcn->GetValue(); - if ( distdir.Len() < 15 || ccn.IsEmpty() ) { + if ( to.Len() < 15 || ccn.IsEmpty() ) { wxMessageBox(wxT("フォルダを指定してください.")); return; } - wxStringTokenizer tkz( distdir, wxFILE_SEP_PATH ); + wxStringTokenizer tkz( to, wxFILE_SEP_PATH ); wxString d; while ( tkz.HasMoreTokens() ) { d.Append( tkz.GetNextToken() ); @@ -204,11 +201,22 @@ } wxMessageBox(wxT("移動先フォルダ準備完了")); - wxString cmd = wxT("explorer ") + distdir; + wxString cmd = wxT("explorer ") + to; wxExecute( cmd ); } -void MyFrame::Do(wxCommandEvent& WXUNUSED(event)) +/* 移動 */ +void MyFrame::OnMove(wxCommandEvent& WXUNUSED(event)) +{ + MoveImage(); +} +/* 検知 */ +void MyFrame::OnDetect(wxCommandEvent& WXUNUSED(event)) +{ + ReadyImage(); +} +/* 移動し検知 */ +void MyFrame::OnMoveAndDetect(wxCommandEvent& WXUNUSED(event)) { MoveImage(); ReadyImage(); @@ -228,11 +236,18 @@ m_listCtrlView->DeleteAllItems(); m_imageList->RemoveAll(); wxListItem item; + wxString first; + float b; long l; while ( cout ) { if ( i > 7 ) break; wxString imagefile = workdir + wxFILE_SEP_PATH + filename; - if ( i > 1 && IsMarksheet() ) cout = false; + if ( i == 0 ) { + IsMarksheet( imagefile, &b, &l ); + first = imagefile; + SetStatusText( wxString::Format(wxT("z = %f, l = %d"),b,l), 2 ); + } + if ( i > 1 && IsMarksheet( imagefile, &b, &l ) ) cout = false; item.SetId(i); item.SetMask(wxLIST_MASK_STATE|wxLIST_MASK_TEXT|wxLIST_MASK_IMAGE); @@ -243,19 +258,27 @@ m_listCtrlView->InsertItem( item ); m_listCtrlView->SetItem( item ); - wxImage img( imagefile, wxBITMAP_TYPE_JPEG ); - wxBitmap bmp( img.Scale( 63, 89, wxIMAGE_QUALITY_HIGH ) ); + wxImage image( imagefile, wxBITMAP_TYPE_JPEG ); + wxBitmap bmp( image.Scale( 189, 267, wxIMAGE_QUALITY_HIGH ) ); m_imageList->Add( bmp ); // write log i++; cout = dir.GetNext( &filename ); } - /* - wxImage img_org( s, wxBITMAP_TYPE_JPEG ); - wxImage img_name; - img_name = img_org.GetSubImage( wxRect( wxPoint(328,556), wxSize(626,288) ) ); - img_name = img_name.Scale( 200, 92 ); - */ + + 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 ); } /* 画像移動 */ @@ -280,6 +303,16 @@ */ } +/* 画像を選択 */ +void MyFrame::ToggleSelect(wxListEvent& event) +{ +} + +/* パラメータダイアログ */ +void MyFrame::OnParam(wxCommandEvent& WXUNUSED(event)) +{ +} + // 以下,定型もの /* アプリフォルダを開く */ void MyFrame::OnOpenAppDir(wxCommandEvent& WXUNUSED(event)) @@ -290,14 +323,14 @@ } /* サイズ変更 */ -void MyFrame::OnSize(wxSizeEvent& event) +void MyFrame::OnWinSize(wxSizeEvent& event) { this->Refresh( true, NULL ); TellLocation(); event.Skip(); } /* ウィンドウ移動 */ -void MyFrame::OnMove(wxMoveEvent& WXUNUSED(event)) +void MyFrame::OnWinMove(wxMoveEvent& WXUNUSED(event)) { TellLocation(); return; @@ -310,7 +343,7 @@ int y = r.GetY(); int w = r.GetWidth(); int h = r.GetHeight(); - SetStatusText( wxString::Format(wxT("(%d,%d) %dx%d"),x,y,w,h), 2 ); + SetStatusText( wxString::Format(wxT("(%d,%d) %dx%d"),x,y,w,h), 3 ); } /* 終了 */ void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))