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