<p>
Many methods of <a href="Molecule.html">Molecule</a> are described as "undoable". This means, when such methods are invoked for a <a href="Molecule.html">Molecule</a> that has an associated document, an undo operation is automatically registered to the document.
</p>
+<h4>Graphic objects</h4>
+<a name="description-graphic-objects"></a>
+<p>
+(New in 0.6.2) Some Ruby methods allow you to handle graphic objects that are displayed in the same view as the molecule. The methods include <a href="#create_graphic">create_graphic</a>, <a href="#remove_graphic">remove_graphic</a>, <a href="#ngraphics">ngraphics</a>, <a href="#set_graphic_point">set_graphic_point</a>, <a href="#set_graphic_color">set_graphic_color</a>, <a href="#show_graphic">show_graphic</a>, and <a href="#hide_graphic">hide_graphic</a>.
+</p>
+
</div>
<div id="methods">
</div>
</div>
+<div id="method-create_graphic" class="method-detail">
+<a name="create_graphic"></a>
+<div class="method-heading">
+<span class="method-name">create_graphic(kind, color, points, fill = nil) → Integer</span>
+</div>
+<div class="method-description">
+<p>
+Create a new graphic object. Kind: a symbol representing the kind of the graphic. :line, :poly, :cylinder, :cone, :ellipsoid. Color: an array of 3 (rgb) or 4 (rgba) floating numbers. Points: an array of <a href="Vector3D.html">Vector3D</a>s.
+</p>
+<p>
+Returns the index of the newly created graphic.
+</p>
+<p>
+<i>See Also:</i> <a href="#remove_graphic">Molecule#remove_graphic</a>
+</p></div>
+</div>
+
<div id="method-M000318" class="method-detail">
<a name="M000318"></a>
<div class="method-heading">
</div>
</div>
+<div id="method-get_view_rotation" class="method-detail">
+<a name="get_view_rotation"></a>
+<div class="method-heading">
+<span class="method-name">get_view_rotation → [[ax, ay, az], angle]</span>
+</div>
+<div class="method-description">
+<p>
+Get the current rotation for the view. Angle is in degree, not radian.
+</p>
+<p>
+<i>See Also:</i> <a href="#set_view_rotation">Molecule#set_view_rotation</a>
+</p></div>
+</div>
+
+<div id="method-get_view_scale" class="method-detail">
+<a name="get_view_scale"></a>
+<div class="method-heading">
+<span class="method-name">get_view_scale → Float</span>
+</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).
+</p>
+<p>
+<i>See Also:</i> <a href="#set_view_scale">Molecule#set_view_scale</a>
+</p></div>
+</div>
+
+<div id="method-get_view_translation" class="method-detail">
+<a name="get_view_translation"></a>
+<div class="method-heading">
+<span class="method-name">get_view_translation → <a href="Vector3D.html">Vector3D</a></span>
+</div>
+<div class="method-description">
+<p>
+Get the current translation factor for the view.
+</p>
+<p>
+<i>See Also:</i> <a href="#set_view_translation">Molecule#set_view_translation</a>
+</p></div>
+</div>
+
<div id="method-M000261" class="method-detail">
<a name="M000261"></a>
<div class="method-heading">
</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) → self</span>
+</div>
+<div class="method-description">
+<p>
+Unset the visibility flag of the graphic_index-th graphic object.
+</p>
+<p>
+<i>See Also:</i> <a href="#show_graphic">Molecule#show_graphic</a>
+</p></div>
+</div>
+
<div id="method-improper-par" class="method-detail">
<a name="improper_par"></a>
<div class="method-heading">
</div>
</div>
+<div id="method-ngraphics" class="method-detail">
+<a name="ngraphics"></a>
+<div class="method-heading">
+<span class="method-name">ngraphics → Integer</span>
+</div>
+<div class="method-description">
+<p>
+Get the number of graphic objects.
+</p>
+</div>
+</div>
+
<div id="method-M000221" class="method-detail">
<a name="M000221"></a>
<div class="method-heading">
</div>
</div>
+<div id="method-remove_graphic" class="method-detail">
+<a name="remove_graphic"></a>
+<div class="method-heading">
+<span class="method-name">remove_graphic(index) → index</span>
+</div>
+<div class="method-description">
+<p>
+Remove a graphic object.
+</p>
+<p>
+<i>See Also:</i> <a href="#create_graphic">Molecule#create_graphic</a>
+</p></div>
+</div>
+
<div id="method-M000257" class="method-detail">
<a name="M000257"></a>
<div class="method-heading">
</div>
</div>
+<div id="method-set_background_color" class="method-detail">
+<a name="set_background_color"></a>
+<div class="method-heading">
+<span class="method-name">set_background_color(red, green, blue) → self</span>
+</div>
+<div class="method-description">
+<p>
+Set the background color of the model view. Red, green, blue are in the range of [0, 1].
+</p>
+</div>
+</div>
+
<div id="method-M000181" class="method-detail">
<a name="M000181"></a>
<div class="method-heading">
</div>
</div>
+<div id="method-set_graphic_color" class="method-detail">
+<a name="set_graphic_color"></a>
+<div class="method-heading">
+<span class="method-name">set_graphic_color(graphic_index, new_vaue) → new_value</span>
+</div>
+<div class="method-description">
+<p>
+Change the color of graphic_index-th graphic object. The new value must be an array-like object containing three or four numbers.
+</p>
+</div>
+</div>
+
+<div id="method-set_graphic_point" class="method-detail">
+<a name="set_graphic_point"></a>
+<div class="method-heading">
+<span class="method-name">set_graphic_point(graphic_index, point_index, new_value) → new_value</span>
+</div>
+<div class="method-description">
+<p>
+Change the point_index-th control point of graphic_index-th graphic object. If the object is a line strip, nil is allowed for the new value, which means the line strip ends at the last point.
+</p>
+</div>
+</div>
+
<div id="method-M000264" class="method-detail">
<a name="M000264"></a>
<div class="method-heading">
</div>
</div>
+<div id="method-set_view_rotation" class="method-detail">
+<a name="set_view_rotation"></a>
+<div class="method-heading">
+<span class="method-name">set_view_rotation(axis, angle) → self</span>
+</div>
+<div class="method-description">
+<p>
+Set the current rotation for the view. Axis is a <a href="Vector3D.html">Vector3D</a> or an object that can be transformed to a <a href="Vector3D.html">Vector3D</a>. Angle is in degree, not radian.
+</p>
+<p>
+<i>See Also:</i> <a href="#get_view_rotation">Molecule#get_view_rotation</a>
+</p></div>
+</div>
+
+<div id="method-set_view_scale" class="method-detail">
+<a name="set_view_scale"></a>
+<div class="method-heading">
+<span class="method-name">set_view_scale(scale) → self</span>
+</div>
+<div class="method-description">
+<p>
+Set the current scale for the view. For detailed description of the scale parameter, see <a href="#get_view_scale">Molecule#get_view_scale</a>.
+</p>
+<p>
+<i>See Also:</i> <a href="#get_view_scale">Molecule#get_view_scale</a>
+</p></div>
+</div>
+
+<div id="method-set_view_translation" class="method-detail">
+<a name="set_view_translation"></a>
+<div class="method-heading">
+<span class="method-name">set_view_translation(vec) → self</span>
+</div>
+<div class="method-description">
+<p>
+Set the current translation for the view.
+</p>
+<p>
+<i>See Also:</i> <a href="#get_view_translation">Molecule#get_view_translation</a>
+</p></div>
+</div>
+
<div id="method-M000301" class="method-detail">
<a name="M000301"></a>
<div class="method-heading">
</div>
</div>
+<div id="method-show_graphic" class="method-detail">
+<a name="show_graphic"></a>
+<div class="method-heading">
+<span class="method-name">show_graphic(graphic_index) → self</span>
+</div>
+<div class="method-description">
+<p>
+Set the visibility flag of the graphic_index-th graphic object.
+</p>
+<p>
+<i>See Also:</i> <a href="#hide_graphic">Molecule#hide_graphic</a>
+</p></div>
+</div>
+
<div id="method-M000307" class="method-detail">
<a name="M000307"></a>
<div class="method-heading">
self.show_graphite = Integer<br />
</span>
</div>
-
<div class="method-description">
<p>
Set whether to show the graphite plane. The plane is assumed to be on the xy plane. If the argument is positive, it also indicates the number of rings to display for each direction. If the argument is zero, the plane is not displayed. If no argument is given, the current value is returned.
</div>
</body>
-</html>
\ No newline at end of file
+</html>
/*
* call-seq:
- * delete_graphic(index) -> integer
+ * remove_graphic(index) -> integer
*
- * Delete a graphic object.
+ * Remove a graphic object.
*/
static VALUE
-s_Molecule_DeleteGraphic(VALUE self, VALUE ival)
+s_Molecule_RemoveGraphic(VALUE self, VALUE ival)
{
Molecule *mol;
int i;
i = NUM2INT(rb_Integer(ival));
if (i < 0 || i >= mol->mview->ngraphics)
rb_raise(rb_eArgError, "graphic index is out of range");
- MainView_deleteGraphic(mol->mview, i);
+ MainView_removeGraphic(mol->mview, i);
return ival;
}
rb_define_method(rb_cMolecule, "line_mode", s_Molecule_LineMode, -1);
rb_define_alias(rb_cMolecule, "line_mode=", "line_mode");
rb_define_method(rb_cMolecule, "resize_to_fit", s_Molecule_ResizeToFit, 0);
+#if !defined(__CMDMAC__)
rb_define_method(rb_cMolecule, "get_view_rotation", s_Molecule_GetViewRotation, 0);
rb_define_method(rb_cMolecule, "get_view_scale", s_Molecule_GetViewScale, 0);
rb_define_method(rb_cMolecule, "get_view_translation", s_Molecule_GetViewTranslation, 0);
rb_define_method(rb_cMolecule, "set_view_translation", s_Molecule_SetViewTranslation, 1);
rb_define_method(rb_cMolecule, "set_background_color", s_Molecule_SetBackgroundColor, -1);
rb_define_method(rb_cMolecule, "create_graphic", s_Molecule_CreateGraphic, -1);
- rb_define_method(rb_cMolecule, "delete_graphic", s_Molecule_DeleteGraphic, 1);
+ rb_define_method(rb_cMolecule, "remove_graphic", s_Molecule_RemoveGraphic, 1);
rb_define_method(rb_cMolecule, "ngraphics", s_Molecule_NGraphics, 0);
rb_define_method(rb_cMolecule, "set_graphic_point", s_Molecule_SetGraphicPoint, 3);
rb_define_method(rb_cMolecule, "set_graphic_color", s_Molecule_SetGraphicColor, 2);
rb_define_method(rb_cMolecule, "show_graphic", s_Molecule_ShowGraphic, 1);
rb_define_method(rb_cMolecule, "hide_graphic", s_Molecule_HideGraphic, 1);
+#endif
rb_define_method(rb_cMolecule, "show_text", s_Molecule_ShowText, 1);
rb_define_method(rb_cMolecule, "md_arena", s_Molecule_MDArena, 0);
rb_define_method(rb_cMolecule, "set_parameter_attr", s_Molecule_SetParameterAttr, 5);