changeset 9:dfa5cae8c992

small fix
author pyon@macmini
date Thu, 20 Oct 2011 07:44:56 +0900
parents 550c143ab194
children 1fda3a06c39b
files include/dndfile.h include/myframe.h include/myutils.h include/utils.h makefile src/myframe.cpp
diffstat 6 files changed, 123 insertions(+), 120 deletions(-) [+]
line wrap: on
line diff
--- a/include/dndfile.h	Wed Oct 19 20:36:52 2011 +0900
+++ b/include/dndfile.h	Thu Oct 20 07:44:56 2011 +0900
@@ -1,5 +1,5 @@
 // Filename   : param.cpp
-// Last Change: 18-Oct-2011.
+// Last Change: 19-Oct-2011.
 //
 
 class DnDFile : public wxFileDropTarget
@@ -17,7 +17,6 @@
                 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;
         }
--- a/include/myframe.h	Wed Oct 19 20:36:52 2011 +0900
+++ b/include/myframe.h	Thu Oct 20 07:44:56 2011 +0900
@@ -1,5 +1,5 @@
 // Filename   : myframe.h
-// Last Change: 19-Oct-2011.
+// Last Change: 20-Oct-2011.
 //
 
 #ifndef __myframe__
@@ -61,6 +61,7 @@
         void OnDelete(wxCommandEvent& event);
         void OnUndo(wxCommandEvent& event);
         void ReadyImage(void);
+        void WatchDir(void);
         // $B0J2<!$Dj7?$b$N(B
         void OnWinSize(wxSizeEvent& event);
         void OnWinMove(wxMoveEvent& event);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/myutils.h	Thu Oct 20 07:44:56 2011 +0900
@@ -0,0 +1,108 @@
+// Filename   : myutils.h
+// Last Change: 20-Oct-2011.
+//
+#ifndef __myutils__
+#define __myutils__
+
+/********** Marksheet **********/
+bool IsBlack( int r, int g, int b ) 
+{
+    if ( r == 0 && g == 0 && b == 0 ) {
+        return true;
+    }
+    return false;
+};
+
+wxString GuessHhs( wxString& file ) 
+{
+    wxString hhs;
+    wxImage img( file, wxBITMAP_TYPE_JPEG );
+    int sx = 1800;  // start x
+    int sy = 315;;  // start y
+    int bw = 60;    // block width
+    int bh = 50;    // block height
+    int area = bw * bh;
+    int black = 0;
+    int x, y;
+    unsigned char r, g, b;
+
+    int max_n;
+    float max;
+    float bk;
+    for ( int c=0; c<10; c++ ) {
+        max = 0.0;
+        max_n = -1;
+        for ( int n=0; n<10; n++ ) {
+
+            for ( x=sx+bw*c; x<sx+bw*(c+1); x++ ) {
+                for ( y=sy+bh*n; y<sy+bh*(n+1); 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++;
+                }
+            }
+
+            bk = (float)black / area;
+            if ( max < bk ) {
+                max = bk;
+                max_n = n;
+            }
+            //wxPuts(wxString::Format(wxT("%d %f"),n,bk));
+            black = 0;
+        }
+        hhs.Append( wxString::Format( wxT("%d"), max_n ) );
+    }
+
+    return hhs;
+};
+
+bool IsMarksheet( wxString& file, float* brate, long* len )
+{
+    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++;
+    }
+    float z = (float)black / h;
+    float zmin = 0.095713;
+    float zmax = 0.108600;
+
+    wxFile f( file );
+    long l = f.Length();
+    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 ) {
+        return true;
+    }
+    return false;
+};
+
+/********** Cache **********/
+class Cache
+{
+public:
+    wxString filename;  // key
+    wxString fullpathname; 
+    wxString z, l;
+    bool     marksheet;
+};
+
+bool IsCached( wxString file )
+{
+    Cache* i = new Cache;
+};
+#endif // __myutils__
+
--- a/include/utils.h	Wed Oct 19 20:36:52 2011 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,109 +0,0 @@
-// Filename   : utils.h
-// Last Change: 19-Oct-2011.
-//
-#ifndef __utils__
-#define __utils__
-
-/********** Marksheet **********/
-bool IsBlack( int r, int g, int b ) 
-{
-    if ( r == 0 && g == 0 && b == 0 ) {
-        return true;
-    }
-    return false;
-};
-
-wxString GuessHhs( wxString& file ) 
-{
-    wxString hhs;
-    wxImage img( file, wxBITMAP_TYPE_JPEG );
-    int sx = 1800;  // start x
-    int sy = 315;;  // start y
-    int bw = 60;    // block width
-    int bh = 50;    // block height
-    int area = bw * bh;
-    int black = 0;
-    int x, y;
-    unsigned char r, g, b;
-
-    int max_n;
-    float max;
-    float bk;
-    for ( int c=0; c<10; c++ ) {
-        max = 0.0;
-        max_n = -1;
-        for ( int n=0; n<10; n++ ) {
-
-            for ( x=sx+bw*c; x<sx+bw*(c+1); x++ ) {
-                for ( y=sy+bh*n; y<sy+bh*(n+1); 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++;
-                }
-            }
-
-            bk = (float)black / area;
-            if ( max < bk ) {
-                max = bk;
-                max_n = n;
-            }
-            //wxPuts(wxString::Format(wxT("%d %f"),n,bk));
-            black = 0;
-        }
-        hhs.Append( wxString::Format( wxT("%d"), max_n ) );
-    }
-
-    return hhs;
-};
-
-bool IsMarksheet( wxString& file, float* brate, long* len )
-{
-    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++;
-    }
-    float z = (float)black / h;
-    float zmin = 0.095713;
-    float zmax = 0.108600;
-
-    wxFile f( file );
-    long l = f.Length();
-    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 ) {
-        return true;
-    }
-    return false;
-};
-
-/********** Cache **********/
-class Cache
-{
-public:
-    wxString filename;  // key
-    wxString z, b;
-    bool     marksheet;
-};
-
-WX_DECLARE_HASH_MAP( wxString, Cache*, wxStringHash, wxStringEqual, CacheHash )
-
-bool IsCached( wxString file )
-{
-    Cache i = new Cache;
-};
-#endif // __utils__
-
--- a/makefile	Wed Oct 19 20:36:52 2011 +0900
+++ b/makefile	Thu Oct 20 07:44:56 2011 +0900
@@ -1,6 +1,6 @@
 #
 # Makefile for wxWidgets Application
