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