OSDN Git Service

Molecule#is_atom_hidden and AtomRef#hidden, hidden= are implemented, and Molecule...
authortoshinagata1964 <toshinagata1964@a2be9bc6-48de-4e38-9406-05402d4bc13c>
Tue, 26 Jun 2012 11:57:25 +0000 (11:57 +0000)
committertoshinagata1964 <toshinagata1964@a2be9bc6-48de-4e38-9406-05402d4bc13c>
Tue, 26 Jun 2012 11:57:25 +0000 (11:57 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/molby/trunk@236 a2be9bc6-48de-4e38-9406-05402d4bc13c

Documents/src/molby_rb/AtomRef.html
Documents/src/molby_rb/Molecule.html
MolLib/Ruby_bind/ruby_bind.c

index 6379112..311d07d 100644 (file)
@@ -343,6 +343,21 @@ Get/set the fractional coordinate z. If the crystallographic unit cell is not de
 </div>
 
 <div id="method-atom_type" class="method-detail">
+<a name="hidden"></a>
+<div class="method-heading">
+<span class="method-name">
+hidden       &rarr; Boolean<br />
+self.hidden = Boolean<br />
+</span>
+</div>
+<div class="method-description">
+<p>
+Get/set the hidden flag. This is an atom attribute, and is independent with the Molecule attribute such as <a href="Molecule.html#show_hydrogens">Molecule#show_hydrogens</a>, <a href="Molecule.html#show_dummy_atoms">Molecule#show_dummy_atoms</a> and <a href="Molecule.html#show_expanded">Molecule#show_expanded</a>. If you want to examine the visibility of an atom by taking these attributes into consideration, try <a href="Molecule.html#is_atom_visible">Molecule#is_atom_visible</a>.
+</p>
+</div>
+</div>
+
+<div id="method-atom_type" class="method-detail">
 <a name="index"></a>
 <div class="method-heading">
 <span class="method-name">
index c32b9a1..d7a7b84 100644 (file)
@@ -1345,7 +1345,7 @@ Get the current rotation for the view. Angle is in degree, not radian. The sign
 </div>
 <div class="method-description">
 <p>
-Get the current scale for the view. Scale is expressed with a floating-point number in the range -5.0 to 5.0. The scale parameter is transformed to perspective parameters (fovy and distance) in the following way: for negative scale, fovy = 30 deg and distance = cot(15) * 10^(-scale); for positive scale, fovy = 30 * 10^(-scale) and distance = cot(15).
+Get the current scale for the view. Scale is expressed with a dimensionless floating-point number in the range -5.0 to 5.0. The scale parameter is transformed to perspective parameters (fovy and distance) in the following way: for negative scale, fovy = 30 degree and distance = cot(15) * 10^(-scale) * 10 &Aring;; for positive scale, fovy = 30 * 10^(-scale) degree and distance = cot(15) * 10 &Aring;.
 </p>
 <p>
 <i>See Also:</i> <a href="#set_view_scale">Molecule#set_view_scale</a>
@@ -1380,36 +1380,6 @@ Create bonds between atoms that are within the threshold distance. If limit is a
 </div>
 
 <div id="method-hide_graphic" class="method-detail">
-<a name="hidden_atoms"></a>
-<div class="method-heading">
-<span class="method-name">hidden_atoms &rarr; <a href="IntGroup.html">IntGroup</a></span>
-</div>
-<div class="method-description">
-<p>
-Returns a list of currently hidden atoms.
-</p>
-<p>
-<i>See Also:</i> <a href="#set_hidden_atoms">Molecule#hidden_atoms=</a>
-</p></div>
-</div>
-
-<div id="method-hide_graphic" class="method-detail">
-<a name="set_hidden_atoms"></a>
-<div class="method-heading">
-<span class="method-name">self.hidden_atoms = <a href="IntGroup.html">IntGroup</a><br />
-set_hidden_atoms(<a href="IntGroup.html">IntGroup</a>)
-</span>
-</div>
-<div class="method-description">
-<p>
-Hide the specified atoms. Note: this operation is _not_ undoable.
-</p>
-<p>
-<i>See Also:</i> <a href="#hidden_atoms">Molecule#hidden_atoms</a>
-</p></div>
-</div>
-
-<div id="method-hide_graphic" class="method-detail">
 <a name="hide_graphic"></a>
 <div class="method-heading">
 <span class="method-name">hide_graphic(graphic_index) &rarr; self</span>
@@ -1510,6 +1480,19 @@ Invert the molecule with the given center. If group is given, only the atoms in
 </div>
 </div>
 
+<div id="method-M000284" class="method-detail">
+<a name="is_atom_hidden"></a>
+<div class="method-heading">
+<span class="method-name">is_atom_hidden(index)       &rarr; Boolean<br />
+</span>
+</div>
+<div class="method-description">
+<p>
+Check whether the atom is visible or not. Unlike <a href="AtomRef.html#hidden">AtomRef#hidden</a>, this method takes care of the Molecule attributes <a href="Molecule.html#show_hydrogens">show_hydrogens</a>, <a href="Molecule.html#show_expanded">show_expanded</a> and <a href="Molecule.html#show_dummy_atoms">show_dummy_atoms</a>. 
+</p>
+</div>
+</div>
+
 <div id="method-M000311" class="method-detail">
 <a name="M000311"></a>
 <div class="method-heading">
index f3de893..726aedf 100644 (file)
@@ -69,7 +69,8 @@ static VALUE
        s_SigmaSym, s_SigmaXSym, s_SigmaYSym, s_SigmaZSym,
        s_VSym, s_FSym, s_OccupancySym, s_TempFactorSym,
        s_AnisoSym, s_SymopSym, s_IntChargeSym, s_FixForceSym,
-       s_FixPosSym, s_ExclusionSym, s_MMExcludeSym, s_PeriodicExcludeSym;
+       s_FixPosSym, s_ExclusionSym, s_MMExcludeSym, s_PeriodicExcludeSym,
+       s_HiddenSym;
 
 /*  Symbols for parameter attributes  */
 static VALUE
@@ -3482,6 +3483,10 @@ static VALUE s_AtomRef_GetPeriodicExclude(VALUE self) {
        return INT2NUM(s_AtomFromValue(self)->periodic_exclude);
 }
 
+static VALUE s_AtomRef_GetHidden(VALUE self) {
+       return ((s_AtomFromValue(self)->exflags & kAtomHiddenFlag) != 0 ? Qtrue : Qfalse);
+}
+
 static VALUE s_AtomRef_SetIndex(VALUE self, VALUE val) {
        rb_raise(rb_eMolbyError, "index cannot be directly set");
        return Qnil;
@@ -3920,6 +3925,18 @@ static VALUE s_AtomRef_SetPeriodicExclude(VALUE self, VALUE val) {
        return val;
 }
 
+static VALUE s_AtomRef_SetHidden(VALUE self, VALUE val) {
+       Atom *ap = s_AtomFromValue(self);
+       VALUE oval = ((ap->exflags & kAtomHiddenFlag) != 0 ? Qtrue : Qfalse);
+       if (RTEST(val)) {
+               ap->exflags |= kAtomHiddenFlag;
+       } else {
+               ap->exflags &= ~kAtomHiddenFlag;
+       }
+       s_RegisterUndoForAtomAttrChange(self, s_HiddenSym, val, oval);
+       return val;
+}
+
 static struct s_AtomAttrDef {
        char *name;
        VALUE *symref;  /*  Address of s_IndexSymbol etc. */
@@ -3963,6 +3980,7 @@ static struct s_AtomAttrDef {
        {"exclusion",    &s_ExclusionSym,    0, s_AtomRef_GetExclusion,    s_AtomRef_SetExclusion},
        {"mm_exclude",   &s_MMExcludeSym,    0, s_AtomRef_GetMMExclude,    s_AtomRef_SetMMExclude},
        {"periodic_exclude", &s_PeriodicExcludeSym, 0, s_AtomRef_GetPeriodicExclude, s_AtomRef_SetPeriodicExclude},
+       {"hidden",       &s_HiddenSym,       0, s_AtomRef_GetHidden,       s_AtomRef_SetHidden},
        {NULL} /* Sentinel */
 };
 
@@ -6617,7 +6635,9 @@ s_Molecule_SetUndoableSelection(VALUE self, VALUE val)
 static VALUE
 s_Molecule_HiddenAtoms(VALUE self)
 {
-    Molecule *mol;
+       rb_raise(rb_eMolbyError, "set_hidden_atoms is now obsolete. Try using Molecule#is_atom_visible or AtomRef#hidden.");
+       return Qnil;  /*  Not reached  */
+/*    Molecule *mol;
        IntGroup *ig;
        VALUE val;
     Data_Get_Struct(self, Molecule, mol);
@@ -6633,7 +6653,7 @@ s_Molecule_HiddenAtoms(VALUE self)
                IntGroupRelease(ig);
                rb_obj_freeze(val);
                return val;
-       } else return Qnil;
+       } else return Qnil; */
 }
 
 /*
@@ -6646,6 +6666,9 @@ s_Molecule_HiddenAtoms(VALUE self)
 static VALUE
 s_Molecule_SetHiddenAtoms(VALUE self, VALUE val)
 {
+       rb_raise(rb_eMolbyError, "set_hidden_atoms is now obsolete. Try using Molecule#is_atom_visible or AtomRef#hidden.");
+       return Qnil;  /*  Not reached  */
+/*
        Molecule *mol;
     Data_Get_Struct(self, Molecule, mol);
        if (mol != NULL) {
@@ -6667,7 +6690,7 @@ s_Molecule_SetHiddenAtoms(VALUE self, VALUE val)
                        IntGroupRelease(ig);
                MoleculeCallback_notifyModification(mol, 0);
        }
-       return val;
+       return val; */
 }
 
 /*
@@ -8166,6 +8189,35 @@ s_Molecule_ShowEllipsoids(int argc, VALUE *argv, VALUE self)
 
 /*
  *  call-seq:
+ *     is_atom_visible(index)  -> Boolean
+ *
+ *  Check is an atom is visible. It examines the atom attribute (ap->exflags & kAtomHiddenFlag)
+ *  as well as the molecule attributes (showHydrogens, etc.)
+ */
+static VALUE
+s_Molecule_IsAtomVisible(VALUE self, VALUE ival)
+{
+       Molecule *mol;
+       Int idx;
+       Atom *ap;
+    Data_Get_Struct(self, Molecule, mol);
+       idx = s_Molecule_AtomIndexFromValue(mol, ival);
+       if (idx < 0 || idx >= mol->natoms)
+               return Qnil;
+       ap = ATOM_AT_INDEX(mol->atoms, idx);
+       if (mol->mview != NULL) {
+               if (mol->mview->showHydrogens == 0 && ap->atomicNumber == 1)
+                       return Qfalse;
+               if (mol->mview->showExpandedAtoms == 0 && SYMOP_ALIVE(ap->symop))
+                       return Qfalse;
+               if (mol->mview->showDummyAtoms == 0 && ap->atomicNumber == 0)
+                       return Qfalse;
+       }
+       return ((ap->exflags & kAtomHiddenFlag) != 0 ? Qfalse : Qtrue);
+}
+
+/*
+ *  call-seq:
  *     show_graphite -> Integer
  *     show_graphite = Integer
  *     show_graphite = boolean
@@ -9400,9 +9452,9 @@ Init_Molby(void)
        rb_define_method(rb_cMolecule, "selection", s_Molecule_Selection, 0);
        rb_define_method(rb_cMolecule, "selection=", s_Molecule_SetSelection, 1);
        rb_define_method(rb_cMolecule, "set_undoable_selection", s_Molecule_SetUndoableSelection, 1);
-       rb_define_method(rb_cMolecule, "hidden_atoms", s_Molecule_HiddenAtoms, 0);
-       rb_define_method(rb_cMolecule, "hidden_atoms=", s_Molecule_SetHiddenAtoms, 1);  
-       rb_define_alias(rb_cMolecule, "set_hidden_atoms", "hidden_atoms=");
+       rb_define_method(rb_cMolecule, "hidden_atoms", s_Molecule_HiddenAtoms, 0);  /*  obsolete  */
+       rb_define_method(rb_cMolecule, "hidden_atoms=", s_Molecule_SetHiddenAtoms, 1);  /*  obsolete  */
+       rb_define_alias(rb_cMolecule, "set_hidden_atoms", "hidden_atoms=");  /*  obsolete  */
        rb_define_method(rb_cMolecule, "frame", s_Molecule_Frame, 0);
        rb_define_method(rb_cMolecule, "frame=", s_Molecule_SelectFrame, 1);
        rb_define_alias(rb_cMolecule, "select_frame", "frame=");
@@ -9451,6 +9503,7 @@ Init_Molby(void)
        rb_define_method(rb_cMolecule, "show_dummy_atoms=", s_Molecule_ShowDummyAtoms, -1);
        rb_define_method(rb_cMolecule, "show_expanded", s_Molecule_ShowExpanded, -1);
        rb_define_method(rb_cMolecule, "show_expanded=", s_Molecule_ShowExpanded, -1);
+       rb_define_method(rb_cMolecule, "is_atom_visible", s_Molecule_IsAtomVisible, 1);
        rb_define_method(rb_cMolecule, "show_ellipsoids", s_Molecule_ShowEllipsoids, -1);
        rb_define_method(rb_cMolecule, "show_ellipsoids=", s_Molecule_ShowEllipsoids, -1);
        rb_define_method(rb_cMolecule, "show_graphite", s_Molecule_ShowGraphite, -1);