0
|
1 // Filename : myframe.cpp
|
8
|
2 // Last Change: 19-Oct-2011.
|
0
|
3 //
|
|
4
|
|
5 #include "main.h"
|
|
6 #include "myframe.h"
|
5
|
7 #include "param.h"
|
1
|
8 #include "marksheet.h"
|
6
|
9 #include "dndfile.h"
|
0
|
10
|
5
|
11 // resources
|
|
12 // 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)
|
|
14 #if !defined(__WXMSW__) && !defined(__WXPM__)
|
|
15 #include "sample.xpm"
|
|
16 #endif
|
|
17
|
0
|
18 //////////////////////////////////////////////////////////////////////////
|
|
19 // frame constructor
|
|
20 MyFrame::MyFrame( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxFrame( parent, id, title, pos, size, style )
|
|
21 {
|
|
22 this->SetBackgroundColour( wxColour(wxT("WHEAT")) );
|
|
23 // set the frame icon
|
5
|
24 SetIcon(wxICON(sample));
|
0
|
25
|
|
26 // メニューバー
|
|
27 m_menubarFile = new wxMenuBar();
|
|
28 m_menuFile = new wxMenu();
|
|
29 wxMenuItem* m_menuItemParam;
|
|
30 m_menuItemParam = new wxMenuItem( m_menuFile, ID_MENUITEMPARAM, wxString( wxT("パラメータ(&P)") ) , wxEmptyString, wxITEM_NORMAL );
|
|
31 m_menuFile->Append( m_menuItemParam );
|
|
32
|
|
33 wxMenuItem* m_menuItemAppDIr;
|
|
34 m_menuItemAppDIr = new wxMenuItem( m_menuFile, ID_MENUITEMAPPDIR, wxString( wxT("アプリフォルダを開く(&O)") ) , wxEmptyString, wxITEM_NORMAL );
|
|
35 m_menuFile->Append( m_menuItemAppDIr );
|
|
36
|
|
37 wxMenuItem* m_separator;
|
|
38 m_separator = m_menuFile->AppendSeparator(); // ----
|
|
39
|
|
40 wxMenuItem* m_menuItemQuit;
|
|
41 m_menuItemQuit = new wxMenuItem( m_menuFile, ID_MENUITEMQUIT, wxString( wxT("終了(&X)") ) , wxEmptyString, wxITEM_NORMAL );
|
|
42 m_menuFile->Append( m_menuItemQuit );
|
|
43
|
|
44 m_menubarFile->Append( m_menuFile, wxT("ファイル(&F)") );
|
|
45
|
|
46 this->SetMenuBar( m_menubarFile );
|
|
47
|
|
48 // コントロール
|
|
49 wxBoxSizer* bSizerTop = new wxBoxSizer( wxVERTICAL );
|
|
50
|
|
51 wxBoxSizer* bSizerFrom = new wxBoxSizer( wxHORIZONTAL );
|
|
52
|
|
53 m_staticTextWork = new wxStaticText( this, wxID_ANY, wxT("作業フォルダ"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
54 bSizerFrom->Add( m_staticTextWork, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
|
|
55
|
|
56 m_dirPickerWork = new wxDirPickerCtrl( this, wxID_ANY, wxGetApp().workdir, wxT("Select a folder"), wxDefaultPosition, wxDefaultSize, wxDIRP_DEFAULT_STYLE );
|
|
57 bSizerFrom->Add( m_dirPickerWork, 1, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
|
|
58
|
|
59 bSizerTop->Add( bSizerFrom, 0, wxEXPAND, 5 );
|
|
60
|
1
|
61 wxBoxSizer* bSizerDist = new wxBoxSizer( wxHORIZONTAL );
|
|
62
|
|
63 m_staticTextDist = new wxStaticText( this, wxID_ANY, wxT("保存フォルダ"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
64 bSizerDist->Add( m_staticTextDist, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
|
|
65
|
|
66 m_textCtrlDist = new wxTextCtrl( this, ID_TEXTCTRLDIST, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
|
|
67 m_textCtrlDist->SetMaxLength( 15 );
|
|
68 bSizerDist->Add( m_textCtrlDist, 1, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
|
|
69 bSizerDist->Add( 0, 0, 1, wxEXPAND, 5 );
|
0
|
70
|
|
71 m_staticTextDrive = new wxStaticText( this, wxID_ANY, wxT("ドライブ"), wxDefaultPosition, wxDefaultSize, 0 );
|
1
|
72 bSizerDist->Add( m_staticTextDrive, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
|
0
|
73
|
|
74 wxArrayString drives;
|
|
75 drives.Add(wxT("C:"));
|
|
76 drives.Add(wxT("Y:"));
|
|
77 drives.Add(wxT("Z:"));
|
|
78 m_comboBoxDrive = new wxComboBox( this, wxID_ANY, wxT("C:"), wxDefaultPosition, wxSize(50,-1), drives, 0 );
|
1
|
79 bSizerDist->Add( m_comboBoxDrive, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
|
0
|
80
|
|
81 m_staticTextDate = new wxStaticText( this, wxID_ANY, wxT("開催日"), wxDefaultPosition, wxDefaultSize, 0 );
|
1
|
82 bSizerDist->Add( m_staticTextDate, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
|
0
|
83
|
|
84 m_datePicker = new wxDatePickerCtrl( this, wxID_ANY, wxDefaultDateTime, wxDefaultPosition, wxDefaultSize, wxDP_DROPDOWN );
|
1
|
85 bSizerDist->Add( m_datePicker, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
|
8
|
86
|
|
87 m_buttonNextThu = new wxButton( this, ID_BUTTONNEXTTHU, wxT("次木 >>"), wxDefaultPosition, wxSize(60,-1), 0 );
|
|
88 bSizerDist->Add( m_buttonNextThu, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
|
0
|
89
|
|
90 m_staticTextCcn = new wxStaticText( this, wxID_ANY, wxT("合議体"), wxDefaultPosition, wxDefaultSize, 0 );
|
1
|
91 bSizerDist->Add( m_staticTextCcn, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
|
0
|
92
|
|
93 wxArrayString ccns;
|
|
94 ccns.Add(wxT("角館1")); ccns.Add(wxT("角館2")); ccns.Add(wxT("角館3")); ccns.Add(wxT("角館4"));
|
|
95 ccns.Add(wxT("西仙1")); ccns.Add(wxT("西仙2")); ccns.Add(wxT("西仙3"));
|
|
96 ccns.Add(wxT("千畑1")); ccns.Add(wxT("千畑2")); ccns.Add(wxT("千畑3"));
|
|
97 ccns.Add(wxT("大曲1")); ccns.Add(wxT("大曲2")); ccns.Add(wxT("大曲3")); ccns.Add(wxT("大曲4")); ccns.Add(wxT("大曲5")); ccns.Add(wxT("大曲6"));
|
|
98 ccns.Add(wxT("六郷1")); ccns.Add(wxT("六郷2")); ccns.Add(wxT("六郷3"));
|
|
99 m_comboBoxCcn = new wxComboBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(100,-1), ccns, 0 );
|
1
|
100 bSizerDist->Add( m_comboBoxCcn, 0, wxALL, 5 );
|
0
|
101
|
|
102 m_buttonMkDir = new wxButton( this, ID_BUTTONMKDIR, wxT("適用"), wxDefaultPosition, wxDefaultSize, 0 );
|
1
|
103 bSizerDist->Add( m_buttonMkDir, 0, wxALL, 5 );
|
0
|
104
|
|
105 bSizerTop->Add( bSizerDist, 0, wxEXPAND, 5 );
|
|
106
|
|
107 wxBoxSizer* bSizerManip = new wxBoxSizer( wxHORIZONTAL );
|
|
108
|
|
109 wxBoxSizer* bSizerGuess = new wxBoxSizer( wxVERTICAL );
|
|
110
|
|
111 m_staticTextName = new wxStaticText( this, wxID_ANY, wxT("氏名"), wxDefaultPosition, wxDefaultSize, 0 );
|
1
|
112 bSizerGuess->Add( m_staticTextName, 0, wxTOP|wxLEFT, 5 );
|
4
|
113 wxString logo = wxGetCwd() + wxFILE_SEP_PATH + wxT("image") + wxFILE_SEP_PATH + wxT("logo.png");
|
|
114 wxBitmap bmp = wxBitmap( logo, wxBITMAP_TYPE_PNG );
|
|
115 m_bitmapName = new wxStaticBitmap( this, wxID_ANY, bmp, wxDefaultPosition, wxSize(320,95), 0 );
|
0
|
116 bSizerGuess->Add( m_bitmapName, 0, wxALL, 5 );
|
|
117
|
|
118 m_staticTextHhsno = new wxStaticText( this, wxID_ANY, wxT("被保険者番号"), wxDefaultPosition, wxDefaultSize, 0 );
|
1
|
119 bSizerGuess->Add( m_staticTextHhsno, 0, wxTOP|wxLEFT, 5 );
|
4
|
120 logo = wxGetCwd() + wxFILE_SEP_PATH + wxT("image") + wxFILE_SEP_PATH + wxT("0123456789.png");
|
|
121 bmp.LoadFile( logo, wxBITMAP_TYPE_PNG );
|
|
122 m_bitmapHhsno = new wxStaticBitmap( this, wxID_ANY, bmp, wxDefaultPosition, wxSize(320,54), 0 );
|
|
123 bSizerGuess->Add( m_bitmapHhsno, 0, wxALL, 5 );
|
0
|
124
|
|
125 m_staticTextGuess = new wxStaticText( this, wxID_ANY, wxT("推定値"), wxDefaultPosition, wxDefaultSize, 0 );
|
1
|
126 bSizerGuess->Add( m_staticTextGuess, 0, wxTOP|wxLEFT, 5 );
|
0
|
127 m_textCtrlGuess = new wxTextCtrl( this, ID_TEXTCTRLGUESS, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
|
|
128 m_textCtrlGuess->SetMaxLength( 10 );
|
|
129 bSizerGuess->Add( m_textCtrlGuess, 0, wxALL, 5 );
|
|
130
|
|
131 bSizerManip->Add( bSizerGuess, 0, wxEXPAND, 5 );
|
|
132
|
|
133 m_listCtrlView = new wxListCtrl( this, ID_LISTCTRLVIEW, wxDefaultPosition, wxDefaultSize, wxLC_ICON );
|
1
|
134 m_listCtrlView->SetBackgroundColour(wxT("LIGHT GREY"));
|
0
|
135 bSizerManip->Add( m_listCtrlView, 1, wxALL|wxEXPAND, 5 );
|
5
|
136 m_imageList = new wxImageList( 160, 226 );
|
0
|
137 m_listCtrlView->AssignImageList( m_imageList, wxIMAGE_LIST_NORMAL );
|
6
|
138 //m_listCtrlView->SetDropTarget( new DnDFile(m_dirPickerWork) );
|
|
139 this->SetDropTarget( new DnDFile(m_dirPickerWork) );
|
0
|
140
|
|
141 wxBoxSizer* bSizerButton = new wxBoxSizer( wxVERTICAL );
|
|
142
|
1
|
143 m_buttonDetect = new wxButton( this, ID_BUTTONDETECT, wxT("検知"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
144 bSizerButton->Add( m_buttonDetect, 0, wxALL, 5 );
|
0
|
145 m_buttonMove = new wxButton( this, ID_BUTTONMOVE, wxT("移動"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
146 bSizerButton->Add( m_buttonMove, 0, wxALL, 5 );
|
4
|
147 m_buttonMove->Enable(false);
|
5
|
148
|
0
|
149 m_buttonDel = new wxButton( this, ID_BUTTONDEL, wxT("削除"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
150 bSizerButton->Add( m_buttonDel, 0, wxALL, 5 );
|
|
151 m_buttonUndo = new wxButton( this, ID_BUTTONUNDO, wxT("戻す"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
152 bSizerButton->Add( m_buttonUndo, 0, wxALL, 5 );
|
4
|
153 m_buttonUndo->Enable(false);
|
0
|
154
|
|
155 bSizerManip->Add( bSizerButton, 0, wxALIGN_CENTER_VERTICAL, 5 );
|
|
156
|
|
157 bSizerTop->Add( bSizerManip, 1, wxEXPAND, 5 );
|
|
158
|
|
159 this->SetSizer( bSizerTop );
|
|
160 this->Layout();
|
|
161
|
|
162 // ステータスバー
|
3
|
163 int widths[] = { 150, 250, -1, 120 };
|
0
|
164 m_statusBar = this->CreateStatusBar( WXSIZEOF(widths), wxST_SIZEGRIP );
|
|
165 m_statusBar->SetStatusWidths( WXSIZEOF(widths), widths );
|
|
166 m_statusBar->SetStatusText( wxEmptyString, 0 );
|
|
167
|
|
168 this->Centre( wxBOTH );
|
|
169 }
|
|
170
|
|
171 // destructor
|
|
172 MyFrame::~MyFrame()
|
|
173 {
|
|
174 }
|
|
175
|
|
176 // Event Table
|
|
177 BEGIN_EVENT_TABLE( MyFrame, wxFrame )
|
1
|
178 EVT_SIZE( MyFrame::OnWinSize )
|
|
179 EVT_MOVE( MyFrame::OnWinMove )
|
8
|
180 EVT_MENU( ID_MENUITEMPARAM, MyFrame::OnParam )
|
|
181 EVT_MENU( ID_MENUITEMAPPDIR, MyFrame::OnOpenAppDir )
|
|
182 EVT_MENU( wxID_EXIT, MyFrame::OnQuit )
|
|
183 EVT_BUTTON( ID_BUTTONNEXTTHU, MyFrame::OnNextThursday )
|
|
184 EVT_BUTTON( ID_BUTTONMKDIR, MyFrame::OnMakeDir )
|
|
185 EVT_BUTTON( ID_BUTTONDETECT, MyFrame::OnDetect )
|
|
186 EVT_BUTTON( ID_BUTTONMOVE, MyFrame::OnMove )
|
|
187 EVT_BUTTON( ID_BUTTONDEL, MyFrame::OnDelete )
|
|
188 EVT_BUTTON( ID_BUTTONUNDO, MyFrame::OnUndo )
|
3
|
189 EVT_LIST_ITEM_SELECTED( ID_LISTCTRLVIEW, MyFrame::GetImageInfo )
|
|
190 EVT_LIST_ITEM_ACTIVATED( ID_LISTCTRLVIEW, MyFrame::ViewLarge )
|
0
|
191 EVT_CLOSE( MyFrame::SaveConfig )
|
|
192 END_EVENT_TABLE()
|
|
193
|
|
194 // Event Handlers
|
8
|
195 /* 次の木曜日 */
|
|
196 void MyFrame::OnNextThursday(wxCommandEvent& WXUNUSED(event))
|
|
197 {
|
|
198 wxDateTime dt = m_datePicker->GetValue();
|
|
199 wxDateSpan ds( 0, 0, 0, 1 );
|
|
200 dt += ds;
|
|
201 dt.SetToNextWeekDay( wxDateTime::Thu );
|
|
202 m_datePicker->SetValue( dt );
|
|
203 }
|
|
204
|
0
|
205 /* 移動先フォルダ作成 */
|
3
|
206 void MyFrame::OnMakeDir(wxCommandEvent& WXUNUSED(event))
|
0
|
207 {
|
1
|
208 wxString to;
|
|
209 to.Append( m_comboBoxDrive->GetValue() );
|
|
210 to.Append( wxFILE_SEP_PATH );
|
|
211 wxDateTime dt = m_datePicker->GetValue();
|
|
212 to.Append( dt.Format(wxT("%Y%m%d")) );
|
|
213 to.Append( wxFILE_SEP_PATH );
|
|
214 to.Append( m_comboBoxCcn->GetValue() );
|
|
215 m_textCtrlDist->SetValue( to );
|
|
216
|
0
|
217 wxString ccn = m_comboBoxCcn->GetValue();
|
1
|
218 if ( to.Len() < 15 || ccn.IsEmpty() ) {
|
0
|
219 wxMessageBox(wxT("フォルダを指定してください."));
|
|
220 return;
|
|
221 }
|
|
222
|
1
|
223 wxStringTokenizer tkz( to, wxFILE_SEP_PATH );
|
0
|
224 wxString d;
|
|
225 while ( tkz.HasMoreTokens() ) {
|
|
226 d.Append( tkz.GetNextToken() );
|
|
227 d.Append( wxFILE_SEP_PATH );
|
|
228 if ( !wxDirExists( d ) ) wxMkdir( d );
|
|
229 }
|
4
|
230 m_buttonMove->Enable(true);
|
0
|
231
|
|
232 wxMessageBox(wxT("移動先フォルダ準備完了"));
|
1
|
233 wxString cmd = wxT("explorer ") + to;
|
0
|
234 wxExecute( cmd );
|
|
235 }
|
1
|
236 /* 検知 */
|
|
237 void MyFrame::OnDetect(wxCommandEvent& WXUNUSED(event))
|
|
238 {
|
|
239 ReadyImage();
|
|
240 }
|
5
|
241
|
4
|
242 /* 選択したファイルを移動 */
|
5
|
243 void MyFrame::OnMove(wxCommandEvent& WXUNUSED(event))
|
4
|
244 {
|
|
245 m_undo.Clear();
|
|
246 wxString workdir = m_dirPickerWork->GetPath();
|
|
247 wxString distdir = m_textCtrlDist->GetValue();
|
|
248 long item = -1;
|
|
249 for ( ;; ) {
|
|
250 item = m_listCtrlView->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
|
|
251 if ( item == -1 ) break;
|
5
|
252 wxString hhsno = m_textCtrlGuess->GetValue();
|
|
253 if ( !wxDirExists( distdir + wxFILE_SEP_PATH + hhsno ) ) wxMkdir( distdir + wxFILE_SEP_PATH + hhsno );
|
|
254
|
|
255 wxString file = m_listCtrlView->GetItemText( item );
|
4
|
256 wxString from = workdir + wxFILE_SEP_PATH + file;
|
5
|
257 wxString to = distdir + wxFILE_SEP_PATH + hhsno + wxFILE_SEP_PATH + file;
|
4
|
258 wxRenameFile( from, to, true );
|
5
|
259 m_undo.Insert( wxT("move ") + to + wxT(" ") + from, 0 );
|
4
|
260 }
|
|
261 ReadyImage();
|
|
262 m_buttonUndo->Enable(true);
|
|
263 }
|
|
264 /* 選択したファイルを削除 */
|
|
265 void MyFrame::OnDelete(wxCommandEvent& WXUNUSED(event))
|
|
266 {
|
|
267 m_undo.Clear();
|
|
268 wxString workdir = m_dirPickerWork->GetPath();
|
|
269 wxString trash = wxGetCwd() + wxFILE_SEP_PATH + wxT("trash");
|
|
270 long item = -1;
|
|
271 for ( ;; ) {
|
|
272 item = m_listCtrlView->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
|
|
273 if ( item == -1 ) break;
|
|
274 wxString file = m_listCtrlView->GetItemText( item );
|
|
275 wxString from = workdir + wxFILE_SEP_PATH + file;
|
|
276 wxString to = trash + wxFILE_SEP_PATH + file;
|
|
277 wxRenameFile( from, to, true );
|
5
|
278 m_undo.Insert( wxT("move ") + to + wxT(" ") + from, 0 );
|
4
|
279 }
|
|
280 ReadyImage();
|
|
281 m_buttonUndo->Enable(true);
|
|
282 }
|
|
283 /* アンドゥ */
|
|
284 void MyFrame::OnUndo(wxCommandEvent& WXUNUSED(event))
|
|
285 {
|
|
286 for ( int i=0; i<m_undo.GetCount(); i++ ) {
|
|
287 wxExecute( m_undo[i] );
|
|
288 }
|
|
289 wxMessageBox(wxT("戻し完了."));
|
|
290 m_buttonUndo->Enable(false);
|
|
291 m_undo.Clear();
|
|
292 ReadyImage();
|
|
293 }
|
0
|
294
|
|
295 /* 画像をリストコントロールに表示 */
|
|
296 void MyFrame::ReadyImage()
|
|
297 {
|
|
298 wxString workdir = m_dirPickerWork->GetPath();
|
|
299 wxDir dir( workdir );
|
|
300 if ( !dir.IsOpened() ) return;
|
4
|
301 wxString notfound = wxGetCwd() + wxFILE_SEP_PATH + wxT("image") + wxFILE_SEP_PATH + wxT("notfound.png");
|
|
302 wxBitmap bmp = wxBitmap( notfound, wxBITMAP_TYPE_PNG );
|
|
303 m_bitmapName->SetBitmap( bmp );
|
|
304 notfound = wxGetCwd() + wxFILE_SEP_PATH + wxT("image") + wxFILE_SEP_PATH + wxT("0000000000.png");
|
|
305 bmp.LoadFile( notfound, wxBITMAP_TYPE_PNG );
|
|
306 m_bitmapHhsno->SetBitmap( bmp );
|
0
|
307
|
6
|
308 wxArrayString filenames;
|
|
309 unsigned int n = dir.GetAllFiles( workdir, &filenames, wxT("*.jpg"), wxDIR_FILES );
|
0
|
310
|
|
311 m_listCtrlView->DeleteAllItems();
|
|
312 m_imageList->RemoveAll();
|
|
313 wxListItem item;
|
1
|
314 wxString first;
|
4
|
315 wxProgressDialog pd( wxT("進行状況"), wxT("処理開始..."), 7, this, wxPD_APP_MODAL|wxPD_REMAINING_TIME|wxPD_AUTO_HIDE );
|
|
316 pd.SetSize( wxSize(320,140) );
|
1
|
317 float b; long l;
|
6
|
318 for ( int i=0; i<n; i++ ) {
|
|
319 wxFileName f( filenames[i] );
|
|
320 wxString filename = f.GetFullName();
|
0
|
321
|
3
|
322 m_listCtrlView->InsertItem( i, filename );
|
|
323 m_listCtrlView->SetItem( i, 0, filename, i );
|
0
|
324
|
6
|
325 wxImage image( filenames[i], wxBITMAP_TYPE_JPEG );
|
5
|
326 wxBitmap bmp( image.Scale( 160, 226, wxIMAGE_QUALITY_HIGH ) );
|
0
|
327 m_imageList->Add( bmp );
|
3
|
328
|
|
329 if ( i == 0 ) {
|
6
|
330 IsMarksheet( filenames[i], &b, &l );
|
|
331 first = filenames[i];
|
3
|
332 SetStatusText( wxString::Format(wxT("1st image : z = %f, l = %d"),b,l), 1 );
|
4
|
333
|
|
334 wxImage marksheet( first, wxBITMAP_TYPE_JPEG );
|
|
335 wxImage name_image;
|
|
336 name_image = marksheet.GetSubImage( wxRect( wxPoint(300,550), wxSize(640,190) ) );
|
|
337 wxBitmap name_bmp = ( name_image.Scale( 320, 95, wxIMAGE_QUALITY_HIGH ) );
|
|
338 m_bitmapName->SetBitmap( name_bmp );
|
|
339
|
|
340 wxImage hhsno_image;
|
|
341 hhsno_image = marksheet.GetSubImage( wxRect( wxPoint(1800,210), wxSize(594,100) ) );
|
|
342 wxBitmap hhsno_bmp = ( hhsno_image.Scale( 320, 54, wxIMAGE_QUALITY_HIGH ) );
|
|
343 m_bitmapHhsno->SetBitmap( hhsno_bmp );
|
|
344
|
|
345 wxString hhsno = GuessHhs( first );
|
|
346 m_textCtrlGuess->SetValue( hhsno );
|
3
|
347 }
|
|
348 else {
|
6
|
349 if ( IsMarksheet( filenames[i], &b, &l ) ) {
|
3
|
350 break;
|
|
351 }
|
|
352 }
|
|
353 m_listCtrlView->SetItemState( i, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
|
|
354
|
0
|
355 // write log
|
6
|
356 pd.Update( i+1, wxT("画像認識中") );
|
0
|
357 }
|
1
|
358
|
4
|
359 SetStatusText( wxEmptyString, 2 );
|
0
|
360 }
|
|
361
|
1
|
362 /* 画像を選択 */
|
3
|
363 void MyFrame::GetImageInfo(wxListEvent& event)
|
1
|
364 {
|
3
|
365 SetStatusText( wxEmptyString, 2 );
|
2
|
366 int i = event.GetIndex();
|
|
367
|
3
|
368 wxString filename = event.GetText();
|
|
369 wxString workdir = m_dirPickerWork->GetPath();
|
|
370 wxString imagefile = workdir + wxFILE_SEP_PATH + filename;
|
|
371 float b; long l;
|
|
372 wxString msg;
|
|
373 if ( IsMarksheet( imagefile, &b, &l ) ) {
|
4
|
374 msg = wxT("perhaps marksheet !");
|
2
|
375 }
|
3
|
376 SetStatusText( wxString::Format(wxT("selected image : z = %f, l = %d ...")+msg, b, l ), 2 );
|
2
|
377 }
|
|
378
|
|
379 /* 画像のスクリーン表示*/
|
|
380 void MyFrame::ViewLarge(wxListEvent& event)
|
|
381 {
|
|
382 int i = event.GetIndex();
|
|
383 wxListItem item;
|
|
384 item.SetId(i);
|
|
385
|
|
386 wxString filename = event.GetText();
|
|
387 wxString workdir = m_dirPickerWork->GetPath();
|
|
388 wxString imagefile = workdir + wxFILE_SEP_PATH + filename;
|
|
389
|
|
390 wxImage image( imagefile, wxBITMAP_TYPE_JPEG );
|
|
391 wxBitmap bmp( image.Scale( 707, 1000, wxIMAGE_QUALITY_HIGH ) );
|
|
392 wxSplashScreen* splash = new wxSplashScreen( bmp,
|
|
393 wxSPLASH_CENTRE_ON_SCREEN|wxSPLASH_TIMEOUT,
|
|
394 3000, NULL, -1, wxDefaultPosition, wxDefaultSize,
|
|
395 wxSIMPLE_BORDER|wxSTAY_ON_TOP );
|
|
396 wxYield();
|
1
|
397 }
|
|
398
|
|
399 /* パラメータダイアログ */
|
|
400 void MyFrame::OnParam(wxCommandEvent& WXUNUSED(event))
|
|
401 {
|
5
|
402 ParamDialog* pd = new ParamDialog( NULL, wxID_ANY, wxT("Setting Parameters") );
|
|
403 if ( pd->ShowModal() == wxID_OK ) {
|
6
|
404 pd->NewParam( wxGetApp().lmin, wxGetApp().lmax, wxGetApp().zmin, wxGetApp().zmax );
|
5
|
405 }
|
|
406 pd->Destroy();
|
1
|
407 }
|
|
408
|
0
|
409 // 以下,定型もの
|
|
410 /* アプリフォルダを開く */
|
|
411 void MyFrame::OnOpenAppDir(wxCommandEvent& WXUNUSED(event))
|
|
412 {
|
5
|
413 wxString appdir = wxGetCwd();
|
0
|
414 wxString execmd = wxT("explorer ") + appdir;
|
|
415 wxExecute( execmd );
|
|
416 }
|
|
417
|
|
418 /* サイズ変更 */
|
1
|
419 void MyFrame::OnWinSize(wxSizeEvent& event)
|
0
|
420 {
|
|
421 this->Refresh( true, NULL );
|
|
422 TellLocation();
|
|
423 event.Skip();
|
|
424 }
|
|
425 /* ウィンドウ移動 */
|
1
|
426 void MyFrame::OnWinMove(wxMoveEvent& WXUNUSED(event))
|
0
|
427 {
|
|
428 TellLocation();
|
|
429 return;
|
|
430 }
|
|
431 /* ウィンドウ位置とサイズを表示 */
|
|
432 void MyFrame::TellLocation( void )
|
|
433 {
|
|
434 wxRect r = this->GetRect();
|
|
435 int x = r.GetX();
|
|
436 int y = r.GetY();
|
|
437 int w = r.GetWidth();
|
|
438 int h = r.GetHeight();
|
1
|
439 SetStatusText( wxString::Format(wxT("(%d,%d) %dx%d"),x,y,w,h), 3 );
|
0
|
440 }
|
|
441 /* 終了 */
|
|
442 void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
|
|
443 {
|
|
444 Close(true);
|
|
445 }
|
|
446 /* 設定を保存 */
|
|
447 void MyFrame::SaveConfig(wxCloseEvent& WXUNUSED(event))
|
|
448 {
|
|
449 if ( !IsIconized() && !IsMaximized() ) {
|
|
450 wxGetApp().rect = this->GetRect();
|
|
451 }
|
|
452 wxGetApp().workdir = m_dirPickerWork->GetPath();
|
|
453
|
|
454 Destroy();
|
|
455 }
|
|
456
|