OSDN Git Service

Experimental 'filter' mode is removed.
authortoshinagata1964 <toshinagata1964@a2be9bc6-48de-4e38-9406-05402d4bc13c>
Fri, 12 Oct 2012 11:22:42 +0000 (11:22 +0000)
committertoshinagata1964 <toshinagata1964@a2be9bc6-48de-4e38-9406-05402d4bc13c>
Fri, 12 Oct 2012 11:22:42 +0000 (11:22 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/molby/trunk@293 a2be9bc6-48de-4e38-9406-05402d4bc13c

MolLib/Ruby_bind/ruby_bind.c
Scripts/dialog.rb
Scripts/startup.rb
wxSources/ConsoleFrame.cpp
wxSources/MyApp.cpp
wxSources/MyApp.h
wxSources/MyDocManager.cpp
wxSources/MyDocManager.h

index d9ee34c..5324880 100644 (file)
@@ -684,31 +684,6 @@ s_Kernel_CallSubProcess(VALUE self, VALUE cmd, VALUE procname)
        return INT2NUM(n);
 }
 
-/*
- *  call-seq:
- *     enable_filter_mode -> Integer
- *
- *  Switch to a filter mode. Should be invoked from within a script file.
- *  Returns true when successfully switched, false when already in filter mode.
- *  No Molecule should be open as a view; otherwise, an exception is raised.
- */
-static VALUE
-s_Kernel_EnableFilterMode(VALUE self)
-{
-       int n = MyAppCallback_switchToFilterMode();
-       if (n == 0)
-               return Qtrue;
-       else if (n == 1)
-               return Qfalse;
-       else if (n == -1)
-               rb_raise(rb_eMolbyError, "To switch to filter mode, all molecule should be closed");
-       else if (n == -2)
-               rb_raise(rb_eMolbyError, "No script file is specified for filter mode");
-       else
-               rb_raise(rb_eMolbyError, "Cannot switch to filter mode");
-       return Qnil;  /*  Dummy to keep compiler happy  */
-}
-
 #pragma mark ====== User defaults ======
 
 /*
@@ -10147,7 +10122,6 @@ Init_Molby(void)
        rb_define_method(rb_mKernel, "call_subprocess", s_Kernel_CallSubProcess, 2);
        rb_define_method(rb_mKernel, "message_box", s_Kernel_MessageBox, -1);
        rb_define_method(rb_mKernel, "error_message_box", s_Kernel_ErrorMessageBox, 1);
-       rb_define_method(rb_mKernel, "enable_filter_mode", s_Kernel_EnableFilterMode, 0);
        
        s_ID_equal = rb_intern("==");
 }
@@ -10157,7 +10131,7 @@ Init_Molby(void)
 static VALUE s_ruby_top_self = Qfalse;
 
 static VALUE
-s_evalRubyScriptOnMoleculeSub(VALUE val)
+s_evalRubyScriptOnMoleculeSubSub(VALUE tagval, VALUE val)
 {
        void **ptr = (void **)val;
        Molecule *mol = (Molecule *)ptr[1];
@@ -10184,6 +10158,12 @@ s_evalRubyScriptOnMoleculeSub(VALUE val)
        }
 }
 
+static VALUE
+s_evalRubyScriptOnMoleculeSub(VALUE val)
+{
+       return rb_catch("molby_top", s_evalRubyScriptOnMoleculeSubSub, val);
+}
+
 RubyValue
 Molby_evalRubyScriptOnMolecule(const char *script, Molecule *mol, const char *fname, int *status)
 {
index e87fa66..b3df79c 100755 (executable)
@@ -39,16 +39,21 @@ class Dialog
 
   def self.filter_kit(title, description, &block)
     Dialog.new(title, nil, nil) {
-      def write(s)  #  Override standard output
+      def self.write(s)  #  Override standard output
         item_with_tag("text").append_string(s)
       end
       button_action = proc {
         names = Dialog.open_panel("Select file(s) to process", nil, nil, false, true)
         if names
-          stdout_save = $stdout
-          $stdout = self
-          block.call(names)
-          $stdout = stdout_save
+                 begin
+            stdout_save = $stdout
+            $stdout = self
+                   catch(:exit) {
+              block.call(names)
+               }
+                 ensure
+            $stdout = stdout_save
+                 end
         end
       }
       layout(1,
index cb153b2..268fd24 100755 (executable)
@@ -39,6 +39,10 @@ def backtrace
   end
 end
 
+def exit(val = nil)
+  throw(:molby_top, val)
+end
+
 load "transform.rb"
 load "molecule.rb"
 load "loadsave.rb"
index a94b526..a8332b6 100755 (executable)
@@ -71,7 +71,8 @@ ConsoleFrame::OnCreate()
        //  Set the default font (fixed-pitch)
        wxTextAttr attr;
 #if defined(__WXMSW__)
-       wxFont font = wxSystemSettings::GetFont(wxSYS_ANSI_FIXED_FONT);
+//     wxFont font = wxSystemSettings::GetFont(wxSYS_ANSI_FIXED_FONT);
+       wxFont font(10, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
 #else
        wxFont font(11, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
 #endif
@@ -100,17 +101,8 @@ ConsoleFrame::CreateConsoleFrame(wxMDIParentFrame *parent)
        ConsoleFrame *frame = new ConsoleFrame(parent, _T("Console"), origin, wxDefaultSize, wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE);
 
        frame->OnCreate();
-
-       if (wxGetApp().IsFilterMode()) {
-#if defined(__WXMSW__)
-               frame->Maximize();
-#else
-               frame->SetSize(800, 480);
-#endif
-       } else {
-               frame->SetSize(640, 200);
-       }
-               
+       frame->SetClientSize(size);
+       
        return frame;
 }
 
index 9c351e0..9d1f9a9 100755 (executable)
@@ -74,8 +74,6 @@
 
 static char *sLastBuildString = "";
 
-static const char *sExecutingRubyScriptPath = NULL;
-
 MyFrame *frame = (MyFrame *) NULL;
 
 IMPLEMENT_APP(MyApp)
@@ -172,8 +170,6 @@ MyApp::MyApp(void)
        m_CountNamedFragments = 0;
        m_NamedFragments = (char **)(-1);  /*  Will be set to NULL after Ruby interpreter is initialized  */
        m_pendingFilesToOpen = NULL;
