atomes 1.3.1
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-2026 by CNRS and University of Strasbourg */
15
21
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 * felemt[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);
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 = combo_get_active ((GtkWidget *)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 if (activef)
549 {
550 if (((obj == 1 || obj == 2) && key == FBONDS-1 && (i == 0 || i == 1))
551 || ((obj == 3 || obj == 4) && key == FANGLES-1 && (i == 0 || i == 1))
552 || ((obj == 5 || obj == 6) && (key == FDIHEDRAL-2 || key == FDIHEDRAL-1) && (i == 0 || i == 1))
553 || ((obj == 5 || obj == 6) && (key == 1 || key == 2) && i ==3))
554 {
555 str = g_strdup_printf (" <b><i>%s</i></b>", _(words[i]));
556 }
557 else
558 {
559 str = g_strdup_printf (" <b><i>%s</i></b>", words[i]);
560 }
561 }
562 else
563 {
564 str = g_strdup_printf (" <b><i>%s</i></b>", words[i]);
565 }
566 lab = markup_label (str, 100, -1, 0.0, 0.5);
567 g_free (str);
568 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 50);
569 entry = create_entry (G_CALLBACK(update_field_parameter), 100, 15, FALSE, GINT_TO_POINTER(i));
570 update_entry_double (GTK_ENTRY(entry), data[i]);
571 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, entry, FALSE, FALSE, 0);
572 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 0);
573 }
574 if (obj == 11 && key == 0)
575 {
577 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, cross_vbox, FALSE, FALSE, 0);
579 lab = markup_label (_("<u><i>Cross terms with atom:</i></u>"), 160, -1, 0.0, 0.5);
580 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, cross_hbox, lab, FALSE, FALSE, 30);
582 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, cross_hbox, cross_box, FALSE, FALSE, 0);
583 add_box_child_start (GTK_ORIENTATION_VERTICAL, cross_vbox, cross_hbox, FALSE, FALSE, 10);
584 for (i=11; i< 14; i++)
585 {
586 hbox = create_hbox (0);
587 str = g_strdup_printf (" <b><i>%s</i></b>", words[i]);
588 lab = markup_label (str, 120, -1, 0.0, 0.5);
589 g_free (str);
590 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 50);
591 centry[i-11] = create_entry (G_CALLBACK(update_cross_parameter), 100, 15, FALSE, GINT_TO_POINTER(i-11));
592 update_entry_double (GTK_ENTRY(centry[i-11]), cross[tmp_fbody -> id][0][i-11]);
593 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, centry[i-11], FALSE, FALSE, 0);
594 add_box_child_start (GTK_ORIENTATION_VERTICAL, cross_vbox, hbox, FALSE, FALSE, 0);
595 }
596 if (tmp_fbody -> na[0] < 0)
597 {
599 }
600 else
601 {
603 }
604 }
605 }
606 else
607 {
608 hbox = create_hbox (0);
609 str = g_strdup_printf (_("<i>Tabulated</i>"));
610 lab = markup_label (str, 100, -1, 0.0, 0.5);
611 g_free (str);
612 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 30);
613 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 0);
614 }
615 if (obj == 9 && tmp_field -> type >= CFF91 && tmp_field -> type <= COMPASS)
616 {
617 str = g_strdup_printf (_("In %s, non-bonded interactions are evaluated using: \n%s\n"
618 "Therefore the parameters provided by the force field are incompatible with the DL-POLY options."),
620 hbox = create_hbox (0);
621 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label (str, -1, -1, 0.5, 0.5), FALSE, FALSE, 50);
622 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 10);
623 g_free (str);
624 }
625 else if (obj == 9 && key == 0 && (tmp_field -> type <= CVFF_AUG || tmp_field -> type > COMPASS))
626 {
627 if (tmp_field -> type < CVFF)
628 {
629 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>"
630 " are calculated using Ɛ<sub>i/j</sub> and r0<sub>i/j</sub> provided by the force field parameters."),
632 if (tmp_field -> type > AMBER99)
633 {
634 str = g_strdup_printf (_("%s\nScaled 1-4 exclusion parameters, provided by the %s force field, are ignored."), str, field_acro[tmp_field -> type]);
635 }
636 }
637 else
638 {
639 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>"
640 " are calculated using A<sub>i/j</sub> and B<sub>i/j</sub> provided by the force field parameters."),
642 }
643 hbox = create_hbox (0);
644 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label (str, -1, -1, 0.5, 0.5), FALSE, FALSE, 50);
645 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 10);
646 g_free (str);
647 }
648 else if ((obj == 3 || obj == 4) && tmp_field -> type > AMBER99 && tmp_field -> type < CVFF)
649 {
650 hbox = create_hbox (0);
651 str = g_strdup_printf (_("Urey-Bradley terms provided by the %s force field are ignored.\n"), field_acro[tmp_field -> type]);
652 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label (str, -1, -1, 0.5, 0.5), FALSE, FALSE, 50);
653 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 10);
654 g_free (str);
655 }
656 }
657 return vbox;
658}
659
667gchar * field_str (int a)
668{
669 gchar * str = g_strdup_printf (_("External field"));
670 if (a > -1)
671 {
672 str = g_strdup_printf ("%s: <b>%s</b>", str, (activef) ? fnames[activef][15][a] : _(fnames[activef][15][a]));
673 }
674 return str;
675}
676
683{
684 gchar * text = _("Are you sure to change the type of Tersoff potential ?\n"
685 "<i>Tersoff (ter)</i> and <i>KIHS (kihs)</i> forms cannot be mixed\n"
686 "Therefore this choice will affect <b>all</b> Tersoff potential(s).\n"
687 "Any previous parameters will be erased !");
688 if (num_body_d > 1)
689 {
690 return ask_yes_no (_("Change Tersoff potential ?!"), text, GTK_MESSAGE_QUESTION, field_assistant);
691 }
692 else
693 {
694 change_tersoff = TRUE;
695 return TRUE;
696 }
697}
698
706GtkWidget * param_prop_param_box (int pid)
707{
708 switch (pid)
709 {
710 case MOLIMIT-9:
711 return parameters_box (0, tmp_ftet -> key, fvars_teth[activef][tmp_ftet -> key], tmp_ftet -> val);
712 break;
713 case MOLIMIT-1:
714 return parameters_box (pid-6, tmp_fprop -> key, fvars_inversion[activef][tmp_fprop -> key], tmp_fprop -> val);
715 break;
716 case MOLIMIT:
717 return parameters_box (pid-6, tmp_fbody -> key, fvars_vdw[activef][tmp_fbody -> key], tmp_fbody -> val);
718 break;
719 case MOLIMIT+1:
720 return parameters_box (pid-6, tmp_fbody -> key, fvars_met[activef][tmp_fbody -> key], tmp_fbody -> val);
721 break;
722 case MOLIMIT+2:
723 return parameters_box (pid-6, tmp_fbody -> key, fvars_ters[activef][tmp_fbody -> key], tmp_fbody -> val);
724 break;
725 case MOLIMIT+3:
726 return parameters_box (pid-6, tmp_fbody -> key, fvars_tbd[activef][tmp_fbody -> key], tmp_fbody -> val);
727 break;
728 case MOLIMIT+4:
729 return parameters_box (pid-6, tmp_fbody -> key, fvars_fbd[activef][tmp_fbody -> key], tmp_fbody -> val);
730 break;
731 case SEXTERN:
732 return parameters_box (14, tmp_fext -> key, fvars_fext[activef][tmp_fext -> key], tmp_fext -> val);
733 break;
734 default:
735 switch ((pid-7)/2)
736 {
737 case 0:
738 return parameters_box (pid-6, tmp_fprop -> key, fvars_bond[activef][tmp_fprop -> key], tmp_fprop -> val);
739 break;
740 case 1:
741 return parameters_box (pid-6, tmp_fprop -> key, fvars_angle[activef][tmp_fprop -> key], tmp_fprop -> val);
742 break;
743 default:
744 return parameters_box (pid-6, tmp_fprop -> key, fvars_dihedral[activef][tmp_fprop -> key], tmp_fprop -> val);
745 break;
746 }
747 break;
748 }
749}
750
759G_MODULE_EXPORT void changed_field_key_combo (GtkComboBox * box, gpointer data)
760{
761 int i, j;
762 gboolean changeit = FALSE;
763 i = GPOINTER_TO_INT(data);
764 j = combo_get_active ((GtkWidget *)box);
765 if (i > 6 && i < MOLIMIT)
766 {
767 if (j != tmp_fprop -> key)
768 {
769 tmp_fprop -> key = j;
770 tmp_fprop -> val = NULL;
771 tmp_fprop -> val = allocfloat (fvalues[activef][i-6][j]);
772 changeit = TRUE;
773 }
774 }
775 else
776 {
777 switch (i)
778 {
779 case 6:
780 if (j != tmp_ftet -> key)
781 {
782 tmp_ftet -> key = j;
783 tmp_ftet -> val = NULL;
784 tmp_ftet -> val = allocfloat (fvalues[activef][0][j]);
785 changeit = TRUE;
786 }
787 break;
788 case SEXTERN:
789 if (j != tmp_fext -> key)
790 {
791 tmp_fext -> key = j;
792 gtk_label_set_text (GTK_LABEL(body_lab), field_str(tmp_fext -> key));
793 gtk_label_set_use_markup (GTK_LABEL(body_lab), TRUE);
794 tmp_fext -> val = NULL;
796 changeit = TRUE;
797 }
798 break;
799 default:
800 if (j != tmp_fbody -> key)
801 {
802 changeit = TRUE;
803 if (i == MOLIMIT+2) changeit = tersoff_question ();
804 if (changeit)
805 {
806 tmp_fbody -> key = j;
807 tmp_fbody -> val = NULL;
808 tmp_fbody -> val = allocfloat (fvalues[activef][i-6][j]);
809 if (i == MOLIMIT+2 && j == 0)
810 {
812 }
813 else if (j == 1 && cross != NULL)
814 {
815 g_free (cross);
816 cross = NULL;
817 }
818 }
819 else
820 {
821 combo_set_active ((GtkWidget *)box, tmp_fbody -> key);
822 }
823 }
824 break;
825 }
826 }
827 if (changeit)
828 {
829 if (ff_p_combo[0]) combo_set_active (ff_p_combo[0], 0);
830 if (ff_p_combo[1]) combo_set_active (ff_p_combo[1], 0);
833 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, param_box, p_box, FALSE, FALSE, 0);
835 }
836
837}
838
839#ifdef GTK4
848G_MODULE_EXPORT void visualize_it (GtkCheckButton * but, gpointer data)
849#else
858G_MODULE_EXPORT void visualize_it (GtkToggleButton * but, gpointer data)
859#endif
860{
861 int i, j;
862 i = GPOINTER_TO_INT (data);
863 j = 0;
864 toviz.c = button_get_status ((GtkWidget *)but);
865 if (i < MOLIMIT)
866 {
867 j = combo_get_active (combo_mol[i-1]);
869 }
870 if (is_moy)
871 {
872 visualize_object (i, row_id, j);
874 }
875 else
876 {
878 if (i < MOLIMIT)
879 {
881 tmp_fprop -> show = toviz.c;
882 }
883 }
886}
887
888#ifdef GTK4
897G_MODULE_EXPORT void select_it (GtkCheckButton * but, gpointer data)
898#else
907G_MODULE_EXPORT void select_it (GtkToggleButton * but, gpointer data)
908#endif
909{
910 int i, j;
911 i = GPOINTER_TO_INT (data);
912 toviz.c = button_get_status ((GtkWidget *)but);
913 if (i < MOLIMIT) j = combo_get_active (combo_mol[i-1]);
914 if (is_moy)
915 {
916 select_object (i, row_id, j);
917 }
918 else
919 {
920 tmp_fprop -> use = toviz.c;
921 }
922}
923
924extern ColRGBA init_color (int id, int numid);
925extern int active_sel;
926extern int a_ato;
927extern int ** sel_at;
928extern void run_select_atom_dialog (GtkDialog * select_dialog, gint response_id, gpointer data);
929GtkWidget * add_tree;
931
941G_MODULE_EXPORT void field_molecule_select_atom_id (GtkCellRendererToggle * cell_renderer, gchar * string_path, gpointer data)
942{
943 GtkTreeStore ** model = (GtkTreeStore **)data;
944 GtkTreeIter iter;
945 int h, i, j, k, l, m, n;
946 GtkTreePath * path = gtk_tree_path_new_from_string (string_path);
947 gtk_tree_model_get_iter (GTK_TREE_MODEL(* model), & iter, path);
948 gtk_tree_model_get (GTK_TREE_MODEL(* model), & iter, 0, & i, -1);
949 if (gtk_cell_renderer_toggle_get_active(cell_renderer))
950 {
951 toviz.c = 0;
952 a_ato --;
953 }
954 else
955 {
956 toviz.c = 1;
957 a_ato ++;
958 }
959 if (active_sel < 11)
960 {
961 sel_at[0][i-1] = toviz.c;
962 }
963 switch (active_sel)
964 {
965 case 0:
966 j = i-1;
967 break;
968 case 1:
969 j = i-1;
970 break;
971 case 2:
972 j = tmp_fshell -> id;
973 break;
974 case 3:
975 j = tmp_fshell -> id;
976 break;
977 case 4:
978 j = tmp_fcons -> id;
979 break;
980 case 5:
981 j = tmp_fcons -> id;
982 break;
983 case 6:
984 j = tmp_fpmf -> id;
985 break;
986 case 7:
987 j = tmp_fpmf -> id;
988 break;
989 case 8:
990 j = tmp_frig -> id;
991 break;
992 case 9:
993 j = tmp_ftet -> id;
994 break;
995 default:
996 j = tmp_fbody -> id;
997 break;
998 }
999 if (active_sel < 10)
1000 {
1001 for (k=0; k<tmp_fmol -> multi; k++)
1002 {
1003 l = tmp_fmol -> atoms_id[i-1][k].a;
1004 m = tmp_fmol -> atoms_id[i-1][k].b;
1005 n = get_active_atom (tmp_fmol -> id, l) -> list[m];
1006 field_selection (n, toviz.c, toviz.c, i-1);
1007 }
1008 }
1009 else
1010 {
1011 h = vdw_id = sel_at[0][i-1];
1012 field_nth_body * tmp_fbo = tmp_field -> first_body[0];
1013 for (k=0; k<tmp_field -> nbody[0]; k++)
1014 {
1015 if (tmp_fbo -> id == h)
1016 {
1017 visualize_body (toviz.c, h, tmp_fbo);
1018 break;
1019 }
1020 else if (tmp_fbo -> next != NULL)
1021 {
1022 tmp_fbo = tmp_fbo -> next;
1023 }
1024 }
1025 }
1027 j = (active_sel > 5 && active_sel < 8) ? 1 : 0;
1028 gtk_tree_store_set (* model, & iter, 3+j, toviz.c, -1);
1031}
1032
1041void select_atom_set_color (GtkCellRenderer * renderer, int i)
1042{
1043 set_renderer_color (i, renderer, init_color (i-1, num_field_objects));
1044}
1045
1057void select_atom_set_cmv (GtkTreeViewColumn * col, GtkCellRenderer * renderer, GtkTreeModel * mod, GtkTreeIter * iter, gpointer data)
1058{
1059 int h, i, j, k;
1060 gtk_tree_model_get (mod, iter, 0, & h, -1);
1061 if (active_sel < 11)
1062 {
1063 gtk_tree_model_get (mod, iter, 1, & i, -1);
1064 }
1065 else
1066 {
1067 i = ! h;
1068 }
1069 j = GPOINTER_TO_INT(data);
1070 switch (j)
1071 {
1072 case 0:
1073 gtk_cell_renderer_set_visible (renderer, ! i);
1074 break;
1075 case 1:
1076 if (active_sel > 10)
1077 {
1078 set_renderer_markup (mod, iter, renderer, 1);
1079 i = h;
1080 }
1081 gtk_cell_renderer_set_visible (renderer, i);
1082 break;
1083 case 2:
1084 set_renderer_markup (mod, iter, renderer, 2);
1085 gtk_cell_renderer_set_visible (renderer, i);
1086 break;
1087 case 3:
1088 gtk_cell_renderer_set_visible (renderer, ! i);
1089 break;
1090 case 4:
1091 if ((active_sel > 1 && active_sel < 6) || active_sel > 8)
1092 {
1093 if (active_sel > 10)
1094 {
1095 gtk_tree_model_get (mod, iter, 3, & k, -1);
1096 }
1097 else
1098 {
1099 k = sel_at[0][h-1];
1100 }
1101 if (k || ! a_ato)
1102 {
1103 gtk_cell_renderer_set_visible (renderer, TRUE);
1104 }
1105 else
1106 {
1107 gtk_cell_renderer_set_visible (renderer, ! a_ato);
1108 }
1109 }
1110 else
1111 {
1112 gtk_cell_renderer_set_visible (renderer, ! i);
1113 }
1114 break;
1115 }
1116 if (active_sel < 2 && j < 4)
1117 {
1118 for (i=0; i<tmp_fat -> num/tmp_fmol -> multi; i++)
1119 {
1120 if (sel_at[0][i]+1 == abs(h)) break;
1121 }
1122 if (sel_at[1][i])
1123 {
1124 select_atom_set_color (renderer, sel_at[0][i]+1);
1125 }
1126 else
1127 {
1128 select_atom_set_color (renderer, sel_at[1][i]);
1129 }
1130 }
1131 else if (j < 4)
1132 {
1133 if (h < 0) h = -h;
1134 if (active_sel < 11)
1135 {
1136 k = (sel_at[0][h-1]) ? h : 0;
1137 }
1138 else
1139 {
1140 gtk_tree_model_get (mod, iter, 3, & k, -1);
1141 }
1142 select_atom_set_color (renderer, k);
1143 }
1144}
1145
1146float * val_at;
1147
1148/*
1149* G_MODULE_EXPORT void edit_unit_weight (GtkCellRendererText * cell, gchar * path_string, gchar * new_text, gpointer data)
1150
1151 \brief on edit unit weight callback
1152
1153 \param cell the GtkCellRendererToggle sending the signal
1154 \param string_path the path in the tree store
1155* gchar
1156 \param data the associated data pointer
1157*/
1158G_MODULE_EXPORT void edit_unit_weight (GtkCellRendererText * cell, gchar * path_string, gchar * new_text, gpointer data)
1159{
1160 GtkTreeStore ** model = (GtkTreeStore **)data;
1161 GtkTreeIter iter;
1162 int i;
1163 GtkTreePath * path = gtk_tree_path_new_from_string (path_string);
1164 gtk_tree_model_get_iter (GTK_TREE_MODEL(* model), & iter, path);
1165 gtk_tree_model_get (GTK_TREE_MODEL(* model), & iter, 0, & i, -1);
1166 val_at[i] = string_to_double ((gpointer)new_text);
1167}
1168
1177G_MODULE_EXPORT void select_atom_id_from_fied_molecule (GtkButton * but, gpointer data)
1178{
1179 int i, j, k, l, m, n, o, p, q;
1180 GtkTreeIter id_level;
1181 GtkTreeIter atom_level;
1182 GtkTreeViewColumn * ato_col[5];
1183 GtkCellRenderer * ato_cell[5];
1184 gchar * ato_title[5] = {i18n("Atom Id."), i18n("Fragment"), i18n("Atom"), i18n("Weight (1)"), i18n("Viz.3D & Select")};
1185 gchar * nbd_title[5] = {i18n("Atom Id."), i18n("Field atom"), i18n("Field molecule(s)"), " ", i18n("Viz.3D & Select")};
1186 gchar * ctype[5]={"text", "text", "text", "text", "active"};
1187 GType col_type[2][5] = {{G_TYPE_INT, G_TYPE_INT, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_FLOAT},
1188 {G_TYPE_INT, G_TYPE_INT, G_TYPE_STRING, G_TYPE_FLOAT, G_TYPE_BOOLEAN}};
1189 GType cbl_type[4] = {G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN};
1190 field_object = 1;
1191 active_sel = GPOINTER_TO_INT (data);
1192 gboolean add;
1193 gchar * str;
1194 q = (active_sel > 5 && active_sel < 8) ? 1 : 0;
1195 switch (active_sel)
1196 {
1197 case 0:
1198 str = g_strdup_printf (_("Please select the new atom(s)"));
1199 o = -1;
1200 p = -1;
1201 break;
1202 case 1:
1203 str = g_strdup_printf (_("Please select the atom(s) to freeze / unfreeze"));
1204 o = -1;
1205 p = -1;
1206 break;
1207 case 2:
1208 str = g_strdup_printf (_("Please select the core atom"));
1209 o = tmp_fshell -> ia[0]-1;
1210 p = tmp_fshell -> ia[1]-1;
1211 break;
1212 case 3:
1213 str = g_strdup_printf (_("Please select the atom(s) to shell"));
1214 o = tmp_fshell -> ia[1]-1;
1215 p = tmp_fshell -> ia[0]-1;
1216 break;
1217 case 4:
1218 str = g_strdup_printf (_("Please select the first atom"));
1219 o = tmp_fcons -> ia[0]-1;
1220 p = tmp_fcons -> ia[1]-1;
1221 break;
1222 case 5:
1223 str = g_strdup_printf (_("Please select the second atom"));
1224 o = tmp_fcons -> ia[1]-1;
1225 p = tmp_fcons -> ia[0]-1;
1226 break;
1227 case 6:
1228 str = g_strdup_printf (_("Please select the atom(s) in the first unit"));
1229 break;
1230 case 7:
1231 str = g_strdup_printf (_("Please select the atom(s) in the second unit"));
1232 break;
1233 case 8:
1234 str = g_strdup_printf (_("Please select the atom(s) in the rigid unit"));
1235 p = -1;
1236 break;
1237 case 9:
1238 str = g_strdup_printf (_("Please select the tethered atom"));
1239 o = tmp_ftet -> num-1;
1240 p = -1;
1241 break;
1242 case 11:
1243 if (tmp_fbody -> bd == 2)
1244 {
1245 str = g_strdup_printf (_("Please select the type of field atom"));
1246 }
1247 else
1248 {
1249 str = g_strdup_printf (_("Please select the first type of field atom"));
1250 }
1251 break;
1252 case 12:
1253 str = g_strdup_printf (_("Please select the second type of field atom"));
1254 break;
1255 case 13:
1256 str = g_strdup_printf (_("Please select the third type of field atom"));
1257 break;
1258 case 14:
1259 str = g_strdup_printf (_("Please select the fourth type of field atom"));
1260 break;
1261 }
1262 GtkWidget * amol = dialogmodal (str, GTK_WINDOW(field_assistant));
1263 g_free (str);
1264 gtk_dialog_add_button (GTK_DIALOG(amol), _("Apply"), GTK_RESPONSE_APPLY);
1265 a_ato = 0;
1266 GtkTreeStore * add_model;
1267 if (active_sel < 11)
1268 {
1269 add_model = gtk_tree_store_newv (4+q, col_type[q]);
1270 }
1271 else
1272 {
1273 add_model = gtk_tree_store_newv (4, cbl_type);
1274 }
1275 add_tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(add_model));
1276 if (active_sel < 11)
1277 {
1278 num_field_objects = tmp_fmol -> mol -> natoms;
1279 }
1280
1281 for (i=0; i<4+q; i++)
1282 {
1283 k = i;
1284 if (i < 3+q)
1285 {
1286 ato_cell[i] = gtk_cell_renderer_text_new ();
1287 }
1288 else
1289 {
1290 if (! q) k ++;
1291 ato_cell[i] = gtk_cell_renderer_toggle_new ();
1292 if (active_sel > 1) gtk_cell_renderer_toggle_set_radio (GTK_CELL_RENDERER_TOGGLE(ato_cell[i]), TRUE);
1293 g_signal_connect (G_OBJECT(ato_cell[i]), "toggled", G_CALLBACK(field_molecule_select_atom_id), & add_model);
1294 }
1295 if (active_sel < 11)
1296 {
1297 ato_col[i] = gtk_tree_view_column_new_with_attributes (_(ato_title[k]), ato_cell[i], ctype[k], i, NULL);
1298 }
1299 else
1300 {
1301 ato_col[i] = gtk_tree_view_column_new_with_attributes ((k != 3) ? _(nbd_title[k]) : nbd_title[k], ato_cell[i], ctype[k], i, NULL);
1302 }
1303 gtk_tree_view_append_column (GTK_TREE_VIEW(add_tree), ato_col[i]);
1304 gtk_tree_view_column_set_alignment (ato_col[i], 0.5);
1305 gtk_tree_view_column_set_cell_data_func (ato_col[i], ato_cell[i], select_atom_set_cmv, GINT_TO_POINTER(k), NULL);
1306 if (q && i == 3)
1307 {
1308 g_object_set (ato_cell[i], "editable", TRUE, NULL);
1309 g_signal_connect (G_OBJECT(ato_cell[i]), "edited", G_CALLBACK(edit_unit_weight), & add_model);
1310 }
1311 }
1312 // Clean 3D viz
1314 // fill model
1315 if (active_sel < 2)
1316 {
1317 sel_at = allocdint (2, tmp_fat -> num/tmp_fmol -> multi);
1318 }
1319 else if (active_sel < 11)
1320 {
1321 sel_at = allocdint (2, tmp_fmol -> mol -> natoms);
1322 }
1323 else
1324 {
1325 field_nth_body * tmp_fbo = tmp_field -> first_body[0];
1326 k = 0;
1327 for (i=0; i<tmp_field -> nbody[0]; i++)
1328 {
1329 if (g_strcmp0 (get_active_atom (tmp_fbo -> ma[0][0], tmp_fbo -> a[0][0]) -> name,
1330 get_active_atom (tmp_fbo -> ma[1][0], tmp_fbo -> a[1][0]) -> name) == 0) k ++;
1331 if (tmp_fbo -> next != NULL) tmp_fbo = tmp_fbo -> next;
1332 }
1333 sel_at = allocdint (1, k);
1335 }
1336
1337 if (active_sel < 2)
1338 {
1339 l = 0;
1340 for (i=0; i<tmp_fmol -> mol -> natoms; i++)
1341 {
1342 if (tmp_fmol -> atoms_id[i][0].a == tmp_fat -> id)
1343 {
1344 j = tmp_fmol -> atoms_id[i][0].b;
1345 k = tmp_fat -> list_id[j];
1346 sel_at[0][l] = k;
1347 if (active_sel)
1348 {
1349 sel_at[1][l] = tmp_fat -> frozen_id[j];
1350 }
1351 else
1352 {
1353 sel_at[1][l] = 0;
1354 }
1355 l ++;
1356 }
1357 }
1358 for (i=0; i<tmp_fat -> num/tmp_fmol -> multi; i++)
1359 {
1360 gtk_tree_store_append (add_model, & id_level, NULL);
1361 gtk_tree_store_set (add_model, & id_level, 0, sel_at[0][i]+1, 1, 0, 3, 0, -1);
1362 if (sel_at[1][i])
1363 {
1364 field_molecule_select_atom_id (GTK_CELL_RENDERER_TOGGLE(ato_cell[3]),
1365 gtk_tree_path_to_string(gtk_tree_model_get_path(GTK_TREE_MODEL(add_model), & id_level)),
1366 & add_model);
1367 }
1368 for (j=0; j< tmp_fmol -> multi; j++)
1369 {
1370 gtk_tree_store_append (add_model, & atom_level, & id_level);
1371 k = sel_at[0][i];
1372 l = tmp_fmol -> atoms_id[k][j].b;
1373 m = tmp_fat -> list[l];
1374 str = g_strdup_printf ("%s<sub>%d</sub>", exact_name(tmp_proj -> chemistry -> label[tmp_fat -> sp]), m+1);
1375 gtk_tree_store_set (add_model, & atom_level, 0, -(sel_at[0][i]+1), 1, tmp_fmol -> fragments[j]+1, 2, str, -1);
1376 g_free (str);
1377 }
1378 }
1379 }
1380 else if (active_sel < 4)
1381 {
1382 for (i=0; i<tmp_fmol -> mol -> natoms; i++)
1383 {
1384 if (i != p)
1385 {
1386 gtk_tree_store_append (add_model, & id_level, NULL);
1387 gtk_tree_store_set (add_model, & id_level, 0, i+1, 1, 0, 3, 0, -1);
1388 tmp_fat = get_active_atom (tmp_fmol -> id, tmp_fmol -> atoms_id[i][0].a);
1389 for (j=0; j< tmp_fmol -> multi; j++)
1390 {
1391 gtk_tree_store_append (add_model, & atom_level, & id_level);
1392 k = tmp_fat -> list[tmp_fmol -> atoms_id[i][j].b];
1393 str = g_strdup_printf ("%s<sub>%d</sub>", exact_name(tmp_proj -> chemistry -> label[tmp_fat -> sp]), k+1);
1394 gtk_tree_store_set (add_model, & atom_level, 0, -(i+1), 1, tmp_fmol -> fragments[j]+1, 2, str, -1);
1395 g_free (str);
1396 }
1397 }
1398 }
1399 }
1400 else if (active_sel < 6 || (active_sel > 7 && active_sel < 11))
1401 {
1402 for (i=0; i<tmp_fmol -> mol -> natoms; i++)
1403 {
1404 if (i != p)
1405 {
1406 tmp_fat = get_active_atom (tmp_fmol -> id, tmp_fmol -> atoms_id[i][0].a);
1407 gtk_tree_store_append (add_model, & id_level, NULL);
1408 if (active_sel < 6 || active_sel == 9)
1409 {
1410 if (i == o)
1411 {
1412 k = 1;
1413 }
1414 else
1415 {
1416 k = 0;
1417 }
1418 }
1419 else
1420 {
1421 k = 0;
1422 if (tmp_frig -> num > 0)
1423 {
1424 for (j=0; j<tmp_frig -> num; j++)
1425 {
1426 if (i == tmp_frig -> list[j])
1427 {
1428 k = 1;
1429 break;
1430 }
1431 }
1432 }
1433 }
1434 sel_at[0][i] = k;
1435 gtk_tree_store_set (add_model, & id_level, 0, i+1, 1, 0, 3, 0, -1);
1436 if (sel_at[0][i])
1437 {
1438 field_molecule_select_atom_id (GTK_CELL_RENDERER_TOGGLE(ato_cell[3]),
1439 gtk_tree_path_to_string(gtk_tree_model_get_path(GTK_TREE_MODEL(add_model), & id_level)),
1440 & add_model);
1441 }
1442 for (j=0; j< tmp_fmol -> multi; j++)
1443 {
1444 gtk_tree_store_append (add_model, & atom_level, & id_level);
1445 l = tmp_fat -> list[tmp_fmol -> atoms_id[i][j].b];
1446 str = g_strdup_printf ("%s<sub>%d</sub>", exact_name(tmp_proj -> chemistry -> label[tmp_fat -> sp]), l+1);
1447 gtk_tree_store_set (add_model, & atom_level, 0, -(i+1), 1, tmp_fmol -> fragments[j]+1, 2, str, -1);
1448 g_free (str);
1449 }
1450 }
1451 }
1452 }
1453 else if (active_sel > 10)
1454 {
1455 m = active_sel-11;
1456 field_nth_body * tmp_fbo = tmp_field -> first_body[0];
1457 k = 0;
1458 for (i=0; i<tmp_field -> nbody[0]; i++)
1459 {
1460 // need to find the atoms name
1461 if (g_strcmp0 (get_active_atom (tmp_fbo -> ma[0][0], tmp_fbo -> a[0][0]) -> name,
1462 get_active_atom (tmp_fbo -> ma[1][0], tmp_fbo -> a[1][0]) -> name) == 0)
1463 {
1464 add = TRUE;
1465 for (j=0; j < body_at(tmp_fbody -> bd); j++)
1466 {
1467 if (j != m && tmp_fbody -> na[j] > -1)
1468 {
1469 if (g_strcmp0 (get_active_atom (tmp_fbo -> ma[0][0], tmp_fbo -> a[0][0]) -> name,
1470 get_active_atom (tmp_fbody -> ma[j][0], tmp_fbody -> a[j][0]) -> name) == 0) add = FALSE;
1471 }
1472 }
1473 if (add)
1474 {
1475 gtk_tree_store_append (add_model, & id_level, NULL);
1476 l = 0;
1477 if (tmp_fbody -> na[m] > -1)
1478 {
1479 if (g_strcmp0 (get_active_atom (tmp_fbo -> ma[0][0], tmp_fbo -> a[0][0]) -> name,
1480 get_active_atom (tmp_fbody -> ma[m][0], tmp_fbody -> a[m][0]) -> name) == 0)
1481 {
1482 l = 1;
1483 vdw_id = tmp_fbo -> id;
1484 a_ato = 1;
1485 }
1486 }
1487 gtk_tree_store_set (add_model, & id_level, 0, k+1, 1,
1488 exact_name(get_active_atom (tmp_fbo -> ma[0][0], tmp_fbo -> a[0][0]) -> name), 3, l, -1);
1489 sel_at[0][k] = tmp_fbo -> id;
1490 for (j=0; j<tmp_fbo -> na[0]; j++)
1491 {
1492 gtk_tree_store_append (add_model, & atom_level, & id_level);
1493 gtk_tree_store_set (add_model, & atom_level, 0, 0, 2, get_active_field_molecule(tmp_fbo -> ma[0][j]) -> name, 3, 0, -1);
1494 }
1495 }
1496 k ++;
1497 }
1498 if (tmp_fbo -> next != NULL) tmp_fbo = tmp_fbo -> next;
1499 }
1500 }
1501 else
1502 {
1503 val_at = allocfloat (tmp_fmol -> mol -> natoms);
1504 if (active_sel == 5)
1505 {
1506 k = 1;
1507 m = 0;
1508 }
1509 else
1510 {
1511 k = 0;
1512 m = 1;
1513 }
1514 for (i=0; i<tmp_fmol -> mol -> natoms; i++)
1515 {
1516 add = TRUE;
1517 if (tmp_fpmf -> num[k] > 0)
1518 {
1519 for (l=0; l<tmp_fpmf -> num[k]; l++)
1520 {
1521 if (i == tmp_fpmf -> list[k][l])
1522 {
1523 add = FALSE;
1524 break;
1525 }
1526 }
1527 }
1528 if (add)
1529 {
1530 tmp_fat = get_active_atom (tmp_fmol -> id, tmp_fmol -> atoms_id[i][0].a);
1531 gtk_tree_store_append (add_model, & id_level, NULL);
1532 n = 0;
1533 if (tmp_fpmf -> num[m] > 0)
1534 {
1535 for (l=0; l<tmp_fpmf -> num[m]; l++)
1536 {
1537 if (i == tmp_fpmf -> list[m][l])
1538 {
1539 n = 1;
1540 break;
1541 }
1542 }
1543 }
1544 val_at[i] = tmp_fat -> mass;
1545 sel_at[0][i] = n;
1546 gtk_tree_store_set (add_model, & id_level, 0, i+1, 1, 0, 3, val_at[i], 4, 0, -1);
1547 if (sel_at[0][i])
1548 {
1549 field_molecule_select_atom_id (GTK_CELL_RENDERER_TOGGLE(ato_cell[4]),
1550 gtk_tree_path_to_string(gtk_tree_model_get_path(GTK_TREE_MODEL(add_model), & id_level)),
1551 & add_model);
1552 }
1553 for (l=0; l< tmp_fmol -> multi; l++)
1554 {
1555 gtk_tree_store_append (add_model, & atom_level, & id_level);
1556 n = tmp_fat -> list[tmp_fmol -> atoms_id[i][l].b];
1557 str = g_strdup_printf ("%s<sub>%d</sub>", exact_name(tmp_proj -> chemistry -> label[tmp_fat -> sp]), n+1);
1558 gtk_tree_store_set (add_model, & atom_level, 0, -(i+1), 1, tmp_fmol -> fragments[l]+1, 2, str, -1);
1559 g_free (str);
1560 }
1561 }
1562 }
1563 }
1564 g_object_unref (add_model);
1565
1566 if (active_sel < 2)
1567 {
1568 j = tmp_fat -> num/tmp_fmol -> multi;
1569 }
1570 else
1571 {
1573 }
1574 i = ((j+1)*37 < 500) ? (j+1)*37 : 500;
1575 if (active_sel > 10) q = 1;
1576 GtkWidget * vbox = dialog_get_content_area (amol);
1577 GtkWidget * scrollsets = create_scroll (vbox, 320+q*100, i, GTK_SHADOW_ETCHED_IN);
1579
1580 if (q && active_sel < 11)
1581 {
1582 str = g_strdup_printf (_(" <b>(1)</b> if all 0.0 then atomic weight(s) will be used by DL-POLY"));
1583 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, markup_label(str, -1, -1, 0.0, 0.5), FALSE, FALSE, 0);
1584 g_free (str);
1585 }
1586 if (active_sel < 2)
1587 {
1588 str = g_strdup_printf (_("The atom(s) above will be described\n"
1589 "in the force field using the parameters\n"
1590 "of the <b>%s</b> field atom.\n"),
1591 tmp_fat -> name);
1592 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, markup_label(str, -1, -1, 0.5, 0.5), FALSE, FALSE, 0);
1593 g_free (str);
1594 }
1595 show_the_widgets (amol);
1596 switch (active_sel)
1597 {
1598 case 0:
1599 run_this_gtk_dialog (amol, G_CALLBACK(run_add_atom_dialog), NULL);
1600 break;
1601 default:
1602 run_this_gtk_dialog (amol, G_CALLBACK(run_select_atom_dialog), GINT_TO_POINTER(active_sel));
1603 if (active_sel == 1)
1604 {
1605 str = g_strdup_printf (_("%d atom(s)"), tmp_fat -> frozen);
1606 if (but) gtk_button_set_label (but, str);
1607 }
1608 break;
1609 }
1610 g_free (sel_at);
1611 if (q && active_sel < 11) g_free (val_at);
1612}
1613
1614GtkWidget * av_lgt;
1615
1623void update_field_dist (float v)
1624{
1625 gchar * str;
1626 if (v < 0.0)
1627 {
1628 str = g_strdup_printf (" ");
1629 }
1630 else
1631 {
1632 str = g_strdup_printf ("<b>%8.3f</b>", v);
1633 }
1634 gtk_label_set_text (GTK_LABEL(av_lgt), str);
1635 gtk_label_set_use_markup (GTK_LABEL(av_lgt), TRUE);
1636}
1637
1645gchar * body_str (int a)
1646{
1647 int i, j;
1648 j = body_at (a);
1649 gchar * str = g_strdup_printf ("%s <b>", _(felemt[a+MOLIMIT+1]));
1650 for (i=0; i<j; i++)
1651 {
1652 if (tmp_fbody -> na[i] > -1)
1653 {
1654 str = g_strdup_printf ("%s%s", str, get_active_atom (tmp_fbody -> ma[i][0], tmp_fbody -> a[i][0]) -> name);
1655 }
1656 if (i < j-1 && j > 1) str = g_strdup_printf ("%s - ", str);
1657 }
1658 str = g_strdup_printf ("%s</b>", str);
1659 return str;
1660}
1661
1670G_MODULE_EXPORT void selection_button (GtkButton * but, gpointer data)
1671{
1673 int i, j, k, l, m, n, o, p, q, r;
1674 i = GPOINTER_TO_INT(data);
1675 gchar * stra = NULL;
1676 gchar * strb = NULL;
1677 if (i == 2 || i == 3)
1678 {
1679 j=i-2;
1680 if (! tmp_fshell -> ia[j])
1681 {
1682 stra = g_strdup_printf (_("Not picked yet !"));
1683 strb = g_strdup_printf (DELETEB);
1684 }
1685 else
1686 {
1687 k = tmp_fshell -> ia[j]-1;
1688 l = tmp_fmol -> atoms_id[k][0].a;
1689 stra = g_strdup_printf ("%s - %d", exact_name(tmp_proj -> chemistry -> label[get_active_atom (tmp_fmol -> id, l) -> sp]), tmp_fshell -> ia[j]);
1690 strb = g_strdup_printf (APPLY);
1691 }
1692 }
1693 else if (i == 4 || i == 5)
1694 {
1695 j=i-4;
1696 if (! tmp_fcons -> ia[j])
1697 {
1698 stra = g_strdup_printf (_("Not picked yet !"));
1699 strb = g_strdup_printf (DELETEB);
1700 }
1701 else
1702 {
1703 k = tmp_fcons -> ia[j] - 1;
1704 l = tmp_fmol -> atoms_id[k][0].a;
1705 stra = g_strdup_printf ("%s - %d", exact_name(tmp_proj -> chemistry -> label[get_active_atom (tmp_fmol -> id, l) -> sp]), tmp_fcons -> ia[j]);
1706 strb = g_strdup_printf (APPLY);
1707 }
1708 }
1709 else if (i == 6 || i == 7)
1710 {
1711 j=i-6;
1712 if (! tmp_fpmf -> num[j])
1713 {
1714 stra = g_strdup_printf (_("Not picked yet !"));
1715 strb = g_strdup_printf (DELETEB);
1716 }
1717 else
1718 {
1719 stra = g_strdup_printf (_("%d atom(s)"), tmp_fpmf -> num[j]);
1720 strb = g_strdup_printf (APPLY);
1721 }
1722 }
1723 else if (i == 8)
1724 {
1725 j=0;
1726 if (! tmp_frig -> num)
1727 {
1728 stra = g_strdup_printf (_("Not picked yet !"));
1729 strb = g_strdup_printf (DELETEB);
1730 }
1731 else
1732 {
1733 stra = g_strdup_printf (_("%d atom(s)"), tmp_frig -> num);
1734 strb = g_strdup_printf (APPLY);
1735 }
1736 }
1737 else if (i == 9)
1738 {
1739 j=0;
1740 if (! tmp_ftet -> num)
1741 {
1742 stra = g_strdup_printf (_("Not picked yet !"));
1743 strb = g_strdup_printf (DELETEB);
1744 }
1745 else
1746 {
1747 k = tmp_fmol -> atoms_id[tmp_ftet -> num - 1][0].a;
1748 stra = g_strdup_printf ("%s - %d", exact_name(tmp_proj -> chemistry -> label[get_active_atom (tmp_fmol -> id, k) -> sp]), tmp_ftet -> num);
1749 strb = g_strdup_printf (APPLY);
1750 }
1751 }
1752 else if (i == 11 || i == 12 || i == 13 || i == 14)
1753 {
1754 j=i-11;
1755 if (tmp_fbody -> na[j] < 0)
1756 {
1757 stra = g_strdup_printf (_("Not picked yet !"));
1758 strb = g_strdup_printf (DELETEB);
1759 }
1760 else
1761 {
1762 stra = g_strdup_printf ("%s", exact_name(get_active_atom (tmp_fbody -> ma[j][0]-1, tmp_fbody -> a[j][0]) -> name));
1763 strb = g_strdup_printf (APPLY);
1764 }
1765 if (tmp_fbody -> bd == 2)
1766 {
1769 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, cross_hbox, cross_box, FALSE, FALSE, 0);
1771 }
1772 if (tmp_fbody -> na[j] < 0)
1773 {
1775 }
1776 else
1777 {
1780 }
1781 gtk_label_set_text (GTK_LABEL(body_lab), body_str (tmp_fbody -> bd));
1782 gtk_label_set_use_markup (GTK_LABEL(body_lab), TRUE);
1783 }
1785 g_free (strb);
1786 if (i == 4 || i == 5)
1787 {
1788 if (tmp_fcons -> ia[0] && tmp_fcons -> ia[1])
1789 {
1790 // update_distance
1791 tmp_fcons -> av = 0.0;
1792 for (k=0; k<tmp_fmol -> multi; k++)
1793 {
1794 l = tmp_fmol -> atoms_id[tmp_fcons -> ia[0]-1][k].a;
1795 m = tmp_fmol -> atoms_id[tmp_fcons -> ia[0]-1][k].b;
1796 n = get_active_atom (tmp_fmol -> id, l) -> list[m];
1797 l = tmp_fmol -> atoms_id[tmp_fcons -> ia[1]-1][k].a;
1798 m = tmp_fmol -> atoms_id[tmp_fcons -> ia[1]-1][k].b;
1799 o = get_active_atom (tmp_fmol -> id, l) -> list[m];
1800 tmp_fcons -> av += distance_3d (& tmp_proj -> cell, 0, & tmp_proj -> atoms[0][n], & tmp_proj -> atoms[0][o]).length;
1801 }
1802 tmp_fcons -> av /= tmp_fmol -> multi;
1803 }
1805 }
1806 else if (i == 6 || i == 7)
1807 {
1808 if (tmp_fpmf -> num[0] > 0 && tmp_fpmf -> num[1] > 0)
1809 {
1810 atom at[2][tmp_fmol -> multi];
1811 float ma[2][tmp_fmol -> multi];
1812 gboolean all_zero = TRUE;
1813 float v;
1814 for (k=0; k<2; k++)
1815 {
1816 for (l=0; l<tmp_fpmf -> num[k]; l++)
1817 {
1818 if (tmp_fpmf -> weight[k][l] != 0.0)
1819 {
1820 all_zero = FALSE;
1821 break;
1822 }
1823 }
1824 if (! all_zero) break;
1825 }
1826 for (k=0; k<2; k++)
1827 {
1828 for (l=0; l<tmp_fmol -> multi; l++)
1829 {
1830 ma[k][l] = 0.0;
1831 at[k][l].x = 0.0;
1832 at[k][l].y = 0.0;
1833 at[k][l].z = 0.0;
1834 }
1835 }
1836 for (k=0; k<2; k++)
1837 {
1838 for (l=0; l<tmp_fpmf -> num[k]; l++)
1839 {
1840 m = tmp_fpmf -> list[k][l];
1841 for (n=0; n<tmp_fmol -> multi; n++)
1842 {
1843 o = tmp_fmol -> atoms_id[m][n].a;
1844 p = tmp_fmol -> atoms_id[m][n].b;
1845 q = get_active_atom (tmp_fmol -> id, o) -> list[p];
1846 if (all_zero)
1847 {
1848 r = tmp_proj -> atoms[0][q].sp;
1849 v = tmp_proj -> chemistry -> chem_prop[CHEM_M][r];
1850 }
1851 else
1852 {
1853 v = tmp_fpmf -> weight[k][l];
1854 }
1855 at[k][n].x += v * tmp_proj -> atoms[0][q].x;
1856 at[k][n].y += v * tmp_proj -> atoms[0][q].y;
1857 at[k][n].z += v * tmp_proj -> atoms[0][q].z;
1858 ma[k][n] += v;
1859 }
1860 }
1861 }
1862 v = 0.0;
1863 for (n=0; n<tmp_fmol -> multi; n++)
1864 {
1865 for (k=0; k<2; k++)
1866 {
1867 at[k][n].x /= ma[k][n];
1868 at[k][n].y /= ma[k][n];
1869 at[k][n].z /= ma[k][n];
1870 }
1871 v += distance_3d (& tmp_proj -> cell, 0, & at[0][n], & at[1][n]).length;
1872 }
1873 tmp_fpmf -> av = v / tmp_fmol -> multi;
1874 }
1876 }
1877 gtk_button_set_label (but, stra);
1878 gtk_widget_set_size_request ((GtkWidget *)but, 150, -1);
1879 g_free (stra);
1880}
1881
1890G_MODULE_EXPORT void changed_atom_combo (GtkComboBox * box, gpointer data)
1891{
1892 int i, j, k;
1893 i = GPOINTER_TO_INT(data);
1894 j = combo_get_active ((GtkWidget *)box);
1895 switch (i)
1896 {
1897 case 0:
1898 widget_set_sensitive (afftype, (j) ? TRUE : FALSE);
1899 k = -1;
1900 if (tmp_fat -> afid > -1)
1901 {
1902 for (k=0; k<atoms_id[tmp_fat -> sp]; k++)
1903 {
1904 if (atoms_id_list[tmp_fat -> sp][k] == tmp_fat -> afid) break;
1905 }
1906 }
1908 if (j)
1909 {
1910 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);
1911 }
1912 else
1913 {
1914 tmp_fat -> mass = tmp_proj -> chemistry -> chem_prop[CHEM_M][tmp_fat -> sp];
1915 }
1916 break;
1917 case 1:
1918 if (j > 0)
1919 {
1920 tmp_fat -> afid = atoms_id_list[tmp_fat -> sp][j - 1];
1921 }
1922 else
1923 {
1924 tmp_fat -> afid = - 1;
1925 }
1926 tmp_fat -> mass = get_force_field_atom_mass (tmp_fat -> sp, j-1);
1928 break;
1929 }
1930}
1931
1941gchar * get_body_element_name (field_nth_body * body, int aid, int nbd)
1942{
1943 int i, j;
1944 i = body -> ma[aid][0];
1945 if (! nbd)
1946 {
1947 return g_strdup_printf ("%s", get_active_atom (i, body -> a[aid][0]) -> name);
1948 }
1949 else
1950 {
1951 j = get_active_shell (i, body -> a[aid][0]-nbd+1) -> ia[0];
1952 return g_strdup_printf ("%s_sh", get_active_atom (i, j) -> name);
1953 }
1954}
1955
1967gboolean body_identicals (field_nth_body * body, int nbd, int * na, int ** ma, int ** ba)
1968{
1969 gchar * stra, * strb, * strc, * strd;
1970 int i, j;
1971 stra = get_body_element_name (body, 0, 0);
1972 strb = get_body_element_name (body, 1, 0);
1973 i = ma[0][0];
1974 if (ba[0][0] < nbd)
1975 {
1976 strc = g_strdup_printf ("%s", get_active_atom (i, ba[0][0]) -> name);
1977 }
1978 else
1979 {
1980 j = get_active_shell (i, ba[0][0]-nbd) -> ia[0];
1981 strc = g_strdup_printf ("%s_sh", get_active_atom (i, j) -> name);
1982 }
1983 i = ma[1][0];
1984 if (ba[1][0] < nbd)
1985 {
1986 strd = g_strdup_printf ("%s", get_active_atom (i, ba[1][0]) -> name);
1987 }
1988 else
1989 {
1990 j = get_active_shell (i, ba[1][0]-nbd) -> ia[0];
1991 strd = g_strdup_printf ("%s_sh", get_active_atom (i, j) -> name);
1992 }
1993 gboolean res = FALSE;
1994 if (g_strcmp0(stra, strc) == 0 && g_strcmp0(strb, strd) == 0) res = TRUE;
1995 if (g_strcmp0(stra, strd) == 0 && g_strcmp0(strb, strc) == 0) res = TRUE;
1996 // g_debug ("stra= %s, strb= %s, strc= %s, strd= %s:: res= %d", stra, strb, strc, strd, res);
1997 g_free (stra);
1998 g_free (strb);
1999 g_free (strc);
2000 g_free (strd);
2001 return res;
2002}
2003
2010{
2011 int i;
2012 field_molecule * molff;
2013 field_shell * shellff;
2014 molff = tmp_field -> first_molecule;
2015 i = 0;
2016 while (molff)
2017 {
2018 i += molff -> atoms;
2019 shellff = molff -> first_shell;
2020 while (shellff)
2021 {
2022 if (shellff -> use && shellff -> vdw && shellff -> ia[0] > -1) i ++;
2023 shellff = shellff -> next;
2024 }
2025 molff = molff -> next;
2026 }
2027 return i;
2028}
2029
2037void adjust_vdw_interactions (gboolean add_shell)
2038{
2039 int i, j, k, l, m, n;
2040 field_molecule * molff;
2041 field_atom* atff;
2042 field_shell * shellff;
2043 field_nth_body * bodyff;
2044
2045 i = get_num_vdw_max ();
2046 m = i * (i+1) / 2;
2047 n = (add_shell) ? i * (i-1) / 2 : (i+1) * (i+2) / 2;
2048 bodyff = get_active_body (0, 0);
2049 while (bodyff)
2050 {
2051 for (j=0; j<2; j++)
2052 {
2053 k = bodyff -> ma[j][0];
2054 if (bodyff -> a[j][0] >= n)
2055 {
2056 bodyff -> a[j][0] -= n;
2057 bodyff -> a[j][0] += m;
2058 }
2059 }
2060 bodyff = bodyff -> next;
2061 }
2062 if (add_shell)
2063 {
2064 gboolean add_vdw;
2065 gchar * str;
2066 gchar ** to_be_vdw = g_malloc0(i*sizeof*to_be_vdw);
2067 int * vdw_mlist = allocint (i);
2068 int ** vdw_aids = allocdint (i,i);
2069 int ** vdw_mids = allocdint (i,i);
2070 int vdw_na[2];
2071 int * vdw_a[2], * vdw_ma[2];
2072 int nbd = m;
2073 molff = tmp_field -> first_molecule;
2074 l = 0;
2075 while (molff)
2076 {
2077 atff = molff -> first_atom;
2078 while (atff)
2079 {
2080 add_vdw = TRUE;
2081 for (k=0; k<l; k++)
2082 {
2083 if (g_strcmp0 (to_be_vdw[k], atff -> name) == 0)
2084 {
2085 add_vdw = FALSE;
2086 vdw_mlist[k] ++;
2087 vdw_mids[k][vdw_mlist[k]] = molff -> id;
2088 vdw_aids[k][vdw_mlist[k]] = atff -> id;
2089 break;
2090 }
2091 }
2092 if (add_vdw)
2093 {
2094 to_be_vdw[k] = g_strdup_printf ("%s", atff -> name);
2095 vdw_mids[k][0] = molff -> id;
2096 vdw_aids[k][0] = atff -> id;
2097 l ++;
2098 }
2099 atff = atff -> next;
2100 }
2101 shellff = molff -> first_shell;
2102 while (shellff)
2103 {
2104 if (shellff -> use && shellff -> vdw && shellff -> ia[0] > -1)
2105 {
2106 add_vdw = TRUE;
2107 atff = get_active_atom (molff -> id, shellff -> ia[0]);
2108 str = g_strdup_printf ("%s_sh", atff -> name);
2109 for (k=0; k<l; k++)
2110 {
2111 if (g_strcmp0 (to_be_vdw[k], str) == 0)
2112 {
2113 add_vdw = FALSE;
2114 vdw_mlist[k] ++;
2115 vdw_mids[k][vdw_mlist[k]] = molff -> id;
2116 vdw_aids[k][vdw_mlist[k]] = shellff -> id + nbd;
2117 break;
2118 }
2119 }
2120 if (add_vdw)
2121 {
2122 to_be_vdw[k] = g_strdup_printf ("%s", str);
2123 vdw_mids[k][0] = molff -> id;
2124 vdw_aids[k][0] = shellff -> id + nbd;
2125 l ++;
2126 }
2127 g_free (str);
2128 }
2129 shellff = shellff -> next;
2130 }
2131 molff = molff -> next;
2132 }
2133 i = tmp_field -> nbody[0];
2134 j = 0;
2135 for (k=0; k<l; k++)
2136 {
2137 bodyff = get_active_body (0, 0);
2138 while (bodyff)
2139 {
2140 vdw_na[0] = vdw_na[1] = vdw_mlist[k]+1;
2141 vdw_a[0] = vdw_a[1] = duplicate_int (vdw_na[0], vdw_aids[k]);
2142 vdw_ma[0] = vdw_ma[1] = duplicate_int (vdw_na[0], vdw_mids[k]);
2143 if (body_identicals(bodyff, nbd, vdw_na, vdw_ma, vdw_a)) break;
2144 bodyff = bodyff -> next;
2145 }
2146 if (! bodyff)
2147 {
2148 bodyff = get_active_body (i+j, 0);
2149 bodyff -> next = init_field_nth_body (i+j, 0, vdw_na, vdw_ma, vdw_a);
2150 bodyff -> next -> prev = bodyff;
2151 j ++;
2152 }
2153 }
2154 for (m=0; m<l-1; m++)
2155 {
2156 for (n=m+1; n<l; n++)
2157 {
2158 bodyff = get_active_body (0, 0);
2159 while (bodyff)
2160 {
2161 vdw_na[0] = vdw_mlist[m]+1;
2162 vdw_na[1] = vdw_mlist[n]+1;
2163 vdw_a[0] = duplicate_int (vdw_na[0], vdw_aids[m]);
2164 vdw_a[1] = duplicate_int (vdw_na[1], vdw_aids[n]);
2165 vdw_ma[0] = duplicate_int (vdw_na[0], vdw_mids[m]);
2166 vdw_ma[1] = duplicate_int (vdw_na[1], vdw_mids[n]);
2167 if (body_identicals(bodyff, nbd, vdw_na, vdw_ma, vdw_a)) break;
2168 bodyff = bodyff -> next;
2169 }
2170 if (! bodyff)
2171 {
2172 bodyff = get_active_body (i+j, 0);
2173 bodyff -> next = init_field_nth_body (i+j, 0, vdw_na, vdw_ma, vdw_a);
2174 bodyff -> next -> prev = bodyff;
2175 j ++;
2176 }
2177 }
2178 }
2179 tmp_field -> nbody[0] += j;
2180 }
2181 else
2182 {
2183 atff = get_active_atom (tmp_fmol -> id, tmp_fshell -> ia[0]);
2184 gchar * str = g_strdup_printf ("%s_sh", atff -> name);
2185 gchar * stra, * strb;
2186 bodyff = get_active_body (0, 0);
2187 i = 0;
2188 while (bodyff)
2189 {
2190 stra = get_body_element_name (bodyff, 0, m+1);
2191 strb = get_body_element_name (bodyff, 1, m+1);
2192 if (g_strcmp0(str,stra) == 0 || g_strcmp0(str,strb) == 0)
2193 {
2194 if (bodyff -> next)
2195 {
2196 bodyff -> prev -> next = bodyff -> next;
2197 bodyff -> next -> prev = bodyff -> prev;
2198 }
2199 else
2200 {
2201 bodyff = bodyff -> prev;
2202 g_free (bodyff -> next);
2203 bodyff -> next = NULL;
2204 }
2205 i ++;
2206 }
2207 g_free (stra);
2208 g_free (strb);
2209 bodyff = bodyff -> next;
2210 }
2211 g_free (str);
2212 tmp_field -> nbody[0] -= i;
2213 }
2214}
2215
2216#ifdef GTK4
2225G_MODULE_EXPORT void shell_in_vdw (GtkCheckButton * but, gpointer data)
2226#else
2235G_MODULE_EXPORT void shell_in_vdw (GtkToggleButton * but, gpointer data)
2236#endif
2237{
2238 tmp_fshell -> vdw = button_get_status ((GtkWidget *)but);
2240}
2241
2244
2254G_MODULE_EXPORT void run_edit_parameters (GtkDialog * dialog, gint response_id, gpointer data)
2255{
2256 if (rep.a > 6 && rep.a < MOLIMIT)
2257 {
2259 }
2260 else if (rep.a == 1)
2261 {
2262 if (g_strcmp0 (rep_atom_name, tmp_fat -> name) != 0)
2263 {
2264 // Atom name's change, need to update non bonded interactions
2265 compare_non_bonded (tmp_fat -> name);
2266 }
2267 g_free (rep_atom_name);
2268 rep_atom_name = NULL;
2269 }
2270 destroy_this_dialog (dialog);
2271}
2272
2281void edit_parameters (int f, int id)
2282{
2283 gchar * str = g_strdup_printf (_("%s parameter(s)"), _(felemt[f+1]));
2284 GtkWidget * dialog = dialogmodal(str, GTK_WINDOW(field_assistant));
2285 GtkWidget * lab;
2286 GtkWidget * entry;
2287 GtkWidget * but;
2288 GtkWidget * hbox;
2289 GtkWidget * combo;
2290 GtkWidget * box = dialog_get_content_area (dialog);
2291 gboolean show_it;
2292 gboolean use_it;
2293 gchar * cs_name[3]={i18n("Core atom: "), i18n("Shell atom: "), i18n("Selection: ")};
2294 gchar * cs_param[4]={i18n("Mass:"), i18n("Charge:"), "<i>k<sub>2</sub></i> ", "<i>k<sub>4</sub></i> "};
2295 gchar * cs_unit[4]={"g mol<sup>-1</sup>", " ", "&#xC5;<sup>-2</sup>", "&#xC5;<sup>-4</sup>"};
2296 gchar * co_name[4]={i18n("First atom: "), i18n("Second atom: "), i18n("Third atom: "), i18n("Fourth atom: ")};
2297 gchar * pm_name[2]={i18n("First unit: "), i18n("Second unit: ")};
2298 int i, j, k, l, m;
2299 float v;
2300 gchar * ba;
2301 is_moy = 1;
2302 show_it = use_it = FALSE;
2303 for (i=0; i<2; i++) ff_p_combo[i] = NULL;
2304 if (f < MOLIMIT)
2305 {
2306 i = combo_get_active (combo_mol[f-1]);
2307 lab = markup_label (g_strdup_printf (_("\tMolecule: \t<b>%s</b>"), get_active_field_molecule(i) -> name), -1, 30, 0.0, 0.5);
2308 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, lab, FALSE, FALSE, 0);
2310 }
2311 switch (f)
2312 {
2313 case 1:
2314 // Atom edit
2315 tmp_fat = get_active_atom(i, id);
2316 rep_atom_name = g_strdup_printf("%s", tmp_fat -> name);
2317 lab = markup_label (g_strdup_printf (_("\tAtom: \t\t<b>%s</b>"), rep_atom_name), -1, 50, 0.0, 0.5);
2318 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, lab, FALSE, FALSE, 0);
2319 hbox = create_hbox (0);
2320 str = g_strdup_printf (_("Element:"));
2321 lab = markup_label (str, 120, 30, 0.0, 0.5);
2322 g_free (str);
2323 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2324 str = g_strdup_printf ("%s", exact_name(tmp_proj -> chemistry -> element[tmp_fat -> sp]));
2325 lab = markup_label (str, -1, -1, 0.5, 0.5);
2326 g_free (str);
2327 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 0);
2328 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 0);
2329 hbox = create_hbox (0);
2330 str = g_strdup_printf (_("Field parameters:"));
2331 lab = markup_label (str, 120, -1, 0.0, 0.5);
2332 g_free (str);
2333 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2334 combo = create_combo ();
2335 combo_text_append (combo, _("Manual"));
2336 combo_text_append (combo, _("Automatic"));
2337 combo_set_active (combo, (tmp_fat -> afid > -1) ? 1 : 0);
2338 widget_set_sensitive (combo, atoms_id[tmp_fat -> sp]);
2339 g_signal_connect (G_OBJECT(combo), "changed", G_CALLBACK(changed_atom_combo), GINT_TO_POINTER(0));
2340 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, combo, FALSE, FALSE, 0);
2341 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 0);
2342 hbox = create_hbox (0);
2343 str = g_strdup_printf (_("Force field type <sup>*</sup>:"));
2344 lab = markup_label (str, 120, 30, 0.0, 0.5);
2345 g_free (str);
2346 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2347 afftype = create_combo ();
2348 combo_text_append (afftype, "None");
2349 k = 0;
2350 for (i=0; i<atoms_id[tmp_fat -> sp]; i++)
2351 {
2352 j = atoms_id_list[tmp_fat -> sp][i];
2353 str = g_strdup_printf ("%s", exact_name(ff_atoms[j][2]));
2354 if (g_strcmp0 (ff_atoms[j][3], " ") != 0) str = g_strdup_printf ("%s : %s", str, ff_atoms[j][3]);
2356 g_free (str);
2357 if (atoms_id_list[tmp_fat -> sp][i] == tmp_fat -> afid) k = i+1;
2358 }
2360 g_signal_connect (G_OBJECT(afftype), "changed", G_CALLBACK(changed_atom_combo), GINT_TO_POINTER(1));
2361 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, afftype, FALSE, FALSE, 0);
2362 widget_set_sensitive (afftype, (tmp_fat -> afid > -1) ? TRUE : FALSE);
2363 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 0);
2364 hbox = create_hbox (0);
2365 str = g_strdup_printf (_("Name: "));
2366 lab = markup_label (str, 120, -1, 0.0, 0.5);
2367 g_free (str);
2368 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2369 entry = create_entry (G_CALLBACK(update_atom_parameter), 100, 15, FALSE, GINT_TO_POINTER(-1));
2370 update_entry_text (GTK_ENTRY(entry), tmp_fat -> name);
2371 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, entry, FALSE, FALSE, 0);
2372 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 0);
2373 hbox = create_hbox (0);
2374 str = g_strdup_printf (_("Mass: "));
2375 lab = markup_label (str, 120, -1, 0.0, 0.5);
2376 g_free (str);
2377 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2378 entry = create_entry (G_CALLBACK(update_atom_parameter), 100, 15, FALSE, GINT_TO_POINTER(0));
2379 update_entry_double (GTK_ENTRY(entry), tmp_fat -> mass);
2380 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, entry, FALSE, FALSE, 0);
2381 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 0);
2382 hbox = create_hbox (0);
2383 str = g_strdup_printf (_("Charge: "));
2384 lab = markup_label (str, 120, -1, 0.0, 0.5);
2385 g_free (str);
2386 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2387 entry = create_entry (G_CALLBACK(update_atom_parameter), 100, 15, FALSE, GINT_TO_POINTER(1));
2388 update_entry_double (GTK_ENTRY(entry), tmp_fat -> charge);
2389 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, entry, FALSE, FALSE, 0);
2390 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 0);
2391 hbox = create_hbox (0);
2392 str = g_strdup_printf (_("Frozen: "));
2393 lab = markup_label (str, 120, -1, 0.0, 0.5);
2394 g_free (str);
2395 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2396 str = g_strdup_printf (_("%d atom(s)"), tmp_fat -> frozen);
2397 but = create_button (str, IMG_NONE, NULL, 150, -1, GTK_RELIEF_NORMAL, G_CALLBACK(select_atom_id_from_fied_molecule), GINT_TO_POINTER(1));
2398 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, but, FALSE, FALSE, 0);
2399 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 0);
2400 break;
2401 case 2:
2402 // Shell edit
2403 tmp_fshell = get_active_shell (i, id);
2404 str = g_strdup_printf (_("\tCore-Shell N°<b>%d</b>"), tmp_fshell -> id+1);
2405 lab = markup_label (str, 300, 50, 0.0, 0.5);
2406 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, lab, FALSE, FALSE, 0);
2407 for (k=0; k<2; k++)
2408 {
2409 hbox = create_hbox (0);
2410 lab = markup_label (_(cs_name[k]), 100, -1, 0.0, 0.5);
2411 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2412 if (! tmp_fshell -> ia[k])
2413 {
2414 str = g_strdup_printf (_("Not picked yet !"));
2416 }
2417 else
2418 {
2419 j = tmp_fshell -> ia[k] - 1;
2420 l = tmp_fmol -> atoms_id[j][0].a;
2421 str = g_strdup_printf ("%s - %d", exact_name(tmp_proj -> chemistry -> label[get_active_atom (i, l) -> sp]), tmp_fshell -> ia[k]);
2422 img_but[k] = stock_image (APPLY);
2423 }
2424 but = create_button (str, IMG_NONE, NULL, 150, -1, GTK_RELIEF_NORMAL, G_CALLBACK(selection_button), GINT_TO_POINTER(k+2));
2425 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, but, FALSE, FALSE, 0);
2426 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, img_but[k], FALSE, FALSE, 30);
2427 }
2428
2429 /*for (k=0; k<3; k++)
2430 {
2431 shell_hbox[k] = create_hbox (0);
2432 lab = markup_label (_(cs_name[k]), 100, -1, 0.0, 0.5);
2433 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, shell_hbox[k], lab, FALSE, FALSE, 10);
2434 if ((k < 2 && tmp_fshell -> ia[k] == -1) || (k == 2 && ! tmp_fshell -> ib))
2435 {
2436 str = g_strdup_printf (_("Not picked yet !"));
2437 img_but[k] = stock_image (DELETEB);
2438 }
2439 else
2440 {
2441 if (k < 2)
2442 {
2443 str = g_strdup_printf (_("Selected !"));
2444 }
2445 else
2446 {
2447 str = g_strdup_printf (_("%d atom(s) selected !"), tmp_fshell -> ia[1]-1);
2448 }
2449 img_but[k] = stock_image (APPLY);
2450 }
2451 if (k < 2)
2452 {
2453 shell_cbox[k] = create_combo ();
2454 combo_text_append (shell_cbox[k], _("Not picked yet !"));
2455 switch (k)
2456 {
2457 case 0:
2458 tmp_fat = tmp_fmol -> first_atom;
2459 while (tmp_fat)
2460 {
2461 combo_text_append (shell_cbox[k], tmp_fat -> name);
2462 tmp_fat = tmp_fat -> next;
2463 }
2464 break;
2465 case 1:
2466 combo_text_append (shell_cbox[k], _("All Atoms"));
2467 combo_text_append (shell_cbox[k], _("Selected Atoms"));
2468 break;
2469 }
2470 l = (! k) ? tmp_fshell -> ia[k]+1 : (tmp_fshell -> ia[k] < 1) ? tmp_fshell -> ia[k]+1 : 2;
2471 combo_set_active (shell_cbox[k], l);
2472 g_signal_connect (G_OBJECT(shell_cbox[k]), "changed", G_CALLBACK(changed_shell_combo), GINT_TO_POINTER(k));
2473 gtk_widget_set_size_request (shell_cbox[k], 150, -1);
2474 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, shell_hbox[k], shell_cbox[k], FALSE, FALSE, 0);
2475 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, shell_hbox[k], img_but[k], FALSE, FALSE, 30);
2476 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, shell_hbox[k], FALSE, FALSE, 0);
2477 }
2478 else
2479 {
2480 shell_but = create_button (str, IMG_NONE, NULL, 150, -1, GTK_RELIEF_NORMAL, G_CALLBACK(selection_button), GINT_TO_POINTER(2));
2481 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, shell_hbox[k], shell_but, FALSE, FALSE, 0);
2482 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, shell_hbox[k], img_but[k], FALSE, FALSE, 30);
2483 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, shell_hbox[k], FALSE, FALSE, 0);
2484 }
2485 g_free (str);
2486 }
2487 */
2488 for (k=0; k<4; k++)
2489 {
2490 hbox = create_hbox (0);
2491 lab = markup_label ((k < 2) ? _(cs_param[k]) : cs_param[k], 100, -1, 0.0, 0.5);
2492 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2493 entry = create_entry (G_CALLBACK(update_atom_parameter), 150, 15, FALSE, GINT_TO_POINTER(2+k));
2494 v = (! k) ? tmp_fshell -> m : (k == 1) ? tmp_fshell -> z : (k == 2) ? tmp_fshell -> k2 : tmp_fshell -> k4;
2495 update_entry_double (GTK_ENTRY(entry), v);
2496 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, entry, FALSE, FALSE, 0);
2497 if (k < 2)
2498 {
2499 str = g_strdup_printf ("%s", cs_unit[k]);
2500 }
2501 else
2502 {
2503 str = g_strdup_printf ("%s %s", fkeysw[activef][0][tmp_field -> energy_unit], cs_unit[k]);
2504 }
2505 lab = markup_label (str, -1, -1, 0.0, 0.5);
2506 g_free (str);
2507 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 30);
2508 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 0);
2509 }
2510 hbox = create_hbox (0);
2511 lab = markup_label(_("Use non-bonded: "), 185, 40, 0.0, 0.5);
2512 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2513 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);
2514 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 0);
2515 show_it = tmp_fshell -> show;
2516 use_it = tmp_fshell -> use;
2517 break;
2518 case 3:
2519 // Constraint edit
2521 str = g_strdup_printf (_("\tBond constraint N°<b>%d</b>"), tmp_fcons -> id+1);
2522 lab = markup_label (str, 300, 50, 0.0, 0.5);
2523 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, lab, FALSE, FALSE, 0);
2524 for (k=0; k<2; k++)
2525 {
2526 hbox = create_hbox (0);
2527 lab = markup_label (_(co_name[k]), 100, -1, 0.0, 0.5);
2528 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2529 if (! tmp_fcons -> ia[k])
2530 {
2531 str = g_strdup_printf (_("Not picked yet !"));
2533 }
2534 else
2535 {
2536 j = tmp_fcons -> ia[k]-1;
2537 l = tmp_fmol -> atoms_id[j][0].a;
2538 str = g_strdup_printf ("%s - %d", exact_name(tmp_proj -> chemistry -> label[get_active_atom (i, l) -> sp]), tmp_fcons -> ia[k]);
2539 img_but[k] = stock_image (APPLY);
2540 }
2541 but = create_button (str, IMG_NONE, NULL, 150, -1, GTK_RELIEF_NORMAL, G_CALLBACK(selection_button), GINT_TO_POINTER(k+4));
2542 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, but, FALSE, FALSE, 0);
2543 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, img_but[k], FALSE, FALSE, 30);
2544 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 0);
2545 }
2546 hbox = create_hbox (0);
2547 str = g_strdup_printf (_("Av. distance (1): "));
2548 lab = markup_label (str, 100, 50, 0.0, 0.5);
2549 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2550 av_lgt = markup_label ("", 150, 50, 0.5, 0.5);
2552 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, av_lgt, FALSE, FALSE, 0);
2553 str = g_strdup_printf ("[&#xC5;]");
2554 lab = markup_label (str, -1, -1, 0.0, 0.5);
2555 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 30);
2556 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 0);
2557 hbox = create_hbox (0);
2558 str = g_strdup_printf (_("Length: "));
2559 lab = markup_label (str, 100, -1, 0.0, 0.5);
2560 g_free (str);
2561 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2562 entry = create_entry (G_CALLBACK(update_atom_parameter), 150, 15, FALSE, GINT_TO_POINTER(6));
2563 update_entry_double (GTK_ENTRY(entry), tmp_fcons -> length);
2564 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, entry, FALSE, FALSE, 0);
2565 str = g_strdup_printf ("[&#xC5;]");
2566 lab = markup_label (str, -1, -1, 0.0, 0.5);
2567 g_free (str);
2568 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 30);
2569 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 0);
2570 show_it = tmp_fcons -> show;
2571 use_it = tmp_fcons -> use;
2572 break;
2573 case 4:
2574 // Pmf edit
2575 tmp_fpmf = get_active_pmf (i, id);
2576 str = g_strdup_printf (_("\tMean force potential N°<b>%d</b>"), tmp_fpmf -> id+1);
2577 lab = markup_label (str, 300, 50, 0.0, 0.5);
2578 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, lab, FALSE, FALSE, 0);
2579 for (k=0; k<2; k++)
2580 {
2581 hbox = create_hbox (0);
2582 lab = markup_label (_(pm_name[k]), 100, -1, 0.0, 0.5);
2583 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2584 if (tmp_fpmf -> num[k] == 0)
2585 {
2586 str = g_strdup_printf (_("Not picked yet !"));
2588 }
2589 else
2590 {
2591 str = g_strdup_printf (_("%d atom(s)"), tmp_fpmf -> num[k]);
2592 img_but[k] = stock_image (APPLY);
2593 }
2594 but = create_button (str, IMG_NONE, NULL, 150, -1, GTK_RELIEF_NORMAL, G_CALLBACK(selection_button), GINT_TO_POINTER(k+6));
2595 g_free (str);
2596 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, but, FALSE, FALSE, 0);
2597 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, img_but[k], FALSE, FALSE, 30);
2598 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 0);
2599 }
2600
2601 hbox = create_hbox (0);
2602 str = g_strdup_printf (_("Av. d<sub>1-2</sub> (1): "));
2603 lab = markup_label (str, 100, 50, 0.0, 0.5);
2604 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2605 av_lgt = markup_label ("", 150, 50, 0.5, 0.5);
2607 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, av_lgt, FALSE, FALSE, 0);
2608 str = g_strdup_printf ("[&#xC5;]");
2609 lab = markup_label (str, -1, 50, 0.0, 0.5);
2610 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 30);
2611 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 0);
2612
2613 hbox = create_hbox (0);
2614 str = g_strdup_printf (_("Length: "));
2615 lab = markup_label (str, 100, -1, 0.0, 0.5);
2616 g_free (str);
2617 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2618 entry = create_entry (G_CALLBACK(update_atom_parameter), 150, 15, FALSE, GINT_TO_POINTER(7));
2619 update_entry_double (GTK_ENTRY(entry), tmp_fpmf -> length);
2620 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, entry, FALSE, FALSE, 0);
2621 str = g_strdup_printf ("[&#xC5;]");
2622 lab = markup_label (str, -1, -1, 0.0, 0.5);
2623 g_free (str);
2624 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 30);
2625 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 0);
2626 show_it = tmp_fpmf -> show;
2627 use_it = tmp_fpmf -> use;
2628 break;
2629 case 5:
2630 // Rigid edit
2631 tmp_frig = get_active_rigid (i, id);
2632 str = g_strdup_printf (_("\tRigid unit N°<b>%d</b>"), id+1);
2633 lab = markup_label (str, 300, 50, 0.0, 0.5);
2634 g_free (str);
2635 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, lab, FALSE, FALSE, 0);
2636
2637 hbox = create_hbox (0);
2638 str = g_strdup_printf (_("Atom(s): "));
2639 lab = markup_label (str, 100, -1, 0.0, 0.5);
2640 g_free (str);
2641 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2642 if (tmp_frig -> num == 0)
2643 {
2644 str = g_strdup_printf (_("Not picked yet !"));
2646 }
2647 else
2648 {
2649 str = g_strdup_printf (_("%d atom(s)"), tmp_frig -> num);
2650 img_but[0] = stock_image (APPLY);
2651 }
2652 but = create_button (str, IMG_NONE, NULL, 150, -1, GTK_RELIEF_NORMAL, G_CALLBACK(selection_button), GINT_TO_POINTER(8));
2653 g_free (str);
2654 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, but, FALSE, FALSE, 0);
2655 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, img_but[0], FALSE, FALSE, 30);
2656 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 0);
2657 show_it = tmp_frig -> show;
2658 use_it = tmp_frig -> use;
2659 break;
2660 case 6:
2661 // Tethered
2662 tmp_ftet = get_active_tethered (i, id);
2663 str = g_strdup_printf (_("\tTethered atom N°<b>%d</b>"), id+1);
2664 lab = markup_label (str, 300, 50, 0.0, 0.5);
2665 g_free (str);
2666 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, lab, FALSE, FALSE, 0);
2667
2668 hbox = create_hbox (0);
2669 str = g_strdup_printf (_("Atom: "));
2670 lab = markup_label (str, 100, -1, 0.0, 0.5);
2671 g_free (str);
2672 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2673 if (! tmp_ftet -> num)
2674 {
2675 str = g_strdup_printf (_("Not picked yet !"));
2677 }
2678 else
2679 {
2680 k = tmp_fmol -> atoms_id[tmp_ftet -> num-1][0].a;
2681 str = g_strdup_printf ("%s - %d", exact_name(tmp_proj -> chemistry -> label[get_active_atom (i, k) -> sp]), tmp_ftet -> num);
2682 img_but[0] = stock_image (APPLY);
2683 }
2684 but = create_button (str, IMG_NONE, NULL, 150, -1, GTK_RELIEF_NORMAL, G_CALLBACK(selection_button), GINT_TO_POINTER(9));
2685 g_free (str);
2686 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, but, FALSE, FALSE, 0);
2687 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, img_but[0], FALSE, FALSE, 30);
2688 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 0);
2689 show_it = tmp_ftet -> show;
2690 use_it = tmp_ftet -> use;
2691 break;
2692 case SEXTERN:
2694 body_lab = markup_label (field_str(tmp_fext -> key), 250, 50, 0.5, 0.5);
2695 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, body_lab, FALSE, FALSE, 0);
2696 use_it = tmp_fext -> use;
2697 break;
2698 default:
2699 if (f < MOLIMIT)
2700 {
2701 // Bond, angle, dihedral, improper, inversion edit
2702 tmp_fstr = get_active_struct (f-7, i, id);
2703 m = struct_id (f);
2704 str = g_strdup_printf (_("\t%s type N°<b>%d</b>\n\tField atoms: <b>"), mo_title[f-7], id+1);
2705 for (k=0; k<m; k++)
2706 {
2707 if (k == m-1) str = g_strdup_printf (_("%s</b> and <b>"), str);
2708 str = g_strdup_printf ("%s%s", str, get_active_atom (i, tmp_fstr -> aid[k]) -> name);
2709 if (m > 2 && k < m-1) str = g_strdup_printf ("%s</b>, <b>", str);
2710 }
2711 str = g_strdup_printf ("%s</b>", str);
2712 edit_atids = allocint (m);
2713 gtk_tree_model_get (GTK_TREE_MODEL(field_model[f]), & field_iter, 0, & is_moy, -1);
2714 if (! is_moy)
2715 {
2716 str = g_strdup_printf (_("%s\n\tBetween atoms: <b>"), str);
2717 for (k=0; k<m; k++)
2718 {
2719 gtk_tree_model_get (GTK_TREE_MODEL(field_model[f]), & field_iter, k+1, & ba, -1);
2720 edit_atids[k] = (int) string_to_double ((gpointer)ba) - 1;
2721 if (k == m-1) str = g_strdup_printf (_("%s</b> and <b>"), str);
2722 str = g_strdup_printf ("%s%s", str, ba);
2723 if (m > 2 && k < m-1) str = g_strdup_printf ("%s</b>, <b>", str);
2724 }
2725 str = g_strdup_printf ("%s</b>", str);
2726 if (tmp_fstr -> other)
2727 {
2729 if (! tmp_fprop)
2730 {
2731 tmp_fprop = tmp_fstr -> other;
2732 while (tmp_fprop -> next) tmp_fprop = tmp_fprop -> next;
2733 tmp_fprop -> next = duplicate_field_prop (tmp_fstr -> def, f-7);
2734 tmp_fprop = tmp_fprop -> next;
2735 for (k=0; k<m; k++) tmp_fprop -> aid[k] = edit_atids[k];
2736 }
2737 }
2738 else
2739 {
2740 tmp_fstr -> other = duplicate_field_prop (tmp_fstr -> def, f-7);
2741 for (k=0; k<m; k++) tmp_fstr -> other -> aid[k] = edit_atids[k];
2742 tmp_fprop = tmp_fstr -> other;
2743 }
2744 }
2745 else
2746 {
2747 for (l=0; l<m; l++) edit_atids[l] = -1;
2748 tmp_fprop = tmp_fstr -> def;
2749 }
2750 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, markup_label (str, -1, (is_moy) ? 70 : 100, 0.0, 0.5), FALSE, FALSE, 0);
2751 g_free (str);
2752 show_it = tmp_fprop -> show;
2753 use_it = tmp_fprop -> use;
2754 }
2755 else
2756 {
2757 l = f - MOLIMIT;
2758 tmp_fbody = get_active_body (id, l);
2759 body_lab = markup_label (body_str (tmp_fbody -> bd), 250, 50, 0.5, 0.5);
2760 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, body_lab, FALSE, FALSE, 0);
2761 if (l > 0)
2762 {
2763 for (k=0; k< body_at(l); k++)
2764 {
2765 hbox = create_hbox (0);
2766 if (l == 2)
2767 {
2768 lab = markup_label (_("Tersoff atom: "), 100, -1, 0.0, 0.5);
2769 }
2770 else
2771 {
2772 lab = markup_label (_(co_name[k]), 100, -1, 0.0, 0.5);
2773 }
2774 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2775 if (tmp_fbody -> na[k] < 0)
2776 {
2777 str = g_strdup_printf (_("Not picked yet !"));
2779 }
2780 else
2781 {
2782 str = g_strdup_printf ("%s", get_active_atom (tmp_fbody -> ma[k][0], tmp_fbody -> a[k][0]) -> name);
2783 img_but[k] = stock_image (APPLY);
2784 }
2785 but = create_button (str, IMG_NONE, NULL, 150, -1, GTK_RELIEF_NORMAL, G_CALLBACK(selection_button), GINT_TO_POINTER(11+k));
2786 g_free (str);
2787 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, but, FALSE, FALSE, 0);
2788 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, img_but[k], FALSE, FALSE, 30);
2789 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 0);
2790 }
2791 }
2792 show_it = tmp_fbody -> show;
2793 use_it = tmp_fbody -> use;
2794 }
2795 break;
2796 }
2797 if (f < SEXTERN)
2798 {
2799 hbox = create_hbox (0);
2800 lab = markup_label(_("Visualize in the model: "), (f == 1) ? 150 : 185, 40, 0.0, 0.5);
2801 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2802 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);
2803 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 0);
2804 }
2805 if (f == 1)
2806 {
2807 str = g_strdup_printf (_("<sup>*</sup> this will be used to adjust bonding, angles, etc ... accordingly,\n"
2808 " providing that some parameters can be found in the force field data.\n"
2809 " Please note that comments are directly imported from the force field file."));
2810 lab = markup_label (str, -1, 75, 0.5, 0.5);
2811 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, lab, FALSE, FALSE, 0);
2812 }
2813 if (f > 1)
2814 {
2815 hbox = create_hbox (0);
2816 lab = markup_label(_("Use to create force field: "), 185, 40, 0.0, 0.5);
2817 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2818 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);
2819 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 0);
2820 if (f > 5)
2821 {
2822 if (f > 6 && f < 16)
2823 {
2824 if (f != 15 || tmp_field -> type < CFF91 || tmp_field -> type > COMPASS)
2825 {
2826 hbox = create_hbox (0);
2827 gchar * funits[5] ={"Ev", "kcal mol<sup>-1</sup>", "kJ mol<sup>-1</sup>", "K B<sup>-1</sup>", _("DL_POLY internal units")};
2828 str = g_strdup_printf (_("Field parameters <sup>*</sup>:"));
2829 lab = markup_label (str, 120, -1, 0.0, 0.5);
2830 g_free (str);
2831 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2832 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, create_field_prop_combo (f, is_moy), FALSE, FALSE, 0);
2833 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 0);
2834 str = g_strdup_printf (_("<sup>*</sup> Available parameters with matching chemical species,\n"
2835 " %s force field energy related parameters in: %s \n"
2836 " if required conversion to FIELD file energy unit will be performed upon selection.\n"
2837 " Please note that comments are directly imported from the force field file.\n"),
2838 field_acro[tmp_field -> type], (ff_unit == 4) ? _(funits[ff_unit]) : funits[ff_unit]);
2839 lab = markup_label (str, -1, 75, 0.5, 0.5);
2840 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, lab, FALSE, FALSE, 0);
2841 }
2842 }
2843 hbox = create_hbox (0);
2844 str = g_strdup_printf (_("Potential: "));
2845 lab = markup_label (str, 100, -1, 0.0, 0.5);
2846 g_free (str);
2847 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2849 for (j=0; j<fetypes[activef][f-5]; j++)
2850 {
2851 str = g_strdup_printf ("%s (%s)", dlp_to_translate(activef,f-5,j) ? _(fnames[activef][f-5][j]) : fnames[activef][f-5][j], exact_name(fkeysw[activef][f-5][j]));
2853 g_free (str);
2854 }
2855 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, field_key_combo, FALSE, FALSE, 0);
2856 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 0);
2857 param_box = create_hbox (0);
2859 switch (f)
2860 {
2861 case 6:
2862 // Tethered
2864 break;
2865 case SEXTERN:
2867 break;
2868 default:
2869 if (f < MOLIMIT)
2870 {
2872 }
2873 else
2874 {
2875 // non nonded
2877 }
2878 break;
2879 }
2880 g_signal_connect (G_OBJECT(field_key_combo), "changed", G_CALLBACK(changed_field_key_combo), GINT_TO_POINTER(f));
2881 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, param_box, p_box, FALSE, FALSE, 0);
2882 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, param_box, FALSE, FALSE, 5);
2883 }
2884 else if (f == 3)
2885 {
2886 hbox = create_hbox (0);
2887 str = g_strdup_printf (_(" <b>(1)</b> average distance between the 2 atoms\n\tas measured in the 3D model"));
2888 lab = markup_label (str, 320, -1, 0.0, 0.5);
2889 g_free (str);
2890 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2891 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 0);
2892 }
2893 else if (f == 4)
2894 {
2895 hbox = create_hbox (0);
2896 str = g_strdup_printf (_(" <b>(1)</b> average distance between the barycenters\n\tof units 1 and 2 as measured in the model"));
2897 lab = markup_label (str, 320, -1, 0.0, 0.5);
2898 g_free (str);
2899 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2900 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 0);
2901 }
2902 }
2903 rep.a = f;
2904 rep.b = m;
2905 g_signal_connect (G_OBJECT(dialog), "response", G_CALLBACK(run_edit_parameters), NULL);
2906 show_the_widgets (dialog);
2907 if (f == 2)
2908 {
2909 if (tmp_fshell -> ia[0] < 0 || tmp_fshell -> ia[1] < 1) hide_the_widgets (shell_hbox[2]);
2910 if (tmp_fshell -> ia[0] < 0) widget_set_sensitive (shell_hbox[1], FALSE);
2911 }
2912
2913 dialog_id ++;
2914 Event_loop[dialog_id] = g_main_loop_new (NULL, FALSE);
2915 g_main_loop_run (Event_loop[dialog_id]);
2916}
2917
2926void update_tersoffs (int id, int key)
2927{
2928 int i;
2929 field_nth_body * bod = tmp_field -> first_body[2];
2930 for (i=0; i<tmp_field -> nbody[2]; i++)
2931 {
2932 if (i != id)
2933 {
2934 if (bod -> key != key)
2935 {
2936 bod -> key = key;
2937 bod -> val = NULL;
2938 bod -> val = allocfloat (fvalues[activef][MOLIMIT-4][bod -> key]);
2939 }
2940 }
2941 if (bod -> next != NULL) bod = bod -> next;
2942 }
2943 if (key && tmp_field -> cross != NULL)
2944 {
2945 g_free (tmp_field -> cross);
2946 tmp_field -> cross = NULL;
2947 }
2948}
2949
2958void check_tersoffs (int id, int key)
2959{
2960 int i, j;
2961 if (change_tersoff && id != -1) update_tersoffs (id, key);
2962 if (! key)
2963 {
2964 if (tmp_field -> cross)
2965 {
2966 g_free (tmp_field -> cross);
2967 tmp_field -> cross = NULL;
2968 }
2969 if (cross)
2970 {
2971 tmp_field -> cross = g_malloc0(tmp_field -> nbody[2]*sizeof*tmp_field -> cross);
2972 for (i=0; i<tmp_field -> nbody[2]; i++)
2973 {
2974 tmp_field -> cross[i] = g_malloc0(tmp_field -> nbody[2]*sizeof*tmp_field -> cross[i]);
2975 for (j=0; j<tmp_field -> nbody[2]; j++) tmp_field -> cross[i][j] = duplicate_double (3, cross[i][j]);
2976 }
2977 }
2978 else
2979 {
2980 tmp_field -> cross = alloctdouble (tmp_field -> nbody[2], tmp_field -> nbody[2], 3);
2981 }
2982 }
2983}
2984
2994G_MODULE_EXPORT void edit_field_prop (GSimpleAction * action, GVariant * parameter, gpointer data)
2995{
2996 int i, j, k;
2997 i = GPOINTER_TO_INT (data);
2998 gchar * tmp;
2999 switch (i)
3000 {
3001 case 0:
3002 if (action == NULL)
3003 {
3005 tmp = g_strdup_printf (_("Please enter name for new molecule N°%d"), tmp_field -> molecules);
3006 tmp_fmol -> name = g_strdup_printf("MOL-%d", i);
3007 tmp = cask (tmp, _("Molecule name:"), 0, tmp_fmol -> name, field_assistant);
3008 if (tmp != NULL)
3009 {
3010 tmp_fmol -> name = g_strdup_printf ("%s", tmp);
3011 g_free (tmp);
3012 }
3013 }
3014 else
3015 {
3017 tmp = g_strdup_printf (_("Please enter name for molecule N°%d"), row_id+1);
3018 tmp = cask (tmp, _("Molecule name:"), 0, tmp_fmol -> name, field_assistant);
3019 if (tmp != NULL)
3020 {
3021 tmp_fmol -> name = g_strdup_printf ("%s", tmp);
3022 g_free (tmp);
3024 }
3025 }
3026 break;
3027 default:
3028 if (i == MOLIMIT+2)
3029 {
3030 num_body_d = tmp_field -> nbody[2];
3031 cross = NULL;
3032 if (tmp_field -> cross != NULL)
3033 {
3034 cross = g_malloc0(tmp_field -> nbody[2]*sizeof*cross);
3035 for (j=0; j<tmp_field -> nbody[2]; j++)
3036 {
3037 cross[j] = g_malloc0(tmp_field -> nbody[2]*sizeof*cross[j]);
3038 for (k=0; k<tmp_field -> nbody[2]; k++) cross[j][k] = duplicate_double (3, tmp_field -> cross[j][k]);
3039 }
3040 }
3041 change_tersoff = FALSE;
3042 }
3044 if (i == MOLIMIT+2) check_tersoffs (tmp_fbody -> id, tmp_fbody -> key);
3046 break;
3047 }
3048}
3049
3059G_MODULE_EXPORT void add_field_prop (GSimpleAction * action, GVariant * parameter, gpointer data)
3060{
3061 int i, j, k, l, m;
3062 gboolean save_it;
3063 i = GPOINTER_TO_INT (data);
3064 field_molecule * fmol;
3065 if (i < MOLIMIT)
3066 {
3067 j = combo_get_active (combo_mol[i-1]);
3069 }
3070 if (i == 2)
3071 {
3072 if (fmol -> first_shell == NULL)
3073 {
3074 fmol -> first_shell = init_field_shell (fmol -> shells, 0, 0);
3075 }
3076 else
3077 {
3078 tmp_fshell = get_active_shell (j, fmol -> shells);
3079 tmp_fshell -> next = init_field_shell (fmol -> shells, 0, 0);
3080 tmp_fshell -> next -> prev = g_malloc0(sizeof*tmp_fshell -> next -> prev);
3081 tmp_fshell -> next -> prev = tmp_fshell;
3082 }
3083 row_id = fmol -> shells;
3084 edit_parameters (i, fmol -> shells);
3085 if (tmp_fshell -> ia[0] || tmp_fshell -> ia[1])
3086 {
3087 fmol -> shells ++;
3088 if (! tmp_fshell -> ia[0] || ! tmp_fshell -> ia[1]) tmp_fshell -> use = FALSE;
3089 }
3090 else
3091 {
3092 tmp_fshell = get_active_shell (j, fmol -> shells);
3093 tmp_fshell -> next = NULL;
3094 if (fmol -> shells == 0) fmol -> first_shell = NULL;
3095 }
3096 }
3097 else if (i == 3)
3098 {
3099 if (fmol -> first_constraint == NULL)
3100 {
3101 fmol -> first_constraint = init_field_constraint (fmol -> constraints, 0, 0);
3102 }
3103 else
3104 {
3105 tmp_fcons = get_active_constraint (j, fmol -> constraints);
3106 tmp_fcons -> next = init_field_constraint (fmol -> constraints, 0, 0);
3107 tmp_fcons -> next -> prev = g_malloc0(sizeof*tmp_fcons -> next -> prev);
3108 tmp_fcons -> next -> prev = tmp_fcons;
3109 }
3110 row_id = fmol -> constraints;
3111 edit_parameters (i, fmol -> constraints);
3112 if (tmp_fcons -> ia[0] || tmp_fcons -> ia[1])
3113 {
3114 fmol -> constraints ++;
3115 if (! tmp_fcons -> ia[0] || ! tmp_fcons -> ia[1]) tmp_fcons -> use = FALSE;
3116 }
3117 else
3118 {
3119 tmp_fcons = get_active_constraint (j, fmol -> constraints);
3120 tmp_fcons -> next = NULL;
3121 if (fmol -> constraints == 0) fmol -> first_constraint = NULL;
3122 }
3123 }
3124 else if (i == 4)
3125 {
3126 if (fmol -> first_pmf == NULL)
3127 {
3128 fmol -> first_pmf = init_field_pmf (fmol -> pmfs, NULL, NULL, NULL);
3129 }
3130 else
3131 {
3132 tmp_fpmf = get_active_pmf (j, fmol -> pmfs);
3133 tmp_fpmf -> next = init_field_pmf (fmol -> pmfs, NULL, NULL, NULL);
3134 tmp_fpmf -> next -> prev = g_malloc0(sizeof*tmp_fpmf -> next -> prev);
3135 tmp_fpmf -> next -> prev = tmp_fpmf;
3136 }
3137 row_id = fmol -> pmfs;
3138 edit_parameters (i, fmol -> pmfs);
3139 if (tmp_fpmf -> num[0] > 0 || tmp_fpmf -> num[1] > 0)
3140 {
3141 fmol -> pmfs ++;
3142 if (tmp_fpmf -> length == 0.0 || tmp_fpmf -> num[0] == 0 || tmp_fpmf -> num[1] == 0) tmp_fpmf -> use = FALSE;
3143 if (tmp_fpmf -> use)
3144 {
3145 toviz.c = TRUE;
3146 select_object (i, fmol -> pmfs, j);
3147 }
3148 }
3149 else
3150 {
3151 tmp_fpmf = get_active_pmf (j, fmol -> pmfs);
3152 tmp_fpmf -> next = NULL;
3153 if (fmol -> pmfs == 0) fmol -> first_pmf = NULL;
3154 }
3155 }
3156 else if (i == 5)
3157 {
3158 if (fmol -> first_rigid == NULL)
3159 {
3160 fmol -> first_rigid = init_field_rigid (fmol -> rigids, 0, NULL);
3161 }
3162 else
3163 {
3164 tmp_frig = get_active_rigid (j, fmol -> rigids);
3165 tmp_frig -> next = init_field_rigid (fmol -> rigids, 0, NULL);
3166 tmp_frig -> next -> prev = g_malloc0(sizeof*tmp_frig -> next -> prev);
3167 tmp_frig -> next -> prev = tmp_frig;
3168 }
3169 row_id = fmol -> rigids;
3170 edit_parameters (i, fmol -> rigids);
3171 if (tmp_frig -> num > 0)
3172 {
3173 fmol -> rigids ++;
3174 tmp_frig -> use = TRUE;
3175 }
3176 else
3177 {
3178 tmp_frig = get_active_rigid (j, fmol -> rigids);
3179 tmp_frig -> next = NULL;
3180 if (fmol -> rigids == 0) fmol -> first_rigid = NULL;
3181 }
3182 }
3183 else if (i == 6)
3184 {
3185 if (fmol -> first_tethered == NULL)
3186 {
3187 fmol -> first_tethered = init_field_tethered (fmol -> tethered, 0);
3188 }
3189 else
3190 {
3191 tmp_ftet = get_active_tethered (j, fmol -> tethered);
3192 tmp_ftet -> next = init_field_tethered (fmol -> tethered, 0);
3193 tmp_ftet -> next -> prev = g_malloc0(sizeof*tmp_ftet -> next -> prev);
3194 tmp_ftet -> next -> prev = tmp_ftet;
3195 }
3196 row_id = fmol -> tethered;
3197 edit_parameters (i, fmol -> tethered);
3198 if (tmp_ftet -> num)
3199 {
3200 fmol -> tethered ++;
3201 tmp_ftet -> use = TRUE;
3202 }
3203 else
3204 {
3205 tmp_ftet = get_active_tethered (j, fmol -> tethered);
3206 tmp_ftet -> next = NULL;
3207 if (fmol -> tethered == 0) fmol -> first_tethered = NULL;
3208 }
3209 }
3210 else if (i == SEXTERN)
3211 {
3212 if (tmp_field -> first_external == NULL)
3213 {
3214 tmp_field -> first_external = init_field_external (tmp_field -> extern_fields);
3215 }
3216 else
3217 {
3218 tmp_fext = get_active_external (tmp_field -> extern_fields-1);
3219 tmp_fext -> next = init_field_external (tmp_field -> extern_fields);
3220 tmp_fext -> next -> prev = g_malloc0(sizeof*tmp_fext -> next -> prev);
3221 tmp_fext -> next -> prev = tmp_fext;
3222 }
3223 row_id = tmp_field -> extern_fields;
3224 edit_parameters (i, tmp_field -> extern_fields);
3225 if (tmp_fext -> use && tmp_fext -> key > -1)
3226 {
3227 tmp_field -> extern_fields ++;
3228 }
3229 else
3230 {
3231 tmp_fext = get_active_external (tmp_field -> extern_fields);
3232 tmp_fext -> next = NULL;
3233 if (tmp_field -> extern_fields == 0) tmp_field -> first_external = NULL;
3234 }
3235 }
3236 else
3237 {
3238 j = i - MOLIMIT;
3239 row_id = tmp_field -> nbody[j];
3240 if (tmp_field -> first_body[j] == NULL)
3241 {
3242 tmp_field -> first_body[j] = init_field_nth_body (tmp_field -> nbody[j], j, NULL, NULL, NULL);
3243 }
3244 else
3245 {
3246 tmp_fbody = get_active_body (tmp_field -> nbody[j], j);
3247 tmp_fbody -> next = init_field_nth_body (tmp_field -> nbody[j], j, NULL, NULL, NULL);
3248 tmp_fbody -> next -> prev = g_malloc0(sizeof*tmp_fbody -> next -> prev);
3249 tmp_fbody -> next -> prev = tmp_fbody;
3250 }
3251 if (j == 2)
3252 {
3253 cross = NULL;
3254 cross = alloctdouble (tmp_field -> nbody[j]+1, tmp_field -> nbody[j]+1, 3);
3255 if (tmp_field -> cross != NULL)
3256 {
3257 for (k=0; k<tmp_field -> nbody[j]; k++)
3258 {
3259 for (l=0; l<tmp_field -> nbody[j]; l++)
3260 {
3261 for (m=0; m<3; m++) cross[k][l][m] = cross[l][k][m] = tmp_field -> cross[k][l][m];
3262 }
3263 }
3264 }
3265 else
3266 {
3267 tmp_field -> cross = alloctdouble (1, 1, 3);
3268 }
3269 }
3270 edit_parameters (i, tmp_field -> nbody[j]);
3271 save_it = FALSE;
3272 k = body_at (j);
3273 for (l=0; l<k; l++) if (tmp_fbody -> na[l] > -1) save_it = TRUE;
3274 if (save_it)
3275 {
3276 tmp_field -> nbody[j] ++;
3277 for (l=0; l<k; l++) if (tmp_fbody -> na[l] < 0) tmp_fbody -> use = FALSE;
3278 if (j == 2) check_tersoffs (tmp_fbody -> id, tmp_fbody -> key);
3279 }
3280 else
3281 {
3282 tmp_fbody = get_active_body (tmp_field -> nbody[j], j);
3283 tmp_fbody -> next = NULL;
3284 if (tmp_field -> nbody[j] == 0) tmp_field -> first_body[j] = NULL;
3285 }
3286 }
3288}
3289
3299G_MODULE_EXPORT void remove_field_prop (GSimpleAction * action, GVariant * parameter, gpointer data)
3300{
3301 int i, j, k, l, m, n, o;
3302 i = GPOINTER_TO_INT (data);
3303 gchar * str;
3304 if (i < MOLIMIT)
3305 {
3306 j = combo_get_active (combo_mol[i-1]);
3308 str = g_strdup_printf (_("Delete %s N°%d from molecule %s, is this correct ?"), _(elemts[i]), row_id+1, tmp_fmol -> name);
3309 }
3310 else
3311 {
3312 str = g_strdup_printf (_("Delete %s, is this correct ?"), _(elemts[i]));
3313 }
3314 selection_confirmed = FALSE;
3315 field_question (str, G_CALLBACK(confirm_selection), NULL);
3316 g_free (str);
3318 {
3319 if (i == 2)
3320 {
3322 if (tmp_fshell == tmp_fmol -> first_shell)
3323 {
3324 if (tmp_fshell -> next != NULL)
3325 {
3326 tmp_fmol -> first_shell = tmp_fmol -> first_shell -> next;
3327 tmp_fmol -> first_shell -> prev = NULL;
3328 }
3329 else
3330 {
3331 tmp_fmol -> first_shell = NULL;
3332 }
3333 }
3334 else if (tmp_fshell -> next == NULL)
3335 {
3336 tmp_fshell = tmp_fshell -> prev;
3337 tmp_fshell -> next = NULL;
3338 }
3339 else
3340 {
3341 tmp_fshell -> prev -> next = tmp_fshell -> next;
3342 tmp_fshell -> next -> prev = tmp_fshell -> prev;
3343 }
3344 tmp_fmol -> shells --;
3345 tmp_fshell = tmp_fmol -> first_shell;
3346 for (j=0; j<tmp_fmol -> shells; j++)
3347 {
3348 tmp_fshell -> id = j;
3349 if (tmp_fshell -> next != NULL) tmp_fshell = tmp_fshell -> next;
3350 }
3351 }
3352 else if (i == 3)
3353 {
3355 if (tmp_fcons == tmp_fmol -> first_constraint)
3356 {
3357 if (tmp_fcons -> next != NULL)
3358 {
3359 tmp_fmol -> first_constraint = tmp_fmol -> first_constraint -> next;
3360 tmp_fmol -> first_constraint -> prev = NULL;
3361 }
3362 else
3363 {
3364 tmp_fmol -> first_constraint = NULL;
3365 }
3366 }
3367 else if (tmp_fcons -> next == NULL)
3368 {
3369 tmp_fcons = tmp_fcons -> prev;
3370 tmp_fcons -> next = NULL;
3371 }
3372 else
3373 {
3374 tmp_fcons -> prev -> next = tmp_fcons -> next;
3375 tmp_fcons -> next -> prev = tmp_fcons -> prev;
3376 }
3377 tmp_fmol -> constraints --;
3378 tmp_fcons = tmp_fmol -> first_constraint;
3379 for (j=0; j<tmp_fmol -> constraints; j++)
3380 {
3381 tmp_fcons -> id = j;
3382 if (tmp_fcons -> next != NULL) tmp_fcons = tmp_fcons -> next;
3383 }
3384 }
3385 else if (i == 4)
3386 {
3388 if (tmp_fpmf == tmp_fmol -> first_pmf)
3389 {
3390 if (tmp_fpmf -> next != NULL)
3391 {
3392 tmp_fmol -> first_pmf = tmp_fmol -> first_pmf -> next;
3393 tmp_fmol -> first_pmf -> prev = NULL;
3394 }
3395 else
3396 {
3397 tmp_fmol -> first_pmf = NULL;
3398 }
3399 }
3400 else if (tmp_fpmf -> next == NULL)
3401 {
3402 tmp_fpmf = tmp_fpmf -> prev;
3403 tmp_fpmf -> next = NULL;
3404 }
3405 else
3406 {
3407 tmp_fpmf -> prev -> next = tmp_fpmf -> next;
3408 tmp_fpmf -> next -> prev = tmp_fpmf -> prev;
3409 }
3410 tmp_fmol -> pmfs --;
3411 tmp_fpmf = tmp_fmol -> first_pmf;
3412 for (j=0; j<tmp_fmol -> pmfs; j++)
3413 {
3414 tmp_fpmf -> id = j;
3415 if (tmp_fpmf -> next != NULL) tmp_fpmf = tmp_fpmf -> next;
3416 }
3417 }
3418 else if (i == 5)
3419 {
3421 if (tmp_frig == tmp_fmol -> first_rigid)
3422 {
3423 if (tmp_frig -> next != NULL)
3424 {
3425 tmp_fmol -> first_rigid = tmp_fmol -> first_rigid -> next;
3426 tmp_fmol -> first_rigid -> prev = NULL;
3427 }
3428 else
3429 {
3430 tmp_fmol -> first_rigid = NULL;
3431 }
3432 }
3433 else if (tmp_frig -> next == NULL)
3434 {
3435 tmp_frig = tmp_frig -> prev;
3436 tmp_frig -> next = NULL;
3437 }
3438 else
3439 {
3440 tmp_frig -> prev -> next = tmp_frig -> next;
3441 tmp_frig -> next -> prev = tmp_frig -> prev;
3442 }
3443 tmp_fmol -> rigids --;
3444 tmp_frig = tmp_fmol -> first_rigid;
3445 for (j=0; j<tmp_fmol -> rigids; j++)
3446 {
3447 tmp_frig -> id = j;
3448 if (tmp_frig -> next != NULL) tmp_frig = tmp_frig -> next;
3449 }
3450 }
3451 else if (i == 6)
3452 {
3454 if (tmp_ftet == tmp_fmol -> first_tethered)
3455 {
3456 if (tmp_ftet -> next != NULL)
3457 {
3458 tmp_fmol -> first_tethered = tmp_fmol -> first_tethered -> next;
3459 tmp_fmol -> first_tethered -> prev = NULL;
3460 }
3461 else
3462 {
3463 tmp_fmol -> first_tethered = NULL;
3464 }
3465 }
3466 else if (tmp_ftet -> next == NULL)
3467 {
3468 tmp_ftet = tmp_ftet -> prev;
3469 tmp_ftet -> next = NULL;
3470 }
3471 else
3472 {
3473 tmp_ftet -> prev -> next = tmp_ftet -> next;
3474 tmp_ftet -> next -> prev = tmp_ftet -> prev;
3475 }
3476 tmp_fmol -> tethered --;
3477 tmp_ftet = tmp_fmol -> first_tethered;
3478 for (j=0; j<tmp_fmol -> tethered; j++)
3479 {
3480 tmp_ftet -> id = j;
3481 if (tmp_ftet -> next != NULL) tmp_ftet = tmp_ftet -> next;
3482 }
3483 }
3484 else if (i == SEXTERN)
3485 {
3487 if (tmp_fext == tmp_field -> first_external)
3488 {
3489 if (tmp_fext -> next != NULL)
3490 {
3491 tmp_field -> first_external = tmp_field -> first_external -> next;
3492 tmp_field -> first_external -> prev = NULL;
3493 }
3494 else
3495 {
3496 tmp_field -> first_external = NULL;
3497 }
3498 }
3499 else if (tmp_fext -> next == NULL)
3500 {
3501 tmp_fext = tmp_fext -> prev;
3502 tmp_fext -> next = NULL;
3503 }
3504 else
3505 {
3506 tmp_fext -> prev -> next = tmp_fext -> next;
3507 tmp_fext -> next -> prev = tmp_fext -> prev;
3508 }
3509 tmp_field -> extern_fields --;
3510 tmp_fext = tmp_field -> first_external;
3511 for (k=0; k<tmp_field -> extern_fields; k++)
3512 {
3513 tmp_fext -> id = k;
3514 if (tmp_fext -> next != NULL) tmp_fext = tmp_fext -> next;
3515 }
3516 }
3517 else
3518 {
3519 j = i - MOLIMIT;
3521 if (j == 2)
3522 {
3523 cross = NULL;
3524 if (tmp_field -> nbody[j] > 1)
3525 {
3526 cross = alloctdouble (tmp_field -> nbody[j]-1, tmp_field -> nbody[j]-1, 3);
3527 m = -1;
3528 for (k=0; k<tmp_field -> nbody[j]; k++)
3529 {
3530 if (k != tmp_fbody -> id)
3531 {
3532 m ++;
3533 n = -1;
3534 for (l=0; l<tmp_field -> nbody[j]; l++)
3535 {
3536 if (l != tmp_fbody -> id)
3537 {
3538 n ++;
3539 for (o=0; o<3; o++) cross[m][n][o] = cross[n][m][o] = tmp_field -> cross[k][l][o];
3540 }
3541 }
3542 }
3543 }
3544 }
3545 }
3546 if (tmp_fbody == tmp_field -> first_body[j])
3547 {
3548 if (tmp_fbody -> next != NULL)
3549 {
3550 tmp_field -> first_body[j] = tmp_field -> first_body[j] -> next;
3551 tmp_field -> first_body[j] -> prev = NULL;
3552 }
3553 else
3554 {
3555 tmp_field -> first_body[j] = NULL;
3556 }
3557 }
3558 else if (tmp_fbody -> next == NULL)
3559 {
3560 tmp_fbody = tmp_fbody -> prev;
3561 tmp_fbody -> next = NULL;
3562 }
3563 else
3564 {
3565 tmp_fbody -> prev -> next = tmp_fbody -> next;
3566 tmp_fbody -> next -> prev = tmp_fbody -> prev;
3567 }
3568 tmp_field -> nbody[j] --;
3569 g_free (tmp_fbody);
3570 tmp_fbody = tmp_field -> first_body[j];
3571 k = 0;
3572 while (tmp_fbody)
3573 {
3574 tmp_fbody -> id = k;
3575 k ++;
3576 tmp_fbody = tmp_fbody -> next;
3577 }
3578
3579 if (j == 2) check_tersoffs (-1, tmp_field -> first_body[j] -> key);
3580 }
3582 }
3583}
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
ColRGBA init_color(int id, int numid)
initialize color based id number over total number of elements
Definition initcoord.c:81
GtkTreeStore * add_model
Definition cpmd_nose.c:157
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_at
Definition dlp_edit.c:1146
float val
Definition dlp_init.c:117
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 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
int ** sel_at
Definition dlp_atom.c:56
int a_ato
Definition dlp_atom.c:57
GtkCellRenderer * ato_cell[4]
Definition dlp_atom.c:63
int active_sel
Definition dlp_atom.c:54
int vdw_id
Definition dlp_edit.c:930
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:423
gchar * mo_title[8]
Definition dlp_field.c:1025
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:2242
int * edit_atids
Definition dlp_edit.c:123
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
gchar * felemt[MAXDATA+1]
Definition dlp_field.c:164
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:1158
gchar * body_str(int a)
get body potential string name
Definition dlp_edit.c:1645
GtkWidget * add_tree
Definition dlp_edit.c:929
void visualize_single_struct(int id, int jd, int kd, int *ids)
visualize single structural element
Definition dlp_viz.c:486
GtkWidget * shell_hbox[3]
Definition dlp_edit.c:118
void update_field_dist(float v)
update field distance widget
Definition dlp_edit.c:1623
G_MODULE_EXPORT void add_field_prop(GSimpleAction *action, GVariant *parameter, gpointer data)
add field property callback
Definition dlp_edit.c:3059
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:376
void update_tersoffs(int id, int key)
update non bonded potential
Definition dlp_edit.c:2926
int is_moy
Definition dlp_edit.c:122
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:1041
GtkWidget * img_but[4]
Definition dlp_edit.c:115
void check_tersoffs(int id, int key)
check non bonded potential
Definition dlp_edit.c:2958
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:1890
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:1057
GtkWidget * centry[3]
Definition dlp_edit.c:416
gchar * elemts[MAXDATA]
Definition dlp_field.c:187
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:682
int get_num_vdw_max()
Get the number of field shell interactions.
Definition dlp_edit.c:2009
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:1177
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:2994
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:735
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:2037
G_MODULE_EXPORT void select_it(GtkToggleButton *but, gpointer data)
select object toggle callback GTK3
Definition dlp_edit.c:907
GtkWidget * param_prop_param_box(int pid)
prepare field parameter edition widgets
Definition dlp_edit.c:706
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:1670
GtkWidget * param_box
Definition dlp_edit.c:114
G_MODULE_EXPORT void remove_field_prop(GSimpleAction *action, GVariant *parameter, gpointer data)
remove field property callback
Definition dlp_edit.c:3299
gchar * rep_atom_name
Definition dlp_edit.c:2243
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:941
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:1967
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:2235
gchar * field_str(int a)
get field external name
Definition dlp_edit.c:667
G_MODULE_EXPORT void run_edit_parameters(GtkDialog *dialog, gint response_id, gpointer data)
edit field parameter - running the dialog
Definition dlp_edit.c:2254
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:858
void visualize_body(int viz, int bd, field_nth_body *body)
show / hide non bonded interaction
Definition dlp_viz.c:339
GtkWidget * ff_p_combo[2]
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:1614
G_MODULE_EXPORT void changed_field_key_combo(GtkComboBox *box, gpointer data)
change field key
Definition dlp_edit.c:759
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:120
void edit_parameters(int f, int id)
edit field parameter - creating the dialog
Definition dlp_edit.c:2281
gchar * get_body_element_name(field_nth_body *body, int aid, int nbd)
get field body potential element name
Definition dlp_edit.c:1941
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:396
char * fvars_inversion[2][FINVERS][FINVERS_P]
Definition dlp_field.c:612
char * fvars_dihedral[2][FDIHEDRAL][FDIHEDRAL_P]
Definition dlp_field.c:540
char * fvars_angle[2][FANGLES][FANGLES_P]
Definition dlp_field.c:462
char * fvars_vdw[2][FVDW][FVDW_P]
Definition dlp_field.c:692
GtkTreeIter field_iter
Definition dlp_field.c:1038
char * fvars_fbd[2][FFOURBODY][FFOURBODY_P]
Definition dlp_field.c:852
glwin * tmp_view
Definition dlp_field.c:1042
field_constraint * tmp_fcons
Definition dlp_field.c:1049
int fvalues[2][15][21]
Definition dlp_field.c:345
int field_object
Definition dlp_field.c:1069
field_nth_body * tmp_fbody
Definition dlp_field.c:1055
project * tmp_proj
Definition dlp_field.c:1043
field_shell * tmp_fshell
Definition dlp_field.c:1048
field_rigid * tmp_frig
Definition dlp_field.c:1051
int body_at(int b)
find the number of atom(s) in a non bonded interaction
Definition dlp_field.c:1112
int num_field_objects
Definition dlp_field.c:1071
field_pmf * tmp_fpmf
Definition dlp_field.c:1050
gchar * fnames[2][16][21]
Definition dlp_field.c:308
field_external * tmp_fext
Definition dlp_field.c:1057
field_atom * tmp_fat
Definition dlp_field.c:1047
int row_id
Definition dlp_field.c:1072
GtkTreeStore * field_model[MAXDATA]
Definition dlp_field.c:1037
char * fvars_ters[2][FTERSOFFS][FTERSOFFS_P]
Definition dlp_field.c:816
int struct_id(int f)
number of atoms in a structural element
Definition dlp_field.c:1089
void update_field_trees()
classical force field assistant update all tree models
Definition dlp_field.c:1907
field_struct * tmp_fstr
Definition dlp_field.c:1054
field_molecule * tmp_fmol
Definition dlp_field.c:1045
field_prop * tmp_fprop
Definition dlp_field.c:1053
char * fvars_tbd[2][FTHREEBODY][FTHREEBODY_P]
Definition dlp_field.c:826
field_tethered * tmp_ftet
Definition dlp_field.c:1052
GType col_type[MAXDATA][12]
Definition dlp_field.c:946
GtkWidget * field_assistant
Definition dlp_field.c:1030
gchar * fkeysw[2][16][21]
Definition dlp_field.c:275
gboolean dlp_to_translate(int fid, int obj, int key)
test if fnames text is to be translated or not
Definition dlp_field.c:1215
classical_field * tmp_field
Definition dlp_field.c:1041
char * fvars_fext[2][FEXTERNAL][FEXTERNAL_P]
Definition dlp_field.c:866
GtkWidget * combo_mol[MOLIMIT-1]
Definition dlp_field.c:1034
char * fvars_met[2][FMETALS][FMETALS_P]
Definition dlp_field.c:778
char * fvars_teth[2][FTETH][FTETH_P]
Definition dlp_field.c:382
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)
initialize 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:547
#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]
#define FBONDS
Definition dlp_field.h:70
#define FDIHEDRAL
Definition dlp_field.h:72
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:579
#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:550
field_external * init_field_external(int bi)
initialize 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)
initialize 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
#define FANGLES
Definition dlp_field.h:71
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:317
double * duplicate_double(int num, double *old_val)
copy a list of double
Definition global.c:595
int dialog_id
Definition global.c:170
int activef
Definition global.c:164
GMainLoop * Event_loop[5]
Definition global.c:182
double *** alloctdouble(int xal, int yal, int zal)
allocate a double *** pointer
Definition global.c:485
int * allocint(int val)
allocate an int * pointer
Definition global.c:301
#define i18n(String)
Definition global.c:80
float * allocfloat(int val)
allocate a float * pointer
Definition global.c:385
double string_to_double(gpointer string)
convert string to double
Definition global.c:611
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:533
@ IMG_NONE
Definition global.h:276
int combo_get_active(GtkWidget *combo)
retrieve the active item's position
Definition gtk-misc.c:935
GtkWidget * create_entry(GCallback handler, int dim, int cdim, gboolean key_release, gpointer data)
Create a GtkEntry.
Definition gtk-misc.c:1401
void update_entry_double(GtkEntry *entry, double doubleval)
update the content of a GtkEntry as double
Definition gtk-misc.c:688
void set_renderer_color(int tocol, GtkCellRenderer *renderer, ColRGBA col)
set the color of a GtkCellRenderer
Definition gtk-misc.c:1740
GtkWidget * create_scroll(GtkWidget *box, int dimx, int dimy, int shadow)
create a scroll window
Definition gtk-misc.c:2139
GtkWidget * dialogmodal(gchar *str, GtkWindow *parent)
Create a new dialog modal window.
Definition gtk-misc.c:552
void combo_set_active(GtkWidget *combo, int pos)
set the active item's position
Definition gtk-misc.c:958
const gchar * entry_get_text(GtkEntry *entry)
get the text in a GtkEntry
Definition gtk-misc.c:652
#define BSEP
Definition global.h:261
GtkWidget * stock_image(const gchar *stock_id)
create a GtkImage for the Gtk database
Definition gtk-misc.c:1451
void set_renderer_markup(GtkTreeModel *mod, GtkTreeIter *iter, GtkCellRenderer *renderer, int col)
set Pango text markup for a GtkCellRenderer
Definition gtk-misc.c:1764
#define APPLY
Definition global.h:236
GtkWidget * check_button(gchar *text, int dimx, int dimy, gboolean state, GCallback handler, gpointer data)
create a check button
Definition gtk-misc.c:1937
@ CONTAINER_SCR
Definition global.h:267
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:1999
GtkWidget * create_combo()
create a GtkCombox widget, note deprecated in GTK4
Definition gtk-misc.c:1010
GtkWidget * dialog_get_content_area(GtkWidget *widg)
prepare GtkWidget to insert content in a GtkDialog window
Definition gtk-misc.c:861
GtkWidget * markup_label(gchar *text, int dimx, int dimy, float ax, float ay)
create a GtkLabel with pango markup
Definition gtk-misc.c:1672
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:340
#define DELETEB
Definition global.h:238
void widget_set_sensitive(GtkWidget *widg, gboolean sensitive)
Set sensitivity for a GtkWidget, ensuring it is a GtkWidget.
Definition gtk-misc.c:247
void destroy_this_dialog(GtkDialog *dialog)
destroy a GtkDialog
Definition gtk-misc.c:2235
GtkWidget * create_hbox(int spacing)
create a GtkBox with horizontal orientation
Definition gtk-misc.c:849
#define CHEM_M
Definition global.h:317
void combo_text_append(GtkWidget *combo, gchar *text)
append text in GtkComboBox widget
Definition gtk-misc.c:987
GtkWidget * destroy_this_widget(GtkWidget *widg)
destroy a GtkWidget
Definition gtk-misc.c:2213
void update_entry_text(GtkEntry *entry, gchar *text)
update the content of a GtkEntry as string
Definition gtk-misc.c:726
void add_container_child(int type, GtkWidget *widg, GtkWidget *child)
Add a GtkWidget into another GtkWidget.
Definition gtk-misc.c:267
void set_image_from_icon_name(GtkWidget *widg, gchar *icon)
set a image from a stock icon name
Definition gtk-misc.c:2030
void hide_the_widgets(GtkWidget *widg)
hide GtkWidget
Definition gtk-misc.c:224
GtkWidget * create_vbox(int spacing)
create a GtkBox with vertical orientation
Definition gtk-misc.c:837
int button_get_status(GtkWidget *button)
get status of check / toggle button
Definition gtk-misc.c:1899
#define MAXDATA
Number of tabs for the description of the classical force field.
Definition global.h:776
void show_the_widgets(GtkWidget *widg)
show GtkWidget
Definition gtk-misc.c:202
Variable declarations related to the OpenGL window Function declarations related to the OpenGL wind...
action
Definition glview.h:198
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:770
gboolean ask_yes_no(gchar *title, gchar *text, int type, GtkWidget *widg)
ask yes or no for something: prepare dialog
Definition interface.c:420
gchar * exact_name(gchar *name)
short cut to print string without spaces
Definition interface.c:434
Messaging function declarations.
integer(kind=c_int) function molecules(frag_and_mol, allbonds)
double z
Definition ogl_draw.c:63
Definition global.h:964
double z
Definition global.h:970
double y
Definition global.h:969
double x
Definition global.h:968
Definition glwin.h:350
Definition global.h:111
double length
Definition glwin.h:124
Definition glwin.h:967
GtkWidget * res[2]
Definition w_encode.c:342
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