atomes 1.1.17
atomes: an atomic scale modeling tool box
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
w_search.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
25/*
26* This file: 'w_search.c'
27*
28* Contains:
29*
30
31 - The functions to create the object search widgets, for:
32 - The atom(s) / clone(s) advanced window
33 - The model edition window (move, remove, replace, insert, random move)
34 - The crystal builder window
35
36*
37* List of functions:
38
39 int get_asearch_num_objects (atom_search * asearch);
40 int get_asearch_object (atom_search * asearch);
41 int get_asearch_filter (atom_search * asearch);
42 int get_selected_object_id (gboolean visible, int p, gchar * str, atom_search * asearch);
43 int get_todo_size (atom_search * asearch);
44
45 gboolean get_asearch_is_object (atom_search * asearch);
46 gboolean fill_for_action (atom_search * asearch, int i, int j, project * this_proj);
47 gboolean append (atom_search * asearch, project * this_proj, int i, int j);
48 gboolean update_this_search (atom_search * asearch);
49 gboolean remove_from_model (GtkTreeModel * model, GtkTreePath * path, GtkTreeIter * iter, gpointer data);
50 gboolean atom_is_in_model (GtkTreeModel * model, GtkTreePath * path, GtkTreeIter * iter, gpointer data);
51 gboolean update_search_model (GtkTreeModel * model, GtkTreePath * path, GtkTreeIter * iter, gpointer data);
52
53 gchar * adjust_picked (gchar * picked, atomic_object * object, gboolean init);
54 gchar * get_node_name (int node, atom_search * asearch, project * this_proj);
55
56 void check_tree_for_this_search (project * this_proj, atom_search * asearch);
57 void check_all_trees (project * this_proj);
58 void motion_to_zero (atom_search * asearch);
59 void adjust_object_to_move (project * this_proj, atom_search * asearch, int mv, int id);
60 void append_to_model (GtkTreeIter * atom_level, atom_search * asearch, gboolean is_object, int h, int i, project * this_proj);
61 void fill_atom_model (atom_search * asearch, project * this_proj);
62 void update_search_tree (atom_search * asearch);
63 void clear_fields (atom_search * asearch);
64 void re_populate_tree_search (atom_search * asearch);
65 void adjust_search_param (atom_search * asearch, project * this_proj, int a, int s, int c, gboolean status);
66 void adjust_this_tree_branch (atom_search * asearch, project * this_proj, int oid, int sid, GtkTreeIter iter);
67 void adjust_this_tree_leaf (atom_search * asearch, project * this_proj, int oid, int aid, int new_status, GtkTreeIter iter);
68 void adjust_data_model_to_replace (project * this_proj, atom_search * asearch, int sid, int vid);
69 void search_set_visible (GtkTreeViewColumn * col, GtkCellRenderer * renderer, GtkTreeModel * mod, GtkTreeIter * iter, gpointer data);
70 void get_coord_iter_and_edit (gchar * path_string, gpointer data, GtkWidget * widg);
71 void allocate_todo (atom_search * asearch, int tsize);
72 void clean_todo (atom_search * asearch);
73 void clean_picked_and_labelled (atom_search * asearch);
74 void add_random_column (atom_search * asearch);
75 void prep_search_box (GtkWidget * vbox, GtkWidget * lab, GtkWidget * combo);
76
77 G_MODULE_EXPORT void set_atom (GtkEntry * entry, gpointer data);
78 G_MODULE_EXPORT void remove_atom (GtkButton * but, gpointer data);
79 G_MODULE_EXPORT void add_atom (GtkButton * but, gpointer data);
80 G_MODULE_EXPORT void set_id (GtkEntry * entry, gpointer data);
81 G_MODULE_EXPORT void select_atom (GtkCellRendererToggle * cell_renderer, gchar * string_path, gpointer data);
82 G_MODULE_EXPORT void changed_action_renderer (GtkCellRendererCombo * combo, gchar * path_string, GtkTreeIter * iter, gpointer data);
83 G_MODULE_EXPORT void set_occupancy (GtkEntry * res, gpointer data);
84 G_MODULE_EXPORT void set_i_coord (GtkEntry * res, gpointer data);
85 G_MODULE_EXPORT void set_max_msd (GtkEntry * res, gpointer data);
86 G_MODULE_EXPORT void set_max_action (GtkEntry * res, gpointer data);
87 G_MODULE_EXPORT void set_max_msd_for_all (GtkEntry * res, gpointer data);
88 G_MODULE_EXPORT void to_edit_coords (GtkCellRenderer * cell, GtkCellEditable * editable, gchar * path_string, gpointer data);
89 G_MODULE_EXPORT void markup_action_renderer (GtkCellRendererCombo * cell, GtkCellEditable * editable, gchar * path_string, gpointer data);
90 G_MODULE_EXPORT void select_all_atoms (GtkTreeViewColumn * col, gpointer data);
91 G_MODULE_EXPORT void move_up_down (GtkTreeModel * tree_model, GtkTreePath * path, gpointer data);
92 G_MODULE_EXPORT void set_spec_changed (GtkComboBox * box, gpointer data);
93 G_MODULE_EXPORT void set_filter_changed (GtkComboBox * box, gpointer data);
94 G_MODULE_EXPORT void set_object_changed (GtkComboBox * box, gpointer data);
95 G_MODULE_EXPORT void set_search_mode (GtkComboBox * box, gpointer data);
96 G_MODULE_EXPORT void set_search_digit (GtkEntry * res, gpointer data);
97
98 GtkWidget * create_atoms_tree (atom_search * asearch, project * this_proj, int nats);
99 GtkWidget * prepare_box_too_much (atom_search * asearch);
100 GtkWidget * selection_tab (atom_search * asearch, int nats);
101
102 GtkTreeModel * replace_combo_tree (gboolean insert, int proj);
103
104 atomic_object * get_atomic_object_by_origin (atomic_object * first, int oid, int aid);
105
106*/
107
108#include "atom_edit.h"
109
110extern int check_label_numbers (project * this_proj, int types);
111extern int selected_aspec;
112extern int select_from_library (gboolean visible, project * this_proj, atom_search * asearch);
114extern void create_slab_lists (project * this_proj);
115extern int get_to_be_selected (glwin * view);
116extern void restore_ogl_selection (glwin * view);
117
126{
127 int filter = get_asearch_filter (asearch);
128 switch (filter)
129 {
130 case 0:
131 return get_project_by_id (asearch -> proj) -> nspec;
132 break;
133 case 1:
134 return get_project_by_id (asearch -> proj) -> coord -> cmax+1;
135 break;
136 default:
137 return get_project_by_id (asearch -> proj) -> coord -> totcoord[filter -1];
138 break;
139 }
140}
141
150{
151 if (asearch -> object < 0) return 0;
152 if (asearch -> mode) return asearch -> object;
153 if (get_project_by_id(asearch -> proj) -> natomes >= 10000)
154 {
155 return (asearch -> object > 1) ? 2 : asearch -> object;
156 }
157 else
158 {
159 return asearch -> object;
160 }
161}
162
171{
172 if (asearch -> object < 0 || asearch -> filter < 0) return 0;
173 if (asearch -> mode)
174 {
175 return asearch -> object + asearch -> filter;
176 }
177 else if (get_project_by_id(asearch -> proj) -> natomes >= 10000)
178 {
179 return (asearch -> object > 1) ? 1 + asearch -> filter : asearch -> filter;
180 }
181 else
182 {
183 return asearch -> object + asearch -> filter;
184 }
185}
186
195{
196 if (asearch -> passivating)
197 {
198 return (asearch -> object > 1) ? TRUE : FALSE;
199 }
200 else
201 {
202 return (asearch -> object) ? TRUE : FALSE;
203 }
204}
205
214void check_tree_for_this_search (project * this_proj, atom_search * asearch)
215{
216 int j, k, l, m, n, o, p;
217 double u, v;
218 gchar * str;
219 GtkTreeIter iter;
220 GtkTreeIter child;
221 GtkTreeModel * atom_model;
222 gboolean dothis, dothat, is_first;
223
224 int obj = get_asearch_object (asearch);
225 int filter = get_asearch_filter (asearch);
226 int is_clone = (asearch -> action == 1) ? 1 : 0;
227 int status = (asearch -> action < 2) ? 2 : asearch -> status;
228 int val = get_asearch_num_objects (asearch);
229 int step = this_proj -> modelgl -> anim -> last -> img -> step;
230 atom_model = GTK_TREE_MODEL(asearch -> atom_model);
231 if (gtk_tree_model_get_iter_first (atom_model, & iter))
232 {
233 dothis = TRUE;
234 if (! filter && status == 2)
235 {
236 while (dothis)
237 {
238 gtk_tree_model_get (atom_model, & iter, IDCOL, & j, -1);
239 j = abs(j) -1;
240 if (j > -1)
241 {
242 gtk_tree_store_set (asearch -> atom_model, & iter, TOLAB, this_proj -> modelgl -> anim -> last -> img -> show_label[is_clone][j], -1);
243 if (gtk_tree_model_iter_children (atom_model, & child, & iter))
244 {
245 dothat = is_first = TRUE;
246 u = v = 0.0;
247 l = 0;
248 m = 1;
249 while (dothat)
250 {
251 gtk_tree_model_get (atom_model, & child, IDCOL, & k, TOPIC, & l, -1);
252 if (k > 0)
253 {
254 k --;
255 if (asearch -> action == RANMOVE)
256 {
257 v = this_proj -> modelgl -> atom_win -> msd[k];
258 if (! is_first && u != v) v = 0.0;
259 is_first = FALSE;
260 u = v;
261 }
262 m = (l && m) ? 1 : 0;
263 gtk_tree_store_set (asearch -> atom_model, & child, TOLAB, this_proj -> atoms[step][k].label[is_clone], -1);
264 if (asearch -> action == RANMOVE)
265 {
266 if (this_proj -> modelgl -> atom_win -> msd[k] > 0.0)
267 {
268 str = g_strdup_printf ("MSD<sub>max</sub>= %f", this_proj -> modelgl -> atom_win -> msd[k]);
269 }
270 else
271 {
272 str = g_strdup_printf ("Set MSD<sub>max</sub> for ...");
273 }
274 gtk_tree_store_set (asearch -> atom_model, & child, TOPIC+2, str, -1);
275 g_free (str);
276 }
277 is_first = FALSE;
278 }
279 dothat = gtk_tree_model_iter_next (atom_model, & child);
280 }
281 asearch -> pick[j] = m;
282 if (asearch -> action == RANMOVE)
283 {
284 if (v > 0.0)
285 {
286 str = g_strdup_printf ("For all: MSD<sub>max</sub>= %f", v);
287 }
288 else
289 {
290 str = g_strdup_printf ("Set MSD<sub>max</sub> for all ...");
291 }
292 gtk_tree_store_set (asearch -> atom_model, & iter, TOPIC+2, str, -1);
293 g_free (str);
294 }
295 }
296 gtk_tree_store_set (asearch -> atom_model, & iter, TOPIC, asearch -> pick[j], -1);
297 }
298 dothis = gtk_tree_model_iter_next (atom_model, & iter);
299 }
300 }
301 else
302 {
303 while (dothis)
304 {
305 gtk_tree_model_get (atom_model, & iter, IDCOL, & j, -1);
306 j = abs(j) - 1;
307 if (j > -1 && j < val)
308 {
309 k = l = 0;
310 switch (filter)
311 {
312 case 0:
313 for (m=0; m<this_proj -> natomes; m++)
314 {
315 n = this_proj -> atoms[step][m].sp;
316 if (n == j && (this_proj -> atoms[step][m].pick[is_clone] == status || status == 2))
317 {
318 k ++;
319 l += (this_proj -> atoms[step][m].label[is_clone]) ? 1 : 0;
320 }
321 }
322 break;
323 case 1:
324 for (m=0; m<this_proj -> natomes; m++)
325 {
326 n = this_proj -> atoms[step][m].sp;
327 o = this_proj -> atoms[step][m].coord[filter-1];
328 if (this_proj -> atoms[step][m].numv == j && (this_proj -> atoms[step][m].pick[is_clone] == status || status == 2))
329 {
330 k ++;
331 l += (this_proj -> atoms[step][m].label[is_clone]) ? 1 : 0;
332 }
333 }
334 break;
335 default:
336 for (m=0; m<this_proj -> natomes; m++)
337 {
338 n = this_proj -> atoms[step][m].sp;
339 o = this_proj -> atoms[step][m].coord[filter-1];
340 if (filter == 2)
341 {
342 for (p=0; p<n; p++)
343 {
344 o += this_proj -> coord -> ntg[1][p];
345 }
346 }
347 if (o == j && (this_proj -> atoms[step][m].pick[is_clone] == status || status == 2))
348 {
349 k ++;
350 l += (this_proj -> atoms[step][m].label[is_clone]) ? 1 : 0;
351 }
352 }
353 break;
354 }
355 gtk_tree_store_set (asearch -> atom_model, & iter, TOLAB, (k == l && k != 0) ? 1 : 0, -1);
356 if (gtk_tree_model_iter_children (atom_model, & child, & iter))
357 {
358 dothat = TRUE;
359 u = v = 0.0;
360 l = n = 0;
361 m = o = 1;
362 while (dothat)
363 {
364 gtk_tree_model_get (atom_model, & child, IDCOL, & k, TOPIC, & l, -1);
365 if (asearch -> action == RANMOVE && obj)
366 {
367 gtk_tree_model_get (atom_model, & child, TOPIC+1, & n, -1);
368 }
369 if (k > 0)
370 {
371 k --;
372 if (asearch -> action == RANMOVE)
373 {
374 v = this_proj -> modelgl -> atom_win -> msd[k];
375 if (! is_first && u != v) v = 0.0;
376 is_first = FALSE;
377 u = v;
378 }
379 m = (m && l) ? 1 : 0;
380 o = (o && n) ? 1 : 0;
381 gtk_tree_store_set (asearch -> atom_model, & child, TOLAB, this_proj -> atoms[step][k].label[is_clone], -1);
382 if (asearch -> action == RANMOVE)
383 {
384 if (this_proj -> modelgl -> atom_win -> msd[k] > 0.0)
385 {
386 str = g_strdup_printf ("MSD<sub>max</sub>= %f", this_proj -> modelgl -> atom_win -> msd[k]);
387 }
388 else
389 {
390 str = g_strdup_printf ("Set MSD<sub>max</sub> for ...");
391 }
392 gtk_tree_store_set (asearch -> atom_model, & child, TOPIC+2, str, -1);
393 g_free (str);
394 }
395 }
396 dothat = gtk_tree_model_iter_next (atom_model, & child);
397 }
398 if (asearch -> action == RANMOVE)
399 {
400 asearch -> pick[j] = (m && o) ? 3 : (o) ? 2 : (m) ? 1 : 0;
401 }
402 else
403 {
404 asearch -> pick[j] = m;
405 }
406 gtk_tree_store_set (asearch -> atom_model, & iter, TOPIC, m, -1);
407 if (asearch -> action == RANMOVE && v != 0)
408 {
409 if (v > 0.0)
410 {
411 if (filter > 2)
412 {
413 str = g_strdup_printf ("For all: MSD<sub>max</sub>= %f", v);
414 }
415 else
416 {
417 str = g_strdup_printf ("MSD<sub>max</sub>= %f", v);
418 }
419 }
420 else
421 {
422 if (obj && filter > 2)
423 {
424 str = g_strdup_printf ("Set MSD<sub>max</sub> for ...");
425 }
426 else
427 {
428 str = g_strdup_printf ("Set MSD<sub>max</sub> for all ...");
429 }
430 }
431 gtk_tree_store_set (asearch -> atom_model, & iter, TOPIC+2, str, -1);
432 g_free (str);
433 if (obj) gtk_tree_store_set (asearch -> atom_model, & iter, TOPIC+1, o, -1);
434 }
435 }
436 }
437 dothis = gtk_tree_model_iter_next (atom_model, & iter);
438 }
439 }
440 }
441}
442
450void check_all_trees (project * this_proj)
451{
452 int i;
453 for (i=0; i<7; i++)
454 {
455 if (i != 5 && this_proj -> modelgl -> search_widg[i] != NULL)
456 {
457 if (this_proj -> modelgl -> search_widg[i] -> atom_model && this_proj -> modelgl -> search_widg[i] -> todo_size < 10000)
458 {
459 check_tree_for_this_search (this_proj, this_proj -> modelgl -> search_widg[i]);
460 }
461 }
462 }
463}
464
475{
476 atomic_object * object = first;
477 while (object)
478 {
479 if (! aid && object -> origin == oid) return object;
480 if (aid && object -> id == aid-1) return object;
481 object = object -> next;
482 }
483 return NULL;
484}
485
494{
495 project * this_proj = get_project_by_id (asearch -> proj);
496 int i, j;
497 for (i=0; i<2; i++)
498 {
499 for (j=0; j<6; j++)
500 {
501 this_proj -> modelgl -> atom_win -> old_param[asearch -> status][i][j] = this_proj -> modelgl -> atom_win -> new_param[asearch -> status][i][j] = 0.0;
502 }
503 }
504 for (i=0; i<2; i++)
505 {
506 for (j=0; j<6; j++)
507 {
508 update_range_and_entry (this_proj, asearch -> status, i, j);
509 }
510 }
511}
512
523void adjust_object_to_move (project * this_proj, atom_search * asearch, int mv, int id)
524{
525 gboolean adjust_mv = FALSE;
526 int filter = get_asearch_filter (asearch);
527 if (this_proj -> modelgl -> atom_win -> to_be_moved[mv])
528 {
529 atomic_object * object = this_proj -> modelgl -> atom_win -> to_be_moved[mv];
530 gboolean check_it = TRUE;
531 gboolean remove_it = FALSE;
532 gboolean add_it = FALSE;
533 while (check_it)
534 {
535 if (object -> id == id)
536 {
537 if (! asearch -> todo[id]) remove_it = TRUE;
538 check_it = FALSE;
539 }
540 else
541 {
542 if (object -> next)
543 {
544 object = object -> next;
545 }
546 else
547 {
548 check_it = FALSE;
549 add_it = TRUE;
550 }
551 }
552 }
553 if (remove_it)
554 {
555 adjust_mv = TRUE;
556 if (object -> ibonds) g_free (object -> ibonds);
557 if (object -> baryc) g_free (object -> baryc);
558 if (object -> at_list) g_free (object -> at_list);
559 if (object -> coord) g_free (object -> coord);
560 if (object -> bcid) g_free (object -> bcid);
561 object -> atoms = object -> bonds = 0;
562 if (object -> next && object -> prev)
563 {
564 object -> prev -> next = object -> next;
565 object -> next -> prev = object -> prev;
566 g_free (object);
567 }
568 else if (! object -> prev && object -> next)
569 {
570 object = object -> next;
571 object -> prev = NULL;
572 g_free (this_proj -> modelgl -> atom_win -> to_be_moved[mv]);
573 this_proj -> modelgl -> atom_win -> to_be_moved[mv] = object;
574 }
575 else if (object -> prev)
576 {
577 object -> prev -> next = NULL;
578 g_free (object);
579 }
580 else
581 {
582 g_free (this_proj -> modelgl -> atom_win -> to_be_moved[mv]);
583 this_proj -> modelgl -> atom_win -> to_be_moved[mv] = NULL;
584 }
585 }
586 else if (add_it)
587 {
588 adjust_mv = TRUE;
589 object_motion = TRUE;
590 if (! filter)
591 {
592 object -> next = create_object_from_species (this_proj, id, NULL);
593 }
594 else if (filter < 3)
595 {
596 object -> next = create_object_from_atom_coordination (this_proj, filter-1, id, NULL);
597 }
598 else
599 {
600 object -> next = create_object_from_frag_mol (this_proj, filter-1, id, NULL);
601 }
602 object -> next -> id = id;
603 object_motion = FALSE;
604 this_proj -> modelgl -> atom_win -> rebuilt[mv] = FALSE;
605 object -> next -> prev = object;
606 }
607 }
608 else
609 {
610 adjust_mv = TRUE;
611 object_motion = TRUE;
612 if (! filter)
613 {
614 this_proj -> modelgl -> atom_win -> to_be_moved[mv] = create_object_from_species (this_proj, id, NULL);
615 }
616 else if (filter < 3)
617 {
618 this_proj -> modelgl -> atom_win -> to_be_moved[mv] = create_object_from_atom_coordination (this_proj, filter-1, id, NULL);
619 }
620 else
621 {
622 this_proj -> modelgl -> atom_win -> to_be_moved[mv] = create_object_from_frag_mol (this_proj, filter-1, id, NULL);
623 }
624 this_proj -> modelgl -> atom_win -> to_be_moved[mv] -> id = id;
625 this_proj -> modelgl -> atom_win -> rebuilt[mv] = FALSE;
626 object_motion = FALSE;
627 }
628 if (adjust_mv && ! mv && this_proj -> modelgl -> atom_win) motion_to_zero (asearch);
629}
630
643void append_to_model (GtkTreeIter * atom_level, atom_search * asearch, gboolean is_object, int h, int i, project * this_proj)
644{
645 int j, k, l;
646 int step = this_proj -> modelgl -> anim -> last -> img -> step;
647 gchar * str;
648 j = this_proj -> atoms[0][i].sp;
649 str = g_strdup_printf ("%s<sub>%d</sub>", this_proj -> chemistry -> label[j], i+1);
650 int aobj = get_asearch_object (asearch);
651 if (aobj == 2) str = g_strdup_printf ("%s + neighbor(s)", str);
652 gboolean is_clone = (asearch -> pointer[0].c == 1) ? 1 : 0;
653 gtk_tree_store_set (asearch -> atom_model, atom_level, IDCOL, i+1, 1, " ", 2, str, TOLAB, this_proj -> atoms[step][i].label[is_clone], -1);
654 g_free (str);
655 atomic_object * object;
656 switch (asearch -> action)
657 {
658 case 0:
659 gtk_tree_store_set (asearch -> atom_model, atom_level, TOPIC, this_proj -> atoms[step][i].pick[0], -1);
660 break;
661 case 1:
662 gtk_tree_store_set (asearch -> atom_model, atom_level, TOPIC, this_proj -> atoms[step][i].pick[0], -1);
663 break;
664 case RANMOVE:
665 if (asearch -> set_for_all > 0)
666 {
667 asearch -> todo[i] = asearch -> set_for_all;
668 if (aobj)
669 {
670 adjust_object_to_move (this_proj, asearch, 1, i);
671 }
672 }
673 k = (asearch -> todo[i] == 1 || asearch -> todo[i] == 3) ? 1 : 0;
674 l = (asearch -> todo[i] == 2 || asearch -> todo[i] == 3) ? 1 : 0;
675 if (this_proj -> modelgl -> atom_win -> msd[i] > 0.0)
676 {
677 str = g_strdup_printf ("MSD<sub>max</sub>= %f", this_proj -> modelgl -> atom_win -> msd[i]);
678 }
679 else
680 {
681 str = g_strdup_printf ("Set MSD<sub>max</sub> for ...");
682 }
683 gtk_tree_store_set (asearch -> atom_model, atom_level, TOPIC, k, TOPIC+2, str, -1);
684 if (is_object)
685 {
686 gtk_tree_store_set (asearch -> atom_model, atom_level, TOPIC+1, l, -1);
687 }
688 g_free (str);
689 break;
690 default:
691 if (asearch -> set_for_all > 0)
692 {
693 asearch -> todo[i] = asearch -> set_for_all;
694 if (asearch -> action == DISPL)
695 {
696 if (aobj)
697 {
698 adjust_object_to_move (this_proj, asearch, 0, i);
699 }
700 }
701 }
702 gtk_tree_store_set (asearch -> atom_model, atom_level, TOPIC, asearch -> todo[i], -1);
703 if (asearch -> action == REPLACE)
704 {
705 object = get_atomic_object_by_origin (this_proj -> modelgl -> atom_win -> to_be_inserted[0], i, 0);
706 gtk_tree_store_set (asearch -> atom_model, atom_level, TOPIC+1, (object) ? object -> name : "Select ...", TOPIC+3, h, -1);
707 }
708 break;
709 }
710}
711
722gboolean fill_for_action (atom_search * asearch, int i, int j, project * this_proj)
723{
724 gboolean append = FALSE;
725 if (asearch -> spec == 0 || asearch -> spec == j+1)
726 {
727 if (asearch -> action > 1)
728 {
729 if (asearch -> status == 2)
730 {
731 append = TRUE;
732 }
733 else
734 {
735 append = (this_proj -> atoms[0][i].pick[0] == asearch -> status) ? TRUE : FALSE;
736 }
737 }
738 else
739 {
740 append = TRUE;
741 }
742 }
743 return append;
744}
745
756gboolean append (atom_search * asearch, project * this_proj, int i, int j)
757{
758 int k;
759 gchar * str_a, * str_b;
760 k = this_proj -> modelgl -> anim -> last -> img -> step;
761 gboolean append = FALSE;
762 if (fill_for_action (asearch, i, j, this_proj))
763 {
764 if (asearch -> search_digit == -1)
765 {
766 if (asearch -> pointer[0].c == 1)
767 {
768 append = this_proj -> atoms[k][i].cloned;
769 }
770 else
771 {
772 append = TRUE;
773 }
774 }
775 else
776 {
777 str_a = g_strdup_printf ("%d", i+1);
778 str_b = g_strdup_printf ("%d", asearch -> search_digit);
779 if (strlen (str_b) > strlen (str_a))
780 {
781 append = FALSE;
782 }
783 else
784 {
785 k = 0;
786 append = TRUE;
787 while (k < strlen (str_b))
788 {
789 if (str_a[k] != str_b[k])
790 {
791 append = FALSE;
792 break;
793 }
794 k++;
795 }
796 }
797 g_free (str_a);
798 g_free (str_b);
799 }
800 }
801 return append;
802}
803
813gchar * adjust_picked (gchar * picked, atomic_object * object, gboolean init)
814{
815 if (object)
816 {
817 if (init && ! picked)
818 {
819 return g_strdup_printf ("%s", object -> name);
820 }
821 else
822 {
823 if (g_strcmp0(picked, object -> name) == 0)
824 {
825 return g_strdup_printf ("%s", picked);
826 }
827 else
828 {
829 return NULL;
830 }
831 }
832 }
833 else
834 {
835 return NULL;
836 }
837}
838
848gchar * get_node_name (int node, atom_search * asearch, project * this_proj)
849{
850 int i, j, k, l;
851 int filter = get_asearch_filter (asearch);
852 gchar * str;
853 if (! filter)
854 {
855 str = g_strdup_printf ("%s", this_proj -> chemistry -> label[node]);
856 }
857 else if (filter == 1)
858 {
859 str = (node) ? g_strdup_printf ("%d-fold", node) : g_strdup_printf ("Isolated");
860 }
861 else if (filter == 2)
862 {
863 i = 0;
864 for (j=0; j<this_proj -> nspec; j++)
865 {
866 i += this_proj -> coord -> ntg[1][j];
867 if (i > node) break;
868 }
869 k = 0;
870 for (l=0; l<j; l++) k += this_proj -> coord -> ntg[filter - 1][l];
871 str = g_strdup_printf ("%s", env_name(this_proj, node-k, j, 1, NULL));
872 }
873 else if (filter == 3)
874 {
875 str = g_strdup_printf ("Fragment N°%d", node+1);
876 }
877 else
878 {
879 str = g_strdup_printf ("Molecule N°%d", node+1);
880 }
881 if (filter < 3 && asearch -> pointer[0].c == 1) str = g_strdup_printf ("%s<sup>*</sup>", str);
882 return str;
883}
884
893void fill_atom_model (atom_search * asearch, project * this_proj)
894{
895 GtkTreeIter spec_level, atom_level;
896 int g, h, i, j, k, l, m, n;
897 gchar * str;
898 gboolean do_append;
899 gboolean doit;
900 gboolean * to_insert;
901 gboolean is_object = get_asearch_is_object (asearch);
902 gchar ** picked_names;
903 int obj = get_asearch_object (asearch);
904 int filter = get_asearch_filter (asearch);
905 int step = this_proj -> modelgl -> anim -> last -> img -> step;
906 if (asearch -> action != INSERT)
907 {
908 if (asearch -> todo_size >= 10000 && ! asearch -> passivating && ! asearch -> mode)
909 {
910 if (! is_the_widget_visible(asearch -> info[1]))
911 {
912 show_the_widgets (asearch -> info[1]);
913 }
914 if (is_the_widget_visible (asearch -> id_box))
915 {
916 hide_the_widgets (asearch -> id_box);
917 }
918 }
919 else
920 {
921 if (is_the_widget_visible(asearch -> info[1]))
922 {
923 hide_the_widgets (asearch -> info[1]);
924 }
925 if (asearch -> mode)
926 {
927 if (is_the_widget_visible(asearch -> id_box))
928 {
929 hide_the_widgets (asearch -> id_box);
930 }
931 }
932 else
933 {
934 if (asearch -> passivating || (filter > 2 && obj == 2))
935 {
936 if (is_the_widget_visible (asearch -> id_box))
937 {
938 hide_the_widgets (asearch -> id_box);
939 }
940 }
941 else
942 {
943 if (! is_the_widget_visible (asearch -> id_box))
944 {
945 show_the_widgets (asearch -> id_box);
946 }
947 }
948 }
949 int val = get_asearch_num_objects (asearch);
950 to_insert = allocbool(val);
951 n = 0;
952 if (asearch -> action == REPLACE)
953 {
954 picked_names = g_malloc0(val*sizeof*picked_names);
955 n = (asearch -> pointer[0].c == 3) ? 0 : 3;
956 }
957 switch (filter)
958 {
959 case 0:
960 for (h=0; h<val; h++)
961 {
962 doit = TRUE;
963 if (! asearch -> spec || asearch -> spec == h+1)
964 {
965 for (i=0; i<this_proj -> natomes; i++)
966 {
967 j = this_proj -> atoms[0][i].sp;
968 if (j == h)
969 {
970 to_insert[h] = append (asearch, this_proj, i, j);
971 if (to_insert[h])
972 {
973 if (asearch -> action == REPLACE && asearch -> in_selection)
974 {
975 picked_names[h] = adjust_picked (picked_names[h],
976 get_atomic_object_by_origin (this_proj -> modelgl -> atom_win -> to_be_inserted[n], (asearch -> mode) ? -(h+3) : (asearch -> passivating) ? h : i, 0),
977 doit);
978 doit = FALSE;
979 }
980 if (asearch -> action != REPLACE || n || ! picked_names[h] || asearch -> mode) break;
981 }
982 }
983 }
984 }
985 }
986 break;
987 case 1:
988 for (h=0; h<val; h++)
989 {
990 doit = TRUE;
991 for (i=0; i<this_proj -> natomes; i++)
992 {
993 if (this_proj -> atoms[0][i].numv == h)
994 {
995 j = this_proj -> atoms[0][i].sp;
996 to_insert[h] = append (asearch, this_proj, i, j);
997 if (to_insert[h])
998 {
999 if (asearch -> action == REPLACE && asearch -> in_selection)
1000 {
1001 picked_names[h] = adjust_picked (picked_names[h],
1002 get_atomic_object_by_origin (this_proj -> modelgl -> atom_win -> to_be_inserted[n], (asearch -> mode) ? -(h+3) : (asearch -> passivating) ? h : i, 0),
1003 doit);
1004 }
1005 if (asearch -> action != REPLACE || n || ! picked_names[h] || asearch -> mode) break;
1006 }
1007 }
1008 }
1009 }
1010 break;
1011 default:
1012 if (val >= 10000 && (obj == 1 || asearch -> object == 3))
1013 {
1014 // Improbable: more than 10 000 fragments or molecules
1015 // Note: so far the selection and the test case functions are not ready yet
1016 to_insert[0] = TRUE;
1017 picked_names[0] = g_strdup_printf ("All %s(s)", (filter == 2) ? "fragment" : "molecule");
1018 val = 1;
1019 }
1020 else
1021 {
1022 for (h=0; h<val; h++)
1023 {
1024 doit = TRUE;
1025 for (i=0; i<this_proj -> natomes; i++)
1026 {
1027 if (asearch -> spec == 0 || asearch -> spec == this_proj -> atoms[0][i].sp + 1)
1028 {
1029 j = this_proj -> atoms[step][i].coord[filter - 1];
1030 if (filter == 2)
1031 {
1032 for (k=0; k<this_proj -> atoms[0][i].sp; k++) j += this_proj -> coord -> ntg[filter - 1][k];
1033 }
1034 if (j == h)
1035 {
1036 to_insert[h] = append (asearch, this_proj, i, this_proj -> atoms[0][i].sp);
1037 if (to_insert[h])
1038 {
1039 if (asearch -> action == REPLACE && asearch -> in_selection)
1040 {
1041 picked_names[h] = adjust_picked (picked_names[h],
1042 get_atomic_object_by_origin (this_proj -> modelgl -> atom_win -> to_be_inserted[n], (asearch -> mode) ? -(h+3) : (asearch -> passivating) ? h : i, 0),
1043 doit);
1044 }
1045 if (asearch -> action != REPLACE || n || ! picked_names[h] || asearch -> mode) break;
1046 }
1047 }
1048 }
1049 }
1050 }
1051 }
1052 break;
1053 }
1054 if ((asearch -> action == REPLACE || asearch -> action == REMOVE) && asearch -> mode && obj && filter > 2)
1055 {
1056 if (filter == 3 && this_proj -> coord -> totcoord[2] > 1)
1057 {
1058 str = g_strdup_printf ("Fragments");
1059 gtk_tree_store_append (asearch -> atom_model, & spec_level, NULL);
1060 if (asearch -> set_for_all > 0) asearch -> pick[0] = asearch -> set_for_all;
1061 gtk_tree_store_set (asearch -> atom_model, & spec_level, IDCOL, -1, 1, str, TOPIC, asearch -> pick[0], -1);
1062 g_free (str);
1063 str = g_strdup_printf ("%d", asearch -> todo[0]);
1064 j = (asearch -> action == REMOVE) ? 1 : 2;
1065 gtk_tree_store_set (asearch -> atom_model, & spec_level, TOPIC+j, str, -1);
1066 g_free (str);
1067 if (asearch -> action == REPLACE)
1068 {
1069 if (picked_names[0])
1070 {
1071 str = g_strdup_printf ("For all: %s", picked_names[0]);
1072 gtk_tree_store_set (asearch -> atom_model, & spec_level, TOPIC+1, str, -1);
1073 g_free (str);
1074 }
1075 else
1076 {
1077 gtk_tree_store_set (asearch -> atom_model, & spec_level, TOPIC+1, "Select for all ...", -1);
1078 }
1079 }
1080 }
1081 else if (filter == 4 && this_proj -> modelfc)
1082 {
1083 for (k=0; k<this_proj -> modelfc -> mol_by_step[0]; k++)
1084 {
1085 if (this_proj -> modelfc -> mols[0][k].multiplicity > 1)
1086 {
1087 str = g_strdup_printf ("Molecule N°%d", k+1);
1088 gtk_tree_store_append (asearch -> atom_model, & spec_level, NULL);
1089 if (asearch -> set_for_all > 0) asearch -> pick[k] = asearch -> set_for_all;
1090 gtk_tree_store_set (asearch -> atom_model, & spec_level, IDCOL, -(k+1), 1, str, TOPIC, asearch -> pick[k], -1);
1091 g_free (str);
1092 str = g_strdup_printf ("%d", asearch -> todo[k]);
1093 gtk_tree_store_set (asearch -> atom_model, & spec_level, TOPIC+2, str, -1);
1094 g_free (str);
1095 if (asearch -> action == REPLACE)
1096 {
1097 if (picked_names[k])
1098 {
1099 str = g_strdup_printf ("For all: %s", picked_names[k]);
1100 gtk_tree_store_set (asearch -> atom_model, & spec_level, TOPIC+1, str, -1);
1101 g_free (str);
1102 }
1103 else
1104 {
1105 gtk_tree_store_set (asearch -> atom_model, & spec_level, TOPIC+1, "Select for all ...", -1);
1106 }
1107 }
1108 }
1109 }
1110 }
1111 }
1112 else
1113 {
1114 for (h=0; h<val; h++)
1115 {
1116 if (to_insert[h])
1117 {
1118 gtk_tree_store_append (asearch -> atom_model, & spec_level, NULL);
1119 if (asearch -> action == REPLACE && ! asearch -> mode)
1120 {
1121 g = (asearch -> pointer[0].c == 3) ? 0 : 1;
1122 this_proj -> modelgl -> atom_win -> replace_nodes[g][h] = gtk_tree_model_get_path (GTK_TREE_MODEL(asearch -> atom_model), & spec_level);
1123 }
1124 str = get_node_name (h, asearch, this_proj);
1125 if (asearch -> set_for_all > 0) asearch -> pick[h] = asearch -> set_for_all;
1126 if (asearch -> action < RANMOVE || asearch -> action > RANMOVE)
1127 {
1128 gtk_tree_store_set (asearch -> atom_model, & spec_level, IDCOL, -(h+1), 1, str, TOPIC, asearch -> pick[h], -1);
1129 if (asearch -> passivating)
1130 {
1131 gtk_tree_store_set (asearch -> atom_model, & spec_level, TOLAB, asearch -> lab[h], -1);
1132 }
1133
1134 if (asearch -> set_for_all > 0 && asearch -> action == DISPL && filter > 2)
1135 {
1136 asearch -> todo[h] = asearch -> set_for_all;
1137 adjust_object_to_move (this_proj, asearch, 0, h);
1138 }
1139 if (asearch -> mode)
1140 {
1141 g_free (str);
1142 str = g_strdup_printf ("%d", asearch -> todo[h]);
1143 gtk_tree_store_set (asearch -> atom_model, & spec_level, TOPIC+5-asearch -> action, str, -1);
1144 }
1145 }
1146 else if (asearch -> action == RANMOVE)
1147 {
1148 i = (asearch -> pick[h] == 1 || asearch -> pick[h] == 3) ? 1 : 0;
1149 gtk_tree_store_set (asearch -> atom_model, & spec_level, IDCOL, -(h+1), 1, str, TOPIC, i, -1);
1150 if (is_object)
1151 {
1152 i = (asearch -> pick[h] == 2 || asearch -> pick[h] == 3) ? 1 : 0;
1153 gtk_tree_store_set (asearch -> atom_model, & spec_level, TOPIC+1, i, -1);
1154 if (asearch -> set_for_all > 0)
1155 {
1156 if (filter > 2)
1157 {
1158 asearch -> todo[h] = asearch -> set_for_all;
1159 adjust_object_to_move (this_proj, asearch, 1, h);
1160 }
1161 }
1162 }
1163 }
1164 g_free (str);
1165 if (asearch -> action == REPLACE)
1166 {
1167 if (picked_names[h])
1168 {
1169 if (asearch -> mode || (obj && filter > 2))
1170 {
1171 str = g_strdup_printf ("%s", picked_names[h]);
1172 }
1173 else
1174 {
1175 str = g_strdup_printf ("For all: %s", picked_names[h]);
1176 }
1177 gtk_tree_store_set (asearch -> atom_model, & spec_level, TOPIC+1, str, -1);
1178 g_free (str);
1179 }
1180 else
1181 {
1182 if (asearch -> mode || (obj && filter > 2))
1183 {
1184 gtk_tree_store_set (asearch -> atom_model, & spec_level, TOPIC+1, "Select ...", -1);
1185 }
1186 else
1187 {
1188 gtk_tree_store_set (asearch -> atom_model, & spec_level, TOPIC+1, "Select for all ...", -1);
1189 }
1190 }
1191 }
1192 else if (asearch -> action == RANMOVE)
1193 {
1194 if (this_proj -> modelgl -> atom_win -> msd_all[h] > 0.0)
1195 {
1196 if (obj && filter > 2)
1197 {
1198 str = g_strdup_printf ("MSD<sub>max</sub>= %f", this_proj -> modelgl -> atom_win -> msd_all[h]);
1199 }
1200 else
1201 {
1202 str = g_strdup_printf ("For all: MSD<sub>max</sub>= %f", this_proj -> modelgl -> atom_win -> msd_all[h]);
1203 }
1204 gtk_tree_store_set (asearch -> atom_model, & spec_level, TOPIC+2, str, -1);
1205 g_free (str);
1206 }
1207 else
1208 {
1209 if (obj && filter > 2)
1210 {
1211 gtk_tree_store_set (asearch -> atom_model, & spec_level, TOPIC+2, "Set MSD<sub>max</sub> for ...", -1);
1212 }
1213 else
1214 {
1215 gtk_tree_store_set (asearch -> atom_model, & spec_level, TOPIC+2, "Set MSD<sub>max</sub> for all ...", -1);
1216 }
1217 }
1218 }
1219 doit = FALSE;
1220 if (asearch -> action > REMOVE && asearch -> action != RANMOVE)
1221 {
1222 doit = TRUE;
1223 }
1224 else
1225 {
1226 doit = (asearch -> passivating) ? FALSE : ! asearch -> mode;
1227 }
1228 if (doit && (! obj || (filter > 0 && filter < 3)))
1229 {
1230 for (i=0; i<this_proj -> natomes; i++)
1231 {
1232 do_append = FALSE;
1233 j = this_proj -> atoms[0][i].sp;
1234 if (! filter)
1235 {
1236 if (j == h && append (asearch, this_proj, i, j)) do_append=TRUE;
1237 }
1238 else
1239 {
1240 k = filter - 1;
1241 l = this_proj -> atoms[step][i].coord[k];
1242 if (filter == 1)
1243 {
1244 m = this_proj -> coord -> geolist[0][j][l];
1245 if (m == h && append (asearch, this_proj, i, j)) do_append=TRUE;
1246 }
1247 else
1248 {
1249 if (filter == 2) for (m=0; m<j; m++) l += this_proj -> coord -> ntg[1][m];
1250 if (l == h && append (asearch, this_proj, i, j)) do_append=TRUE;
1251 }
1252 }
1253 if (do_append)
1254 {
1255 gtk_tree_store_append (asearch -> atom_model, & atom_level, & spec_level);
1256 append_to_model (& atom_level, asearch, is_object, h, i, this_proj);
1257 }
1258 }
1259 }
1260 }
1261 }
1262 g_free (to_insert);
1263 if (asearch -> action == DISPL) check_motion_interactors (this_proj, asearch);
1264 if (asearch -> action == REPLACE) g_free (picked_names);
1265 }
1266 //if (asearch -> passivating)
1267 check_tree_for_this_search (this_proj, asearch);
1268 }
1269 }
1270 else
1271 {
1272 i = (asearch -> pointer[0].c == 7) ? 2 : 1;
1273 atomic_object * iobj = this_proj -> modelgl -> atom_win -> to_be_inserted[i];
1274 j = 0;
1275 while (iobj)
1276 {
1277 gtk_list_store_append (asearch -> obj_model, & atom_level);
1278 str = g_strdup_printf ("x= %f, y= %f, z= %f", iobj -> baryc[0], iobj -> baryc[1], iobj -> baryc[2]);
1279 gtk_list_store_set (asearch -> obj_model, & atom_level, IDCOL, j+1, 1, g_strdup_printf ("%d", j+1), 2, iobj -> name,
1280 TOLAB, asearch -> todo[j], TOPIC, str, -1);
1281 g_free (str);
1282 if (i == 2)
1283 {
1284 str = g_strdup_printf ("%f", iobj -> occ);
1285 gtk_list_store_set (asearch -> obj_model, & atom_level, TOPIC+1, str, -1);
1286 g_free (str);
1287 }
1288 j ++;
1289 iobj = iobj -> next;
1290 }
1291 }
1292 if (asearch -> set_for_all > 0) asearch -> set_for_all = -asearch -> set_for_all;
1293}
1294
1295G_MODULE_EXPORT void move_up_down (GtkTreeModel * tree_model, GtkTreePath * path, gpointer data);
1296void add_random_column (atom_search * asearch);
1297
1306{
1307 if (asearch -> pointer[0].c == 7 && asearch -> obj_model)
1308 {
1309 g_signal_handler_disconnect (G_OBJECT(GTK_TREE_MODEL(asearch -> obj_model)), asearch -> filter);
1310 gtk_list_store_clear (asearch -> obj_model);
1311 asearch -> filter = g_signal_connect_data (G_OBJECT(GTK_TREE_MODEL(asearch -> obj_model)), "row-deleted", G_CALLBACK(move_up_down), asearch, NULL, (GConnectFlags) 0);
1312 }
1313 else
1314 {
1315 if (asearch -> atom_model) gtk_tree_store_clear (asearch -> atom_model);
1316 if (asearch -> obj_model) gtk_list_store_clear (asearch -> obj_model);
1317 }
1318 fill_atom_model (asearch, get_project_by_id(asearch -> proj));
1319 //if (asearch -> action) gtk_tree_view_expand_all (GTK_TREE_VIEW(asearch -> atom_tree));
1320}
1321
1330{
1331 int object = get_asearch_object (asearch);
1332 int filter = get_asearch_filter (asearch);
1333 if (asearch -> passivating)
1334 {
1335 return FALSE;
1336 }
1337 else if (! asearch -> passivating && asearch -> todo_size >= 10000)
1338 {
1339 return FALSE;
1340 }
1341 else if (! (object && filter > 2))
1342 {
1343 return TRUE;
1344 }
1345 return FALSE;
1346}
1347
1356G_MODULE_EXPORT void set_atom (GtkEntry * entry, gpointer data)
1357{
1358 atom_search * asearch = (atom_search *)data;
1359 int i;
1360 project * this_proj = get_project_by_id(asearch -> proj);
1361 gchar * str_a, * str_b;
1362 str_a = g_strdup_printf ("%s", entry_get_text (GTK_ENTRY(asearch -> entry_a)));
1363 asearch -> spec_to_add = -1;
1364 for (i = 0; i < this_proj -> nspec; i++)
1365 {
1366 str_b = g_strdup_printf ("%s", exact_name(this_proj -> chemistry -> label[i]));
1367 if (g_strcmp0 (str_a, str_b) == 0)
1368 {
1369 asearch -> spec_to_add = i;
1370 }
1371 g_free (str_b);
1372 }
1373 g_free (str_a);
1374 if (asearch -> spec_to_add != -1)
1375 {
1376 widget_set_sensitive (asearch -> entry_b, 1);
1377 set_image_from_icon_name (asearch -> img_a, APPLY);
1378 }
1379 else
1380 {
1381 widget_set_sensitive (asearch -> entry_b, 0);
1382 widget_set_sensitive (asearch -> but_a, 0);
1383 widget_set_sensitive (asearch -> but_b, 0);
1384 update_entry_text (GTK_ENTRY(asearch -> entry_b), "");
1385 set_image_from_icon_name (asearch -> img_a, DIAL_ERROR);
1386 }
1387}
1388
1397{
1398 int i = gtk_combo_box_get_active (GTK_COMBO_BOX(asearch -> atom_box));
1399 if (i)
1400 {
1401 update_entry_text (GTK_ENTRY(asearch -> entry_a), exact_name(get_project_by_id(asearch -> proj) -> chemistry -> label[i-1]));
1402 }
1403 else
1404 {
1405 update_entry_text (GTK_ENTRY(asearch -> entry_a), "");
1406 }
1407 set_atom (GTK_ENTRY(asearch -> entry_a), asearch);
1408 update_entry_text (GTK_ENTRY(asearch -> entry_b), "");
1409 set_image_from_icon_name (asearch -> img_b, DIAL_ERROR);
1410}
1411
1422gboolean remove_from_model (GtkTreeModel * model, GtkTreePath * path, GtkTreeIter * iter, gpointer data)
1423{
1424 int i, j;
1425 GtkTreeIter parent;
1426 atom_search * asearch = (atom_search *)data;
1427 project * this_proj;
1428 if (gtk_tree_model_get_iter (model, iter, path))
1429 {
1430 gtk_tree_model_get (model, iter, IDCOL, & i, -1);
1431 if (i == asearch -> int_b)
1432 {
1433 j = (i > 0) ? i -- : abs(i) - 1;
1434 asearch -> todo[j] = 0;
1435 if (asearch -> action == REPLACE)
1436 {
1437 j = (i > 0) ? i -- : i - 2;
1438 this_proj = get_project_by_id(asearch -> proj);
1439 clean_this_object (j, 0, this_proj, asearch);
1440 asearch -> in_selection --;
1441 }
1442 if (gtk_tree_model_iter_parent (model, & parent, iter))
1443 {
1444 gtk_tree_store_remove (GTK_TREE_STORE(model), iter);
1445 if (! gtk_tree_model_iter_has_child(model, & parent))
1446 {
1447 gtk_tree_store_remove (GTK_TREE_STORE(model), & parent);
1448 if (asearch -> action == REPLACE)
1449 {
1450 j = abs(i) - 1;
1451 gtk_tree_path_free (this_proj -> modelgl -> atom_win -> replace_nodes[0][j]);
1452 this_proj -> modelgl -> atom_win -> replace_nodes[0][j] = NULL;
1453 }
1454 }
1455 }
1456 else
1457 {
1458 gtk_tree_store_remove (GTK_TREE_STORE(model), iter);
1459 }
1460 return TRUE;
1461 }
1462 }
1463 return FALSE;
1464}
1465
1474G_MODULE_EXPORT void remove_atom (GtkButton * but, gpointer data)
1475{
1476 atom_search * asearch = (atom_search *)data;
1477 asearch -> int_b = (int )string_to_double ((gpointer)entry_get_text (GTK_ENTRY(asearch -> entry_b)));
1478 gtk_tree_model_foreach (GTK_TREE_MODEL(asearch -> atom_model), remove_from_model, asearch);
1479 clear_fields (asearch);
1480}
1481
1492gboolean atom_is_in_model (GtkTreeModel * model, GtkTreePath * path, GtkTreeIter * iter, gpointer data)
1493{
1494 int b;
1495 atom_search * asearch = (atom_search *)data;
1496 if (gtk_tree_model_get_iter (model, iter, path))
1497 {
1498 gtk_tree_model_get (model, iter, IDCOL, & b, -1);
1499 if (b == asearch -> int_b)
1500 {
1501 asearch -> was_selected = TRUE;
1502 asearch -> path = gtk_tree_model_get_path (model, iter);
1503 return TRUE;
1504 }
1505 }
1506 return FALSE;
1507}
1508
1517G_MODULE_EXPORT void add_atom (GtkButton * but, gpointer data)
1518{
1519 atom_search * asearch = (atom_search *)data;
1520 project * this_proj = get_project_by_id(asearch -> proj);
1521 GtkTreeIter spec_level, atom_level, new_level;
1522 int i, j, k, l, m;
1523 i = this_proj -> modelgl -> anim -> last -> img -> step;
1524 j = asearch -> spec_to_add;
1525 int filter = get_asearch_filter (asearch);
1526 gboolean is_object = get_asearch_is_object (asearch);
1527 if (! asearch -> mode)
1528 {
1529 if (append (asearch, this_proj, -1, j))
1530 {
1531 asearch -> was_selected = FALSE;
1532 m = asearch -> int_b;
1533 asearch -> int_b = j+1;
1534 gtk_tree_model_foreach (GTK_TREE_MODEL(asearch -> atom_model), atom_is_in_model, asearch);
1535 if (! asearch -> was_selected)
1536 {
1537 switch (filter)
1538 {
1539 case 0:
1540 l = j;
1541 break;
1542 case 1:
1543 l = this_proj -> atoms[i][asearch -> num_to_add].numv;
1544 break;
1545 case 2:
1546 l = this_proj -> atoms[i][asearch -> num_to_add].coord[filter - 1];
1547 for (k=0; k<j; k++) l += this_proj -> coord -> ntg[filter - 1][k];
1548 break;
1549 default:
1550 l = this_proj -> atoms[i][asearch -> num_to_add].coord[filter - 1];
1551 break;
1552 }
1553 asearch -> int_b = -(l+1);
1554 gchar * str = get_node_name (l, asearch, this_proj);
1555 asearch -> was_selected = FALSE;
1556 gtk_tree_model_foreach (GTK_TREE_MODEL(asearch -> atom_model), atom_is_in_model, asearch);
1557 if (! asearch -> was_selected)
1558 {
1559 gtk_tree_store_append (asearch -> atom_model, & spec_level, NULL);
1560 if (asearch -> action == REPLACE)
1561 {
1562 this_proj -> modelgl -> atom_win -> replace_nodes[0][l] = gtk_tree_model_get_path (GTK_TREE_MODEL(asearch -> atom_model), & spec_level);
1563 }
1564 gtk_tree_store_set (asearch -> atom_model, & spec_level, IDCOL, -(l+1), 1, str, -1);
1565 gtk_tree_store_append (asearch -> atom_model, & atom_level, & spec_level);
1566 append_to_model (& atom_level, asearch, is_object, l, asearch -> num_to_add, this_proj);
1567 }
1568 else
1569 {
1570 // Find out where to insert that node !
1571 gtk_tree_model_get_iter (GTK_TREE_MODEL(asearch -> atom_model), & spec_level, asearch -> path);
1572 if (gtk_tree_model_iter_children (GTK_TREE_MODEL(asearch -> atom_model), & atom_level, & spec_level))
1573 {
1574 gboolean append = FALSE;
1575 gboolean dothat = TRUE;
1576 k = 0;
1577 while (dothat)
1578 {
1579 gtk_tree_model_get (GTK_TREE_MODEL(asearch -> atom_model), & atom_level, IDCOL, & k, -1);
1580 if (k > asearch -> num_to_add)
1581 {
1582 dothat = FALSE;
1583 }
1584 else
1585 {
1586 dothat = gtk_tree_model_iter_next (GTK_TREE_MODEL(asearch -> atom_model), & atom_level);
1587 append = TRUE;
1588 }
1589 }
1590 gtk_tree_store_insert_before (asearch -> atom_model, & new_level, & spec_level, (append) ? NULL : & atom_level);
1591 append_to_model (& new_level, asearch, l, is_object, asearch -> num_to_add, this_proj);
1592 }
1593 }
1594 g_free (str);
1595 asearch -> int_b = m;
1596 if (asearch -> action == REPLACE)
1597 {
1598 gtk_tree_store_set (asearch -> atom_model, & spec_level, TOPIC+1, "Select for all ...", -1);
1599 }
1600 else if (asearch -> action == RANMOVE)
1601 {
1602 str = g_strdup_printf ("Set MSD<sub>max</sub> for all ...");
1603 gtk_tree_store_set (asearch -> atom_model, & spec_level, TOPIC+2, str, -1);
1604 g_free (str);
1605 }
1606 }
1607 }
1608 }
1609 clear_fields (asearch);
1610}
1611
1620{
1621 project * this_proj = get_project_by_id (asearch -> proj);
1622 GtkTreeIter spec_level, atom_level, new_level;
1623 int i, j, k, l, m;
1624 i = this_proj -> modelgl -> anim -> last -> img -> step;
1625 int filter = get_asearch_filter (asearch);
1626 gboolean is_object = get_asearch_is_object (asearch);
1627 int s_int_b = asearch -> int_b;
1628 for (j=0; j<asearch -> todo_size; j++)
1629 {
1630 if (asearch -> todo[j])
1631 {
1632 k = this_proj -> atoms[i][j].sp;
1633 if (append (asearch, this_proj, -1, k))
1634 {
1635 asearch -> was_selected = FALSE;
1636 switch (filter)
1637 {
1638 case 0:
1639 l = k;
1640 break;
1641 case 1:
1642 l = this_proj -> atoms[i][j].numv;
1643 break;
1644 case 2:
1645 l = this_proj -> atoms[i][j].coord[filter - 1];
1646 for (m=0; m<k; m++) l += this_proj -> coord -> ntg[filter - 1][m];
1647 break;
1648 default:
1649 l = this_proj -> atoms[i][j].coord[filter - 1];
1650 break;
1651 }
1652 asearch -> int_b = -(l+1);
1653 gtk_tree_model_foreach (GTK_TREE_MODEL(asearch -> atom_model), atom_is_in_model, asearch);
1654 if (! asearch -> was_selected)
1655 {
1656 gchar * str = get_node_name (l, asearch, this_proj);
1657 gtk_tree_store_append (asearch -> atom_model, & spec_level, NULL);
1658 gtk_tree_store_set (asearch -> atom_model, & spec_level, IDCOL, asearch -> int_b, 1, str, -1);
1659 if (asearch -> action == RANMOVE)
1660 {
1661 str = g_strdup_printf ("Set MSD<sub>max</sub> for all ...");
1662 gtk_tree_store_set (asearch -> atom_model, & spec_level, TOPIC+2, str, -1);
1663 g_free (str);
1664 }
1665 gtk_tree_store_append (asearch -> atom_model, & atom_level, & spec_level);
1666 append_to_model (& atom_level, asearch, is_object, l, j, this_proj);
1667 }
1668 else
1669 {
1670 // Find out where to insert that node !
1671 gtk_tree_model_get_iter (GTK_TREE_MODEL(asearch -> atom_model), & spec_level, asearch -> path);
1672 if (gtk_tree_model_iter_children (GTK_TREE_MODEL(asearch -> atom_model), & atom_level, & spec_level))
1673 {
1674 gboolean append = FALSE;
1675 gboolean dothat = TRUE;
1676 k = 0;
1677 while (dothat)
1678 {
1679 gtk_tree_model_get (GTK_TREE_MODEL(asearch -> atom_model), & atom_level, IDCOL, & k, -1);
1680 if (k > j)
1681 {
1682 dothat = FALSE;
1683 }
1684 else
1685 {
1686 dothat = gtk_tree_model_iter_next (GTK_TREE_MODEL(asearch -> atom_model), & atom_level);
1687 append = TRUE;
1688 }
1689 }
1690 gtk_tree_store_insert_before (asearch -> atom_model, & new_level, & spec_level, (append) ? NULL : & atom_level);
1691 append_to_model (& new_level, asearch, is_object, l, j, this_proj);
1692 }
1693 }
1694 }
1695 }
1696 }
1697 asearch -> int_b = s_int_b;
1698}
1699
1708G_MODULE_EXPORT void set_id (GtkEntry * entry, gpointer data)
1709{
1710 atom_search * asearch = (atom_search *)data;
1711 project * this_proj = get_project_by_id(asearch -> proj);
1712 asearch -> int_b = (int )string_to_double ((gpointer)entry_get_text (GTK_ENTRY(asearch -> entry_b)));
1713 if (asearch -> int_b > 0 && asearch -> int_b < this_proj -> natomes+1)
1714 {
1715 asearch -> was_selected = FALSE;
1716 gtk_tree_model_foreach (GTK_TREE_MODEL(asearch -> atom_model), atom_is_in_model, asearch);
1717 int s = this_proj -> modelgl -> anim -> last -> img -> step;
1718 asearch -> int_b --;
1719 if (asearch -> was_selected && this_proj -> atoms[s][asearch -> int_b].sp == asearch -> spec_to_add)
1720 {
1721 widget_set_sensitive (asearch -> but_a, 0);
1722 widget_set_sensitive (asearch -> but_b, 1);
1723 set_image_from_icon_name (asearch -> img_b, APPLY);
1724 }
1725 else
1726 {
1727 if (this_proj -> atoms[s][asearch -> int_b].sp == asearch -> spec_to_add)
1728 {
1729 asearch -> num_to_add = asearch -> int_b;
1730 widget_set_sensitive (asearch -> but_a, 1);
1731 widget_set_sensitive (asearch -> but_b, 0);
1732 set_image_from_icon_name (asearch -> img_b, APPLY);
1733 }
1734 else
1735 {
1736 widget_set_sensitive (asearch -> but_a, 0);
1737 widget_set_sensitive (asearch -> but_b, 0);
1738 set_image_from_icon_name (asearch -> img_b, DIAL_ERROR);
1739 }
1740 }
1741 }
1742}
1743
1756void adjust_search_param (atom_search * asearch, project * this_proj, int a, int s, int c, gboolean status)
1757{
1758 int i, j, k, l, m;
1759 opengl_project_changed (asearch -> proj);
1760 i = (a < 0) ? 0 : a;
1761 for (j=i; j<this_proj -> natomes; j++)
1762 {
1763 k = this_proj -> atoms[0][j].pick[0];
1764 l = this_proj -> atoms[0][j].sp;
1765 m = this_proj -> atoms[0][j].label[0];
1766 if (s < 0 || l == s)
1767 {
1768 if (asearch -> status == 2 || asearch -> status == k)
1769 {
1770 if (a == j || a < 0)
1771 {
1772 switch (c)
1773 {
1774 case TOLAB:
1775#ifdef GTK4
1776 if (m != status) label_unlabel_this_atom (NULL, NULL, GINT_TO_POINTER(j));
1777#else
1778 if (m != status) label_unlabel_this_atom (NULL, GINT_TO_POINTER(j));
1779#endif
1780 break;
1781 default:
1782 if (asearch -> action != RANMOVE)
1783 {
1784 asearch -> todo[j] = status;
1785 if (asearch -> action == DISPL && asearch -> object) adjust_object_to_move (this_proj, asearch, 0, j);
1786 }
1787 else
1788 {
1789 switch (asearch -> todo[j])
1790 {
1791 case 0:
1792 asearch -> todo[j] += (c-TOLAB);
1793 break;
1794 case 1:
1795 if (c == TOPIC)
1796 {
1797 asearch -> todo[j] -= (c-TOLAB);
1798 }
1799 else
1800 {
1801 asearch -> todo[j] += (c-TOLAB);
1802 }
1803 break;
1804 case 2:
1805 if (c == TOPIC)
1806 {
1807 asearch -> todo[j] += (c-TOLAB);
1808 }
1809 else
1810 {
1811 asearch -> todo[j] -= (c-TOLAB);
1812 }
1813 break;
1814 case 3:
1815 asearch -> todo[j] -= (c-TOLAB);
1816 break;
1817 }
1818 if (asearch -> object) adjust_object_to_move (this_proj, asearch, 1, j);
1819 }
1820 break;
1821 }
1822 }
1823 if (a == j) break;
1824 }
1825 }
1826 }
1827}
1828
1829G_MODULE_EXPORT void set_spec_changed (GtkComboBox * box, gpointer data);
1830
1842void adjust_this_tree_branch (atom_search * asearch, project * this_proj, int oid, int sid, GtkTreeIter iter)
1843{
1844 int k, l, m, n, o, p, q;
1845 int status;
1846 int * to_label = NULL;
1847 int is_clone = (asearch -> action == 1) ? 1 : 0;
1848 int object = get_asearch_object (asearch);
1849 int filter = get_asearch_filter (asearch);
1850 gboolean doit;
1851 GtkTreeModel * model = (asearch -> action == INSERT) ? GTK_TREE_MODEL(asearch -> obj_model) : GTK_TREE_MODEL(asearch -> atom_model);
1852 opengl_project_changed (this_proj -> id);
1853 gtk_tree_model_get (model, & iter, oid, & status, -1);
1854 atom_in_selection * selected;
1855 if (asearch -> action < 2 && oid == TOPIC)
1856 {
1858 switch (filter)
1859 {
1860 case 0:
1861 selected_aspec = sid;
1862#ifdef GTK4
1863 select_unselect_atoms (NULL, NULL, & this_proj -> modelgl -> colorp[0][! status]);
1864#else
1865 select_unselect_atoms (NULL, & this_proj -> modelgl -> colorp[0][! status]);
1866#endif
1867 break;
1868 default:
1869 if (filter < 3)
1870 {
1871 k = this_proj -> modelgl -> selection_mode;
1872 this_proj -> modelgl -> selection_mode = object;
1873 }
1874 p = this_proj -> modelgl -> anim -> last -> img -> step;
1875 for (l=0; l<this_proj -> natomes; l++)
1876 {
1877 n = this_proj -> atoms[p][l].sp;
1878 o = this_proj -> atoms[p][l].coord[filter-1];
1879 doit = FALSE;
1880 if (filter == 1)
1881 {
1882 if (this_proj -> atoms[p][l].numv == sid && append (asearch, this_proj, l, n)) doit = TRUE;
1883 }
1884 else
1885 {
1886 if (filter == 2)
1887 {
1888 for (m=0; m<n; m++)
1889 {
1890 o += this_proj -> coord -> ntg[1][m];
1891 }
1892 }
1893 if (o == sid && append (asearch, this_proj, l, n)) doit = TRUE;
1894 }
1895 if (doit)
1896 {
1897 o = get_to_be_selected (this_proj -> modelgl);
1898#ifdef GTK4
1899 if (this_proj -> atoms[p][l].pick[o] != status)
1900 {
1901 select_unselect_this_atom (NULL, NULL, GINT_TO_POINTER(l));
1902 }
1903 select_unselect_this_atom (NULL, NULL, GINT_TO_POINTER(l));
1904#else
1905 if (this_proj -> atoms[p][l].pick[o] != status)
1906 {
1907 select_unselect_this_atom (NULL, GINT_TO_POINTER(l));
1908 }
1909 select_unselect_this_atom (NULL, GINT_TO_POINTER(l));
1910#endif
1911 }
1912 }
1913 if (filter < 3) this_proj -> modelgl -> selection_mode = k;
1914 break;
1915 }
1916 }
1917 else
1918 {
1919 if (asearch -> action != INSERT)
1920 {
1921 if (oid == TOLAB)
1922 {
1923 if (asearch -> pointer[0].c == 8)
1924 {
1925 preserve_ogl_selection (this_proj -> modelgl);
1926 this_proj -> modelgl -> cell_win -> cut_this_slab = TRUE;
1927 save_all_selections (this_proj -> modelgl, 0);
1928 create_slab_lists (this_proj);
1929 update_all_selections (this_proj -> modelgl, 0);
1930 q = 0;
1931 if (this_proj -> modelgl -> anim -> last -> img -> selected[0] -> selected)
1932 {
1933 to_label = allocint (this_proj -> modelgl -> anim -> last -> img -> selected[0] -> selected);
1934 }
1935 }
1936 p = this_proj -> modelgl -> anim -> last -> img -> step;
1937 switch (filter)
1938 {
1939 case 0:
1940 if (asearch -> pointer[0].c == 8)
1941 {
1942 if (this_proj -> modelgl -> anim -> last -> img -> selected[0] -> selected)
1943 {
1944 selected = this_proj -> modelgl -> anim -> last -> img -> selected[0] -> first;
1945 while (selected)
1946 {
1947 if (selected -> sp == sid)
1948 {
1949 to_label[q] = selected -> id;
1950 q ++;
1951 }
1952 selected = selected -> next;
1953 }
1954 }
1955 }
1956 else
1957 {
1958#ifdef GTK4
1959 show_hide_labels (NULL, NULL, & this_proj -> modelgl -> colorp[is_clone][sid]);
1960#else
1961 // GTK3 Menu Action To Check
1962 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)this_proj -> modelgl -> ogl_lab[is_clone][sid], ! status);
1963 show_hide_labels (this_proj -> modelgl -> ogl_lab[is_clone][sid], & this_proj -> modelgl -> colorp[is_clone][sid]);
1964#endif
1965 }
1966 break;
1967 default:
1968 if (filter < 3)
1969 {
1970 k = this_proj -> modelgl -> selection_mode;
1971 this_proj -> modelgl -> selection_mode = object;
1972 }
1973 for (l=0; l<this_proj -> natomes; l++)
1974 {
1975 n = this_proj -> atoms[p][l].sp;
1976 o = this_proj -> atoms[p][l].coord[filter-1];
1977 doit = FALSE;
1978 if (filter == 1)
1979 {
1980 if (this_proj -> atoms[p][l].numv == sid && append (asearch, this_proj, l, n)) doit = TRUE;
1981 }
1982 else if (filter == 2 || filter == 4)
1983 {
1984 if (filter == 2)
1985 {
1986 for (m=0; m<n; m++)
1987 {
1988 o += this_proj -> coord -> ntg[1][m];
1989 }
1990 }
1991 if (o == sid && append (asearch, this_proj, l, n)) doit = TRUE;
1992 }
1993 else if (filter == 3)
1994 {
1995 if (asearch -> mode && object)
1996 {
1997 doit = TRUE;
1998 }
1999 else
2000 {
2001 if (o == sid && append (asearch, this_proj, l, n)) doit = TRUE;
2002 }
2003 }
2004 if (doit)
2005 {
2006 if (asearch -> pointer[0].c == 8)
2007 {
2008 if (this_proj -> modelgl -> anim -> last -> img -> selected[0] -> selected)
2009 {
2010 selected = this_proj -> modelgl -> anim -> last -> img -> selected[0] -> first;
2011 while (selected)
2012 {
2013 if (selected -> id == l)
2014 {
2015 to_label[q] = l;
2016 q ++;
2017 }
2018 selected = selected -> next;
2019 }
2020 }
2021 }
2022 else
2023 {
2024 this_proj -> atoms[p][l].label[0] = status;
2025#ifdef GTK4
2026 label_unlabel_this_atom (NULL, NULL, GINT_TO_POINTER(l));
2027#else
2028 label_unlabel_this_atom (NULL, GINT_TO_POINTER(l));
2029#endif
2030 }
2031 }
2032 }
2033 if (filter < 3) this_proj -> modelgl -> selection_mode = k;
2034 break;
2035 }
2036
2037 if (asearch -> pointer[0].c == 8)
2038 {
2039 restore_ogl_selection (this_proj -> modelgl);
2040 if (q)
2041 {
2042 for (l=0; l<q; l++)
2043 {
2044 m = to_label[l];
2045 this_proj -> atoms[0][m].label[0] = ! status;
2046 this_proj -> atoms[0][m].label[1] = ! status;
2047 }
2048 g_free (to_label);
2049 }
2050 this_proj -> modelgl -> cell_win -> cut_this_slab = FALSE;
2051 this_proj -> modelgl -> create_shaders[SLABS] = TRUE;
2052 gtk_tree_store_set (asearch -> atom_model, & iter, TOLAB, ! status, -1);
2053 }
2054 }
2055 else
2056 {
2057 if (asearch -> passivating || (object && filter > 2))
2058 {
2059 if (asearch -> action == RANMOVE)
2060 {
2061 if (! status)
2062 {
2063 asearch -> todo[sid] += (oid-TOLAB);
2064 }
2065 else
2066 {
2067 asearch -> todo[sid] -= (oid-TOLAB);
2068 }
2069 if (object && ! asearch -> passivating) adjust_object_to_move (this_proj, asearch, 1, sid);
2070 }
2071 else
2072 {
2073 asearch -> todo[sid] = ! status;
2074 if (asearch -> action == DISPL)
2075 {
2076 if (object && ! asearch -> passivating) adjust_object_to_move (this_proj, asearch, 0, sid);
2077 motion_to_zero (asearch);
2078 }
2079 }
2080 }
2081 else if (! asearch -> mode)
2082 {
2083 switch (filter)
2084 {
2085 case 0:
2086 for (l=0; l<this_proj -> natomes; l++)
2087 {
2088 n = this_proj -> atoms[0][l].sp;
2089 if (n == sid && append (asearch, this_proj, l, n))
2090 {
2091 if (asearch -> action == RANMOVE)
2092 {
2093 if (! status)
2094 {
2095 asearch -> todo[l] += (oid-TOLAB);
2096 }
2097 else
2098 {
2099 asearch -> todo[l] -= (oid-TOLAB);
2100 }
2101 if (object) adjust_object_to_move (this_proj, asearch, 1, l);
2102 }
2103 else
2104 {
2105 asearch -> todo[l] = ! status;
2106 if (asearch -> action == DISPL && object) adjust_object_to_move (this_proj, asearch, 0, l);
2107 }
2108 }
2109 }
2110 break;
2111 case 1:
2112 for (l=0; l<this_proj -> natomes; l++)
2113 {
2114 n = this_proj -> atoms[0][l].sp;
2115 if (this_proj -> atoms[0][l].numv == sid && append (asearch, this_proj, l, n))
2116 {
2117 if (asearch -> action == RANMOVE)
2118 {
2119 if (! status)
2120 {
2121 asearch -> todo[l] += (oid-TOLAB);
2122 }
2123 else
2124 {
2125 asearch -> todo[l] -= (oid-TOLAB);
2126 }
2127 if (object) adjust_object_to_move (this_proj, asearch, 1, l);
2128 }
2129 else
2130 {
2131 asearch -> todo[l] = ! status;
2132 if (asearch -> action == DISPL && object) adjust_object_to_move (this_proj, asearch, 0, l);
2133 }
2134 }
2135 }
2136 break;
2137 case 2:
2138 for (l=0; l<this_proj -> natomes; l++)
2139 {
2140 n = this_proj -> atoms[0][l].sp;
2141 o = this_proj -> atoms[0][l].coord[filter-1];
2142 for (m=0; m<n; m++)
2143 {
2144 o += this_proj -> coord -> ntg[1][m];
2145 }
2146 if (o == sid && append (asearch, this_proj, l, n))
2147 {
2148 if (asearch -> action == RANMOVE)
2149 {
2150 if (! status)
2151 {
2152 asearch -> todo[l] += (oid-TOLAB);
2153 }
2154 else
2155 {
2156 asearch -> todo[l] -= (oid-TOLAB);
2157 }
2158 if (object) adjust_object_to_move (this_proj, asearch, 1, l);
2159 }
2160 else
2161 {
2162 asearch -> todo[l] = ! status;
2163 if (asearch -> action == DISPL && object) adjust_object_to_move (this_proj, asearch, 0, l);
2164 }
2165 }
2166 }
2167 break;
2168 default:
2169 for (l=0; l<this_proj -> natomes; l++)
2170 {
2171 n = this_proj -> atoms[0][l].sp;
2172 o = this_proj -> atoms[0][l].coord[filter-1];
2173 if (o == sid && append (asearch, this_proj, l, n))
2174 {
2175 if (asearch -> action == RANMOVE)
2176 {
2177 if (! status)
2178 {
2179 asearch -> todo[l] += (oid-TOLAB);
2180 }
2181 else
2182 {
2183 asearch -> todo[l] -= (oid-TOLAB);
2184 }
2185 if (object) adjust_object_to_move (this_proj, asearch, 1, l);
2186 }
2187 else
2188 {
2189 asearch -> todo[l] = ! status;
2190 if (asearch -> action == DISPL && object) adjust_object_to_move (this_proj, asearch, 0, l);
2191 }
2192 }
2193 }
2194 break;
2195 }
2196 }
2197 }
2198 }
2199 else
2200 {
2201 for (k=0; k<asearch -> in_selection; k++)
2202 {
2203 asearch -> todo[k] = ! status;
2204 }
2205 }
2206 }
2207 switch (oid)
2208 {
2209 case TOLAB:
2210 if (asearch -> action == INSERT) asearch -> pick[sid] = ! status;
2211 asearch -> lab[sid] = ! status;
2212 break;
2213 default:
2214 if (asearch -> action == RANMOVE)
2215 {
2216 if (! status)
2217 {
2218 asearch -> pick[sid] += (oid-TOLAB);
2219 }
2220 else
2221 {
2222 asearch -> pick[sid] -= (oid-TOLAB);
2223 }
2224 }
2225 else
2226 {
2227 asearch -> pick[sid] = ! status;
2228 }
2229 break;
2230 }
2231 if (asearch -> todo_size < 10000 || asearch -> passivating || (object == 2 && filter > 2)) update_search_tree (asearch);
2232}
2233
2246void adjust_this_tree_leaf (atom_search * asearch, project * this_proj, int oid, int aid, int new_status, GtkTreeIter iter)
2247{
2248 int status;
2249 int k, l, p;
2250 opengl_project_changed (this_proj -> id);
2251 int sel = this_proj -> modelgl -> selection_mode;
2252 int is_clone = (asearch -> action == 1) ? 1 : 0;
2253 int object = (asearch -> object) ? 1 : 0;
2254 this_proj -> modelgl -> selection_mode = object;
2255 p = this_proj -> modelgl -> anim -> last -> img -> step;
2256 // For atom i
2257 if (oid == TOLAB)
2258 {
2259 if (asearch -> action == INSERT)
2260 {
2261 if (asearch -> todo[aid] != new_status || new_status < 0)
2262 {
2263 status = ! asearch -> todo[aid];
2264 asearch -> todo[aid] = status;
2265 }
2266 }
2267 else if (this_proj -> atoms[p][aid].label[is_clone] != new_status || new_status < 0)
2268 {
2269#ifdef GTK4
2270 label_unlabel_this_atom (NULL, NULL, GINT_TO_POINTER(aid));
2271#else
2272 label_unlabel_this_atom (NULL, GINT_TO_POINTER(aid));
2273#endif
2274 status = this_proj -> atoms[p][aid].label[is_clone];
2275 }
2276 }
2277 else
2278 {
2279 if (asearch -> action < 2)
2280 {
2281 if (this_proj -> atoms[p][aid].pick[0] != new_status || new_status < 0)
2282 {
2283 // selected_status = ! this_proj -> atoms[p][aid].pick[get_to_be_selected (this_proj -> modelgl)];
2284 selected_status = ! this_proj -> atoms[p][aid].pick[0];
2285#ifdef GTK4
2286 select_unselect_this_atom (NULL, NULL, GINT_TO_POINTER(aid));
2287#else
2288 select_unselect_this_atom (NULL, GINT_TO_POINTER(aid));
2289#endif
2290 status = this_proj -> atoms[p][aid].pick[0];
2291 }
2292 }
2293 else
2294 {
2295 if (asearch -> todo[aid] != new_status || new_status < 0)
2296 {
2297 status = ! asearch -> todo[aid];
2298 adjust_search_param (asearch, this_proj, aid, this_proj -> atoms[p][aid].sp, oid, status);
2299 }
2300 }
2301 }
2302 status = (new_status < 0) ? status : new_status;
2303 if (asearch -> action == RANMOVE && oid != TOLAB)
2304 {
2305 k = (asearch -> todo[aid] == 1 || asearch -> todo[aid] == 3) ? 1 : 0;
2306 l = (asearch -> todo[aid] == 2 || asearch -> todo[aid] == 3) ? 1 : 0;
2307 // Check 'for all'
2308 gtk_tree_store_set (asearch -> atom_model, & iter, TOPIC, k, -1);
2309 if (object) gtk_tree_store_set (asearch -> atom_model, & iter, TOPIC+1, l, -1);
2310 }
2311 else if (asearch -> action == INSERT)
2312 {
2313 gtk_list_store_set (asearch -> obj_model, & iter, oid, status, -1);
2314 }
2315 else
2316 {
2317 if (asearch -> action == DISPL && oid != TOLAB) motion_to_zero (asearch);
2318 gtk_tree_store_set (asearch -> atom_model, & iter, oid, status, -1);
2319 }
2320 this_proj -> modelgl -> selection_mode = sel;
2321 check_all_trees (this_proj);
2322}
2323
2333G_MODULE_EXPORT void select_atom (GtkCellRendererToggle * cell_renderer, gchar * string_path, gpointer data)
2334{
2335 int i, j, k;
2336 GtkTreeIter iter;
2337 tint * dat = (tint *)data;
2338 project * this_proj = get_project_by_id(dat -> a);
2339 atom_search * asearch = this_proj -> modelgl -> search_widg[dat -> c];
2340 GtkTreePath * path = gtk_tree_path_new_from_string (string_path);
2341 GtkTreeModel * model = (asearch -> action == INSERT) ? GTK_TREE_MODEL(asearch -> obj_model) : GTK_TREE_MODEL(asearch -> atom_model);
2342 gtk_tree_model_get_iter (model, & iter, path);
2343 gtk_tree_model_get (model, & iter, IDCOL, & i, -1);
2344 check_label = FALSE;
2345 if (this_proj -> modelgl -> atom_win)
2346 {
2347 this_proj -> modelgl -> atom_win -> rebuilt[(asearch -> action == RANMOVE) ? 1 : 0] = FALSE;
2348 }
2349 if (i > 0)
2350 {
2351 i --;
2352 // For atom i
2353 adjust_this_tree_leaf (asearch, this_proj, dat -> b, i, -1, iter);
2354 }
2355 else
2356 {
2357 // For spec i
2358 if (asearch -> todo_size >= 10000 && ! asearch -> passivating)
2359 {
2360 GtkTreeIter child;
2361 gtk_tree_model_get (GTK_TREE_MODEL(asearch -> atom_model), & iter, dat -> b, & j, -1);
2362 gtk_tree_store_set (asearch -> atom_model, & iter, dat -> b, ! j, -1);
2363 if (gtk_tree_model_iter_children (GTK_TREE_MODEL(asearch -> atom_model), & child, & iter))
2364 {
2365 gboolean dothis = TRUE;
2366 while (dothis)
2367 {
2368 gtk_tree_model_get (GTK_TREE_MODEL(asearch -> atom_model), & child, IDCOL, & k, -1);
2369 k --;
2370 adjust_this_tree_leaf (asearch, this_proj, dat -> b, k, ! j, child);
2371 dothis = gtk_tree_model_iter_next (GTK_TREE_MODEL(asearch -> atom_model), & child);
2372 }
2373 }
2374 }
2375 else
2376 {
2377 adjust_this_tree_branch (asearch, this_proj, dat -> b, abs(i) - 1, iter);
2378 }
2379 }
2380 if (asearch -> action == DISPL) check_motion_interactors (this_proj, asearch);
2381 check_label = TRUE;
2382 this_proj -> modelgl -> labelled = check_label_numbers (this_proj, 2);
2383 update (this_proj -> modelgl);
2384}
2385
2396int get_selected_object_id (gboolean visible, int p, gchar * str, atom_search * asearch)
2397{
2398 int i, j;
2399 gchar * word, * name;
2400 for (i = 1; mol[i].type || mol[i].object; i++)
2401 {
2402 if (mol[i].object != NULL)
2403 {
2404 if (g_strcmp0 (mol[i].object, str) == 0)
2405 {
2406 if (i < 9)
2407 {
2408 return (int) mol[i].Z;
2409 }
2410 else if (i == 9)
2411 {
2412 return get_atom_id_from_periodic_table (asearch);
2413 }
2414 else if (i > 10 && i < 17)
2415 {
2416 return insert_this_project_from_lib (i-11, visible, get_project_by_id(p), asearch);
2417 }
2418 else if (i == 17)
2419 {
2420 return select_from_library (visible, get_project_by_id(p), asearch);
2421 }
2422 }
2423 }
2424 }
2425 for (i=0; i<nprojects; i++)
2426 {
2427 name = g_strdup_printf ("%s (%d)", get_project_by_id(i) -> name, i+1);
2428 for (j=0; j<3; j++)
2429 {
2430 word = g_strdup_printf ("%s in %s", action_atoms[j], name);
2431 if (g_strcmp0 (word, str) == 0)
2432 {
2433 g_free (word);
2434 g_free (name);
2435 get_project_by_id(p) -> modelgl -> other_status = j;
2437 }
2438 else
2439 {
2440 g_free (word);
2441 }
2442 }
2443 g_free (name);
2444 }
2445 if (g_strcmp0 ("Copied data", str) == 0)
2446 {
2447 return FROM_DATA;
2448 }
2449 if (g_strcmp0 ("Empty position", str) == 0) return 120;
2450 return 0;
2451}
2452
2463void adjust_data_model_to_replace (project * this_proj, atom_search * asearch, int sid, int vid)
2464{
2465 int i, j, k, l;
2466 int filter = get_asearch_filter (asearch);
2467 switch (filter)
2468 {
2469 case 0:
2470 for (i=0; i<this_proj -> natomes; i++)
2471 {
2472 if (this_proj -> atoms[0][i].sp == sid && append (asearch, this_proj, i, this_proj -> atoms[0][i].sp))
2473 {
2474 to_insert_in_project (vid, i, this_proj, asearch, TRUE);
2475 }
2476 }
2477 break;
2478 case 1:
2479 for (i=0; i<this_proj -> natomes; i++)
2480 {
2481 if (this_proj -> atoms[0][i].numv == sid)
2482 {
2483 j = this_proj -> atoms[0][i].sp;
2484 if (append (asearch, this_proj, i, j))
2485 {
2486 to_insert_in_project (vid, i, this_proj, asearch, TRUE);
2487 }
2488 }
2489 }
2490 break;
2491 case 2:
2492 for (i=0; i<this_proj -> natomes; i++)
2493 {
2494 j = this_proj -> atoms[0][i].sp;
2495 k = this_proj -> atoms[0][i].coord[1];
2496 for (l=0; l<j; l++) k += this_proj -> coord -> ntg[1][l];
2497 if (k == sid && append (asearch, this_proj, i, j))
2498 {
2499 to_insert_in_project (vid, i, this_proj, asearch, TRUE);
2500 }
2501 }
2502 break;
2503 default:
2504 for (i=0; i<this_proj -> natomes; i++)
2505 {
2506 j = this_proj -> atoms[0][i].sp;
2507 k = this_proj -> atoms[0][i].coord[filter-1];
2508 if (k == sid && append (asearch, this_proj, i, j))
2509 {
2510 to_insert_in_project (vid, i, this_proj, asearch, TRUE);
2511 }
2512 }
2513 break;
2514 }
2515}
2516
2527G_MODULE_EXPORT void changed_action_renderer (GtkCellRendererCombo * combo, gchar * path_string, GtkTreeIter * iter, gpointer data)
2528{
2529 tint * dat = (tint *)data;
2530 project * this_proj = get_project_by_id(dat -> a);
2531 int h, i, j, k;
2532 atom_search * asearch = this_proj -> modelgl -> search_widg[dat -> c];
2533 GValue val = {0, };
2534 GObject * cmodel;
2535 g_object_get (combo, "model", & cmodel, NULL);
2536 gtk_tree_model_get_value ((GtkTreeModel *)cmodel, iter, 0, & val);
2537 GtkTreeIter child;
2538 gboolean dothis;
2539 GtkTreeModel * model = (asearch -> action == INSERT) ? GTK_TREE_MODEL(asearch -> obj_model) : GTK_TREE_MODEL(asearch -> atom_model);
2540 if (gtk_tree_model_get_iter_from_string (model, iter, path_string))
2541 {
2542 gtk_tree_model_get (model, iter, IDCOL, & h, -1);
2543 gchar * str = g_strdup_printf ("%s", (char *)g_value_get_string (& val));
2544 i = get_selected_object_id (TRUE, this_proj -> id, str, asearch);
2545 g_free (str);
2546 int object = get_asearch_object (asearch);
2547 int filter = get_asearch_filter (asearch);
2548 k = (asearch -> pointer[0].c == 3) ? 0 : (asearch -> pointer[0].c == 5) ? 1 : 3;
2549 if (h > 0 || (object && ! asearch -> passivating && filter > 2) || asearch -> passivating || asearch -> mode)
2550 {
2551 // Single atom or object
2552 if (i)
2553 {
2554 j = (asearch -> mode) ? h - 2 : abs(h) - 1;
2555 to_insert_in_project (i, j, this_proj, asearch, TRUE);
2556 str = (asearch -> mode) ? g_strdup_printf ("%s", get_atomic_object_by_origin(this_proj -> modelgl -> atom_win -> to_be_inserted[k], j, 0) -> name) : g_strdup_printf ("For all: %s", get_atomic_object_by_origin(this_proj -> modelgl -> atom_win -> to_be_inserted[k], j, 0) -> name);
2557 gtk_tree_store_set (asearch -> atom_model, iter, TOPIC+1, str, -1);
2558 g_free (str);
2559 }
2560 else
2561 {
2562 gtk_tree_store_set (asearch -> atom_model, iter, TOPIC+1, (h > 0) ? "Select ..." : "Select for all ...", -1);
2563 }
2564 }
2565 else
2566 {
2567 // The entire species
2568 if (i)
2569 {
2570 if (! asearch -> passivating && this_proj -> natomes >= 10000)
2571 {
2572 if (gtk_tree_model_iter_children (GTK_TREE_MODEL(asearch -> atom_model), & child, iter))
2573 {
2574 dothis = TRUE;
2575 while (dothis)
2576 {
2577 gtk_tree_model_get (GTK_TREE_MODEL(asearch -> atom_model), & child, IDCOL, & j, -1);
2578 j --;
2579 to_insert_in_project (i, j, this_proj, asearch, TRUE);
2580 gtk_tree_store_set (asearch -> atom_model, & child, TOPIC+1, get_atomic_object_by_origin(this_proj -> modelgl -> atom_win -> to_be_inserted[k], j, 0) -> name, -1);
2581 dothis = gtk_tree_model_iter_next (GTK_TREE_MODEL(asearch -> atom_model), & child);
2582 }
2583 }
2584 str = g_strdup_printf ("For all: %s", get_atomic_object_by_origin(this_proj -> modelgl -> atom_win -> to_be_inserted[k], j, 0) -> name);
2585 gtk_tree_store_set (asearch -> atom_model, iter, TOPIC+1, str, -1);
2586 g_free (str);
2587 }
2588 else
2589 {
2590 adjust_data_model_to_replace (this_proj, asearch, abs(h)-1, i);
2591 }
2592 }
2593 else
2594 {
2595 if (! asearch -> passivating && this_proj -> natomes >= 10000)
2596 {
2597 gtk_tree_store_set (asearch -> atom_model, iter, 5, "Select for all ...", -1);
2598 if (gtk_tree_model_iter_children (GTK_TREE_MODEL(asearch -> atom_model), & child, iter))
2599 {
2600 dothis = TRUE;
2601 while (dothis)
2602 {
2603 gtk_tree_store_set (asearch -> atom_model, & child, TOPIC+1, "Select ...", -1);
2604 dothis = gtk_tree_model_iter_next (GTK_TREE_MODEL(asearch -> atom_model), & child);
2605 }
2606 }
2607 }
2608 else
2609 {
2610 gtk_tree_store_set (asearch -> atom_model, iter, 5, "Select ...", -1);
2611 }
2612 }
2613 }
2614 if (update_this_search(asearch)) update_search_tree (asearch);
2615 }
2616}
2617
2626GtkTreeModel * replace_combo_tree (gboolean insert, int proj)
2627{
2628 GtkTreeIter iter, iter2, iter3;
2629 GtkTreeStore *store;
2630 int i, j;
2631 gchar * name, * word;
2632
2633 store = gtk_tree_store_new (1, G_TYPE_STRING);
2634
2635 if (insert)
2636 {
2637 gtk_tree_store_append (store, & iter, NULL);
2638 gtk_tree_store_set (store, & iter, 0, "Select ...", -1);
2639 }
2640 for (i=0; mol[i].type || mol[i].object; i++)
2641 {
2642 if (mol[i].type)
2643 {
2644 gtk_tree_store_append (store, & iter, NULL);
2645 gtk_tree_store_set (store, & iter, 0, mol[i].type, -1);
2646 }
2647 else if (mol[i].object)
2648 {
2649 gtk_tree_store_append (store, & iter2, & iter);
2650 gtk_tree_store_set (store, & iter2, 0, mol[i].object, -1);
2651 }
2652 }
2653 gboolean doit = FALSE;
2654 for (i=0; i<nprojects; i++)
2655 {
2656 if (get_project_by_id(i) -> steps == 1 && get_project_by_id(i) -> natomes)
2657 {
2658 doit = TRUE;
2659 break;
2660 }
2661 }
2662 if (doit)
2663 {
2664 gtk_tree_store_append (store, & iter, NULL);
2665 gtk_tree_store_set (store, & iter, 0, "Import from project", -1);
2666 for (i=0; i<nprojects; i++)
2667 {
2668 if (get_project_by_id(i) -> steps == 1 && get_project_by_id(i) -> natomes)
2669 {
2670 gtk_tree_store_append (store, & iter2, & iter);
2671 name = g_strdup_printf ("%s (%d)", get_project_by_id(i) -> name, i+1);
2672 gtk_tree_store_set (store, & iter2, 0, name, -1);
2673 for (j=0; j<3; j++)
2674 {
2675 gtk_tree_store_append (store, & iter3, & iter2);
2676 word = g_strdup_printf ("%s in %s", action_atoms[j], name);
2677 gtk_tree_store_set (store, & iter3, 0, word, -1);
2678 g_free (word);
2679 }
2680 g_free (name);
2681 }
2682 }
2683 }
2684 if (copied_object)
2685 {
2686 gtk_tree_store_append (store, &iter, NULL);
2687 gtk_tree_store_set (store, & iter, 0, "Copied data", -1);
2688 }
2689 if (get_project_by_id(proj) -> modelgl)
2690 {
2691 if (get_project_by_id(proj) -> modelgl -> builder_win)
2692 {
2693 gtk_tree_store_append (store, &iter, NULL);
2694 gtk_tree_store_set (store, & iter, 0, "Empty position", -1);
2695 }
2696 }
2697 return GTK_TREE_MODEL (store);
2698}
2699
2711void search_set_visible (GtkTreeViewColumn * col, GtkCellRenderer * renderer, GtkTreeModel * mod, GtkTreeIter * iter, gpointer data)
2712{
2713 int i, j;
2714 i = GPOINTER_TO_INT(data);
2715 i ++;
2716 gtk_tree_model_get (mod, iter, IDCOL, & j, -1);
2717 gboolean vis = (j < 0 && i == 2) ? FALSE : TRUE;
2718 gtk_cell_renderer_set_visible (renderer, vis);
2719 if (vis && (i < TOLAB || i > TOPIC))
2720 {
2721 gchar * str = NULL;
2722 gtk_tree_model_get (mod, iter, i, & str, -1);
2723 g_object_set (renderer, "markup", str, NULL, NULL);
2724 g_free (str);
2725 }
2726}
2727
2730
2739G_MODULE_EXPORT void set_occupancy (GtkEntry * res, gpointer data)
2740{
2741 const gchar * m = entry_get_text (res);
2742 double v = string_to_double ((gpointer)m);
2743 atomic_object * object = (atomic_object *)data;
2744 if (v > 0.0 && v<= 1.0)
2745 {
2746 object -> occ = v;
2747 }
2748 update_entry_double (res, object -> occ);
2749}
2750
2759G_MODULE_EXPORT void set_i_coord (GtkEntry * res, gpointer data)
2760{
2761 const gchar * m = entry_get_text (res);
2762 double v = string_to_double ((gpointer)m);
2763 int ax = GPOINTER_TO_INT (data);
2764 project * this_proj = get_project_by_id (csearch -> proj);
2765 int oid = (csearch -> pointer[0].c == 5) ? 1 : 2;
2766 atomic_object * object = get_atomic_object_by_origin (this_proj -> modelgl -> atom_win -> to_be_inserted[oid], 0, atom_to_edit+1);
2767 object -> baryc[ax] = v;
2768 update_entry_double (res, object -> baryc[ax]);
2769}
2770
2779G_MODULE_EXPORT void set_max_msd (GtkEntry * res, gpointer data)
2780{
2781 const gchar * m = entry_get_text (res);
2782 double v = string_to_double ((gpointer)m);
2783 int ax = GPOINTER_TO_INT (data);
2784 project * this_proj = get_project_by_id (csearch -> proj);
2785 if (! (v < 0.0))
2786 {
2787 if (ax > 0)
2788 {
2789 if (this_proj -> modelgl -> atom_win -> msd[ax-1] != v) csearch -> pick[this_proj -> atoms[0][ax-1].sp] = 0;
2790 this_proj -> modelgl -> atom_win -> msd[ax-1] = v;
2791 }
2792 else
2793 {
2794 ax = -ax-1;
2795 this_proj -> modelgl -> atom_win -> msd_all[ax] = v;
2796 if (! csearch -> passivating)
2797 {
2798 int object = get_asearch_object (csearch);
2800 int i, j, k, l;
2801 switch (filter)
2802 {
2803 case 0:
2804 for (i=0; i<this_proj -> natomes; i++)
2805 {
2806 if (this_proj -> atoms[0][i].sp == ax) this_proj -> modelgl -> atom_win -> msd[i] = v;
2807 }
2808 break;
2809 case 1:
2810 for (i=0; i<this_proj -> natomes; i++)
2811 {
2812 j = this_proj -> atoms[0][i].sp;
2813 if (this_proj -> atoms[0][i].numv == ax) this_proj -> modelgl -> atom_win -> msd[i] = v;
2814 }
2815 break;
2816 case 2:
2817 for (i=0; i<this_proj -> natomes; i++)
2818 {
2819 j = this_proj -> atoms[0][i].sp;
2820 k = this_proj -> atoms[0][i].coord[filter-1];
2821 for (l=0; l<j; l++) k += this_proj -> coord -> ntg[1][l];
2822 if (k == ax) this_proj -> modelgl -> atom_win -> msd[i] = v;
2823 }
2824 break;
2825 default:
2826 if (! object)
2827 {
2828 for (i=0; i<this_proj -> natomes; i++)
2829 {
2830 j = this_proj -> atoms[0][i].coord[filter-1];
2831 if (j == ax) this_proj -> modelgl -> atom_win -> msd[i] = v;
2832 }
2833 }
2834 break;
2835 }
2836 }
2837 }
2839 }
2840 else
2841 {
2842 //show_error ("MSD<sub>max</sub> must be > 0.0 !", 1, this_proj -> modelgl -> atom_win -> win);
2843 if (ax > 0)
2844 {
2845 v = this_proj -> modelgl -> atom_win -> msd[ax-1];
2846 }
2847 else
2848 {
2849 v = this_proj -> modelgl -> atom_win -> msd_all[-ax-1];
2850 }
2852 }
2853}
2854
2856
2865G_MODULE_EXPORT void set_max_action (GtkEntry * res, gpointer data)
2866{
2867 const gchar * m = entry_get_text (res);
2868 int v = (int)string_to_double ((gpointer)m);
2869 int ax = GPOINTER_TO_INT (data);
2870 if (v > -1 && v <= max_random)
2871 {
2872 csearch -> todo[-ax-1] = v;
2873 }
2874 update_entry_int (res, csearch -> todo[-ax-1]);
2875}
2876
2886void get_coord_iter_and_edit (gchar * path_string, gpointer data, GtkWidget * widg)
2887{
2888 tint * cid = (tint *)data;
2889 project * this_proj = get_project_by_id (cid -> a);
2890 csearch = this_proj -> modelgl -> search_widg[cid -> c];
2891 GtkTreeIter iter;
2892 GtkTreeModel * model = (csearch -> action == INSERT) ? GTK_TREE_MODEL(csearch -> obj_model) : GTK_TREE_MODEL(csearch -> atom_model);
2893 if (gtk_tree_model_get_iter (model, & iter, gtk_tree_path_new_from_string (path_string)))
2894 {
2895 int h, i, j, k, l;
2896 gtk_tree_model_get (model, & iter, IDCOL, & h, -1);
2897 if (h > 0 || csearch -> action == REPLACE || csearch -> action == REMOVE || csearch -> action == RANMOVE)
2898 {
2899
2900 atom_to_edit = h-1;
2901 GtkWidget * win = gtk_dialog_new ();
2902 if (this_proj -> modelgl -> builder_win)
2903 {
2904 gtk_window_set_transient_for (GTK_WINDOW (win), GTK_WINDOW(this_proj -> modelgl -> builder_win -> win));
2905 }
2906 else
2907 {
2908 gtk_window_set_transient_for (GTK_WINDOW (win), GTK_WINDOW(this_proj -> modelgl -> atom_win -> win));
2909 }
2910 gtk_window_set_resizable (GTK_WINDOW (win), FALSE);
2911 gchar * str;
2912 atomic_object * iobj;
2913 gchar * obj[5]={"atom(s)", "total coordination(s)", "partial coordination(s)", "in fragment", "in molecule"};
2914 gchar * act[2]={"Replace", "Remove"};
2915 int object = get_asearch_object (csearch);
2917 switch (csearch -> action)
2918 {
2919 case REPLACE:
2920 str = g_strdup_printf ("Replace %s randomly", obj[(object) ? filter : 0]);
2921 break;
2922 case REMOVE:
2923 str = g_strdup_printf ("Remove %s randomly", obj[(object) ? filter : 0]);
2924 break;
2925 case RANMOVE:
2926 str = g_strdup_printf ("Maximum Mean Square Displacement");
2927 break;
2928 default:
2929 i = (csearch -> pointer[0].c == 5) ? 1 : 2;
2930 iobj = get_atomic_object_by_origin (this_proj -> modelgl -> atom_win -> to_be_inserted[i], 0, atom_to_edit+1);
2931 if (cid -> b - TOLAB)
2932 {
2933 str = g_strdup_printf ("Site occupancy for %s", prepare_for_title(iobj -> name));
2934 }
2935 else
2936 {
2937 str = g_strdup_printf ("Insert %s at", prepare_for_title(iobj -> name));
2938 }
2939 break;
2940 }
2941 gtk_window_set_title (GTK_WINDOW(win), str);
2942 g_free (str);
2943 gtk_window_set_modal (GTK_WINDOW (win), TRUE);
2944 GtkWidget * vbox = dialog_get_content_area (win);
2945 GtkWidget * hbox;
2946 GtkWidget * entry;
2947 gchar * axis[3]={"x", "y", "z"};
2948 gchar * nran = NULL;
2949 switch (csearch -> action)
2950 {
2951 case INSERT:
2952 if (cid -> b - TOLAB && csearch -> pointer[0].c == 7)
2953 {
2954 hbox = create_hbox (5);
2955 str = g_strdup_printf ("Occupancy= ");
2956 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label(str, 100, -1, 0.0, 0.5), FALSE, FALSE, 0);
2957 g_free (str);
2958 entry = create_entry (G_CALLBACK(set_occupancy), 100, 15, FALSE, iobj);
2959 update_entry_double (GTK_ENTRY(entry), iobj -> occ);
2960 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, entry, FALSE, FALSE, 0);
2961 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 5);
2962 }
2963 else
2964 {
2965 for (i=0; i<3; i++)
2966 {
2967 hbox = create_hbox (5);
2968 str = g_strdup_printf ("%s =", axis[i]);
2969 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label(str, 100, -1, 0.0, 0.5), FALSE, FALSE, 0);
2970 g_free (str);
2971 entry = create_entry (G_CALLBACK(set_i_coord), 100, 15, FALSE, GINT_TO_POINTER(i));
2972 update_entry_double (GTK_ENTRY(entry), iobj -> baryc[i]);
2973 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, entry, FALSE, FALSE, 0);
2974 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 5);
2975 }
2976 }
2977 break;
2978 case RANMOVE:
2979 hbox = create_hbox (5);
2980 entry = create_entry (G_CALLBACK(set_max_msd), 100, 15, FALSE, GINT_TO_POINTER(h));
2981 if (h > 0)
2982 {
2983 j = this_proj -> atoms[0][atom_to_edit].sp;
2984 if (object)
2985 {
2986 str = g_strdup_printf ("MSD<sub>max</sub> for %s<sub>%d</sub> + neighbors = ", this_proj -> chemistry -> label[j], atom_to_edit+1);
2987 }
2988 else
2989 {
2990 str = g_strdup_printf ("MSD<sub>max</sub> for %s<sub>%d</sub> = ", this_proj -> chemistry -> label[j], atom_to_edit+1);
2991 }
2992 update_entry_double (GTK_ENTRY(entry), this_proj -> modelgl -> atom_win -> msd[atom_to_edit]);
2993 }
2994 else
2995 {
2996 switch (filter)
2997 {
2998 case 0:
2999 str = g_strdup_printf ("MSD<sub>max</sub> for all %s atom(s) = ", this_proj -> chemistry -> label[-h-1]);
3000 break;
3001 case 1:
3002 if (-h-1 == 0)
3003 {
3004 str = g_strdup_printf ("MSD<sub>max</sub> for all isolated atom(s) = ");
3005 }
3006 else if (object)
3007 {
3008 str = g_strdup_printf ("MSD<sub>max</sub> for all %d-fold atom(s) + neighbors = ", -h-1);
3009 }
3010 else
3011 {
3012 str = g_strdup_printf ("MSD<sub>max</sub> for all %d-fold atom(s) = ", -h-1);
3013 }
3014 break;
3015 case 2:
3016 i = 0;
3017 for (j=0; j<this_proj -> nspec; j++)
3018 {
3019 i += this_proj -> coord -> ntg[1][j];
3020 if (i > -h-1) break;
3021 }
3022 k = 0;
3023 for (l=0; l<j; l++) k += this_proj -> coord -> ntg[1][l];
3024 i = (-h-1) - k;
3025 nran = env_name(this_proj, i, j, 1, NULL);
3026 if (object)
3027 {
3028 str = g_strdup_printf ("MSD<sub>max</sub> for all %s + neighbors = ", nran);
3029 }
3030 else
3031 {
3032 str = g_strdup_printf ("MSD<sub>max</sub> for all %s = ", nran);
3033 }
3034 break;
3035 case 3:
3036 if (object)
3037 {
3038 str = g_strdup_printf ("MSD<sub>max</sub> for fragment N°%d = ", -h);
3039 }
3040 else
3041 {
3042 str = g_strdup_printf ("MSD<sub>max</sub> for the atom(s) in fragment N°%d = ", -h);
3043 }
3044 break;
3045 case 4:
3046 if (object)
3047 {
3048 str = g_strdup_printf ("MSD<sub>max</sub> for molecule N°%d = ", -h);
3049 }
3050 else
3051 {
3052 str = g_strdup_printf ("MSD<sub>max</sub> for the atom(s) in molecule N°%d = ", -h);
3053 }
3054 break;
3055 }
3056 update_entry_double (GTK_ENTRY(entry), this_proj -> modelgl -> atom_win -> msd_all[-h-1]);
3057 }
3058 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label(str, 100, -1, 0.0, 0.5), FALSE, FALSE, 15);
3059 g_free (str);
3060 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, entry, FALSE, FALSE, 0);
3061 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label("[&#xC5;<sup>2</sup>]", 50, -1, 0.0, 0.5), FALSE, FALSE, 0);
3062 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 5);
3063 break;
3064 default:
3065 max_random = 0;
3066 switch (filter)
3067 {
3068 case 0:
3069 if (csearch -> status == 2)
3070 {
3071 max_random = this_proj -> chemistry -> nsps[-h-1];
3072 nran = g_strdup_printf ("%s", this_proj -> chemistry -> label[-h-1]);
3073 }
3074 else
3075 {
3076 max_random = 0;
3077 for (i=0; i<this_proj -> natomes; i++)
3078 {
3079 if (this_proj -> atoms[0][i].sp == -h-1 && this_proj -> atoms[0][i].pick[0] == csearch -> status) max_random ++;
3080 }
3081 }
3082 break;
3083 case 1:
3084 for (i=0; i<this_proj -> natomes; i++)
3085 {
3086 if (this_proj -> atoms[0][i].numv == -h-1 && (this_proj -> atoms[0][i].pick[0] == csearch -> status || csearch -> status == 2)) max_random ++;
3087 }
3088 if (-h-1 > 0)
3089 {
3090 nran = g_strdup_printf ("%d-fold", -h-1);
3091 }
3092 else
3093 {
3094 nran = g_strdup_printf ("isolated");
3095 }
3096 break;
3097 case 2:
3098 i = 0;
3099 for (j=0; j<this_proj -> nspec; j++)
3100 {
3101 i += this_proj -> coord -> ntg[1][j];
3102 if (i > -h-1) break;
3103 }
3104 k = 0;
3105 for (l=0; l<j; l++) k += this_proj -> coord -> ntg[1][l];
3106 i = (-h-1) - k;
3107 for (k=0; k<this_proj -> natomes; k++)
3108 {
3109 if (this_proj -> atoms[0][k].sp == j && this_proj -> atoms[0][k].coord[1] == i)
3110 {
3111 if (this_proj -> atoms[0][k].pick[0] == csearch -> status || csearch -> status == 2) max_random ++;
3112 }
3113 }
3114 if (csearch -> action != RANMOVE) nran = env_name(this_proj, i, j, 1, NULL);
3115 break;
3116 default:
3117 if (object)
3118 {
3119 i = (-h-1);
3120 if (filter == 3)
3121 {
3122 max_random = this_proj -> coord -> totcoord[2];
3123 }
3124 else if (filter == 4)
3125 {
3126 max_random = this_proj -> modelfc -> mols[0][i].multiplicity;
3127 }
3128 }
3129 else
3130 {
3131 i = (-h-1);
3132 for (k=0; k<this_proj -> natomes; k++)
3133 {
3134 if (this_proj -> atoms[0][k].coord[filter-1] == i)
3135 {
3136 if (this_proj -> atoms[0][k].pick[0] == csearch -> status || csearch -> status == 2) max_random ++;
3137 }
3138 }
3139 nran = g_strdup_printf ("atom(s)");
3140 }
3141 break;
3142 }
3143
3144 hbox = create_hbox (5);
3145 entry = create_entry (G_CALLBACK(set_max_action), 100, 15, FALSE, GINT_TO_POINTER(h));
3146 if (object)
3147 {
3148 if (filter == 3)
3149 {
3150 str = g_strdup_printf ("%s randomly <i>n</i> <b>fragment(s)</b> in all fragments, <i>n</i>= ", act[csearch -> action - 3]);
3151 }
3152 else if (filter == 4)
3153 {
3154 str = g_strdup_printf ("%s randomly <i>n</i> <b>fragment(s)</b> in molecule N°%d, <i>n</i>= ", act[csearch -> action - 3], -h);
3155 }
3156 else
3157 {
3158 str = g_strdup_printf ("%s randomly <i>n</i> <b>%s</b> coordinations, <i>n</i>= ", act[csearch -> action - 3], nran);
3159 }
3160 }
3161 else
3162 {
3163 if (filter < 3)
3164 {
3165 str = g_strdup_printf ("%s randomly <i>n</i> <b>%s</b> %s, <i>n</i>= ", act[csearch -> action - 3], nran, obj[0]);
3166 }
3167 else
3168 {
3169 str = g_strdup_printf ("%s randomly <i>n</i> <b>%s</b> %s N°%d, <i>n</i>= ", act[csearch -> action - 3], nran, obj[filter], -h);
3170 }
3171 }
3172 if (nran) g_free (nran);
3173 update_entry_int (GTK_ENTRY(entry), csearch -> todo[-h-1]);
3174 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label(str, 100, -1, 0.0, 0.5), FALSE, FALSE, 15);
3175 g_free (str);
3176 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, entry, FALSE, FALSE, 0);
3177 str = g_strdup_printf (" with <i>n</i><sub>max</sub> = <b>%d</b>", max_random);
3178 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label(str, 50, -1, 0.0, 0.5), FALSE, FALSE, 15);
3179 g_free (str);
3180 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 5);
3181 break;
3182 }
3183 run_this_gtk_dialog (win, G_CALLBACK(run_destroy_dialog), NULL);
3184 if (csearch -> action != RANMOVE)
3185 {
3187 }
3188 else
3189 {
3190 if (h > 0)
3191 {
3192 if (this_proj -> modelgl -> atom_win -> msd[atom_to_edit] > 0.0)
3193 {
3194 str = g_strdup_printf ("MSD<sub>max</sub>= %f", this_proj -> modelgl -> atom_win -> msd[atom_to_edit]);
3195 }
3196 else
3197 {
3198 str = g_strdup_printf ("Set MSD<sub>max</sub> for ...");
3199 }
3200 gtk_tree_store_set (csearch -> atom_model, & iter, TOPIC+2, str, -1);
3201 g_free (str);
3202 }
3203 else
3204 {
3205 if (this_proj -> modelgl -> atom_win -> msd_all[-h-1] > 0.0)
3206 {
3207 if (object && filter > 2)
3208 {
3209 str = g_strdup_printf ("MSD<sub>max</sub>= %f", this_proj -> modelgl -> atom_win -> msd_all[-h-1]);
3210 }
3211 else
3212 {
3213 str = g_strdup_printf ("For all: MSD<sub>max</sub>= %f", this_proj -> modelgl -> atom_win -> msd_all[-h-1]);
3214 }
3215 gtk_tree_store_set (csearch -> atom_model, & iter, TOPIC+2, str, -1);
3216 g_free (str);
3217 }
3218 else
3219 {
3220 if (object && filter > 2)
3221 {
3222 gtk_tree_store_set (csearch -> atom_model, &iter, TOPIC+2, "Set MSD<sub>max</sub> for ...", -1);
3223 }
3224 else
3225 {
3226 gtk_tree_store_set (csearch -> atom_model, & iter, TOPIC+2, "Set MSD<sub>max</sub> for all ...", -1);
3227 }
3228 }
3229 }
3230 check_all_trees (this_proj);
3231 }
3232 }
3233 }
3234}
3235
3246G_MODULE_EXPORT void to_edit_coords (GtkCellRenderer * cell, GtkCellEditable * editable, gchar * path_string, gpointer data)
3247{
3248 destroy_this_widget (GTK_WIDGET(editable));
3249 get_coord_iter_and_edit (path_string, data, NULL);
3250}
3251
3262G_MODULE_EXPORT void markup_action_renderer (GtkCellRendererCombo * cell, GtkCellEditable * editable, gchar * path_string, gpointer data)
3263{
3264 GtkComboBox * combo = GTK_COMBO_BOX(editable);
3265 GList * cell_list = gtk_cell_layout_get_cells(GTK_CELL_LAYOUT(combo));
3266 if (cell_list && cell_list -> data)
3267 {
3268 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo), cell_list -> data, "markup", 0, NULL);
3269 }
3270 /*GtkCellView * view = (GtkCellView *)gtk_bin_get_child(GTK_BIN(editable));
3271 GList * list = gtk_cell_view_get_cell_renderers (view);
3272 while (list)
3273 {
3274 GtkCellRenderer *render = (GtkCellRenderer *)list -> data;
3275 list = list -> next;
3276 gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT(combo), renderer1, TaskStatusComboCellData, NULL, NULL);
3277 }*/
3278}
3279
3288G_MODULE_EXPORT void set_max_msd_for_all (GtkEntry * res, gpointer data)
3289{
3290 const gchar * m = entry_get_text (res);
3291 double v = string_to_double ((gpointer)m);
3292 project * this_proj = get_project_by_id (csearch -> proj);
3293 int i, j;
3294 if (v <= 0.0)
3295 {
3296 // show_error ("MSD<sub>max</sub> must be > 0.0 !", 1, this_proj -> modelgl -> atom_win -> win);
3297 v = this_proj -> modelgl -> atom_win -> msd[0];
3298 }
3299 i = csearch -> todo_size;
3300 for (j=0; j<i; j++)
3301 {
3302 this_proj -> modelgl -> atom_win -> msd[j] = v;
3303 }
3305 for (j=0; j<i; j++)
3306 {
3307 this_proj -> modelgl -> atom_win -> msd_all[j] = v;
3308 }
3310}
3311
3322gboolean update_search_model (GtkTreeModel * model, GtkTreePath * path, GtkTreeIter * iter, gpointer data)
3323{
3324 int i;
3325 tint * dat = (tint *)data;
3326 project * this_proj = get_project_by_id(dat -> a);
3327 atom_search * asearch = this_proj -> modelgl -> search_widg[dat -> c];
3328 if (gtk_tree_model_get_iter (model, iter, path))
3329 {
3330 gtk_tree_model_get (model, iter, IDCOL, & i, -1);
3331 gtk_tree_store_set (GTK_TREE_STORE(model), iter, dat -> b, asearch -> int_b, -1);
3332 if (i > 0)
3333 {
3334 i --;
3335 adjust_this_tree_leaf (asearch, this_proj, dat -> b, i, asearch -> int_b, * iter);
3336 }
3337 else if (asearch -> object)
3338 {
3339 adjust_this_tree_branch (asearch, this_proj, dat -> b, abs(i) - 1, * iter);
3340 }
3341 return FALSE;
3342 }
3343 else
3344 {
3345 return TRUE;
3346 }
3347}
3348
3357G_MODULE_EXPORT void select_all_atoms (GtkTreeViewColumn * col, gpointer data)
3358{
3359 tint * dat = (tint *)data;
3360 project * this_proj = get_project_by_id(dat -> a);
3361 csearch = this_proj -> modelgl -> search_widg[dat -> c];
3362 int i, j, k;
3363 opengl_project_changed (dat -> a);
3364 if (dat -> b == TOPIC+2)
3365 {
3366 GtkWidget * win = gtk_dialog_new ();
3367 gtk_window_set_transient_for (GTK_WINDOW (win), GTK_WINDOW(this_proj -> modelgl -> atom_win -> win));
3368 gtk_window_set_resizable (GTK_WINDOW (win), FALSE);
3369 gchar * str = g_strdup_printf ("Maximum Mean Square Displacement");
3370 gtk_window_set_title (GTK_WINDOW(win), str);
3371 g_free (str);
3372 gtk_window_set_modal (GTK_WINDOW (win), TRUE);
3373 GtkWidget * vbox = dialog_get_content_area (win);
3374 GtkWidget * hbox = create_hbox (5);
3375 GtkWidget * entry = create_entry (G_CALLBACK(set_max_msd_for_all), 100, 15, FALSE, NULL);
3376 update_entry_double (GTK_ENTRY(entry), 0.0);
3377 str = g_strdup_printf ("MSD<sub>max</sub> for all object(s) = ");
3378 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label(str, 100, -1, 0.0, 0.5), FALSE, FALSE, 15);
3379 g_free (str);
3380 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, entry, FALSE, FALSE, 0);
3381 str = g_strdup_printf ("[&#xC5;<sup>2</sup>]");
3382 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label(str, 50, -1, 0.0, 0.5), FALSE, FALSE, 0);
3383 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 5);
3384 run_this_gtk_dialog (win, G_CALLBACK(run_destroy_dialog), NULL);
3386 }
3387 else
3388 {
3389 if (dat -> b == TOLAB)
3390 {
3391 if (csearch -> action == INSERT)
3392 {
3393 k = (csearch -> pointer[0].c == 5) ? 1 : 2;
3394 if (this_proj -> modelgl -> atom_win -> to_be_inserted[k])
3395 {
3396 j = ! csearch -> todo[0];
3397 for (i=0; i<csearch -> in_selection; i++) csearch -> todo[i] = j;
3398 }
3399 }
3400 else
3401 {
3402 k = this_proj -> modelgl -> anim -> last -> img -> step;
3403 if (csearch -> action < 2)
3404 {
3405 is_selected = -1;
3406 i = 0;
3407 }
3408 else
3409 {
3410 if (csearch -> status < 2)
3411 {
3413 for (i=0; i<this_proj -> natomes; i++)
3414 {
3415 if (this_proj -> atoms[k][i].pick[0] == is_selected) break;
3416 }
3417 }
3418 else
3419 {
3420 is_selected = -1;
3421 i = 0;
3422 }
3423 }
3424 j = ! this_proj -> atoms[k][i].label[0];
3425 selected_aspec = -1;
3426 column_label = TRUE;
3427#ifdef GTK4
3428 label_unlabel_atoms (NULL, NULL, & opengl_project -> modelgl -> colorp[0][j]);
3429#else
3430 label_unlabel_atoms (NULL, & opengl_project -> modelgl -> colorp[0][j]);
3431#endif
3432 column_label = FALSE;
3433 }
3434 }
3435 else
3436 {
3437 k = this_proj -> modelgl -> anim -> last -> img -> step;
3438 if (csearch -> action < 2)
3439 {
3440 j = ! this_proj -> atoms[k][0].pick[0];
3442#ifdef GTK4
3443 select_unselect_atoms (NULL, NULL, & opengl_project -> modelgl -> colorp[0][j]);
3444#else
3445 select_unselect_atoms (NULL, & opengl_project -> modelgl -> colorp[0][j]);
3446#endif
3447 }
3448 else
3449 {
3450 if (csearch -> action != RANMOVE)
3451 {
3452 j = (csearch -> set_for_all < 0) ? 0 : 1;
3453 }
3454 else
3455 {
3456 // The value depends on both translation (1), rotation (2), or both (3)
3457 switch (abs(csearch -> set_for_all))
3458 {
3459 case 0:
3460 if (dat -> b == TOPIC)
3461 {
3462 j = 1;
3463 }
3464 else
3465 {
3466 j = 2;
3467 }
3468 break;
3469 case 1:
3470 if (dat -> b == TOPIC)
3471 {
3472 j = 0;
3473 }
3474 else
3475 {
3476 j = 3;
3477 }
3478 break;
3479 case 2:
3480 if (dat -> b == TOPIC)
3481 {
3482 j = 3;
3483 }
3484 else
3485 {
3486 j = 0;
3487 }
3488 break;
3489 case 3:
3490 if (dat -> b == TOPIC)
3491 {
3492 j = 2;
3493 }
3494 else
3495 {
3496 j = 1;
3497 }
3498 break;
3499 }
3500 }
3501 }
3502 }
3503 if (csearch -> action > 1 && dat -> c != 7)
3504 {
3506 if (dat -> b != TOLAB) clean_todo (csearch);
3507 }
3508 csearch -> set_for_all = (dat -> b == TOLAB) ? 0 : j;
3510 }
3511 /*else
3512 {
3513 GtkTreeIter iter;
3514 if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL(csearch -> atom_model), & iter))
3515 {
3516 gtk_tree_model_get (GTK_TREE_MODEL(csearch -> atom_model), & iter, dat -> b, & j, -1);
3517 g_debug ("j= %d,", j);
3518 g_debug ("a= %d, b= %d, c= %d, aa= %d, bb= %d, cc= %d", dat -> a, dat -> b, dat -> c,
3519 csearch -> pointer[dat -> b-TOLAB].a, csearch -> pointer[dat -> b-TOLAB].b, csearch -> pointer[dat -> b-TOLAB].c);
3520 csearch -> int_b = ! j;
3521 gtk_tree_model_foreach (GTK_TREE_MODEL(csearch -> atom_model), update_search_model, & csearch -> pointer[dat -> b-TOLAB]);
3522 }
3523 }*/
3524}
3525
3535G_MODULE_EXPORT void move_up_down (GtkTreeModel * tree_model, GtkTreePath * path, gpointer data)
3536{
3537 atom_search * asearch = (atom_search *)data;
3538 project * this_proj = get_project_by_id(asearch -> proj);
3539 atomic_object * obja, * objb, * objc;
3540 GtkTreeIter iter;
3541 gboolean valid;
3542 int i, j;
3543 int * old_todo = duplicate_int (asearch -> in_selection, asearch -> todo);
3544 obja = duplicate_atomic_object (this_proj -> modelgl -> atom_win -> to_be_inserted[2]);
3545 obja -> next = this_proj -> modelgl -> atom_win -> to_be_inserted[2] -> next;
3546 g_free (this_proj -> modelgl -> atom_win -> to_be_inserted[2]);
3547 objb = NULL;
3548 valid = gtk_tree_model_get_iter_first (tree_model, & iter);
3549 j = 0;
3550 while (valid)
3551 {
3552 gtk_tree_model_get (tree_model, & iter, 0, & i, -1);
3553 i --;
3554 objc = obja;
3555 while (objc -> id != i) objc = objc -> next;
3556 if (objc)
3557 {
3558 if (! objb)
3559 {
3560 this_proj -> modelgl -> atom_win -> to_be_inserted[2] = duplicate_atomic_object (objc);
3561 objb = this_proj -> modelgl -> atom_win -> to_be_inserted[2];
3562 }
3563 else
3564 {
3565 objb -> next = duplicate_atomic_object (objc);
3566 objb -> next -> prev = objb;
3567 objb = objb -> next;
3568 }
3569 objb -> id = j;
3570 asearch -> todo[j] = old_todo[i];
3571 j ++;
3572 }
3573 valid = gtk_tree_model_iter_next (tree_model, & iter);
3574 }
3575 g_free (old_todo);
3576 i = 0;
3577 valid = gtk_tree_model_get_iter_first (tree_model, & iter);
3578 while (valid)
3579 {
3580 gtk_list_store_set (GTK_LIST_STORE(tree_model), & iter, IDCOL, i+1, 1, g_strdup_printf ("%d", i+1), -1);
3581 i ++;
3582 valid = gtk_tree_model_iter_next (tree_model, & iter);
3583 }
3584}
3585
3595GtkWidget * create_atoms_tree (atom_search * asearch, project * this_proj, int nats)
3596{
3597 int i, j, k, l;
3598 GtkTreeViewColumn * atom_col[5];
3599 GtkCellRenderer * atom_cell[5];
3600 gchar * ctitle[6][5]={{"Object", "Name", "Label", "Pick", " "},
3601 {"Object", "Name", "Label", "Move", " "},
3602 {"Object", "Name", "Label", "Replace", "By"},
3603 {"Object", "Name", "Label", "Remove", " "},
3604 {"Object", "Name", "Insert", "Position", "Occupancy"},
3605 {"Object", "Name", "Label", "Translate", "Max. MSD"}};
3606 gchar * ctype[3][5]={{"text", "text", "active", "active", "text"},
3607 {"text", "text", "active", "text", "text"},
3608 {"text", "text", "active", "active", "text"}};
3609 j = (asearch -> action == REPLACE || asearch -> action == RANMOVE) ? 1 : 0;
3610 k = (asearch -> action == RANMOVE) ? 2 : (asearch -> action == INSERT) ? 1 : 0;
3611 if (asearch -> action == INSERT && asearch -> pointer[0].c == 7) j ++;
3612 gboolean toggle;
3613 GType coltype[3][8] = {{G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT},
3614 {G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT},
3615 {G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_INT}};
3616 if (asearch -> action == INSERT)
3617 {
3618 asearch -> obj_model = gtk_list_store_newv (8, coltype[k]);
3619 }
3620 else
3621 {
3622 asearch -> atom_model = gtk_tree_store_newv (8, coltype[k]);
3623 }
3624 if (! (nats > 10000) || asearch -> action == INSERT)
3625 {
3626 fill_atom_model (asearch, this_proj);
3627 }
3628 if (asearch -> action == INSERT)
3629 {
3630 asearch -> atom_tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(asearch -> obj_model));
3631 }
3632 else
3633 {
3634 asearch -> atom_tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(asearch -> atom_model));
3635 }
3636
3637 for (i=0; i<4+j; i++)
3638 {
3639 toggle = FALSE;
3640 if (i < 2 || (asearch -> action == INSERT && i > 2) || (asearch -> action == RANMOVE && i == 4))
3641 {
3642 atom_cell[i] = gtk_cell_renderer_text_new ();
3643 if ((asearch -> action == INSERT && i > 2) || (asearch -> action == RANMOVE && i == 4))
3644 {
3645 g_object_set (atom_cell[i], "editable", TRUE, NULL);
3646 g_signal_connect (G_OBJECT(atom_cell[i]), "editing-started", G_CALLBACK(to_edit_coords), & asearch -> pointer[i-3]);
3647 if (asearch -> action == RANMOVE) toggle = TRUE;
3648 }
3649 }
3650 else if (i < 4)
3651 {
3652 atom_cell[i] = gtk_cell_renderer_toggle_new ();
3653 g_signal_connect (G_OBJECT(atom_cell[i]), "toggled", G_CALLBACK(select_atom), & asearch -> pointer[i-2]);
3654 toggle = TRUE;
3655 }
3656 else
3657 {
3658 atom_cell[i] = gtk_cell_renderer_combo_new ();
3659 GtkTreeModel * model = replace_combo_tree (FALSE, this_proj -> id);
3660 g_object_set (atom_cell[i], "model", model, "text-column", 0, "has-entry", FALSE, "editable", TRUE, NULL);
3661 g_object_unref (model);
3662 g_signal_connect (G_OBJECT(atom_cell[i]), "editing-started", G_CALLBACK(markup_action_renderer), & asearch -> pointer[i-4]);
3663 g_signal_connect (G_OBJECT(atom_cell[i]), "changed", G_CALLBACK(changed_action_renderer), & asearch -> pointer[i-4]);
3664 }
3665 gtk_cell_renderer_set_fixed_size (atom_cell[i], -1, 25);
3666 l = (asearch -> action == RANMOVE && i == 4) ? i+1 : i;
3667 atom_col[i] = gtk_tree_view_column_new_with_attributes (ctitle[(asearch -> action < 2) ? 0 : asearch -> action - 1][i], atom_cell[i], ctype[k][i], l+1, NULL);
3668 if (toggle && ! asearch -> passivating)
3669 {
3670 gtk_tree_view_column_set_clickable (atom_col[i], TRUE);
3671 g_signal_connect (G_OBJECT(atom_col[i]), "clicked", G_CALLBACK(select_all_atoms), & asearch -> pointer[l-2]);
3672 }
3673 gtk_tree_view_append_column(GTK_TREE_VIEW(asearch -> atom_tree), atom_col[i]);
3674 gtk_tree_view_column_set_alignment (atom_col[i], 0.5);
3675 gtk_tree_view_column_set_cell_data_func (atom_col[i], atom_cell[i], search_set_visible, GINT_TO_POINTER(l), NULL);
3676 }
3677 if (asearch -> pointer[0].c == 7)
3678 {
3679 asearch -> filter = g_signal_connect_data (G_OBJECT(GTK_TREE_MODEL(asearch -> obj_model)), "row-deleted", G_CALLBACK(move_up_down), asearch, NULL, (GConnectFlags) 0);
3680 gtk_tree_view_set_reorderable (GTK_TREE_VIEW(asearch -> atom_tree), TRUE);
3681 }
3682 return asearch -> atom_tree;
3683}
3684
3693{
3694 int object = get_asearch_object (asearch);
3695 int filter = get_asearch_filter (asearch);
3696 project * this_proj = get_project_by_id (asearch -> proj);
3697 int tsize = 0;
3698 switch (filter)
3699 {
3700 case 0:
3701 tsize = (asearch -> mode || asearch -> passivating) ? this_proj -> nspec : this_proj -> natomes;
3702 break;
3703 case 1:
3704 tsize = (asearch -> mode || asearch -> passivating) ? this_proj -> coord -> cmax+1 : this_proj -> natomes;
3705 break;
3706 default:
3707 if (asearch -> mode || asearch -> passivating)
3708 {
3709 tsize = this_proj -> coord -> totcoord[filter -1];
3710 }
3711 else
3712 {
3713 tsize = (object && filter > 2) ? this_proj -> coord -> totcoord[filter -1] : this_proj -> natomes;
3714 }
3715 break;
3716 }
3717 return tsize;
3718}
3719
3728void allocate_todo (atom_search * asearch, int tsize)
3729{
3730 asearch -> todo = allocint (tsize);
3731 asearch -> todo_size = tsize;
3732}
3733
3741void clean_todo (atom_search * asearch)
3742{
3743 project * this_proj = get_project_by_id (asearch -> proj);
3744 if (asearch -> todo) g_free (asearch -> todo);
3745 allocate_todo (asearch, get_todo_size(asearch));
3746 atomic_object * object;
3747 switch (asearch -> action)
3748 {
3749 case DISPL:
3750 if (this_proj -> modelgl -> atom_win -> to_be_moved[0])
3751 {
3752 object = this_proj -> modelgl -> atom_win -> to_be_moved[0];
3753 while (object -> next)
3754 {
3755 object = object -> next;
3756 g_free (object -> prev);
3757 }
3758 g_free (object);
3759 this_proj -> modelgl -> atom_win -> to_be_moved[0] = NULL;
3760 }
3761 break;
3762 case RANMOVE:
3763 if (this_proj -> modelgl -> atom_win -> to_be_moved[1])
3764 {
3765 object = this_proj -> modelgl -> atom_win -> to_be_moved[1];
3766 while (object -> next)
3767 {
3768 object = object -> next;
3769 g_free (object -> prev);
3770 }
3771 g_free (object);
3772 this_proj -> modelgl -> atom_win -> to_be_moved[1] = NULL;
3773 }
3774 g_free (this_proj -> modelgl -> atom_win -> msd);
3775 this_proj -> modelgl -> atom_win -> msd = allocfloat (asearch -> todo_size);
3776 break;
3777 case REPLACE:
3778 if (this_proj -> modelgl -> atom_win -> to_be_inserted[0])
3779 {
3780 object = this_proj -> modelgl -> atom_win -> to_be_inserted[0];
3781 while (object -> next)
3782 {
3783 object = object -> next;
3784 g_free (object -> prev);
3785 }
3786 g_free (object);
3787 this_proj -> modelgl -> atom_win -> to_be_inserted[0] = NULL;
3788 }
3789 asearch -> in_selection = 0;
3790 break;
3791 }
3792}
3793
3802void clean_picked_and_labelled (atom_search * asearch, gboolean clean_msd)
3803{
3804 project * this_proj;
3805 int val = get_asearch_num_objects (asearch);
3806 asearch -> lab = allocint(val);
3807 asearch -> pick = allocint(val);
3808 if (asearch -> action == RANMOVE)
3809 {
3810 this_proj = get_project_by_id (asearch -> proj);
3811 if (this_proj -> modelgl -> atom_win && clean_msd)
3812 {
3813 g_free (this_proj -> modelgl -> atom_win -> msd_all);
3814 this_proj -> modelgl -> atom_win -> msd_all = allocfloat (val);
3815 }
3816 }
3817 else if (asearch -> action == REPLACE)
3818 {
3819 this_proj = get_project_by_id (asearch -> proj);
3820 int i = (asearch -> pointer[0].c == 3) ? 0 : 1;
3821 if (this_proj -> modelgl -> atom_win)
3822 {
3823 if (this_proj -> modelgl -> atom_win -> win && this_proj -> modelgl -> atom_win -> replace_nodes[i])
3824 {
3825 g_free (this_proj -> modelgl -> atom_win -> replace_nodes[i]);
3826 }
3827 this_proj -> modelgl -> atom_win -> replace_nodes[i] = g_malloc0(val*sizeof*this_proj -> modelgl -> atom_win -> replace_nodes[i]);
3828 }
3829 }
3830}
3831
3840G_MODULE_EXPORT void set_spec_changed (GtkComboBox * box, gpointer data)
3841{
3842 atom_search * asearch = (atom_search *) data;
3843 int i = gtk_combo_box_get_active (box);
3844 asearch -> spec = i;
3845 update_search_tree (asearch);
3846 if (get_project_by_id(asearch -> proj) -> natomes >= 10000)
3847 {
3848 if (i > 0)
3849 {
3850 update_entry_text (GTK_ENTRY(asearch -> entry_a), exact_name(get_project_by_id(asearch -> proj) -> chemistry -> label[i-1]));
3851 }
3852 else
3853 {
3854 update_entry_text (GTK_ENTRY(asearch -> entry_a), "");
3855 }
3856 set_atom (GTK_ENTRY(asearch -> entry_a), asearch);
3857 widget_set_sensitive (asearch -> entry_a, ! i);
3858 }
3859}
3860
3869G_MODULE_EXPORT void set_filter_changed (GtkComboBox * box, gpointer data)
3870{
3871 atom_search * asearch = (atom_search *) data;
3872 asearch -> filter = gtk_combo_box_get_active (box);
3873 int object = get_asearch_object (asearch);
3874 int filter = get_asearch_filter (asearch);
3875 widget_set_sensitive (asearch -> atom_box, (object && filter > 2) ? 0 : 1);
3876 widget_set_sensitive (asearch -> id_box, (object && filter > 2) ? 0 : 1);
3877 if (object && filter > 2)
3878 {
3879 gtk_combo_box_set_active (GTK_COMBO_BOX(asearch -> atom_box), 0);
3880 }
3881 if (asearch -> action == DISPL) motion_to_zero (asearch);
3882 clean_todo (asearch);
3883 clean_picked_and_labelled (asearch, TRUE);
3884 set_spec_changed (GTK_COMBO_BOX(asearch -> atom_box), asearch);
3885}
3886
3895G_MODULE_EXPORT void set_object_changed (GtkComboBox * box, gpointer data)
3896{
3897 atom_search * asearch = (atom_search *) data;
3898 GtkTreeViewColumn * rot_c;
3899 int was_object;
3900 int object;
3901 int filter;
3902 if (get_project_by_id(asearch -> proj) -> natomes >= 10000)
3903 {
3904 was_object = ((! asearch -> mode && asearch -> object > 1) || (asearch -> mode && asearch -> object)) ? 1 : 0;
3905 asearch -> object = gtk_combo_box_get_active (box);
3906 filter = get_asearch_filter (asearch);
3907 object = ((! asearch -> mode && asearch -> object > 1) || (asearch -> mode && asearch -> object)) ? 1 : 0;
3908 if ((! asearch -> mode && (asearch -> object == 1 || asearch -> object == 3)) || (asearch -> mode && asearch -> object))
3909 {
3910 if (! asearch -> mode) asearch -> passivating = TRUE;
3911 if (is_the_widget_visible(asearch -> id_box)) hide_the_widgets (asearch -> id_box);
3912 if (is_the_widget_visible(asearch -> info[1])) hide_the_widgets (asearch -> info[1]);
3913 }
3914 else
3915 {
3916 asearch -> passivating = FALSE;
3917 if (((! asearch -> mode && asearch -> object == 2) || (asearch -> mode && asearch -> object)) && filter > 2)
3918 {
3919 if (is_the_widget_visible(asearch -> id_box)) hide_the_widgets (asearch -> id_box);
3920 if (is_the_widget_visible(asearch -> info[1])) hide_the_widgets (asearch -> info[1]);
3921 }
3922 else
3923 {
3924 if (! is_the_widget_visible(asearch -> id_box)) show_the_widgets (asearch -> id_box);
3925 if (! is_the_widget_visible(asearch -> info[1])) show_the_widgets (asearch -> info[1]);
3926 }
3927 }
3928 }
3929 else
3930 {
3931 was_object = (asearch -> object) ? 1 : 0;
3932 asearch -> object = gtk_combo_box_get_active (box);
3933 filter = get_asearch_filter (asearch);
3934 object = (asearch -> object) ? 1 : 0;
3935 if (is_the_widget_visible(asearch -> id_box)) hide_the_widgets (asearch -> id_box);
3936 if (is_the_widget_visible(asearch -> info[1])) hide_the_widgets (asearch -> info[1]);
3937 }
3938 if (was_object)
3939 {
3940 combo_text_prepend (asearch -> filter_box, "Chemical species");
3941 if (asearch -> action == RANMOVE)
3942 {
3943 rot_c = gtk_tree_view_get_column (GTK_TREE_VIEW(asearch -> atom_tree), 4);
3944 gtk_tree_view_remove_column (GTK_TREE_VIEW(asearch -> atom_tree), rot_c);
3945 }
3946 }
3947 if (object)
3948 {
3949 gtk_combo_box_text_remove ((GtkComboBoxText *)asearch -> filter_box, 0);
3950 if (asearch -> action == RANMOVE)
3951 {
3952 GtkCellRenderer * rot = gtk_cell_renderer_toggle_new ();
3953 g_signal_connect (G_OBJECT(rot), "toggled", G_CALLBACK(select_atom), & asearch -> pointer[2]);
3954 int i = 5;
3955 rot_c = gtk_tree_view_column_new_with_attributes ("Rotate", rot, "active", i, NULL);
3956 gtk_tree_view_column_set_clickable (rot_c, TRUE);
3957 g_signal_connect (G_OBJECT(rot_c), "clicked", G_CALLBACK(select_all_atoms), & asearch -> pointer[2]);
3958 gtk_tree_view_column_set_alignment (rot_c, 0.5);
3959 gtk_tree_view_insert_column (GTK_TREE_VIEW(asearch -> atom_tree), rot_c, i-1);
3960 }
3961 }
3962
3963 if (asearch -> action == DISPL) widget_set_sensitive (get_project_by_id(asearch -> proj) -> modelgl -> atom_win -> at_expand[2], object);
3964 gtk_combo_box_set_active (GTK_COMBO_BOX(asearch -> filter_box), 0);
3965 set_filter_changed (GTK_COMBO_BOX(asearch -> filter_box), asearch);
3966}
3967
3976{
3977 int i = 8 - asearch -> action;
3978 GtkCellRenderer * num = gtk_cell_renderer_text_new ();
3979 g_object_set (num, "editable", TRUE, NULL);
3980 g_signal_connect (G_OBJECT(num), "editing-started", G_CALLBACK(to_edit_coords), & asearch -> pointer[0]);
3981 GtkTreeViewColumn * num_c = gtk_tree_view_column_new_with_attributes ("Number", num, "text", i, NULL);
3982 gtk_tree_view_column_set_cell_data_func (num_c, num, search_set_visible, GINT_TO_POINTER(i), NULL);
3983 gtk_tree_view_append_column(GTK_TREE_VIEW(asearch -> atom_tree), num_c);
3984}
3985
3994G_MODULE_EXPORT void set_search_mode (GtkComboBox * box, gpointer data)
3995{
3996 atom_search * asearch = (atom_search *)data;
3997 project * this_proj = get_project_by_id(asearch -> proj);
3998 asearch -> mode = gtk_combo_box_get_active (box);
3999 if ((asearch -> action == REPLACE || asearch -> action == REMOVE) && asearch -> atom_tree)
4000 {
4001 if (! asearch -> mode)
4002 {
4003 GtkTreeViewColumn * num_c;
4004 num_c = gtk_tree_view_get_column (GTK_TREE_VIEW(asearch -> atom_tree), 8 - asearch -> action);
4005 gtk_tree_view_remove_column (GTK_TREE_VIEW(asearch -> atom_tree), num_c);
4006 }
4007 else
4008 {
4009 add_random_column (asearch);
4010 }
4011 }
4012 if (this_proj -> natomes >= 10000)
4013 {
4014 if (asearch -> object_box)
4015 {
4016 if (asearch -> mode)
4017 {
4018 gtk_combo_box_text_remove ((GtkComboBoxText *)asearch -> object_box, 3);
4019 gtk_combo_box_text_remove ((GtkComboBoxText *)asearch -> object_box, 1);
4020 }
4021 else
4022 {
4023 gtk_combo_box_text_insert ((GtkComboBoxText *)asearch -> object_box, 1, NULL, "Atom(s): all");
4024 combo_text_append (asearch -> object_box, "Group of atoms: all");
4025 }
4026 }
4027 }
4028 else
4029 {
4030 gtk_combo_box_text_remove_all ((GtkComboBoxText *)asearch -> object_box);
4031 combo_text_append (asearch -> object_box, "Atom(s)");
4032 combo_text_append (asearch -> object_box, "Group of atoms");
4033 }
4034
4035 /*if (asearch -> filter_box)
4036 {
4037 if (! this_proj -> modelgl -> adv_bonding[1] && this_proj -> modelgl -> atom_win -> adv_bonding[1])
4038 {
4039 gtk_combo_box_text_remove ((GtkComboBoxText *)asearch -> filter_box, 3+i);
4040 }
4041 if (! this_proj -> modelgl -> adv_bonding[0] && this_proj -> modelgl -> atom_win -> adv_bonding[0])
4042 {
4043 gtk_combo_box_text_remove ((GtkComboBoxText *)asearch -> filter_box, 2+i);
4044 }
4045 gtk_combo_box_set_active (GTK_COMBO_BOX(asearch -> filter_box), 0);
4046 set_filter_changed (GTK_COMBO_BOX(asearch -> filter_box), asearch);
4047 }*/
4048 gtk_combo_box_set_active (GTK_COMBO_BOX(asearch -> object_box), 0);
4049 set_object_changed (GTK_COMBO_BOX(asearch -> object_box), asearch);
4050}
4051
4060G_MODULE_EXPORT void set_search_digit (GtkEntry * res, gpointer data)
4061{
4062 atom_search * asearch = (atom_search *) data;
4063 const gchar * m = entry_get_text (res);
4064 double v = string_to_double ((gpointer)m);
4065 asearch -> search_digit = (int)v;
4066 if (asearch -> search_digit <= 0)
4067 {
4068 asearch -> search_digit --;
4069 update_entry_text (res, "");
4070 }
4071 else
4072 {
4073 update_entry_int (res, asearch -> search_digit);
4074 }
4075 set_spec_changed (GTK_COMBO_BOX(asearch -> atom_box), data);
4076}
4077
4087void prep_search_box (GtkWidget * vbox, GtkWidget * lab, GtkWidget * combo)
4088{
4089 GtkWidget * hbox = create_hbox (0);
4090 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 2);
4091 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 30);
4092 GtkWidget * fixed = gtk_fixed_new ();
4093 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, fixed, FALSE, FALSE, 10);
4094 gtk_widget_set_size_request (combo, 175, -1);
4095 gtk_fixed_put (GTK_FIXED(fixed), combo, 0, 0);
4096}
4097
4105GtkWidget * prepare_box_too_much (atom_search * asearch)
4106{
4107 GtkWidget * box;
4108 GtkWidget * widg;
4109 GtkWidget * too_box = create_vbox (BSEP);
4110 widg = bbox (too_box, "\t Atom species: ");
4111 gtk_widget_set_size_request (widg, 200, -1);
4112 asearch -> entry_a = create_entry (G_CALLBACK(set_atom), 90, 15, TRUE, asearch);
4113 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, widg, asearch -> entry_a, FALSE, FALSE, 0);
4114 asearch -> img_a = stock_image (DIAL_ERROR);
4115 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, widg, asearch -> img_a, FALSE, FALSE, 5);
4116 widg = bbox (too_box, "\t Atom Id: ");
4117 gtk_widget_set_size_request (widg, 200, -1);
4118 asearch -> entry_b = create_entry (G_CALLBACK(set_id), 90, 15, TRUE, asearch);
4119 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, widg, asearch -> entry_b, FALSE, FALSE, 0);
4120 asearch -> img_b = stock_image (DIAL_ERROR);
4121 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, widg, asearch -> img_b, FALSE, FALSE, 5);
4122 box = create_hbox (0);
4123 add_box_child_start (GTK_ORIENTATION_VERTICAL, too_box, box, FALSE, FALSE, 5);
4124 asearch -> but_a = create_button ("Add", IMG_NONE, NULL, 75, -1, GTK_RELIEF_NORMAL, G_CALLBACK(add_atom), asearch);
4125 widget_set_sensitive (asearch -> but_a, 0);
4126 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, box, asearch -> but_a, FALSE, FALSE, 75);
4127 asearch -> but_b = create_button ("Remove", IMG_NONE, NULL, 75, -1, GTK_RELIEF_NORMAL, G_CALLBACK(remove_atom), asearch);
4128 widget_set_sensitive (asearch -> but_b, 0);
4129 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, box, asearch -> but_b, FALSE, FALSE, 0);
4130 return too_box;
4131}
4132
4141GtkWidget * selection_tab (atom_search * asearch, int nats)
4142{
4143 project * this_proj = get_project_by_id (asearch -> proj);
4144 int i, j;
4145 i = (nats < 10000) ? 1 : 0;
4146 j = (asearch -> action == 5) ? 300 : -1;
4147 GtkWidget * selection = create_layout (j, 390 + (! i)*60 - i*100);
4148 GtkWidget * vbox = add_vbox_to_layout (selection, 0, (asearch -> action > 1) ? 0 : 10);
4149 GtkWidget * hbox, * vvbox;
4150 GtkWidget * lab;
4151 if (asearch -> action != 5)
4152 {
4153 // Later on simply hide info[1] (to much atoms info) if needed
4154 for (j=0; j<2; j++)
4155 {
4156 asearch -> info[j] = create_vbox (BSEP);
4157 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, asearch -> info[j], FALSE, FALSE, 0);
4158 }
4159 hbox = create_hbox (0);
4160 add_box_child_start (GTK_ORIENTATION_VERTICAL, asearch -> info[0], hbox, FALSE, FALSE, 2);
4161 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label("<b>.</b>", 5, -1, 0.0, 0.5), FALSE, FALSE, 10);
4162 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label("Search: ", 50, -1, 0.0, 0.5), FALSE, FALSE, 0);
4163 asearch -> object_box = create_combo ();
4164 combo_text_append (asearch -> object_box, "Atom(s)");
4165 if (! i) combo_text_append (asearch -> object_box, "Atom(s): all");
4166 combo_text_append (asearch -> object_box, "Group of atoms");
4167 if (! i) combo_text_append (asearch -> object_box, "Group of atoms: all");
4168 gtk_combo_box_set_active (GTK_COMBO_BOX(asearch -> object_box), asearch -> object);
4169 asearch -> filter_box = create_combo ();
4170 gchar * filters[5]={"Chemical species", "Total coordination", "Partial coordination", "Fragment", "Molecule"};
4171 for (j=0; j<3; j++) combo_text_append (asearch -> filter_box, filters[j]);
4172 if (this_proj -> modelgl -> adv_bonding[0]) combo_text_append (asearch -> filter_box, filters[3]);
4173 if (this_proj -> modelgl -> adv_bonding[1]) combo_text_append (asearch -> filter_box, filters[4]);
4174 gtk_combo_box_set_active (GTK_COMBO_BOX(asearch -> filter_box), asearch -> filter);
4175
4176 asearch -> atom_box = create_combo ();
4177 combo_text_append (asearch -> atom_box, "All");
4178 for (j=0; j<this_proj -> nspec; j++) combo_text_append (asearch -> atom_box, this_proj -> chemistry -> label[j]);
4179 gtk_combo_box_set_active (GTK_COMBO_BOX(asearch -> atom_box), asearch -> spec);
4180
4181 g_signal_connect (G_OBJECT (asearch -> object_box), "changed", G_CALLBACK(set_object_changed), asearch);
4182 g_signal_connect (G_OBJECT (asearch -> filter_box), "changed", G_CALLBACK(set_filter_changed), asearch);
4183 g_signal_connect (G_OBJECT (asearch -> atom_box), "changed", G_CALLBACK(set_spec_changed), asearch);
4184 GtkWidget * entry = create_entry (G_CALLBACK(set_search_digit), 90, 15, TRUE, asearch);
4185 if (asearch -> action < 2)
4186 {
4187 prep_search_box (asearch -> info[0], markup_label("For: ", 100, -1, 0.0, 0.5), asearch -> object_box);
4188 prep_search_box (asearch -> info[0], markup_label("Filter by: ", 100, -1, 0.0, 0.5), asearch -> filter_box);
4189 prep_search_box (asearch -> info[0], markup_label("Species: ", 100, -1, 0.0, 0.5), asearch -> atom_box);
4190 asearch -> id_box = create_hbox (0);
4191 add_box_child_start (GTK_ORIENTATION_VERTICAL, asearch -> info[0], asearch -> id_box, FALSE, FALSE, 0);
4192 prep_search_box (asearch -> id_box, markup_label("Atom Id: ", 100, -1, 0.0, 0.5), entry);
4193 }
4194 else
4195 {
4196 hbox = create_hbox (0);
4197 add_box_child_start (GTK_ORIENTATION_VERTICAL, asearch -> info[0], hbox, FALSE, FALSE, 5);
4198 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label("For: ", -1, -1, 0.0, 0.5), FALSE, FALSE, 10);
4199 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, asearch -> object_box, FALSE, FALSE, 0);
4200 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label("Filter by: ", -1, -1, 0.0, 0.5), FALSE, FALSE, 10);
4201 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, asearch -> filter_box, FALSE, FALSE, 0);
4202 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label("Species: ", -1, -1, 0.0, 0.5), FALSE, FALSE, 10);
4203 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, asearch -> atom_box, FALSE, FALSE, 0);
4204 asearch -> id_box = create_hbox (0);
4205 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, asearch -> id_box, FALSE, FALSE, 0);
4206 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, asearch -> id_box, markup_label("Atom Id: ", -1, -1, 0.0, 0.5), FALSE, FALSE, 10);
4207 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, asearch -> id_box, entry, FALSE, FALSE, 0);
4208 }
4209
4210 // If more than 10 000 atoms:
4211 if (asearch -> action < 2)
4212 {
4213 lab = markup_label("\t<b>The number of atoms in the model is too large</b>\n"
4214 "\t\t<b>to display and browse the entire list !</b>\n"
4215 "\t<b>You need to search for object(s) manually:</b>", -1, -1, 0.5, 0.5);
4216 }
4217 else
4218 {
4219 lab = markup_label("<b>The number of atoms in the model is too large to display and browse the entire list !</b>\n"
4220 "\t\t\t\t<b>You need to search for object(s) manually:</b>", -1, -1, 0.5, 0.5);
4221 }
4222 add_box_child_start (GTK_ORIENTATION_VERTICAL, asearch -> info[1], lab, FALSE, FALSE, 10);
4223 hbox = create_hbox (0);
4224 add_box_child_start (GTK_ORIENTATION_VERTICAL, asearch -> info[1], hbox, FALSE, FALSE, 0);
4225 /* vvbox = create_vbox (0);
4226 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, vvbox, FALSE, FALSE, 80);
4227 cbox = create_combo ();
4228 combo_text_append (cbox, "All objects");
4229 combo_text_append (cbox, "Selection");
4230 g_signal_connect (G_OBJECT(cbox), "changed", G_CALLBACK(set_too_much_type), asearch);
4231 gtk_combo_box_set_active (GTK_COMBO_BOX(cbox), asearch -> too_much);
4232 add_box_child_start (GTK_ORIENTATION_VERTICAL, vvbox, cbox, FALSE, FALSE, 30);
4233 // asearch -> big_box = // Combo box with "All objects", "Selection" */
4234 vvbox = create_vbox (0);
4235 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, vvbox, FALSE, FALSE, 120);
4236 add_box_child_start (GTK_ORIENTATION_VERTICAL, vvbox, prepare_box_too_much (asearch), FALSE, FALSE, 0);
4237 add_box_child_start (GTK_ORIENTATION_VERTICAL, asearch -> info[1],
4238 markup_label("The search must be performed using species and/or ID.\n"
4239 "Use the filters above to define the object(s) of the search", -1, -1, 0.5, 0.5), FALSE, FALSE, 5);
4240 }
4241
4242 abox (vbox, "Selection: ", 2);
4243 hbox = create_hbox (0);
4244 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 5);
4245 GtkWidget * scrollsets = create_scroll (NULL, -1, -1, GTK_SHADOW_ETCHED_IN);
4246 i = (asearch -> action < 2) ? 0 : 1;
4247 j = (asearch -> action < 2) ? 1 : 0;
4248 if (asearch -> action < 2)
4249 {
4250 gtk_widget_set_size_request (scrollsets, 400+i*100, 270);
4251 }
4252 else
4253 {
4254 gtk_widget_set_size_request (scrollsets, 400+i*100, 290-i*120);
4255 }
4256 gtk_widget_set_hexpand (scrollsets, TRUE);
4257 add_container_child (CONTAINER_SCR, scrollsets, create_atoms_tree (asearch, this_proj, nats));
4258 check_all_trees (this_proj);
4259 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, scrollsets, FALSE, FALSE, 100-j*75);
4260 return selection;
4261}
gchar * action_atoms[3]
Definition atom_edit.c:61
Function declarations for the mode edition window.
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
atomic_object * create_object_from_species(project *this_proj, int sid, atom_search *remove)
create object from all atom(s) of the same chemical species
#define TOPIC
Definition atom_edit.h:46
int create_object_from_open_project(project *this_proj, int p)
create object from atom(s) of a project opened in the workspace
#define IDCOL
Definition atom_edit.h:44
int is_selected
Definition popup.c:182
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
void clean_this_object(int orig, int act, project *this_proj, atom_search *asearch)
clean object data
atomic_object * duplicate_atomic_object(atomic_object *old_obj)
duplicate an insert object
void update_range_and_entry(project *this_proj, int i, int j, int k)
update motion range
Definition atom_move.c:979
int insert_this_project_from_lib(int id, gboolean visible, project *this_proj, atom_search *asearch)
insert object from the library
Definition w_library.c:1158
void to_insert_in_project(int stat, int orig, project *this_proj, atom_search *asearch, gboolean visible)
to insert object in project
#define TOLAB
Definition atom_edit.h:45
void check_motion_interactors(project *this_proj, atom_search *asearch)
add motion check button
Definition atom_move.c:1160
insertion_menu mol[]
Definition w_library.c:193
GtkFileFilter * filter[NCFORMATS+1]
Definition callbacks.c:1405
GtkWidget * builder_win(project *this_proj, gpointer data)
create crystal builder window
G_MODULE_EXPORT void cut_this_slab(GtkButton *but, gpointer data)
cut this slab callback
Definition cell_cut.c:493
gchar * axis[3]
Definition w_axis.c:65
integer(kind=c_int) function chemistry()
Definition chemistry.F90:22
color colorp[64]
double ax
Definition curve.c:70
void label(cairo_t *cr, double val, int axe, int p, project *this_proj)
draw axis label
Definition labels.c:56
ColRGBA col
Definition d_measures.c:77
gboolean check_it(int i, int j, int k, int l)
test this atom id ?
Definition d_poly.c:340
int atoms[NUM_STYLES][2]
int bonds[NUM_STYLES][2]
GtkTreePath * path
Definition datab.c:103
GtkTreeSelection * sel
Definition datab.c:102
float val
Definition dlp_init.c:117
gchar * ctitle[MAXDATA][12]
Definition dlp_field.c:834
int * duplicate_int(int num, int *old_val)
copy a list of int
Definition global.c:560
gboolean * allocbool(int val)
allocate a gboolean * pointer
Definition global.c:254
int nprojects
Definition global.c:158
gboolean selected_status
Definition global.c:187
gboolean column_label
Definition global.c:184
gboolean check_label
Definition global.c:185
int * allocint(int val)
allocate an int * pointer
Definition global.c:314
gboolean object_motion
Definition global.c:186
float * allocfloat(int val)
allocate a float * pointer
Definition global.c:398
double string_to_double(gpointer string)
convert string to double
Definition global.c:624
void run_this_gtk_dialog(GtkWidget *dial, GCallback handler, gpointer data)
run a GTK (3 and 4) basic GtkDialog
Definition gtk-misc.c:492
@ IMG_NONE
Definition global.h:260
GtkWidget * create_entry(GCallback handler, int dim, int cdim, gboolean key_release, gpointer data)
Create a GtkEntry.
Definition gtk-misc.c:1314
void update_entry_double(GtkEntry *entry, double doubleval)
update the content of a GtkEntry as double
Definition gtk-misc.c:633
G_MODULE_EXPORT void show_hide_labels(GtkWidget *widg, gpointer data)
#define DIAL_ERROR
Definition global.h:223
GtkWidget * create_scroll(GtkWidget *box, int dimx, int dimy, int shadow)
create a scroll window
Definition gtk-misc.c:1960
gboolean is_the_widget_visible(GtkWidget *widg)
test if a GtkWidget exist, then return if it is visible or not
Definition gtk-misc.c:714
project * proj
GtkWidget * add_vbox_to_layout(GtkWidget *layout, int size_x, int size_y)
Insert a vertical GtkBox in a GtkLatout then send back the GtkBox.
Definition gtk-misc.c:864
const gchar * entry_get_text(GtkEntry *entry)
get the text in a GtkEntry
Definition gtk-misc.c:597
#define BSEP
Definition global.h:245
void opengl_project_changed(int id)
change the OpenGL project
Definition update_p.c:245
void update_entry_int(GtkEntry *entry, int intval)
update the content of a GtkEntry as int
Definition gtk-misc.c:614
G_MODULE_EXPORT void select_unselect_this_atom(GtkWidget *widg, gpointer data)
select / unselect this atom callback GTK3
Definition popup.c:1177
GtkWidget * stock_image(const gchar *stock_id)
create a GtkImage for the Gtk database
Definition gtk-misc.c:1364
#define APPLY
Definition global.h:220
@ CONTAINER_SCR
Definition global.h:251
GtkWidget * create_button(gchar *text, int image_format, gchar *image, int dimx, int dimy, int relief, GCallback handler, gpointer data)
create a simple button
Definition gtk-misc.c:1863
G_MODULE_EXPORT void label_unlabel_atoms(GtkWidget *widg, gpointer data)
label / unlabel a type of atom(s) callback GTK3
Definition popup.c:1503
GtkWidget * create_combo()
create a GtkCombox widget, note deprecated in GTK4
Definition gtk-misc.c:923
GtkWidget * dialog_get_content_area(GtkWidget *widg)
prepare GtkWidget to insert content in a GtkDialog window
Definition gtk-misc.c:825
GtkWidget * markup_label(gchar *text, int dimx, int dimy, float ax, float ay)
Definition gtk-misc.c:1585
project * opengl_project
Definition project.c:54
void add_box_child_start(int orientation, GtkWidget *widg, GtkWidget *child, gboolean expand, gboolean fill, int padding)
Add a GtkWidget in a GtkBox at the initial position.
Definition gtk-misc.c:299
void widget_set_sensitive(GtkWidget *widg, gboolean sensitive)
Set sensitivity for a GtkWidget, ensuring it is a GtkWidget.
Definition gtk-misc.c:206
GtkWidget * create_hbox(int spacing)
create a GtkBox with horizontal orientation
Definition gtk-misc.c:813
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 combo_text_append(GtkWidget *combo, gchar *text)
append text in GtkComboBox widget
Definition gtk-misc.c:900
G_MODULE_EXPORT void run_destroy_dialog(GtkDialog *dialog, gint response_id, gpointer data)
to destroy a GtkDialog when the dialog emit the closing signal
Definition gtk-misc.c:2102
GtkWidget * create_layout(int x, int y)
create a GtkLayout / GtkFixed widget
Definition gtk-misc.c:880
GtkWidget * destroy_this_widget(GtkWidget *widg)
destroy a GtkWidget
Definition gtk-misc.c:2034
GtkWidget * bbox(GtkWidget *box, char *lab)
Definition gtk-misc.c:1921
void update_entry_text(GtkEntry *entry, gchar *text)
update the content of a GtkEntry as string
Definition gtk-misc.c:671
gchar * prepare_for_title(gchar *init)
prepare a string for a window title, getting rid of all markup
Definition tools.c:71
void add_container_child(int type, GtkWidget *widg, GtkWidget *child)
Add a GtkWidget into another GtkWidget.
Definition gtk-misc.c:226
void set_image_from_icon_name(GtkWidget *widg, gchar *icon)
set a image from a stock icon name
Definition gtk-misc.c:1894
void combo_text_prepend(GtkWidget *combo, gchar *text)
prepend text in GtkComboBox widget
Definition gtk-misc.c:913
void hide_the_widgets(GtkWidget *widg)
hide GtkWidget
Definition gtk-misc.c:189
GtkWidget * create_vbox(int spacing)
create a GtkBox with vertical orientation
Definition gtk-misc.c:801
GtkWidget * abox(GtkWidget *box, char *lab, int vspace)
box creating routine, to help design faster elements for the GUI
Definition gtk-misc.c:1912
G_MODULE_EXPORT void label_unlabel_this_atom(GtkWidget *widg, gpointer data)
label / unlabel this atom callback GTK3
Definition popup.c:1128
atomic_object * copied_object
Definition glwindow.c:123
void show_the_widgets(GtkWidget *widg)
show GtkWidget
Definition gtk-misc.c:173
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
action
Definition glview.h:189
gboolean pick
int step
Definition ogl_draw.c:70
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
@ FROM_DATA
Definition glwin.h:74
@ SLABS
Definition glwin.h:101
int get_atom_id_from_periodic_table(atom_search *asearch)
get atom Z from selection in the periodic table
Definition w_periodic.c:672
gchar * env_name(project *this_proj, int g, int s, int f, GtkTextBuffer *buffer)
ouput the name of a coordination sphere
Definition interface.c:889
gchar * exact_name(gchar *name)
short cut to print string without spaces
Definition interface.c:370
integer(kind=c_int) function msd(dlt, ndts)
Definition msd.F90:22
Definition glwin.h:875
gchar * type
Definition global.h:872
gchar * object
Definition global.h:873
coord_info * coord
Definition global.h:954
Definition global.h:104
int b
Definition tab-1.c:95
int c
Definition tab-1.c:95
int a
Definition tab-1.c:95
int status
Definition w_advance.c:160
GtkTreeStore * atom_model
GtkWidget * res[2]
Definition w_encode.c:212
int max_random
Definition w_search.c:2855
GtkTreeModel * replace_combo_tree(gboolean insert, int proj)
replace combo box in the tree view
Definition w_search.c:2626
gboolean atom_is_in_model(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
is this atom already in the tree model if >= 10 000 atoms
Definition w_search.c:1492
void adjust_this_tree_leaf(atom_search *asearch, project *this_proj, int oid, int aid, int new_status, GtkTreeIter iter)
adjust tree leaf (for a single object)
Definition w_search.c:2246
G_MODULE_EXPORT void select_all_atoms(GtkTreeViewColumn *col, gpointer data)
select all element(s) in the tree view column
Definition w_search.c:3357
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
gboolean update_this_search(atom_search *asearch)
test if it is required to update the search tree or not
Definition w_search.c:1329
G_MODULE_EXPORT void to_edit_coords(GtkCellRenderer *cell, GtkCellEditable *editable, gchar *path_string, gpointer data)
to edit data in the atom search tree model
Definition w_search.c:3246
void adjust_object_to_move(project *this_proj, atom_search *asearch, int mv, int id)
adjust atom search parameters for motion cases
Definition w_search.c:523
gboolean get_asearch_is_object(atom_search *asearch)
get asearch object
Definition w_search.c:194
void append_to_model(GtkTreeIter *atom_level, atom_search *asearch, gboolean is_object, int h, int i, project *this_proj)
append data to the search tree store
Definition w_search.c:643
GtkWidget * create_atoms_tree(atom_search *asearch, project *this_proj, int nats)
create atom search tree view
Definition w_search.c:3595
G_MODULE_EXPORT void add_atom(GtkButton *but, gpointer data)
add atom (or object) to the search tree if >= 10 000 atoms
Definition w_search.c:1517
G_MODULE_EXPORT void markup_action_renderer(GtkCellRendererCombo *cell, GtkCellEditable *editable, gchar *path_string, gpointer data)
add pango markup to a combo box inserted in the cell of a tree view
Definition w_search.c:3262
atom_selection * preserve_ogl_selection(glwin *view)
copy the atom selection, so that it can be re-used once the input assistant is closed.
Definition calc.c:264
GtkWidget * selection_tab(atom_search *asearch, int nats)
create the search widget
Definition w_search.c:4141
G_MODULE_EXPORT void set_occupancy(GtkEntry *res, gpointer data)
set occupancy entry callback
Definition w_search.c:2739
G_MODULE_EXPORT void set_max_msd(GtkEntry *res, gpointer data)
set MSD max entry callback
Definition w_search.c:2779
G_MODULE_EXPORT void select_atom(GtkCellRendererToggle *cell_renderer, gchar *string_path, gpointer data)
toggle select / unselect object in the atom search tree model
Definition w_search.c:2333
int check_label_numbers(project *this_proj, int types)
check how many atom label(s) are visible
Definition popup.c:1040
int get_todo_size(atom_search *asearch)
get the size of the atom search selection list
Definition w_search.c:3692
gboolean append(atom_search *asearch, project *this_proj, int i, int j)
test if the atom 'i' of species 'j' must be added to the tree store or not
Definition w_search.c:756
gchar * adjust_picked(gchar *picked, atomic_object *object, gboolean init)
adjust the name of the replacement object to use for a type of object if any
Definition w_search.c:813
G_MODULE_EXPORT void set_i_coord(GtkEntry *res, gpointer data)
set insertion coordinate(s) for the object to be inserted entry callback
Definition w_search.c:2759
int atom_to_edit
Definition w_search.c:2728
G_MODULE_EXPORT void set_atom(GtkEntry *entry, gpointer data)
adjust atom search parameters if >= 10 000 atoms
Definition w_search.c:1356
G_MODULE_EXPORT void set_max_msd_for_all(GtkEntry *res, gpointer data)
set the maximum MSD for all atom(s) / object(s) of the search
Definition w_search.c:3288
void update_search_tree(atom_search *asearch)
update search tree
Definition w_search.c:1305
void create_slab_lists(project *this_proj)
prepare slab(s) OpenGL rendering
Definition d_box.c:898
int get_asearch_num_objects(atom_search *asearch)
the number of type of object(s) in this atom search
Definition w_search.c:125
atom_search * csearch
Definition w_search.c:2729
G_MODULE_EXPORT void set_filter_changed(GtkComboBox *box, gpointer data)
change the search filter
Definition w_search.c:3869
int get_selected_object_id(gboolean visible, int p, gchar *str, atom_search *asearch)
get the id of the object selected (in contextual menu, or in combo box)
Definition w_search.c:2396
void re_populate_tree_search(atom_search *asearch)
re populate search tree after atom action if >= 10 000 atoms
Definition w_search.c:1619
G_MODULE_EXPORT void remove_atom(GtkButton *but, gpointer data)
remove atom (or object) from the search tree if >= 10 000 atoms
Definition w_search.c:1474
void add_random_column(atom_search *asearch)
add a column to the search tree model for the case of random search
Definition w_search.c:3975
int get_asearch_filter(atom_search *asearch)
get asearch filter
Definition w_search.c:170
void get_coord_iter_and_edit(gchar *path_string, gpointer data, GtkWidget *widg)
find iter in the tree model using path string, then edit the data
Definition w_search.c:2886
int get_to_be_selected(glwin *view)
find which atom(s) are to be selected
Definition popup.c:197
void search_set_visible(GtkTreeViewColumn *col, GtkCellRenderer *renderer, GtkTreeModel *mod, GtkTreeIter *iter, gpointer data)
show / hide cell renderer, if visible then add or not pango markup
Definition w_search.c:2711
void restore_ogl_selection(glwin *view)
restore a saved atom selection
Definition calc.c:218
void fill_atom_model(atom_search *asearch, project *this_proj)
fill atom search tree store
Definition w_search.c:893
void adjust_search_param(atom_search *asearch, project *this_proj, int a, int s, int c, gboolean status)
adjust parameters for this atom search
Definition w_search.c:1756
void clean_picked_and_labelled(atom_search *asearch, gboolean clean_msd)
initialize atom search data buffers
Definition w_search.c:3802
G_MODULE_EXPORT void set_max_action(GtkEntry *res, gpointer data)
set how many time(s) to re-do the action
Definition w_search.c:2865
GtkWidget * prepare_box_too_much(atom_search *asearch)
if too many atoms, then individual search
Definition w_search.c:4105
void check_all_trees(project *this_proj)
check all search trees
Definition w_search.c:450
gboolean update_search_model(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
update tree model for each iter
Definition w_search.c:3322
void clear_fields(atom_search *asearch)
clear all search fields if >= 10 000 atoms
Definition w_search.c:1396
void adjust_this_tree_branch(atom_search *asearch, project *this_proj, int oid, int sid, GtkTreeIter iter)
adjust tree branch (for an entire type of object)
Definition w_search.c:1842
gboolean fill_for_action(atom_search *asearch, int i, int j, project *this_proj)
test if the atom 'i' of species 'j' matches requirement(s) to be in the tree store
Definition w_search.c:722
G_MODULE_EXPORT void set_search_digit(GtkEntry *res, gpointer data)
update search entry
Definition w_search.c:4060
gboolean remove_from_model(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
remove from the tree model
Definition w_search.c:1422
void allocate_todo(atom_search *asearch, int tsize)
allocate the selection list data buffer
Definition w_search.c:3728
gchar * get_node_name(int node, atom_search *asearch, project *this_proj)
get node label in the atom search tree store
Definition w_search.c:848
int selected_aspec
Definition popup.c:180
void prep_search_box(GtkWidget *vbox, GtkWidget *lab, GtkWidget *combo)
prepare some search widgets
Definition w_search.c:4087
G_MODULE_EXPORT void set_object_changed(GtkComboBox *box, gpointer data)
change the search object
Definition w_search.c:3895
void clean_todo(atom_search *asearch)
clean atom search selection list
Definition w_search.c:3741
G_MODULE_EXPORT void changed_action_renderer(GtkCellRendererCombo *combo, gchar *path_string, GtkTreeIter *iter, gpointer data)
change combo box in atom search tree model
Definition w_search.c:2527
G_MODULE_EXPORT void set_id(GtkEntry *entry, gpointer data)
set search id if >= 10 000 atoms
Definition w_search.c:1708
void adjust_data_model_to_replace(project *this_proj, atom_search *asearch, int sid, int vid)
adjust the data of the tree model to insert 'vid'
Definition w_search.c:2463
G_MODULE_EXPORT void set_search_mode(GtkComboBox *box, gpointer data)
change search mode
Definition w_search.c:3994
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
G_MODULE_EXPORT void move_up_down(GtkTreeModel *tree_model, GtkTreePath *path, gpointer data)
Move row up or down in the tree model using the mouse.
Definition w_search.c:3535
int select_from_library(gboolean visible, project *this_proj, atom_search *asearch)
select object to insert from the library
Definition w_library.c:1102
G_MODULE_EXPORT void set_spec_changed(GtkComboBox *box, gpointer data)
change the search chemical species
Definition w_search.c:3840
void check_tree_for_this_search(project *this_proj, atom_search *asearch)
check, and adjust if needed, the tree construction for this atom search
Definition w_search.c:214
GtkWidget * hbox
Definition workspace.c:71
GtkWidget * img
Definition workspace.c:70
GtkWidget * vbox
Definition workspace.c:72
GtkWidget * lab
Definition workspace.c:73