-       m_filterScriptName = NULL;
-       m_filterScriptBaseName = NULL;
 #if defined(__WXMSW__)
        m_checker = NULL;
        m_ipcServiceName = NULL;
@@ -189,32 +185,11 @@ bool MyApp::OnInit(void)
        wxSystemOptions::SetOption(wxT("mac.listctrl.always_use_generic"), 1);
 #endif
 
-       //  Check if invoked as a filter mode
-       if (argc > 2) {
-               wxString arg1(argv[1]);
-               wxString arg2(argv[2]);
-               if (arg1 == wxT("--filter") && (arg2.EndsWith(wxT(".rb")) || arg2.EndsWith(wxT(".mrb")))) {
-                       char *p;
-                       m_filterScriptName = strdup(arg2.mb_str(wxConvFile));
-                       p = strrchr(m_filterScriptName, '/');
-#if defined(__WXMSW__)
-                       if (p == NULL)
-                               p = strrchr(m_filterScriptName, '\\');
-#endif
-                       if (p == NULL)
-                               p = m_filterScriptName;
-                       m_filterScriptBaseName = strdup(p);
-               }
-       }
-       
 #if __WXMSW__
        {
                //  Check if the same application is already running
                char *buf, *p;
-               if (m_filterScriptBaseName != NULL) {
-                       p = m_filterScriptBaseName;
-               } else p = "";
-               asprintf(&buf, "Molby%s-%s", p, (const char *)wxGetUserId().mb_str(WX_DEFAULT_CONV));
+               asprintf(&buf, "Molby-%s", (const char *)wxGetUserId().mb_str(WX_DEFAULT_CONV));
                wxString name(buf, WX_DEFAULT_CONV);
                m_ipcServiceName = new wxString(name);
                m_ipcServiceName->Prepend(wxT("IPC-"));
@@ -224,11 +199,6 @@ bool MyApp::OnInit(void)
                        //  Make a connection with the other instance and ask for opening the file(s)
                        wxString files;
                        wxConnectionBase *connection;
-                       if (m_filterScriptName != NULL) {
-                               //  Skip the "--filter" option and the script name
-                               argc -= 2;
-                               argv += 2;
-                       }
                        while (argc > 1) {
                                files.append(argv[1]);
                                files.append(wxT("\n"));
@@ -379,16 +349,7 @@ bool MyApp::OnInit(void)
                        wxSetWorkingDirectory(docHome);
                        
                }
-               if (IsFilterMode()) {
-                       MyAppCallback_setConsoleColor(3);
-                       MyAppCallback_showScriptMessage("***********************************************************\n");
-                       MyAppCallback_showScriptMessage(" Molby is now running in the filter mode.\n");
-                       MyAppCallback_showScriptMessage(" When you open files, they will be processed by\n");
-                       MyAppCallback_showScriptMessage(" the script '%s'.\n", m_filterScriptBaseName);
-                       MyAppCallback_showScriptMessage(" You can process any file, not necessarily molecular files.\n");
-                       MyAppCallback_showScriptMessage("***********************************************************\n");
-                       MyAppCallback_setConsoleColor(0);
-               }
+
                MyAppCallback_showScriptMessage("%% ");
                
                /*  Build the predefined fragments menu  */
@@ -399,14 +360,9 @@ bool MyApp::OnInit(void)
        }
        
        /*  Open given files: Ruby script is executed, other files are opened as a document  */