-#  Last Change: 19-Oct-2011.
+#  Last Change: 20-Oct-2011.
 #  by Takayuki Mutoh
 #
 
@@ -102,7 +102,7 @@
 	-mkdir -p $(OBJDIR)
 	$(CXX) -c $< -o $@ $(CPPFLAGS)
 
-$(OBJDIR)/myframe.o: myframe.cpp myframe.h common.h main.h marksheet.h dndfile.h
+$(OBJDIR)/myframe.o: myframe.cpp myframe.h common.h main.h myutils.h dndfile.h
 	$(CXX) -c $< -o $@ $(CPPFLAGS)
 
 $(OBJDIR)/param.o: param.cpp param.h common.h main.h
--- a/src/myframe.cpp	Wed Oct 19 20:36:52 2011 +0900
+++ b/src/myframe.cpp	Thu Oct 20 07:44:56 2011 +0900
@@ -1,12 +1,12 @@
 // Filename   : myframe.cpp
-// Last Change: 19-Oct-2011.
+// Last Change: 20-Oct-2011.
 //
 
 #include "main.h"
 #include "myframe.h"
 #include "param.h"
-#include "marksheet.h"
 #include "dndfile.h"
+#include "myutils.h"
 
 // resources
 // the application icon (under Windows and OS/2 it is in resources and even
@@ -15,6 +15,8 @@
     #include "sample.xpm"
 #endif
 
+WX_DECLARE_HASH_MAP( wxString, Cache*, wxStringHash, wxStringEqual, CacheHash );
+
 //////////////////////////////////////////////////////////////////////////
 // frame constructor
 MyFrame::MyFrame( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxFrame( parent, id, title, pos, size, style )
@@ -166,6 +168,8 @@
     m_statusBar->SetStatusText( wxEmptyString, 0 );
 	
 	this->Centre( wxBOTH );
+
+    CacheHash cache;
 }
 
 // destructor
@@ -314,7 +318,7 @@
     wxString first;
     wxProgressDialog pd( wxT("進行状況"), wxT("処理開始..."), 7, this, wxPD_APP_MODAL|wxPD_REMAINING_TIME|wxPD_AUTO_HIDE );
     pd.SetSize( wxSize(320,140) );
-    float b; long l;
+    float z; long l;
     for ( int i=0; i<n; i++ ) {
         wxFileName f( filenames[i] );
         wxString filename = f.GetFullName();
@@ -327,9 +331,9 @@
         m_imageList->Add( bmp );
 
         if ( i == 0 ) {
-            IsMarksheet( filenames[i], &b, &l );
+            IsMarksheet( filenames[i], &z, &l );
             first = filenames[i];
-            SetStatusText( wxString::Format(wxT("1st image : z = %f, l = %d"),b,l), 1 );
+            SetStatusText( wxString::Format(wxT("1st image : z = %f, l = %d"),z,l), 1 );
 
             wxImage marksheet( first, wxBITMAP_TYPE_JPEG );
             wxImage name_image;
@@ -346,7 +350,7 @@
             m_textCtrlGuess->SetValue( hhsno );
         }
         else {
-            if ( IsMarksheet( filenames[i], &b, &l ) ) {
+            if ( IsMarksheet( filenames[i], &z, &l ) ) {
                 break;
             }
         }