OSDN Git Service

Create New Atom menu command is being implemented (not tested at all yet)
authortoshinagata1964 <toshinagata1964@a2be9bc6-48de-4e38-9406-05402d4bc13c>
Thu, 21 Jul 2011 16:45:41 +0000 (16:45 +0000)
committertoshinagata1964 <toshinagata1964@a2be9bc6-48de-4e38-9406-05402d4bc13c>
Thu, 21 Jul 2011 16:45:41 +0000 (16:45 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/molby/trunk@78 a2be9bc6-48de-4e38-9406-05402d4bc13c

Documents/etc/tutorial_5_01.png [new file with mode: 0644]
Documents/src/doc_source.html
MolLib/MainView.c
MolLib/MainView.h
MolLib/Ruby_bind/ruby_bind.c
memo.txt
wxSources/MoleculeView.cpp
wxSources/MyApp.cpp
wxSources/MyApp.h
wxSources/MyDocument.cpp
wxSources/MyDocument.h

diff --git a/Documents/etc/tutorial_5_01.png b/Documents/etc/tutorial_5_01.png
new file mode 100644 (file)
index 0000000..955ea3d
Binary files /dev/null and b/Documents/etc/tutorial_5_01.png differ
index dd83497..25302b0 100644 (file)
@@ -913,7 +913,7 @@ Molby の分子力学計算は、基本的な分子力場(結合の伸縮、
 <h1>Step Five: Edit a Molecule: Using a Property Table</h1>
 <h2>1. The Property Table of a Molecule</h2>
 <p>
-A molecule has many properties. It has a set of atoms and bonds. An atom has a name, an atom type, an element, a weight (which can be derived from the element), a charge, coordinates, and so on. According to the custom in the biomolecular modeling, atoms are grouped in "residues." It also has a set of parameters used in molecular mechanics. Molby also has a limited support for quantum chemical calculations. For that purpose, a molecule in Molby can retain information such as MO coefficients.
+A molecule has many properties. It has a set of atoms and bonds. An atom has a name, an atom type, an element, a weight (which can be derived from the element), a charge, coordinates, and so on. According to the custom in the biomolecular modeling, atoms are grouped in "residues." It also has a set of parameters used in molecular mechanics. Molby also has a limited support for quantum chemical calculations. In relation to that, a molecule in Molby can retain extra information such as MO coefficients.
 </p>
 <p>
 Most of these information are accessible via the <span class="italic">property table</span>. The table is on the left side of the model window.
index f0ffc24..6abda71 100755 (executable)
@@ -2987,6 +2987,26 @@ MainView_numberOfRowsInTable(MainView *mview)
        return IntGroupGetCount(mview->tableCache);
 }
 
+int
+MainView_indexToTableRow(MainView *mview, int idx)
+{
+       if (mview == NULL)
+               return -1;
+       if (mview->tableIndex == kMainViewParameterTableIndex)
+               return -1;  /*  Not supported yet  */
+       return IntGroupLookupPoint(mview->tableCache, idx);
+}
+
+int
+MainView_tableRowToIndex(MainView *mview, int row)
+{
+       if (mview == NULL)
+               return -1;
+       if (mview->tableIndex == kMainViewParameterTableIndex)
+               return -1;  /*  Not supported yet  */
+       return IntGroupGetNthPoint(mview->tableCache, row);
+}
+
 static char *
 sAtomDescription(Atom *ap, char *buf, int bufsize)
 {
index ff0b5ce..3bdf663 100755 (executable)
@@ -190,6 +190,8 @@ void MainView_tableTitleForIndex(MainView *mview, int idx, char *buf, int bufsiz
 void MainView_createColumnsForTableAtIndex(MainView *mview, int idx);
 void MainView_refreshTable(MainView *mview);
 int MainView_numberOfRowsInTable(MainView *mview);
+int MainView_indexToTableRow(MainView *mview, int idx);
+int MainView_tableRowToIndex(MainView *mview, int row);
 void MainView_valueForTable(MainView *mview, int column, int row, char *buf, int bufsize);
 void MainView_setValueForTable(MainView *mview, int column, int row, const char *buf);
 int MainView_setColorForTable(MainView *mview, int column, int row, float *fg, float *bg);
@@ -238,6 +240,7 @@ STUB void MainViewCallback_setTableSelection(MainView *mview, IntGroup *selectio
 STUB IntGroup *MainViewCallback_getTableSelection(MainView *mview);
 STUB void MainViewCallback_showTable(MainView *mview);
 STUB void MainViewCallback_hideTable(MainView *mview);
+STUB void MainViewCallback_ensureVisible(MainView *mview, int row);
 
 /*  Register the type definition  */
 //extern void MainView_register(PyObject *module);
index de7d234..1b092d8 100644 (file)
@@ -5622,14 +5622,22 @@ s_Molecule_CreateAnAtom(int argc, VALUE *argv, VALUE self)
        char *p, resName[6], atomName[6];
        int resSeq;
     Data_Get_Struct(self, Molecule, mol);
-       rb_scan_args(argc, argv, "11", &name, &ival);
+       rb_scan_args(argc, argv, "02", &name, &ival);
        if (ival != Qnil)
                pos = NUM2INT(rb_Integer(ival));
        else pos = -1;
-    p = StringValuePtr(name);
-    i = MoleculeAnalyzeAtomName(p, resName, &resSeq, atomName);
-    if (atomName[0] == 0)
-      rb_raise(rb_eMolbyError, "bad atom name specification: %s", p);
+       if (name != Qnil) {
+               p = StringValuePtr(name);
+               if (p[0] != 0) {
+                       i = MoleculeAnalyzeAtomName(p, resName, &resSeq, atomName);
+                       if (atomName[0] == 0)
+                         rb_raise(rb_eMolbyError, "bad atom name specification: %s", p);
+               }
+       } else p = NULL;
+       if (p == NULL || p[0] == 0) {
+               memset(atomName, 0, 4);
+               resSeq = -1;
+       }
     memset(&arec, 0, sizeof(arec));
     strncpy(arec.aname, atomName, 4);
     if (resSeq >= 0) {
index fceb384..a0a145d 100755 (executable)
--- a/memo.txt
+++ b/memo.txt
@@ -185,4 +185,5 @@ rdt: (only used in LES)
 
 sander -O -i min.in -o NAME.out -p NAME.prmtop -c NAME.inpcrd -x NAME.mdcrd -r NAME.restrt
 
-
+2011.7.8.
+ MoleculeMerge(), MoleculeUnmerge() の仕様を見直した方がいい。undo サポート用に、bond/angle/dihedral/improper を指定した位置に入れる機能が欲しい。パラメータも、すべての種類のパラメータを指定した位置に入れる機能が必要。IntGroup の配列でパラメータを与えるか?
index 95e0ee0..6cf0201 100755 (executable)
@@ -1224,3 +1224,11 @@ MainViewCallback_hideTable(MainView *mview)
   //           [doc hideTable: doc];
   //   }
 }
+
+void
+MainViewCallback_ensureVisible(MainView *mview, int row)
+{
+       MyListCtrl *listctrl = s_MyListCtrlFromMainView(mview);
+       if (listctrl != NULL)
+               listctrl->EnsureVisible(row);
+}
index c2367d2..f4ef1f4 100755 (executable)
@@ -346,6 +346,17 @@ MyApp::CreateMenuBar(int kind, wxMenu **out_file_history_menu, wxMenu **out_edit
        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_CreateNewVdwOffsetParameter, _T("Vdw Offset"));
+       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"));
index 1597a49..32cdb02 100755 (executable)
@@ -48,48 +48,57 @@ enum {
        myMenuID_Export = 102,
        myMenuID_SelectFragment = 103,
        myMenuID_SelectReverse = 104,
-       myMenuID_AddHydrogen = 105,
-       myMenuID_AddHydrogenSp3 = 106,
-       myMenuID_AddHydrogenSp2 = 107,
-       myMenuID_AddHydrogenLinear = 108,
-       myMenuID_AddHydrogenPyramidal = 109,
-       myMenuID_AddHydrogenBent = 110,
-       myMenuID_FitToScreen = 120,
-       myMenuID_CenterSelection = 121,
-       myMenuID_ShowUnitCell = 122,
-       myMenuID_ShowPeriodicBox = 123,
-       myMenuID_ShowHydrogens = 124,
-       myMenuID_ShowDummyAtoms = 125,
-       myMenuID_ShowExpandedAtoms = 126,
-       myMenuID_ShowEllipsoids = 127,
-       myMenuID_ShowRotationCenter = 128,
-       myMenuID_ShowGraphite = 129,
-       myMenuID_LineMode = 130,
-       myMenuID_ShowAllAtoms = 131,
-       myMenuID_HideSelected = 132,
-       myMenuID_HideUnselected = 133,
-       myMenuID_HideReverse = 134,
-       myMenuID_MolecularDynamics = 140,
-       myMenuID_Minimize = 141,
-       myMenuID_StopMDRun = 142,
+       myMenuID_CreateNewAtom = 105,
+       myMenuID_CreateNewParameter = 106,
+       myMenuID_CreateNewVdwParameter = 107,
+       myMenuID_CreateNewBondParameter = 108,
+       myMenuID_CreateNewAngleParameter = 109,
+       myMenuID_CreateNewDihedralParameter = 110,
+       myMenuID_CreateNewImproperParameter = 111,
+       myMenuID_CreateNewVdwPairParameter = 112,
+       myMenuID_CreateNewVdwOffsetParameter = 113,
+       myMenuID_AddHydrogen = 114,
+       myMenuID_AddHydrogenSp3 = 115,
+       myMenuID_AddHydrogenSp2 = 116,
+       myMenuID_AddHydrogenLinear = 117,
+       myMenuID_AddHydrogenPyramidal = 118,
+       myMenuID_AddHydrogenBent = 119,
+       myMenuID_FitToScreen = 150,
+       myMenuID_CenterSelection = 151,
+       myMenuID_ShowUnitCell = 152,
+       myMenuID_ShowPeriodicBox = 153,
+       myMenuID_ShowHydrogens = 154,
+       myMenuID_ShowDummyAtoms = 155,
+       myMenuID_ShowExpandedAtoms = 156,
+       myMenuID_ShowEllipsoids = 157,
+       myMenuID_ShowRotationCenter = 158,
+       myMenuID_ShowGraphite = 159,
+       myMenuID_LineMode = 160,
+       myMenuID_ShowAllAtoms = 161,
+       myMenuID_HideSelected = 162,
+       myMenuID_HideUnselected = 163,
+       myMenuID_HideReverse = 164,
+       myMenuID_MolecularDynamics = 200,
+       myMenuID_Minimize = 201,
+       myMenuID_StopMDRun = 202,
 //     myMenuID_ReadParameters = 143,
-       myMenuID_ViewGlobalParameters = 144,
-       myMenuID_ViewParameterFilesList = 145,
-       myMenuID_DefinePeriodicBox = 146,
-       myMenuID_ShowPeriodicImage = 147,
-       myMenuID_PressureControl = 148,
-       myMenuID_DefineSymmetry = 149,
-       myMenuID_ExpandBySymmetry = 150,
-       myMenuID_MDTools = 151,
-       myMenuID_RunAntechamber = 152,
-       myMenuID_RunResp = 153,
-       myMenuID_CreateSanderInput = 154,
-       myMenuID_ImportAmberLib = 155,
-       myMenuID_CreateGamessInput = 160,
-       myMenuID_CreateMOCube = 161,
-       myMenuID_ExecuteScript = 200,
-       myMenuID_OpenConsoleWindow = 201,
-       myMenuID_CustomScript = 202,
+       myMenuID_ViewGlobalParameters = 204,
+       myMenuID_ViewParameterFilesList = 205,
+       myMenuID_DefinePeriodicBox = 206,
+       myMenuID_ShowPeriodicImage = 207,
+       myMenuID_PressureControl = 208,
+       myMenuID_DefineSymmetry = 209,
+       myMenuID_ExpandBySymmetry = 210,
+       myMenuID_MDTools = 211,
+       myMenuID_RunAntechamber = 212,
+       myMenuID_RunResp = 213,
+       myMenuID_CreateSanderInput = 214,
+       myMenuID_ImportAmberLib = 215,
+       myMenuID_CreateGamessInput = 250,
+       myMenuID_CreateMOCube = 251,
+       myMenuID_ExecuteScript = 300,
+       myMenuID_OpenConsoleWindow = 301,
+       myMenuID_CustomScript = 302,
        myMenuID_MyLastMenuItem = 499
 };
 
index e6d446e..da11306 100755 (executable)
@@ -73,6 +73,8 @@ BEGIN_EVENT_TABLE(MyDocument, wxDocument)
        EVT_MENU(wxID_PASTE, MyDocument::OnPaste)
        EVT_MENU(wxID_CUT, MyDocument::OnCut)
        EVT_MENU(wxID_DELETE, MyDocument::OnDelete)
+       EVT_MENU(myMenuID_CreateNewAtom, MyDocument::OnCreateNewAtom)
+       EVT_MENU_RANGE(myMenuID_CreateNewVdwParameter, myMenuID_CreateNewVdwOffsetParameter, MyDocument::OnCreateNewParameter)
        EVT_MENU(wxID_SELECTALL, MyDocument::OnSelectAll)
        EVT_MENU(myMenuID_SelectFragment, MyDocument::OnSelectFragment)
        EVT_MENU(myMenuID_SelectReverse, MyDocument::OnSelectReverse)
@@ -499,6 +501,46 @@ MyDocument::OnDelete(wxCommandEvent& event)
 }
 
 void
+MyDocument::OnCreateNewAtom(wxCommandEvent &event)
+{
+       int idx;
+       IntGroup *ig = MoleculeGetSelection(mol);
+       MainView *mview = GetMainView();
+       if (mview == NULL)
+               return;
+       MainViewCallback_selectTable(mview, kMainViewAtomTableIndex);
+       if (ig != NULL && IntGroupGetCount(ig) > 0) {
+               idx = IntGroupGetEndPoint(ig, IntGroupGetIntervalCount(ig) - 1);
+       } else {
+               idx = mol->natoms;
+       }
+       MolActionCreateAndPerform(mol, SCRIPT_ACTION("si"), "create_atom", "", idx);
+       ig = IntGroupNewWithPoints(idx, 1, -1);
+       MoleculeSetSelection(mol, ig);
+       IntGroupRelease(ig);
+       MainViewCallback_setNeedsDisplay(mview, 1);
+       MainViewCallback_reloadTableData(mview);
+       MainViewCallback_ensureVisible(mview, MainView_indexToTableRow(mview, idx));
+}
+
+void
+MyDocument::OnCreateNewParameter(wxCommandEvent &event)
+{
+/*     int uid = event.GetId();
+       const char *type;
+       IntGroup *ig;
+       switch (uid) {
+               case myMenuID_CreateNewVdwParameter: type = "td"; break;
+               case myMenuID_AddHydrogenSp2: type = "tr"; break;
+               case myMenuID_AddHydrogenLinear: type = "li"; break;
+               case myMenuID_AddHydrogenPyramidal: type = "py"; break;
+               case myMenuID_AddHydrogenBent: type = "be"; break;
+               default: return;
+       }
+ */
+}
+
+void
 MyDocument::OnSelectAll(wxCommandEvent& event)
 {
        if (wxWindow::FindFocus() == ((MoleculeView *)GetFirstView())->GetListCtrl() && mol->mview->tableIndex == kMainViewParameterTableIndex) {
index 6d0cf9b..3004520 100755 (executable)
@@ -85,6 +85,9 @@ public:
        void    OnPaste(wxCommandEvent& event);
        void    OnDelete(wxCommandEvent& event);
 
+       void    OnCreateNewAtom(wxCommandEvent &event);
+       void    OnCreateNewParameter(wxCommandEvent &event);
+       
        void    OnSelectAll(wxCommandEvent& event);
        void    OnSelectFragment(wxCommandEvent& event);
        void    OnSelectReverse(wxCommandEvent& event);