-       if (IsFilterMode()) {
-               argc -= 2;
-               argv += 2;
-       }
        if (argc == 1) {
 #if defined(__WXMSW__)
-               if (!IsFilterMode())
-                       m_docManager->CreateDocument(wxEmptyString, wxDOC_NEW);
+               m_docManager->CreateDocument(wxEmptyString, wxDOC_NEW);
 #endif
        } else {
                int i;
@@ -433,7 +389,6 @@ MyApp::CreateMenuBar(int kind, wxMenu **out_file_history_menu, wxMenu **out_edit
        
        //// Make a menubar
        wxMenu *file_menu = new wxMenu;
-       bool filter_mode = IsFilterMode();
 
        file_menu->Append(wxID_NEW, _T("&New...\tCtrl-N"));
        file_menu->Append(wxID_OPEN, _T("&Open...\tCtrl-O"));
@@ -444,24 +399,22 @@ MyApp::CreateMenuBar(int kind, wxMenu **out_file_history_menu, wxMenu **out_edit
                m_docManager->FileHistoryUseMenu(*out_file_history_menu);  //  Should be removed when menu is discarded
        }
        /*  Build "Open Predefined"  */
-       if (!filter_mode) {
-               wxMenu *predefined_menu = new wxMenu;
-               file_menu->Append(myMenuID_PredefinedFragment, _T("Open Predefined"), predefined_menu);
+       wxMenu *predefined_menu = new wxMenu;
+       file_menu->Append(myMenuID_PredefinedFragment, _T("Open Predefined"), predefined_menu);
+
+       file_menu->AppendSeparator();
+       file_menu->Append(wxID_CLOSE, _T("&Close\tCtrl-W"));
+       file_menu->Append(wxID_SAVE, _T("&Save\tCtrl-S"));
+       file_menu->Append(wxID_SAVEAS, _T("Save &As..."));      
        
-               file_menu->AppendSeparator();
-               file_menu->Append(wxID_CLOSE, _T("&Close\tCtrl-W"));
-               file_menu->Append(wxID_SAVE, _T("&Save\tCtrl-S"));
-               file_menu->Append(wxID_SAVEAS, _T("Save &As..."));      
-               
-               file_menu->AppendSeparator();
-               file_menu->Append(myMenuID_Import, _T("Import..."));    
-               file_menu->Append(myMenuID_Export, _T("Export..."));    
-               
-               file_menu->AppendSeparator();
-               file_menu->Append(wxID_PRINT, _T("&Print...\tCtrl-P"));
-               file_menu->Append(wxID_PRINT_SETUP, _T("Print &Setup..."));
-               file_menu->Append(wxID_PREVIEW, _T("Print Pre&view"));
-       }
+       file_menu->AppendSeparator();
+       file_menu->Append(myMenuID_Import, _T("Import..."));    
+       file_menu->Append(myMenuID_Export, _T("Export..."));    
+       
+       file_menu->AppendSeparator();
+       file_menu->Append(wxID_PRINT, _T("&Print...\tCtrl-P"));
+       file_menu->Append(wxID_PRINT_SETUP, _T("Print &Setup..."));
+       file_menu->Append(wxID_PREVIEW, _T("Print Pre&view"));
        
        file_menu->AppendSeparator();
 #if defined(__WXMAC__)
@@ -480,98 +433,86 @@ MyApp::CreateMenuBar(int kind, wxMenu **out_file_history_menu, wxMenu **out_edit
        edit_menu->Append(wxID_CLEAR, _T("Clear"));
        edit_menu->AppendSeparator();
        edit_menu->Append(wxID_SELECTALL, _T("Select All\tCtrl-A"));
-       if (!filter_mode) {
-               edit_menu->Append(myMenuID_SelectFragment, _T("Select Fragment\tCtrl-F"));
-               edit_menu->Append(myMenuID_SelectReverse, _T("Select Reverse"));
-               edit_menu->AppendSeparator();
-               wxMenu *create_parameter_menu = new wxMenu;
-               create_parameter_menu->Append(myMenuID_CreateNewVdwParameter, _T("Vdw"));
-               create_parameter_menu->Append(myMenuID_CreateNewBondParameter, _T("Bond"));
-               create_parameter_menu->Append(myMenuID_CreateNewAngleParameter, _T("Angle"));
-               create_parameter_menu->Append(myMenuID_CreateNewDihedralParameter, _T("Dihedral"));
-               create_parameter_menu->Append(myMenuID_CreateNewImproperParameter, _T("Improper"));
-               create_parameter_menu->Append(myMenuID_CreateNewVdwPairParameter, _T("Vdw Pair"));
-               create_parameter_menu->Append(myMenuID_CreateNewVdwCutoffParameter, _T("Vdw Cutoff"));
-               edit_menu->Append(myMenuID_CreateNewAtom, _T("Create New Atom\tCtrl-I"));
-               edit_menu->Append(myMenuID_CreateNewParameter, _T("Create New Parameter"), create_parameter_menu);
-               edit_menu->AppendSeparator();
-               wxMenu *add_hydrogen_menu = new wxMenu;
-               add_hydrogen_menu->Append(myMenuID_AddHydrogenSp3, _T("Tetrahedral sp3"));
-               add_hydrogen_menu->Append(myMenuID_AddHydrogenSp2, _T("Trigonal sp2"));
-               add_hydrogen_menu->Append(myMenuID_AddHydrogenLinear, _T("Linear sp"));
-               add_hydrogen_menu->Append(myMenuID_AddHydrogenPyramidal, _T("Pyramidal (like NH2)"));
-               add_hydrogen_menu->Append(myMenuID_AddHydrogenBent, _T("Bent (like OH)"));
-               edit_menu->Append(myMenuID_AddHydrogen, _T("Add Hydrogen"), add_hydrogen_menu);
-       }
+       edit_menu->Append(myMenuID_SelectFragment, _T("Select Fragment\tCtrl-F"));
+       edit_menu->Append(myMenuID_SelectReverse, _T("Select Reverse"));
+       edit_menu->AppendSeparator();
+       wxMenu *create_parameter_menu = new wxMenu;
+       create_parameter_menu->Append(myMenuID_CreateNewVdwParameter, _T("Vdw"));
+       create_parameter_menu->Append(myMenuID_CreateNewBondParameter, _T("Bond"));
+       create_parameter_menu->Append(myMenuID_CreateNewAngleParameter, _T("Angle"));
+       create_parameter_menu->Append(myMenuID_CreateNewDihedralParameter, _T("Dihedral"));
+       create_parameter_menu->Append(myMenuID_CreateNewImproperParameter, _T("Improper"));
+       create_parameter_menu->Append(myMenuID_CreateNewVdwPairParameter, _T("Vdw Pair"));
+       create_parameter_menu->Append(myMenuID_CreateNewVdwCutoffParameter, _T("Vdw Cutoff"));
+       edit_menu->Append(myMenuID_CreateNewAtom, _T("Create New Atom\tCtrl-I"));
+       edit_menu->Append(myMenuID_CreateNewParameter, _T("Create New Parameter"), create_parameter_menu);
+       edit_menu->AppendSeparator();
+       wxMenu *add_hydrogen_menu = new wxMenu;
+       add_hydrogen_menu->Append(myMenuID_AddHydrogenSp3, _T("Tetrahedral sp3"));
+       add_hydrogen_menu->Append(myMenuID_AddHydrogenSp2, _T("Trigonal sp2"));
+       add_hydrogen_menu->Append(myMenuID_AddHydrogenLinear, _T("Linear sp"));
+       add_hydrogen_menu->Append(myMenuID_AddHydrogenPyramidal, _T("Pyramidal (like NH2)"));
+       add_hydrogen_menu->Append(myMenuID_AddHydrogenBent, _T("Bent (like OH)"));
+       edit_menu->Append(myMenuID_AddHydrogen, _T("Add Hydrogen"), add_hydrogen_menu);
        
        if (out_edit_menu != NULL)
                *out_edit_menu = edit_menu;     // Should be associated with the command processor if available
        
        wxMenu *show_menu = new wxMenu;
-       if (!filter_mode) {
-               show_menu->Append(myMenuID_FitToScreen, _T("Fit To Screen\tCtrl-T"));
-               show_menu->Append(myMenuID_CenterSelection, _T("Center Selection"));
-               show_menu->AppendSeparator();
-               show_menu->Append(myMenuID_ShowUnitCell, _T("Show Unit Cell"), _T(""), wxITEM_CHECK);
-       /*      show_menu->Append(myMenuID_ShowPeriodicBox, _T("Show Periodic Box"), _T(""), wxITEM_CHECK); */
-               show_menu->Append(myMenuID_ShowHydrogens, _T("Show Hydrogen Atoms"), _T(""), wxITEM_CHECK);
-               show_menu->Append(myMenuID_ShowDummyAtoms, _T("Show Dummy Atoms"), _T(""), wxITEM_CHECK);
-               show_menu->Append(myMenuID_ShowExpandedAtoms, _T("Show Expanded Atoms"), _T(""), wxITEM_CHECK);
-               show_menu->Append(myMenuID_ShowEllipsoids, _T("Show Ellipsoids"), _T(""), wxITEM_CHECK);
-               show_menu->Append(myMenuID_ShowRotationCenter, _T("Show Rotation Center"), _T(""), wxITEM_CHECK);
-               show_menu->AppendSeparator();
-               show_menu->Append(myMenuID_HideSelected, _T("Hide Selected"), _T(""));
-               show_menu->Append(myMenuID_HideUnselected, _T("Hide Unselected"), _T(""));
-               show_menu->Append(myMenuID_HideReverse, _T("Hide Reverse"), _T(""));
-               show_menu->Append(myMenuID_ShowAllAtoms, _T("Show All Atoms"), _T(""));
-               show_menu->AppendSeparator();
-               show_menu->Append(myMenuID_ShowGraphite, _T("Show Graphite..."));
-               show_menu->AppendSeparator();
-               show_menu->Append(myMenuID_LineMode, _T("Line Mode"), _T(""), wxITEM_CHECK);
-       }
+       show_menu->Append(myMenuID_FitToScreen, _T("Fit To Screen\tCtrl-T"));
+       show_menu->Append(myMenuID_CenterSelection, _T("Center Selection"));
+       show_menu->AppendSeparator();
+       show_menu->Append(myMenuID_ShowUnitCell, _T("Show Unit Cell"), _T(""), wxITEM_CHECK);
+/*     show_menu->Append(myMenuID_ShowPeriodicBox, _T("Show Periodic Box"), _T(""), wxITEM_CHECK); */
+       show_menu->Append(myMenuID_ShowHydrogens, _T("Show Hydrogen Atoms"), _T(""), wxITEM_CHECK);
+       show_menu->Append(myMenuID_ShowDummyAtoms, _T("Show Dummy Atoms"), _T(""), wxITEM_CHECK);
+       show_menu->Append(myMenuID_ShowExpandedAtoms, _T("Show Expanded Atoms"), _T(""), wxITEM_CHECK);
+       show_menu->Append(myMenuID_ShowEllipsoids, _T("Show Ellipsoids"), _T(""), wxITEM_CHECK);
+       show_menu->Append(myMenuID_ShowRotationCenter, _T("Show Rotation Center"), _T(""), wxITEM_CHECK);
+       show_menu->AppendSeparator();
+       show_menu->Append(myMenuID_HideSelected, _T("Hide Selected"), _T(""));
+       show_menu->Append(myMenuID_HideUnselected, _T("Hide Unselected"), _T(""));
+       show_menu->Append(myMenuID_HideReverse, _T("Hide Reverse"), _T(""));
+       show_menu->Append(myMenuID_ShowAllAtoms, _T("Show All Atoms"), _T(""));
+       show_menu->AppendSeparator();
+       show_menu->Append(myMenuID_ShowGraphite, _T("Show Graphite..."));
+       show_menu->AppendSeparator();
+       show_menu->Append(myMenuID_LineMode, _T("Line Mode"), _T(""), wxITEM_CHECK);
 
        wxMenu *md_menu = new wxMenu;
-       if (!filter_mode) {
-               md_menu->Append(myMenuID_MolecularDynamics, _T("Molecular Dynamics..."));
-               md_menu->Append(myMenuID_Minimize, _T("Minimize..."));
-               md_menu->Append(myMenuID_StopMDRun, _T("Stop\tCtrl-."));
-               md_menu->AppendSeparator();
-       //      md_menu->Append(myMenuID_ReadParameters, _T("Read Parameters..."));     
-               md_menu->Append(myMenuID_ViewGlobalParameters, _T("View Global Parameters..."));
-               md_menu->Append(myMenuID_ViewParameterFilesList, _T("Load/Unload Global Parameters..."));
-               md_menu->AppendSeparator();
-               md_menu->Append(myMenuID_DefinePeriodicBox, _T("Define Unit Cell..."));
-               md_menu->Append(myMenuID_ShowPeriodicImage, _T("Show Periodic Image..."));
-       /*      md_menu->Append(myMenuID_PressureControl, _T("Pressure Control...")); */
-       /*      md_menu->Append(myMenuID_DefineSymmetry, _T("Define Symmetry Operations..."));
-               md_menu->Append(myMenuID_ExpandBySymmetry, _T("Expand by Symmetry...")); */
-               md_menu->AppendSeparator();
-       }
+       md_menu->Append(myMenuID_MolecularDynamics, _T("Molecular Dynamics..."));
+       md_menu->Append(myMenuID_Minimize, _T("Minimize..."));
+       md_menu->Append(myMenuID_StopMDRun, _T("Stop\tCtrl-."));
+       md_menu->AppendSeparator();
+//     md_menu->Append(myMenuID_ReadParameters, _T("Read Parameters..."));     
+       md_menu->Append(myMenuID_ViewGlobalParameters, _T("View Global Parameters..."));
+       md_menu->Append(myMenuID_ViewParameterFilesList, _T("Load/Unload Global Parameters..."));
+       md_menu->AppendSeparator();
+       md_menu->Append(myMenuID_DefinePeriodicBox, _T("Define Unit Cell..."));
+       md_menu->Append(myMenuID_ShowPeriodicImage, _T("Show Periodic Image..."));
+/*     md_menu->Append(myMenuID_PressureControl, _T("Pressure Control...")); */
+/*     md_menu->Append(myMenuID_DefineSymmetry, _T("Define Symmetry Operations..."));
+       md_menu->Append(myMenuID_ExpandBySymmetry, _T("Expand by Symmetry...")); */
+       md_menu->AppendSeparator();
        
        wxMenu *md_tools_menu = new wxMenu;
-       if (!filter_mode) {
-               md_tools_menu->Append(myMenuID_RunAntechamber, _T("Antechamber/parmchk..."));
-               md_tools_menu->Append(myMenuID_RunResp, _T("GAMESS/RESP..."));
-               md_tools_menu->Append(myMenuID_CreateSanderInput, _T("Create SANDER input..."));
-               md_tools_menu->Append(myMenuID_ImportAmberLib, _T("Import AMBER Lib..."));
-               md_tools_menu->Append(myMenuID_ImportAmberFrcmod, _T("Import AMBER Frcmod..."));
-               md_menu->Append(myMenuID_MDTools, _T("Tools"), md_tools_menu);
-       }
+       md_tools_menu->Append(myMenuID_RunAntechamber, _T("Antechamber/parmchk..."));
+       md_tools_menu->Append(myMenuID_RunResp, _T("GAMESS/RESP..."));
+       md_tools_menu->Append(myMenuID_CreateSanderInput, _T("Create SANDER input..."));
+       md_tools_menu->Append(myMenuID_ImportAmberLib, _T("Import AMBER Lib..."));
+       md_tools_menu->Append(myMenuID_ImportAmberFrcmod, _T("Import AMBER Frcmod..."));
+       md_menu->Append(myMenuID_MDTools, _T("Tools"), md_tools_menu);
 
        wxMenu *qc_menu = new wxMenu;
-       if (!filter_mode) {
-               qc_menu->Append(myMenuID_CreateGamessInput, _T("Create GAMESS input..."));
-               qc_menu->Append(myMenuID_CreateMOCube, _T("Create MO cube..."));
-       }
+       qc_menu->Append(myMenuID_CreateGamessInput, _T("Create GAMESS input..."));
+       qc_menu->Append(myMenuID_CreateMOCube, _T("Create MO cube..."));
        
        wxMenu *script_menu = new wxMenu;
-       if (!filter_mode) {
-               script_menu->Append(myMenuID_ExecuteScript, _T("Execute Script..."));
-               script_menu->Append(myMenuID_OpenConsoleWindow, _T("Open Console Window..."));
-               script_menu->Append(myMenuID_EmptyConsoleWindow, _T("Empty Console Window"));
-               script_menu->AppendSeparator();
-               countNonCustomScriptMenu = script_menu->GetMenuItemCount();
-       }
+       script_menu->Append(myMenuID_ExecuteScript, _T("Execute Script..."));
+       script_menu->Append(myMenuID_OpenConsoleWindow, _T("Open Console Window..."));
+       script_menu->Append(myMenuID_EmptyConsoleWindow, _T("Empty Console Window"));
+       script_menu->AppendSeparator();
+       countNonCustomScriptMenu = script_menu->GetMenuItemCount();
 
        wxMenu *help_menu = new wxMenu;
        help_menu->Append(wxID_ABOUT, _T("&About...\tF1"));
@@ -580,12 +521,10 @@ MyApp::CreateMenuBar(int kind, wxMenu **out_file_history_menu, wxMenu **out_edit
        
        menu_bar->Append(file_menu, _T("&File"));
        menu_bar->Append(edit_menu, _T("&Edit"));
-       if (!filter_mode) {
-               menu_bar->Append(show_menu, _T("Show"));
-               menu_bar->Append(md_menu, _T("MM/MD"));
-               menu_bar->Append(qc_menu, _T("QChem"));
-               menu_bar->Append(script_menu, _T("&Script"));
-       }
+       menu_bar->Append(show_menu, _T("Show"));
+       menu_bar->Append(md_menu, _T("MM/MD"));
+       menu_bar->Append(qc_menu, _T("QChem"));
+       menu_bar->Append(script_menu, _T("&Script"));
        menu_bar->Append(help_menu, _T("&Help"));
        
        UpdateScriptMenu(menu_bar);
@@ -602,9 +541,7 @@ MyApp::CreateMenuBar(int kind, wxMenu **out_file_history_menu, wxMenu **out_edit
 void
 MyApp::MacNewFile()
 {
-       /*  Do nothing in filter mode  */
-       if (!IsFilterMode())
-               m_docManager->CreateDocument(_T(""), wxDOC_NEW);
+       m_docManager->CreateDocument(_T(""), wxDOC_NEW);
 }
 
 void
@@ -732,59 +669,12 @@ sModifyMenuForFilterMode(wxMenuBar *mbar)
 }
 
 int
-MyApp::SwitchToFilterMode(const char *filterScriptName)
-{
-       if (IsFilterMode())
-               return 1;   /*  Already filter mode  */
-       if (m_docManager->GetCurrentView() != NULL)
-               return -1;  /*  Molecule is open: cannot switch  */
-
-       /*  Remove menu items except for absolutely necessary  */
-       sModifyMenuForFilterMode(GetMainFrame()->GetMenuBar());
-       sModifyMenuForFilterMode(consoleFrame->GetMenuBar());
-       
-       /*  Record the name of the filter script  */
-       char *p;
-       m_filterScriptName = strdup(filterScriptName);
-       p = strrchr(m_filterScriptName, '/');
-#if defined(__WXMSW__)
-       if (p == NULL)
-               p = strrchr(m_filterScriptName, '\\');
-#endif
-       if (p == NULL)
-               p = m_filterScriptName;
-       else p++;
-       m_filterScriptBaseName = strdup(p);
-
-       /*  Resize the console window and show startup message  */
-       int width, height;
-       consoleFrame->GetClientSize(&width, &height);
-       if (width < 640)
-               width = 640;
-       if (height < 480)
-               height = 480;
-       consoleFrame->EmptyBuffer(false);
-       consoleFrame->SetClientSize(width, height);
-       MyAppCallback_setConsoleColor(3);
-       MyAppCallback_showScriptMessage("***********************************************************\n");
-       MyAppCallback_showScriptMessage(" Molby is now running in the filter mode.\n");
-       MyAppCallback_showScriptMessage(" When you open files, they will be processed by\n");
-       MyAppCallback_showScriptMessage(" the script '%s'.\n", m_filterScriptBaseName);
-       MyAppCallback_showScriptMessage(" You can process any file, not necessarily molecular files.\n");
-       MyAppCallback_showScriptMessage("***********************************************************\n");
-       MyAppCallback_setConsoleColor(0);
-       
-       return 0;
-}
-
-int
 MyApp::AppendConsoleMessage(const char *mes)
 {
        wxTextCtrl *textCtrl;
        if (consoleFrame != NULL && (textCtrl = consoleFrame->textCtrl) != NULL) {
                wxString string(mes, WX_DEFAULT_CONV);
                textCtrl->AppendText(string);
-               textCtrl->DiscardEdits();  /*  Disable undo for this operation  */
                return string.Len();
        } else return 0;
 }
@@ -1271,8 +1161,6 @@ bool
 MyApp::OnOpenFiles(const wxString &files)
 {
        Int start, end;
-       Int nargs = 0;
-       const char **args = NULL;
        bool success = true;
        int status;
        RubyValue retval;
@@ -1282,44 +1170,24 @@ MyApp::OnOpenFiles(const wxString &files)
                wxString file = files.Mid(start, (end == wxString::npos ? wxString::npos : end - start));
                if (file.Len() == 0)
                        break;
-               if (IsFilterMode()) {
-                       /*  Filter mode: build ARGV and call the given script (later)  */
-                       AssignArray(&args, &nargs, sizeof(char *), nargs, NULL);
-                       args[nargs - 1] = strdup(file.mb_str(wxConvFile));
-               } else {
-                       if (file.EndsWith(wxT(".rb")) || file.EndsWith(wxT(".mrb"))) {
-                               /*  Execute the file as a Ruby script  */
-                               retval = MyAppCallback_executeScriptFromFile((const char *)file.mb_str(wxConvFile), &status);
-                               if (status != 0) {
-                                       if (retval == (RubyValue)6 && status == -1)
-                                               MyAppCallback_errorMessageBox("Cannot open Ruby script: %s", (const char *)file.mb_str(wxConvFile));
-                                       else
-                                               Molby_showError(status);
-                                       return false;
-                               }
-                       } else {
-                               if (NULL == wxGetApp().DocManager()->CreateDocument(file, wxDOC_SILENT))
-                                       success = false;
+               if (file.EndsWith(wxT(".rb")) || file.EndsWith(wxT(".mrb"))) {
+                       /*  Execute the file as a Ruby script  */
+                       retval = MyAppCallback_executeScriptFromFile((const char *)file.mb_str(wxConvFile), &status);
+                       if (status != 0) {
+                               if (retval == (RubyValue)6 && status == -1)
+                                       MyAppCallback_errorMessageBox("Cannot open Ruby script: %s", (const char *)file.mb_str(wxConvFile));
+                               else
+                                       Molby_showError(status);
+                               return false;
                        }
+               } else {
+                       if (NULL == wxGetApp().DocManager()->CreateDocument(file, wxDOC_SILENT))
+                               success = false;
                }
                if (end == wxString::npos)
                        break;
                start = end + 1;
        }
-       if (IsFilterMode()) {
-               Molby_buildARGV(nargs, args);
-               for (start = 0; start < nargs; start++)
-                       free((void *)args[start]);
-               
-               retval = MyAppCallback_executeScriptFromFile(m_filterScriptName, &status);
-               if (status != 0) {
-                       if (retval == (RubyValue)6 && status == -1)
-                               MyAppCallback_errorMessageBox("Cannot open Ruby script: %s", m_filterScriptName);
-                       else
-                               Molby_showError(status);
-                       return false;
-               }
-       }
        return success;
 }
 
@@ -1879,7 +1747,6 @@ RubyValue
 MyAppCallback_executeScriptFromFile(const char *cpath, int *status)
 {
        RubyValue retval;
-       const char *old_cpath;
        wxString cwd = wxFileName::GetCwd();
        wxString path(cpath, wxConvFile);
        char *p = strdup(cpath);
@@ -1955,10 +1822,7 @@ MyAppCallback_executeScriptFromFile(const char *cpath, int *status)
                }
        }
        
-       old_cpath = sExecutingRubyScriptPath;
-       sExecutingRubyScriptPath = cpath;
        retval = Molby_evalRubyScriptOnMolecule(script, MoleculeCallback_currentMolecule(), pp, status);
-       sExecutingRubyScriptPath = old_cpath;
        
        free(script);
        free(p);
@@ -1988,10 +1852,3 @@ int MyAppCallback_callSubProcess(const char *cmdline, const char *procname)
 {
        return wxGetApp().CallSubProcess(cmdline, procname);
 }
-
-int MyAppCallback_switchToFilterMode(void)
-{
-       if (sExecutingRubyScriptPath == NULL)
-               return -2;  /*  Not invoked from file  */
-       return wxGetApp().SwitchToFilterMode(sExecutingRubyScriptPath);
-}
index fec47f3..d19b70e 100755 (executable)
@@ -182,10 +182,6 @@ class MyApp: public wxApp
        
        bool OnOpenFiles(const wxString &files);
 
-       int SwitchToFilterMode(const char *filterScriptName);
-       bool IsFilterMode() { return (m_filterScriptName != NULL); }
-       const char *FilterScriptBaseName() { return m_filterScriptBaseName; }
-
        MyListCtrl *GetGlobalParameterListCtrl();
        
 #if defined(__WXMAC__)
@@ -219,9 +215,6 @@ protected:
 
        wxString *m_pendingFilesToOpen;  /*  Files to be processed by OnOpenFilesByIPC()  */
 
-       char *m_filterScriptName;        /*  Ruby script when invoked as a filter mode  */
-       char *m_filterScriptBaseName;    /*  The file name (without directories) of the filter script  */
-       
 #if defined(__WXMSW__)
 public:
        wxSingleInstanceChecker *m_checker;
index 8ede83f..ebf9ca5 100644 (file)
@@ -49,42 +49,6 @@ MyDocManager::SetDocumentTypesEnabled(const char **extensions, bool flag)
        }
 }
 
-/*
-wxDocument*
-MyDocManager::CreateDocument(const wxString& path, long flags)
-{
-       return wxDocManager::CreateDocument(path, flags);
-}
-*/
-
-void
-MyDocManager::OnFileOpen(wxCommandEvent& event)
-{
-       if (wxGetApp().IsFilterMode()) {
-               /*  Select files to give to the script  */
-               int result = 0;
-               wxString tstr(wxT("Choose File(s) to be processed by "));
-               wxString files;
-               tstr.Append(wxString(wxGetApp().FilterScriptBaseName(), wxConvFile));
-               wxFileDialog *dialog = new wxFileDialog(NULL, tstr, wxT(""), wxT(""), wxT("All files (*.*)|*.*"), wxFD_OPEN | wxFD_MULTIPLE);
-               if (dialog->ShowModal() == wxID_OK) {
-                       int i, n;
-                       wxArrayString paths;
-                       dialog->GetPaths(paths);
-                       n = paths.GetCount();
-                       for (i = 0; i < n; i++) {
-                               files.Append(paths[i]);
-                               files.Append(wxT("\n"));
-                       }
-                       result = 1;
-               }
-               dialog->Destroy();
-               wxGetApp().OnOpenFiles(files);
-       } else {
-               wxDocManager::OnFileOpen(event);
-       }
-}
-
 void
 MyDocManager::OnFileSave(wxCommandEvent& event)
 {
index be51fe7..9964880 100644 (file)
@@ -23,7 +23,7 @@
 class MyDocManager: public wxDocManager {
 public:
 //     wxDocument* CreateDocument(const wxString& path, long flags);
-       void OnFileOpen(wxCommandEvent& event);
+//     void OnFileOpen(wxCommandEvent& event);
        void OnFileSave(wxCommandEvent& event);
        void OnFileSaveAs(wxCommandEvent& event);
        void SetDocumentTypesEnabled(const char **extensions, bool flag);