changeset 0:7bf900d47e9e

start mover2
author pyon@macmini
date Sat, 15 Oct 2011 13:24:27 +0900
parents
children b47bd4618c16
files .hgignore include/common.h include/main.h include/marksheet.h include/myframe.h include/param.h include/symbol.h makefile src/main.cpp src/myframe.cpp src/param.cpp src/testframe.cpp src/testtune.cpp
diffstat 13 files changed, 1130 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.hgignore	Sat Oct 15 13:24:27 2011 +0900
@@ -0,0 +1,10 @@
+syntax: glob
+obj/*.o
+img/*
+tmp/*
+db/*
+work/*
+*.app/*
+.DS_Store
+*.conf
+*~
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/common.h	Sat Oct 15 13:24:27 2011 +0900
@@ -0,0 +1,57 @@
+// Filename   : common.h
+// Last Change: 15-Oct-2011.
+//
+#ifndef __COMMON__
+#define __COMMON__
+
+#include "wx/wxprec.h"
+ 
+#ifndef WX_PRECOMP
+    #include "wx/wx.h"
+    #include <wx/icon.h>
+    #include <wx/dir.h>
+    #include <wx/menu.h>
+    #include <wx/string.h>
+    #include <wx/statusbr.h>
+    #include <wx/stattext.h>
+    #include <wx/button.h>
+    #include <wx/datectrl.h>
+    #include <wx/dateevt.h>
+    #include <wx/textctrl.h>
+    #include <wx/filepicker.h>
+    #include <wx/filename.h>
+    #include <wx/listctrl.h>
+    #include <wx/dir.h>
+    #include <wx/file.h>
+    #include <wx/tokenzr.h>
+    #include <wx/stdpaths.h>
+    #include <wx/sizer.h>
+    #include <wx/combobox.h>
+    #include <wx/progdlg.h>
+    #include <wx/frame.h>
+#endif
+
+enum {
+    // mainframe
+    ID_MAIN    = wxID_HIGHEST + 1,
+    ID_TEST,
+
+    ID_MENUBARFILE,
+    ID_MENUITEMPARAM,
+    ID_MENUITEMAPPDIR,
+    ID_MENUITEMQUIT,
+
+    ID_BUTTONMKDIR,
+    ID_TEXTCTRLDIST,
+    ID_TEXTCTRLGUESS,
+    ID_LISTCTRLVIEW,
+
+    ID_BUTTONMOVE,
+    ID_BUTTONDEL,
+    ID_BUTTONUNDO,
+
+    // param
+    ID_BUTTONSAVE,
+};
+#endif  // __COMMON__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/main.h	Sat Oct 15 13:24:27 2011 +0900
@@ -0,0 +1,33 @@
+// Filename   : main.h
+// Last Change: 15-Oct-2011.
+//
+#include "wx/wx.h"
+#include "wx/config.h"
+#include "wx/fileconf.h"
+
+#include "symbol.h"
+// private classes
+// Define a new application type, each program should derive a class from wxApp
+class MyApp : public wxApp
+{
+    DECLARE_CLASS( MyApp )
+public:
+    MyApp();
+    ~MyApp();
+
+    virtual bool OnInit();
+    virtual int  OnExit();
+    void ConfInit();
+
+    wxFileConfig *config;
+    wxString      conf_file;
+    wxRect        rect;
+    wxString      workdir;
+    wxString      lmin;
+    wxString      lmax;
+    wxString      bmin;
+    wxString      bmax;
+};
+
+DECLARE_APP(MyApp)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/marksheet.h	Sat Oct 15 13:24:27 2011 +0900
@@ -0,0 +1,97 @@
+// Filename   : marksheet.h
+// Last Change: 06-Oct-2011.
+//
+#ifndef __MARKSHEET__
+#define __MARKSHEET__
+
+
+#include "wx/utils.h"
+#include "wx/file.h"
+#include "wx/string.h"
+#include "wx/image.h"
+
+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 )
+{
+    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;
+
+    //wxPuts(wxString::Format(wxT("z = %f, len = %d"),z,len));
+    if ( zmin < z && z < zmax
+      && lmin < l && l < lmax ) {
+        return true;
+    }
+    return false;
+};
+
+#endif // __MARKSHEET__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/myframe.h	Sat Oct 15 13:24:27 2011 +0900
@@ -0,0 +1,64 @@
+// Filename   : myframe.h
+// Last Change: 15-Oct-2011.
+//
+
+#ifndef __myframe__
+#define __myframe__
+
+#include "common.h"
+
+class MyFrame : public wxFrame 
+{
+    DECLARE_EVENT_TABLE()
+    private:
+        wxImageList*      m_imageList;
+    
+    protected:
+        wxMenuBar*        m_menubarFile;
+        wxMenu*           m_menuFile;
+        wxStatusBar*      m_statusBar;
+
+        wxStaticText*     m_staticTextWork;
+        wxDirPickerCtrl*  m_dirPickerWork;
+        wxStaticText*     m_staticTextDrive;
+        wxComboBox*       m_comboBoxDrive;
+        wxStaticText*     m_staticTextDate;
+        wxDatePickerCtrl* m_datePicker;
+        wxStaticText*     m_staticTextCcn;
+        wxComboBox*       m_comboBoxCcn;
+        wxButton*         m_buttonMkDir;
+        wxStaticText*     m_staticTextDist;
+        wxTextCtrl*       m_textCtrlDist;
+        
+        wxStaticText*     m_staticTextName;
+        wxStaticBitmap*   m_bitmapName;
+        wxStaticText*     m_staticTextHhsno;
+        wxStaticBitmap*   m_bitmapHHsno;
+        wxStaticText*     m_staticTextGuess;
+        wxTextCtrl*       m_textCtrlGuess;
+
+        wxListCtrl*       m_listCtrlView;
+        wxButton*         m_buttonMove;
+        wxButton*         m_buttonDel;
+        wxButton*         m_buttonUndo;
+    
+    public:
+        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 MakeDir(wxCommandEvent& event);
+        void Do(wxCommandEvent& event);
+        void ReadyImage(void);
+        void MoveImage(void);
+        // $B0J2<!$Dj7?$b$N(B
+        void OnSize(wxSizeEvent& event);
+        void OnMove(wxMoveEvent& event);
+        void TellLocation( void );
+        void OnQuit(wxCommandEvent& event);
+        void OnOpenAppDir(wxCommandEvent& event);
+        void SaveConfig(wxCloseEvent& event);
+};
+
+#endif // __myframe__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/param.h	Sat Oct 15 13:24:27 2011 +0900
@@ -0,0 +1,40 @@
+// Filename   : param.h
+// Last Change: 15-Oct-2011.
+//
+
+#ifndef __param__
+#define __param__
+
+#include "common.h"
+///////////////////////////////////////////////////////////////////////////////
+/// Class MyFrame
+///////////////////////////////////////////////////////////////////////////////
+class ParamDialog : public wxDialog 
+{
+    DECLARE_EVENT_TABLE();
+	private:
+	
+	protected:
+		wxTextCtrl*   m_textCtrlLenMIn;
+		wxStaticText* m_staticTextLen;
+		wxTextCtrl*   m_textCtrlLenMax;
+
+		wxTextCtrl*   m_textCtrlBMin;
+		wxStaticText* m_staticTextBlack;
+		wxTextCtrl*   m_textCtrlBmax;
+
+		wxStaticText* m_staticTextlDummy;
+		wxButton*     m_buttonCancel;
+		wxButton*     m_buttonSave;
+	
+	public:
+		ParamDialog( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("パラメータ設定"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxCAPTION|wxDEFAULT_DIALOG_STYLE );
+		~ParamDialog();
+
+        void GetParam(void);
+        void SaveParam(wxCommandEvent& event);
+	
+};
+
+#endif //__param.h__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/symbol.h	Sat Oct 15 13:24:27 2011 +0900
@@ -0,0 +1,10 @@
+// Filename   : symbol.h
+// Last Change: 15-Oct-2011.
+//
+
+#define MYAPPNAME wxT("AMover2")
+
+#define VER 2
+#define REV 0
+#define BLD 20111017
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/makefile	Sat Oct 15 13:24:27 2011 +0900
@@ -0,0 +1,150 @@
+#
+# Makefile for wxWidgets Application
+#  Last Change: 15-Oct-2011.
+#  by Takayuki Mutoh
+#
+
+# Program Name
+PROGNAME = mover2
+### Variables: ###
+OBJDIR = ./obj
+CXX = g++
+vpath %.cpp ./src
+vpath %.h   ./include
+
+ifdef COMSPEC
+# for Microsoft Windows
+WXCPPFLAGS = -I/local/lib/wx/include/msw-unicode-release-static-2.8 \
+		   -I/local/include/wx-2.8 \
+		   -D__WXMSW__
+WXLIBS = -L/local/lib -Wl,--subsystem,windows -mwindows \
+	   -lwx_mswu_richtext-2.8 \
+	   -lwx_mswu_aui-2.8 \
+	   -lwx_mswu_xrc-2.8 \
+	   -lwx_mswu_qa-2.8 \
+	   -lwx_mswu_html-2.8 \
+	   -lwx_mswu_adv-2.8 \
+	   -lwx_mswu_core-2.8 \
+	   -lwx_baseu_xml-2.8 \
+	   -lwx_baseu_net-2.8 \
+	   -lwx_baseu-2.8 \
+	   -lwxregexu-2.8 \
+	   -lwxexpat-2.8 \
+	   -lwxtiff-2.8 \
+	   -lwxjpeg-2.8 \
+	   -lwxpng-2.8 \
+	   -lwxzlib-2.8 \
+	   -lrpcrt4 \
+	   -loleaut32 \
+	   -lole32 \
+	   -luuid \
+	   -lwinspool \
+	   -lwinmm \
+	   -lshell32 \
+	   -lcomctl32 \
+	   -lcomdlg32 \
+	   -lctl3d32 \
+	   -ladvapi32 \
+	   -lwsock32 \
+	   -lgdi32
+EXECUTABLE = $(PROGNAME).exe
+
+else
+# for Apple MacOSX
+# 2.8
+WXCPPFLAGS = -I/opt/local/lib/wx/include/mac-unicode-release-2.8 \
+		   -I/opt/local/include/wx-2.8 \
+		   -D_FILE_OFFSET_BITS=64 \
+		   -D_LARGE_FILES \
+		   -D__WXMAC__
+WXLIBS = -framework IOKit \
+	   -framework Carbon \
+       -framework Cocoa \
+       -framework System \
+       -framework QuickTime \
+       -framework OpenGL \
+       -framework AGL \
+       -lwx_macu-2.8 \
+       -L/opt/local/lib \
+       -arch i386
+
+EXECUTABLE = $(PROGNAME).app/Contents/PkgInfo
+
+endif
+
+OBJ = $(OBJDIR)/main.o \
+	  $(OBJDIR)/myframe.o \
+	  $(OBJDIR)/param.o
+ifdef COMSPEC
+OBJMSW = $(OBJ) $(OBJDIR)/sample_rc.o
+endif
+
+# user include
+CPPFLAGS = $(WXCPPFLAGS) -I./include -I./img
+# user lib
+LIBS = -static-libgcc -static-libstdc++ $(WXLIBS)
+
+
+### Targets: ###
+
+all: $(EXECUTABLE)
+
+ifdef COMSPEC
+$(PROGNAME): $(OBJMSW)
+	$(CXX) $^ -o $@ $(LIBS)
+else
+$(PROGNAME): $(OBJ)
+	$(CXX) $^ -o $@ $(LIBS)
+endif
+
+
+$(OBJDIR)/main.o: main.cpp main.h myframe.h common.h testframe.cpp symbol.h
+	-mkdir -p $(OBJDIR)
+	$(CXX) -c $< -o $@ $(CPPFLAGS)
+
+$(OBJDIR)/myframe.o: myframe.cpp myframe.h common.h main.h
+	$(CXX) -c $< -o $@ $(CPPFLAGS)
+
+$(OBJDIR)/param.o: param.cpp param.h common.h main.h
+	$(CXX) -c $< -o $@ $(CPPFLAGS)
+
+testtune: testtune.cpp
+	$(CXX) $< -o $@ $(CPPFLAGS) $(LIBS)
+
+
+# for icon
+ifdef COMSPEC
+$(OBJDIR)/sample_rc.o: sample.rc
+	windres -i sample.rc -o $@ -I/local/include/wx-2.8
+endif
+
+
+$(EXECUTABLE): $(PROGNAME)
+ifdef COMSPEC
+	strip --strip-all $(EXECUTABLE)
+else
+	-mkdir -p $(PROGNAME).app/Contents
+	-mkdir -p $(PROGNAME).app/Contents/MacOS
+	-mkdir -p $(PROGNAME).app/Contents/Resources
+	
+	sed -e "s/IDENTIFIER/$(PROGNAME)/" \
+	-e "s/EXECUTABLE/$(PROGNAME)/" \
+	-e "s/VERSION/0.0/" \
+	Info.plist.in > $(PROGNAME).app/Contents/Info.plist
+	
+	echo -n "APPL????" > $(EXECUTABLE)
+	
+	ln -f $(PROGNAME) $(PROGNAME).app/Contents/MacOS/$(PROGNAME)
+	cp -f wxmac.icns $(PROGNAME).app/Contents/Resources/wxmac.icns
+
+	open $(PROGNAME).app
+endif
+
+
+clean:
+	rm -f $(PROGNAME) $(PROGNAME).exe
+	rm -f $(OBJDIR)/*.o
+	rm -rf $(PROGNAME).app
+
+.PHONY:	all clean
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main.cpp	Sat Oct 15 13:24:27 2011 +0900
@@ -0,0 +1,87 @@
+// Filename   : main.cpp
+// Last Change: 15-Oct-2011.
+//
+
+#include "common.h"
+#include "main.h"
+#include "myframe.h"
+//#include "testframe.cpp"
+
+IMPLEMENT_APP(MyApp)
+
+IMPLEMENT_CLASS( MyApp, wxApp )
+
+MyApp::MyApp()
+{
+}
+MyApp::~MyApp()
+{
+}
+
+bool MyApp::OnInit()
+{
+    if ( !wxApp::OnInit() ) return false;
+
+    wxImage::AddHandler( new wxJPEGHandler );
+
+    ConfInit();
+
+    wxString progname = wxT("A Mover");
+    wxString verstr = wxString::Format( wxT(" - v%d.%d ( build %d )"), VER, REV, BLD );
+    wxString title = progname + verstr;
+
+    MyFrame *mainframe = new MyFrame( NULL, ID_MAIN, title );
+    mainframe->SetSize( rect );
+    mainframe->SetMinSize( wxSize( 580, 680 ) );
+    mainframe->Show(true);
+    /*
+    TestFrame *tf = new TestFrame( NULL, ID_TEST, wxT("A Test") );
+    tf->Show(true);
+    */
+
+    return true;
+}
+
+int MyApp::OnExit()
+{
+    config->SetPath( wxT("/Geometry") );
+    config->Write( wxT("x"), rect.x );
+    config->Write( wxT("y"), rect.y );
+    config->Write( wxT("w"), rect.width );
+    config->Write( wxT("h"), rect.height );
+
+    config->SetPath( wxT("/WorkDir") );
+    config->Write( wxT("workdir"), workdir );
+
+    config->SetPath( wxT("/Param") );
+    config->Write( wxT("lmin"), lmin );
+    config->Write( wxT("lmax"), lmax );
+    config->Write( wxT("bmin"), bmin );
+    config->Write( wxT("bmax"), bmax );
+
+    delete config;
+
+    return 0;
+}
+
+void MyApp::ConfInit()
+{
+    conf_file = wxGetCwd() + wxFILE_SEP_PATH + MYAPPNAME + wxT(".conf");
+    config = new wxFileConfig( wxT("MyApp"), wxT("T.Mutoh"), conf_file, wxEmptyString, wxCONFIG_USE_LOCAL_FILE );
+
+    config->SetPath( wxT("/Geometry") );
+    config->Read( wxT("x"), &rect.x );
+    config->Read( wxT("y"), &rect.y );
+    config->Read( wxT("w"), &rect.width );
+    config->Read( wxT("h"), &rect.height );
+
+    config->SetPath( wxT("/WorkDir") );
+    config->Read( wxT("workdir"), &workdir );
+
+    config->SetPath( wxT("/Param") );
+    config->Read( wxT("lmin"), lmin );
+    config->Read( wxT("lmax"), lmax );
+    config->Read( wxT("bmin"), bmin );
+    config->Read( wxT("bmax"), bmax );
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/myframe.cpp	Sat Oct 15 13:24:27 2011 +0900
@@ -0,0 +1,330 @@
+// Filename   : myframe.cpp
+// Last Change: 15-Oct-2011.
+//
+
+#include "main.h"
+#include "myframe.h"
+
+//////////////////////////////////////////////////////////////////////////
+// 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 )
+{
+    this->SetBackgroundColour( wxColour(wxT("WHEAT")) );
+    // set the frame icon
+    //SetIcon(wxICON(sample));
+	
+    // メニューバー
+	m_menubarFile = new wxMenuBar();
+	m_menuFile = new wxMenu();
+	wxMenuItem* m_menuItemParam;
+	m_menuItemParam = new wxMenuItem( m_menuFile, ID_MENUITEMPARAM, wxString( wxT("パラメータ(&P)") ) , wxEmptyString, wxITEM_NORMAL );
+	m_menuFile->Append( m_menuItemParam );
+	
+	wxMenuItem* m_menuItemAppDIr;
+	m_menuItemAppDIr = new wxMenuItem( m_menuFile, ID_MENUITEMAPPDIR, wxString( wxT("アプリフォルダを開く(&O)") ) , wxEmptyString, wxITEM_NORMAL );
+	m_menuFile->Append( m_menuItemAppDIr );
+	
+	wxMenuItem* m_separator;
+	m_separator = m_menuFile->AppendSeparator();    // ----
+	
+	wxMenuItem* m_menuItemQuit;
+	m_menuItemQuit = new wxMenuItem( m_menuFile, ID_MENUITEMQUIT, wxString( wxT("終了(&X)") ) , wxEmptyString, wxITEM_NORMAL );
+	m_menuFile->Append( m_menuItemQuit );
+	
+	m_menubarFile->Append( m_menuFile, wxT("ファイル(&F)") ); 
+	
+	this->SetMenuBar( m_menubarFile );
+	
+    // コントロール	
+	wxBoxSizer* bSizerTop = new wxBoxSizer( wxVERTICAL );
+	
+	wxBoxSizer* bSizerFrom = new wxBoxSizer( wxHORIZONTAL );
+	
+	m_staticTextWork = new wxStaticText( this, wxID_ANY, wxT("作業フォルダ"), wxDefaultPosition, wxDefaultSize, 0 );
+	bSizerFrom->Add( m_staticTextWork, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
+	
+	m_dirPickerWork = new wxDirPickerCtrl( this, wxID_ANY, wxGetApp().workdir, wxT("Select a folder"), wxDefaultPosition, wxDefaultSize, wxDIRP_DEFAULT_STYLE );
+	bSizerFrom->Add( m_dirPickerWork, 1, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
+	
+	bSizerTop->Add( bSizerFrom, 0, wxEXPAND, 5 );
+	
+	wxBoxSizer* bSizerCcn = new wxBoxSizer( wxHORIZONTAL );
+	
+	m_staticTextDrive = new wxStaticText( this, wxID_ANY, wxT("ドライブ"), wxDefaultPosition, wxDefaultSize, 0 );
+	bSizerCcn->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 );
+	
+	m_staticTextDate = new wxStaticText( this, wxID_ANY, wxT("開催日"), wxDefaultPosition, wxDefaultSize, 0 );
+	bSizerCcn->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 );
+	
+	m_staticTextCcn = new wxStaticText( this, wxID_ANY, wxT("合議体"), wxDefaultPosition, wxDefaultSize, 0 );
+	bSizerCcn->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"));
+	ccns.Add(wxT("西仙1")); ccns.Add(wxT("西仙2")); ccns.Add(wxT("西仙3"));
+	ccns.Add(wxT("千畑1")); ccns.Add(wxT("千畑2")); ccns.Add(wxT("千畑3"));
+	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 );
+	
+	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 );
+	
+	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 );
+	
+	wxBoxSizer* bSizerManip = new wxBoxSizer( wxHORIZONTAL );
+	
+	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_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_bitmapHHsno, 0, wxALL, 5 );
+	
+	m_staticTextGuess = new wxStaticText( this, wxID_ANY, wxT("推定値"), wxDefaultPosition, wxDefaultSize, 0 );
+	bSizerGuess->Add( m_staticTextGuess, 0, wxALL, 5 );
+	m_textCtrlGuess = new wxTextCtrl( this, ID_TEXTCTRLGUESS, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
+	m_textCtrlGuess->SetMaxLength( 10 ); 
+	bSizerGuess->Add( m_textCtrlGuess, 0, wxALL, 5 );
+	
+	bSizerManip->Add( bSizerGuess, 0, wxEXPAND, 5 );
+	
+	m_listCtrlView = new wxListCtrl( this, ID_LISTCTRLVIEW, wxDefaultPosition, wxDefaultSize, wxLC_ICON );
+	bSizerManip->Add( m_listCtrlView, 1, wxALL|wxEXPAND, 5 );
+    m_imageList = new wxImageList( 63, 89 );
+    m_listCtrlView->AssignImageList( m_imageList, wxIMAGE_LIST_NORMAL );
+	
+	wxBoxSizer* bSizerButton = new wxBoxSizer( wxVERTICAL );
+	
+	m_buttonMove = new wxButton( this, ID_BUTTONMOVE, wxT("移動"), wxDefaultPosition, wxDefaultSize, 0 );
+	bSizerButton->Add( m_buttonMove, 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 );
+	bSizerButton->Add( m_buttonUndo, 0, wxALL, 5 );
+	
+	bSizerManip->Add( bSizerButton, 0, wxALIGN_CENTER_VERTICAL, 5 );
+	
+	bSizerTop->Add( bSizerManip, 1, wxEXPAND, 5 );
+	
+	this->SetSizer( bSizerTop );
+	this->Layout();
+
+    // ステータスバー
+    int widths[] = { -1, 150, 120, 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
+MyFrame::~MyFrame()
+{
+}
+
+// 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_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 ccn = m_comboBoxCcn->GetValue();
+    if ( distdir.Len() < 15 || ccn.IsEmpty() ) {
+        wxMessageBox(wxT("フォルダを指定してください."));
+        return;
+    }
+
+    wxStringTokenizer tkz( distdir, wxFILE_SEP_PATH );
+    wxString d;
+    while ( tkz.HasMoreTokens() ) {
+        d.Append( tkz.GetNextToken() );
+        d.Append( wxFILE_SEP_PATH );
+        if ( !wxDirExists( d ) ) wxMkdir( d );
+    }
+
+    wxMessageBox(wxT("移動先フォルダ準備完了"));
+    wxString cmd = wxT("explorer ") + distdir;
+    wxExecute( cmd );
+}
+
+void MyFrame::Do(wxCommandEvent& WXUNUSED(event))
+{
+    MoveImage();
+    ReadyImage();
+}
+
+/* 画像をリストコントロールに表示 */
+void MyFrame::ReadyImage()
+{
+    wxString workdir = m_dirPickerWork->GetPath();
+    wxDir dir( workdir );
+    if ( !dir.IsOpened() ) return;
+
+    wxString filename;
+    bool cout = dir.GetFirst( &filename, wxT("*.jpg"), wxDIR_FILES );
+
+    int i = 0;
+    m_listCtrlView->DeleteAllItems();
+    m_imageList->RemoveAll();
+    wxListItem item;
+    while ( cout ) {
+        if ( i > 7 ) break;
+
+        wxString imagefile = workdir + wxFILE_SEP_PATH + filename;
+        if ( i > 1 && IsMarksheet() ) cout = false;
+
+        item.SetId(i);
+        item.SetMask(wxLIST_MASK_STATE|wxLIST_MASK_TEXT|wxLIST_MASK_IMAGE);
+        item.SetStateMask(wxLIST_STATE_SELECTED);
+        item.SetState(wxLIST_STATE_SELECTED);
+        item.SetImage(i);
+        item.SetText(filename);
+        m_listCtrlView->InsertItem( item );
+        m_listCtrlView->SetItem( item );
+
+        wxImage img( imagefile, wxBITMAP_TYPE_JPEG );
+        wxBitmap bmp( img.Scale( 63, 89, 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 );
+    */
+}
+
+/* 画像移動 */
+void MyFrame::MoveImage()
+{
+    wxString distdir = m_textCtrlDist->GetValue();
+    wxString ccn = m_comboBoxCcn->GetValue();
+    if ( distdir.IsEmpty() || ccn.IsEmpty() ) {
+        wxMessageBox(wxT("フォルダを指定してください."));
+        return;
+    }
+
+    distdir.Append( wxFILE_SEP_PATH );
+    if ( !wxDirExists( distdir ) ) {
+        wxMessageBox(wxT("フォルダが存在しません."));
+        return;
+    }
+
+    /*
+    wxString to = distdir + wxFILE_SEP_PATH + hhs + wxFILE_SEP_PATH + filename;
+    wxRenameFile( from, to, false );
+    */
+}
+
+// 以下,定型もの
+/* アプリフォルダを開く */
+void MyFrame::OnOpenAppDir(wxCommandEvent& WXUNUSED(event))
+{
+    wxString appdir = m_dirPickerWork->GetPath();
+    wxString execmd = wxT("explorer ") + appdir;
+    wxExecute( execmd );
+}
+
+/* サイズ変更 */
+void MyFrame::OnSize(wxSizeEvent& event)
+{
+    this->Refresh( true, NULL );
+    TellLocation();
+    event.Skip();
+}
+/* ウィンドウ移動 */
+void MyFrame::OnMove(wxMoveEvent& WXUNUSED(event))
+{
+    TellLocation();
+    return;
+}
+/* ウィンドウ位置とサイズを表示 */
+void MyFrame::TellLocation( void ) 
+{
+    wxRect r = this->GetRect();
+    int x = r.GetX();
+    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 );
+}
+/* 終了 */
+void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
+{
+    Close(true);
+}
+/* 設定を保存 */
+void MyFrame::SaveConfig(wxCloseEvent& WXUNUSED(event))
+{
+    if ( !IsIconized() && !IsMaximized() ) {
+        wxGetApp().rect = this->GetRect();
+    }
+    wxGetApp().workdir = m_dirPickerWork->GetPath();
+
+    Destroy();
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/param.cpp	Sat Oct 15 13:24:27 2011 +0900
@@ -0,0 +1,72 @@
+// Filename   : param.cpp
+// Last Change: 15-Oct-2011.
+//
+
+#include "main.h"
+#include "param.h"
+
+///////////////////////////////////////////////////////////////////////////
+ParamDialog::ParamDialog( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )
+{
+    this->SetBackgroundColour( wxColour(wxT("WHEAT")) );
+
+	wxBoxSizer* bSizer = new wxBoxSizer( wxVERTICAL );
+	
+	wxGridSizer* gSizer = new wxGridSizer( 2, 3, 0, 0 );
+	
+	m_textCtrlLenMIn = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
+	gSizer->Add( m_textCtrlLenMIn, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT|wxALIGN_RIGHT|wxALIGN_TOP, 20 );
+	
+	m_staticTextLen = new wxStaticText( this, wxID_ANY, wxT("< レングス <"), wxDefaultPosition, wxDefaultSize, 0 );
+	gSizer->Add( m_staticTextLen, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 5 );
+	
+	m_textCtrlLenMax = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
+	gSizer->Add( m_textCtrlLenMax, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
+	
+	m_textCtrlBMin = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
+	gSizer->Add( m_textCtrlBMin, 0, wxALL|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 5 );
+	
+	m_staticTextBlack = new wxStaticText( this, wxID_ANY, wxT("< 黒色比率 <"), wxDefaultPosition, wxDefaultSize, 0 );
+	gSizer->Add( m_staticTextBlack, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 );
+	
+	m_textCtrlBmax = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
+	gSizer->Add( m_textCtrlBmax, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
+	
+	m_staticTextlDummy = new wxStaticText( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
+	gSizer->Add( m_staticTextlDummy, 0, wxALL, 5 );
+	
+	m_buttonCancel = new wxButton( this, wxID_CANCEL, wxT("キャンセル"), wxDefaultPosition, wxDefaultSize, 0 );
+	gSizer->Add( m_buttonCancel, 0, wxALL, 5 );
+	
+	m_buttonSave = new wxButton( this, ID_BUTTONSAVE, wxT("設定保存"), wxDefaultPosition, wxDefaultSize, 0 );
+	gSizer->Add( m_buttonSave, 0, wxALIGN_BOTTOM|wxALIGN_TOP, 10 );
+	
+	bSizer->Add( gSizer, 0, 0, 20 );
+	
+	this->SetSizer( bSizer );
+	this->Layout();
+	bSizer->Fit( this );
+	
+	this->Centre( wxBOTH );
+
+    GetParam();
+}
+
+// destructor
+ParamDialog::~ParamDialog()
+{
+}
+// Event Table
+BEGIN_EVENT_TABLE( ParamDialog, wxDialog )
+    EVT_BUTTON( ID_BUTTONSAVE,  ParamDialog::SaveParam )
+END_EVENT_TABLE()
+
+/* 現在の設定を読込み */
+void ParamDialog::GetParam(void)
+{
+}
+/* 設定を保存 */
+void ParamDialog::SaveParam(wxCommandEvent& WXUNUSED(event))
+{
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/testframe.cpp	Sat Oct 15 13:24:27 2011 +0900
@@ -0,0 +1,76 @@
+// Filename   : testframe.cpp
+// Last Change: 08-Oct-2011.
+//
+#include "common.h"
+
+class TestFrame : public wxFrame 
+{
+    DECLARE_EVENT_TABLE()
+    private:
+        wxListCtrl* m_listCtrl;
+
+	public:
+		TestFrame( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxCLOSE_BOX );
+		~TestFrame();
+
+        void OnMessage(wxListEvent&);
+};
+
+// constructor
+TestFrame::TestFrame( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) 
+    : wxFrame( parent, id, title, pos, size, style )
+{
+	this->SetSize( 400, 600 );
+    this->SetBackgroundColour( wxColour(wxT("WHEAT")) );
+	
+	wxBoxSizer* bSizer;
+	bSizer = new wxBoxSizer( wxVERTICAL );
+	
+	m_listCtrl = new wxListCtrl( this, ID_LSWHITE, wxDefaultPosition, wxDefaultSize, wxLC_REPORT );
+    wxListItem itemCol;
+    itemCol.SetText( wxT("通番") );
+    m_listCtrl->InsertColumn( 0, itemCol );
+    m_listCtrl->SetColumnWidth( 0, 100 );
+    itemCol.SetText( wxT("被保険者番号") );
+    m_listCtrl->InsertColumn( 1, itemCol );
+    m_listCtrl->SetColumnWidth( 1, 180 );
+    itemCol.SetText( wxT("ファイル数") );
+    m_listCtrl->InsertColumn( 2, itemCol );
+    m_listCtrl->SetColumnWidth( 1, 100 );
+	bSizer->Add( m_listCtrl, 1, wxALL|wxEXPAND, 5 );
+
+	this->SetSizer( bSizer );
+	this->Layout();
+	
+	this->Centre( wxBOTH );
+
+    m_listCtrl->InsertItem( 1, wxT("aaa") );
+    m_listCtrl->SetItem( 0, 1, wxT("bbb"), -1 );
+    m_listCtrl->InsertItem( 1, wxT("aa2") );
+    m_listCtrl->SetItem( 1, 1, wxT("bb2"), -1 );
+}
+
+// destructor
+TestFrame::~TestFrame()
+{
+}
+
+// Event Table
+BEGIN_EVENT_TABLE( TestFrame, wxFrame )
+    EVT_LIST_ITEM_ACTIVATED( ID_LSWHITE, TestFrame::OnMessage )
+END_EVENT_TABLE()
+
+// Event Handlers
+void TestFrame::OnMessage(wxListEvent& event)
+{
+    wxListItem item = event.GetItem();
+    item.SetColumn(1);
+    item.SetMask(wxLIST_MASK_TEXT);
+    //int n = item.GetColumn();
+    //wxString msg_n = wxString::Format(wxT("%d"),n);
+    //wxMessageBox( msg_n );
+    m_listCtrl->GetItem( item );
+    wxString msg   = item.GetText();
+    wxMessageBox( msg );
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/testtune.cpp	Sat Oct 15 13:24:27 2011 +0900
@@ -0,0 +1,104 @@
+// Filename   : testtune.cpp
+// Last Change: 13-Oct-2011.
+//
+
+#include "wx/utils.h"
+#include "wx/file.h"
+#include "wx/string.h"
+#include "wx/app.h"
+#include "wx/image.h"
+
+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 )
+{
+    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;
+
+    wxPuts(wxString::Format(wxT("z = %f, len = %d"),z,l));
+    if ( zmin < z && z < zmax
+      && lmin < l && l < lmax ) {
+        return true;
+    }
+    return false;
+}
+
+int main( int argc, char **argv ) 
+{
+    wxInitAllImageHandlers();
+    wxString file = wxT("img999.jpg");
+
+    if ( IsMarksheet( file ) ) wxPuts(file+wxT(" is perhaps marksheet !"));
+    wxString hhs = GuessHhs( file );
+    wxPuts(hhs);
+
+}
+