Mercurial > mercurial > hgweb_searcher03.cgi
changeset 12:52958cd4a073
Implement Force Mask button in Batch Print Mode.
author | pyon@macmini |
---|---|
date | Sun, 18 May 2014 19:49:15 +0900 |
parents | dfcf8c973219 |
children | bbd65edf71d4 |
files | Changes Makefile doc/Searcher 03 の新機能.docx doc/Searcher 03 の新機能.pdf include/bprint.h include/common.h include/marksheet.h include/myframe.h include/preview.h src/bprint.cpp src/cache.cpp src/index.cpp src/marksheet.cpp src/myframe.cpp src/preview.cpp |
diffstat | 15 files changed, 186 insertions(+), 38 deletions(-) [+] |
line wrap: on
line diff
--- a/Changes Wed May 07 20:38:57 2014 +0900 +++ b/Changes Sun May 18 19:49:15 2014 +0900 @@ -1,3 +1,10 @@ +version 03.13 +2014-05-21 + Implement file infomation window in PreviewDialog. + Implement Print First File with Mask in Batch Print Mode. + Implement load batch-printed log. + +---- version 03.12 2014-05-13 Implement Cache maker. @@ -17,7 +24,7 @@ version 03.09 2013-11-01 Fixed bug. - Alert when not masked in batch print mode. + Alert when not masked in Batch Print Mode. ---- version 03.08
--- a/Makefile Wed May 07 20:38:57 2014 +0900 +++ b/Makefile Sun May 18 19:49:15 2014 +0900 @@ -1,5 +1,5 @@ # Makefile for wxWidgets Application -# Last Change: 30-Apr-2014. +# Last Change: 14-May-2014. # by Takayuki Mutoh # @@ -40,6 +40,7 @@ $(OBJDIR)/preview.o \ $(OBJDIR)/bprint.o \ $(OBJDIR)/db.o \ + $(OBJDIR)/hhsdb.o \ $(OBJDIR)/marksheet.o \ $(OBJDIR)/cache.o \ $(OBJDIR)/wxsqlite3.o @@ -91,12 +92,15 @@ $(OBJDIR)/thumbnail.o: thumbnail.cpp thumbnail.h common.h $(CXX) -c $< -o $@ $(CXXFLAGS) -$(OBJDIR)/preview.o: preview.cpp preview.h common.h +$(OBJDIR)/preview.o: preview.cpp preview.h marksheet.h common.h $(CXX) -c $< -o $@ $(CXXFLAGS) $(OBJDIR)/bprint.o: bprint.cpp bprint.h marksheet.h common.h dndfile.h $(CXX) -c $< -o $@ $(CXXFLAGS) +$(OBJDIR)/hhsdb.o: hhsdb.cpp hhsdb.h common.h db.h + $(CXX) -c $< -o $@ $(CXXFLAGS) + $(OBJDIR)/db.o: db.cpp db.h common.h $(CXX) -c $< -o $@ $(CXXFLAGS)
--- a/include/bprint.h Wed May 07 20:38:57 2014 +0900 +++ b/include/bprint.h Sun May 18 19:49:15 2014 +0900 @@ -1,5 +1,5 @@ // Filename : bprint.h -// Last Change: 18-Sep-2013. +// Last Change: 16-May-2014. // #ifndef __BPRINT_H__ #define __BPRINT_H__ @@ -23,6 +23,8 @@ wxGrid* m_grid; wxButton* m_buttonClear; wxButton* m_buttonPrint; + wxButton* m_buttonMaskPrint; + wxButton* m_buttonLdLog; wxButton* m_buttonClose; public: @@ -34,6 +36,8 @@ void OnInput( wxGridEvent& event ); void OnClear( wxCommandEvent& WXUNUSED(event) ); void OnPrint( wxCommandEvent& WXUNUSED(event) ); + void OnMaskPrint( wxCommandEvent& WXUNUSED(event) ); + void OnLoadLog( wxCommandEvent& WXUNUSED(event) ); void SetMark( long lmin, long lmax, double zmin, double zmax ) { m_lmin = lmin; m_lmax = lmax; m_zmin = zmin; m_zmax = zmax; } // Accessor @@ -49,6 +53,8 @@ { ID_BPCLEAR = wxID_HIGHEST + 50, ID_BPPRINT, + ID_BPFFMP, + ID_BPLDLOG, }; #endif //__BPRINT_H__
--- a/include/common.h Wed May 07 20:38:57 2014 +0900 +++ b/include/common.h Sun May 18 19:49:15 2014 +0900 @@ -1,5 +1,5 @@ // Filename : common.h -// Last Change: 30-Apr-2014. +// Last Change: 14-May-2014. // #ifndef __COMMON_H__ #define __COMMON_H__ @@ -37,11 +37,13 @@ #include <wx/textfile.h> #include <wx/tokenzr.h> #include <wx/msgdlg.h> +#include <wx/filedlg.h> #include <wx/progdlg.h> #include <wx/grid.h> #include <wx/regex.h> #include <wx/dir.h> #include <wx/print.h> +#include <wx/filepicker.h> #include <wx/html/htmprint.h> #include <wx/datectrl.h> #include <wx/xrc/xmlres.h>
--- a/include/marksheet.h Wed May 07 20:38:57 2014 +0900 +++ b/include/marksheet.h Sun May 18 19:49:15 2014 +0900 @@ -1,5 +1,5 @@ // Filename : marksheet.h -// Last Change: 11-Sep-2013. +// Last Change: 13-May-2014. // #ifndef __MARKSHEET_H__ #define __MARKSHEET_H__ @@ -9,6 +9,7 @@ bool IsBlack( int r, int g, int b ); wxString GuessHhs( wxString& file ); bool IsMarksheet( wxString& file, double zmin, double zmax, long lmin, long lmax ); +void GetScore( float* z, long* l, wxString file ); wxString GetHhsName( wxString& hhsno ); int IsHhsno( wxString& hhsno, wxString& name ); int GetMarksheetVersion( wxString file );
--- a/include/myframe.h Wed May 07 20:38:57 2014 +0900 +++ b/include/myframe.h Sun May 18 19:49:15 2014 +0900 @@ -1,5 +1,5 @@ // Filename : myframe.h -// Last Change: 30-Apr-2014. +// Last Change: 16-May-2014. // #ifndef __MYFRAME_H__ #define __MYFRAME_H__ @@ -29,6 +29,7 @@ class ThumbnailPanel : public wxPanel { private: + MyFrame* m_parent; wxArrayString m_imagefiles; wxArrayString m_cachefiles;
--- a/include/preview.h Wed May 07 20:38:57 2014 +0900 +++ b/include/preview.h Sun May 18 19:49:15 2014 +0900 @@ -1,5 +1,5 @@ // Filename : preview.h -// Last Change: 01-May-2014. +// Last Change: 16-May-2014. // #ifndef __PREVIEW_H__ @@ -51,6 +51,8 @@ wxScrolledWindow* m_scrolledWindow; wxStaticBitmap* m_bitmap; PThumbnailPanel* m_thumbPanel; + wxTextCtrl* m_textInfo; + wxButton* m_buttonMaskPrint; wxButton* m_buttonPrint; wxButton* m_buttonClose;
--- a/src/bprint.cpp Wed May 07 20:38:57 2014 +0900 +++ b/src/bprint.cpp Sun May 18 19:49:15 2014 +0900 @@ -1,5 +1,5 @@ // Filename : bprint.cpp -// Last Change: 01-Nov-2013. +// Last Change: 16-May-2014. // #include "bprint.h" @@ -55,8 +55,16 @@ m_buttonClear = new wxButton( this, ID_BPCLEAR, wxT("クリア"), wxDefaultPosition, wxDefaultSize, 0 ); bSizerButton->Add( m_buttonClear, 0, wxALL, 5 ); - m_buttonPrint = new wxButton( this, ID_BPPRINT, wxT("印刷"), wxDefaultPosition, wxDefaultSize, 0 ); + m_buttonMaskPrint = new wxButton( this, ID_BPFFMP, wxT("FFMP"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizerButton->Add( m_buttonMaskPrint, 0, wxALL, 5 ); + + m_buttonPrint = new wxButton( this, ID_BPPRINT, wxT("一括印刷"), wxDefaultPosition, wxDefaultSize, 0 ); bSizerButton->Add( m_buttonPrint, 0, wxALL, 5 ); + + m_buttonLdLog = new wxButton( this, ID_BPLDLOG, wxT("一括印刷ログ"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizerButton->Add( m_buttonLdLog, 0, wxALL, 5 ); + + bSizerButton->Add( 0, 20, 0, 0, 5 ); bSizerButton->Add( 0, 20, 0, 0, 5 ); @@ -83,7 +91,9 @@ BEGIN_EVENT_TABLE( FrameBatchPrint, wxDialog ) EVT_GRID_CELL_CHANGING( FrameBatchPrint::OnInput ) EVT_BUTTON( ID_BPCLEAR, FrameBatchPrint::OnClear ) + EVT_BUTTON( ID_BPFFMP, FrameBatchPrint::OnMaskPrint ) EVT_BUTTON( ID_BPPRINT, FrameBatchPrint::OnPrint ) + EVT_BUTTON( ID_BPLDLOG, FrameBatchPrint::OnLoadLog ) END_EVENT_TABLE() // Event Handlers & Functions @@ -132,7 +142,7 @@ if ( !dir.IsOpened() ) return; wxString html; - html = html + wxT("<html><body>\n"); + html = wxT("<html><body>\n"); wxString file; bool cout = dir.GetFirst( &file, wxT("*.jpg"), wxDIR_FILES ); @@ -188,6 +198,51 @@ WriteLog( log ); } +/* 一枚目強制マスク印刷 */ +void FrameBatchPrint::OnMaskPrint( wxCommandEvent& WXUNUSED(event) ) +{ + wxArrayInt rows = m_grid->GetSelectedRows(); + if ( rows.GetCount() != 1 ) { + wxMessageDialog md( this, wxT("1件のみ選択してください."), wxT("Message"), wxOK|wxICON_INFORMATION ); + md.ShowModal(); + return; + } + + wxString path = m_grid->GetCellValue( rows[0], 2 ); + wxDir dir( path ); + if ( !dir.IsOpened() ) return; + + wxPrintDialogData pd; + wxPrinter p( &pd ); + p.PrintDialog( NULL ); + + // 印刷用の html を作成 + wxString file; + if ( dir.GetFirst( &file, wxT("*.jpg"), wxDIR_FILES ) ) { + wxString tmpdir = wxGetCwd() + wxFILE_SEP_PATH + wxT("tmp") + wxFILE_SEP_PATH; + file = path + wxFILE_SEP_PATH + file; + file.Replace( wxFILE_SEP_PATH, wxT("/") ); + wxString tmpjpg = wxString::Format( wxT("%stmp.jpg"), tmpdir ); + + wxImage img_org( file, wxBITMAP_TYPE_JPEG ); + img_org.SetRGB( m_mask1, 255, 255, 255 ); // cm name + img_org.SetRGB( m_mask2, 255, 255, 255 ); // cm no. + img_org.SetRGB( m_mask3, 255, 255, 255 ); // barcode + img_org.SaveFile( tmpjpg ); + + wxString html; + html = wxT("<html><body>\n"); + html = html + wxT("<img src=\"") + tmpjpg + wxT("\" width=\"750\" height=\"1060\"/>"); + html = html + wxT("</body></html>"); + + // start printing + wxHtmlPrintout hpout( wxT("Searcher03") ); + hpout.SetMargins( 0, 0, 0, 0, 0 ); + hpout.SetHtmlText( html, wxEmptyString, false ); + p.Print( NULL, &hpout, false ); + } +} + /* 入力禁止 */ void FrameBatchPrint::SetGridReadOnly( void ) { @@ -196,7 +251,46 @@ m_grid->SetReadOnly( r, c, true ); } -/* 印刷ログ */ +/* 印刷ログ表示 */ +void FrameBatchPrint::OnLoadLog( wxCommandEvent& WXUNUSED(event) ) +{ + wxFileDialog fd( this, wxT("Choose a file"), wxT("log"), wxEmptyString, wxT("log files (*.log)|bp_*.log"), wxFD_OPEN|wxFD_FILE_MUST_EXIST ); + if ( fd.ShowModal() == wxID_CANCEL ) + return; + + m_grid->ClearGrid(); + + wxTextFile logfile; + logfile.Open( fd.GetPath() ); + + // + int d = logfile.GetLineCount() - m_grid->GetNumberRows(); + if ( d > 0 ) + m_grid->AppendRows( d, true ); + + wxArrayString hhsno; + wxString hhs, path, stat; + for ( int n = 0; n < logfile.GetLineCount(); n++ ) { + hhs = logfile[n].AfterLast( wxFILE_SEP_PATH ); + stat = hhs.AfterFirst( ' ' ); + hhs = hhs.BeforeFirst( ' ' ); + path = logfile[n]; + if ( !stat.IsEmpty() ) { + path = path.BeforeFirst( ' ' ); + } + m_grid->SetCellValue( n, 0, hhs ); + m_grid->SetCellValue( n, 2, path ); + m_grid->SetCellValue( n, 3, stat ); + hhsno.Add( hhs ); + } + for ( int n = 0; n < hhsno.GetCount(); n++ ) { + wxArrayString info = wxSplit( GetHhsInfoByHhsNo( hhsno[n] ), '_', '\\' ); + m_grid->SetCellValue( n, 1, info[0] ); + } + logfile.Close(); +} + +/* 印刷ログ出力 */ void FrameBatchPrint::WriteLog( wxArrayString logline ) { wxDateTime now = wxDateTime::Now();
--- a/src/cache.cpp Wed May 07 20:38:57 2014 +0900 +++ b/src/cache.cpp Sun May 18 19:49:15 2014 +0900 @@ -1,5 +1,5 @@ // Filename : cache.cpp -// Last Change: 07-May-2014. +// Last Change: 08-May-2014. // #include "cache.h" @@ -66,7 +66,7 @@ for ( int i = 0; i < path.GetCount(); i++ ) { wxArrayString files; - wxDir::GetAllFiles( path[i], &files, wxT("*.*"), wxDIR_DEFAULT ); + wxDir::GetAllFiles( path[i], &files, wxT("*.jpg"), wxDIR_DEFAULT ); for ( int j = 0; j < files.GetCount(); j++ ) { wxImage image( files[j], wxBITMAP_TYPE_JPEG );
--- a/src/index.cpp Wed May 07 20:38:57 2014 +0900 +++ b/src/index.cpp Sun May 18 19:49:15 2014 +0900 @@ -1,5 +1,5 @@ // Filename : index.cpp -// Last Change: 28-Apr-2014. +// Last Change: 12-May-2014. // #include "index.h" @@ -44,7 +44,7 @@ bSizerR->Add( 0, 300, 1, wxEXPAND, 5 ); - m_richText = new wxRichTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1, 100 ), wxVSCROLL|wxBORDER_NONE|wxWANTS_CHARS ); + m_richText = new wxRichTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1, 160 ), wxVSCROLL|wxBORDER_NONE|wxWANTS_CHARS ); bSizerR->Add( m_richText, 0, wxEXPAND|wxALL, 5 ); m_buttonClose = new wxButton( this, wxID_CANCEL, wxT("閉じる"), wxDefaultPosition, wxDefaultSize, 0 );
--- a/src/marksheet.cpp Wed May 07 20:38:57 2014 +0900 +++ b/src/marksheet.cpp Sun May 18 19:49:15 2014 +0900 @@ -1,5 +1,5 @@ // Filename : marksheet.cpp -// Last Change: 11-Sep-2013. +// Last Change: 13-May-2014. // #include "common.h" @@ -59,23 +59,10 @@ bool IsMarksheet( wxString& file, double zmin, double zmax, long lmin, long lmax ) { - wxImage img( file, wxBITMAP_TYPE_JPEG ); - int black = 0; - int x = 2465; - int h = 3500; - unsigned char r, g, b; + float z; + long l; - for ( int y=0; y<h; y++ ) { - r = img.GetRed( x, y ); - g = img.GetGreen( x, y ); - b = img.GetBlue( x, y ); - if( IsBlack( (int)r, (int)g, (int)b ) ) black++; - } - float z = (float)black / h; - - wxFile f( file ); - long l = f.Length(); - + GetScore( &z, &l, file ); //wxPuts(wxString::Format(wxT("z = %f, len = %d"),z,l)); if ( zmin < z && z < zmax && lmin < l && l < lmax ) { @@ -84,6 +71,25 @@ return false; } +void GetScore( float* z, long* l, wxString file ) +{ + wxImage img( file, wxBITMAP_TYPE_JPEG ); + int black = 0; + int x = 2465; + int h = 3500; + unsigned char r, g, b; + + for ( int y = 0; y < h; y++ ) { + r = img.GetRed( x, y ); + g = img.GetGreen( x, y ); + b = img.GetBlue( x, y ); + if( IsBlack( (int)r, (int)g, (int)b ) ) black++; + } + *z = (float)black / h; + + wxFile f( file ); + *l = f.Length(); +} wxString GetHhsName( wxString& hhsno ) {
--- a/src/myframe.cpp Wed May 07 20:38:57 2014 +0900 +++ b/src/myframe.cpp Sun May 18 19:49:15 2014 +0900 @@ -1,5 +1,5 @@ // Filename : myframe.cpp -// Last Change: 02-May-2014. +// Last Change: 16-May-2014. // #include "main.h" #include "db.h" @@ -100,6 +100,8 @@ ThumbnailPanel::ThumbnailPanel( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style ) : wxPanel( parent, id, pos, size, style ) { + m_parent = (MyFrame*)parent; + wxBoxSizer* bSizer = new wxBoxSizer( wxHORIZONTAL ); this->SetBackgroundColour( wxColour( 192, 192, 192 ) ); @@ -189,7 +191,7 @@ { if ( m_imagefiles.GetCount() < n + 1 ) return; - PreviewDialog* pd = new PreviewDialog( this, wxID_ANY, wxT("プレビュー"), wxDefaultPosition, wxDefaultSize, wxCAPTION|wxFRAME_NO_TASKBAR ); + PreviewDialog* pd = new PreviewDialog( m_parent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxCAPTION|wxFRAME_NO_TASKBAR ); pd->Show(); pd->Maximize( true ); pd->SetFiles( m_imagefiles, m_cachefiles ); @@ -232,6 +234,11 @@ m_menuFile->AppendSeparator(); // ---- + /* + wxMenuItem* m_menuItemHhsdb = new wxMenuItem( m_menuFile, ID_MNHHSDB, wxString( wxT("被保険者DB更新(&U)") ) , wxT("Update HHS databases"), wxITEM_NORMAL ); + m_menuFile->Append( m_menuItemHhsdb ); + */ + wxMenuItem* m_menuItemBkup = new wxMenuItem( m_menuFile, ID_MNDBBKUP, wxString( wxT("DBバックアップ(&B)") ) , wxT("Backup databases"), wxITEM_NORMAL ); m_menuFile->Append( m_menuItemBkup );
--- a/src/preview.cpp Wed May 07 20:38:57 2014 +0900 +++ b/src/preview.cpp Sun May 18 19:49:15 2014 +0900 @@ -1,7 +1,8 @@ // Filename : preview.cpp -// Last Change: 01-May-2014. +// Last Change: 16-May-2014. // +#include "marksheet.h" #include "preview.h" #define THUMB_W 60 #define THUMB_H 75 @@ -100,8 +101,13 @@ m_thumbPanel = new PThumbnailPanel( this, wxID_ANY, wxDefaultPosition, wxSize( 100, -1 ), wxSUNKEN_BORDER ); bSizerMenu->Add( m_thumbPanel, 0, wxALL|wxEXPAND, 5 ); + m_textInfo = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1, 80 ), wxTE_MULTILINE|wxTE_READONLY|wxTE_NO_VSCROLL ); + m_textInfo->SetBackgroundColour( wxColour( 192, 192, 192 ) ); + bSizerMenu->Add( m_textInfo, 0, wxRIGHT|wxLEFT|wxBOTTOM, 5 ); + m_buttonPrint = new wxButton( this, ID_PRINT, wxT("印刷"), wxDefaultPosition, wxDefaultSize, 0 ); bSizerMenu->Add( m_buttonPrint, 0, wxALL, 5 ); + bSizerMenu->Add( 0, 0, 0, 0, 5 ); m_buttonClose = new wxButton( this, wxID_CANCEL, wxT("閉じる"), wxDefaultPosition, wxDefaultSize, 0 ); @@ -120,7 +126,7 @@ // Event Table BEGIN_EVENT_TABLE( PreviewDialog, wxDialog ) - EVT_BUTTON( ID_PRINT, PreviewDialog::OnPrint ) + EVT_BUTTON( ID_PRINT, PreviewDialog::OnPrint ) END_EVENT_TABLE() #define WIDTH 2480 @@ -139,6 +145,15 @@ m_scrolledWindow->Scroll( 0, 0 ); m_scrolledWindow->SetScrollbars( 10, 10, 0, h/10 ); m_preview = m_imagefiles[n]; + + // + float z; + long l; + GetScore( &z, &l, m_imagefiles[n] ); + wxString info = m_imagefiles[n].AfterLast( wxFILE_SEP_PATH ); + info += wxString::Format( wxT("\n%z = %f"), z ); + info += wxString::Format( wxT("\n%l = %ld"), l ); + m_textInfo->SetValue( info ); } void PreviewDialog::SetFiles( wxArrayString imagefiles, wxArrayString cachefiles ) @@ -146,9 +161,12 @@ m_imagefiles = imagefiles; m_cachefiles = cachefiles; m_thumbPanel->SetFiles( m_imagefiles, m_cachefiles ); + + wxString title = wxT("プレビュー @ ") + m_imagefiles[0].BeforeLast( wxFILE_SEP_PATH ); + this->SetTitle( title ); } -void PreviewDialog::OnPrint( wxCommandEvent& WXUNUSED(envet) ) +void PreviewDialog::OnPrint( wxCommandEvent& WXUNUSED(event) ) { wxString html; html = html + wxT("<html><body>\n");