atomes 1.1.15
atomes: an atomic scale modeling tool box
Loading...
Searching...
No Matches
dlp_edit.c
Go to the documentation of this file.
1/* This file is part of the 'atomes' software
2
3'atomes' is free software: you can redistribute it and/or modify it under the terms
4of the GNU Affero General Public License as published by the Free Software Foundation,
5either version 3 of the License, or (at your option) any later version.
6
7'atomes' is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
8without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9See the GNU General Public License for more details.
10
11You should have received a copy of the GNU Affero General Public License along with 'atomes'.
12If not, see <https://www.gnu.org/licenses/>
13
14Copyright (C) 2022-2024 by CNRS and University of Strasbourg */
15
22/*
23* This file: 'dlp_edit.c'
24*
25* Contains:
26*
27
28 - The functions to edit DL-POLY force field parameters
29
30*
31* List of functions:
32
33 int get_num_vdw_max ();
34
35 gboolean are_identical_prop (int ti, int ai, field_prop * pro_a, field_prop * pro_b);
36 gboolean tersoff_question ();
37 gboolean body_identicals (field_nth_body * body, int nbd, int * na, int ** ma, int ** ba);
38
39 gchar * get_this_vdw_string ();
40 gchar * field_str (int a);
41 gchar * body_str (int a);
42 gchar * get_body_element_name (field_nth_body * body, int aid, int nbd);
43
44 void adjust_field_prop (int fil, int sti, field_prop * tmp, int * ids, int key);
45 void select_atom_set_color (GtkCellRenderer * renderer, int i);
46 void select_atom_set_cmv (GtkTreeViewColumn * col, GtkCellRenderer * renderer, GtkTreeModel * mod, GtkTreeIter * iter, gpointer data);
47 void update_field_dist (float v);
48 void adjust_vdw_interactions (gboolean add_shell);
49 void edit_parameters (int f, int id);
50 void update_tersoffs (int id, int key);
51 void check_tersoffs (int id, int key);
52
53 G_MODULE_EXPORT void update_atom_parameter (GtkEntry * res, gpointer data);
54 G_MODULE_EXPORT void update_field_parameter (GtkEntry * res, gpointer data);
55 G_MODULE_EXPORT void update_cross_parameter (GtkEntry * res, gpointer data);
56 G_MODULE_EXPORT void changed_cross_combo (GtkComboBox * box, gpointer data);
57 G_MODULE_EXPORT void changed_field_key_combo (GtkComboBox * box, gpointer data);
58 G_MODULE_EXPORT void visualize_it (GtkCheckButton * but, gpointer data);
59 G_MODULE_EXPORT void visualize_it (GtkToggleButton * but, gpointer data);
60 G_MODULE_EXPORT void select_it (GtkCheckButton * but, gpointer data);
61 G_MODULE_EXPORT void select_it (GtkToggleButton * but, gpointer data);
62 G_MODULE_EXPORT void field_molecule_select_atom_id (GtkCellRendererToggle * cell_renderer, gchar * string_path, gpointer data);
63 G_MODULE_EXPORT void edit_unit_weight (GtkCellRendererText * cell, gchar * path_string, gchar * new_text, gpointer data);
64 G_MODULE_EXPORT void select_atom_id_from_fied_molecule (GtkButton * but, gpointer data);
65 G_MODULE_EXPORT void selection_button (GtkButton * but, gpointer data);
66 G_MODULE_EXPORT void changed_atom_combo (GtkComboBox * box, gpointer data);
67 G_MODULE_EXPORT void shell_in_vdw (GtkCheckButton * but, gpointer data);
68 G_MODULE_EXPORT void shell_in_vdw (GtkToggleButton * but, gpointer data);
69 G_MODULE_EXPORT void run_edit_parameters (GtkDialog * dialog, gint response_id, gpointer data);
70 G_MODULE_EXPORT void edit_field_prop (GSimpleAction * action, GVariant * parameter, gpointer data);
71 G_MODULE_EXPORT void add_field_prop (GSimpleAction * action, GVariant * parameter, gpointer data);
72 G_MODULE_EXPORT void remove_field_prop (GSimpleAction * action, GVariant * parameter, gpointer data);
73
74 GtkWidget * combo_cross (field_nth_body * body);
75 GtkWidget * parameters_box (int obj, int key, gchar ** words, float * data);
76 GtkWidget * param_prop_param_box (int pid);
77
78*/
79
80#include "global.h"
81#include "interface.h"
82#include "glwindow.h"
83#include "glview.h"
84#include "dlp_field.h"
85#include "calc.h"
86
87extern int * atoms_id;
88extern int ** atoms_id_list;
89extern char *** ff_atoms;
90
91extern gchar * felemts[MAXDATA+1];
92extern gchar * elemts[MAXDATA];
93extern gchar * mo_title[8];
94
95extern int fetypes[2][16];
96
97extern void clean_up_molecules_info (gboolean usel);
98extern void select_object (int id, int jd, int kd);
99extern G_MODULE_EXPORT void run_add_atom_dialog (GtkDialog * add_dialog, gint response_id, gpointer data);
100extern void field_selection (int i, int viz, int lab, int aid);
101extern void field_unselect_all ();
102extern void compare_non_bonded (gchar * fatom);
103extern void visualize_single_struct (int id, int jd, int kd, int * ids);
104extern void visualize_body (int viz, int bd, field_nth_body * body);
105extern void init_default_shaders (glwin * view);
106extern GtkWidget * create_field_prop_combo (int f, int is_moy);
107extern void check_atom_for_updates ();
109extern GtkWidget * ff_p_combo[2];
110
111GtkWidget * field_key_combo;
112GtkWidget * p_box;
113GtkWidget * cross_vbox, * cross_hbox;
114GtkWidget * param_box;
115GtkWidget * img_but[4];
116GtkWidget * shell_but;
117
118GtkWidget * shell_hbox[3];
119GtkWidget * shell_cbox[2];
120GtkWidget * body_lab;
121GtkWidget * afftype;
124
135gboolean are_identical_prop (int ti, int ai, field_prop * pro_a, field_prop * pro_b)
136{
137 if (pro_a -> key != pro_b -> key) return FALSE;
138 if (pro_a -> use != pro_b -> use) return FALSE;
139 if (pro_a -> show != pro_b -> show) return FALSE;
140 int i;
141 /*for (i=0; i<ai; i++)
142 {
143 if (pro_a -> aid[i] != pro_b -> aid[i]) return FALSE;
144 }*/
145 for (i=0; i<fvalues[activef][ti][pro_a -> key]; i++)
146 {
147 if (pro_a -> val[i] != pro_b -> val[i]) return FALSE;
148 }
149 return TRUE;
150}
151
163void adjust_field_prop (int fil, int sti, field_prop * tmp, int * ids, int key)
164{
165 int i, j, k, l;
166 gboolean add;
167 add = FALSE;
168 field_prop * pro, * ptmp;
169 if (ids[0] < 0)
170 {
171 // Default prop
172 if (tmp == NULL)
173 {
174 // New val for default field prop
175 tmp_fstr -> def = init_field_prop (fil, key, tmp_fstr -> def -> show, tmp_fstr -> def -> use);
176 }
177 else
178 {
179 tmp_fstr -> def = duplicate_field_prop (tmp, fil);
180 }
181 }
182 else
183 {
184 // Not default, between specified atoms
185 if (tmp != NULL)
186 {
187 pro = get_active_prop_using_atoms (tmp_fstr -> other, sti, ids);
188 if (pro == NULL)
189 {
190 // No 'other' yet, but is it identical to default ?
191 if (! are_identical_prop (fil+1, sti, tmp, tmp_fstr -> def))
192 {
193 add = TRUE;
194 }
195 }
196 else if (! are_identical_prop (fil+1, sti, tmp, pro))
197 {
198 add = TRUE;
199 }
200 }
201 else
202 {
203 if (tmp_fstr -> other == NULL)
204 {
205 add = TRUE;
206 j = key;
207 k = tmp_fstr -> def -> show;
208 l = tmp_fstr -> def -> use;
209 }
210 else
211 {
212 pro = get_active_prop_using_atoms (tmp_fstr -> other, sti, ids);
213 if (pro == NULL)
214 {
215 if (key != tmp_fstr -> def -> key)
216 {
217 add = TRUE;
218 j = key;
219 k = tmp_fstr -> def -> show;
220 l = tmp_fstr -> def -> use;
221 }
222 }
223 else if (key != pro -> key)
224 {
225 add = TRUE;
226 j = key;
227 }
228 }
229 }
230
231 if (add)
232 {
233 if (tmp_fstr -> other == NULL)
234 {
235 if (tmp != NULL)
236 {
237 tmp_fstr -> other = duplicate_field_prop (tmp, fil);
238 }
239 else
240 {
241 tmp_fstr -> other = init_field_prop (fil, j, k, l);
242 for (i=0; i<sti; i++) tmp_fstr -> other -> aid[i] = ids[i];
243 }
244 }
245 else if (pro == NULL)
246 {
247 pro = tmp_fstr -> other;
248 while (pro -> next != NULL) pro = pro -> next;
249 if (tmp != NULL)
250 {
251 pro -> next = duplicate_field_prop (tmp, fil);
252 }
253 else
254 {
255 pro -> next = init_field_prop (fil, j, k, l);
256 pro = pro -> next;
257 for (i=0; i<sti; i++) pro -> aid[i] = ids[i];
258 }
259 }
260 else
261 {
262 if (tmp != NULL)
263 {
264 // Modifying an existing 'other' prop
265 pro -> key = tmp -> key;
266 pro -> val = NULL;
267 if (fvalues[activef][fil+1][tmp -> key] > 0)
268 {
269 pro -> val = duplicate_float (fvalues[activef][fil+1][tmp -> key], tmp -> val);
270 }
271 pro -> show = tmp -> show;
272 pro -> use = tmp -> use;
273 }
274 else
275 {
276 pro -> key = j;
277 pro -> val = NULL;
278 pro -> val = allocfloat (fvalues[activef][fil+1][j]);
279 }
280 }
281 }
282 }
283
284 if (tmp_fstr -> other != NULL)
285 {
286 ptmp = tmp_fstr -> other;
287 while (ptmp)
288 {
289 if (are_identical_prop (fil+1, sti, ptmp, tmp_fstr -> def))
290 {
291 if (ptmp -> next != NULL)
292 {
293 if (ptmp -> prev != NULL)
294 {
295 ptmp -> prev -> next = ptmp -> next;
296 ptmp -> next -> prev = ptmp -> prev;
297 }
298 else
299 {
300 ptmp -> next -> prev = NULL;
301 }
302 }
303 else if (ptmp -> prev != NULL)
304 {
305 ptmp -> prev -> next = NULL;
306 }
307 else
308 {
309 g_free (tmp_fstr -> other);
310 tmp_fstr -> other = NULL;
311 ptmp = NULL;
312 }
313 }
314 if (ptmp) ptmp = ptmp -> next;
315 }
316 }
317 if (tmp_fstr -> other != NULL)
318 {
319 ptmp = tmp_fstr -> other;
320 ptmp -> pid = 0;
321 while (ptmp -> next != NULL)
322 {
323 ptmp -> next -> pid = ptmp -> pid + 1;
324 ptmp = ptmp -> next;
325 }
326 }
327}
328
337G_MODULE_EXPORT void update_atom_parameter (GtkEntry * res, gpointer data)
338{
339 int i = GPOINTER_TO_INT(data);
340 double v;
341 const gchar * m = entry_get_text (res);
342 if (i > -1)
343 {
344 v = string_to_double ((gpointer)m);
346 }
347 switch (i)
348 {
349 case -1:
350 tmp_fat -> name = g_strdup_printf ("%s", m);
351 break;
352 case 0:
353 tmp_fat -> mass = v;
354 break;
355 case 1:
356 tmp_fat -> charge = v;
357 break;
358 case 2:
359 tmp_fshell -> m = v;
360 break;
361 case 3:
362 tmp_fshell -> z = v;
363 break;
364 case 4:
365 tmp_fshell -> k2 = v;
366 break;
367 case 5:
368 tmp_fshell -> k4 = v;
369 break;
370 case 6:
371 tmp_fcons -> length = v;
372 break;
373 case 7:
374 tmp_fpmf -> length = v;
375 break;
376 }
377}
378
380
389G_MODULE_EXPORT void update_field_parameter (GtkEntry * res, gpointer data)
390{
391 int i = GPOINTER_TO_INT(data);
392 const gchar * m = entry_get_text (res);
393 double v = string_to_double ((gpointer)m);
395 if (object_is > 0 && object_is < 9)
396 {
397 tmp_fprop -> val[i] = v;
398 }
399 else
400 {
401 switch (object_is)
402 {
403 case 0:
404 tmp_ftet -> val[i] = v;
405 break;
406 case 14:
407 tmp_fext -> val[i] = v;
408 break;
409 default:
410 tmp_fbody -> val[i] = v;
411 break;
412 }
413 }
414}
415
416GtkWidget * centry[3];
417GtkWidget * cross_box;
418double *** cross = NULL;
421
430G_MODULE_EXPORT void update_cross_parameter (GtkEntry * res, gpointer data)
431{
432 int j, k;
433 k = GPOINTER_TO_INT(data);
434 const gchar * m = entry_get_text (res);
435 double v = string_to_double ((gpointer)m);
437 j = gtk_combo_box_get_active (GTK_COMBO_BOX(cross_box));
438 cross[tmp_fbody -> id][j][k] = cross[j][tmp_fbody -> id][k] = v;
439}
440
449G_MODULE_EXPORT void changed_cross_combo (GtkComboBox * box, gpointer data)
450{
451 int i, j;
452 i = gtk_combo_box_get_active (box);
453 for (j=0; j<3; j++)
454 {
455 // g_debug ("Updating entry:: id= %d, i= %d, j= %d", tmp_fbody -> id, i, j);
456 update_entry_double (GTK_ENTRY(centry[j]), cross[tmp_fbody -> id][i][j]);
457 }
458}
459
467GtkWidget * combo_cross (field_nth_body * body)
468{
469 GtkWidget * combo;
470 combo = create_combo ();
471 g_signal_connect (G_OBJECT(combo), "changed", G_CALLBACK(changed_cross_combo), NULL);
472 if (tmp_field -> first_body[2] && tmp_fbody -> na[0] > -1)
473 {
474 field_nth_body * obody;
475 obody = tmp_field -> first_body[2];
476 while (obody)
477 {
478 combo_text_append (combo, get_active_atom(obody -> ma[0][0], obody -> a[0][0]) -> name);
479 obody = obody -> next;
480 }
481 }
482 return combo;
483}
484
491{
492 gchar * str = NULL;
493 if (tmp_field -> type <= CHARMMSI || tmp_field -> type > COMPASS)
494 {
495 str = g_strdup_printf ("<i>U</i>(r<sub>ij</sub>) = <b>Ɛ<sub>ij</sub></b> x [ (<b>r0<sub>ij</sub></b>/r<sub>ij</sub>)<sup>12</sup> - 2.0 (<b>r0<sub>ij</sub></b>/r<sub>ij</sub>)<sup>6</sup> ]\n"
496 "\t\twith <b>Ɛ<sub>ij</sub></b> = sqrt (Ɛ<sub>i</sub> x Ɛ<sub>j</sub>)\n"
497 "\t\tand <b>r0<sub>ij</sub></b> = r0<sub>i</sub>/2.0 + r0<sub>j</sub>/2.0");
498 }
499 else if (tmp_field -> type == CVFF || tmp_field -> type == CVFF_AUG)
500 {
501 str = g_strdup_printf ("<i>U</i>(r<sub>ij</sub>) = (<b>A<sub>ij</sub></b>/r<sub>ij</sub>)<sup>12</sup> - 2.0 (<b>B<sub>ij</sub></b>/r<sub>ij</sub>)<sup>6</sup>\n"
502 "\t\twith <b>A<sub>ij</sub></b> = sqrt (A<sub>i</sub> x A<sub>j</sub>)\n"
503 "\t\tand <b>B<sub>ij</sub></b> = sqrt (B<sub>i</sub> x B<sub>j</sub>)");
504 }
505 else if (tmp_field -> type >= CFF91 && tmp_field -> type <= COMPASS)
506 {
507 str = g_strdup_printf ("<i>U</i>(r<sub>ij</sub>) = <b>Ɛ<sub>ij</sub></b> x [ 2.0 (<b>r0<sub>ij</sub></b>/r<sub>ij</sub>)<sup>9</sup> - 3.0 (<b>r0<sub>ij</sub></b>/r<sub>ij</sub>)<sup>6</sup> ]\n"
508 "\t\twith <b>Ɛ<sub>ij</sub></b> = 2.0 sqrt (Ɛ<sub>i</sub> x Ɛ<sub>j</sub>) x (r0<sub>i</sub><sup>3</sup> r0<sub>j</sub><sup>3</sup>) / (r0<sub>i</sub><sup>6</sup> + r0<sub>j</sub><sup>6</sup>)\n"
509 "\t\tand <b>r0<sub>ij</sub></b> = [(r0<sub>i</sub><sup>6</sup> + r0<sub>j</sub><sup>6</sup>)/2.0] <sup>1/6</sup>");
510 }
511 return str;
512}
513
524GtkWidget * parameters_box (int obj, int key, gchar ** words, float * data)
525{
526 int i;
527 gchar * str = NULL;
528 GtkWidget * vbox = create_vbox (BSEP);
529 GtkWidget * hbox;
530 GtkWidget * lab;
531 GtkWidget * entry;
532 object_is = obj;
533
534 if (obj > -1 && key > -1)
535 {
536 if (fvalues[activef][obj][key] > 0)
537 {
538 for (i=0; i< fvalues[activef][obj][key]; i++)
539 {
540 if (obj == 11 && key == 0 && i == 0)
541 {
542 hbox = create_hbox (0);
543 lab = markup_label ("<u><i>Single terms:</i></u>", 100, 50, 0.0, 0.5);
544 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 30);
545 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 0);
546 }
547 hbox = create_hbox (0);
548 str = g_strdup_printf (" <b><i>%s</i></b>", words[i]);
549 lab = markup_label (str, 100, -1, 0.0, 0.5);
550 g_free (str);
551 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 50);
552 entry = create_entry (G_CALLBACK(update_field_parameter), 100, 15, FALSE, GINT_TO_POINTER(i));
553 update_entry_double (GTK_ENTRY(entry), data[i]);
554 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, entry, FALSE, FALSE, 0);
555 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 0);
556 }
557 if (obj == 11 && key == 0)
558 {
560 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, cross_vbox, FALSE, FALSE, 0);
562 lab = markup_label ("<u><i>Cross terms with atom:</i></u>", 160, -1, 0.0, 0.5);
563 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, cross_hbox, lab, FALSE, FALSE, 30);
565 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, cross_hbox, cross_box, FALSE, FALSE, 0);
566 add_box_child_start (GTK_ORIENTATION_VERTICAL, cross_vbox, cross_hbox, FALSE, FALSE, 10);
567 for (i=11; i< 14; i++)
568 {
569 hbox = create_hbox (0);
570 str = g_strdup_printf (" <b><i>%s</i></b>", words[i]);
571 lab = markup_label (str, 120, -1, 0.0, 0.5);
572 g_free (str);
573 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 50);
574 centry[i-11] = create_entry (G_CALLBACK(update_cross_parameter), 100, 15, FALSE, GINT_TO_POINTER(i-11));
575 update_entry_double (GTK_ENTRY(centry[i-11]), cross[tmp_fbody -> id][0][i-11]);
576 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, centry[i-11], FALSE, FALSE, 0);
577 add_box_child_start (GTK_ORIENTATION_VERTICAL, cross_vbox, hbox, FALSE, FALSE, 0);
578 }
579 if (tmp_fbody -> na[0] < 0)
580 {
582 }
583 else
584 {
585 gtk_combo_box_set_active (GTK_COMBO_BOX(cross_box), 0);
586 }
587 }
588 }
589 else
590 {
591 hbox = create_hbox (0);
592 str = g_strdup_printf ("<i>Tabulated</i>");
593 lab = markup_label (str, 100, -1, 0.0, 0.5);
594 g_free (str);
595 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 30);
596 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 0);
597 }
598 if (obj == 9 && tmp_field -> type >= CFF91 && tmp_field -> type <= COMPASS)
599 {
600 str = g_strdup_printf ("In %s, non-bonded interactions are evaluated using: \n%s\nTherefore the parameters provided by the force field are incompatible with the DL-POLY options.", field_acro[tmp_field -> type], get_this_vdw_string());
601 hbox = create_hbox (0);
602 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label (str, -1, -1, 0.5, 0.5), FALSE, FALSE, 50);
603 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 10);
604 g_free (str);
605 }
606 else if (obj == 9 && key == 0 && (tmp_field -> type <= CVFF_AUG || tmp_field -> type > COMPASS))
607 {
608 if (tmp_field -> type < CVFF)
609 {
610 str = g_strdup_printf ("In %s, 12-6 non-bonded interactions are evaluated using: \n%s\n<i><b>A</b></i> and <i><b>B</b></i>"
611 " are calculated using Ɛ<sub>i/j</sub> and r0<sub>i/j</sub> provided by the force field parameters.",
613 if (tmp_field -> type > AMBER99)
614 {
615 str = g_strdup_printf ("%s\nScaled 1-4 exclusion parameters, provided by the %s force field, are ignored.", str, field_acro[tmp_field -> type]);
616 }
617 }
618 else
619 {
620 str = g_strdup_printf ("In %s, 12-6 non-bonded interactions are evaluated using: \n%s\n<i><b>A</b></i> and <i><b>B</b></i>"
621 " are calculated using A<sub>i/j</sub> and B<sub>i/j</sub> provided by the force field parameters.",
623 }
624 hbox = create_hbox (0);
625 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label (str, -1, -1, 0.5, 0.5), FALSE, FALSE, 50);
626 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 10);
627 g_free (str);
628 }
629 else if ((obj == 3 || obj == 4) && tmp_field -> type > AMBER99 && tmp_field -> type < CVFF)
630 {
631 hbox = create_hbox (0);
632 str = g_strdup_printf ("Urey-Bradley terms provided by the %s force field are ignored.\n", field_acro[tmp_field -> type]);
633 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label (str, -1, -1, 0.5, 0.5), FALSE, FALSE, 50);
634 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 10);
635 g_free (str);
636 }
637 }
638 return vbox;
639}
640
648gchar * field_str (int a)
649{
650 gchar * str = g_strdup_printf ("External field");
651 if (a > -1)
652 {
653 str = g_strdup_printf ("%s: <b>%s</b>", str, fnames[activef][15][a]);
654 }
655 return str;
656}
657
664{
665 gchar * text = "Are you sure to want to change the type of Tersoff potential ?\n"
666 "<i>Tersoff (ter)</i> and <i>KIHS (kihs)</i> forms cannot be mixed\n"
667 "Therefore this choice will affect <b>all</b> Tersoff potential(s)"
668 "Any previous parameters will be erased !";
669 if (num_body_d > 1)
670 {
671 return ask_yes_no ("Change Tersoff potential ?!", text, GTK_MESSAGE_QUESTION, field_assistant);
672 }
673 else
674 {
675 change_tersoff = TRUE;
676 return TRUE;
677 }
678}
679
687GtkWidget * param_prop_param_box (int pid)
688{
689 switch (pid)
690 {
691 case MOLIMIT-9:
692 return parameters_box (0, tmp_ftet -> key, fvars_teth[activef][tmp_ftet -> key], tmp_ftet -> val);
693 break;
694 case MOLIMIT-1:
695 return parameters_box (pid-6, tmp_fprop -> key, fvars_inversion[activef][tmp_fprop -> key], tmp_fprop -> val);
696 break;
697 case MOLIMIT:
698 return parameters_box (pid-6, tmp_fbody -> key, fvars_vdw[activef][tmp_fbody -> key], tmp_fbody -> val);
699 break;
700 case MOLIMIT+1:
701 return parameters_box (pid-6, tmp_fbody -> key, fvars_met[activef][tmp_fbody -> key], tmp_fbody -> val);
702 break;
703 case MOLIMIT+2:
704 return parameters_box (pid-6, tmp_fbody -> key, fvars_ters[activef][tmp_fbody -> key], tmp_fbody -> val);
705 break;
706 case MOLIMIT+3:
707 return parameters_box (pid-6, tmp_fbody -> key, fvars_tbd[activef][tmp_fbody -> key], tmp_fbody -> val);
708 break;
709 case MOLIMIT+4:
710 return parameters_box (pid-6, tmp_fbody -> key, fvars_fbd[activef][tmp_fbody -> key], tmp_fbody -> val);
711 break;
712 case SEXTERN:
713 return parameters_box (14, tmp_fext -> key, fvars_fext[activef][tmp_fext -> key], tmp_fext -> val);
714 break;
715 default:
716 switch ((pid-7)/2)
717 {
718 case 0:
719 return parameters_box (pid-6, tmp_fprop -> key, fvars_bond[activef][tmp_fprop -> key], tmp_fprop -> val);
720 break;
721 case 1:
722 return parameters_box (pid-6, tmp_fprop -> key, fvars_angle[activef][tmp_fprop -> key], tmp_fprop -> val);
723 break;
724 default:
725 return parameters_box (pid-6, tmp_fprop -> key, fvars_dihedral[activef][tmp_fprop -> key], tmp_fprop -> val);
726 break;
727 }
728 break;
729 }
730}
731
740G_MODULE_EXPORT void changed_field_key_combo (GtkComboBox * box, gpointer data)
741{
742 int i, j;
743 gboolean changeit = FALSE;
744 i = GPOINTER_TO_INT(data);
745 j = gtk_combo_box_get_active (box);
746 if (i > 6 && i < MOLIMIT)
747 {
748 if (j != tmp_fprop -> key)
749 {
750 tmp_fprop -> key = j;
751 tmp_fprop -> val = NULL;
752 tmp_fprop -> val = allocfloat (fvalues[activef][i-6][j]);
753 changeit = TRUE;
754 }
755 }
756 else
757 {
758 switch (i)
759 {
760 case 6:
761 if (j != tmp_ftet -> key)
762 {
763 tmp_ftet -> key = j;
764 tmp_ftet -> val = NULL;
765 tmp_ftet -> val = allocfloat (fvalues[activef][0][j]);
766 changeit = TRUE;
767 }
768 break;
769 case SEXTERN:
770 if (j != tmp_fext -> key)
771 {
772 tmp_fext -> key = j;
773 gtk_label_set_text (GTK_LABEL(body_lab), field_str(tmp_fext -> key));
774 gtk_label_set_use_markup (GTK_LABEL(body_lab), TRUE);
775 tmp_fext -> val = NULL;
777 changeit = TRUE;
778 }
779 break;
780 default:
781 if (j != tmp_fbody -> key)
782 {
783 changeit = TRUE;
784 if (i == MOLIMIT+2) changeit = tersoff_question ();
785 if (changeit)
786 {
787 tmp_fbody -> key = j;
788 tmp_fbody -> val = NULL;
789 tmp_fbody -> val = allocfloat (fvalues[activef][i-6][j]);
790 if (i == MOLIMIT+2 && j == 0)
791 {
793 }
794 else if (j == 1 && cross != NULL)
795 {
796 g_free (cross);
797 cross = NULL;
798 }
799 }
800 else
801 {
802 gtk_combo_box_set_active (box, tmp_fbody -> key);
803 }
804 }
805 break;
806 }
807 }
808 if (changeit)
809 {
810 if (ff_p_combo[0]) gtk_combo_box_set_active (GTK_COMBO_BOX(ff_p_combo[0]), 0);
811 if (ff_p_combo[1]) gtk_combo_box_set_active (GTK_COMBO_BOX(ff_p_combo[1]), 0);
814 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, param_box, p_box, FALSE, FALSE, 0);
816 }
817
818}
819
820#ifdef GTK4
829G_MODULE_EXPORT void visualize_it (GtkCheckButton * but, gpointer data)
830#else
839G_MODULE_EXPORT void visualize_it (GtkToggleButton * but, gpointer data)
840#endif
841{
842 int i, j;
843 i = GPOINTER_TO_INT (data);
844 j = 0;
845#ifdef GTK4
846 toviz.c = gtk_check_button_get_active (but);
847#else
848 toviz.c = gtk_toggle_button_get_active (but);
849#endif
850 if (i < MOLIMIT)
851 {
852 j = gtk_combo_box_get_active(GTK_COMBO_BOX(combo_mol[i-1]));
854 }
855 if (is_moy)
856 {
857 visualize_object (i, row_id, j);
859 }
860 else
861 {
863 if (i < MOLIMIT)
864 {
866 tmp_fprop -> show = toviz.c;
867 }
868 }
871}
872
873#ifdef GTK4
882G_MODULE_EXPORT void select_it (GtkCheckButton * but, gpointer data)
883#else
892G_MODULE_EXPORT void select_it (GtkToggleButton * but, gpointer data)
893#endif
894{
895 int i, j;
896 i = GPOINTER_TO_INT (data);
897#ifdef GTK4
898 toviz.c = gtk_check_button_get_active (but);
899#else
900 toviz.c = gtk_toggle_button_get_active (but);
901#endif
902 if (i < MOLIMIT) j = gtk_combo_box_get_active(GTK_COMBO_BOX(combo_mol[i-1]));
903 if (is_moy)
904 {
905 select_object (i, row_id, j);
906 }
907 else
908 {
909 tmp_fprop -> use = toviz.c;
910 }
911}
912
913extern ColRGBA init_color (int id, int numid);
914extern int active_sel;
915extern int a_ato;
916extern int ** sel_at;
917extern void run_select_atom_dialog (GtkDialog * select_dialog, gint response_id, gpointer data);
918GtkWidget * add_tree;
920
930G_MODULE_EXPORT void field_molecule_select_atom_id (GtkCellRendererToggle * cell_renderer, gchar * string_path, gpointer data)
931{
932 GtkTreeStore ** model = (GtkTreeStore **)data;
933 GtkTreeIter iter;
934 int h, i, j, k, l, m, n;
935 GtkTreePath * path = gtk_tree_path_new_from_string (string_path);
936 gtk_tree_model_get_iter (GTK_TREE_MODEL(* model), & iter, path);
937 gtk_tree_model_get (GTK_TREE_MODEL(* model), & iter, 0, & i, -1);
938 if (gtk_cell_renderer_toggle_get_active(cell_renderer))
939 {
940 toviz.c = 0;
941 a_ato --;
942 }
943 else
944 {
945 toviz.c = 1;
946 a_ato ++;
947 }
948 if (active_sel < 11)
949 {
950 sel_at[0][i-1] = toviz.c;
951 }
952 switch (active_sel)
953 {
954 case 0:
955 j = i-1;
956 break;
957 case 1:
958 j = i-1;
959 break;
960 case 2:
961 j = tmp_fshell -> id;
962 break;
963 case 3:
964 j = tmp_fshell -> id;
965 break;
966 case 4:
967 j = tmp_fcons -> id;
968 break;
969 case 5:
970 j = tmp_fcons -> id;
971 break;
972 case 6:
973 j = tmp_fpmf -> id;
974 break;
975 case 7:
976 j = tmp_fpmf -> id;
977 break;
978 case 8:
979 j = tmp_frig -> id;
980 break;
981 case 9:
982 j = tmp_ftet -> id;
983 break;
984 default:
985 j = tmp_fbody -> id;
986 break;
987 }
988 if (active_sel < 10)
989 {
990 for (k=0; k<tmp_fmol -> multi; k++)
991 {
992 l = tmp_fmol -> atoms_id[i-1][k].a;
993 m = tmp_fmol -> atoms_id[i-1][k].b;
994 n = get_active_atom (tmp_fmol -> id, l) -> list[m];
995 field_selection (n, toviz.c, toviz.c, i-1);
996 }
997 }
998 else
999 {
1000 h = vdw_id = sel_at[0][i-1];
1001 field_nth_body * tmp_fbo = tmp_field -> first_body[0];
1002 for (k=0; k<tmp_field -> nbody[0]; k++)
1003 {
1004 if (tmp_fbo -> id == h)
1005 {
1006 visualize_body (toviz.c, h, tmp_fbo);
1007 break;
1008 }
1009 else if (tmp_fbo -> next != NULL)
1010 {
1011 tmp_fbo = tmp_fbo -> next;
1012 }
1013 }
1014 }
1016 j = (active_sel > 5 && active_sel < 8) ? 1 : 0;
1017 gtk_tree_store_set (* model, & iter, 3+j, toviz.c, -1);
1020}
1021
1030void select_atom_set_color (GtkCellRenderer * renderer, int i)
1031{
1032 set_renderer_color (i, renderer, init_color (i-1, num_field_objects));
1033}
1034
1046void select_atom_set_cmv (GtkTreeViewColumn * col, GtkCellRenderer * renderer, GtkTreeModel * mod, GtkTreeIter * iter, gpointer data)
1047{
1048 int h, i, j, k;
1049 gchar * str = NULL;
1050 gtk_tree_model_get (mod, iter, 0, & h, -1);
1051 if (active_sel < 11)
1052 {
1053 gtk_tree_model_get (mod, iter, 1, & i, -1);
1054 }
1055 else
1056 {
1057 i = ! h;
1058 }
1059 j = GPOINTER_TO_INT(data);
1060 switch (j)
1061 {
1062 case 0:
1063 gtk_cell_renderer_set_visible (renderer, ! i);
1064 break;
1065 case 1:
1066 if (active_sel > 10)
1067 {
1068 gtk_tree_model_get (mod, iter, 1, & str, -1);
1069 g_object_set (renderer, "markup", str, NULL, NULL);
1070 g_free (str);
1071 i = h;
1072 }
1073 gtk_cell_renderer_set_visible (renderer, i);
1074 break;
1075 case 2:
1076 gtk_tree_model_get (mod, iter, 2, & str, -1);
1077 g_object_set (renderer, "markup", str, NULL, NULL);
1078 g_free (str);
1079 gtk_cell_renderer_set_visible (renderer, i);
1080 break;
1081 case 3:
1082 gtk_cell_renderer_set_visible (renderer, ! i);
1083 break;
1084 case 4:
1085 if ((active_sel > 1 && active_sel < 6) || active_sel > 8)
1086 {
1087 if (active_sel > 10)
1088 {
1089 gtk_tree_model_get (mod, iter, 3, & k, -1);
1090 }
1091 else
1092 {
1093 k = sel_at[0][h-1];
1094 }
1095 if (k || ! a_ato)
1096 {
1097 gtk_cell_renderer_set_visible (renderer, TRUE);
1098 }
1099 else
1100 {
1101 gtk_cell_renderer_set_visible (renderer, ! a_ato);
1102 }
1103 }
1104 else
1105 {
1106 gtk_cell_renderer_set_visible (renderer, ! i);
1107 }
1108 break;
1109 }
1110 if (active_sel < 2 && j < 4)
1111 {
1112 for (i=0; i<tmp_fat -> num/tmp_fmol -> multi; i++)
1113 {
1114 if (sel_at[0][i]+1 == abs(h)) break;
1115 }
1116 if (sel_at[1][i])
1117 {
1118 select_atom_set_color (renderer, sel_at[0][i]+1);
1119 }
1120 else
1121 {
1122 select_atom_set_color (renderer, sel_at[1][i]);
1123 }
1124 }
1125 else if (j < 4)
1126 {
1127 if (h < 0) h = -h;
1128 if (active_sel < 11)
1129 {
1130 k = (sel_at[0][h-1]) ? h : 0;
1131 }
1132 else
1133 {
1134 gtk_tree_model_get (mod, iter, 3, & k, -1);
1135 }
1136 select_atom_set_color (renderer, k);
1137 }
1138}
1139
1140float * val_at;
1141
1142/*
1143* G_MODULE_EXPORT void edit_unit_weight (GtkCellRendererText * cell, gchar * path_string, gchar * new_text, gpointer data)
1144
1145 \brief on edit unit weight callback
1146
1147 \param cell the GtkCellRendererToggle sending the signal
1148 \param string_path the path in the tree store
1149* gchar
1150 \param data the associated data pointer
1151*/
1152G_MODULE_EXPORT void edit_unit_weight (GtkCellRendererText * cell, gchar * path_string, gchar * new_text, gpointer data)
1153{
1154 GtkTreeStore ** model = (GtkTreeStore **)data;
1155 GtkTreeIter iter;
1156 int i;
1157 GtkTreePath * path = gtk_tree_path_new_from_string (path_string);
1158 gtk_tree_model_get_iter (GTK_TREE_MODEL(* model), & iter, path);
1159 gtk_tree_model_get (GTK_TREE_MODEL(* model), & iter, 0, & i, -1);
1160 val_at[i] = string_to_double ((gpointer)new_text);
1161}
1162
1171G_MODULE_EXPORT void select_atom_id_from_fied_molecule (GtkButton * but, gpointer data)
1172{
1173 int i, j, k, l, m, n, o, p, q;
1174 GtkTreeIter id_level;
1175 GtkTreeIter atom_level;
1176 GtkTreeViewColumn * ato_col[5];
1177 GtkCellRenderer * ato_cell[5];
1178 gchar * ato_title[5] = {"Atom Id", "Fragment", "Atom", "Weight (1)", "Viz.3D & Select"};
1179 gchar * nbd_title[5] = {"Atom Id", "Field atom", "Field molecule(s)", " ", "Viz.3D & Select"};
1180 gchar * ctype[5]={"text", "text", "text", "text", "active"};
1181 GType col_type[2][5] = {{G_TYPE_INT, G_TYPE_INT, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_FLOAT},
1182 {G_TYPE_INT, G_TYPE_INT, G_TYPE_STRING, G_TYPE_FLOAT, G_TYPE_BOOLEAN}};
1183 GType cbl_type[4] = {G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN};
1184 field_object = 1;
1185 active_sel = GPOINTER_TO_INT (data);
1186 gboolean add;
1187 gchar * str;
1188 q = (active_sel > 5 && active_sel < 8) ? 1 : 0;
1189 switch (active_sel)
1190 {
1191 case 0:
1192 str = g_strdup_printf ("Please select the new atom(s)");
1193 o = -1;
1194 p = -1;
1195 break;
1196 case 1:
1197 str = g_strdup_printf ("Please select the atom(s) to freeze / unfreeze");
1198 o = -1;
1199 p = -1;
1200 break;
1201 case 2:
1202 str = g_strdup_printf ("Please select the core atom");
1203 o = tmp_fshell -> ia[0]-1;
1204 p = tmp_fshell -> ia[1]-1;
1205 break;
1206 case 3:
1207 str = g_strdup_printf ("Please select the atom(s) to shell");
1208 o = tmp_fshell -> ia[1]-1;
1209 p = tmp_fshell -> ia[0]-1;
1210 break;
1211 case 4:
1212 str = g_strdup_printf ("Please select the first atom");
1213 o = tmp_fcons -> ia[0]-1;
1214 p = tmp_fcons -> ia[1]-1;
1215 break;
1216 case 5:
1217 str = g_strdup_printf ("Please select the second atom");
1218 o = tmp_fcons -> ia[1]-1;
1219 p = tmp_fcons -> ia[0]-1;
1220 break;
1221 case 6:
1222 str = g_strdup_printf ("Please select the atom(s) in the first unit");
1223 break;
1224 case 7:
1225 str = g_strdup_printf ("Please select the atom(s) in the second unit");
1226 break;
1227 case 8:
1228 str = g_strdup_printf ("Please select the atom(s) in the rigid unit");
1229 p = -1;
1230 break;
1231 case 9:
1232 str = g_strdup_printf ("Please select the tethered atom");
1233 o = tmp_ftet -> num-1;
1234 p = -1;
1235 break;
1236 case 11:
1237 if (tmp_fbody -> bd == 2)
1238 {
1239 str = g_strdup_printf ("Please select the type of field atom");
1240 }
1241 else
1242 {
1243 str = g_strdup_printf ("Please select the first type of field atom");
1244 }
1245 break;
1246 case 12:
1247 str = g_strdup_printf ("Please select the second type of field atom");
1248 break;
1249 case 13:
1250 str = g_strdup_printf ("Please select the third type of field atom");
1251 break;
1252 case 14:
1253 str = g_strdup_printf ("Please select the fourth type of field atom");
1254 break;
1255 }
1256 GtkWidget * amol = dialogmodal (str, GTK_WINDOW(field_assistant));
1257 g_free (str);
1258 gtk_dialog_add_button (GTK_DIALOG(amol), "Apply", GTK_RESPONSE_APPLY);
1259 a_ato = 0;
1260 GtkTreeStore * add_model;
1261 if (active_sel < 11)
1262 {
1263 add_model = gtk_tree_store_newv (4+q, col_type[q]);
1264 }
1265 else
1266 {
1267 add_model = gtk_tree_store_newv (4, cbl_type);
1268 }
1269 add_tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(add_model));
1270 if (active_sel < 11)
1271 {
1272 num_field_objects = tmp_fmol -> mol -> natoms;
1273 }
1274
1275 for (i=0; i<4+q; i++)
1276 {
1277 k = i;
1278 if (i < 3+q)
1279 {
1280 ato_cell[i] = gtk_cell_renderer_text_new ();
1281 }
1282 else
1283 {
1284 if (! q) k ++;
1285 ato_cell[i] = gtk_cell_renderer_toggle_new ();
1286 if (active_sel > 1) gtk_cell_renderer_toggle_set_radio (GTK_CELL_RENDERER_TOGGLE(ato_cell[i]), TRUE);
1287 g_signal_connect (G_OBJECT(ato_cell[i]), "toggled", G_CALLBACK(field_molecule_select_atom_id), & add_model);
1288 }
1289 if (active_sel < 11)
1290 {
1291 ato_col[i] = gtk_tree_view_column_new_with_attributes (ato_title[k], ato_cell[i], ctype[k], i, NULL);
1292 }
1293 else
1294 {
1295 ato_col[i] = gtk_tree_view_column_new_with_attributes (nbd_title[k], ato_cell[i], ctype[k], i, NULL);
1296 }
1297 gtk_tree_view_append_column (GTK_TREE_VIEW(add_tree), ato_col[i]);
1298 gtk_tree_view_column_set_alignment (ato_col[i], 0.5);
1299 gtk_tree_view_column_set_cell_data_func (ato_col[i], ato_cell[i], select_atom_set_cmv, GINT_TO_POINTER(k), NULL);
1300 if (q && i == 3)
1301 {
1302 g_object_set (ato_cell[i], "editable", TRUE, NULL);
1303 g_signal_connect (G_OBJECT(ato_cell[i]), "edited", G_CALLBACK(edit_unit_weight), & add_model);
1304 }
1305 }
1306 // Clean 3D viz
1308 // fill model
1309 if (active_sel < 2)
1310 {
1311 sel_at = allocdint(2, tmp_fat -> num/tmp_fmol -> multi);
1312 }
1313 else if (active_sel < 11)
1314 {
1315 sel_at = allocdint(2, tmp_fmol -> mol -> natoms);
1316 }
1317 else
1318 {
1319 field_nth_body * tmp_fbo = tmp_field -> first_body[0];
1320 k = 0;
1321 for (i=0; i<tmp_field -> nbody[0]; i++)
1322 {
1323 if (g_strcmp0 (get_active_atom (tmp_fbo -> ma[0][0], tmp_fbo -> a[0][0]) -> name,
1324 get_active_atom (tmp_fbo -> ma[1][0], tmp_fbo -> a[1][0]) -> name) == 0) k ++;
1325 if (tmp_fbo -> next != NULL) tmp_fbo = tmp_fbo -> next;
1326 }
1327 sel_at = allocdint(1, k);
1329 }
1330
1331 if (active_sel < 2)
1332 {
1333 l = 0;
1334 for (i=0; i<tmp_fmol -> mol -> natoms; i++)
1335 {
1336 if (tmp_fmol -> atoms_id[i][0].a == tmp_fat -> id)
1337 {
1338 j = tmp_fmol -> atoms_id[i][0].b;
1339 k = tmp_fat -> list_id[j];
1340 sel_at[0][l] = k;
1341 if (active_sel)
1342 {
1343 sel_at[1][l] = tmp_fat -> frozen_id[j];
1344 }
1345 else
1346 {
1347 sel_at[1][l] = 0;
1348 }
1349 l ++;
1350 }
1351 }
1352 for (i=0; i<tmp_fat -> num/tmp_fmol -> multi; i++)
1353 {
1354 gtk_tree_store_append (add_model, & id_level, NULL);
1355 gtk_tree_store_set (add_model, & id_level, 0, sel_at[0][i]+1, 1, 0, 3, 0, -1);
1356 if (sel_at[1][i])
1357 {
1358 field_molecule_select_atom_id (GTK_CELL_RENDERER_TOGGLE(ato_cell[3]),
1359 gtk_tree_path_to_string(gtk_tree_model_get_path(GTK_TREE_MODEL(add_model), & id_level)),
1360 & add_model);
1361 }
1362 for (j=0; j< tmp_fmol -> multi; j++)
1363 {
1364 gtk_tree_store_append (add_model, & atom_level, & id_level);
1365 k = sel_at[0][i];
1366 l = tmp_fmol -> atoms_id[k][j].b;
1367 m = tmp_fat -> list[l];
1368 str = g_strdup_printf ("%s<sub>%d</sub>", exact_name(tmp_proj -> chemistry -> label[tmp_fat -> sp]), m+1);
1369 gtk_tree_store_set (add_model, & atom_level, 0, -(sel_at[0][i]+1), 1, tmp_fmol -> fragments[j]+1, 2, str, -1);
1370 g_free (str);
1371 }
1372 }
1373 }
1374 else if (active_sel < 4)
1375 {
1376 for (i=0; i<tmp_fmol -> mol -> natoms; i++)
1377 {
1378 if (i != p)
1379 {
1380 gtk_tree_store_append (add_model, & id_level, NULL);
1381 gtk_tree_store_set (add_model, & id_level, 0, i+1, 1, 0, 3, 0, -1);
1382 tmp_fat = get_active_atom (tmp_fmol -> id, tmp_fmol -> atoms_id[i][0].a);
1383 for (j=0; j< tmp_fmol -> multi; j++)
1384 {
1385 gtk_tree_store_append (add_model, & atom_level, & id_level);
1386 k = tmp_fat -> list[tmp_fmol -> atoms_id[i][j].b];
1387 str = g_strdup_printf ("%s<sub>%d</sub>", exact_name(tmp_proj -> chemistry -> label[tmp_fat -> sp]), k+1);
1388 gtk_tree_store_set (add_model, & atom_level, 0, -(i+1), 1, tmp_fmol -> fragments[j]+1, 2, str, -1);
1389 g_free (str);
1390 }
1391 }
1392 }
1393 }
1394 else if (active_sel < 6 || (active_sel > 7 && active_sel < 11))
1395 {
1396 for (i=0; i<tmp_fmol -> mol -> natoms; i++)
1397 {
1398 if (i != p)
1399 {
1400 tmp_fat = get_active_atom (tmp_fmol -> id, tmp_fmol -> atoms_id[i][0].a);
1401 gtk_tree_store_append (add_model, & id_level, NULL);
1402 if (active_sel < 6 || active_sel == 9)
1403 {
1404 if (i == o)
1405 {
1406 k = 1;
1407 }
1408 else
1409 {
1410 k = 0;
1411 }
1412 }
1413 else
1414 {
1415 k = 0;
1416 if (tmp_frig -> num > 0)
1417 {
1418 for (j=0; j<tmp_frig -> num; j++)
1419 {
1420 if (i == tmp_frig -> list[j])
1421 {
1422 k = 1;
1423 break;
1424 }
1425 }
1426 }
1427 }
1428 sel_at[0][i] = k;
1429 gtk_tree_store_set (add_model, & id_level, 0, i+1, 1, 0, 3, 0, -1);
1430 if (sel_at[0][i])
1431 {
1432 field_molecule_select_atom_id (GTK_CELL_RENDERER_TOGGLE(ato_cell[3]),
1433 gtk_tree_path_to_string(gtk_tree_model_get_path(GTK_TREE_MODEL(add_model), & id_level)),
1434 & add_model);
1435 }
1436 for (j=0; j< tmp_fmol -> multi; j++)
1437 {
1438 gtk_tree_store_append (add_model, & atom_level, & id_level);
1439 l = tmp_fat -> list[tmp_fmol -> atoms_id[i][j].b];
1440 str = g_strdup_printf ("%s<sub>%d</sub>", exact_name(tmp_proj -> chemistry -> label[tmp_fat -> sp]), l+1);
1441 gtk_tree_store_set (add_model, & atom_level, 0, -(i+1), 1, tmp_fmol -> fragments[j]+1, 2, str, -1);
1442 g_free (str);
1443 }
1444 }
1445 }
1446 }
1447 else if (active_sel > 10)
1448 {
1449 m = active_sel-11;
1450 field_nth_body * tmp_fbo = tmp_field -> first_body[0];
1451 k = 0;
1452 for (i=0; i<tmp_field -> nbody[0]; i++)
1453 {
1454 // need to find the atoms name
1455 if (g_strcmp0 (get_active_atom (tmp_fbo -> ma[0][0], tmp_fbo -> a[0][0]) -> name,
1456 get_active_atom (tmp_fbo -> ma[1][0], tmp_fbo -> a[1][0]) -> name) == 0)
1457 {
1458 add = TRUE;
1459 for (j=0; j < body_at(tmp_fbody -> bd); j++)
1460 {
1461 if (j != m && tmp_fbody -> na[j] > -1)
1462 {
1463 if (g_strcmp0 (get_active_atom (tmp_fbo -> ma[0][0], tmp_fbo -> a[0][0]) -> name,
1464 get_active_atom (tmp_fbody -> ma[j][0], tmp_fbody -> a[j][0]) -> name) == 0) add = FALSE;
1465 }
1466 }
1467 if (add)
1468 {
1469 gtk_tree_store_append (add_model, & id_level, NULL);
1470 l = 0;
1471 if (tmp_fbody -> na[m] > -1)
1472 {
1473 if (g_strcmp0 (get_active_atom (tmp_fbo -> ma[0][0], tmp_fbo -> a[0][0]) -> name,
1474 get_active_atom (tmp_fbody -> ma[m][0], tmp_fbody -> a[m][0]) -> name) == 0)
1475 {
1476 l = 1;
1477 vdw_id = tmp_fbo -> id;
1478 a_ato = 1;
1479 }
1480 }
1481 gtk_tree_store_set (add_model, & id_level, 0, k+1, 1,
1482 exact_name(get_active_atom (tmp_fbo -> ma[0][0], tmp_fbo -> a[0][0]) -> name), 3, l, -1);
1483 sel_at[0][k] = tmp_fbo -> id;
1484 for (j=0; j<tmp_fbo -> na[0]; j++)
1485 {
1486 gtk_tree_store_append (add_model, & atom_level, & id_level);
1487 gtk_tree_store_set (add_model, & atom_level, 0, 0, 2, get_active_field_molecule(tmp_fbo -> ma[0][j]) -> name, 3, 0, -1);
1488 }
1489 }
1490 k ++;
1491 }
1492 if (tmp_fbo -> next != NULL) tmp_fbo = tmp_fbo -> next;
1493 }
1494 }
1495 else
1496 {
1497 val_at = allocfloat (tmp_fmol -> mol -> natoms);
1498 if (active_sel == 5)
1499 {
1500 k = 1;
1501 m = 0;
1502 }
1503 else
1504 {
1505 k = 0;
1506 m = 1;
1507 }
1508 for (i=0; i<tmp_fmol -> mol -> natoms; i++)
1509 {
1510 add = TRUE;
1511 if (tmp_fpmf -> num[k] > 0)
1512 {
1513 for (l=0; l<tmp_fpmf -> num[k]; l++)
1514 {
1515 if (i == tmp_fpmf -> list[k][l])
1516 {
1517 add = FALSE;
1518 break;
1519 }
1520 }
1521 }
1522 if (add)
1523 {
1524 tmp_fat = get_active_atom (tmp_fmol -> id, tmp_fmol -> atoms_id[i][0].a);
1525 gtk_tree_store_append (add_model, & id_level, NULL);
1526 n = 0;
1527 if (tmp_fpmf -> num[m] > 0)
1528 {
1529 for (l=0; l<tmp_fpmf -> num[m]; l++)
1530 {
1531 if (i == tmp_fpmf -> list[m][l])
1532 {
1533 n = 1;
1534 break;
1535 }
1536 }
1537 }
1538 val_at[i] = tmp_fat -> mass;
1539 sel_at[0][i] = n;
1540 gtk_tree_store_set (add_model, & id_level, 0, i+1, 1, 0, 3, val_at[i], 4, 0, -1);
1541 if (sel_at[0][i])
1542 {
1543 field_molecule_select_atom_id (GTK_CELL_RENDERER_TOGGLE(ato_cell[4]),
1544 gtk_tree_path_to_string(gtk_tree_model_get_path(GTK_TREE_MODEL(add_model), & id_level)),
1545 & add_model);
1546 }
1547 for (l=0; l< tmp_fmol -> multi; l++)
1548 {
1549 gtk_tree_store_append (add_model, & atom_level, & id_level);
1550 n = tmp_fat -> list[tmp_fmol -> atoms_id[i][l].b];
1551 str = g_strdup_printf ("%s<sub>%d</sub>", exact_name(tmp_proj -> chemistry -> label[tmp_fat -> sp]), n+1);
1552 gtk_tree_store_set (add_model, & atom_level, 0, -(i+1), 1, tmp_fmol -> fragments[l]+1, 2, str, -1);
1553 g_free (str);
1554 }
1555 }
1556 }
1557 }
1558 g_object_unref (add_model);
1559
1560 if (active_sel < 2)
1561 {
1562 j = tmp_fat -> num/tmp_fmol -> multi;
1563 }
1564 else
1565 {
1567 }
1568 i = ((j+1)*37 < 500) ? (j+1)*37 : 500;
1569 if (active_sel > 10) q = 1;
1570 GtkWidget * vbox = dialog_get_content_area (amol);
1571 GtkWidget * scrollsets = create_scroll (vbox, 320+q*100, i, GTK_SHADOW_ETCHED_IN);
1573
1574 if (q && active_sel < 11)
1575 {
1576 str = g_strdup_printf (" <b>(1)</b> if all 0.0 then atomic weight(s) will be used by DL-POLY");
1577 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, markup_label(str, -1, -1, 0.0, 0.5), FALSE, FALSE, 0);
1578 g_free (str);
1579 }
1580 if (active_sel < 2)
1581 {
1582 str = g_strdup_printf ("The atom(s) above will be described\n"
1583 "in the force field using the parameters\n"
1584 "of the <b>%s</b> field atom.\n", tmp_fat -> name);
1585 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, markup_label(str, -1, -1, 0.5, 0.5), FALSE, FALSE, 0);
1586 g_free (str);
1587 }
1588 show_the_widgets (amol);
1589 switch (active_sel)
1590 {
1591 case 0:
1592 run_this_gtk_dialog (amol, G_CALLBACK(run_add_atom_dialog), NULL);
1593 break;
1594 default:
1595 run_this_gtk_dialog (amol, G_CALLBACK(run_select_atom_dialog), GINT_TO_POINTER(active_sel));
1596 if (active_sel == 1)
1597 {
1598 str = g_strdup_printf ("%d atom(s)", tmp_fat -> frozen);
1599 if (but) gtk_button_set_label (but, str);
1600 }
1601 break;
1602 }
1603 g_free (sel_at);
1604 if (q && active_sel < 11) g_free (val_at);
1605}
1606
1607GtkWidget * av_lgt;
1608
1616void update_field_dist (float v)
1617{
1618 gchar * str;
1619 if (v < 0.0)
1620 {
1621 str = g_strdup_printf (" ");
1622 }
1623 else
1624 {
1625 str = g_strdup_printf ("<b>%8.3f</b>", v);
1626 }
1627 gtk_label_set_text (GTK_LABEL(av_lgt), str);
1628 gtk_label_set_use_markup (GTK_LABEL(av_lgt), TRUE);
1629}
1630
1638gchar * body_str (int a)
1639{
1640 int i, j;
1641 j = body_at (a);
1642 gchar * str = g_strdup_printf ("%s <b>", felemts[a+MOLIMIT+1]);
1643 for (i=0; i<j; i++)
1644 {
1645 if (tmp_fbody -> na[i] > -1)
1646 {
1647 str = g_strdup_printf ("%s%s", str, get_active_atom (tmp_fbody -> ma[i][0], tmp_fbody -> a[i][0]) -> name);
1648 }
1649 if (i < j-1 && j > 1) str = g_strdup_printf ("%s - ", str);
1650 }
1651 str = g_strdup_printf ("%s</b>", str);
1652 return str;
1653}
1654
1663G_MODULE_EXPORT void selection_button (GtkButton * but, gpointer data)
1664{
1666 int i, j, k, l, m, n, o, p, q, r;
1667 i = GPOINTER_TO_INT(data);
1668 gchar * stra = NULL;
1669 gchar * strb = NULL;
1670 if (i == 2 || i == 3)
1671 {
1672 j=i-2;
1673 if (! tmp_fshell -> ia[j])
1674 {
1675 stra = g_strdup_printf ("Not picked yet !");
1676 strb = g_strdup_printf (DELETEB);
1677 }
1678 else
1679 {
1680 k = tmp_fshell -> ia[j]-1;
1681 l = tmp_fmol -> atoms_id[k][0].a;
1682 stra = g_strdup_printf ("%s - %d", exact_name(tmp_proj -> chemistry -> label[get_active_atom (tmp_fmol -> id, l) -> sp]), tmp_fshell -> ia[j]);
1683 strb = g_strdup_printf (APPLY);
1684 }
1685 }
1686 else if (i == 4 || i == 5)
1687 {
1688 j=i-4;
1689 if (! tmp_fcons -> ia[j])
1690 {
1691 stra = g_strdup_printf ("Not picked yet !");
1692 strb = g_strdup_printf (DELETEB);
1693 }
1694 else
1695 {
1696 k = tmp_fcons -> ia[j] - 1;
1697 l = tmp_fmol -> atoms_id[k][0].a;
1698 stra = g_strdup_printf ("%s - %d", exact_name(tmp_proj -> chemistry -> label[get_active_atom (tmp_fmol -> id, l) -> sp]), tmp_fcons -> ia[j]);
1699 strb = g_strdup_printf (APPLY);
1700 }
1701 }
1702 else if (i == 6 || i == 7)
1703 {
1704 j=i-6;
1705 if (! tmp_fpmf -> num[j])
1706 {
1707 stra = g_strdup_printf ("Not picked yet !");
1708 strb = g_strdup_printf (DELETEB);
1709 }
1710 else
1711 {
1712 stra = g_strdup_printf ("%d atom(s)", tmp_fpmf -> num[j]);
1713 strb = g_strdup_printf (APPLY);
1714 }
1715 }
1716 else if (i == 8)
1717 {
1718 j=0;
1719 if (! tmp_frig -> num)
1720 {
1721 stra = g_strdup_printf ("Not picked yet !");
1722 strb = g_strdup_printf (DELETEB);
1723 }
1724 else
1725 {
1726 stra = g_strdup_printf ("%d atom(s)", tmp_frig -> num);
1727 strb = g_strdup_printf (APPLY);
1728 }
1729 }
1730 else if (i == 9)
1731 {
1732 j=0;
1733 if (! tmp_ftet -> num)
1734 {
1735 stra = g_strdup_printf ("Not picked yet !");
1736 strb = g_strdup_printf (DELETEB);
1737 }
1738 else
1739 {
1740 k = tmp_fmol -> atoms_id[tmp_ftet -> num - 1][0].a;
1741 stra = g_strdup_printf ("%s - %d", exact_name(tmp_proj -> chemistry -> label[get_active_atom (tmp_fmol -> id, k) -> sp]), tmp_ftet -> num);
1742 strb = g_strdup_printf (APPLY);
1743 }
1744 }
1745 else if (i == 11 || i == 12 || i == 13 || i == 14)
1746 {
1747 j=i-11;
1748 if (tmp_fbody -> na[j] < 0)
1749 {
1750 stra = g_strdup_printf ("Not picked yet !");
1751 strb = g_strdup_printf (DELETEB);
1752 }
1753 else
1754 {
1755 stra = g_strdup_printf ("%s", exact_name(get_active_atom (tmp_fbody -> ma[j][0]-1, tmp_fbody -> a[j][0]) -> name));
1756 strb = g_strdup_printf (APPLY);
1757 }
1758 if (tmp_fbody -> bd == 2)
1759 {
1762 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, cross_hbox, cross_box, FALSE, FALSE, 0);
1764 }
1765 if (tmp_fbody -> na[j] < 0)
1766 {
1768 }
1769 else
1770 {
1772 gtk_combo_box_set_active (GTK_COMBO_BOX(cross_box), 0);
1773 }
1774 gtk_label_set_text (GTK_LABEL(body_lab), body_str (tmp_fbody -> bd));
1775 gtk_label_set_use_markup (GTK_LABEL(body_lab), TRUE);
1776 }
1778 g_free (strb);
1779 if (i == 4 || i == 5)
1780 {
1781 if (tmp_fcons -> ia[0] && tmp_fcons -> ia[1])
1782 {
1783 // update_distance
1784 tmp_fcons -> av = 0.0;
1785 for (k=0; k<tmp_fmol -> multi; k++)
1786 {
1787 l = tmp_fmol -> atoms_id[tmp_fcons -> ia[0]-1][k].a;
1788 m = tmp_fmol -> atoms_id[tmp_fcons -> ia[0]-1][k].b;
1789 n = get_active_atom (tmp_fmol -> id, l) -> list[m];
1790 l = tmp_fmol -> atoms_id[tmp_fcons -> ia[1]-1][k].a;
1791 m = tmp_fmol -> atoms_id[tmp_fcons -> ia[1]-1][k].b;
1792 o = get_active_atom (tmp_fmol -> id, l) -> list[m];
1793 tmp_fcons -> av += distance_3d (& tmp_proj -> cell, 0, & tmp_proj -> atoms[0][n], & tmp_proj -> atoms[0][o]).length;
1794 }
1795 tmp_fcons -> av /= tmp_fmol -> multi;
1796 }
1798 }
1799 else if (i == 6 || i == 7)
1800 {
1801 if (tmp_fpmf -> num[0] > 0 && tmp_fpmf -> num[1] > 0)
1802 {
1803 atom at[2][tmp_fmol -> multi];
1804 float ma[2][tmp_fmol -> multi];
1805 gboolean all_zero = TRUE;
1806 float v;
1807 for (k=0; k<2; k++)
1808 {
1809 for (l=0; l<tmp_fpmf -> num[k]; l++)
1810 {
1811 if (tmp_fpmf -> weight[k][l] != 0.0)
1812 {
1813 all_zero = FALSE;
1814 break;
1815 }
1816 }
1817 if (! all_zero) break;
1818 }
1819 for (k=0; k<2; k++)
1820 {
1821 for (l=0; l<tmp_fmol -> multi; l++)
1822 {
1823 ma[k][l] = 0.0;
1824 at[k][l].x = 0.0;
1825 at[k][l].y = 0.0;
1826 at[k][l].z = 0.0;
1827 }
1828 }
1829 for (k=0; k<2; k++)
1830 {
1831 for (l=0; l<tmp_fpmf -> num[k]; l++)
1832 {
1833 m = tmp_fpmf -> list[k][l];
1834 for (n=0; n<tmp_fmol -> multi; n++)
1835 {
1836 o = tmp_fmol -> atoms_id[m][n].a;
1837 p = tmp_fmol -> atoms_id[m][n].b;
1838 q = get_active_atom (tmp_fmol -> id, o) -> list[p];
1839 if (all_zero)
1840 {
1841 r = tmp_proj -> atoms[0][q].sp;
1842 v = tmp_proj -> chemistry -> chem_prop[CHEM_M][r];
1843 }
1844 else
1845 {
1846 v = tmp_fpmf -> weight[k][l];
1847 }
1848 at[k][n].x += v * tmp_proj -> atoms[0][q].x;
1849 at[k][n].y += v * tmp_proj -> atoms[0][q].y;
1850 at[k][n].z += v * tmp_proj -> atoms[0][q].z;
1851 ma[k][n] += v;
1852 }
1853 }
1854 }
1855 v = 0.0;
1856 for (n=0; n<tmp_fmol -> multi; n++)
1857 {
1858 for (k=0; k<2; k++)
1859 {
1860 at[k][n].x /= ma[k][n];
1861 at[k][n].y /= ma[k][n];
1862 at[k][n].z /= ma[k][n];
1863 }
1864 v += distance_3d (& tmp_proj -> cell, 0, & at[0][n], & at[1][n]).length;
1865 }
1866 tmp_fpmf -> av = v / tmp_fmol -> multi;
1867 }
1869 }
1870 gtk_button_set_label (but, stra);
1871 gtk_widget_set_size_request ((GtkWidget *)but, 150, -1);
1872 g_free (stra);
1873}
1874
1883G_MODULE_EXPORT void changed_atom_combo (GtkComboBox * box, gpointer data)
1884{
1885 int i, j, k;
1886 i = GPOINTER_TO_INT(data);
1887 j = gtk_combo_box_get_active (box);
1888 switch (i)
1889 {
1890 case 0:
1891 widget_set_sensitive (afftype, (j) ? TRUE : FALSE);
1892 k = -1;
1893 if (tmp_fat -> afid > -1)
1894 {
1895 for (k=0; k<atoms_id[tmp_fat -> sp]; k++)
1896 {
1897 if (atoms_id_list[tmp_fat -> sp][k] == tmp_fat -> afid) break;
1898 }
1899 }
1900 gtk_combo_box_set_active (GTK_COMBO_BOX(afftype), k+1);
1901 if (j)
1902 {
1903 tmp_fat -> mass =(tmp_fat -> afid < 0) ? tmp_proj -> chemistry -> chem_prop[CHEM_M][tmp_fat -> sp] : get_force_field_atom_mass (tmp_fat -> sp, tmp_fat -> afid);
1904 }
1905 else
1906 {
1907 tmp_fat -> mass = tmp_proj -> chemistry -> chem_prop[CHEM_M][tmp_fat -> sp];
1908 }
1909 break;
1910 case 1:
1911 if (j > 0)
1912 {
1913 tmp_fat -> afid = atoms_id_list[tmp_fat -> sp][j - 1];
1914 }
1915 else
1916 {
1917 tmp_fat -> afid = - 1;
1918 }
1919 tmp_fat -> mass = get_force_field_atom_mass (tmp_fat -> sp, j-1);
1921 break;
1922 }
1923}
1924
1934gchar * get_body_element_name (field_nth_body * body, int aid, int nbd)
1935{
1936 int i, j;
1937 i = body -> ma[aid][0];
1938 if (! nbd)
1939 {
1940 return g_strdup_printf ("%s", get_active_atom (i, body -> a[aid][0]) -> name);
1941 }
1942 else
1943 {
1944 j = get_active_shell (i, body -> a[aid][0]-nbd+1) -> ia[0];
1945 return g_strdup_printf ("%s_sh", get_active_atom (i, j) -> name);
1946 }
1947}
1948
1960gboolean body_identicals (field_nth_body * body, int nbd, int * na, int ** ma, int ** ba)
1961{
1962 gchar * stra, * strb, * strc, * strd;
1963 int i, j;
1964 stra = get_body_element_name (body, 0, 0);
1965 strb = get_body_element_name (body, 1, 0);
1966 i = ma[0][0];
1967 if (ba[0][0] < nbd)
1968 {
1969 strc = g_strdup_printf ("%s", get_active_atom (i, ba[0][0]) -> name);
1970 }
1971 else
1972 {
1973 j = get_active_shell (i, ba[0][0]-nbd) -> ia[0];
1974 strc = g_strdup_printf ("%s_sh", get_active_atom (i, j) -> name);
1975 }
1976 i = ma[1][0];
1977 if (ba[1][0] < nbd)
1978 {
1979 strd = g_strdup_printf ("%s", get_active_atom (i, ba[1][0]) -> name);
1980 }
1981 else
1982 {
1983 j = get_active_shell (i, ba[1][0]-nbd) -> ia[0];
1984 strd = g_strdup_printf ("%s_sh", get_active_atom (i, j) -> name);
1985 }
1986 gboolean res = FALSE;
1987 if (g_strcmp0(stra, strc) == 0 && g_strcmp0(strb, strd) == 0) res = TRUE;
1988 if (g_strcmp0(stra, strd) == 0 && g_strcmp0(strb, strc) == 0) res = TRUE;
1989 // g_debug ("stra= %s, strb= %s, strc= %s, strd= %s:: res= %d", stra, strb, strc, strd, res);
1990 g_free (stra);
1991 g_free (strb);
1992 g_free (strc);
1993 g_free (strd);
1994 return res;
1995}
1996
2003{
2004 int i;
2005 field_molecule * molff;
2006 field_shell * shellff;
2007 molff = tmp_field -> first_molecule;
2008 i = 0;
2009 while (molff)
2010 {
2011 i += molff -> atoms;
2012 shellff = molff -> first_shell;
2013 while (shellff)
2014 {
2015 if (shellff -> use && shellff -> vdw && shellff -> ia[0] > -1) i ++;
2016 shellff = shellff -> next;
2017 }
2018 molff = molff -> next;
2019 }
2020 return i;
2021}
2022
2030void adjust_vdw_interactions (gboolean add_shell)
2031{
2032 int i, j, k, l, m, n;
2033 field_molecule * molff;
2034 field_atom* atff;
2035 field_shell * shellff;
2036 field_nth_body * bodyff;
2037
2038 i = get_num_vdw_max ();
2039 m = i * (i+1) / 2;
2040 n = (add_shell) ? i * (i-1) / 2 : (i+1) * (i+2) / 2;
2041 bodyff = get_active_body (0, 0);
2042 while (bodyff)
2043 {
2044 for (j=0; j<2; j++)
2045 {
2046 k = bodyff -> ma[j][0];
2047 if (bodyff -> a[j][0] >= n)
2048 {
2049 bodyff -> a[j][0] -= n;
2050 bodyff -> a[j][0] += m;
2051 }
2052 }
2053 bodyff = bodyff -> next;
2054 }
2055 if (add_shell)
2056 {
2057 gboolean add_vdw;
2058 gchar * str;
2059 gchar ** to_be_vdw = g_malloc (i*sizeof*to_be_vdw);
2060 int * vdw_mlist = allocint (i);
2061 int ** vdw_aids = allocdint (i,i);
2062 int ** vdw_mids = allocdint (i,i);
2063 int vdw_na[2];
2064 int * vdw_a[2], * vdw_ma[2];
2065 int nbd = m;
2066 molff = tmp_field -> first_molecule;
2067 l = 0;
2068 while (molff)
2069 {
2070 atff = molff -> first_atom;
2071 while (atff)
2072 {
2073 add_vdw = TRUE;
2074 for (k=0; k<l; k++)
2075 {
2076 if (g_strcmp0 (to_be_vdw[k], atff -> name) == 0)
2077 {
2078 add_vdw = FALSE;
2079 vdw_mlist[k] ++;
2080 vdw_mids[k][vdw_mlist[k]] = molff -> id;
2081 vdw_aids[k][vdw_mlist[k]] = atff -> id;
2082 break;
2083 }
2084 }
2085 if (add_vdw)
2086 {
2087 to_be_vdw[k] = g_strdup_printf ("%s", atff -> name);
2088 vdw_mids[k][0] = molff -> id;
2089 vdw_aids[k][0] = atff -> id;
2090 l ++;
2091 }
2092 atff = atff -> next;
2093 }
2094 shellff = molff -> first_shell;
2095 while (shellff)
2096 {
2097 if (shellff -> use && shellff -> vdw && shellff -> ia[0] > -1)
2098 {
2099 add_vdw = TRUE;
2100 atff = get_active_atom (molff -> id, shellff -> ia[0]);
2101 str = g_strdup_printf ("%s_sh", atff -> name);
2102 for (k=0; k<l; k++)
2103 {
2104 if (g_strcmp0 (to_be_vdw[k], str) == 0)
2105 {
2106 add_vdw = FALSE;
2107 vdw_mlist[k] ++;
2108 vdw_mids[k][vdw_mlist[k]] = molff -> id;
2109 vdw_aids[k][vdw_mlist[k]] = shellff -> id + nbd;
2110 break;
2111 }
2112 }
2113 if (add_vdw)
2114 {
2115 to_be_vdw[k] = g_strdup_printf ("%s", str);
2116 vdw_mids[k][0] = molff -> id;
2117 vdw_aids[k][0] = shellff -> id + nbd;
2118 l ++;
2119 }
2120 g_free (str);
2121 }
2122 shellff = shellff -> next;
2123 }
2124 molff = molff -> next;
2125 }
2126 i = tmp_field -> nbody[0];
2127 j = 0;
2128 for (k=0; k<l; k++)
2129 {
2130 bodyff = get_active_body (0, 0);
2131 while (bodyff)
2132 {
2133 vdw_na[0] = vdw_na[1] = vdw_mlist[k]+1;
2134 vdw_a[0] = vdw_a[1] = duplicate_int (vdw_na[0], vdw_aids[k]);
2135 vdw_ma[0] = vdw_ma[1] = duplicate_int (vdw_na[0], vdw_mids[k]);
2136 if (body_identicals(bodyff, nbd, vdw_na, vdw_ma, vdw_a)) break;
2137 bodyff = bodyff -> next;
2138 }
2139 if (! bodyff)
2140 {
2141 bodyff = get_active_body (i+j, 0);
2142 bodyff -> next = init_field_nth_body (i+j, 0, vdw_na, vdw_ma, vdw_a);
2143 bodyff -> next -> prev = bodyff;
2144 j ++;
2145 }
2146 }
2147 for (m=0; m<l-1; m++)
2148 {
2149 for (n=m+1; n<l; n++)
2150 {
2151 bodyff = get_active_body (0, 0);
2152 while (bodyff)
2153 {
2154 vdw_na[0] = vdw_mlist[m]+1;
2155 vdw_na[1] = vdw_mlist[n]+1;
2156 vdw_a[0] = duplicate_int (vdw_na[0], vdw_aids[m]);
2157 vdw_a[1] = duplicate_int (vdw_na[1], vdw_aids[n]);
2158 vdw_ma[0] = duplicate_int (vdw_na[0], vdw_mids[m]);
2159 vdw_ma[1] = duplicate_int (vdw_na[1], vdw_mids[n]);
2160 if (body_identicals(bodyff, nbd, vdw_na, vdw_ma, vdw_a)) break;
2161 bodyff = bodyff -> next;
2162 }
2163 if (! bodyff)
2164 {
2165 bodyff = get_active_body (i+j, 0);
2166 bodyff -> next = init_field_nth_body (i+j, 0, vdw_na, vdw_ma, vdw_a);
2167 bodyff -> next -> prev = bodyff;
2168 j ++;
2169 }
2170 }
2171 }
2172 tmp_field -> nbody[0] += j;
2173 }
2174 else
2175 {
2176 atff = get_active_atom (tmp_fmol -> id, tmp_fshell -> ia[0]);
2177 gchar * str = g_strdup_printf ("%s_sh", atff -> name);
2178 gchar * stra, * strb;
2179 bodyff = get_active_body (0, 0);
2180 i = 0;
2181 while (bodyff)
2182 {
2183 stra = get_body_element_name (bodyff, 0, m+1);
2184 strb = get_body_element_name (bodyff, 1, m+1);
2185 if (g_strcmp0(str,stra) == 0 || g_strcmp0(str,strb) == 0)
2186 {
2187 if (bodyff -> next)
2188 {
2189 bodyff -> prev -> next = bodyff -> next;
2190 bodyff -> next -> prev = bodyff -> prev;
2191 }
2192 else
2193 {
2194 bodyff = bodyff -> prev;
2195 g_free (bodyff -> next);
2196 bodyff -> next = NULL;
2197 }
2198 i ++;
2199 }
2200 g_free (stra);
2201 g_free (strb);
2202 bodyff = bodyff -> next;
2203 }
2204 g_free (str);
2205 tmp_field -> nbody[0] -= i;
2206 }
2207}
2208
2209#ifdef GTK4
2218G_MODULE_EXPORT void shell_in_vdw (GtkCheckButton * but, gpointer data)
2219#else
2228G_MODULE_EXPORT void shell_in_vdw (GtkToggleButton * but, gpointer data)
2229#endif
2230{
2231#ifdef GTK4
2232 tmp_fshell -> vdw = gtk_check_button_get_active (but);
2233#else
2234 tmp_fshell -> vdw = gtk_toggle_button_get_active (but);
2235#endif
2237}
2238
2241
2251G_MODULE_EXPORT void run_edit_parameters (GtkDialog * dialog, gint response_id, gpointer data)
2252{
2253 if (rep.a > 6 && rep.a < MOLIMIT)
2254 {
2256 }
2257 else if (rep.a == 1)
2258 {
2259 if (g_strcmp0 (rep_atom_name, tmp_fat -> name) != 0)
2260 {
2261 // Atom name's change, need to update non bonded interactions
2262 compare_non_bonded (tmp_fat -> name);
2263 }
2264 g_free (rep_atom_name);
2265 rep_atom_name = NULL;
2266 }
2267 destroy_this_dialog (dialog);
2268}
2269
2278void edit_parameters (int f, int id)
2279{
2280 gchar * str = g_strdup_printf ("%s parameter(s)", felemts[f+1]);
2281 GtkWidget * dialog = dialogmodal(str, GTK_WINDOW(field_assistant));
2282 GtkWidget * lab;
2283 GtkWidget * entry;
2284 GtkWidget * but;
2285 GtkWidget * hbox;
2286 GtkWidget * combo;
2287 GtkWidget * box = dialog_get_content_area (dialog);
2288 gboolean show_it;
2289 gboolean use_it;
2290 gchar * cs_name[3]={"Core atom: ", "Shell atom: ", "Selection: "};
2291 gchar * cs_param[4]={"Mass:", "Charge:", "<i>k<sub>2</sub></i> ", "<i>k<sub>4</sub></i> "};
2292 gchar * cs_unit[4]={"g mol<sup>-1</sup>", " ", "&#xC5;<sup>-2</sup>", "&#xC5;<sup>-4</sup>"};
2293 gchar * co_name[4]={"First atom: ", "Second atom: ", "Third atom: ", "Fourth atom: "};
2294 gchar * pm_name[2]={"First unit: ", "Second unit: "};
2295 int i, j, k, l, m;
2296 float v;
2297 gchar * ba;
2298 is_moy = 1;
2299 show_it = use_it = FALSE;
2300 for (i=0; i<2; i++) ff_p_combo[i] = NULL;
2301 if (f < MOLIMIT)
2302 {
2303 i = gtk_combo_box_get_active(GTK_COMBO_BOX(combo_mol[f-1]));
2304 lab = markup_label (g_strdup_printf ("\tMolecule: \t<b>%s</b>", get_active_field_molecule(i) -> name), -1, 30, 0.0, 0.5);
2305 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, lab, FALSE, FALSE, 0);
2307 }
2308 switch (f)
2309 {
2310 case 1:
2311 // Atom edit
2312 tmp_fat = get_active_atom(i, id);
2313 rep_atom_name = g_strdup_printf("%s", tmp_fat -> name);
2314 lab = markup_label (g_strdup_printf ("\tAtom: \t\t<b>%s</b>", rep_atom_name), -1, 50, 0.0, 0.5);
2315 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, lab, FALSE, FALSE, 0);
2316 hbox = create_hbox (0);
2317 str = g_strdup_printf ("Element:");
2318 lab = markup_label (str, 120, 30, 0.0, 0.5);
2319 g_free (str);
2320 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2321 str = g_strdup_printf ("%s", exact_name(tmp_proj -> chemistry -> element[tmp_fat -> sp]));
2322 lab = markup_label (str, -1, -1, 0.5, 0.5);
2323 g_free (str);
2324 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 0);
2325 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 0);
2326 hbox = create_hbox (0);
2327 str = g_strdup_printf ("Field parameters:");
2328 lab = markup_label (str, 120, -1, 0.0, 0.5);
2329 g_free (str);
2330 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2331 combo = create_combo ();
2332 combo_text_append (combo, "Manual");
2333 combo_text_append (combo, "Automatic");
2334 gtk_combo_box_set_active (GTK_COMBO_BOX(combo), (tmp_fat -> afid > -1) ? 1 : 0);
2335 widget_set_sensitive (combo, atoms_id[tmp_fat -> sp]);
2336 g_signal_connect (G_OBJECT(combo), "changed", G_CALLBACK(changed_atom_combo), GINT_TO_POINTER(0));
2337 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, combo, FALSE, FALSE, 0);
2338 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 0);
2339 hbox = create_hbox (0);
2340 str = g_strdup_printf ("Force field type <sup>*</sup>:");
2341 lab = markup_label (str, 120, 30, 0.0, 0.5);
2342 g_free (str);
2343 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2344 afftype = create_combo ();
2345 combo_text_append (afftype, "None");
2346 k = 0;
2347 for (i=0; i<atoms_id[tmp_fat -> sp]; i++)
2348 {
2349 j = atoms_id_list[tmp_fat -> sp][i];
2350 str = g_strdup_printf ("%s", exact_name(ff_atoms[j][2]));
2351 if (g_strcmp0 (ff_atoms[j][3], " ") != 0) str = g_strdup_printf ("%s : %s", str, ff_atoms[j][3]);
2353 g_free (str);
2354 if (atoms_id_list[tmp_fat -> sp][i] == tmp_fat -> afid) k = i+1;
2355 }
2356 gtk_combo_box_set_active (GTK_COMBO_BOX(afftype), k);
2357 g_signal_connect (G_OBJECT(afftype), "changed", G_CALLBACK(changed_atom_combo), GINT_TO_POINTER(1));
2358 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, afftype, FALSE, FALSE, 0);
2359 widget_set_sensitive (afftype, (tmp_fat -> afid > -1) ? TRUE : FALSE);
2360 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 0);
2361 hbox = create_hbox (0);
2362 str = g_strdup_printf ("Name: ");
2363 lab = markup_label (str, 120, -1, 0.0, 0.5);
2364 g_free (str);
2365 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2366 entry = create_entry (G_CALLBACK(update_atom_parameter), 100, 15, FALSE, GINT_TO_POINTER(-1));
2367 update_entry_text (GTK_ENTRY(entry), tmp_fat -> name);
2368 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, entry, FALSE, FALSE, 0);
2369 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 0);
2370 hbox = create_hbox (0);
2371 str = g_strdup_printf ("Mass: ");
2372 lab = markup_label (str, 120, -1, 0.0, 0.5);
2373 g_free (str);
2374 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2375 entry = create_entry (G_CALLBACK(update_atom_parameter), 100, 15, FALSE, GINT_TO_POINTER(0));
2376 update_entry_double (GTK_ENTRY(entry), tmp_fat -> mass);
2377 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, entry, FALSE, FALSE, 0);
2378 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 0);
2379 hbox = create_hbox (0);
2380 str = g_strdup_printf ("Charge: ");
2381 lab = markup_label (str, 120, -1, 0.0, 0.5);
2382 g_free (str);
2383 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2384 entry = create_entry (G_CALLBACK(update_atom_parameter), 100, 15, FALSE, GINT_TO_POINTER(1));
2385 update_entry_double (GTK_ENTRY(entry), tmp_fat -> charge);
2386 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, entry, FALSE, FALSE, 0);
2387 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 0);
2388 hbox = create_hbox (0);
2389 str = g_strdup_printf ("Frozen: ");
2390 lab = markup_label (str, 120, -1, 0.0, 0.5);
2391 g_free (str);
2392 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2393 str = g_strdup_printf ("%d atom(s)", tmp_fat -> frozen);
2394 but = create_button (str, IMG_NONE, NULL, 150, -1, GTK_RELIEF_NORMAL, G_CALLBACK(select_atom_id_from_fied_molecule), GINT_TO_POINTER(1));
2395 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, but, FALSE, FALSE, 0);
2396 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 0);
2397 break;
2398 case 2:
2399 // Shell edit
2400 tmp_fshell = get_active_shell (i, id);
2401 str = g_strdup_printf ("\tCore-Shell N°<b>%d</b>", tmp_fshell -> id+1);
2402 lab = markup_label (str, 300, 50, 0.0, 0.5);
2403 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, lab, FALSE, FALSE, 0);
2404 for (k=0; k<2; k++)
2405 {
2406 hbox = create_hbox (0);
2407 lab = markup_label (cs_name[k], 100, -1, 0.0, 0.5);
2408 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2409 if (! tmp_fshell -> ia[k])
2410 {
2411 str = g_strdup_printf ("Not picked yet !");
2413 }
2414 else
2415 {
2416 j = tmp_fshell -> ia[k] - 1;
2417 l = tmp_fmol -> atoms_id[j][0].a;
2418 str = g_strdup_printf ("%s - %d", exact_name(tmp_proj -> chemistry -> label[get_active_atom (i, l) -> sp]), tmp_fshell -> ia[k]);
2419 img_but[k] = stock_image (APPLY);
2420 }
2421 but = create_button (str, IMG_NONE, NULL, 150, -1, GTK_RELIEF_NORMAL, G_CALLBACK(selection_button), GINT_TO_POINTER(k+2));
2422 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, but, FALSE, FALSE, 0);
2423 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, img_but[k], FALSE, FALSE, 30);
2424 }
2425
2426 /*for (k=0; k<3; k++)
2427 {
2428 shell_hbox[k] = create_hbox (0);
2429 lab = markup_label (cs_name[k], 100, -1, 0.0, 0.5);
2430 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, shell_hbox[k], lab, FALSE, FALSE, 10);
2431 if ((k < 2 && tmp_fshell -> ia[k] == -1) || (k == 2 && ! tmp_fshell -> ib))
2432 {
2433 str = g_strdup_printf ("Not picked yet !");
2434 img_but[k] = stock_image (DELETEB);
2435 }
2436 else
2437 {
2438 if (k < 2)
2439 {
2440 str = g_strdup_printf ("Selected !");
2441 }
2442 else
2443 {
2444 str = g_strdup_printf ("%d atom(s) selected !", tmp_fshell -> ia[1]-1);
2445 }
2446 img_but[k] = stock_image (APPLY);
2447 }
2448 if (k < 2)
2449 {
2450 shell_cbox[k] = create_combo ();
2451 combo_text_append (shell_cbox[k], "Not picked yet !");
2452 switch (k)
2453 {
2454 case 0:
2455 tmp_fat = tmp_fmol -> first_atom;
2456 while (tmp_fat)
2457 {
2458 combo_text_append (shell_cbox[k], tmp_fat -> name);
2459 tmp_fat = tmp_fat -> next;
2460 }
2461 break;
2462 case 1:
2463 combo_text_append (shell_cbox[k], "All atoms");
2464 combo_text_append (shell_cbox[k], "Selected atoms");
2465 break;
2466 }
2467 l = (! k) ? tmp_fshell -> ia[k]+1 : (tmp_fshell -> ia[k] < 1) ? tmp_fshell -> ia[k]+1 : 2;
2468 gtk_combo_box_set_active (GTK_COMBO_BOX(shell_cbox[k]), l);
2469 g_signal_connect (G_OBJECT(shell_cbox[k]), "changed", G_CALLBACK(changed_shell_combo), GINT_TO_POINTER(k));
2470 gtk_widget_set_size_request (shell_cbox[k], 150, -1);
2471 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, shell_hbox[k], shell_cbox[k], FALSE, FALSE, 0);
2472 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, shell_hbox[k], img_but[k], FALSE, FALSE, 30);
2473 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, shell_hbox[k], FALSE, FALSE, 0);
2474 }
2475 else
2476 {
2477 shell_but = create_button (str, IMG_NONE, NULL, 150, -1, GTK_RELIEF_NORMAL, G_CALLBACK(selection_button), GINT_TO_POINTER(2));
2478 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, shell_hbox[k], shell_but, FALSE, FALSE, 0);
2479 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, shell_hbox[k], img_but[k], FALSE, FALSE, 30);
2480 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, shell_hbox[k], FALSE, FALSE, 0);
2481 }
2482 g_free (str);
2483 }
2484 */
2485 for (k=0; k<4; k++)
2486 {
2487 hbox = create_hbox (0);
2488 lab = markup_label (cs_param[k], 100, -1, 0.0, 0.5);
2489 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2490 entry = create_entry (G_CALLBACK(update_atom_parameter), 150, 15, FALSE, GINT_TO_POINTER(2+k));
2491 v = (! k) ? tmp_fshell -> m : (k == 1) ? tmp_fshell -> z : (k == 2) ? tmp_fshell -> k2 : tmp_fshell -> k4;
2492 update_entry_double (GTK_ENTRY(entry), v);
2493 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, entry, FALSE, FALSE, 0);
2494 if (k < 2)
2495 {
2496 str = g_strdup_printf ("%s", cs_unit[k]);
2497 }
2498 else
2499 {
2500 str = g_strdup_printf ("%s %s", fkeysw[activef][0][tmp_field -> energy_unit], cs_unit[k]);
2501 }
2502 lab = markup_label (str, -1, -1, 0.0, 0.5);
2503 g_free (str);
2504 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 30);
2505 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 0);
2506 }
2507 hbox = create_hbox (0);
2508 lab = markup_label("Use non-bonded: ", 185, 40, 0.0, 0.5);
2509 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2510 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, check_button (NULL, -1, -1, tmp_fshell -> vdw, G_CALLBACK(shell_in_vdw), NULL), FALSE, FALSE, 30);
2511 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 0);
2512 show_it = tmp_fshell -> show;
2513 use_it = tmp_fshell -> use;
2514 break;
2515 case 3:
2516 // Constraint edit
2518 str = g_strdup_printf ("\tBond constraint N°<b>%d</b>", tmp_fcons -> id+1);
2519 lab = markup_label (str, 300, 50, 0.0, 0.5);
2520 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, lab, FALSE, FALSE, 0);
2521 for (k=0; k<2; k++)
2522 {
2523 hbox = create_hbox (0);
2524 lab = markup_label (co_name[k], 100, -1, 0.0, 0.5);
2525 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2526 if (! tmp_fcons -> ia[k])
2527 {
2528 str = g_strdup_printf ("Not picked yet !");
2530 }
2531 else
2532 {
2533 j = tmp_fcons -> ia[k]-1;
2534 l = tmp_fmol -> atoms_id[j][0].a;
2535 str = g_strdup_printf ("%s - %d", exact_name(tmp_proj -> chemistry -> label[get_active_atom (i, l) -> sp]), tmp_fcons -> ia[k]);
2536 img_but[k] = stock_image (APPLY);
2537 }
2538 but = create_button (str, IMG_NONE, NULL, 150, -1, GTK_RELIEF_NORMAL, G_CALLBACK(selection_button), GINT_TO_POINTER(k+4));
2539 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, but, FALSE, FALSE, 0);
2540 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, img_but[k], FALSE, FALSE, 30);
2541 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 0);
2542 }
2543 hbox = create_hbox (0);
2544 str = g_strdup_printf ("Av. distance (1): ");
2545 lab = markup_label (str, 100, 50, 0.0, 0.5);
2546 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2547 av_lgt = markup_label ("", 150, 50, 0.5, 0.5);
2549 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, av_lgt, FALSE, FALSE, 0);
2550 str = g_strdup_printf ("[&#xC5;]");
2551 lab = markup_label (str, -1, -1, 0.0, 0.5);
2552 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 30);
2553 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 0);
2554 hbox = create_hbox (0);
2555 str = g_strdup_printf ("Length: ");
2556 lab = markup_label (str, 100, -1, 0.0, 0.5);
2557 g_free (str);
2558 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2559 entry = create_entry (G_CALLBACK(update_atom_parameter), 150, 15, FALSE, GINT_TO_POINTER(6));
2560 update_entry_double (GTK_ENTRY(entry), tmp_fcons -> length);
2561 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, entry, FALSE, FALSE, 0);
2562 str = g_strdup_printf ("[&#xC5;]");
2563 lab = markup_label (str, -1, -1, 0.0, 0.5);
2564 g_free (str);
2565 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 30);
2566 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 0);
2567 show_it = tmp_fcons -> show;
2568 use_it = tmp_fcons -> use;
2569 break;
2570 case 4:
2571 // Pmf edit
2572 tmp_fpmf = get_active_pmf (i, id);
2573 str = g_strdup_printf ("\tMean force potential N°<b>%d</b>", tmp_fpmf -> id+1);
2574 lab = markup_label (str, 300, 50, 0.0, 0.5);
2575 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, lab, FALSE, FALSE, 0);
2576 for (k=0; k<2; k++)
2577 {
2578 hbox = create_hbox (0);
2579 lab = markup_label (pm_name[k], 100, -1, 0.0, 0.5);
2580 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2581 if (tmp_fpmf -> num[k] == 0)
2582 {
2583 str = g_strdup_printf ("Not picked yet !");
2585 }
2586 else
2587 {
2588 str = g_strdup_printf ("%d atom(s)", tmp_fpmf -> num[k]);
2589 img_but[k] = stock_image (APPLY);
2590 }
2591 but = create_button (str, IMG_NONE, NULL, 150, -1, GTK_RELIEF_NORMAL, G_CALLBACK(selection_button), GINT_TO_POINTER(k+6));
2592 g_free (str);
2593 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, but, FALSE, FALSE, 0);
2594 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, img_but[k], FALSE, FALSE, 30);
2595 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 0);
2596 }
2597
2598 hbox = create_hbox (0);
2599 str = g_strdup_printf ("Av. d<sub>1-2</sub> (1): ");
2600 lab = markup_label (str, 100, 50, 0.0, 0.5);
2601 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2602 av_lgt = markup_label ("", 150, 50, 0.5, 0.5);
2604 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, av_lgt, FALSE, FALSE, 0);
2605 str = g_strdup_printf ("[&#xC5;]");
2606 lab = markup_label (str, -1, 50, 0.0, 0.5);
2607 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 30);
2608 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 0);
2609
2610 hbox = create_hbox (0);
2611 str = g_strdup_printf ("Length: ");
2612 lab = markup_label (str, 100, -1, 0.0, 0.5);
2613 g_free (str);
2614 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2615 entry = create_entry (G_CALLBACK(update_atom_parameter), 150, 15, FALSE, GINT_TO_POINTER(7));
2616 update_entry_double (GTK_ENTRY(entry), tmp_fpmf -> length);
2617 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, entry, FALSE, FALSE, 0);
2618 str = g_strdup_printf ("[&#xC5;]");
2619 lab = markup_label (str, -1, -1, 0.0, 0.5);
2620 g_free (str);
2621 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 30);
2622 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 0);
2623 show_it = tmp_fpmf -> show;
2624 use_it = tmp_fpmf -> use;
2625 break;
2626 case 5:
2627 // Rigid edit
2628 tmp_frig = get_active_rigid (i, id);
2629 str = g_strdup_printf ("\tRigid unit N°<b>%d</b>", id+1);
2630 lab = markup_label (str, 300, 50, 0.0, 0.5);
2631 g_free (str);
2632 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, lab, FALSE, FALSE, 0);
2633
2634 hbox = create_hbox (0);
2635 str = g_strdup_printf ("Atom(s): ");
2636 lab = markup_label (str, 100, -1, 0.0, 0.5);
2637 g_free (str);
2638 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2639 if (tmp_frig -> num == 0)
2640 {
2641 str = g_strdup_printf ("Not picked yet !");
2643 }
2644 else
2645 {
2646 str = g_strdup_printf ("%d atom(s)", tmp_frig -> num);
2647 img_but[0] = stock_image (APPLY);
2648 }
2649 but = create_button (str, IMG_NONE, NULL, 150, -1, GTK_RELIEF_NORMAL, G_CALLBACK(selection_button), GINT_TO_POINTER(8));
2650 g_free (str);
2651 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, but, FALSE, FALSE, 0);
2652 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, img_but[0], FALSE, FALSE, 30);
2653 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 0);
2654 show_it = tmp_frig -> show;
2655 use_it = tmp_frig -> use;
2656 break;
2657 case 6:
2658 // Tethered
2659 tmp_ftet = get_active_tethered (i, id);
2660 str = g_strdup_printf ("\tTethered atom N°<b>%d</b>", id+1);
2661 lab = markup_label (str, 300, 50, 0.0, 0.5);
2662 g_free (str);
2663 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, lab, FALSE, FALSE, 0);
2664
2665 hbox = create_hbox (0);
2666 str = g_strdup_printf ("Atom: ");
2667 lab = markup_label (str, 100, -1, 0.0, 0.5);
2668 g_free (str);
2669 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2670 if (! tmp_ftet -> num)
2671 {
2672 str = g_strdup_printf ("Not picked yet !");
2674 }
2675 else
2676 {
2677 k = tmp_fmol -> atoms_id[tmp_ftet -> num-1][0].a;
2678 str = g_strdup_printf ("%s - %d", exact_name(tmp_proj -> chemistry -> label[get_active_atom (i, k) -> sp]), tmp_ftet -> num);
2679 img_but[0] = stock_image (APPLY);
2680 }
2681 but = create_button (str, IMG_NONE, NULL, 150, -1, GTK_RELIEF_NORMAL, G_CALLBACK(selection_button), GINT_TO_POINTER(9));
2682 g_free (str);
2683 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, but, FALSE, FALSE, 0);
2684 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, img_but[0], FALSE, FALSE, 30);
2685 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 0);
2686 show_it = tmp_ftet -> show;
2687 use_it = tmp_ftet -> use;
2688 break;
2689 case SEXTERN:
2691 body_lab = markup_label (field_str(tmp_fext -> key), 250, 50, 0.5, 0.5);
2692 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, body_lab, FALSE, FALSE, 0);
2693 use_it = tmp_fext -> use;
2694 break;
2695 default:
2696 if (f < MOLIMIT)
2697 {
2698 // Bond, angle, dihedral, improper, inversion edit
2699 tmp_fstr = get_active_struct (f-7, i, id);
2700 m = struct_id (f);
2701 str = g_strdup_printf ("\t%s type N°<b>%d</b>\n\tField atoms: <b>", mo_title[f-7], id+1);
2702 for (k=0; k<m; k++)
2703 {
2704 if (k == m-1) str = g_strdup_printf ("%s</b> and <b>", str);
2705 str = g_strdup_printf ("%s%s", str, get_active_atom (i, tmp_fstr -> aid[k]) -> name);
2706 if (m > 2 && k < m-1) str = g_strdup_printf ("%s</b>, <b>", str);
2707 }
2708 str = g_strdup_printf ("%s</b>", str);
2709 edit_atids = allocint (m);
2710 gtk_tree_model_get (GTK_TREE_MODEL(field_model[f]), & field_iter, 0, & is_moy, -1);
2711 if (! is_moy)
2712 {
2713 str = g_strdup_printf ("%s\n\tBetween atoms: <b>", str);
2714 for (k=0; k<m; k++)
2715 {
2716 gtk_tree_model_get (GTK_TREE_MODEL(field_model[f]), & field_iter, k+1, & ba, -1);
2717 edit_atids[k] = (int) string_to_double ((gpointer)ba) - 1;
2718 if (k == m-1) str = g_strdup_printf ("%s</b> and <b>", str);
2719 str = g_strdup_printf ("%s%s", str, ba);
2720 if (m > 2 && k < m-1) str = g_strdup_printf ("%s</b>, <b>", str);
2721 }
2722 str = g_strdup_printf ("%s</b>", str);
2723 if (tmp_fstr -> other)
2724 {
2726 if (! tmp_fprop)
2727 {
2728 tmp_fprop = tmp_fstr -> other;
2729 while (tmp_fprop -> next) tmp_fprop = tmp_fprop -> next;
2730 tmp_fprop -> next = duplicate_field_prop (tmp_fstr -> def, f-7);
2731 tmp_fprop = tmp_fprop -> next;
2732 for (k=0; k<m; k++) tmp_fprop -> aid[k] = edit_atids[k];
2733 }
2734 }
2735 else
2736 {
2737 tmp_fstr -> other = duplicate_field_prop (tmp_fstr -> def, f-7);
2738 for (k=0; k<m; k++) tmp_fstr -> other -> aid[k] = edit_atids[k];
2739 tmp_fprop = tmp_fstr -> other;
2740 }
2741 }
2742 else
2743 {
2744 for (l=0; l<m; l++) edit_atids[l] = -1;
2745 tmp_fprop = tmp_fstr -> def;
2746 }
2747 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, markup_label (str, -1, (is_moy) ? 70 : 100, 0.0, 0.5), FALSE, FALSE, 0);
2748 g_free (str);
2749 show_it = tmp_fprop -> show;
2750 use_it = tmp_fprop -> use;
2751 }
2752 else
2753 {
2754 l = f - MOLIMIT;
2755 tmp_fbody = get_active_body (id, l);
2756 body_lab = markup_label (body_str (tmp_fbody -> bd), 250, 50, 0.5, 0.5);
2757 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, body_lab, FALSE, FALSE, 0);
2758 if (l > 0)
2759 {
2760 for (k=0; k< body_at(l); k++)
2761 {
2762 hbox = create_hbox (0);
2763 if (l == 2)
2764 {
2765 lab = markup_label ("Tersoff atom: ", 100, -1, 0.0, 0.5);
2766 }
2767 else
2768 {
2769 lab = markup_label (co_name[k], 100, -1, 0.0, 0.5);
2770 }
2771 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2772 if (tmp_fbody -> na[k] < 0)
2773 {
2774 str = g_strdup_printf ("Not picked yet !");
2776 }
2777 else
2778 {
2779 str = g_strdup_printf ("%s", get_active_atom (tmp_fbody -> ma[k][0], tmp_fbody -> a[k][0]) -> name);
2780 img_but[k] = stock_image (APPLY);
2781 }
2782 but = create_button (str, IMG_NONE, NULL, 150, -1, GTK_RELIEF_NORMAL, G_CALLBACK(selection_button), GINT_TO_POINTER(11+k));
2783 g_free (str);
2784 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, but, FALSE, FALSE, 0);
2785 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, img_but[k], FALSE, FALSE, 30);
2786 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 0);
2787 }
2788 }
2789 show_it = tmp_fbody -> show;
2790 use_it = tmp_fbody -> use;
2791 }
2792 break;
2793 }
2794 if (f < SEXTERN)
2795 {
2796 hbox = create_hbox (0);
2797 lab = markup_label("Visualize in the model: ", (f == 1) ? 150 : 185, 40, 0.0, 0.5);
2798 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2799 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, check_button (NULL, -1, -1, show_it, G_CALLBACK(visualize_it), GINT_TO_POINTER(f)), FALSE, FALSE, 30);
2800 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 0);
2801 }
2802 if (f == 1)
2803 {
2804 str = g_strdup_printf ("<sup>*</sup> this will be used to adjust bonding, angles, etc ... accordingly,\n"
2805 " providing that some parameters can be found in the force field data.\n"
2806 " Please note that comments are directly imported from the force field file.");
2807 lab = markup_label (str, -1, 75, 0.5, 0.5);
2808 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, lab, FALSE, FALSE, 0);
2809 }
2810 if (f > 1)
2811 {
2812 hbox = create_hbox (0);
2813 lab = markup_label("Use to create force field: ", 185, 40, 0.0, 0.5);
2814 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2815 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, check_button (NULL, -1, -1, use_it, G_CALLBACK(select_it), GINT_TO_POINTER(f)), FALSE, FALSE, 30);
2816 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 0);
2817 if (f > 5)
2818 {
2819 if (f > 6 && f < 16)
2820 {
2821 if (f != 15 || tmp_field -> type < CFF91 || tmp_field -> type > COMPASS)
2822 {
2823 hbox = create_hbox (0);
2824 gchar * funits[5] ={"Ev", "kcal mol<sup>-1</sup>", "kJ mol<sup>-1</sup>", "K B<sup>-1</sup>", "DL_POLY internal units"};
2825 str = g_strdup_printf ("Field parameters <sup>*</sup>:");
2826 lab = markup_label (str, 120, -1, 0.0, 0.5);
2827 g_free (str);
2828 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2829 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, create_field_prop_combo (f, is_moy), FALSE, FALSE, 0);
2830 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 0);
2831 str = g_strdup_printf ("<sup>*</sup> Available parameters with matching chemical species,\n"
2832 " %s force field energy related parameters in: %s \n"
2833 " if required conversion to FIELD file energy unit will be performed upon selection.\n"
2834 " Please note that comments are directly imported from the force field file.\n",
2835 field_acro[tmp_field -> type], funits[ff_unit]);
2836 lab = markup_label (str, -1, 75, 0.5, 0.5);
2837 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, lab, FALSE, FALSE, 0);
2838 }
2839 }
2840 hbox = create_hbox (0);
2841 str = g_strdup_printf ("Potential: ");
2842 lab = markup_label (str, 100, -1, 0.0, 0.5);
2843 g_free (str);
2844 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2846 for (j=0; j<fetypes[activef][f-5]; j++)
2847 {
2848 str = g_strdup_printf ("%s (%s)", fnames[activef][f-5][j], exact_name(fkeysw[activef][f-5][j]));
2850 g_free (str);
2851 }
2852 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, field_key_combo, FALSE, FALSE, 0);
2853 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 0);
2854 param_box = create_hbox (0);
2856 switch (f)
2857 {
2858 case 6:
2859 // Tethered
2860 gtk_combo_box_set_active (GTK_COMBO_BOX(field_key_combo), tmp_ftet -> key);
2861 break;
2862 case SEXTERN:
2863 gtk_combo_box_set_active (GTK_COMBO_BOX(field_key_combo), tmp_fext -> key);
2864 break;
2865 default:
2866 if (f < MOLIMIT)
2867 {
2868 gtk_combo_box_set_active (GTK_COMBO_BOX(field_key_combo), tmp_fprop -> key);
2869 }
2870 else
2871 {
2872 // non nonded
2873 gtk_combo_box_set_active (GTK_COMBO_BOX(field_key_combo), tmp_fbody -> key);
2874 }
2875 break;
2876 }
2877 g_signal_connect (G_OBJECT(field_key_combo), "changed", G_CALLBACK(changed_field_key_combo), GINT_TO_POINTER(f));
2878 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, param_box, p_box, FALSE, FALSE, 0);
2879 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, param_box, FALSE, FALSE, 5);
2880 }
2881 else if (f == 3)
2882 {
2883 hbox = create_hbox (0);
2884 str = g_strdup_printf (" <b>(1)</b> average distance between the 2 atoms\n"
2885 "\tas measured in the 3D model");
2886 lab = markup_label (str, 320, -1, 0.0, 0.5);
2887 g_free (str);
2888 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2889 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 0);
2890 }
2891 else if (f == 4)
2892 {
2893 hbox = create_hbox (0);
2894 str = g_strdup_printf (" <b>(1)</b> average distance between the barycenters\n"
2895 "\tof units 1 and 2 as measured in the model");
2896 lab = markup_label (str, 320, -1, 0.0, 0.5);
2897 g_free (str);
2898 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2899 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 0);
2900 }
2901 }
2902 rep.a = f;
2903 rep.b = m;
2904 g_signal_connect (G_OBJECT(dialog), "response", G_CALLBACK(run_edit_parameters), NULL);
2905 show_the_widgets (dialog);
2906 if (f == 2)
2907 {
2908 if (tmp_fshell -> ia[0] < 0 || tmp_fshell -> ia[1] < 1) hide_the_widgets (shell_hbox[2]);
2909 if (tmp_fshell -> ia[0] < 0) widget_set_sensitive (shell_hbox[1], FALSE);
2910 }
2911
2912 dialog_id ++;
2913 Event_loop[dialog_id] = g_main_loop_new (NULL, FALSE);
2914 g_main_loop_run (Event_loop[dialog_id]);
2915}
2916
2925void update_tersoffs (int id, int key)
2926{
2927 int i;
2928 field_nth_body * bod = tmp_field -> first_body[2];
2929 for (i=0; i<tmp_field -> nbody[2]; i++)
2930 {
2931 if (i != id)
2932 {
2933 if (bod -> key != key)
2934 {
2935 bod -> key = key;
2936 bod -> val = NULL;
2937 bod -> val = allocfloat (fvalues[activef][MOLIMIT-4][bod -> key]);
2938 }
2939 }
2940 if (bod -> next != NULL) bod = bod -> next;
2941 }
2942 if (key && tmp_field -> cross != NULL)
2943 {
2944 g_free (tmp_field -> cross);
2945 tmp_field -> cross = NULL;
2946 }
2947}
2948
2957void check_tersoffs (int id, int key)
2958{
2959 int i, j;
2960 if (change_tersoff && id != -1) update_tersoffs (id, key);
2961 if (! key)
2962 {
2963 if (tmp_field -> cross)
2964 {
2965 g_free (tmp_field -> cross);
2966 tmp_field -> cross = NULL;
2967 }
2968 if (cross)
2969 {
2970 tmp_field -> cross = g_malloc (tmp_field -> nbody[2]*sizeof*tmp_field -> cross);
2971 for (i=0; i<tmp_field -> nbody[2]; i++)
2972 {
2973 tmp_field -> cross[i] = g_malloc (tmp_field -> nbody[2]*sizeof*tmp_field -> cross[i]);
2974 for (j=0; j<tmp_field -> nbody[2]; j++) tmp_field -> cross[i][j] = duplicate_double (3, cross[i][j]);
2975 }
2976 }
2977 else
2978 {
2979 tmp_field -> cross = alloctdouble (tmp_field -> nbody[2], tmp_field -> nbody[2], 3);
2980 }
2981 }
2982}
2983
2993G_MODULE_EXPORT void edit_field_prop (GSimpleAction * action, GVariant * parameter, gpointer data)
2994{
2995 int i, j, k;
2996 i = GPOINTER_TO_INT (data);
2997 gchar * tmp;
2998 switch (i)
2999 {
3000 case 0:
3001 if (action == NULL)
3002 {
3004 tmp = g_strdup_printf ("Please enter name for new molecule N°%d", tmp_field -> molecules);
3005 tmp_fmol -> name = g_strdup_printf("MOL-%d", i);
3006 tmp = cask (tmp, "Molecule name:", 0, tmp_fmol -> name, field_assistant);
3007 if (tmp != NULL)
3008 {
3009 tmp_fmol -> name = g_strdup_printf ("%s", tmp);
3010 g_free (tmp);
3011 }
3012 }
3013 else
3014 {
3016 tmp = g_strdup_printf ("Please enter name for molecule N°%d", row_id+1);
3017 tmp = cask (tmp, "Molecule name:", 0, tmp_fmol -> name, field_assistant);
3018 if (tmp != NULL)
3019 {
3020 tmp_fmol -> name = g_strdup_printf ("%s", tmp);
3021 g_free (tmp);
3023 }
3024 }
3025 break;
3026 default:
3027 if (i == MOLIMIT+2)
3028 {
3029 num_body_d = tmp_field -> nbody[2];
3030 cross = NULL;
3031 if (tmp_field -> cross != NULL)
3032 {
3033 cross = g_malloc (tmp_field -> nbody[2]*sizeof*cross);
3034 for (j=0; j<tmp_field -> nbody[2]; j++)
3035 {
3036 cross[j] = g_malloc (tmp_field -> nbody[2]*sizeof*cross[j]);
3037 for (k=0; k<tmp_field -> nbody[2]; k++) cross[j][k] = duplicate_double (3, tmp_field -> cross[j][k]);
3038 }
3039 }
3040 change_tersoff = FALSE;
3041 }
3043 if (i == MOLIMIT+2) check_tersoffs (tmp_fbody -> id, tmp_fbody -> key);
3045 break;
3046 }
3047}
3048
3058G_MODULE_EXPORT void add_field_prop (GSimpleAction * action, GVariant * parameter, gpointer data)
3059{
3060 int i, j, k, l, m;
3061 gboolean save_it;
3062 i = GPOINTER_TO_INT (data);
3063 field_molecule * fmol;
3064 if (i < MOLIMIT)
3065 {
3066 j = gtk_combo_box_get_active (GTK_COMBO_BOX(combo_mol[i-1]));
3068 }
3069 if (i == 2)
3070 {
3071 if (fmol -> first_shell == NULL)
3072 {
3073 fmol -> first_shell = init_field_shell (fmol -> shells, 0, 0);
3074 }
3075 else
3076 {
3077 tmp_fshell = get_active_shell (j, fmol -> shells);
3078 tmp_fshell -> next = init_field_shell (fmol -> shells, 0, 0);
3079 tmp_fshell -> next -> prev = g_malloc (sizeof*tmp_fshell -> next -> prev);
3080 tmp_fshell -> next -> prev = tmp_fshell;
3081 }
3082 row_id = fmol -> shells;
3083 edit_parameters (i, fmol -> shells);
3084 if (tmp_fshell -> ia[0] || tmp_fshell -> ia[1])
3085 {
3086 fmol -> shells ++;
3087 if (! tmp_fshell -> ia[0] || ! tmp_fshell -> ia[1]) tmp_fshell -> use = FALSE;
3088 }
3089 else
3090 {
3091 tmp_fshell = get_active_shell (j, fmol -> shells);
3092 tmp_fshell -> next = NULL;
3093 if (fmol -> shells == 0) fmol -> first_shell = NULL;
3094 }
3095 }
3096 else if (i == 3)
3097 {
3098 if (fmol -> first_constraint == NULL)
3099 {
3100 fmol -> first_constraint = init_field_constraint (fmol -> constraints, 0, 0);
3101 }
3102 else
3103 {
3104 tmp_fcons = get_active_constraint (j, fmol -> constraints);
3105 tmp_fcons -> next = init_field_constraint (fmol -> constraints, 0, 0);
3106 tmp_fcons -> next -> prev = g_malloc0 (sizeof*tmp_fcons -> next -> prev);
3107 tmp_fcons -> next -> prev = tmp_fcons;
3108 }
3109 row_id = fmol -> constraints;
3110 edit_parameters (i, fmol -> constraints);
3111 if (tmp_fcons -> ia[0] || tmp_fcons -> ia[1])
3112 {
3113 fmol -> constraints ++;
3114 if (! tmp_fcons -> ia[0] || ! tmp_fcons -> ia[1]) tmp_fcons -> use = FALSE;
3115 }
3116 else
3117 {
3118 tmp_fcons = get_active_constraint (j, fmol -> constraints);
3119 tmp_fcons -> next = NULL;
3120 if (fmol -> constraints == 0) fmol -> first_constraint = NULL;
3121 }
3122 }
3123 else if (i == 4)
3124 {
3125 if (fmol -> first_pmf == NULL)
3126 {
3127 fmol -> first_pmf = init_field_pmf (fmol -> pmfs, NULL, NULL, NULL);
3128 }
3129 else
3130 {
3131 tmp_fpmf = get_active_pmf (j, fmol -> pmfs);
3132 tmp_fpmf -> next = init_field_pmf (fmol -> pmfs, NULL, NULL, NULL);
3133 tmp_fpmf -> next -> prev = g_malloc0 (sizeof*tmp_fpmf -> next -> prev);
3134 tmp_fpmf -> next -> prev = tmp_fpmf;
3135 }
3136 row_id = fmol -> pmfs;
3137 edit_parameters (i, fmol -> pmfs);
3138 if (tmp_fpmf -> num[0] > 0 || tmp_fpmf -> num[1] > 0)
3139 {
3140 fmol -> pmfs ++;
3141 if (tmp_fpmf -> length == 0.0 || tmp_fpmf -> num[0] == 0 || tmp_fpmf -> num[1] == 0) tmp_fpmf -> use = FALSE;
3142 if (tmp_fpmf -> use)
3143 {
3144 toviz.c = TRUE;
3145 select_object (i, fmol -> pmfs, j);
3146 }
3147 }
3148 else
3149 {
3150 tmp_fpmf = get_active_pmf (j, fmol -> pmfs);
3151 tmp_fpmf -> next = NULL;
3152 if (fmol -> pmfs == 0) fmol -> first_pmf = NULL;
3153 }
3154 }
3155 else if (i == 5)
3156 {
3157 if (fmol -> first_rigid == NULL)
3158 {
3159 fmol -> first_rigid = init_field_rigid (fmol -> rigids, 0, NULL);
3160 }
3161 else
3162 {
3163 tmp_frig = get_active_rigid (j, fmol -> rigids);
3164 tmp_frig -> next = init_field_rigid (fmol -> rigids, 0, NULL);
3165 tmp_frig -> next -> prev = g_malloc0 (sizeof*tmp_frig -> next -> prev);
3166 tmp_frig -> next -> prev = tmp_frig;
3167 }
3168 row_id = fmol -> rigids;
3169 edit_parameters (i, fmol -> rigids);
3170 if (tmp_frig -> num > 0)
3171 {
3172 fmol -> rigids ++;
3173 tmp_frig -> use = TRUE;
3174 }
3175 else
3176 {
3177 tmp_frig = get_active_rigid (j, fmol -> rigids);
3178 tmp_frig -> next = NULL;
3179 if (fmol -> rigids == 0) fmol -> first_rigid = NULL;
3180 }
3181 }
3182 else if (i == 6)
3183 {
3184 if (fmol -> first_tethered == NULL)
3185 {
3186 fmol -> first_tethered = init_field_tethered (fmol -> tethered, 0);
3187 }
3188 else
3189 {
3190 tmp_ftet = get_active_tethered (j, fmol -> tethered);
3191 tmp_ftet -> next = init_field_tethered (fmol -> tethered, 0);
3192 tmp_ftet -> next -> prev = g_malloc0 (sizeof*tmp_ftet -> next -> prev);
3193 tmp_ftet -> next -> prev = tmp_ftet;
3194 }
3195 row_id = fmol -> tethered;
3196 edit_parameters (i, fmol -> tethered);
3197 if (tmp_ftet -> num)
3198 {
3199 fmol -> tethered ++;
3200 tmp_ftet -> use = TRUE;
3201 }
3202 else
3203 {
3204 tmp_ftet = get_active_tethered (j, fmol -> tethered);
3205 tmp_ftet -> next = NULL;
3206 if (fmol -> tethered == 0) fmol -> first_tethered = NULL;
3207 }
3208 }
3209 else if (i == SEXTERN)
3210 {
3211 if (tmp_field -> first_external == NULL)
3212 {
3213 tmp_field -> first_external = init_field_external (tmp_field -> extern_fields);
3214 }
3215 else
3216 {
3217 tmp_fext = get_active_external (tmp_field -> extern_fields-1);
3218 tmp_fext -> next = init_field_external (tmp_field -> extern_fields);
3219 tmp_fext -> next -> prev = g_malloc0 (sizeof*tmp_fext -> next -> prev);
3220 tmp_fext -> next -> prev = tmp_fext;
3221 }
3222 row_id = tmp_field -> extern_fields;
3223 edit_parameters (i, tmp_field -> extern_fields);
3224 if (tmp_fext -> use && tmp_fext -> key > -1)
3225 {
3226 tmp_field -> extern_fields ++;
3227 }
3228 else
3229 {
3230 tmp_fext = get_active_external (tmp_field -> extern_fields);
3231 tmp_fext -> next = NULL;
3232 if (tmp_field -> extern_fields == 0) tmp_field -> first_external = NULL;
3233 }
3234 }
3235 else
3236 {
3237 j = i - MOLIMIT;
3238 row_id = tmp_field -> nbody[j];
3239 if (tmp_field -> first_body[j] == NULL)
3240 {
3241 tmp_field -> first_body[j] = init_field_nth_body (tmp_field -> nbody[j], j, NULL, NULL, NULL);
3242 }
3243 else
3244 {
3245 tmp_fbody = get_active_body (tmp_field -> nbody[j], j);
3246 tmp_fbody -> next = init_field_nth_body (tmp_field -> nbody[j], j, NULL, NULL, NULL);
3247 tmp_fbody -> next -> prev = g_malloc0 (sizeof*tmp_fbody -> next -> prev);
3248 tmp_fbody -> next -> prev = tmp_fbody;
3249 }
3250 if (j == 2)
3251 {
3252 cross = NULL;
3253 cross = alloctdouble (tmp_field -> nbody[j]+1, tmp_field -> nbody[j]+1, 3);
3254 if (tmp_field -> cross != NULL)
3255 {
3256 for (k=0; k<tmp_field -> nbody[j]; k++)
3257 {
3258 for (l=0; l<tmp_field -> nbody[j]; l++)
3259 {
3260 for (m=0; m<3; m++) cross[k][l][m] = cross[l][k][m] = tmp_field -> cross[k][l][m];
3261 }
3262 }
3263 }
3264 else
3265 {
3266 tmp_field -> cross = alloctdouble (1, 1, 3);
3267 }
3268 }
3269 edit_parameters (i, tmp_field -> nbody[j]);
3270 save_it = FALSE;
3271 k = body_at (j);
3272 for (l=0; l<k; l++) if (tmp_fbody -> na[l] > -1) save_it = TRUE;
3273 if (save_it)
3274 {
3275 tmp_field -> nbody[j] ++;
3276 for (l=0; l<k; l++) if (tmp_fbody -> na[l] < 0) tmp_fbody -> use = FALSE;
3277 if (j == 2) check_tersoffs (tmp_fbody -> id, tmp_fbody -> key);
3278 }
3279 else
3280 {
3281 tmp_fbody = get_active_body (tmp_field -> nbody[j], j);
3282 tmp_fbody -> next = NULL;
3283 if (tmp_field -> nbody[j] == 0) tmp_field -> first_body[j] = NULL;
3284 }
3285 }
3287}
3288
3298G_MODULE_EXPORT void remove_field_prop (GSimpleAction * action, GVariant * parameter, gpointer data)
3299{
3300 int i, j, k, l, m, n, o;
3301 i = GPOINTER_TO_INT (data);
3302 gchar * str;
3303 if (i < MOLIMIT)
3304 {
3305 j = gtk_combo_box_get_active (GTK_COMBO_BOX(combo_mol[i-1]));
3307 str = g_strdup_printf ("Delete %s N°%d from molecule %s, is this correct ?", elemts[i], row_id+1, tmp_fmol -> name);
3308 }
3309 else
3310 {
3311 str = g_strdup_printf ("Delete %s, is this correct ?", elemts[i]);
3312 }
3313 selection_confirmed = FALSE;
3314 field_question (str, G_CALLBACK(confirm_selection), NULL);
3315 g_free (str);
3317 {
3318 if (i == 2)
3319 {
3321 if (tmp_fshell == tmp_fmol -> first_shell)
3322 {
3323 if (tmp_fshell -> next != NULL)
3324 {
3325 tmp_fmol -> first_shell = tmp_fmol -> first_shell -> next;
3326 tmp_fmol -> first_shell -> prev = NULL;
3327 }
3328 else
3329 {
3330 tmp_fmol -> first_shell = NULL;
3331 }
3332 }
3333 else if (tmp_fshell -> next == NULL)
3334 {
3335 tmp_fshell = tmp_fshell -> prev;
3336 tmp_fshell -> next = NULL;
3337 }
3338 else
3339 {
3340 tmp_fshell -> prev -> next = tmp_fshell -> next;
3341 tmp_fshell -> next -> prev = tmp_fshell -> prev;
3342 }
3343 tmp_fmol -> shells --;
3344 tmp_fshell = tmp_fmol -> first_shell;
3345 for (j=0; j<tmp_fmol -> shells; j++)
3346 {
3347 tmp_fshell -> id = j;
3348 if (tmp_fshell -> next != NULL) tmp_fshell = tmp_fshell -> next;
3349 }
3350 }
3351 else if (i == 3)
3352 {
3354 if (tmp_fcons == tmp_fmol -> first_constraint)
3355 {
3356 if (tmp_fcons -> next != NULL)
3357 {
3358 tmp_fmol -> first_constraint = tmp_fmol -> first_constraint -> next;
3359 tmp_fmol -> first_constraint -> prev = NULL;
3360 }
3361 else
3362 {
3363 tmp_fmol -> first_constraint = NULL;
3364 }
3365 }
3366 else if (tmp_fcons -> next == NULL)
3367 {
3368 tmp_fcons = tmp_fcons -> prev;
3369 tmp_fcons -> next = NULL;
3370 }
3371 else
3372 {
3373 tmp_fcons -> prev -> next = tmp_fcons -> next;
3374 tmp_fcons -> next -> prev = tmp_fcons -> prev;
3375 }
3376 tmp_fmol -> constraints --;
3377 tmp_fcons = tmp_fmol -> first_constraint;
3378 for (j=0; j<tmp_fmol -> constraints; j++)
3379 {
3380 tmp_fcons -> id = j;
3381 if (tmp_fcons -> next != NULL) tmp_fcons = tmp_fcons -> next;
3382 }
3383 }
3384 else if (i == 4)
3385 {
3387 if (tmp_fpmf == tmp_fmol -> first_pmf)
3388 {
3389 if (tmp_fpmf -> next != NULL)
3390 {
3391 tmp_fmol -> first_pmf = tmp_fmol -> first_pmf -> next;
3392 tmp_fmol -> first_pmf -> prev = NULL;
3393 }
3394 else
3395 {
3396 tmp_fmol -> first_pmf = NULL;
3397 }
3398 }
3399 else if (tmp_fpmf -> next == NULL)
3400 {
3401 tmp_fpmf = tmp_fpmf -> prev;
3402 tmp_fpmf -> next = NULL;
3403 }
3404 else
3405 {
3406 tmp_fpmf -> prev -> next = tmp_fpmf -> next;
3407 tmp_fpmf -> next -> prev = tmp_fpmf -> prev;
3408 }
3409 tmp_fmol -> pmfs --;
3410 tmp_fpmf = tmp_fmol -> first_pmf;
3411 for (j=0; j<tmp_fmol -> pmfs; j++)
3412 {
3413 tmp_fpmf -> id = j;
3414 if (tmp_fpmf -> next != NULL) tmp_fpmf = tmp_fpmf -> next;
3415 }
3416 }
3417 else if (i == 5)
3418 {
3420 if (tmp_frig == tmp_fmol -> first_rigid)
3421 {
3422 if (tmp_frig -> next != NULL)
3423 {
3424 tmp_fmol -> first_rigid = tmp_fmol -> first_rigid -> next;
3425 tmp_fmol -> first_rigid -> prev = NULL;
3426 }
3427 else
3428 {
3429 tmp_fmol -> first_rigid = NULL;
3430 }
3431 }
3432 else if (tmp_frig -> next == NULL)
3433 {
3434 tmp_frig = tmp_frig -> prev;
3435 tmp_frig -> next = NULL;
3436 }
3437 else
3438 {
3439 tmp_frig -> prev -> next = tmp_frig -> next;
3440 tmp_frig -> next -> prev = tmp_frig -> prev;
3441 }
3442 tmp_fmol -> rigids --;
3443 tmp_frig = tmp_fmol -> first_rigid;
3444 for (j=0; j<tmp_fmol -> rigids; j++)
3445 {
3446 tmp_frig -> id = j;
3447 if (tmp_frig -> next != NULL) tmp_frig = tmp_frig -> next;
3448 }
3449 }
3450 else if (i == 6)
3451 {
3453 if (tmp_ftet == tmp_fmol -> first_tethered)
3454 {
3455 if (tmp_ftet -> next != NULL)
3456 {
3457 tmp_fmol -> first_tethered = tmp_fmol -> first_tethered -> next;
3458 tmp_fmol -> first_tethered -> prev = NULL;
3459 }
3460 else
3461 {
3462 tmp_fmol -> first_tethered = NULL;
3463 }
3464 }
3465 else if (tmp_ftet -> next == NULL)
3466 {
3467 tmp_ftet = tmp_ftet -> prev;
3468 tmp_ftet -> next = NULL;
3469 }
3470 else
3471 {
3472 tmp_ftet -> prev -> next = tmp_ftet -> next;
3473 tmp_ftet -> next -> prev = tmp_ftet -> prev;
3474 }
3475 tmp_fmol -> tethered --;
3476 tmp_ftet = tmp_fmol -> first_tethered;
3477 for (j=0; j<tmp_fmol -> tethered; j++)
3478 {
3479 tmp_ftet -> id = j;
3480 if (tmp_ftet -> next != NULL) tmp_ftet = tmp_ftet -> next;
3481 }
3482 }
3483 else if (i == SEXTERN)
3484 {
3486 if (tmp_fext == tmp_field -> first_external)
3487 {
3488 if (tmp_fext -> next != NULL)
3489 {
3490 tmp_field -> first_external = tmp_field -> first_external -> next;
3491 tmp_field -> first_external -> prev = NULL;
3492 }
3493 else
3494 {
3495 tmp_field -> first_external = NULL;
3496 }
3497 }
3498 else if (tmp_fext -> next == NULL)
3499 {
3500 tmp_fext = tmp_fext -> prev;
3501 tmp_fext -> next = NULL;
3502 }
3503 else
3504 {
3505 tmp_fext -> prev -> next = tmp_fext -> next;
3506 tmp_fext -> next -> prev = tmp_fext -> prev;
3507 }
3508 tmp_field -> extern_fields --;
3509 tmp_fext = tmp_field -> first_external;
3510 for (k=0; k<tmp_field -> extern_fields; k++)
3511 {
3512 tmp_fext -> id = k;
3513 if (tmp_fext -> next != NULL) tmp_fext = tmp_fext -> next;
3514 }
3515 }
3516 else
3517 {
3518 j = i - MOLIMIT;
3520 if (j == 2)
3521 {
3522 cross = NULL;
3523 if (tmp_field -> nbody[j] > 1)
3524 {
3525 cross = alloctdouble (tmp_field -> nbody[j]-1, tmp_field -> nbody[j]-1, 3);
3526 m = -1;
3527 for (k=0; k<tmp_field -> nbody[j]; k++)
3528 {
3529 if (k != tmp_fbody -> id)
3530 {
3531 m ++;
3532 n = -1;
3533 for (l=0; l<tmp_field -> nbody[j]; l++)
3534 {
3535 if (l != tmp_fbody -> id)
3536 {
3537 n ++;
3538 for (o=0; o<3; o++) cross[m][n][o] = cross[n][m][o] = tmp_field -> cross[k][l][o];
3539 }
3540 }
3541 }
3542 }
3543 }
3544 }
3545 if (tmp_fbody == tmp_field -> first_body[j])
3546 {
3547 if (tmp_fbody -> next != NULL)
3548 {
3549 tmp_field -> first_body[j] = tmp_field -> first_body[j] -> next;
3550 tmp_field -> first_body[j] -> prev = NULL;
3551 }
3552 else
3553 {
3554 tmp_field -> first_body[j] = NULL;
3555 }
3556 }
3557 else if (tmp_fbody -> next == NULL)
3558 {
3559 tmp_fbody = tmp_fbody -> prev;
3560 tmp_fbody -> next = NULL;
3561 }
3562 else
3563 {
3564 tmp_fbody -> prev -> next = tmp_fbody -> next;
3565 tmp_fbody -> next -> prev = tmp_fbody -> prev;
3566 }
3567 tmp_field -> nbody[j] --;
3568 g_free (tmp_fbody);
3569 tmp_fbody = tmp_field -> first_body[j];
3570 k = 0;
3571 while (tmp_fbody)
3572 {
3573 tmp_fbody -> id = k;
3574 k ++;
3575 tmp_fbody = tmp_fbody -> next;
3576 }
3577
3578 if (j == 2) check_tersoffs (-1, tmp_field -> first_body[j] -> key);
3579 }
3581 }
3582}
insertion_menu mol[]
Definition w_library.c:193
void field_question(gchar *question, GCallback handler, gpointer data)
ask the use to confirm something
Definition calc.c:103
gboolean selection_confirmed
Definition calc.c:77
G_MODULE_EXPORT void confirm_selection(GtkDialog *dialog, gint response_id, gpointer data)
confirm that the selection is good
Definition calc.c:88
Variable declarations for the MD input preparation assistants.
integer(kind=c_int) function chemistry()
Definition chemistry.F90:22
GtkTreeStore * add_model
Definition cpmd_nose.c:157
void label(cairo_t *cr, double val, int axe, int p, project *this_proj)
draw axis label
Definition labels.c:56
ColRGBA col
Definition d_measures.c:77
int atoms[NUM_STYLES][2]
GtkTreePath * path
Definition datab.c:103
gchar * text
Definition datab.c:105
field_constraint * get_active_constraint(int a, int b)
retrieve constraint property
Definition dlp_active.c:185
field_molecule * get_active_field_molecule(int a)
retrieve field molecule
Definition dlp_active.c:87
field_rigid * get_active_rigid(int a, int b)
retrieve rigid property
Definition dlp_active.c:225
field_prop * get_active_prop_using_atoms(struct field_prop *pr, int ti, int *ids)
retrieve field molecule structural property using atoms
Definition dlp_active.c:286
field_struct * get_active_struct(int s, int a, int b)
retrieve field structural property
Definition dlp_active.c:318
field_shell * get_active_shell(int a, int b)
retrieve shell property
Definition dlp_active.c:165
field_atom * get_active_atom(int a, int b)
retrieve field atom
Definition dlp_active.c:145
field_external * get_active_external(int a)
retrieve external field property
Definition dlp_active.c:125
field_nth_body * get_active_body(int a, int b)
retrieve field nth body interaction
Definition dlp_active.c:106
field_pmf * get_active_pmf(int a, int b)
retrieve PMF property
Definition dlp_active.c:205
field_tethered * get_active_tethered(int a, int b)
retrieve tethered property
Definition dlp_active.c:245
GtkTreeViewColumn * ato_col[4]
Definition dlp_atom.c:62
float val
Definition dlp_init.c:117
GtkCellRenderer * ato_cell[4]
Definition dlp_atom.c:63
field_prop * duplicate_field_prop(field_prop *old_prop, int ti)
create a copy of a field property
Definition dlp_copy.c:218
GtkWidget * combo_cross(field_nth_body *body)
create field cross configuration widgets
Definition dlp_edit.c:467
void select_object(int id, int jd, int kd)
select structural element
Definition dlp_viz.c:425
gchar * mo_title[8]
Definition dlp_field.c:935
int object_is
Definition dlp_edit.c:379
void field_unselect_all()
unselect all atoms
Definition dlp_viz.c:130
dint rep
Definition dlp_edit.c:2239
int * edit_atids
Definition dlp_edit.c:123
float * val_at
Definition dlp_edit.c:1140
void run_select_atom_dialog(GtkDialog *select_dialog, gint response_id, gpointer data)
DL-POLY force field atom selection - creating the dialog.
Definition dlp_atom.c:381
gboolean change_tersoff
Definition dlp_edit.c:420
GtkWidget * shell_but
Definition dlp_edit.c:116
GtkWidget * parameters_box(int obj, int key, gchar **words, float *data)
pepare field property edition parameters
Definition dlp_edit.c:524
G_MODULE_EXPORT void edit_unit_weight(GtkCellRendererText *cell, gchar *path_string, gchar *new_text, gpointer data)
Definition dlp_edit.c:1152
gchar * body_str(int a)
get body potential string name
Definition dlp_edit.c:1638
GtkWidget * add_tree
Definition dlp_edit.c:918
void visualize_single_struct(int id, int jd, int kd, int *ids)
visualize single structural element
Definition dlp_viz.c:488
GtkWidget * shell_hbox[3]
Definition dlp_edit.c:118
void update_field_dist(float v)
update field distance widget
Definition dlp_edit.c:1616
G_MODULE_EXPORT void add_field_prop(GSimpleAction *action, GVariant *parameter, gpointer data)
add field property callback
Definition dlp_edit.c:3058
G_MODULE_EXPORT void update_field_parameter(GtkEntry *res, gpointer data)
update field parameter entry callback
Definition dlp_edit.c:389
int fetypes[2][16]
Definition dlp_field.c:286
void update_tersoffs(int id, int key)
update non bonded potential
Definition dlp_edit.c:2925
int is_moy
Definition dlp_edit.c:122
gchar * felemts[MAXDATA+1]
Definition dlp_field.c:140
gboolean are_identical_prop(int ti, int ai, field_prop *pro_a, field_prop *pro_b)
are the 2 field property identicals ?
Definition dlp_edit.c:135
void select_atom_set_color(GtkCellRenderer *renderer, int i)
set cell renderer color
Definition dlp_edit.c:1030
GtkWidget * img_but[4]
Definition dlp_edit.c:115
void check_tersoffs(int id, int key)
check non bonded potential
Definition dlp_edit.c:2957
G_MODULE_EXPORT void run_add_atom_dialog(GtkDialog *add_dialog, gint response_id, gpointer data)
DL-POLY force field atom selection - running the dialog.
Definition dlp_atom.c:295
G_MODULE_EXPORT void changed_atom_combo(GtkComboBox *box, gpointer data)
change atom
Definition dlp_edit.c:1883
G_MODULE_EXPORT void update_atom_parameter(GtkEntry *res, gpointer data)
update field atom parameter entry callback
Definition dlp_edit.c:337
int ** atoms_id_list
void select_atom_set_cmv(GtkTreeViewColumn *col, GtkCellRenderer *renderer, GtkTreeModel *mod, GtkTreeIter *iter, gpointer data)
field atom set renderer color, markup and visibility in the property edition atom(s) selection tree s...
Definition dlp_edit.c:1046
GtkWidget * centry[3]
Definition dlp_edit.c:416
gchar * elemts[MAXDATA]
Definition dlp_field.c:163
GtkWidget * shell_cbox[2]
Definition dlp_edit.c:119
gchar * get_this_vdw_string()
get VdW formalism description string
Definition dlp_edit.c:490
ColRGBA init_color(int id, int numid)
initialize color based id number over total number of elements
Definition initcoord.c:81
gboolean tersoff_question()
change Tersoff potential ?
Definition dlp_edit.c:663
int get_num_vdw_max()
Get the number of field shell interactions.
Definition dlp_edit.c:2002
void compare_non_bonded(gchar *fatom)
compare non bond interaction parameters
Definition dlp_comp.c:184
void adjust_field_prop(int fil, int sti, field_prop *tmp, int *ids, int key)
adjust field property
Definition dlp_edit.c:163
G_MODULE_EXPORT void select_atom_id_from_fied_molecule(GtkButton *but, gpointer data)
select atom id from field molecule - creating the dialog
Definition dlp_edit.c:1171
int ** sel_at
Definition dlp_atom.c:56
GtkWidget * afftype
Definition dlp_edit.c:121
G_MODULE_EXPORT void edit_field_prop(GSimpleAction *action, GVariant *parameter, gpointer data)
edit field property callback
Definition dlp_edit.c:2993
void check_to_visualize_properties_for_this_field_mol(int pid, int mol)
check if rendering is required for object in molecule
Definition dlp_viz.c:737
GtkWidget * create_field_prop_combo(int f, int is_moy)
create field parameter selection combo box
void adjust_vdw_interactions(gboolean add_shell)
adjust VdW interactions
Definition dlp_edit.c:2030
G_MODULE_EXPORT void select_it(GtkToggleButton *but, gpointer data)
select object toggle callback GTK3
Definition dlp_edit.c:892
GtkWidget * param_prop_param_box(int pid)
prepare field parameter edition widgets
Definition dlp_edit.c:687
void field_selection(int i, int viz, int lab, int aid)
select / unselect atom
Definition dlp_viz.c:91
GtkWidget * field_key_combo
Definition dlp_edit.c:111
GtkWidget * body_lab
Definition dlp_edit.c:120
G_MODULE_EXPORT void selection_button(GtkButton *but, gpointer data)
select field object callback
Definition dlp_edit.c:1663
GtkWidget * param_box
Definition dlp_edit.c:114
int a_ato
Definition dlp_atom.c:57
G_MODULE_EXPORT void remove_field_prop(GSimpleAction *action, GVariant *parameter, gpointer data)
remove field property callback
Definition dlp_edit.c:3298
gchar * rep_atom_name
Definition dlp_edit.c:2240
int * atoms_id
GtkWidget * cross_hbox
Definition dlp_edit.c:113
G_MODULE_EXPORT void changed_cross_combo(GtkComboBox *box, gpointer data)
change field cross combo
Definition dlp_edit.c:449
GtkWidget * p_box
Definition dlp_edit.c:112
G_MODULE_EXPORT void field_molecule_select_atom_id(GtkCellRendererToggle *cell_renderer, gchar *string_path, gpointer data)
on select atom in field molecule toggle callback
Definition dlp_edit.c:930
gboolean body_identicals(field_nth_body *body, int nbd, int *na, int **ma, int **ba)
are these non bonded potentials identicals ?
Definition dlp_edit.c:1960
void check_atom_for_updates()
check for parameters in the database to be used in the force field - creating the dialog
G_MODULE_EXPORT void shell_in_vdw(GtkToggleButton *but, gpointer data)
VdW in shell toggle callback GTK3.
Definition dlp_edit.c:2228
gchar * field_str(int a)
get field external name
Definition dlp_edit.c:648
G_MODULE_EXPORT void run_edit_parameters(GtkDialog *dialog, gint response_id, gpointer data)
edit field parameter - running the dialog
Definition dlp_edit.c:2251
int num_body_d
Definition dlp_edit.c:419
double *** cross
Definition dlp_edit.c:418
G_MODULE_EXPORT void visualize_it(GtkToggleButton *but, gpointer data)
visualize object toggle callback GTK3
Definition dlp_edit.c:839
void visualize_body(int viz, int bd, field_nth_body *body)
show / hide non bonded interaction
Definition dlp_viz.c:341
GtkWidget * ff_p_combo[2]
int active_sel
Definition dlp_atom.c:54
GtkWidget * cross_box
Definition dlp_edit.c:417
void init_default_shaders(glwin *view)
re-initialize the default OpenGL shaders
GtkWidget * av_lgt
Definition dlp_edit.c:1607
G_MODULE_EXPORT void changed_field_key_combo(GtkComboBox *box, gpointer data)
change field key
Definition dlp_edit.c:740
char *** ff_atoms
GtkWidget * cross_vbox
Definition dlp_edit.c:113
void clean_up_molecules_info(gboolean usel)
prepare molecule related widgets in the assistant
Definition dlp_mol.c:124
void edit_parameters(int f, int id)
edit field parameter - creating the dialog
Definition dlp_edit.c:2278
gchar * get_body_element_name(field_nth_body *body, int aid, int nbd)
get field body potential element name
Definition dlp_edit.c:1934
int vdw_id
Definition dlp_edit.c:919
G_MODULE_EXPORT void update_cross_parameter(GtkEntry *res, gpointer data)
update field cross parameter entry callback
Definition dlp_edit.c:430
char * fvars_bond[2][FBONDS][FBONDS_P]
Definition dlp_field.c:306
char * fvars_inversion[2][FINVERS][FINVERS_P]
Definition dlp_field.c:522
char * fvars_dihedral[2][FDIHEDRAL][FDIHEDRAL_P]
Definition dlp_field.c:450
char * fvars_angle[2][FANGLES][FANGLES_P]
Definition dlp_field.c:372
char * fvars_vdw[2][FVDW][FVDW_P]
Definition dlp_field.c:602
GtkTreeIter field_iter
Definition dlp_field.c:948
char * fvars_fbd[2][FFOURBODY][FFOURBODY_P]
Definition dlp_field.c:762
glwin * tmp_view
Definition dlp_field.c:952
field_constraint * tmp_fcons
Definition dlp_field.c:959
int fvalues[2][15][21]
Definition dlp_field.c:255
int field_object
Definition dlp_field.c:979
field_nth_body * tmp_fbody
Definition dlp_field.c:965
project * tmp_proj
Definition dlp_field.c:953
field_shell * tmp_fshell
Definition dlp_field.c:958
field_rigid * tmp_frig
Definition dlp_field.c:961
int body_at(int b)
find the number of atom(s) in a non bonded interaction
Definition dlp_field.c:1022
int num_field_objects
Definition dlp_field.c:981
field_pmf * tmp_fpmf
Definition dlp_field.c:960
gchar * fnames[2][16][21]
Definition dlp_field.c:218
field_external * tmp_fext
Definition dlp_field.c:967
field_atom * tmp_fat
Definition dlp_field.c:957
int row_id
Definition dlp_field.c:982
GtkTreeStore * field_model[MAXDATA]
Definition dlp_field.c:947
char * fvars_ters[2][FTERSOFFS][FTERSOFFS_P]
Definition dlp_field.c:726
int struct_id(int f)
number of atoms in a structural element
Definition dlp_field.c:999
void update_field_trees()
classical force field assistant update all tree models
Definition dlp_field.c:1786
field_struct * tmp_fstr
Definition dlp_field.c:964
field_molecule * tmp_fmol
Definition dlp_field.c:955
field_prop * tmp_fprop
Definition dlp_field.c:963
char * fvars_tbd[2][FTHREEBODY][FTHREEBODY_P]
Definition dlp_field.c:736
field_tethered * tmp_ftet
Definition dlp_field.c:962
GType col_type[MAXDATA][12]
Definition dlp_field.c:856
GtkWidget * field_assistant
Definition dlp_field.c:940
gchar * fkeysw[2][16][21]
Definition dlp_field.c:185
classical_field * tmp_field
Definition dlp_field.c:951
char * fvars_fext[2][FEXTERNAL][FEXTERNAL_P]
Definition dlp_field.c:776
GtkWidget * combo_mol[MOLIMIT-1]
Definition dlp_field.c:944
char * fvars_met[2][FMETALS][FMETALS_P]
Definition dlp_field.c:688
char * fvars_teth[2][FTETH][FTETH_P]
Definition dlp_field.c:292
Variable declarations for the creation of the DL_POLY input file(s)
field_shell * init_field_shell(int id, int ia, int ib)
initialize field core shell interaction
Definition dlp_init.c:394
field_tethered * init_field_tethered(int id, int num)
intialize new field tethered potential
Definition dlp_init.c:510
#define COMPASS
Definition dlp_field.h:138
int * duplicate_int(int num, int *old_val)
copy a list of int
Definition global.c:560
#define CFF91
Definition dlp_field.h:136
float get_force_field_atom_mass(int sp, int num)
get force field atomic mass
#define MOLIMIT
Definition dlp_field.h:117
tint toviz
Definition dlp_viz.c:75
field_prop * init_field_prop(int ti, int key, gboolean show, gboolean use)
initialize new field molecule structural property
Definition dlp_init.c:535
#define CVFF
Definition dlp_field.h:134
#define CVFF_AUG
Definition dlp_field.h:135
char * field_acro[N_FIELDS]
field_pmf * init_field_pmf(int id, int num[2], int *list[2], float *w[2])
initialize new field mean force potential
Definition dlp_init.c:445
float * duplicate_float(int num, float *old_val)
copy a list of float
Definition global.c:592
#define SEXTERN
Definition dlp_field.h:118
#define AMBER99
Definition dlp_field.h:123
void visualize_object(int id, int jd, int kd)
visualize object and update OpenGL rendering
Definition dlp_viz.c:552
field_external * init_field_external(int bi)
intialize new field external potential
Definition dlp_init.c:790
field_constraint * init_field_constraint(int id, int ia, int ib)
initialize field bond constraint
Definition dlp_init.c:419
field_nth_body * init_field_nth_body(int bi, int bd, int *na, int **ma, int **ba)
intialize new field non bonded interaction
Definition dlp_init.c:740
field_rigid * init_field_rigid(int id, int num, int *list)
initialize new field rigid constraint
Definition dlp_init.c:487
int ff_unit
distance distance_3d(cell_info *cell, int mdstep, atom *at, atom *bt)
distance between atom a and b in 3D
Definition ogl_utils.c:81
int multi
Definition dlp_init.c:121
int ** allocdint(int xal, int yal)
allocate an int ** pointer
Definition global.c:330
double * duplicate_double(int num, double *old_val)
copy a list of double
Definition global.c:608
int dialog_id
Definition global.c:167
int activef
Definition global.c:161
GMainLoop * Event_loop[5]
Definition global.c:178
double *** alloctdouble(int xal, int yal, int zal)
allocate a double *** pointer
Definition global.c:498
int * allocint(int val)
allocate an int * pointer
Definition global.c:314
float * allocfloat(int val)
allocate a float * pointer
Definition global.c:398
double string_to_double(gpointer string)
convert string to double
Definition global.c:624
Global variable declarations Global convenience function declarations Global data structure defin...
void run_this_gtk_dialog(GtkWidget *dial, GCallback handler, gpointer data)
run a GTK (3 and 4) basic GtkDialog
Definition gtk-misc.c:492
@ IMG_NONE
Definition global.h:260
GtkWidget * create_entry(GCallback handler, int dim, int cdim, gboolean key_release, gpointer data)
Create a GtkEntry.
Definition gtk-misc.c:1314
void update_entry_double(GtkEntry *entry, double doubleval)
update the content of a GtkEntry as double
Definition gtk-misc.c:633
void set_renderer_color(int tocol, GtkCellRenderer *renderer, ColRGBA col)
set the color of a GtkCellRenderer
Definition gtk-misc.c:1653
GtkWidget * create_scroll(GtkWidget *box, int dimx, int dimy, int shadow)
create a scroll window
Definition gtk-misc.c:1960
GtkWidget * dialogmodal(gchar *str, GtkWindow *parent)
Create a new dialog modal window.
Definition gtk-misc.c:510
const gchar * entry_get_text(GtkEntry *entry)
get the text in a GtkEntry
Definition gtk-misc.c:597
#define BSEP
Definition global.h:245
GtkWidget * stock_image(const gchar *stock_id)
create a GtkImage for the Gtk database
Definition gtk-misc.c:1364
#define APPLY
Definition global.h:220
GtkWidget * check_button(gchar *text, int dimx, int dimy, gboolean state, GCallback handler, gpointer data)
create a check button
Definition gtk-misc.c:1799
@ CONTAINER_SCR
Definition global.h:251
GtkWidget * create_button(gchar *text, int image_format, gchar *image, int dimx, int dimy, int relief, GCallback handler, gpointer data)
create a simple button
Definition gtk-misc.c:1863
GtkWidget * create_combo()
create a GtkCombox widget, note deprecated in GTK4
Definition gtk-misc.c:923
GtkWidget * dialog_get_content_area(GtkWidget *widg)
prepare GtkWidget to insert content in a GtkDialog window
Definition gtk-misc.c:825
GtkWidget * markup_label(gchar *text, int dimx, int dimy, float ax, float ay)
Definition gtk-misc.c:1585
void add_box_child_start(int orientation, GtkWidget *widg, GtkWidget *child, gboolean expand, gboolean fill, int padding)
Add a GtkWidget in a GtkBox at the initial position.
Definition gtk-misc.c:299
#define DELETEB
Definition global.h:222
void widget_set_sensitive(GtkWidget *widg, gboolean sensitive)
Set sensitivity for a GtkWidget, ensuring it is a GtkWidget.
Definition gtk-misc.c:206
void destroy_this_dialog(GtkDialog *dialog)
destroy a GtkDialog
Definition gtk-misc.c:2065
GtkWidget * create_hbox(int spacing)
create a GtkBox with horizontal orientation
Definition gtk-misc.c:813
#define CHEM_M
Definition global.h:298
void combo_text_append(GtkWidget *combo, gchar *text)
append text in GtkComboBox widget
Definition gtk-misc.c:900
GtkWidget * destroy_this_widget(GtkWidget *widg)
destroy a GtkWidget
Definition gtk-misc.c:2034
void update_entry_text(GtkEntry *entry, gchar *text)
update the content of a GtkEntry as string
Definition gtk-misc.c:671
void add_container_child(int type, GtkWidget *widg, GtkWidget *child)
Add a GtkWidget into another GtkWidget.
Definition gtk-misc.c:226
void set_image_from_icon_name(GtkWidget *widg, gchar *icon)
set a image from a stock icon name
Definition gtk-misc.c:1894
void hide_the_widgets(GtkWidget *widg)
hide GtkWidget
Definition gtk-misc.c:189
GtkWidget * create_vbox(int spacing)
create a GtkBox with vertical orientation
Definition gtk-misc.c:801
#define MAXDATA
Number of tabs for the description of the classical force field.
Definition global.h:698
void show_the_widgets(GtkWidget *widg)
show GtkWidget
Definition gtk-misc.c:173
Variable declarations related to the OpenGL window Function declarations related to the OpenGL wind...
action
Definition glview.h:189
Function declarations for the creation of the OpenGL window.
gchar * cask(char *question, char *lab, int id, char *old, GtkWidget *win)
enter a string - prepare the dialog
Definition interface.c:645
gboolean ask_yes_no(gchar *title, gchar *text, int type, GtkWidget *widg)
ask yes or no for something: prepare dialog
Definition interface.c:356
gchar * exact_name(gchar *name)
short cut to print string without spaces
Definition interface.c:370
Messaging function declarations.
integer(kind=c_int) function molecules(frag_and_mol, allbonds)
double z
Definition ogl_draw.c:57
Definition global.h:886
double z
Definition global.h:892
double y
Definition global.h:891
double x
Definition global.h:890
Definition global.h:97
int b
Definition global.h:99
int a
Definition global.h:98
double length
Definition glwin.h:123
Definition glwin.h:875
int c
Definition global.h:107
int a
Definition tab-1.c:95
GtkWidget * res[2]
Definition w_encode.c:212
int element
Definition w_periodic.c:61
GtkWidget * hbox
Definition workspace.c:71
GtkWidget * vbox
Definition workspace.c:72
GtkWidget * lab
Definition workspace.c:73