• R/O
  • HTTP
  • SSH
  • HTTPS

Molby: コミット

Molecular Modeling Software


コミットメタ情報

リビジョンbfdab78aabad347d26f72ec0fa33ebfe9275c563 (tree)
日時2014-10-06 23:36:44
作者toshinagata1964 <toshinagata1964@a2be...>
コミッターtoshinagata1964

ログメッセージ

The settings in the MO surface dialog is now kept after closing the dialog

git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/molby/trunk@579 a2be9bc6-48de-4e38-9406-05402d4bc13c

変更サマリ

差分

--- a/MolLib/MainView.c
+++ b/MolLib/MainView.c
@@ -1233,7 +1233,7 @@ drawSurface(MainView *mview)
12331233 int i, sn, k;
12341234 GLfloat rgba[4];
12351235 MCube *mc;
1236- if (mview->mol == NULL || mview->mol->mcube == NULL)
1236+ if (mview->mol == NULL || mview->mol->mcube == NULL || mview->mol->mcube->hidden != 0)
12371237 return;
12381238 mc = mview->mol->mcube;
12391239 for (sn = 0; sn <= 1; sn++) {
--- a/MolLib/Molecule.h
+++ b/MolLib/Molecule.h
@@ -255,6 +255,7 @@ typedef struct MCubePoint {
255255 } MCubePoint;
256256
257257 typedef struct MCube {
258+ char hidden; /* If non-zero, then this MCube is not drawn */
258259 Int idn; /* MO number */
259260 Vector origin; /* Cube origin */
260261 Double dx, dy, dz; /* Cube steps */
--- a/MolLib/Ruby_bind/ruby_bind.c
+++ b/MolLib/Ruby_bind/ruby_bind.c
@@ -10226,6 +10226,58 @@ s_Molecule_Cubegen(int argc, VALUE *argv, VALUE self)
1022610226
1022710227 /*
1022810228 * call-seq:
10229+ * clear_surface
10230+ *
10231+ * Clear the MO surface if present.
10232+ */
10233+static VALUE
10234+s_Molecule_ClearSurface(VALUE self)
10235+{
10236+ Molecule *mol;
10237+ Data_Get_Struct(self, Molecule, mol);
10238+ if (mol->mcube != NULL)
10239+ MoleculeClearMCube(mol, 0, 0, 0, NULL, 0.0, 0.0, 0.0);
10240+ return self;
10241+}
10242+
10243+/*
10244+ * call-seq:
10245+ * hide_surface
10246+ *
10247+ * Hide the MO surface if present.
10248+ */
10249+static VALUE
10250+s_Molecule_HideSurface(VALUE self)
10251+{
10252+ Molecule *mol;
10253+ Data_Get_Struct(self, Molecule, mol);
10254+ if (mol->mcube != NULL) {
10255+ mol->mcube->hidden = 1;
10256+ MoleculeCallback_notifyModification(mol, 0);
10257+ }
10258+ return self;
10259+}
10260+
10261+/*
10262+ * call-seq:
10263+ * show_surface
10264+ *
10265+ * Show the MO surface if present.
10266+ */
10267+static VALUE
10268+s_Molecule_ShowSurface(VALUE self)
10269+{
10270+ Molecule *mol;
10271+ Data_Get_Struct(self, Molecule, mol);
10272+ if (mol->mcube != NULL) {
10273+ mol->mcube->hidden = 0;
10274+ MoleculeCallback_notifyModification(mol, 0);
10275+ }
10276+ return self;
10277+}
10278+
10279+/*
10280+ * call-seq:
1022910281 * create_surface(mo, attr = nil)
1023010282 *
1023110283 * Create a MO surface. The argument mo is the MO index (1-based); if mo is negative,
@@ -11555,6 +11607,9 @@ Init_Molby(void)
1155511607 rb_define_method(rb_cMolecule, "selected_MO", s_Molecule_SelectedMO, 0);
1155611608 rb_define_method(rb_cMolecule, "default_MO_grid", s_Molecule_GetDefaultMOGrid, -1);
1155711609 rb_define_method(rb_cMolecule, "cubegen", s_Molecule_Cubegen, -1);
11610+ rb_define_method(rb_cMolecule, "clear_surface", s_Molecule_ClearSurface, 0);
11611+ rb_define_method(rb_cMolecule, "show_surface", s_Molecule_ShowSurface, 0);
11612+ rb_define_method(rb_cMolecule, "hide_surface", s_Molecule_HideSurface, 0);
1155811613 rb_define_method(rb_cMolecule, "create_surface", s_Molecule_CreateSurface, -1);
1155911614 rb_define_method(rb_cMolecule, "set_surface_attr", s_Molecule_SetSurfaceAttr, 1);
1156011615 rb_define_method(rb_cMolecule, "nelpots", s_Molecule_NElpots, 0);
--- a/Scripts/commands.rb
+++ b/Scripts/commands.rb
@@ -220,8 +220,14 @@ class Molecule
220220 end
221221
222222 def cmd_create_surface
223+ if @surface_dialog_attr == nil
224+ @surface_dialog_attr = Hash.new
225+ @surface_dialog_attr["hidden"] = -1
226+ end
227+ surface_dialog_attr = @surface_dialog_attr
223228 mol = self
224229 mol.open_auxiliary_window("MO Surface", nil, nil, :resizable=>true, :has_close_box=>true) {
230+ tags = ["mo_ao", "mo", "color", "opacity", "threshold", "expand", "grid"]
225231 motype = mol.get_mo_info(:type)
226232 alpha = mol.get_mo_info(:alpha)
227233 beta = mol.get_mo_info(:beta)
@@ -273,6 +279,23 @@ class Molecule
273279 end
274280 tabvals.push([a, n, label, a_idx])
275281 }
282+ on_update_attr = lambda {
283+ tags.each { |tag|
284+ surface_dialog_attr[tag] = item_with_tag(tag)[:value]
285+ }
286+ it = item_with_tag("hide")
287+ case surface_dialog_attr["hidden"]
288+ when -1
289+ it[:title] = "Hide"
290+ it[:enabled] = false
291+ when 0
292+ it[:title] = "Hide"
293+ it[:enabled] = true
294+ when 1
295+ it[:title] = "Show"
296+ it[:enabled] = true
297+ end
298+ }
276299 on_get_value = lambda { |it, row, col|
277300 if col < 3
278301 tabvals[row][col]
@@ -320,6 +343,7 @@ class Molecule
320343 }
321344 item_with_tag("update")[:enabled] = should_update
322345 end
346+ on_update_attr.call
323347 }
324348 on_mo_action = lambda { |it|
325349 mo = it[:value]
@@ -355,6 +379,7 @@ class Molecule
355379 end
356380 item_with_tag("table")[:refresh] = true
357381 on_action.call(it)
382+ on_update_attr.call
358383 }
359384 on_set_action = lambda { |it|
360385 if mo_ao != it[:value]
@@ -407,6 +432,7 @@ class Molecule
407432 h["mo"] = nil # "Update" button is forced to be enabled
408433 on_mo_action.call(it0)
409434 end
435+ on_update_attr.call
410436 }
411437 on_update = lambda { |it|
412438 h.each_key { |key|
@@ -434,7 +460,10 @@ class Molecule
434460 mol.set_mo_coefficients(0, 0.0, coeffs)
435461 end
436462 mol.create_surface(idx, :npoints=>grid, :color=>color, :thres=>thres, :expand=>expand, :color0=>color0)
463+ mol.show_surface
437464 on_action.call(it)
465+ surface_dialog_attr["hidden"] = 0
466+ on_update_attr.call
438467 }
439468 layout(1,
440469 layout(2,
@@ -459,10 +488,37 @@ class Molecule
459488 :on_count=> lambda { |it| tabvals.count },
460489 :on_get_value=>on_get_value,
461490 :flex=>[0,0,0,0,1,1]),
462- item(:button, :tag=>"update", :title=>"Update", :action=>on_update, :flex=>[0,1,0,0,0,0]),
491+ layout(3,
492+ item(:button, :tag=>"update", :title=>"Update", :action=>on_update),
493+ item(:button, :tag=>"clear", :title=>"Clear", :action=>lambda { |it|
494+ mol.clear_surface
495+ item_with_tag("update")[:enabled] = true
496+ surface_dialog_attr["hidden"] = -1
497+ on_update_attr.call
498+ } ),
499+ item(:button, :tag=>"hide", :title=>"Hide", :action=>lambda { |it|
500+ case surface_dialog_attr["hidden"]
501+ when 0
502+ surface_dialog_attr["hidden"] = 1
503+ mol.hide_surface
504+ when 1
505+ surface_dialog_attr["hidden"] = 0
506+ mol.show_surface
507+ end
508+ on_update_attr.call
509+ } ),
510+ :flex=>[0,1,0,0,0,0]),
463511 :flex=>[0,0,0,0,1,1]
464512 )
513+ tags.each { |tag|
514+ if (val = surface_dialog_attr[tag]) != nil
515+ item_with_tag(tag)[:value] = val
516+ end
517+ }
518+ mo_idx = surface_dialog_attr["mo"]
519+ on_update_attr.call
465520 on_set_action.call(item_with_tag("mo_ao"))
521+ item_with_tag("mo")[:value] = surface_dialog_attr["mo"] = mo_idx
466522 size = self.size
467523 set_min_size(size[0], 250)
468524 item_with_tag("table")[:refresh] = true
旧リポジトリブラウザで表示