atomes 1.3.1
atomes: an atomic scale modeling tool box
Loading...
Searching...
No Matches
atom_action.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: 'atom_action.c'
24*
25* Contains:
26*
27
28 - The functions to apply the edition actions to the model
29
30*
31* List of functions:
32
33 int action_atoms_from_project (project * this_proj, atom_search * asearch, gboolean visible);
34
35 gboolean do_we_have_objects_in_selection (project * this_proj, atom_search * asearch, gboolean editing);
36
37 void free_dummies (dummy_atom * tmp_pick);
38 void clean_this_project (project * this_proj);
39 void clean_motion_search (project * this_proj, atom_search * asearch, int sid);
40 void clean_all_trees (atom_search * asearch, project * this_proj);
41 void apply_action (project * this_proj, atom_search * asearch);
42 void prepare_random_action (project * this_proj, atom_search * asearch);
43
44 G_MODULE_EXPORT void take_action (GtkButton * but, gpointer data);
45
46 atom_search * duplicate_atom_search (atom_search * asearch);
47
48*/
49
50#include "atom_edit.h"
51#include "curve.h"
52#include "preferences.h"
53#include "bind.h"
54
55extern GLdouble get_max_depth (GLdouble depth);
56extern void setup_default_lights (project * this_proj, image * img);
57
65void free_dummies (dummy_atom * tmp_pick)
66{
67 while (tmp_pick)
68 {
69 if (tmp_pick -> next)
70 {
71 tmp_pick = tmp_pick -> next;
72 g_free (tmp_pick -> prev);
73 tmp_pick -> prev = NULL;
74 }
75 else
76 {
77 g_free (tmp_pick);
78 tmp_pick = NULL;
79 }
80 }
81}
82
90void clean_this_project (project * this_proj)
91{
92 int i, j;
93 opengl_project_changed (this_proj -> id);
94 selected_aspec = -1;
95 is_selected = -1;
96 for (i=0; i<opengl_project -> natomes; i++)
97 {
98 opengl_project -> atoms[0][i].show[0] = opengl_project -> atoms[0][i].show[1] = FALSE;
99 }
100 gboolean vis_stat = opengl_project -> modelgl -> atom_win -> visible;
101 opengl_project -> modelgl -> atom_win -> visible = FALSE;
102 i = opengl_project -> modelgl -> selection_mode;
103#ifdef GTK4
104 select_unselect_atoms (NULL, NULL, & opengl_project -> modelgl -> colorp[0][0]);
105 label_unlabel_atoms (NULL, NULL, & opengl_project -> modelgl -> colorp[0][0]);
106#else
107 select_unselect_atoms (NULL, & opengl_project -> modelgl -> colorp[0][0]);
108 label_unlabel_atoms (NULL, & opengl_project -> modelgl -> colorp[0][0]);
109#endif
110 opengl_project -> modelgl -> selection_mode = NSELECTION-1;
111#ifdef GTK4
112 select_unselect_atoms (NULL, NULL, & opengl_project -> modelgl -> colorp[0][0]);
113 label_unlabel_atoms (NULL, NULL, & opengl_project -> modelgl -> colorp[0][0]);
114#else
115 select_unselect_atoms (NULL, & opengl_project -> modelgl -> colorp[0][0]);
116 label_unlabel_atoms (NULL, & opengl_project -> modelgl -> colorp[0][0]);
117#endif
118 opengl_project -> modelgl -> selection_mode = i;
119 opengl_project -> modelgl -> atom_win -> visible = vis_stat;
120#ifdef GTK4
121 label_unlabel_atoms (NULL, NULL, & opengl_project -> modelgl -> colorp[0][0]);
122#else
123 label_unlabel_atoms (NULL, & opengl_project -> modelgl -> colorp[0][0]);
124#endif
125 opengl_project -> modelgl -> create_shaders[RINGS] = TRUE;
126 opengl_project -> modelgl -> n_shaders[RINGS][0] = -1;
127 for (i=0; i<2; i++)
128 {
129 for (j=0; j<opengl_project -> coord -> totcoord[i]; j++)
130 {
131 opengl_project -> modelgl -> anim -> last -> img -> show_poly[i][j] = FALSE;
132 }
133 }
134 opengl_project -> modelgl -> create_shaders[POLYS] = TRUE;
135 opengl_project -> modelgl -> n_shaders[POLYS][0] = -1;
136 opengl_project -> natomes = 0;
137 g_free (this_proj -> atoms[0]);
138 for (i=0; i<2; i++)
139 {
140 if (opengl_project -> modelgl -> bonds[0][i])
141 {
142 if (opengl_project -> modelgl -> bondid[0][i])
143 {
144 g_free (opengl_project -> modelgl -> bondid[0][i]);
145 opengl_project -> modelgl -> bondid[0][i] = NULL;
146 }
147 }
148 opengl_project -> modelgl -> bonds[0][i] = 0;
149 opengl_project -> modelgl -> allbonds[i] = 0;
150 }
151 g_free (opengl_project -> chemistry);
152 opengl_project -> chemistry = NULL;
158 opengl_project -> nspec = 0;
159 for (i=0; i<10; i++) opengl_project -> coord -> totcoord[i] = 0;
160#ifdef GTK3
161 // GTK3 Menu Action To Check
162 for (i=1; i<OGL_COORDS; i++) opengl_project -> modelgl -> ogl_coord[i] = NULL;
163 for (i=0; i<OGL_RINGS; i++) opengl_project -> modelgl -> ogl_rings[i] = NULL;
164 opengl_project -> modelgl -> ogl_chains[0] = NULL;
165#endif
167}
168
178void clean_motion_search (project * this_proj, atom_search * asearch, int sid)
179{
180 int i;
181 if (asearch -> in_selection)
182 {
183 for (i=0; i<asearch -> todo_size; i++) asearch -> todo[i] = 0;
184 asearch -> in_selection = 0;
185 if (this_proj -> modelgl -> atom_win -> to_be_moved[sid])
186 {
187 atomic_object * object = this_proj -> modelgl -> atom_win -> to_be_moved[sid];
188 while (object -> next)
189 {
190 object = object -> next;
191 g_free (object -> prev);
192 }
193 g_free (object);
194 this_proj -> modelgl -> atom_win -> to_be_moved[sid] = NULL;
195 }
196 }
197 this_proj -> modelgl -> atom_win -> rebuilt[! sid] = TRUE;
198 this_proj -> modelgl -> atom_win -> rebuilt[sid] = FALSE;
199}
200
210int action_atoms_from_project (project * this_proj, atom_search * asearch, gboolean visible)
211{
212 int i, j, k, l, m, n, o, p;
213 dummy_atom * to_rem, * to_add;
214 dummy_atom * tmp_rem, * tmp_add;
215 atomic_object * object_list = NULL;
216 atomic_object * tmp_list;
217 atomic_object * object, * tmp_obj;
218 int remove, extra, nmols;
219 int act = (asearch -> pointer[0].c == 3) ? 0 : (asearch -> pointer[0].c == 5) ? 1 : 3;
220
221 to_rem = tmp_rem = NULL;
222 to_add = tmp_add = NULL;
223 remove = extra = nmols = 0;
224 atom_edition * edit = this_proj -> modelgl -> atom_win;
225 edit -> add_spec = 0;
226 if (this_proj -> nspec)
227 {
228 edit -> new_z = duplicate_double (this_proj -> nspec, this_proj -> chemistry -> chem_prop[CHEM_Z]);
229 edit -> coord = duplicate_coord_info (this_proj -> coord);
230 }
231 else if (! this_proj -> natomes)
232 {
233 edit -> coord = NULL;
234 this_proj -> modelgl -> anim -> last -> img -> xyz -> axis = default_axis.axis;
235 }
236 gboolean passivate = FALSE;
237 if (asearch -> action == REMOVE)
238 {
239 if (this_proj -> modelgl -> cell_win)
240 {
241 if (this_proj -> modelgl -> cell_win -> slab_passivate) passivate = TRUE;
242 }
243 }
244
245 if (asearch -> action == DISPL || asearch -> action == REMOVE || asearch -> action == RANMOVE)
246 {
247 for (i=0; i<this_proj -> natomes; i++)
248 {
249 if (asearch -> todo[i])
250 {
251 if (to_rem != NULL)
252 {
253 tmp_rem -> next = g_malloc0(sizeof*tmp_rem);
254 tmp_rem -> next -> prev = tmp_rem;
255 tmp_rem = tmp_rem -> next;
256 }
257 else
258 {
259 to_rem = g_malloc0(sizeof*to_rem);
260 tmp_rem = to_rem;
261 }
262 tmp_rem -> id = i;
263 remove ++;
264 }
265 }
266 }
267 else
268 {
269 object = edit -> to_be_inserted[act];
270 i = o = p = 0;
271 while (object)
272 {
273 j = object -> id;
274/* #ifdef DEBUG
275 g_debug ("object -> id= %d, name= %s, todo[%d]= %d", j+1, object -> name, j+1, asearch -> todo[j]);
276#endif */
277 if (asearch -> todo[j])
278 {
279 if (edit -> coord)
280 {
281 o += search_for_new_spec (edit, object);
282 }
283 else
284 {
285 edit -> coord = duplicate_coord_info (object -> coord);
286 edit -> new_z = allocdouble (edit -> coord -> species);
287 for (k=0; k<edit -> coord -> species; k++) edit -> new_z[k] = (double)object -> old_z[k];
288 o += object -> species;
289 }
290 asearch -> in_selection --;
291 if (! object_list)
292 {
293 object_list = duplicate_atomic_object (object);
294 tmp_list = object_list;
295 }
296 else
297 {
298 tmp_list -> next = duplicate_atomic_object (object);
299 tmp_list -> next -> prev = tmp_list;
300 tmp_list = tmp_list -> next;
301 }
302 for (k=0; k<object -> atoms; k++)
303 {
304 if (to_add)
305 {
306 tmp_add -> next = g_malloc0(sizeof*tmp_add);
307 tmp_add -> next -> prev = tmp_add;
308 tmp_add = tmp_add -> next;
309 }
310 else
311 {
312 to_add = g_malloc0(sizeof*to_add);
313 tmp_add = to_add;
314 }
315 tmp_add -> id = this_proj -> natomes + extra - remove;
316 l = object -> at_list[k].sp;
317 tmp_add -> type = find_spec_id (edit -> coord -> species, object -> old_z[l], edit -> new_z);
318 tmp_add -> xyz[0] = object -> at_list[k].x + object -> baryc[0];
319 tmp_add -> xyz[1] = object -> at_list[k].y + object -> baryc[1];
320 tmp_add -> xyz[2] = object -> at_list[k].z + object -> baryc[2];
321 for (m=0; m<2; m++)
322 {
323 tmp_add -> coord[m] = find_this_geo_id (m, object -> coord, object -> old_z, object -> at_list[k].coord[m],
324 l, tmp_add -> type, edit -> coord, edit -> new_z);
325
326 }
327 for (m=2; m<4; m++) tmp_add -> coord[m] = object -> at_list[k].coord[2] + i;
328 if (this_proj -> coord)
329 {
330 for (m=2; m<4; m++) tmp_add -> coord[m] += this_proj -> coord -> totcoord[m];
331 }
332 tmp_add -> numv = object -> at_list[k].numv;
333 if (tmp_add -> numv)
334 {
335 tmp_add -> vois = duplicate_int (object -> at_list[k].numv, object -> at_list[k].vois);
336 for (m=0; m<tmp_add -> numv; m++) tmp_add -> vois[m] += p + this_proj -> natomes;
337 sort (tmp_add ->numv, tmp_add -> vois);
338 }
339 extra ++;
340 }
341 i += object -> coord -> totcoord[2];
342 p += object -> atoms;
343 if (object -> prev)
344 {
345 if (object -> next)
346 {
347 object -> prev -> next = object -> next;
348 object -> next -> prev = object -> prev;
349 tmp_obj = object;
350 object = object -> next;
351 g_free (tmp_obj);
352 }
353 else
354 {
355 object -> prev -> next = NULL;
356 g_free (object);
357 object = NULL;
358 }
359 }
360 else
361 {
362 if (object -> next)
363 {
364 edit -> to_be_inserted[act] = object -> next;
365 object = object -> next;
366 g_free (object -> prev);
367 object -> prev = NULL;
368 }
369 else
370 {
371 g_free (edit -> to_be_inserted[act]);
372 edit -> to_be_inserted[act] = NULL;
373 object = NULL;
374 }
375 }
376 }
377 else
378 {
379 object = object -> next;
380 }
381 }
382 nmols += i;
383 edit -> coord -> totcoord[2] += i;
384 edit -> add_spec = o;
385 }
386
387#ifdef DEBUG
388 if (asearch -> action == INSERT && extra)
389 {
390 g_debug ("Project coord before insert:");
391 if (this_proj -> natomes)
392 {
393 print_coord_info (this_proj, this_proj -> coord);
394 }
395 else
396 {
397 g_debug (" *** None *** ");
398 }
399 g_debug ("Coord info after object insert:");
400 print_coord_info (NULL, edit -> coord);
401 }
402#endif
403
404 if (asearch -> action == DISPL && remove == 0) return -1;
405 if (asearch -> action == RANMOVE && remove == 0) return -1;
406 if (asearch -> action == REMOVE && remove == 0) return -1;
407 if ((asearch -> action == INSERT || asearch -> action == REPLACE) && extra == 0) return extra;
408 if (asearch -> action == REMOVE && remove > this_proj -> natomes) return -1;
409
410 if ((asearch -> action != DISPL && asearch -> action != RANMOVE)
411 || (asearch -> passivating && asearch -> filter < 3)
412 || (asearch -> action == RANMOVE && asearch -> passivating && asearch -> object < 2)
413 || (asearch -> action == RANMOVE && ! asearch -> passivating && ! asearch -> object))
414 {
415 this_proj -> modelgl -> bonding = FALSE;
416 this_proj -> coord -> totcoord[3] = 0;
417 if (this_proj -> modelgl -> adv_bonding[1])
418 {
419 for (i=0; i<2; i++)
420 {
421 if (this_proj -> modelgl -> anim -> last -> img -> color_map[i] == 4 || this_proj -> modelgl -> anim -> last -> img -> color_map[i] == 5)
422 {
423#ifdef GTK3
424 // GTK3 Menu Action To Check
425 if (this_proj -> modelgl -> color_styles[i*ATOM_MAPS])
426 {
427 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)this_proj -> modelgl -> color_styles[i*ATOM_MAPS], TRUE);
428 set_color_map (this_proj -> modelgl -> color_styles[i*ATOM_MAPS], & this_proj -> modelgl -> colorp[i*ATOM_MAPS][0]);
429 }
430#endif
431 }
432 }
433 }
434 this_proj -> modelgl -> adv_bonding[1] = FALSE;
435 if (this_proj -> force_field[0])
436 {
437 g_free (this_proj -> force_field[0]);
438 this_proj -> force_field[0] = NULL;
439 }
440 if (asearch -> action != DISPL && asearch -> action != RANMOVE)
441 {
442 if (this_proj -> modelgl -> custom_map)
443 {
444 g_free (this_proj -> modelgl -> custom_map);
445 this_proj -> modelgl -> custom_map = NULL;
446 for (i=0; i<2; i++)
447 {
448 j = i*ATOM_MAPS;
449#ifdef GTK3
450 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)this_proj -> modelgl -> color_styles[j], TRUE);
451 set_color_map (this_proj -> modelgl -> color_styles[j], & this_proj -> modelgl -> colorp[j][0]);
452 if (i) widget_set_sensitive (this_proj -> modelgl -> color_styles[j+6], 0);
453#endif
454 }
455 }
456 }
457 }
458
459 // Clean curves data
460 if (this_proj -> analysis)
461 {
462 for (i=0 ; i<NCALCS ; i++)
463 {
464 if (this_proj -> analysis[i])
465 {
466 this_proj -> analysis[i] -> calc_ok = FALSE;
467 hide_curves (this_proj, i);
468 erase_curves (this_proj, i);
469 }
470 }
471 }
472 if (this_proj -> modelgl -> rings)
473 {
474 this_proj -> modelgl -> rings = FALSE;
475 for (i=0; i<5; i++)
476 {
477 clean_rings_data (i, this_proj -> modelgl);
478 }
479#ifdef GTK3
480 update_rings_menus (this_proj -> modelgl);
481#endif
482 }
483 if (this_proj -> modelgl -> chains)
484 {
485 clean_chains_data (this_proj -> modelgl);
486#ifdef GTK3
487 update_chains_menus (this_proj -> modelgl);
488#endif
489 }
490 clean_volumes_data (this_proj -> modelgl);
491
492 if (asearch -> action == REMOVE && remove == this_proj -> natomes)
493 {
494 clean_this_project (this_proj);
495 return remove;
496 }
497
498 atom * new_list = NULL;
499 atom * tmp_new = NULL;
500 gboolean * showfrag;
501 int ** tmpgeo[2];
502 int new_atoms = 0;
503 int * old_id = NULL;
504 if (this_proj -> natomes)
505 {
506 old_id = allocint (this_proj -> natomes);
507 tmp_rem = to_rem;
508 for (i=0; i<this_proj -> natomes; i++)
509 {
510 if (tmp_rem && tmp_rem -> id == i)
511 {
512 old_id[i] = -(i+1);
513 if (asearch -> action == DISPL || asearch -> action == RANMOVE || passivate)
514 {
515 if (new_list)
516 {
517 tmp_new -> next = duplicate_atom (& this_proj -> atoms[0][i]);
518 tmp_new -> next -> prev = tmp_new;
519 tmp_new = tmp_new -> next;
520 }
521 else
522 {
523 new_list = duplicate_atom (& this_proj -> atoms[0][i]);
524 tmp_new = new_list;
525 }
526 new_atoms ++;
527 }
528 if (tmp_rem -> next != NULL) tmp_rem = tmp_rem -> next;
529 }
530 else
531 {
532 old_id[i] = i+1;
533 if (new_list)
534 {
535 tmp_new -> next = duplicate_atom (& this_proj -> atoms[0][i]);
536 tmp_new -> next -> prev = tmp_new;
537 tmp_new = tmp_new -> next;
538 }
539 else
540 {
541 new_list = duplicate_atom (& this_proj -> atoms[0][i]);
542 tmp_new = new_list;
543 }
544 new_atoms ++;
545 }
546 }
547 if (asearch -> action == DISPL || asearch -> action == REMOVE || asearch -> action == RANMOVE)
548 {
549 check_coord_modification (this_proj, old_id, new_list, NULL, TRUE, passivate);
550 // old_id for atoms to be passivated (removed then replaced) have been corrected to be > 0,
551 // accordingly the total number of atoms to save must be updated
552 if (passivate)
553 {
554 i = 0;
555 tmp_new = new_list;
556 while (tmp_new)
557 {
558 if (old_id[tmp_new -> id] > 0) i++;
559 tmp_new = tmp_new -> next;
560 }
561 new_atoms = i;
562 }
563 }
564 // Preserving coordination information
565 for (i=0; i<2; i++)
566 {
567 j= this_proj -> nspec + edit -> add_spec;
568 tmpgeo[i] = g_malloc0(j*sizeof*tmpgeo[i]);
569 for (k=0; k<j; k++)
570 {
571 tmpgeo[i][k] = allocint (edit -> coord -> ntg[i][k]);
572 }
573 }
574 tmp_new = new_list;
575 while (tmp_new)
576 {
577 j = tmp_new -> id;
578 k = tmp_new -> sp;
579 // g_debug (" id= %d, c[0]= %d, c[1]= %d", j, tmp_new -> coord[0], tmp_new -> coord[1]);
580 if (! passivate || old_id[j] > 0)
581 {
582 for (l=0; l<2; l++)
583 {
584 m = tmp_new -> coord[l];
585 if (m >= edit -> coord -> ntg[l][k])
586 {
587 g_warning (_("Error: at= %d, sp= %d, l= %d, geo_id= %d, edit -> coord -> ntg[%d][%d]= %d"), j+1, k, l, m, l, k, edit -> coord -> ntg[l][k]);
588 }
589 tmpgeo[l][k][m] ++;
590 }
591 }
592 tmp_new = tmp_new -> next;
593 }
594
595 if (asearch -> action != INSERT && asearch -> action != REPLACE)
596 {
597 showfrag = remove_bonds_from_project (this_proj, NULL, old_id, new_list, (asearch -> action == DISPL || asearch -> action == RANMOVE) ? FALSE : TRUE, passivate);
598 }
599 else
600 {
601 i = edit -> coord -> totcoord[2];
602 j = this_proj -> coord -> totcoord[2];
603 showfrag = allocbool (i);
604 for (k=0; k<j; k++)
605 {
606 showfrag[k] = this_proj -> modelgl -> anim -> last -> img -> show_coord[2][k];
607 }
608 for (k=j; k<i; k++) showfrag[k] = TRUE;
609 }
610 }
611 else
612 {
613 for (i=0; i<2; i++)
614 {
615 tmpgeo[i] = g_malloc0(edit -> coord -> species*sizeof*tmpgeo[i]);
616 for (j=0; j<edit -> coord -> species; j++)
617 {
618 tmpgeo[i][j] = allocint (edit -> coord -> ntg[i][j]);
619 }
620 }
621 showfrag = allocbool(edit -> coord -> totcoord[2]);
622 for (j=0; j<edit -> coord -> totcoord[2]; j++)
623 {
624 showfrag[j] = TRUE;
625 }
626 }
627
628 if (asearch -> action == DISPL || asearch -> action == REMOVE || asearch -> action == RANMOVE)
629 {
630 free_dummies (to_rem);
631 to_rem = NULL;
632 to_add = NULL;
633 tmp_new = new_list;
634 i = k = 0;
635 while (tmp_new)
636 {
637 if (old_id[tmp_new -> id] > 0 || asearch -> action != REMOVE)
638 {
639 if (tmp_new -> pick[0] || tmp_new -> pick[1])
640 {
641 if (to_add != NULL)
642 {
643 tmp_add -> next = g_malloc0(sizeof*tmp_add);
644 tmp_add -> next -> prev = tmp_add;
645 tmp_add = tmp_add -> next;
646 }
647 else
648 {
649 to_add = g_malloc0(sizeof*to_add);
650 tmp_add = to_add;
651 }
652 for (j=0; j<2; j++) tmp_add -> pick[j] = tmp_new -> pick[j];
653 tmp_add -> id = i;
654 k ++;
655 }
656 i ++;
657 }
658 tmp_new = tmp_new -> next;
659 }
660 }
661 else
662 {
663 tmp_add = to_add;
664 if (new_list)
665 {
666 tmp_new = new_list;
667 while (tmp_new -> next) tmp_new = tmp_new -> next;
668 }
669 while (tmp_add)
670 {
671 if (new_list)
672 {
673 tmp_new -> next = g_malloc0(sizeof*tmp_new -> next);
674 tmp_new -> next -> prev = tmp_new;
675 tmp_new = tmp_new -> next;
676 }
677 else
678 {
679 new_list = g_malloc0(sizeof*new_list);
680 tmp_new = new_list;
681 }
682 tmp_new -> sp = tmp_add -> type;
683 tmp_new -> show[0] = tmp_new -> show[1] = TRUE;
684 tmp_new -> x = tmp_add -> xyz[0];
685 tmp_new -> y = tmp_add -> xyz[1];
686 tmp_new -> z = tmp_add -> xyz[2];
687 for (i=0; i<4; i++) tmp_new -> coord[i] = tmp_add -> coord[i];
688 i = tmp_new -> sp;
689 for (j=0; j<2; j++)
690 {
691 k = tmp_add -> coord[j];
692 tmpgeo[j][i][k] ++;
693 }
694 // Neighbors
695 tmp_new -> numv = tmp_add -> numv;
696 if (tmp_new -> numv) tmp_new -> vois = duplicate_int (tmp_new -> numv, tmp_add -> vois);
697
698 new_atoms ++;
699 tmp_add -> pick[0] = TRUE;
700 tmp_add = tmp_add -> next;
701 }
702
703 atomic_object * object = object_list;
704 i = 0;
705 while (object)
706 {
707 i += object -> bonds;
708 object = object -> next;
709 }
710 int ** new_bond_list = allocdint (i, 2);
711 i = j = 0;
712 object = object_list;
713 while (object)
714 {
715 add_bonds_to_list (new_bond_list, i, j, object);
716 i += object -> atoms;
717 j += object -> bonds;
718 if (object -> next)
719 {
720 object = object -> next;
721 g_free (object -> prev);
722 }
723 else
724 {
725 g_free (object);
726 object = NULL;
727 }
728 }
729 add_bonds_to_project (this_proj, remove, j, new_bond_list);
730 }
731
732 if (this_proj -> natomes)
733 {
734 opengl_project_changed (this_proj -> id);
736 gboolean vis_stat = opengl_project -> modelgl -> atom_win -> visible;
737 opengl_project -> modelgl -> atom_win -> visible = FALSE;
738 i = opengl_project -> modelgl -> selection_mode;
739 opengl_project -> modelgl -> selection_mode = ATOMS;
740#ifdef GTK4
741 select_unselect_atoms (NULL, NULL, & opengl_project -> modelgl -> colorp[0][0]);
742#else
743 select_unselect_atoms (NULL, & opengl_project -> modelgl -> colorp[0][0]);
744#endif
745 opengl_project -> modelgl -> selection_mode = NSELECTION-1;
746#ifdef GTK4
747 select_unselect_atoms (NULL, NULL, & opengl_project -> modelgl -> colorp[0][0]);
748#else
749 select_unselect_atoms (NULL, & opengl_project -> modelgl -> colorp[0][0]);
750#endif
751 opengl_project -> modelgl -> selection_mode = i;
752 opengl_project -> modelgl -> atom_win -> visible = vis_stat;
753 }
754
755 if (this_proj -> nspec)
756 {
757 g_free (this_proj -> atoms[0]);
758 }
759 else
760 {
761 this_proj -> atoms = g_malloc0(sizeof*this_proj -> atoms);
762 }
763
764 int rem_spec;
765 int * spid, * spdel;
766 spid = allocint (this_proj -> nspec + edit -> add_spec);
767 spdel = allocint (this_proj -> nspec + edit -> add_spec);
768 int * atid = allocint (new_atoms);
769 this_proj -> atoms[0] = g_malloc0(new_atoms*sizeof*this_proj -> atoms[0]);
770 tmp_new = new_list;
771 i = 0;
772 while (tmp_new)
773 {
774 if (asearch -> action != REMOVE || old_id[tmp_new -> id] > 0)
775 {
776 this_proj -> atoms[0][i] = * duplicate_atom (tmp_new);
777 this_proj -> atoms[0][i].id = i;
778 spid[this_proj -> atoms[0][i].sp] ++;
779 atid[i] = this_proj -> atoms[0][i].sp;
780 this_proj -> atoms[0][i].pick[0] = this_proj -> atoms[0][i].pick[1] = FALSE;
781 i ++;
782 }
783 if (tmp_new -> next)
784 {
785 tmp_new = tmp_new -> next;
786 g_free (tmp_new -> prev);
787 }
788 else
789 {
790 g_free (tmp_new);
791 tmp_new = NULL;
792 }
793 }
794 if (old_id) g_free (old_id);
795 old_id = NULL;
796 rem_spec = 0;
797 for (i=0; i<this_proj -> nspec + edit -> add_spec; i++)
798 {
799 if (spid[i] == 0)
800 {
801 // A chem spec is being removed ... shit that's more work
802 rem_spec ++;
803 }
804 else
805 {
806 spdel[i] = rem_spec;
807 }
808 }
809
810 if (rem_spec || edit -> add_spec)
811 {
812 int new_spec = this_proj -> nspec - rem_spec + edit -> add_spec;
813 chemical_data * newchem = alloc_chem_data (new_spec);
814 i = 0;
815 for (j=0; j<this_proj -> nspec; j++)
816 {
817 if (spid[j] != 0)
818 {
819 newchem -> nsps[i] = this_proj -> chemistry -> nsps[j];
820 newchem -> formula[i] = this_proj -> chemistry -> formula[j];
821 newchem -> label[i] = g_strdup_printf ("%s", this_proj -> chemistry -> label[j]);
822 newchem -> element[i] = g_strdup_printf ("%s", this_proj -> chemistry -> element[j]);
823 for (k=0; k<CHEM_PARAMS; k++)
824 {
825 newchem -> chem_prop[k][i] = this_proj -> chemistry -> chem_prop[k][j];
826 }
827
828 if (j < this_proj -> nspec-1)
829 {
830 k = i;
831 for (l=j; l<this_proj -> nspec; l++)
832 {
833 if (spid[l] != 0)
834 {
835 newchem -> cutoffs[i][k] = newchem -> cutoffs[k][i] = this_proj -> chemistry -> cutoffs[j][l];
836 k ++;
837 }
838 }
839 }
840 newchem -> nsps[i] = spid[j];
841 i ++;
842 }
843 }
844 j = (this_proj -> nspec) ? 1 : 0;
845 for (k=0; k<edit -> add_spec - j*rem_spec; k++)
846 {
847 l = this_proj -> nspec + k;
848 if ( spid[l])
849 {
850 newchem -> nsps[i] = spid[l];
851 newchem -> formula[i] = 0;
852 newchem -> chem_prop[CHEM_Z][i] = newchem -> chem_prop[CHEM_X][i] = edit -> new_z[l];
853 m = (int)newchem -> chem_prop[CHEM_Z][i];
854 newchem -> label[i] = g_strdup_printf ("%s", periodic_table_info[m].lab);
855 newchem -> element[i] = g_strdup_printf ("%s", periodic_table_info[m].name);
856 n = 0;
857 newchem -> chem_prop[CHEM_M][i] = set_mass_ (& m);
858 newchem -> chem_prop[CHEM_R][i] = set_radius_ (& m, & n);
859 newchem -> chem_prop[CHEM_N][i] = set_neutron_ (& m);
860 newchem -> chem_prop[CHEM_X][i] = newchem -> chem_prop[CHEM_Z][i];
861 i ++;
862 }
863 }
864 initcutoffs (newchem, new_spec);
865 for (i=0; i<new_atoms; i++)
866 {
867 atid[i] -= spdel[atid[i]];
868 this_proj -> atoms[0][i].sp = atid[i];
869 }
870
871 if (this_proj -> chemistry) g_free (this_proj -> chemistry);
872 this_proj -> chemistry = NULL;
873 this_proj -> chemistry = duplicate_chemical_data (new_spec, newchem);
874 g_free (newchem);
875 }
876 else
877 {
878 g_free (this_proj -> chemistry -> nsps);
879 this_proj -> chemistry -> nsps = duplicate_int (this_proj -> nspec, spid);
880 }
881 g_free (atid);
882
883 i = activep;
884 if (! this_proj -> natomes)
885 {
886 this_proj -> natomes = new_atoms;
887 if (! this_proj -> cell.crystal) center_molecule (this_proj);
888 }
889 else
890 {
891 this_proj -> natomes = new_atoms;
892 }
893
894 // Active project changes in the next call
895 recover_opengl_data (this_proj, nmols, edit -> add_spec, rem_spec, spid, spdel, tmpgeo, showfrag);
896
897 if (showfrag)
898 {
899 g_free (showfrag);
900 showfrag = NULL;
901 }
902#ifdef DEBUG
903 if (this_proj -> natomes)
904 {
905 print_coord_info (this_proj, this_proj -> coord);
906 }
907 else
908 {
909 g_debug (" *** None *** ");
910 }
911#endif
912 g_free (spdel);
913 g_free (edit -> new_z);
914 g_free (spid);
915 for (j=0; j<2; j++)
916 {
917 g_free (tmpgeo[j]);
918 }
919
921 if (active_box)
922 {
923 if (test_vol(active_box -> param, active_box -> vect))
924 {
925 if (active_project -> analysis)
926 {
927 if (active_project -> analysis[GDR])
928 {
929 active_project -> analysis[GDR] -> avail_ok = TRUE;
930 active_project -> analysis[GDK] -> avail_ok = TRUE;
931 }
932 }
933 }
934 }
936 active_project -> dmtx = FALSE;
937 active_project -> run = (active_project -> natomes) ? TRUE : FALSE;
938 chemistry_ () ;
939
940 if (asearch -> recompute_bonding)
941 {
943 bonds_update = 1;
944 frag_update = (active_project -> natomes > ATOM_LIMIT) ? 0 : 1;
945 mol_update = (frag_update) ? ((active_project -> steps > STEP_LIMIT) ? 0 : 1) : 0;
946 active_project -> runc[0] = FALSE;
947 on_calc_bonds_released (NULL, NULL);
948 }
949 // Then back to the previous active project
951
952 int shaders[5] = {ATOMS, BONDS, POLYS, RINGS, SELEC};
953 re_create_md_shaders (5, shaders, this_proj);
954 this_proj -> modelgl -> create_shaders[PICKS] = TRUE;
955 this_proj -> modelgl -> create_shaders[MDBOX] = TRUE;
956 this_proj -> modelgl -> create_shaders[LABEL] = TRUE;
957 this_proj -> modelgl -> create_shaders[MEASU] = TRUE;
958
959 tmp_add = to_add;
960 for (i=0; i<2; i++) save_all_selections (this_proj -> modelgl, i);
961 while (tmp_add != NULL)
962 {
963 for (i=0; i<2; i++)
964 {
965 if (tmp_add -> pick[i])
966 {
967 process_selected_atom (this_proj, this_proj -> modelgl, tmp_add -> id, 0, 0, i);
968 }
969 }
970 tmp_add = tmp_add -> next;
971 }
972 for (i=0; i<2; i++) update_all_selections (this_proj -> modelgl, i);
973 if (to_add != NULL) free_dummies (to_add);
974
975 if (visible && (asearch -> action != DISPL && asearch -> action != RANMOVE))
976 {
977 for (i=0; i<3; i++)
978 {
979 g_free (this_proj -> modelgl -> saved_coord[i]);
980 this_proj -> modelgl -> saved_coord[i] = NULL;
981 init_coordinates (this_proj, i, FALSE, TRUE);
982 }
983 this_proj -> modelgl -> was_moved = FALSE;
984 this_proj -> modelgl -> atom_win -> rebuilt[0] = FALSE;
985 this_proj -> modelgl -> atom_win -> rebuilt[1] = FALSE;
986 if (this_proj -> modelgl -> atom_win -> msd) g_free (this_proj -> modelgl -> atom_win -> msd);
987 this_proj -> modelgl -> atom_win -> msd = allocfloat (this_proj -> natomes);
988 if (this_proj -> modelgl -> atom_win -> msd_all) g_free (this_proj -> modelgl -> atom_win -> msd_all);
989 this_proj -> modelgl -> atom_win -> msd_all = allocfloat (this_proj -> nspec);
990 for (i=0; i<2; i++) clean_motion_search (this_proj, this_proj -> modelgl -> search_widg[2+4*i], i);
991 motion_to_zero (this_proj -> modelgl -> search_widg[2]);
992 }
993 else if (visible && (asearch -> action == DISPL || asearch -> action == RANMOVE))
994 {
995 this_proj -> modelgl -> was_moved = TRUE;
996 clean_motion_search (this_proj, this_proj -> modelgl -> search_widg[(asearch -> action == DISPL) ? 6 : 2], (asearch -> action == DISPL) ? 1 : 0);
997 if (asearch -> action == RANMOVE) motion_to_zero (this_proj -> modelgl -> search_widg[2]);
998 }
999 else if (this_proj -> modelgl -> anim -> last -> img -> selected[0] -> selected)
1000 {
1001 g_free (this_proj -> modelgl -> saved_coord[1]);
1002 this_proj -> modelgl -> saved_coord[1] = save_coordinates (this_proj, 1);
1003 this_proj -> modelgl -> baryc[1] = get_bary (this_proj, 1);
1004 }
1005 update (this_proj -> modelgl);
1006#ifdef GTK4
1007 update_menu_bar (this_proj -> modelgl);
1008#endif
1009 clean_coord_window (this_proj);
1010
1011 switch (asearch -> action)
1012 {
1013 case REPLACE:
1014 return extra;
1015 break;
1016 case INSERT:
1017 return extra;
1018 break;
1019 case REMOVE:
1020 return remove;
1021 break;
1022 default:
1023 return 0;
1024 break;
1025 }
1026}
1027
1036void clean_all_trees (atom_search * asearch, project * this_proj)
1037{
1038 int i, j;
1039 for (i=0; i<5; i++)
1040 {
1041 if (i == 3)
1042 {
1043 clean_picked_and_labelled (this_proj -> modelgl -> search_widg[i+2], TRUE);
1044 if (this_proj -> modelgl -> search_widg[INSERT] -> in_selection)
1045 {
1046 allocate_todo (this_proj -> modelgl -> search_widg[i+2], this_proj -> modelgl -> search_widg[INSERT] -> in_selection);
1047 atomic_object * object = this_proj -> modelgl -> atom_win -> to_be_inserted[1];
1048 j = 0;
1049 while (object)
1050 {
1051 object -> id = j;
1052 j ++;
1053 object = object -> next;
1054 }
1055 update_search_tree (this_proj -> modelgl -> search_widg[i+2]);
1056 }
1057 }
1058 else if (this_proj -> modelgl -> search_widg[i+2] -> atom_tree)
1059 {
1060 j = get_asearch_filter (this_proj -> modelgl -> search_widg[i+2]);
1061 if ((j == 3 && ! this_proj -> modelgl -> adv_bonding[0]) || (j == 4 && ! this_proj -> modelgl -> adv_bonding[1]))
1062 {
1063 combo_set_active (this_proj -> modelgl -> search_widg[i+2] -> filter_box, 0);
1064 set_filter_changed (GTK_COMBO_BOX(this_proj -> modelgl -> search_widg[i+2] -> filter_box), this_proj -> modelgl -> search_widg[i+2]);
1065 }
1066 else if (asearch -> action != DISPL && asearch -> action != RANMOVE)
1067 {
1068 set_filter_changed (GTK_COMBO_BOX(this_proj -> modelgl -> search_widg[i+2] -> filter_box), this_proj -> modelgl -> search_widg[i+2]);
1069 }
1070 update_search_tree (this_proj -> modelgl -> search_widg[i+2]);
1071 }
1072 if ((i == 0 || i == 4) && this_proj -> modelgl -> search_widg[i+2] -> todo_size >= GTK_LIMIT)
1073 {
1074 re_populate_tree_search (this_proj -> modelgl -> search_widg[i+2]);
1075 }
1076 }
1077 if ((this_proj -> modelgl -> atom_win -> adv_bonding[0] && ! this_proj -> modelgl -> adv_bonding[0])
1078 || (this_proj -> modelgl -> atom_win -> adv_bonding[1] && ! this_proj -> modelgl -> adv_bonding[1]))
1079 {
1080 int j;
1081 for (i=0; i<5; i++)
1082 {
1083 if (i != 3)
1084 {
1085 if (this_proj -> modelgl -> search_widg[i+2] -> passivating)
1086 {
1087 j = (this_proj -> modelgl -> search_widg[i+2] -> object < 2) ? 3 : 2;
1088 }
1089 else
1090 {
1091 j = (! this_proj -> modelgl -> search_widg[i+2] -> object) ? 3 : 2;
1092 }
1093 if (GTK_IS_WIDGET(this_proj -> modelgl -> search_widg[i+2] -> filter_box))
1094 {
1095 if (this_proj -> modelgl -> atom_win -> adv_bonding[1] && ! this_proj -> modelgl -> adv_bonding[1])
1096 {
1097 gtk_combo_box_text_remove ((GtkComboBoxText *) this_proj -> modelgl -> search_widg[i+2] -> filter_box, j+1);
1098 }
1099 if (this_proj -> modelgl -> atom_win -> adv_bonding[0] && ! this_proj -> modelgl -> adv_bonding[0])
1100 {
1101 gtk_combo_box_text_remove ((GtkComboBoxText *) this_proj -> modelgl -> search_widg[i+2] -> filter_box, j);
1102 }
1103 }
1104 }
1105 }
1106 }
1107 for (i=0 ;i<2; i++) this_proj -> modelgl -> atom_win -> adv_bonding[i] = this_proj -> modelgl -> adv_bonding[i];
1108}
1109
1118void apply_action (project * this_proj, atom_search * asearch)
1119{
1120 gchar * str;
1121 gchar * appl[3] = {i18n("replaced"), i18n("removed"), i18n("inserted")};
1122 int k, l;
1123 l = 0;
1124 gboolean visible = (this_proj -> modelgl -> atom_win) ? this_proj -> modelgl -> atom_win -> visible : FALSE;
1125 if (asearch -> action == REPLACE || asearch -> action == REMOVE)
1126 {
1127 to_remove_this_list_of_objects (this_proj, asearch);
1128 l = action_atoms_from_project (this_proj, remove_search, visible);
1129 g_free (remove_search);
1130 remove_search = NULL;
1131 }
1132 k = (asearch -> action == REMOVE) ? l : action_atoms_from_project (this_proj, asearch, visible);
1133 if (asearch -> action != DISPL && asearch -> action != RANMOVE)
1134 {
1135 switch (k)
1136 {
1137 case 0:
1138 str = g_strdup_printf (_("No atoms to be %s !"), _(appl[asearch -> action-3]));
1139 break;
1140 default:
1141 if (asearch -> action == REPLACE && l)
1142 {
1143 if (asearch -> pointer[0].c == 8) l += asearch -> int_b - k;
1144 str = g_strdup_printf (_("%d atom(s) removed !\n%d atom(s) inserted !"), l, k);
1145 }
1146 else
1147 {
1148 str = g_strdup_printf (_("%d atom(s) %s !"), k, _(appl[asearch -> action-3]));
1149 }
1150 break;
1151 }
1152 if (this_proj -> modelgl -> atom_win -> win)
1153 {
1154 show_info (str, 0, this_proj -> modelgl -> atom_win -> win);
1155 }
1156 else
1157 {
1158 show_info (str, 0, this_proj -> modelgl -> win);
1159 }
1160 g_free (str);
1161 }
1162 if (visible)
1163 {
1164 if (k || l)
1165 {
1166 if (this_proj -> modelgl -> atom_win)
1167 {
1168 if (this_proj -> modelgl -> atom_win -> visible) clean_all_trees (asearch, this_proj);
1169 if (this_proj -> modelgl -> atom_win -> msd)
1170 {
1171 g_free (this_proj -> modelgl -> atom_win -> msd);
1172 this_proj -> modelgl -> atom_win -> msd = NULL;
1173 }
1174 this_proj -> modelgl -> atom_win -> msd = allocfloat (this_proj -> natomes);
1175 }
1176 }
1177 }
1179}
1180
1189void prepare_random_action (project * this_proj, atom_search * asearch)
1190{
1191 int i, j, k, l, m, n, o, p, q;
1192 double test, prob;
1193 atomic_object * object = NULL;
1194 atomic_object * tmp_oba, * tmp_obb;
1195 molecule * molfc;
1196 int max_num, total_num;
1197 gboolean lets_do_this = (asearch -> action == REMOVE || (asearch -> action == REPLACE && this_proj -> modelgl -> atom_win -> to_be_inserted[0])) ? TRUE : FALSE;
1198 if (lets_do_this)
1199 {
1200 int filter = get_asearch_filter (asearch);
1201 int obj = get_asearch_object (asearch);
1202 int num_elem = asearch -> todo_size;
1203 int * random_todo = duplicate_int (num_elem, asearch -> todo);
1204 total_num = (asearch -> mode && filter > 2 && obj) ? this_proj -> coord -> totcoord[2] : this_proj -> natomes;
1205 g_free (asearch -> todo);
1206 allocate_todo (asearch, total_num);
1207 if (asearch -> action == REPLACE && this_proj -> modelgl -> atom_win -> to_be_inserted[0])
1208 {
1209 tmp_oba = this_proj -> modelgl -> atom_win -> to_be_inserted[0];
1210 object = duplicate_atomic_object (tmp_oba);
1211 tmp_obb = object;
1212 while (tmp_oba -> next)
1213 {
1214 tmp_oba = tmp_oba -> next;
1215 tmp_obb -> next = duplicate_atomic_object (tmp_oba);
1216 tmp_obb = tmp_obb -> next;
1217 }
1218 g_free (this_proj -> modelgl -> atom_win -> to_be_inserted[0]);
1219 this_proj -> modelgl -> atom_win -> to_be_inserted[0] = NULL;
1220 }
1221 gboolean doit;
1222 asearch -> in_selection = 0;
1223 tmp_oba = object;
1224 for (i=0; i<num_elem; i++)
1225 {
1226 if (random_todo[i])
1227 {
1228 max_num = 0;
1229 switch (filter)
1230 {
1231 case 0:
1232 max_num = this_proj -> chemistry -> nsps[i];
1233 break;
1234 case 1:
1235 for (j=0; j<this_proj -> natomes; j++)
1236 {
1237 if (this_proj -> atoms[0][j].numv == i) max_num ++;
1238 }
1239 break;
1240 case 2:
1241 j = 0;
1242 for (k=0; k<this_proj -> nspec; k++)
1243 {
1244 j += this_proj -> coord -> ntg[1][k];
1245 if (j > i) break;
1246 }
1247 l = 0;
1248 for (m=0; m<k; m++) l += this_proj -> coord -> ntg[1][m];
1249 p = i - l;
1250 for (l=0; l<this_proj -> natomes; l++)
1251 {
1252 if (this_proj -> atoms[0][l].sp == k && this_proj -> atoms[0][l].coord[1] == p) max_num ++;
1253 }
1254 break;
1255 case 3:
1256 if (obj)
1257 {
1258 max_num = this_proj -> coord -> totcoord[2];
1259 }
1260 else
1261 {
1262 for (l=0; l<this_proj -> natomes; l++)
1263 {
1264 if (this_proj -> atoms[0][l].coord[2] == i) max_num ++;
1265 }
1266 }
1267 break;
1268 case 4:
1269 molfc = & this_proj -> modelfc -> mols[0][i];
1270 if (obj)
1271 {
1272 max_num = molfc -> multiplicity;
1273 }
1274 else
1275 {
1276 max_num = molfc -> natoms*molfc -> multiplicity;
1277 }
1278 break;
1279 }
1280 test = 1.0 / max_num;
1281 j = 0;
1282 // Using CPU time to randomize
1283 clock_t begin = clock();
1284 k = (int)begin;
1285 while (j < random_todo[i])
1286 {
1287 l = 0;
1288 for (m=0; m<total_num; m++)
1289 {
1290 if (! asearch -> todo[m])
1291 {
1292 doit = FALSE;
1293 if (filter < 3 || ! obj)
1294 {
1295 n = this_proj -> atoms[0][m].sp;
1296 if (this_proj -> atoms[0][m].pick[0] == asearch -> status || asearch -> status == 2)
1297 {
1298 switch (filter)
1299 {
1300 case 0:
1301 if (n == i) doit = TRUE;
1302 break;
1303 case 1:
1304 if (this_proj -> atoms[0][m].numv == i) doit = TRUE;
1305 break;
1306 case 2:
1307 o = this_proj -> atoms[0][m].coord[1];
1308 for (q=0;q<n;q++) o += this_proj -> coord -> ntg[1][q];
1309 if (o == i) doit = TRUE;
1310 break;
1311 default:
1312 if (this_proj -> atoms[0][m].coord[filter-1] == i) doit = TRUE;
1313 break;
1314 }
1315 }
1316 }
1317 else if (filter == 3)
1318 {
1319 doit = TRUE;
1320 }
1321 else
1322 {
1323 for (n=0; n<molfc -> multiplicity; n++)
1324 {
1325 if (molfc -> fragments[n] == m)
1326 {
1327 doit = TRUE;
1328 break;
1329 }
1330 }
1331 }
1332 if (doit)
1333 {
1334 l ++;
1335 o = (o+1)*max_num*m;
1336 prob = random3_(& n);
1337 if (prob >= (l-1)*test && prob < l*test)
1338 {
1339 j ++;
1340 asearch -> todo[m] = 1;
1341 if (asearch -> action == REPLACE)
1342 {
1343 if (this_proj -> modelgl -> atom_win -> to_be_inserted[0] == NULL)
1344 {
1345 this_proj -> modelgl -> atom_win -> to_be_inserted[0] = duplicate_atomic_object (tmp_oba);
1346 tmp_obb = this_proj -> modelgl -> atom_win -> to_be_inserted[0];
1347 }
1348 else
1349 {
1350 tmp_obb -> next = duplicate_atomic_object (tmp_oba);
1351 tmp_obb -> next -> prev = tmp_obb;
1352 tmp_obb = tmp_obb -> next;
1353 }
1354 tmp_obb -> id = m;
1355 }
1356 asearch -> in_selection ++;
1357 if (j == random_todo[i]) break;
1358 }
1359 }
1360 }
1361 }
1362 }
1363 if (asearch -> action == REPLACE)
1364 {
1365 if (tmp_oba -> next != NULL) tmp_oba = tmp_oba -> next;
1366 }
1367 }
1368 }
1369 if (asearch -> action == REPLACE) g_free (object);
1370 if (random_todo) g_free (random_todo);
1371 int old_filter = asearch -> filter;
1372 // if (asearch -> mode && obj && asearch -> filter == 3) asearch -> filter = 2;
1373 apply_action (this_proj, asearch);
1374 asearch -> filter = old_filter;
1375 }
1376}
1377
1387gboolean do_we_have_objects_in_selection (project * this_proj, atom_search * asearch, gboolean editing)
1388{
1389 int i, j, k, l, m, n, o, p, q;
1390 gboolean taking_action = FALSE;
1391 if (asearch -> action == INSERT)
1392 {
1393 taking_action = TRUE;
1394 }
1395 else
1396 {
1397 i = j = 0;
1398 if (asearch -> mode)
1399 {
1400 for (l=0; l<asearch -> todo_size; l++)
1401 {
1402 if (asearch -> todo[l]) i++;
1403 if (asearch -> action == REPLACE)
1404 {
1405 if (get_atomic_object_by_origin (this_proj -> modelgl -> atom_win -> to_be_inserted[0], -(l+3), 0))
1406 {
1407 if (asearch -> todo[l]) j ++;
1408 }
1409 }
1410 else
1411 {
1412 if (asearch -> pick[l] && asearch -> todo[l]) j ++;
1413 }
1414 }
1415 if (asearch -> action == REMOVE && i == j)
1416 {
1417 taking_action = TRUE;
1418 }
1419 else if (asearch -> action == REPLACE && i == j && i == asearch -> in_selection)
1420 {
1421 taking_action = TRUE;
1422 }
1423 }
1424 else
1425 {
1426 m = (asearch -> pointer[0].c == 3) ? 0 : (asearch -> pointer[0].c == 5) ? 1 : 3;
1427 int filter = get_asearch_filter (asearch);
1428 int object = get_asearch_object (asearch);
1429 int pass_size;
1430 int * pass_todo = NULL;
1431 atomic_object * passivating_object = NULL;
1432 atomic_object * pao = NULL;
1433 atomic_object * pio = NULL;
1434 float * tmp_msd = NULL;
1435 if (asearch -> passivating)
1436 {
1437 if (object > 1 && filter > 2)
1438 {
1439 pass_size = this_proj -> coord -> totcoord[filter - 1];
1440 }
1441 else
1442 {
1443 pass_size = this_proj -> natomes;
1444 }
1445 pass_todo = allocint (pass_size);
1446 if (asearch -> action == RANMOVE) tmp_msd = allocfloat (this_proj -> natomes);
1447 }
1448 switch (asearch -> action)
1449 {
1450 case DISPL:
1451 for (l=0; l<asearch -> todo_size; l++)
1452 {
1453 if (asearch -> todo[l]) i ++;
1454 if (editing)
1455 {
1456 if (asearch -> todo[l])
1457 {
1458 if (asearch -> passivating)
1459 {
1460 if (object < 2)
1461 {
1462 switch (filter)
1463 {
1464 case 0:
1465 for (n=0; n<this_proj -> natomes; n++)
1466 {
1467 if (this_proj -> atoms[0][n].sp == l)
1468 {
1469 pass_todo[n] = asearch -> todo[l];
1470 k ++;
1471 }
1472 }
1473 break;
1474 case 1:
1475 for (n=0; n<this_proj -> natomes; n++)
1476 {
1477 if (this_proj -> atoms[0][n].numv == l)
1478 {
1479 pass_todo[n] = asearch -> todo[l];
1480 k ++;
1481 }
1482 }
1483 break;
1484 case 2:
1485 for (n=0; n<this_proj -> natomes; n++)
1486 {
1487 o = this_proj -> atoms[0][n].coord[filter - 1];
1488 p = this_proj -> atoms[0][n].sp;
1489 for (q=0; q<p; q++) o += this_proj -> coord -> ntg[1][q];
1490 if (o == l)
1491 {
1492 pass_todo[n] = asearch -> todo[l];
1493 k ++;
1494 }
1495 }
1496 break;
1497 default:
1498 for (n=0; n<this_proj -> natomes; n++)
1499 {
1500 o = this_proj -> atoms[0][n].coord[filter - 1];
1501 if (o == l)
1502 {
1503 pass_todo[n] = asearch -> todo[l];
1504 k ++;
1505 }
1506 }
1507 break;
1508 }
1509 }
1510 else
1511 {
1512 switch (filter)
1513 {
1514 case 1:
1515 for (n=0; n<this_proj -> natomes; n++)
1516 {
1517 if (this_proj -> atoms[0][n].numv == l)
1518 {
1519 pass_todo[n] = asearch -> todo[l];
1520 k ++;
1521 if (! passivating_object)
1522 {
1523 passivating_object = create_object_from_atom_coordination (this_proj, filter-1, n, NULL);
1524 pao = passivating_object;
1525 }
1526 else
1527 {
1528 pao -> next = create_object_from_atom_coordination (this_proj, filter-1, n, NULL);
1529 pao -> next -> prev = pao;
1530 pao = pao -> next;
1531 }
1532 }
1533 }
1534 break;
1535 case 2:
1536 for (n=0; n<this_proj -> natomes; n++)
1537 {
1538 o = this_proj -> atoms[0][n].coord[filter - 1];
1539 p = this_proj -> atoms[0][n].sp;
1540 for (q=0; q<p; q++) o += this_proj -> coord -> ntg[1][q];
1541 if (o == l)
1542 {
1543 pass_todo[n] = asearch -> todo[l];
1544 k ++;
1545 if (! passivating_object)
1546 {
1547 passivating_object = create_object_from_atom_coordination (this_proj, filter-1, n, NULL);
1548 pao = passivating_object;
1549 }
1550 else
1551 {
1552 pao -> next = create_object_from_atom_coordination (this_proj, filter-1, n, NULL);
1553 pao -> next -> prev = pao;
1554 pao = pao -> next;
1555 }
1556 }
1557 }
1558 break;
1559 default:
1560 for (n=0; n<this_proj -> coord -> totcoord[filter -1]; n++)
1561 {
1562 if (n == l)
1563 {
1564 pass_todo[n] = asearch -> todo[l];
1565 k ++;
1566 if (! passivating_object)
1567 {
1568 passivating_object = create_object_from_frag_mol (this_proj, filter-1, n, NULL);
1569 pao = passivating_object;
1570 }
1571 else
1572 {
1573 pao -> next = create_object_from_frag_mol (this_proj, filter-1, n, NULL);
1574 pao -> next -> prev = pao;
1575 pao = pao -> next;
1576 }
1577 }
1578 }
1579 break;
1580 }
1581 }
1582 }
1583 }
1584 }
1585 }
1586 break;
1587 case REPLACE:
1588 for (l=0; l<asearch -> todo_size; l++)
1589 {
1590 if (asearch -> todo[l]) i ++;
1591 pio = get_atomic_object_by_origin (this_proj -> modelgl -> atom_win -> to_be_inserted[m], l, 0);
1592 if (pio)
1593 {
1594 if (asearch -> todo[l])
1595 {
1596 j ++;
1597 if (asearch -> passivating)
1598 {
1599 switch (filter)
1600 {
1601 case 0:
1602 for (n=0; n<this_proj -> natomes; n++)
1603 {
1604 if (this_proj -> atoms[0][n].sp == l)
1605 {
1606 pass_todo[n] = asearch -> todo[l];
1607 if (! passivating_object)
1608 {
1609 passivating_object = duplicate_atomic_object (pio);
1610 pao = passivating_object;
1611 pao -> id = n;
1612 }
1613 else
1614 {
1615 pao -> next = duplicate_atomic_object (pio);
1616 pao -> id = n;
1617 pao -> next -> prev = pao;
1618 pao = pao -> next;
1619 }
1620 k ++;
1621 }
1622 }
1623 break;
1624 case 1:
1625 for (n=0; n<this_proj -> natomes; n++)
1626 {
1627 if (this_proj -> atoms[0][n].numv == l)
1628 {
1629 pass_todo[n] = asearch -> todo[l];
1630 if (! passivating_object)
1631 {
1632 passivating_object = duplicate_atomic_object (pio);
1633 pao = passivating_object;
1634 pao -> id = n;
1635 }
1636 else
1637 {
1638 pao -> next = duplicate_atomic_object (pio);
1639 pao -> id = n;
1640 pao -> next -> prev = pao;
1641 pao = pao -> next;
1642 }
1643 k ++;
1644 }
1645 }
1646 break;
1647 case 2:
1648 for (n=0; n<this_proj -> natomes; n++)
1649 {
1650 o = this_proj -> atoms[0][n].coord[filter - 1];
1651 p = this_proj -> atoms[0][n].sp;
1652 for (q=0; q<p; q++) o += this_proj -> coord -> ntg[1][q];
1653 if (o == l)
1654 {
1655 pass_todo[n] = asearch -> todo[l];
1656 if (! passivating_object)
1657 {
1658 passivating_object = duplicate_atomic_object (pio);
1659 pao = passivating_object;
1660 pao -> id = n;
1661 }
1662 else
1663 {
1664 pao -> next = duplicate_atomic_object (pio);
1665 pao -> id = n;
1666 pao -> next -> prev = pao;
1667 pao = pao -> next;
1668 }
1669 k ++;
1670 }
1671 }
1672 default:
1673 if (object < 2)
1674 {
1675 for (n=0; n<this_proj -> natomes; n++)
1676 {
1677 o = this_proj -> atoms[0][n].coord[filter - 1];
1678 if (o == l)
1679 {
1680 pass_todo[n] = asearch -> todo[l];
1681 if (! passivating_object)
1682 {
1683 passivating_object = duplicate_atomic_object (pio);
1684 pao = passivating_object;
1685 pao -> id = n;
1686 }
1687 else
1688 {
1689 pao -> next = duplicate_atomic_object (pio);
1690 pao -> id = n;
1691 pao -> next -> prev = pao;
1692 pao = pao -> next;
1693 }
1694 k ++;
1695 }
1696 }
1697 }
1698 else
1699 {
1700 pass_todo[l] = asearch -> todo[l];
1701 if (! passivating_object)
1702 {
1703 passivating_object = duplicate_atomic_object (pio);
1704 pao = passivating_object;
1705 pao -> id = l;
1706 }
1707 else
1708 {
1709 pao -> next = duplicate_atomic_object (pio);
1710 pao -> id = l;
1711 pao -> next -> prev = pao;
1712 pao = pao -> next;
1713 }
1714 k ++;
1715 }
1716 break;
1717 }
1718 }
1719 }
1720 }
1721 }
1722 break;
1723 case REMOVE:
1724 for (l=0; l<asearch -> todo_size; l++)
1725 {
1726 if (asearch -> todo[l])
1727 {
1728 i ++;
1729 if (asearch -> passivating)
1730 {
1731 switch (filter)
1732 {
1733 case 0:
1734 for (n=0; n<this_proj -> natomes; n++)
1735 {
1736 if (this_proj -> atoms[0][n].sp == l)
1737 {
1738 pass_todo[n] = 1;
1739 k ++;
1740 }
1741 }
1742 break;
1743 case 1:
1744 for (n=0; n<this_proj -> natomes; n++)
1745 {
1746 if (this_proj -> atoms[0][n].numv == l)
1747 {
1748 pass_todo[n] = 1;
1749 k ++;
1750 }
1751 }
1752 break;
1753 case 2:
1754 for (n=0; n<this_proj -> natomes; n++)
1755 {
1756 o = this_proj -> atoms[0][n].coord[filter - 1];
1757 p = this_proj -> atoms[0][n].sp;
1758 for (q=0; q<p; q++) o += this_proj -> coord -> ntg[1][q];
1759 if (o == l)
1760 {
1761 pass_todo[n] = 1;
1762 k ++;
1763 }
1764 }
1765 default:
1766 if (object < 2)
1767 {
1768 for (n=0; n<this_proj -> natomes; n++)
1769 {
1770 o = this_proj -> atoms[0][n].coord[filter - 1];
1771 if (o == l)
1772 {
1773 pass_todo[n] = 1;
1774 k ++;
1775 }
1776 }
1777 }
1778 else
1779 {
1780 pass_todo[l] = 1;
1781 k ++;
1782 }
1783 break;
1784 }
1785 }
1786 }
1787 }
1788 break;
1789 case RANMOVE:
1790 for (l=0; l<asearch -> todo_size; l++)
1791 {
1792 if (asearch -> passivating)
1793 {
1794 if (asearch -> todo[l] && this_proj -> modelgl -> atom_win -> msd_all[l] > 0.0)
1795 {
1796 i ++;
1797 if (object < 2)
1798 {
1799 switch (filter)
1800 {
1801 case 0:
1802 for (n=0; n<this_proj -> natomes; n++)
1803 {
1804 if (this_proj -> atoms[0][n].sp == l)
1805 {
1806 pass_todo[n] = asearch -> todo[l];
1807 tmp_msd[n] = this_proj -> modelgl -> atom_win -> msd_all[l];
1808 k ++;
1809 }
1810 }
1811 break;
1812 case 1:
1813 for (n=0; n<this_proj -> natomes; n++)
1814 {
1815 if (this_proj -> atoms[0][n].numv == l)
1816 {
1817 pass_todo[n] = asearch -> todo[l];
1818 tmp_msd[n] = this_proj -> modelgl -> atom_win -> msd_all[l];
1819 k ++;
1820 }
1821 }
1822 break;
1823 case 2:
1824 for (n=0; n<this_proj -> natomes; n++)
1825 {
1826 o = this_proj -> atoms[0][n].coord[filter - 1];
1827 p = this_proj -> atoms[0][n].sp;
1828 for (q=0; q<p; q++) o += this_proj -> coord -> ntg[1][q];
1829 if (o == l)
1830 {
1831 pass_todo[n] = asearch -> todo[l];
1832 tmp_msd[n] = this_proj -> modelgl -> atom_win -> msd_all[l];
1833 k ++;
1834 }
1835 }
1836 break;
1837 default:
1838 for (n=0; n<this_proj -> natomes; n++)
1839 {
1840 o = this_proj -> atoms[0][n].coord[filter - 1];
1841 if (o == l)
1842 {
1843 pass_todo[n] = asearch -> todo[l];
1844 tmp_msd[n] = this_proj -> modelgl -> atom_win -> msd_all[l];
1845 k ++;
1846 }
1847 }
1848 break;
1849 }
1850 }
1851 else
1852 {
1853 switch (filter)
1854 {
1855 case 1:
1856 for (n=0; n<this_proj -> natomes; n++)
1857 {
1858 if (this_proj -> atoms[0][n].numv == l)
1859 {
1860 pass_todo[n] = asearch -> todo[l];
1861 tmp_msd[n] = this_proj -> modelgl -> atom_win -> msd_all[l];
1862 if (! passivating_object)
1863 {
1864 passivating_object = create_object_from_atom_coordination (this_proj, filter-1, n, NULL);
1865 pao = passivating_object;
1866 }
1867 else
1868 {
1869 pao -> next = create_object_from_atom_coordination (this_proj, filter-1, n, NULL);
1870 pao -> next -> prev = pao;
1871 pao = pao -> next;
1872 }
1873 k ++;
1874 }
1875 }
1876 break;
1877 case 2:
1878 for (n=0; n<this_proj -> natomes; n++)
1879 {
1880 o = this_proj -> atoms[0][n].coord[filter - 1];
1881 p = this_proj -> atoms[0][n].sp;
1882 for (q=0; q<p; q++) o += this_proj -> coord -> ntg[1][q];
1883 if (o == l)
1884 {
1885 pass_todo[n] = asearch -> todo[l];
1886 tmp_msd[n] = this_proj -> modelgl -> atom_win -> msd_all[l];
1887 if (! passivating_object)
1888 {
1889 passivating_object = create_object_from_atom_coordination (this_proj, filter-1, n, NULL);
1890 pao = passivating_object;
1891 }
1892 else
1893 {
1894 pao -> next = create_object_from_atom_coordination (this_proj, filter-1, n, NULL);
1895 pao -> next -> prev = pao;
1896 pao = pao -> next;
1897 }
1898 k ++;
1899 }
1900 }
1901 break;
1902 default:
1903 for (n=0; n<this_proj -> coord -> totcoord[filter -1]; n++)
1904 {
1905 if (n == l)
1906 {
1907 pass_todo[n] = asearch -> todo[l];
1908 k ++;
1909 tmp_msd[n] = this_proj -> modelgl -> atom_win -> msd_all[l];
1910 if (! passivating_object)
1911 {
1912 passivating_object = create_object_from_frag_mol (this_proj, filter-1, n, NULL);
1913 pao = passivating_object;
1914 }
1915 else
1916 {
1917 pao -> next = create_object_from_frag_mol (this_proj, filter-1, n, NULL);
1918 pao -> next -> prev = pao;
1919 pao = pao -> next;
1920 }
1921 }
1922 }
1923 break;
1924 }
1925 }
1926 }
1927 }
1928 else if (object && filter > 2)
1929 {
1930 if (asearch -> todo[l] && this_proj -> modelgl -> atom_win -> msd_all[l] > 0.0) i ++;
1931 }
1932 else
1933 {
1934 if (asearch -> todo[l] && this_proj -> modelgl -> atom_win -> msd[l] > 0.0) i ++;
1935 }
1936 }
1937 break;
1938 }
1939 if (asearch -> action == REMOVE && i)
1940 {
1941 taking_action = TRUE;
1942 }
1943 else if (asearch -> action == REPLACE)
1944 {
1945 if (asearch -> in_selection == i && i == j) taking_action = TRUE;
1946 }
1947 else
1948 {
1949 asearch -> in_selection = i;
1950 if (i) taking_action = TRUE;
1951 }
1952 if (asearch -> passivating && taking_action && editing)
1953 {
1954 g_free (asearch -> todo);
1955 asearch -> todo = duplicate_int (pass_size, pass_todo);
1956 g_free (pass_todo);
1957 asearch -> todo_size = pass_size;
1958 asearch -> in_selection = k;
1959 switch (asearch -> action)
1960 {
1961 case DISPL:
1962 this_proj -> modelgl -> atom_win -> to_be_moved[0] = passivating_object;
1963 break;
1964 case REPLACE:
1965 this_proj -> modelgl -> atom_win -> to_be_inserted[m] = passivating_object;
1966 break;
1967 case RANMOVE:
1968 if (this_proj -> modelgl -> atom_win -> msd) g_free (this_proj -> modelgl -> atom_win -> msd);
1969 this_proj -> modelgl -> atom_win -> msd = duplicate_float (this_proj -> natomes, tmp_msd);
1970 g_free (tmp_msd);
1971 this_proj -> modelgl -> atom_win -> to_be_moved[1] = passivating_object;
1972 break;
1973
1974 }
1975 }
1976 }
1977 }
1978 return taking_action;
1979}
1980
1989{
1990 atom_search * bsearch = g_malloc0(sizeof*bsearch);
1991 bsearch -> search_digit = asearch -> search_digit;
1992 bsearch -> proj = asearch -> proj;
1993 bsearch -> action = asearch -> action;
1994 bsearch -> status = asearch -> status;
1995 bsearch -> mode = asearch -> mode;
1996 bsearch -> object = asearch -> object;
1997 bsearch -> filter = asearch -> filter;
1998 bsearch -> search_digit = asearch -> search_digit;
1999 bsearch -> spec_to_add = asearch -> spec_to_add;
2000 bsearch -> num_to_add = asearch -> num_to_add;
2001 bsearch -> in_selection = asearch -> in_selection;
2002 bsearch -> passivating = asearch -> passivating;
2003 bsearch -> was_selected = asearch -> was_selected;
2004 bsearch -> recompute_bonding = asearch -> recompute_bonding;
2005 bsearch -> set_for_all = asearch -> set_for_all;
2006 bsearch -> int_b = asearch -> int_b;
2007 int i = get_asearch_num_objects (asearch);
2008 bsearch -> lab = duplicate_int (i, asearch -> lab);
2009 bsearch -> pick = duplicate_int (i, asearch -> lab);
2010 bsearch -> todo_size = asearch -> todo_size;
2011 bsearch -> todo = duplicate_int (bsearch -> todo_size, asearch -> todo);
2012 for (i=0; i<6; i++)
2013 {
2014 bsearch -> pointer[i].a = asearch -> pointer[i].a;
2015 bsearch -> pointer[i].b = asearch -> pointer[i].b;
2016 bsearch -> pointer[i].c = asearch -> pointer[i].c;
2017 }
2018 return bsearch;
2019}
2020
2029G_MODULE_EXPORT void take_action (GtkButton * but, gpointer data)
2030{
2031 tint * id = (tint *)data;
2032 project * this_proj = get_project_by_id (id -> a);
2033 int i;
2034 i = id -> c;
2035 atom_search * this_search = duplicate_atom_search (this_proj -> modelgl -> search_widg[i]);
2036 if (do_we_have_objects_in_selection(this_proj, this_search, TRUE))
2037 {
2038 if (i != RANMOVE)
2039 {
2040 if (this_search -> mode)
2041 {
2042 prepare_random_action (this_proj, this_search);
2043 }
2044 else
2045 {
2046 apply_action (this_proj, this_search);
2047 }
2048 }
2049 else
2050 {
2051 random_move (this_proj, this_search);
2052 clean_all_trees (this_search, this_proj);
2053 }
2054 if (this_proj -> modelgl -> atom_win -> visible)
2055 {
2056 for (i=0; i<5; i++) widget_set_sensitive (gtk_notebook_get_nth_page(GTK_NOTEBOOK (this_proj -> modelgl -> atom_win -> notebook), i), this_proj -> natomes);
2057 widget_set_sensitive (gtk_notebook_get_nth_page(GTK_NOTEBOOK (this_proj -> modelgl -> atom_win -> notebook), 3), 1);
2058 }
2059 }
2060 else
2061 {
2062 if (i < RANMOVE)
2063 {
2064 show_info (_("Nothing to be done, check selection !"), 0, this_proj -> modelgl -> atom_win -> win);
2065 }
2066 else
2067 {
2068 show_info (_("Nothing to be done, check selection and/or MSD !"), 0, this_proj -> modelgl -> atom_win -> win);
2069 }
2070 }
2071}
int action_atoms_from_project(project *this_proj, atom_search *asearch, gboolean visible)
apply atom edition action to project (motion, remove, replace, insert, random move)
void setup_default_lights(project *this_proj, image *img)
initialize lightning for an image data structure
Definition glview.c:1313
atom_search * duplicate_atom_search(atom_search *asearch)
duplicate atom search data structure
void free_dummies(dummy_atom *tmp_pick)
free atom dummy list
Definition atom_action.c:65
void apply_action(project *this_proj, atom_search *asearch)
apply edition action
gboolean do_we_have_objects_in_selection(project *this_proj, atom_search *asearch, gboolean editing)
check for object(s) in selection to apply action
void prepare_random_action(project *this_proj, atom_search *asearch)
prepare random action
void clean_motion_search(project *this_proj, atom_search *asearch, int sid)
clean atom search motion data
void clean_this_project(project *this_proj)
clean project data for the edition process
Definition atom_action.c:90
void clean_all_trees(atom_search *asearch, project *this_proj)
clean all tree models in the 'model edition' window
G_MODULE_EXPORT void take_action(GtkButton *but, gpointer data)
take edition action
GLdouble get_max_depth(GLdouble depth)
guess a reasonable maximum OpenGL window depth
Definition glview.c:1153
void print_coord_info(project *this_proj, coord_info *coord)
print coordination info
Definition atom_coord.c:87
coord_info * duplicate_coord_info(coord_info *old_coord)
duplicate coordination information data structure
Definition atom_coord.c:190
void recover_opengl_data(project *this_proj, int nmols, int add, int rem, int *num, int *rec, int ***tmpgeo, gboolean *showfrag)
recover image pointer data and OpenGL window menu structure
Definition atom_coord.c:549
gboolean was_moved
Definition atom_edit.c:62
void clean_other_window_after_edit(project *this_proj)
update other windows after model edition if required
Definition atom_edit.c:110
Function declarations for the mode edition window.
chemical_data * duplicate_chemical_data(int spec, chemical_data *chem)
duplicate chemical data information
atomic_object * create_object_from_frag_mol(project *this_proj, int coord, int geo, atom_search *remove)
create object from a fragment or a molecule
double ** save_coordinates(project *this_proj, int status)
save atomic coordinates
Definition atom_move.c:91
void motion_to_zero(atom_search *asearch)
reset motion to 0.0
Definition w_search.c:493
int get_asearch_object(atom_search *asearch)
get the number of object(s) in this atom search
Definition w_search.c:149
atom_search * remove_search
Definition popup.c:174
void add_bonds_to_list(int **new_bond_list, int nat, int nbd, atomic_object *object)
add object bond(s) list to overall bond(s) list
Definition atom_insert.c:81
int find_this_geo_id(int id, coord_info *obj, int *old_z, int old_geo, int old_sp, int new_sp, coord_info *coord, double *new_z)
if required create a new geometry, stored in coord, for coordination type 'gid' and chemical species ...
Definition atom_geo.c:209
int find_spec_id(int s, int z, double *list_z)
find species id based on Z
int search_for_new_spec(atom_edition *edit, atomic_object *object)
search for new chemical species
void add_bonds_to_project(project *this_proj, int removed, int nbd, int **new_bond_list)
add bond list to project bond list
Definition atom_insert.c:53
void init_coordinates(project *this_proj, int status, gboolean win, gboolean init)
preserve atomic coordinates
Definition atom_move.c:197
void random_move(project *this_proj, atom_search *asearch)
random move
Definition atom_move.c:657
chemical_data * alloc_chem_data(int spec)
allocate chemistry data
Definition open_p.c:203
void update_search_tree(atom_search *asearch)
update search tree
Definition w_search.c:1287
int is_selected
Definition popup.c:181
int get_asearch_num_objects(atom_search *asearch)
the number of type of object(s) in this atom search
Definition w_search.c:125
void free_glwin_spec_data(project *this_proj, int spec)
free the memory used by the chemical species related data in a glwin data structure
Definition glview.c:1602
void glwin_init_spec_data(project *this_proj, int nspec)
initialize the glwin chemical species related pointers
Definition glview.c:1647
void re_populate_tree_search(atom_search *asearch)
re populate search tree after atom action if >= 10 000 atoms
Definition w_search.c:1601
int get_asearch_filter(atom_search *asearch)
get asearch filter
Definition w_search.c:170
void prepare_opengl_menu_bar(glwin *view)
update the OpenGL window menu bar
Definition glwindow.c:611
void to_remove_this_list_of_objects(project *this_proj, atom_search *asearch)
prepaer to remove a list of object(s) from a project, one object after another.
atomic_object * create_object_from_atom_coordination(project *this_proj, int coord, int aid, atom_search *remove)
create object from an atom and its nearest neighbors
gboolean * remove_bonds_from_project(project *this_proj, atomic_object *this_object, int *old_id, atom *new_list, gboolean remove, gboolean passivate)
remove bond(s) from project
void clean_picked_and_labelled(atom_search *asearch, gboolean clean_msd)
initialize atom search data buffers
Definition w_search.c:3779
atomic_object * duplicate_atomic_object(atomic_object *old_obj)
duplicate an insert object
vec3_t get_bary(project *this_proj, int status)
get barycenter of atomic coordinates
Definition atom_move.c:170
void check_coord_modification(project *this_proj, int old_id[], atom *new_list, atomic_object *this_object, gboolean movtion, gboolean passivating)
void allocate_todo(atom_search *asearch, int tsize)
allocate the selection list data buffer
Definition w_search.c:3705
void center_molecule(project *this_proj)
center atomic coordinates around (0,0,0)
Definition glview.c:1500
atomic_object * get_atomic_object_by_origin(atomic_object *first, int oid, int aid)
get insert object from a list by id
Definition w_search.c:474
void clean_coord_window(project *this_proj)
update the environment configuration window after edtion
Definition atom_edit.c:87
G_MODULE_EXPORT void set_filter_changed(GtkComboBox *box, gpointer data)
change the search filter
Definition w_search.c:3846
G_MODULE_EXPORT void set_color_map(GtkWidget *widg, gpointer data)
set color map callback
Definition m_map.c:1011
Binding to the Fortran90 subroutines.
double random3_(int *)
double set_radius_(int *, int *)
int chemistry_()
double set_neutron_(int *)
double set_mass_(int *)
integer(kind=c_int) function bonding(scf, sbf, adv, bdist, bmin, delt_ij, sfil)
Definition bonds.F90:22
int selected_aspec
Definition popup.c:179
GtkFileFilter * filter[NCFORMATS+1]
Definition callbacks.c:1557
integer function chains()
Definition chains.F90:54
integer(kind=c_int) function chemistry()
Definition chemistry.F90:22
color colorp[64]
gchar * param[2]
void erase_curves(project *this_proj, int c)
free all curve(s) data
Definition curve.c:552
void hide_curves(project *this_proj, int c)
for project hide all curves for a calculation
Definition curve.c:472
Variable declarations for the curve widget Functions for interactions with the curve widget.
void process_selected_atom(project *this_proj, glwin *view, int id, int ac, int se, int pi)
process selected atom
Definition selection.c:514
int atoms[NUM_STYLES][2]
int bonds[NUM_STYLES][2]
int * duplicate_int(int num, int *old_val)
copy a list of int
Definition global.c:547
float * duplicate_float(int num, float *old_val)
copy a list of float
Definition global.c:579
gboolean test_vol(double box[2][3], double vect[3][3])
is the cell properly described to use PBC ?
Definition edit_menu.c:488
int ** allocdint(int xal, int yal)
allocate an int ** pointer
Definition global.c:317
int mol_update
Definition global.c:175
double * duplicate_double(int num, double *old_val)
copy a list of double
Definition global.c:595
int activep
Definition global.c:162
gboolean * allocbool(int val)
allocate a gboolean * pointer
Definition global.c:241
int frag_update
Definition global.c:174
double * allocdouble(int val)
allocate a double * pointer
Definition global.c:446
int bonds_update
Definition global.c:173
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
#define GTK_LIMIT
maximum number of elements in GTK widgets like GtkTreeView, GtkTreeStore or similar rendering widgets...
Definition global.h:77
void update_chains_menus(glwin *view)
#define ATOM_LIMIT
atom number limit to compute fragment(s) and molecule(s) analysis automatically
element_data periodic_table_info[]
Definition w_library.c:71
project * proj
void combo_set_active(GtkWidget *combo, int pos)
set the active item's position
Definition gtk-misc.c:958
#define CHEM_N
Definition global.h:319
void clean_rings_data(int rid, glwin *view)
clean a ring type data for a glview
Definition ringscall.c:361
void opengl_project_changed(int id)
change the OpenGL project
Definition update_p.c:296
#define STEP_LIMIT
Definition global.h:293
G_MODULE_EXPORT void on_calc_bonds_released(GtkWidget *widg, gpointer data)
compute bonding properties
Definition bdcall.c:559
#define CHEM_PARAMS
Definition global.h:315
#define CHEM_R
Definition global.h:318
box_info * active_box
Definition project.c:51
G_MODULE_EXPORT void label_unlabel_atoms(GtkWidget *widg, gpointer data)
label / unlabel a type of atom(s) callback GTK3
Definition popup.c:1522
void clean_chains_data(glwin *view)
cleaning the OpenGL data related to chain statistics
Definition chainscall.c:263
project * opengl_project
Definition project.c:54
void widget_set_sensitive(GtkWidget *widg, gboolean sensitive)
Set sensitivity for a GtkWidget, ensuring it is a GtkWidget.
Definition gtk-misc.c:247
#define CHEM_M
Definition global.h:317
G_MODULE_EXPORT void select_unselect_atoms(GtkWidget *widg, gpointer data)
select / unselect a type of atom(s) callback GTK3
Definition popup.c:1570
void clean_volumes_data(glwin *view)
clean volume data
Definition w_volumes.c:83
#define CHEM_X
Definition global.h:320
#define CHEM_Z
Definition global.h:316
#define GDK
Definition global.h:340
project * active_project
Definition project.c:47
void initcutoffs(chemical_data *chem, int species)
initialize bond cutoffs
Definition bdcall.c:245
void update_rings_menus(glwin *view)
#define NCALCS
#define GDR
Definition global.h:337
project * get_project_by_id(int p)
get project pointer using id number
Definition project.c:120
void update(glwin *view)
update the rendering of the OpenGL window
Definition glview.c:461
void sort(int dim, int *tab)
sort, nim to max, a table by integer value
Definition glview.c:402
void re_create_md_shaders(int nshaders, int shaders[nshaders], project *this_proj)
re-initialize some MD dependent OpenGL shaders
action
Definition glview.h:198
gboolean pick
atom * duplicate_atom(atom *at)
copy (partially) an atom data structure
Definition ogl_draw.c:449
void update_all_selections(glwin *view, int pi)
update the selection data: bonds, angles and dihedrals
Definition selection.c:387
void save_all_selections(glwin *view, int pi)
save all selection data
Definition selection.c:372
@ DISPL
Definition glview.h:234
@ RANMOVE
Definition glview.h:238
@ REPLACE
Definition glview.h:235
@ REMOVE
Definition glview.h:236
@ INSERT
Definition glview.h:237
#define OGL_COORDS
Definition glwin.h:63
#define OGL_RINGS
Definition glwin.h:64
shaders
The different types of shaders in the atomes program.
Definition glwin.h:88
@ BONDS
Definition glwin.h:90
@ PICKS
Definition glwin.h:97
@ LABEL
Definition glwin.h:98
@ POLYS
Definition glwin.h:92
@ SELEC
Definition glwin.h:91
@ MDBOX
Definition glwin.h:93
@ MEASU
Definition glwin.h:99
@ ATOMS
Definition glwin.h:89
@ RINGS
Definition glwin.h:96
#define ATOM_MAPS
Definition glwin.h:61
#define NSELECTION
Definition glwin.h:67
void init_curves_and_calc(project *this_proj)
for a project reset analysis, curves, data to not performed
Definition init_p.c:69
void init_atomes_analysis(project *this_proj, gboolean apply_defaults)
initialize analysis data structures for atomes
Definition initc.c:223
void show_info(char *information, int val, GtkWidget *win)
add / show information message to widget
Definition interface.c:240
void prep_calc_actions()
prepare analysis widgets
Definition update_p.c:59
integer(kind=c_int) function msd(dlt, ndts)
Definition msd.F90:22
double z
Definition ogl_draw.c:63
double y
Definition ogl_draw.c:63
double x
Definition ogl_draw.c:63
axis default_axis
Preference variable declarations.
void active_project_changed(int id)
change the active project
Definition update_p.c:220
Definition global.h:964
Definition glwin.h:332
int numv
Definition global.h:841
Definition glwin.h:364
Definition global.h:118
int status
Definition w_advance.c:173
int element
Definition w_periodic.c:61
GtkWidget * img
Definition workspace.c:70
GtkWidget * lab
Definition workspace.c:73