comparison src/myframe.cpp @ 27:d21de4693652 v2.2dev v2.3

add hhsname
author pyon@macmini
date Sat, 05 Nov 2011 10:13:41 +0900
parents 5a934c8e1b95
children 24283d3a9592
comparison
equal deleted inserted replaced
26:5a934c8e1b95 27:d21de4693652
1 // Filename : myframe.cpp 1 // Filename : myframe.cpp
2 // Last Change: 03-Nov-2011. 2 // Last Change: 05-Nov-2011.
3 // 3 //
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 "dndfile.h" 8 #include "dndfile.h"
9 #include "marksheet.h" 9 #include "marksheet.h"
10
11 #define LOGO_W 288
12 #define LOGO_H 86
13 #define HHSN_W 288
14 #define HHSN_H 49
15 #define THUMB_W 160
16 #define THUMB_H 226
10 17
11 // resources 18 // resources
12 // the application icon (under Windows and OS/2 it is in resources and even 19 // the application icon (under Windows and OS/2 it is in resources and even
13 // though we could still include the XPM here it would be unused) 20 // though we could still include the XPM here it would be unused)
14 #if !defined(__WXMSW__) && !defined(__WXPM__) 21 #if !defined(__WXMSW__) && !defined(__WXPM__)
104 111
105 bSizerTop->Add( bSizerDist, 0, wxEXPAND, 5 ); 112 bSizerTop->Add( bSizerDist, 0, wxEXPAND, 5 );
106 113
107 wxBoxSizer* bSizerManip = new wxBoxSizer( wxHORIZONTAL ); 114 wxBoxSizer* bSizerManip = new wxBoxSizer( wxHORIZONTAL );
108 115
109 wxBoxSizer* bSizerGuess = new wxBoxSizer( wxVERTICAL ); 116 wxBoxSizer* bSizerRecog = new wxBoxSizer( wxVERTICAL );
110 117
111 m_staticTextName = new wxStaticText( this, wxID_ANY, wxT("氏名"), wxDefaultPosition, wxDefaultSize, 0 ); 118 m_staticTextName = new wxStaticText( this, wxID_ANY, wxT("氏名"), wxDefaultPosition, wxDefaultSize, 0 );
112 bSizerGuess->Add( m_staticTextName, 0, wxTOP|wxLEFT, 5 ); 119 bSizerRecog->Add( m_staticTextName, 0, wxTOP|wxLEFT, 5 );
113 wxString logo = wxGetCwd() + wxFILE_SEP_PATH + wxT("image") + wxFILE_SEP_PATH + wxT("logo.png"); 120 wxString logo = wxGetCwd() + wxFILE_SEP_PATH + wxT("image") + wxFILE_SEP_PATH + wxT("logo.png");
114 wxBitmap bmp = wxBitmap( logo, wxBITMAP_TYPE_PNG ); 121 wxBitmap bmp = wxBitmap( logo, wxBITMAP_TYPE_PNG );
115 m_bitmapName = new wxStaticBitmap( this, wxID_ANY, bmp, wxDefaultPosition, wxSize(320,95), 0 ); 122 m_bitmapName = new wxStaticBitmap( this, wxID_ANY, bmp, wxDefaultPosition, wxSize(320,95), 0 );
116 bSizerGuess->Add( m_bitmapName, 0, wxALL, 5 ); 123 bSizerRecog->Add( m_bitmapName, 0, wxTOP|wxBOTTOM|wxLEFT, 5 );
117 124
118 m_staticTextHhsno = new wxStaticText( this, wxID_ANY, wxT("被保険者番号"), wxDefaultPosition, wxDefaultSize, 0 ); 125 m_staticTextHhsno = new wxStaticText( this, wxID_ANY, wxT("被保険者番号"), wxDefaultPosition, wxDefaultSize, 0 );
119 bSizerGuess->Add( m_staticTextHhsno, 0, wxTOP|wxLEFT, 5 ); 126 bSizerRecog->Add( m_staticTextHhsno, 0, wxTOP|wxLEFT, 5 );
120 logo = wxGetCwd() + wxFILE_SEP_PATH + wxT("image") + wxFILE_SEP_PATH + wxT("0123456789.png"); 127 logo = wxGetCwd() + wxFILE_SEP_PATH + wxT("image") + wxFILE_SEP_PATH + wxT("0123456789.png");
121 bmp.LoadFile( logo, wxBITMAP_TYPE_PNG ); 128 bmp.LoadFile( logo, wxBITMAP_TYPE_PNG );
122 m_bitmapHhsno = new wxStaticBitmap( this, wxID_ANY, bmp, wxDefaultPosition, wxSize(320,54), 0 ); 129 m_bitmapHhsno = new wxStaticBitmap( this, wxID_ANY, bmp, wxDefaultPosition, wxSize(320,54), 0 );
123 bSizerGuess->Add( m_bitmapHhsno, 0, wxALL, 5 ); 130 bSizerRecog->Add( m_bitmapHhsno, 0, wxTOP|wxBOTTOM|wxLEFT, 5 );
124 131
125 m_staticTextGuess = new wxStaticText( this, wxID_ANY, wxT("推定値"), wxDefaultPosition, wxDefaultSize, 0 ); 132 m_staticTextGuess = new wxStaticText( this, wxID_ANY, wxT("推定値"), wxDefaultPosition, wxDefaultSize, 0 );
126 bSizerGuess->Add( m_staticTextGuess, 0, wxTOP|wxLEFT, 5 ); 133 bSizerRecog->Add( m_staticTextGuess, 0, wxTOP|wxLEFT, 5 );
134
135 wxBoxSizer* bSizerGuess = new wxBoxSizer( wxHORIZONTAL );
136
127 m_textCtrlGuess = new wxTextCtrl( this, ID_TEXTCTRLGUESS, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); 137 m_textCtrlGuess = new wxTextCtrl( this, ID_TEXTCTRLGUESS, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
128 m_textCtrlGuess->SetMaxLength( 10 ); 138 m_textCtrlGuess->SetMaxLength( 10 );
129 bSizerGuess->Add( m_textCtrlGuess, 0, wxALL, 5 ); 139 bSizerGuess->Add( m_textCtrlGuess, 0, wxALL, 5 );
130 140
131 bSizerManip->Add( bSizerGuess, 0, wxEXPAND, 5 ); 141 m_textCtrlName = new wxTextCtrl( this, ID_TEXTCTRLNAME, wxEmptyString, wxDefaultPosition, wxSize(140,-1), 0 );
142 m_textCtrlName->SetBackgroundColour(wxT("LIGHT GREY"));
143 bSizerGuess->Add( m_textCtrlName, 0, wxALL, 5 );
144
145 bSizerRecog->Add( bSizerGuess, 0, wxEXPAND, 5 );
146
147 bSizerManip->Add( bSizerRecog, 0, wxEXPAND|wxLEFT, 5 );
132 148
133 m_listCtrlView = new wxListCtrl( this, ID_LISTCTRLVIEW, wxDefaultPosition, wxDefaultSize, wxLC_ICON ); 149 m_listCtrlView = new wxListCtrl( this, ID_LISTCTRLVIEW, wxDefaultPosition, wxDefaultSize, wxLC_ICON );
134 m_listCtrlView->SetBackgroundColour(wxT("LIGHT GREY")); 150 m_listCtrlView->SetBackgroundColour(wxT("LIGHT GREY"));
135 bSizerManip->Add( m_listCtrlView, 1, wxALL|wxEXPAND, 5 ); 151 bSizerManip->Add( m_listCtrlView, 1, wxTOP|wxRIGHT|wxBOTTOM|wxEXPAND, 5 );
136 m_imageList = new wxImageList( 160, 226 ); 152 m_imageList = new wxImageList( THUMB_W, THUMB_H );
137 m_listCtrlView->AssignImageList( m_imageList, wxIMAGE_LIST_NORMAL ); 153 m_listCtrlView->AssignImageList( m_imageList, wxIMAGE_LIST_NORMAL );
138 //m_listCtrlView->SetDropTarget( new DnDFile(m_dirPickerWork) ); 154 //m_listCtrlView->SetDropTarget( new DnDFile(m_dirPickerWork) );
139 this->SetDropTarget( new DnDFile(m_dirPickerWork) ); 155 this->SetDropTarget( new DnDFile(m_dirPickerWork) );
140 156
141 wxBoxSizer* bSizerButton = new wxBoxSizer( wxVERTICAL ); 157 wxBoxSizer* bSizerButton = new wxBoxSizer( wxVERTICAL );
153 gSizer->Add( m_buttonUndo, 0, wxALL, 5 ); 169 gSizer->Add( m_buttonUndo, 0, wxALL, 5 );
154 m_buttonUndo->Enable(false); 170 m_buttonUndo->Enable(false);
155 171
156 bSizerButton->Add( gSizer, 0, wxALL, 5 ); 172 bSizerButton->Add( gSizer, 0, wxALL, 5 );
157 173
158 m_listCtrlHhsDir = new wxListCtrl( this, ID_LISTCTRLDIR, wxDefaultPosition, wxDefaultSize, wxLC_REPORT|wxLC_SINGLE_SEL ); 174 m_listCtrlHhsDir = new wxListCtrl( this, ID_LISTCTRLDIR, wxDefaultPosition, wxSize(280,-1), wxLC_REPORT|wxLC_SINGLE_SEL );
159 wxListItem itemCol; 175 wxListItem itemCol;
160 itemCol.SetText( wxT("通番") ); 176 itemCol.SetText( wxT("通番") );
161 m_listCtrlHhsDir->InsertColumn( 0, itemCol ); 177 m_listCtrlHhsDir->InsertColumn( 0, itemCol );
162 m_listCtrlHhsDir->SetColumnWidth( 0, 50 ); 178 m_listCtrlHhsDir->SetColumnWidth( 0, 40 );
163 itemCol.SetText( wxT("被保険者番号") ); 179 itemCol.SetText( wxT("被保険者番号") );
164 m_listCtrlHhsDir->InsertColumn( 1, itemCol ); 180 m_listCtrlHhsDir->InsertColumn( 1, itemCol );
165 m_listCtrlHhsDir->SetColumnWidth( 1, 100 ); 181 m_listCtrlHhsDir->SetColumnWidth( 1, 90 );
166 itemCol.SetText( wxT("ファイル数") ); 182 itemCol.SetText( wxT("枚数") );
167 m_listCtrlHhsDir->InsertColumn( 2, itemCol ); 183 m_listCtrlHhsDir->InsertColumn( 2, itemCol );
168 m_listCtrlHhsDir->SetColumnWidth( 2, 60 ); 184 m_listCtrlHhsDir->SetColumnWidth( 2, 40 );
185 itemCol.SetText( wxT("氏名") );
186 m_listCtrlHhsDir->InsertColumn( 3, itemCol );
187 m_listCtrlHhsDir->SetColumnWidth( 3, 90 );
169 188
170 bSizerButton->Add( m_listCtrlHhsDir, 1, wxEXPAND|wxALL, 5 ); 189 bSizerButton->Add( m_listCtrlHhsDir, 1, wxEXPAND|wxALL, 5 );
171 190
172 bSizerManip->Add( bSizerButton, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 ); 191 bSizerManip->Add( bSizerButton, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );
173 192
377 m_listCtrlView->SetItem( i, 0, ci->filename, i ); 396 m_listCtrlView->SetItem( i, 0, ci->filename, i );
378 397
379 if ( i == 0 ) { // 1枚目はマークシートのはず 398 if ( i == 0 ) { // 1枚目はマークシートのはず
380 wxImage marksheet( ci->fullpath, wxBITMAP_TYPE_JPEG ); 399 wxImage marksheet( ci->fullpath, wxBITMAP_TYPE_JPEG );
381 400
401 // 氏名画像を表示
382 wxImage name_image; 402 wxImage name_image;
383 name_image = marksheet.GetSubImage( wxRect( wxPoint(300,550), wxSize(640,190) ) ); 403 name_image = marksheet.GetSubImage( wxRect( wxPoint(300,550), wxSize(640,190) ) );
384 wxBitmap name_bmp = ( name_image.Scale( 320, 95, wxIMAGE_QUALITY_HIGH ) ); 404 wxBitmap name_bmp = ( name_image.Scale( LOGO_W, LOGO_H, wxIMAGE_QUALITY_HIGH ) );
385 m_bitmapName->SetBitmap( name_bmp ); 405 m_bitmapName->SetBitmap( name_bmp );
386 406
407 // 被保険者番号画像を表示
387 wxImage hhsno_image; 408 wxImage hhsno_image;
388 hhsno_image = marksheet.GetSubImage( wxRect( wxPoint(1800,210), wxSize(594,100) ) ); 409 hhsno_image = marksheet.GetSubImage( wxRect( wxPoint(1800,210), wxSize(594,100) ) );
389 wxBitmap hhsno_bmp = ( hhsno_image.Scale( 320, 54, wxIMAGE_QUALITY_HIGH ) ); 410 wxBitmap hhsno_bmp = ( hhsno_image.Scale( HHSN_W, HHSN_H, wxIMAGE_QUALITY_HIGH ) );
390 m_bitmapHhsno->SetBitmap( hhsno_bmp ); 411 m_bitmapHhsno->SetBitmap( hhsno_bmp );
391 412
392 wxString hhsno = GuessHhs( ci->fullpath ); 413 wxString hhsno = GuessHhs( ci->fullpath );
393 m_textCtrlGuess->SetValue( hhsno ); 414 m_textCtrlGuess->SetValue( hhsno );
394 wxString name; 415 wxString name;
395 int judge = IsHhsno( hhsno, name ); 416 int judge = IsHhsno( hhsno, name );
396 if ( judge == 0 ) m_textCtrlGuess->SetBackgroundColour(*wxRED); // not hhsno-style 417 if ( judge == 0 ) m_textCtrlGuess->SetBackgroundColour(*wxRED); // not hhsno-style
397 //else if ( judge == 1 ) m_textCtrlGuess->SetBackgroundColour(wxT("YELLOW")); // not in DB 418 else if ( judge == 1 ) m_textCtrlGuess->SetBackgroundColour(wxT("YELLOW")); // not in DB
419 m_textCtrlName->SetValue( name );
420
398 SetStatusText( wxString::Format(wxT("1st image : z = %f, l = %d"),ci->z,ci->l), 1 ); 421 SetStatusText( wxString::Format(wxT("1st image : z = %f, l = %d"),ci->z,ci->l), 1 );
399 m_listCtrlView->SetItemState( i, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED ); 422 m_listCtrlView->SetItemState( i, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
400 } 423 }
401 else { // 2枚目以降で初めてマークシートを認識したら,それ以降は選択しない 424 else { // 2枚目以降で初めてマークシートを認識したら,それ以降は選択しない
402 if ( ci->marksheet ) select = false; 425 if ( ci->marksheet ) select = false;
510 } 533 }
511 /* 新しいファイルはキャッシュ */ 534 /* 新しいファイルはキャッシュ */
512 //float z; long l; bool m = IsMarksheet( fullpath, &z, &l ); 535 //float z; long l; bool m = IsMarksheet( fullpath, &z, &l );
513 float z; long l; bool m = IsMarksheet( fullpath, &z, &l, zmin, zmax, lmin, lmax ); 536 float z; long l; bool m = IsMarksheet( fullpath, &z, &l, zmin, zmax, lmin, lmax );
514 wxImage image( fullpath, wxBITMAP_TYPE_JPEG ); 537 wxImage image( fullpath, wxBITMAP_TYPE_JPEG );
515 wxImage thumbnail = image.Scale( 160, 226, wxIMAGE_QUALITY_HIGH ); 538 wxImage thumbnail = image.Scale( THUMB_W, THUMB_H, wxIMAGE_QUALITY_HIGH );
516 wxBitmap bmp( thumbnail ); 539 wxBitmap bmp( thumbnail );
517 unsigned char *data = thumbnail.GetData(); 540 unsigned char *data = thumbnail.GetData();
518 for ( int y=0; y<226; y++ ) for ( int x=0; x<160; x++ ) data[(y*160+x)*3+2] = 255; // 文字色:黒(0,0,0)->青(0,0.255) 541 for ( int y=0; y<THUMB_H; y++ ) for ( int x=0; x<THUMB_W; x++ ) data[(y*THUMB_W+x)*3+2] = 255; // 文字色:黒(0,0,0)->青(0,0.255)
519 wxBitmap bmp_mask( thumbnail ); 542 wxBitmap bmp_mask( thumbnail );
520 543
521 ci->filename = file; 544 ci->filename = file;
522 ci->fullpath = fullpath; 545 ci->fullpath = fullpath;
523 ci->marksheet = m; 546 ci->marksheet = m;
578 { 601 {
579 wxString hhsdir; 602 wxString hhsdir;
580 hhsdir.Append( m_textCtrlDist->GetValue() ); 603 hhsdir.Append( m_textCtrlDist->GetValue() );
581 hhsdir.Append( wxFILE_SEP_PATH ); 604 hhsdir.Append( wxFILE_SEP_PATH );
582 605
583 wxListItem item = event.GetItem(); 606 int i = event.GetIndex();
607 wxListItem item;
608 item.SetId(i);
609
584 item.SetColumn(1); 610 item.SetColumn(1);
585 item.SetMask(wxLIST_MASK_TEXT); 611 item.SetMask(wxLIST_MASK_TEXT);
586 m_listCtrlHhsDir->GetItem( item ); 612 m_listCtrlHhsDir->GetItem( item );
587 hhsdir.Append( item.GetText() ); 613 hhsdir.Append( item.GetText() );
588 wxString execmd = wxT("explorer ") + hhsdir; 614 wxString execmd = wxT("explorer ") + hhsdir;
589 wxExecute( execmd ); 615 wxExecute( execmd );
590 //wxMessageBox(hhsdir);
591 } 616 }
592 617
593 // 以下,定型もの 618 // 以下,定型もの
594 void MyFrame::OnTimer(wxTimerEvent& event) 619 void MyFrame::OnTimer(wxTimerEvent& event)
595 { 620 {