atomes 1.1.15
atomes: an atomic scale modeling tool box
Loading...
Searching...
No Matches
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-2024 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 for (h=0; h<val; h++)
1013 {
1014 doit = TRUE;
1015 for (i=0; i<this_proj -> natomes; i++)
1016 {
1017 if (asearch -> spec == 0 || asearch -> spec == this_proj -> atoms[0][i].sp + 1)
1018 {
1019 j = this_proj -> atoms[step][i].coord[filter - 1];
1020 if (filter == 2)
1021 {
1022 for (k=0; k<this_proj -> atoms[0][i].sp; k++) j += this_proj -> coord -> ntg[filter - 1][k];
1023 }
1024 if (j == h)
1025 {
1026 to_insert[h] = append (asearch, this_proj, i, this_proj -> atoms[0][i].sp);
1027 if (to_insert[h])
1028 {
1029 if (asearch -> action == REPLACE && asearch -> in_selection)
1030 {
1031 picked_names[h] = adjust_picked (picked_names[h],
1032 get_atomic_object_by_origin (this_proj -> modelgl -> atom_win -> to_be_inserted[n], (asearch -> mode) ? -(h+3) : (asearch -> passivating) ? h : i, 0),
1033 doit);
1034 }
1035 if (asearch -> action != REPLACE || n || ! picked_names[h] || asearch -> mode) break;
1036 }
1037 }
1038 }
1039 }
1040 }
1041 break;
1042 }
1043 if ((asearch -> action == REPLACE || asearch -> action == REMOVE) && asearch -> mode && obj && filter > 2)
1044 {
1045 if (filter == 3 && this_proj -> coord -> totcoord[2] > 1)
1046 {
1047 str = g_strdup_printf ("Fragments");
1048 gtk_tree_store_append (asearch -> atom_model, & spec_level, NULL);
1049 if (asearch -> set_for_all > 0) asearch -> pick[0] = asearch -> set_for_all;
1050 gtk_tree_store_set (asearch -> atom_model, & spec_level, IDCOL, -1, 1, str, TOPIC, asearch -> pick[0], -1);
1051 g_free (str);
1052 str = g_strdup_printf ("%d", asearch -> todo[0]);
1053 j = (asearch -> action == REMOVE) ? 1 : 2;
1054 gtk_tree_store_set (asearch -> atom_model, & spec_level, TOPIC+j, str, -1);
1055 g_free (str);
1056 if (asearch -> action == REPLACE)
1057 {
1058 if (picked_names[0])
1059 {
1060 str = g_strdup_printf ("For all: %s", picked_names[0]);
1061 gtk_tree_store_set (asearch -> atom_model, & spec_level, TOPIC+1, str, -1);
1062 g_free (str);
1063 }
1064 else
1065 {
1066 gtk_tree_store_set (asearch -> atom_model, & spec_level, TOPIC+1, "Select for all ...", -1);
1067 }
1068 }
1069 }
1070 else if (filter == 4 && this_proj -> modelfc)
1071 {
1072 for (k=0; k<this_proj -> modelfc -> mol_by_step[0]; k++)
1073 {
1074 if (this_proj -> modelfc -> mols[0][k].multiplicity > 1)
1075 {
1076 str = g_strdup_printf ("Molecule N°%d", k+1);
1077 gtk_tree_store_append (asearch -> atom_model, & spec_level, NULL);
1078 if (asearch -> set_for_all > 0) asearch -> pick[k] = asearch -> set_for_all;
1079 gtk_tree_store_set (asearch -> atom_model, & spec_level, IDCOL, -(k+1), 1, str, TOPIC, asearch -> pick[k], -1);
1080 g_free (str);
1081 str = g_strdup_printf ("%d", asearch -> todo[k]);
1082 gtk_tree_store_set (asearch -> atom_model, & spec_level, TOPIC+2, str, -1);
1083 g_free (str);
1084 if (asearch -> action == REPLACE)
1085 {
1086 if (picked_names[k])
1087 {
1088 str = g_strdup_printf ("For all: %s", picked_names[k]);
1089 gtk_tree_store_set (asearch -> atom_model, & spec_level, TOPIC+1, str, -1);
1090 g_free (str);
1091 }
1092 else
1093 {
1094 gtk_tree_store_set (asearch -> atom_model, & spec_level, TOPIC+1, "Select for all ...", -1);
1095 }
1096 }
1097 }
1098 }
1099 }
1100 }
1101 else
1102 {
1103 for (h=0; h<val; h++)
1104 {
1105 if (to_insert[h])
1106 {
1107 gtk_tree_store_append (asearch -> atom_model, & spec_level, NULL);
1108 if (asearch -> action == REPLACE && ! asearch -> mode)
1109 {
1110 g = (asearch -> pointer[0].c == 3) ? 0 : 1;
1111 this_proj -> modelgl -> atom_win -> replace_nodes[g][h] = gtk_tree_model_get_path (GTK_TREE_MODEL(asearch -> atom_model), & spec_level);
1112 }
1113 str = get_node_name (h, asearch, this_proj);
1114 if (asearch -> set_for_all > 0) asearch -> pick[h] = asearch -> set_for_all;
1115 if (asearch -> action < RANMOVE || asearch -> action > RANMOVE)
1116 {
1117 gtk_tree_store_set (asearch -> atom_model, & spec_level, IDCOL, -(h+1), 1, str, TOPIC, asearch -> pick[h], -1);
1118 if (asearch -> passivating)
1119 {
1120 gtk_tree_store_set (asearch -> atom_model, & spec_level, TOLAB, asearch -> lab[h], -1);
1121 }
1122
1123 if (asearch -> set_for_all > 0 && asearch -> action == DISPL && filter > 2)
1124 {
1125 asearch -> todo[h] = asearch -> set_for_all;
1126 adjust_object_to_move (this_proj, asearch, 0, h);
1127 }
1128 if (asearch -> mode)
1129 {
1130 g_free (str);
1131 str = g_strdup_printf ("%d", asearch -> todo[h]);
1132 gtk_tree_store_set (asearch -> atom_model, & spec_level, TOPIC+5-asearch -> action, str, -1);
1133 }
1134 }
1135 else if (asearch -> action == RANMOVE)
1136 {
1137 i = (asearch -> pick[h] == 1 || asearch -> pick[h] == 3) ? 1 : 0;
1138 gtk_tree_store_set (asearch -> atom_model, & spec_level, IDCOL, -(h+1), 1, str, TOPIC, i, -1);
1139 if (is_object)
1140 {
1141 i = (asearch -> pick[h] == 2 || asearch -> pick[h] == 3) ? 1 : 0;
1142 gtk_tree_store_set (asearch -> atom_model, & spec_level, TOPIC+1, i, -1);
1143 if (asearch -> set_for_all > 0)
1144 {
1145 if (filter > 2)
1146 {
1147 asearch -> todo[h] = asearch -> set_for_all;
1148 adjust_object_to_move (this_proj, asearch, 1, h);
1149 }
1150 }
1151 }
1152 }
1153 g_free (str);
1154 if (asearch -> action == REPLACE)
1155 {
1156 if (picked_names[h])
1157 {
1158 if (asearch -> mode || (obj && filter > 2))
1159 {
1160 str = g_strdup_printf ("%s", picked_names[h]);
1161 }
1162 else
1163 {
1164 str = g_strdup_printf ("For all: %s", picked_names[h]);
1165 }
1166 gtk_tree_store_set (asearch -> atom_model, & spec_level, TOPIC+1, str, -1);
1167 g_free (str);
1168 }
1169 else
1170 {
1171 if (asearch -> mode || (obj && filter > 2))
1172 {
1173 gtk_tree_store_set (asearch -> atom_model, & spec_level, TOPIC+1, "Select ...", -1);
1174 }
1175 else
1176 {
1177 gtk_tree_store_set (asearch -> atom_model, & spec_level, TOPIC+1, "Select for all ...", -1);
1178 }
1179 }
1180 }
1181 else if (asearch -> action == RANMOVE)
1182 {
1183 if (this_proj -> modelgl -> atom_win -> msd_all[h] > 0.0)
1184 {
1185 if (obj && filter > 2)
1186 {
1187 str = g_strdup_printf ("MSD<sub>max</sub>= %f", this_proj -> modelgl -> atom_win -> msd_all[h]);
1188 }
1189 else
1190 {
1191 str = g_strdup_printf ("For all: MSD<sub>max</sub>= %f", this_proj -> modelgl -> atom_win -> msd_all[h]);
1192 }
1193 gtk_tree_store_set (asearch -> atom_model, & spec_level, TOPIC+2, str, -1);
1194 g_free (str);
1195 }
1196 else
1197 {
1198 if (obj && filter > 2)
1199 {
1200 gtk_tree_store_set (asearch -> atom_model, & spec_level, TOPIC+2, "Set MSD<sub>max</sub> for ...", -1);
1201 }
1202 else
1203 {
1204 gtk_tree_store_set (asearch -> atom_model, & spec_level, TOPIC+2, "Set MSD<sub>max</sub> for all ...", -1);
1205 }
1206 }
1207 }
1208 doit = FALSE;
1209 if (asearch -> action > REMOVE && asearch -> action != RANMOVE)
1210 {
1211 doit = TRUE;
1212 }
1213 else
1214 {
1215 doit = (asearch -> passivating) ? FALSE : ! asearch -> mode;
1216 }
1217 if (doit && (! obj || (filter > 0 && filter < 3)))
1218 {
1219 for (i=0; i<this_proj -> natomes; i++)
1220 {
1221 do_append = FALSE;
1222 j = this_proj -> atoms[0][i].sp;
1223 if (! filter)
1224 {
1225 if (j == h && append (asearch, this_proj, i, j)) do_append=TRUE;
1226 }
1227 else
1228 {
1229 k = filter - 1;
1230 l = this_proj -> atoms[step][i].coord[k];
1231 if (filter == 1)
1232 {
1233 m = this_proj -> coord -> geolist[0][j][l];
1234 if (m == h && append (asearch, this_proj, i, j)) do_append=TRUE;
1235 }
1236 else
1237 {
1238 if (filter == 2) for (m=0; m<j; m++) l += this_proj -> coord -> ntg[1][m];
1239 if (l == h && append (asearch, this_proj, i, j)) do_append=TRUE;
1240 }
1241 }
1242 if (do_append)
1243 {
1244 gtk_tree_store_append (asearch -> atom_model, & atom_level, & spec_level);
1245 append_to_model (& atom_level, asearch, is_object, h, i, this_proj);
1246 }
1247 }
1248 }
1249 }
1250 }
1251 g_free (to_insert);
1252 if (asearch -> action == DISPL) check_motion_interactors (this_proj, asearch);
1253 if (asearch -> action == REPLACE) g_free (picked_names);
1254 }
1255 //if (asearch -> passivating)
1256 check_tree_for_this_search (this_proj, asearch);
1257 }
1258 }
1259 else
1260 {
1261 i = (asearch -> pointer[0].c == 7) ? 2 : 1;
1262 atomic_object * iobj = this_proj -> modelgl -> atom_win -> to_be_inserted[i];
1263 j = 0;
1264 while (iobj)
1265 {
1266 gtk_list_store_append (asearch -> obj_model, & atom_level);
1267 str = g_strdup_printf ("x= %f, y= %f, z= %f", iobj -> baryc[0], iobj -> baryc[1], iobj -> baryc[2]);
1268 gtk_list_store_set (asearch -> obj_model, & atom_level, IDCOL, j+1, 1, g_strdup_printf ("%d", j+1), 2, iobj -> name,
1269 TOLAB, asearch -> todo[j], TOPIC, str, -1);
1270 g_free (str);
1271 if (i == 2)
1272 {
1273 str = g_strdup_printf ("%f", iobj -> occ);
1274 gtk_list_store_set (asearch -> obj_model, & atom_level, TOPIC+1, str, -1);
1275 g_free (str);
1276 }
1277 j ++;
1278 iobj = iobj -> next;
1279 }
1280 }
1281 if (asearch -> set_for_all > 0) asearch -> set_for_all = -asearch -> set_for_all;
1282}
1283
1284G_MODULE_EXPORT void move_up_down (GtkTreeModel * tree_model, GtkTreePath * path, gpointer data);
1285void add_random_column (atom_search * asearch);
1286
1295{
1296 if (asearch -> pointer[0].c == 7 && asearch -> obj_model)
1297 {
1298 g_signal_handler_disconnect (G_OBJECT(GTK_TREE_MODEL(asearch -> obj_model)), asearch -> filter);
1299 gtk_list_store_clear (asearch -> obj_model);
1300 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);
1301 }
1302 else
1303 {
1304 if (asearch -> atom_model) gtk_tree_store_clear (asearch -> atom_model);
1305 if (asearch -> obj_model) gtk_list_store_clear (asearch -> obj_model);
1306 }
1307 fill_atom_model (asearch, get_project_by_id(asearch -> proj));
1308 //if (asearch -> action) gtk_tree_view_expand_all (GTK_TREE_VIEW(asearch -> atom_tree));
1309}
1310
1319{
1320 int object = get_asearch_object (asearch);
1321 int filter = get_asearch_filter (asearch);
1322 if (asearch -> passivating)
1323 {
1324 return FALSE;
1325 }
1326 else if (! asearch -> passivating && asearch -> todo_size >= 10000)
1327 {
1328 return FALSE;
1329 }
1330 else if (! (object && filter > 2))
1331 {
1332 return TRUE;
1333 }
1334 return FALSE;
1335}
1336
1345G_MODULE_EXPORT void set_atom (GtkEntry * entry, gpointer data)
1346{
1347 atom_search * asearch = (atom_search *)data;
1348 int i;
1349 project * this_proj = get_project_by_id(asearch -> proj);
1350 gchar * str_a, * str_b;
1351 str_a = g_strdup_printf ("%s", entry_get_text (GTK_ENTRY(asearch -> entry_a)));
1352 asearch -> spec_to_add = -1;
1353 for (i = 0; i < this_proj -> nspec; i++)
1354 {
1355 str_b = g_strdup_printf ("%s", exact_name(this_proj -> chemistry -> label[i]));
1356 if (g_strcmp0 (str_a, str_b) == 0)
1357 {
1358 asearch -> spec_to_add = i;
1359 }
1360 g_free (str_b);
1361 }
1362 g_free (str_a);
1363 if (asearch -> spec_to_add != -1)
1364 {
1365 widget_set_sensitive (asearch -> entry_b, 1);
1366 set_image_from_icon_name (asearch -> img_a, APPLY);
1367 }
1368 else
1369 {
1370 widget_set_sensitive (asearch -> entry_b, 0);
1371 widget_set_sensitive (asearch -> but_a, 0);
1372 widget_set_sensitive (asearch -> but_b, 0);
1373 update_entry_text (GTK_ENTRY(asearch -> entry_b), "");
1374 set_image_from_icon_name (asearch -> img_a, DIAL_ERROR);
1375 }
1376}
1377
1386{
1387 int i = gtk_combo_box_get_active (GTK_COMBO_BOX(asearch -> atom_box));
1388 if (i)
1389 {
1390 update_entry_text (GTK_ENTRY(asearch -> entry_a), exact_name(get_project_by_id(asearch -> proj) -> chemistry -> label[i-1]));
1391 }
1392 else
1393 {
1394 update_entry_text (GTK_ENTRY(asearch -> entry_a), "");
1395 }
1396 set_atom (GTK_ENTRY(asearch -> entry_a), asearch);
1397 update_entry_text (GTK_ENTRY(asearch -> entry_b), "");
1398 set_image_from_icon_name (asearch -> img_b, DIAL_ERROR);
1399}
1400
1411gboolean remove_from_model (GtkTreeModel * model, GtkTreePath * path, GtkTreeIter * iter, gpointer data)
1412{
1413 int i, j;
1414 GtkTreeIter parent;
1415 atom_search * asearch = (atom_search *)data;
1416 project * this_proj;
1417 if (gtk_tree_model_get_iter (model, iter, path))
1418 {
1419 gtk_tree_model_get (model, iter, IDCOL, & i, -1);
1420 if (i == asearch -> int_b)
1421 {
1422 j = (i > 0) ? i -- : abs(i) - 1;
1423 asearch -> todo[j] = 0;
1424 if (asearch -> action == REPLACE)
1425 {
1426 j = (i > 0) ? i -- : i - 2;
1427 this_proj = get_project_by_id(asearch -> proj);
1428 clean_this_object (j, 0, this_proj, asearch);
1429 asearch -> in_selection --;
1430 }
1431 if (gtk_tree_model_iter_parent (model, & parent, iter))
1432 {
1433 gtk_tree_store_remove (GTK_TREE_STORE(model), iter);
1434 if (! gtk_tree_model_iter_has_child(model, & parent))
1435 {
1436 gtk_tree_store_remove (GTK_TREE_STORE(model), & parent);
1437 if (asearch -> action == REPLACE)
1438 {
1439 j = abs(i) - 1;
1440 gtk_tree_path_free (this_proj -> modelgl -> atom_win -> replace_nodes[0][j]);
1441 this_proj -> modelgl -> atom_win -> replace_nodes[0][j] = NULL;
1442 }
1443 }
1444 }
1445 else
1446 {
1447 gtk_tree_store_remove (GTK_TREE_STORE(model), iter);
1448 }
1449 return TRUE;
1450 }
1451 }
1452 return FALSE;
1453}
1454
1463G_MODULE_EXPORT void remove_atom (GtkButton * but, gpointer data)
1464{
1465 atom_search * asearch = (atom_search *)data;
1466 asearch -> int_b = (int )string_to_double ((gpointer)entry_get_text (GTK_ENTRY(asearch -> entry_b)));
1467 gtk_tree_model_foreach (GTK_TREE_MODEL(asearch -> atom_model), remove_from_model, asearch);
1468 clear_fields (asearch);
1469}
1470
1481gboolean atom_is_in_model (GtkTreeModel * model, GtkTreePath * path, GtkTreeIter * iter, gpointer data)
1482{
1483 int b;
1484 atom_search * asearch = (atom_search *)data;
1485 if (gtk_tree_model_get_iter (model, iter, path))
1486 {
1487 gtk_tree_model_get (model, iter, IDCOL, & b, -1);
1488 if (b == asearch -> int_b)
1489 {
1490 asearch -> was_selected = TRUE;
1491 asearch -> path = gtk_tree_model_get_path (model, iter);
1492 return TRUE;
1493 }
1494 }
1495 return FALSE;
1496}
1497
1506G_MODULE_EXPORT void add_atom (GtkButton * but, gpointer data)
1507{
1508 atom_search * asearch = (atom_search *)data;
1509 project * this_proj = get_project_by_id(asearch -> proj);
1510 GtkTreeIter spec_level, atom_level, new_level;
1511 int i, j, k, l, m;
1512 i = this_proj -> modelgl -> anim -> last -> img -> step;
1513 j = asearch -> spec_to_add;
1514 int filter = get_asearch_filter (asearch);
1515 gboolean is_object = get_asearch_is_object (asearch);
1516 if (! asearch -> mode)
1517 {
1518 if (append (asearch, this_proj, -1, j))
1519 {
1520 asearch -> was_selected = FALSE;
1521 m = asearch -> int_b;
1522 asearch -> int_b = j+1;
1523 gtk_tree_model_foreach (GTK_TREE_MODEL(asearch -> atom_model), atom_is_in_model, asearch);
1524 if (! asearch -> was_selected)
1525 {
1526 switch (filter)
1527 {
1528 case 0:
1529 l = j;
1530 break;
1531 case 1:
1532 l = this_proj -> atoms[i][asearch -> num_to_add].numv;
1533 break;
1534 case 2:
1535 l = this_proj -> atoms[i][asearch -> num_to_add].coord[filter - 1];
1536 for (k=0; k<j; k++) l += this_proj -> coord -> ntg[filter - 1][k];
1537 break;
1538 default:
1539 l = this_proj -> atoms[i][asearch -> num_to_add].coord[filter - 1];
1540 break;
1541 }
1542 asearch -> int_b = -(l+1);
1543 gchar * str = get_node_name (l, asearch, this_proj);
1544 asearch -> was_selected = FALSE;
1545 gtk_tree_model_foreach (GTK_TREE_MODEL(asearch -> atom_model), atom_is_in_model, asearch);
1546 if (! asearch -> was_selected)
1547 {
1548 gtk_tree_store_append (asearch -> atom_model, & spec_level, NULL);
1549 if (asearch -> action == REPLACE)
1550 {
1551 this_proj -> modelgl -> atom_win -> replace_nodes[0][l] = gtk_tree_model_get_path (GTK_TREE_MODEL(asearch -> atom_model), & spec_level);
1552 }
1553 gtk_tree_store_set (asearch -> atom_model, & spec_level, IDCOL, -(l+1), 1, str, -1);
1554 gtk_tree_store_append (asearch -> atom_model, & atom_level, & spec_level);
1555 append_to_model (& atom_level, asearch, is_object, l, asearch -> num_to_add, this_proj);
1556 }
1557 else
1558 {
1559 // Find out where to insert that node !
1560 gtk_tree_model_get_iter (GTK_TREE_MODEL(asearch -> atom_model), & spec_level, asearch -> path);
1561 if (gtk_tree_model_iter_children (GTK_TREE_MODEL(asearch -> atom_model), & atom_level, & spec_level))
1562 {
1563 gboolean append = FALSE;
1564 gboolean dothat = TRUE;
1565 k = 0;
1566 while (dothat)
1567 {
1568 gtk_tree_model_get (GTK_TREE_MODEL(asearch -> atom_model), & atom_level, IDCOL, & k, -1);
1569 if (k > asearch -> num_to_add)
1570 {
1571 dothat = FALSE;
1572 }
1573 else
1574 {
1575 dothat = gtk_tree_model_iter_next (GTK_TREE_MODEL(asearch -> atom_model), & atom_level);
1576 append = TRUE;
1577 }
1578 }
1579 gtk_tree_store_insert_before (asearch -> atom_model, & new_level, & spec_level, (append) ? NULL : & atom_level);
1580 append_to_model (& new_level, asearch, l, is_object, asearch -> num_to_add, this_proj);
1581 }
1582 }
1583 g_free (str);
1584 asearch -> int_b = m;
1585 if (asearch -> action == REPLACE)
1586 {
1587 gtk_tree_store_set (asearch -> atom_model, & spec_level, TOPIC+1, "Select for all ...", -1);
1588 }
1589 else if (asearch -> action == RANMOVE)
1590 {
1591 str = g_strdup_printf ("Set MSD<sub>max</sub> for all ...");
1592 gtk_tree_store_set (asearch -> atom_model, & spec_level, TOPIC+2, str, -1);
1593 g_free (str);
1594 }
1595 }
1596 }
1597 }
1598 clear_fields (asearch);
1599}
1600
1609{
1610 project * this_proj = get_project_by_id (asearch -> proj);
1611 GtkTreeIter spec_level, atom_level, new_level;
1612 int i, j, k, l, m;
1613 i = this_proj -> modelgl -> anim -> last -> img -> step;
1614 int filter = get_asearch_filter (asearch);
1615 gboolean is_object = get_asearch_is_object (asearch);
1616 int s_int_b = asearch -> int_b;
1617 for (j=0; j<asearch -> todo_size; j++)
1618 {
1619 if (asearch -> todo[j])
1620 {
1621 k = this_proj -> atoms[i][j].sp;
1622 if (append (asearch, this_proj, -1, k))
1623 {
1624 asearch -> was_selected = FALSE;
1625 switch (filter)
1626 {
1627 case 0:
1628 l = k;
1629 break;
1630 case 1:
1631 l = this_proj -> atoms[i][j].numv;
1632 break;
1633 case 2:
1634 l = this_proj -> atoms[i][j].coord[filter - 1];
1635 for (m=0; m<k; m++) l += this_proj -> coord -> ntg[filter - 1][m];
1636 break;
1637 default:
1638 l = this_proj -> atoms[i][j].coord[filter - 1];
1639 break;
1640 }
1641 asearch -> int_b = -(l+1);
1642 gtk_tree_model_foreach (GTK_TREE_MODEL(asearch -> atom_model), atom_is_in_model, asearch);
1643 if (! asearch -> was_selected)
1644 {
1645 gchar * str = get_node_name (l, asearch, this_proj);
1646 gtk_tree_store_append (asearch -> atom_model, & spec_level, NULL);
1647 gtk_tree_store_set (asearch -> atom_model, & spec_level, IDCOL, asearch -> int_b, 1, str, -1);
1648 if (asearch -> action == RANMOVE)
1649 {
1650 str = g_strdup_printf ("Set MSD<sub>max</sub> for all ...");
1651 gtk_tree_store_set (asearch -> atom_model, & spec_level, TOPIC+2, str, -1);
1652 g_free (str);
1653 }
1654 gtk_tree_store_append (asearch -> atom_model, & atom_level, & spec_level);
1655 append_to_model (& atom_level, asearch, is_object, l, j, this_proj);
1656 }
1657 else
1658 {
1659 // Find out where to insert that node !
1660 gtk_tree_model_get_iter (GTK_TREE_MODEL(asearch -> atom_model), & spec_level, asearch -> path);
1661 if (gtk_tree_model_iter_children (GTK_TREE_MODEL(asearch -> atom_model), & atom_level, & spec_level))
1662 {
1663 gboolean append = FALSE;
1664 gboolean dothat = TRUE;
1665 k = 0;
1666 while (dothat)
1667 {
1668 gtk_tree_model_get (GTK_TREE_MODEL(asearch -> atom_model), & atom_level, IDCOL, & k, -1);
1669 if (k > j)
1670 {
1671 dothat = FALSE;
1672 }
1673 else
1674 {
1675 dothat = gtk_tree_model_iter_next (GTK_TREE_MODEL(asearch -> atom_model), & atom_level);
1676 append = TRUE;
1677 }
1678 }
1679 gtk_tree_store_insert_before (asearch -> atom_model, & new_level, & spec_level, (append) ? NULL : & atom_level);
1680 append_to_model (& new_level, asearch, is_object, l, j, this_proj);
1681 }
1682 }
1683 }
1684 }
1685 }
1686 asearch -> int_b = s_int_b;
1687}
1688
1697G_MODULE_EXPORT void set_id (GtkEntry * entry, gpointer data)
1698{
1699 atom_search * asearch = (atom_search *)data;
1700 project * this_proj = get_project_by_id(asearch -> proj);
1701 asearch -> int_b = (int )string_to_double ((gpointer)entry_get_text (GTK_ENTRY(asearch -> entry_b)));
1702 if (asearch -> int_b > 0 && asearch -> int_b < this_proj -> natomes+1)
1703 {
1704 asearch -> was_selected = FALSE;
1705 gtk_tree_model_foreach (GTK_TREE_MODEL(asearch -> atom_model), atom_is_in_model, asearch);
1706 int s = this_proj -> modelgl -> anim -> last -> img -> step;
1707 asearch -> int_b --;
1708 if (asearch -> was_selected && this_proj -> atoms[s][asearch -> int_b].sp == asearch -> spec_to_add)
1709 {
1710 widget_set_sensitive (asearch -> but_a, 0);
1711 widget_set_sensitive (asearch -> but_b, 1);
1712 set_image_from_icon_name (asearch -> img_b, APPLY);
1713 }
1714 else
1715 {
1716 if (this_proj -> atoms[s][asearch -> int_b].sp == asearch -> spec_to_add)
1717 {
1718 asearch -> num_to_add = asearch -> int_b;
1719 widget_set_sensitive (asearch -> but_a, 1);
1720 widget_set_sensitive (asearch -> but_b, 0);
1721 set_image_from_icon_name (asearch -> img_b, APPLY);
1722 }
1723 else
1724 {
1725 widget_set_sensitive (asearch -> but_a, 0);
1726 widget_set_sensitive (asearch -> but_b, 0);
1727 set_image_from_icon_name (asearch -> img_b, DIAL_ERROR);
1728 }
1729 }
1730 }
1731}
1732
1745void adjust_search_param (atom_search * asearch, project * this_proj, int a, int s, int c, gboolean status)
1746{
1747 int i, j, k, l, m;
1748 opengl_project_changed (asearch -> proj);
1749 i = (a < 0) ? 0 : a;
1750 for (j=i; j<this_proj -> natomes; j++)
1751 {
1752 k = this_proj -> atoms[0][j].pick[0];
1753 l = this_proj -> atoms[0][j].sp;
1754 m = this_proj -> atoms[0][j].label[0];
1755 if (s < 0 || l == s)
1756 {
1757 if (asearch -> status == 2 || asearch -> status == k)
1758 {
1759 if (a == j || a < 0)
1760 {
1761 switch (c)
1762 {
1763 case TOLAB:
1764#ifdef GTK4
1765 if (m != status) label_unlabel_this_atom (NULL, NULL, GINT_TO_POINTER(j));
1766#else
1767 if (m != status) label_unlabel_this_atom (NULL, GINT_TO_POINTER(j));
1768#endif
1769 break;
1770 default:
1771 if (asearch -> action != RANMOVE)
1772 {
1773 asearch -> todo[j] = status;
1774 if (asearch -> action == DISPL && asearch -> object) adjust_object_to_move (this_proj, asearch, 0, j);
1775 }
1776 else
1777 {
1778 switch (asearch -> todo[j])
1779 {
1780 case 0:
1781 asearch -> todo[j] += (c-TOLAB);
1782 break;
1783 case 1:
1784 if (c == TOPIC)
1785 {
1786 asearch -> todo[j] -= (c-TOLAB);
1787 }
1788 else
1789 {
1790 asearch -> todo[j] += (c-TOLAB);
1791 }
1792 break;
1793 case 2:
1794 if (c == TOPIC)
1795 {
1796 asearch -> todo[j] += (c-TOLAB);
1797 }
1798 else
1799 {
1800 asearch -> todo[j] -= (c-TOLAB);
1801 }
1802 break;
1803 case 3:
1804 asearch -> todo[j] -= (c-TOLAB);
1805 break;
1806 }
1807 if (asearch -> object) adjust_object_to_move (this_proj, asearch, 1, j);
1808 }
1809 break;
1810 }
1811 }
1812 if (a == j) break;
1813 }
1814 }
1815 }
1816}
1817
1818G_MODULE_EXPORT void set_spec_changed (GtkComboBox * box, gpointer data);
1819
1831void adjust_this_tree_branch (atom_search * asearch, project * this_proj, int oid, int sid, GtkTreeIter iter)
1832{
1833 int k, l, m, n, o, p, q;
1834 int status;
1835 int * to_label = NULL;
1836 int is_clone = (asearch -> action == 1) ? 1 : 0;
1837 int object = get_asearch_object (asearch);
1838 int filter = get_asearch_filter (asearch);
1839 gboolean doit;
1840 GtkTreeModel * model = (asearch -> action == INSERT) ? GTK_TREE_MODEL(asearch -> obj_model) : GTK_TREE_MODEL(asearch -> atom_model);
1841 opengl_project_changed (this_proj -> id);
1842 gtk_tree_model_get (model, & iter, oid, & status, -1);
1843 atom_in_selection * selected;
1844 if (asearch -> action < 2 && oid == TOPIC)
1845 {
1847 switch (filter)
1848 {
1849 case 0:
1850 selected_aspec = sid;
1851#ifdef GTK4
1852 select_unselect_atoms (NULL, NULL, & this_proj -> modelgl -> colorp[0][! status]);
1853#else
1854 select_unselect_atoms (NULL, & this_proj -> modelgl -> colorp[0][! status]);
1855#endif
1856 break;
1857 default:
1858 if (filter < 3)
1859 {
1860 k = this_proj -> modelgl -> selection_mode;
1861 this_proj -> modelgl -> selection_mode = object;
1862 }
1863 p = this_proj -> modelgl -> anim -> last -> img -> step;
1864 for (l=0; l<this_proj -> natomes; l++)
1865 {
1866 n = this_proj -> atoms[p][l].sp;
1867 o = this_proj -> atoms[p][l].coord[filter-1];
1868 doit = FALSE;
1869 if (filter == 1)
1870 {
1871 if (this_proj -> atoms[p][l].numv == sid && append (asearch, this_proj, l, n)) doit = TRUE;
1872 }
1873 else
1874 {
1875 if (filter == 2)
1876 {
1877 for (m=0; m<n; m++)
1878 {
1879 o += this_proj -> coord -> ntg[1][m];
1880 }
1881 }
1882 if (o == sid && append (asearch, this_proj, l, n)) doit = TRUE;
1883 }
1884 if (doit)
1885 {
1886 o = get_to_be_selected (this_proj -> modelgl);
1887#ifdef GTK4
1888 if (this_proj -> atoms[p][l].pick[o] != status)
1889 {
1890 select_unselect_this_atom (NULL, NULL, GINT_TO_POINTER(l));
1891 }
1892 select_unselect_this_atom (NULL, NULL, GINT_TO_POINTER(l));
1893#else
1894 if (this_proj -> atoms[p][l].pick[o] != status)
1895 {
1896 select_unselect_this_atom (NULL, GINT_TO_POINTER(l));
1897 }
1898 select_unselect_this_atom (NULL, GINT_TO_POINTER(l));
1899#endif
1900 }
1901 }
1902 if (filter < 3) this_proj -> modelgl -> selection_mode = k;
1903 break;
1904 }
1905 }
1906 else
1907 {
1908 if (asearch -> action != INSERT)
1909 {
1910 if (oid == TOLAB)
1911 {
1912 if (asearch -> pointer[0].c == 8)
1913 {
1914 preserve_ogl_selection (this_proj -> modelgl);
1915 this_proj -> modelgl -> cell_win -> cut_this_slab = TRUE;
1916 save_all_selections (this_proj -> modelgl, 0);
1917 create_slab_lists (this_proj);
1918 update_all_selections (this_proj -> modelgl, 0);
1919 q = 0;
1920 if (this_proj -> modelgl -> anim -> last -> img -> selected[0] -> selected)
1921 {
1922 to_label = allocint (this_proj -> modelgl -> anim -> last -> img -> selected[0] -> selected);
1923 }
1924 }
1925 p = this_proj -> modelgl -> anim -> last -> img -> step;
1926 switch (filter)
1927 {
1928 case 0:
1929 if (asearch -> pointer[0].c == 8)
1930 {
1931 if (this_proj -> modelgl -> anim -> last -> img -> selected[0] -> selected)
1932 {
1933 selected = this_proj -> modelgl -> anim -> last -> img -> selected[0] -> first;
1934 while (selected)
1935 {
1936 if (selected -> sp == sid)
1937 {
1938 to_label[q] = selected -> id;
1939 q ++;
1940 }
1941 selected = selected -> next;
1942 }
1943 }
1944 }
1945 else
1946 {
1947#ifdef GTK4
1948 show_hide_labels (NULL, NULL, & this_proj -> modelgl -> colorp[is_clone][sid]);
1949#else
1950 // GTK3 Menu Action To Check
1951 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)this_proj -> modelgl -> ogl_lab[is_clone][sid], ! status);
1952 show_hide_labels (this_proj -> modelgl -> ogl_lab[is_clone][sid], & this_proj -> modelgl -> colorp[is_clone][sid]);
1953#endif
1954 }
1955 break;
1956 default:
1957 if (filter < 3)
1958 {
1959 k = this_proj -> modelgl -> selection_mode;
1960 this_proj -> modelgl -> selection_mode = object;
1961 }
1962 for (l=0; l<this_proj -> natomes; l++)
1963 {
1964 n = this_proj -> atoms[p][l].sp;
1965 o = this_proj -> atoms[p][l].coord[filter-1];
1966 doit = FALSE;
1967 if (filter == 1)
1968 {
1969 if (this_proj -> atoms[p][l].numv == sid && append (asearch, this_proj, l, n)) doit = TRUE;
1970 }
1971 else if (filter == 2 || filter == 4)
1972 {
1973 if (filter == 2)
1974 {
1975 for (m=0; m<n; m++)
1976 {
1977 o += this_proj -> coord -> ntg[1][m];
1978 }
1979 }
1980 if (o == sid && append (asearch, this_proj, l, n)) doit = TRUE;
1981 }
1982 else if (filter == 3)
1983 {
1984 if (asearch -> mode && object)
1985 {
1986 doit = TRUE;
1987 }
1988 else
1989 {
1990 if (o == sid && append (asearch, this_proj, l, n)) doit = TRUE;
1991 }
1992 }
1993 if (doit)
1994 {
1995 if (asearch -> pointer[0].c == 8)
1996 {
1997 if (this_proj -> modelgl -> anim -> last -> img -> selected[0] -> selected)
1998 {
1999 selected = this_proj -> modelgl -> anim -> last -> img -> selected[0] -> first;
2000 while (selected)
2001 {
2002 if (selected -> id == l)
2003 {
2004 to_label[q] = l;
2005 q ++;
2006 }
2007 selected = selected -> next;
2008 }
2009 }
2010 }
2011 else
2012 {
2013 this_proj -> atoms[p][l].label[0] = status;
2014#ifdef GTK4
2015 label_unlabel_this_atom (NULL, NULL, GINT_TO_POINTER(l));
2016#else
2017 label_unlabel_this_atom (NULL, GINT_TO_POINTER(l));
2018#endif
2019 }
2020 }
2021 }
2022 if (filter < 3) this_proj -> modelgl -> selection_mode = k;
2023 break;
2024 }
2025
2026 if (asearch -> pointer[0].c == 8)
2027 {
2028 restore_ogl_selection (this_proj -> modelgl);
2029 if (q)
2030 {
2031 for (l=0; l<q; l++)
2032 {
2033 m = to_label[l];
2034 this_proj -> atoms[0][m].label[0] = ! status;
2035 this_proj -> atoms[0][m].label[1] = ! status;
2036 }
2037 g_free (to_label);
2038 }
2039 this_proj -> modelgl -> cell_win -> cut_this_slab = FALSE;
2040 this_proj -> modelgl -> create_shaders[SLABS] = TRUE;
2041 gtk_tree_store_set (asearch -> atom_model, & iter, TOLAB, ! status, -1);
2042 }
2043 }
2044 else
2045 {
2046 if (asearch -> passivating || (object && filter > 2))
2047 {
2048 if (asearch -> action == RANMOVE)
2049 {
2050 if (! status)
2051 {
2052 asearch -> todo[sid] += (oid-TOLAB);
2053 }
2054 else
2055 {
2056 asearch -> todo[sid] -= (oid-TOLAB);
2057 }
2058 if (object && ! asearch -> passivating) adjust_object_to_move (this_proj, asearch, 1, sid);
2059 }
2060 else
2061 {
2062 asearch -> todo[sid] = ! status;
2063 if (asearch -> action == DISPL)
2064 {
2065 if (object && ! asearch -> passivating) adjust_object_to_move (this_proj, asearch, 0, sid);
2066 motion_to_zero (asearch);
2067 }
2068 }
2069 }
2070 else if (! asearch -> mode)
2071 {
2072 switch (filter)
2073 {
2074 case 0:
2075 for (l=0; l<this_proj -> natomes; l++)
2076 {
2077 n = this_proj -> atoms[0][l].sp;
2078 if (n == sid && append (asearch, this_proj, l, n))
2079 {
2080 if (asearch -> action == RANMOVE)
2081 {
2082 if (! status)
2083 {
2084 asearch -> todo[l] += (oid-TOLAB);
2085 }
2086 else
2087 {
2088 asearch -> todo[l] -= (oid-TOLAB);
2089 }
2090 if (object) adjust_object_to_move (this_proj, asearch, 1, l);
2091 }
2092 else
2093 {
2094 asearch -> todo[l] = ! status;
2095 if (asearch -> action == DISPL && object) adjust_object_to_move (this_proj, asearch, 0, l);
2096 }
2097 }
2098 }
2099 break;
2100 case 1:
2101 for (l=0; l<this_proj -> natomes; l++)
2102 {
2103 n = this_proj -> atoms[0][l].sp;
2104 if (this_proj -> atoms[0][l].numv == sid && append (asearch, this_proj, l, n))
2105 {
2106 if (asearch -> action == RANMOVE)
2107 {
2108 if (! status)
2109 {
2110 asearch -> todo[l] += (oid-TOLAB);
2111 }
2112 else
2113 {
2114 asearch -> todo[l] -= (oid-TOLAB);
2115 }
2116 if (object) adjust_object_to_move (this_proj, asearch, 1, l);
2117 }
2118 else
2119 {
2120 asearch -> todo[l] = ! status;
2121 if (asearch -> action == DISPL && object) adjust_object_to_move (this_proj, asearch, 0, l);
2122 }
2123 }
2124 }
2125 break;
2126 case 2:
2127 for (l=0; l<this_proj -> natomes; l++)
2128 {
2129 n = this_proj -> atoms[0][l].sp;
2130 o = this_proj -> atoms[0][l].coord[filter-1];
2131 for (m=0; m<n; m++)
2132 {
2133 o += this_proj -> coord -> ntg[1][m];
2134 }
2135 if (o == sid && append (asearch, this_proj, l, n))
2136 {
2137 if (asearch -> action == RANMOVE)
2138 {
2139 if (! status)
2140 {
2141 asearch -> todo[l] += (oid-TOLAB);
2142 }
2143 else
2144 {
2145 asearch -> todo[l] -= (oid-TOLAB);
2146 }
2147 if (object) adjust_object_to_move (this_proj, asearch, 1, l);
2148 }
2149 else
2150 {
2151 asearch -> todo[l] = ! status;
2152 if (asearch -> action == DISPL && object) adjust_object_to_move (this_proj, asearch, 0, l);
2153 }
2154 }
2155 }
2156 break;
2157 default:
2158 for (l=0; l<this_proj -> natomes; l++)
2159 {
2160 n = this_proj -> atoms[0][l].sp;
2161 o = this_proj -> atoms[0][l].coord[filter-1];
2162 if (o == sid && append (asearch, this_proj, l, n))
2163 {
2164 if (asearch -> action == RANMOVE)
2165 {
2166 if (! status)
2167 {
2168 asearch -> todo[l] += (oid-TOLAB);
2169 }
2170 else
2171 {
2172 asearch -> todo[l] -= (oid-TOLAB);
2173 }
2174 if (object) adjust_object_to_move (this_proj, asearch, 1, l);
2175 }
2176 else
2177 {
2178 asearch -> todo[l] = ! status;
2179 if (asearch -> action == DISPL && object) adjust_object_to_move (this_proj, asearch, 0, l);
2180 }
2181 }
2182 }
2183 break;
2184 }
2185 }
2186 }
2187 }
2188 else
2189 {
2190 for (k=0; k<asearch -> in_selection; k++)
2191 {
2192 asearch -> todo[k] = ! status;
2193 }
2194 }
2195 }
2196 switch (oid)
2197 {
2198 case TOLAB:
2199 if (asearch -> action == INSERT) asearch -> pick[sid] = ! status;
2200 asearch -> lab[sid] = ! status;
2201 break;
2202 default:
2203 if (asearch -> action == RANMOVE)
2204 {
2205 if (! status)
2206 {
2207 asearch -> pick[sid] += (oid-TOLAB);
2208 }
2209 else
2210 {
2211 asearch -> pick[sid] -= (oid-TOLAB);
2212 }
2213 }
2214 else
2215 {
2216 asearch -> pick[sid] = ! status;
2217 }
2218 break;
2219 }
2220 if (asearch -> todo_size < 10000 || asearch -> passivating || (object == 2 && filter > 2)) update_search_tree (asearch);
2221}
2222
2235void adjust_this_tree_leaf (atom_search * asearch, project * this_proj, int oid, int aid, int new_status, GtkTreeIter iter)
2236{
2237 int status;
2238 int k, l, p;
2239 opengl_project_changed (this_proj -> id);
2240 int sel = this_proj -> modelgl -> selection_mode;
2241 int is_clone = (asearch -> action == 1) ? 1 : 0;
2242 int object = (asearch -> object) ? 1 : 0;
2243 this_proj -> modelgl -> selection_mode = object;
2244 p = this_proj -> modelgl -> anim -> last -> img -> step;
2245 // For atom i
2246 if (oid == TOLAB)
2247 {
2248 if (asearch -> action == INSERT)
2249 {
2250 if (asearch -> todo[aid] != new_status || new_status < 0)
2251 {
2252 status = ! asearch -> todo[aid];
2253 asearch -> todo[aid] = status;
2254 }
2255 }
2256 else if (this_proj -> atoms[p][aid].label[is_clone] != new_status || new_status < 0)
2257 {
2258#ifdef GTK4
2259 label_unlabel_this_atom (NULL, NULL, GINT_TO_POINTER(aid));
2260#else
2261 label_unlabel_this_atom (NULL, GINT_TO_POINTER(aid));
2262#endif
2263 status = this_proj -> atoms[p][aid].label[is_clone];
2264 }
2265 }
2266 else
2267 {
2268 if (asearch -> action < 2)
2269 {
2270 if (this_proj -> atoms[p][aid].pick[0] != new_status || new_status < 0)
2271 {
2272 // selected_status = ! this_proj -> atoms[p][aid].pick[get_to_be_selected (this_proj -> modelgl)];
2273 selected_status = ! this_proj -> atoms[p][aid].pick[0];
2274#ifdef GTK4
2275 select_unselect_this_atom (NULL, NULL, GINT_TO_POINTER(aid));
2276#else
2277 select_unselect_this_atom (NULL, GINT_TO_POINTER(aid));
2278#endif
2279 status = this_proj -> atoms[p][aid].pick[0];
2280 }
2281 }
2282 else
2283 {
2284 if (asearch -> todo[aid] != new_status || new_status < 0)
2285 {
2286 status = ! asearch -> todo[aid];
2287 adjust_search_param (asearch, this_proj, aid, this_proj -> atoms[p][aid].sp, oid, status);
2288 }
2289 }
2290 }
2291 status = (new_status < 0) ? status : new_status;
2292 if (asearch -> action == RANMOVE && oid != TOLAB)
2293 {
2294 k = (asearch -> todo[aid] == 1 || asearch -> todo[aid] == 3) ? 1 : 0;
2295 l = (asearch -> todo[aid] == 2 || asearch -> todo[aid] == 3) ? 1 : 0;
2296 // Check 'for all'
2297 gtk_tree_store_set (asearch -> atom_model, & iter, TOPIC, k, -1);
2298 if (object) gtk_tree_store_set (asearch -> atom_model, & iter, TOPIC+1, l, -1);
2299 }
2300 else if (asearch -> action == INSERT)
2301 {
2302 gtk_list_store_set (asearch -> obj_model, & iter, oid, status, -1);
2303 }
2304 else
2305 {
2306 if (asearch -> action == DISPL && oid != TOLAB) motion_to_zero (asearch);
2307 gtk_tree_store_set (asearch -> atom_model, & iter, oid, status, -1);
2308 }
2309 this_proj -> modelgl -> selection_mode = sel;
2310 check_all_trees (this_proj);
2311}
2312
2322G_MODULE_EXPORT void select_atom (GtkCellRendererToggle * cell_renderer, gchar * string_path, gpointer data)
2323{
2324 int i, j, k;
2325 GtkTreeIter iter;
2326 tint * dat = (tint *)data;
2327 project * this_proj = get_project_by_id(dat -> a);
2328 atom_search * asearch = this_proj -> modelgl -> search_widg[dat -> c];
2329 GtkTreePath * path = gtk_tree_path_new_from_string (string_path);
2330 GtkTreeModel * model = (asearch -> action == INSERT) ? GTK_TREE_MODEL(asearch -> obj_model) : GTK_TREE_MODEL(asearch -> atom_model);
2331 gtk_tree_model_get_iter (model, & iter, path);
2332 gtk_tree_model_get (model, & iter, IDCOL, & i, -1);
2333 check_label = FALSE;
2334 if (this_proj -> modelgl -> atom_win)
2335 {
2336 this_proj -> modelgl -> atom_win -> rebuilt[(asearch -> action == RANMOVE) ? 1 : 0] = FALSE;
2337 }
2338 if (i > 0)
2339 {
2340 i --;
2341 // For atom i
2342 adjust_this_tree_leaf (asearch, this_proj, dat -> b, i, -1, iter);
2343 }
2344 else
2345 {
2346 // For spec i
2347 if (asearch -> todo_size >= 10000 && ! asearch -> passivating)
2348 {
2349 GtkTreeIter child;
2350 gtk_tree_model_get (GTK_TREE_MODEL(asearch -> atom_model), & iter, dat -> b, & j, -1);
2351 gtk_tree_store_set (asearch -> atom_model, & iter, dat -> b, ! j, -1);
2352 if (gtk_tree_model_iter_children (GTK_TREE_MODEL(asearch -> atom_model), & child, & iter))
2353 {
2354 gboolean dothis = TRUE;
2355 while (dothis)
2356 {
2357 gtk_tree_model_get (GTK_TREE_MODEL(asearch -> atom_model), & child, IDCOL, & k, -1);
2358 k --;
2359 adjust_this_tree_leaf (asearch, this_proj, dat -> b, k, ! j, child);
2360 dothis = gtk_tree_model_iter_next (GTK_TREE_MODEL(asearch -> atom_model), & child);
2361 }
2362 }
2363 }
2364 else
2365 {
2366 adjust_this_tree_branch (asearch, this_proj, dat -> b, abs(i) - 1, iter);
2367 }
2368 }
2369 if (asearch -> action == DISPL) check_motion_interactors (this_proj, asearch);
2370 check_label = TRUE;
2371 this_proj -> modelgl -> labelled = check_label_numbers (this_proj, 2);
2372 update (this_proj -> modelgl);
2373}
2374
2385int get_selected_object_id (gboolean visible, int p, gchar * str, atom_search * asearch)
2386{
2387 int i, j;
2388 gchar * word, * name;
2389 for (i = 1; mol[i].type || mol[i].object; i++)
2390 {
2391 if (mol[i].object != NULL)
2392 {
2393 if (g_strcmp0 (mol[i].object, str) == 0)
2394 {
2395 if (i < 9)
2396 {
2397 return (int) mol[i].Z;
2398 }
2399 else if (i == 9)
2400 {
2401 return get_atom_id_from_periodic_table (asearch);
2402 }
2403 else if (i > 10 && i < 17)
2404 {
2405 return insert_this_project_from_lib (i-11, visible, get_project_by_id(p), asearch);
2406 }
2407 else if (i == 17)
2408 {
2409 return select_from_library (visible, get_project_by_id(p), asearch);
2410 }
2411 }
2412 }
2413 }
2414 for (i=0; i<nprojects; i++)
2415 {
2416 name = g_strdup_printf ("%s (%d)", get_project_by_id(i) -> name, i+1);
2417 for (j=0; j<3; j++)
2418 {
2419 word = g_strdup_printf ("%s in %s", action_atoms[j], name);
2420 if (g_strcmp0 (word, str) == 0)
2421 {
2422 g_free (word);
2423 g_free (name);
2424 get_project_by_id(p) -> modelgl -> other_status = j;
2426 }
2427 else
2428 {
2429 g_free (word);
2430 }
2431 }
2432 g_free (name);
2433 }
2434 if (g_strcmp0 ("Copied data", str) == 0)
2435 {
2436 return FROM_DATA;
2437 }
2438 if (g_strcmp0 ("Empty position", str) == 0) return 120;
2439 return 0;
2440}
2441
2452void adjust_data_model_to_replace (project * this_proj, atom_search * asearch, int sid, int vid)
2453{
2454 int i, j, k, l;
2455 int filter = get_asearch_filter (asearch);
2456 switch (filter)
2457 {
2458 case 0:
2459 for (i=0; i<this_proj -> natomes; i++)
2460 {
2461 if (this_proj -> atoms[0][i].sp == sid && append (asearch, this_proj, i, this_proj -> atoms[0][i].sp))
2462 {
2463 to_insert_in_project (vid, i, this_proj, asearch, TRUE);
2464 }
2465 }
2466 break;
2467 case 1:
2468 for (i=0; i<this_proj -> natomes; i++)
2469 {
2470 if (this_proj -> atoms[0][i].numv == sid)
2471 {
2472 j = this_proj -> atoms[0][i].sp;
2473 if (append (asearch, this_proj, i, j))
2474 {
2475 to_insert_in_project (vid, i, this_proj, asearch, TRUE);
2476 }
2477 }
2478 }
2479 break;
2480 case 2:
2481 for (i=0; i<this_proj -> natomes; i++)
2482 {
2483 j = this_proj -> atoms[0][i].sp;
2484 k = this_proj -> atoms[0][i].coord[1];
2485 for (l=0; l<j; l++) k += this_proj -> coord -> ntg[1][l];
2486 if (k == sid && append (asearch, this_proj, i, j))
2487 {
2488 to_insert_in_project (vid, i, this_proj, asearch, TRUE);
2489 }
2490 }
2491 break;
2492 default:
2493 for (i=0; i<this_proj -> natomes; i++)
2494 {
2495 j = this_proj -> atoms[0][i].sp;
2496 k = this_proj -> atoms[0][i].coord[filter-1];
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 }
2504}
2505
2516G_MODULE_EXPORT void changed_action_renderer (GtkCellRendererCombo * combo, gchar * path_string, GtkTreeIter * iter, gpointer data)
2517{
2518 tint * dat = (tint *)data;
2519 project * this_proj = get_project_by_id(dat -> a);
2520 int h, i, j, k;
2521 atom_search * asearch = this_proj -> modelgl -> search_widg[dat -> c];
2522 GValue val = {0, };
2523 GObject * cmodel;
2524 g_object_get (combo, "model", & cmodel, NULL);
2525 gtk_tree_model_get_value ((GtkTreeModel *)cmodel, iter, 0, & val);
2526 GtkTreeIter child;
2527 gboolean dothis;
2528 GtkTreeModel * model = (asearch -> action == INSERT) ? GTK_TREE_MODEL(asearch -> obj_model) : GTK_TREE_MODEL(asearch -> atom_model);
2529 if (gtk_tree_model_get_iter_from_string (model, iter, path_string))
2530 {
2531 gtk_tree_model_get (model, iter, IDCOL, & h, -1);
2532 gchar * str = g_strdup_printf ("%s", (char *)g_value_get_string (& val));
2533 i = get_selected_object_id (TRUE, this_proj -> id, str, asearch);
2534 g_free (str);
2535 int object = get_asearch_object (asearch);
2536 int filter = get_asearch_filter (asearch);
2537 k = (asearch -> pointer[0].c == 3) ? 0 : (asearch -> pointer[0].c == 5) ? 1 : 3;
2538 if (h > 0 || (object && ! asearch -> passivating && filter > 2) || asearch -> passivating || asearch -> mode)
2539 {
2540 // Single atom or object
2541 if (i)
2542 {
2543 j = (asearch -> mode) ? h - 2 : abs(h) - 1;
2544 to_insert_in_project (i, j, this_proj, asearch, TRUE);
2545 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);
2546 gtk_tree_store_set (asearch -> atom_model, iter, TOPIC+1, str, -1);
2547 g_free (str);
2548 }
2549 else
2550 {
2551 gtk_tree_store_set (asearch -> atom_model, iter, TOPIC+1, (h > 0) ? "Select ..." : "Select for all ...", -1);
2552 }
2553 }
2554 else
2555 {
2556 // The entire species
2557 if (i)
2558 {
2559 if (! asearch -> passivating && this_proj -> natomes >= 10000)
2560 {
2561 if (gtk_tree_model_iter_children (GTK_TREE_MODEL(asearch -> atom_model), & child, iter))
2562 {
2563 dothis = TRUE;
2564 while (dothis)
2565 {
2566 gtk_tree_model_get (GTK_TREE_MODEL(asearch -> atom_model), & child, IDCOL, & j, -1);
2567 j --;
2568 to_insert_in_project (i, j, this_proj, asearch, TRUE);
2569 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);
2570 dothis = gtk_tree_model_iter_next (GTK_TREE_MODEL(asearch -> atom_model), & child);
2571 }
2572 }
2573 str = g_strdup_printf ("For all: %s", get_atomic_object_by_origin(this_proj -> modelgl -> atom_win -> to_be_inserted[k], j, 0) -> name);
2574 gtk_tree_store_set (asearch -> atom_model, iter, TOPIC+1, str, -1);
2575 g_free (str);
2576 }
2577 else
2578 {
2579 adjust_data_model_to_replace (this_proj, asearch, abs(h)-1, i);
2580 }
2581 }
2582 else
2583 {
2584 if (! asearch -> passivating && this_proj -> natomes >= 10000)
2585 {
2586 gtk_tree_store_set (asearch -> atom_model, iter, 5, "Select for all ...", -1);
2587 if (gtk_tree_model_iter_children (GTK_TREE_MODEL(asearch -> atom_model), & child, iter))
2588 {
2589 dothis = TRUE;
2590 while (dothis)
2591 {
2592 gtk_tree_store_set (asearch -> atom_model, & child, TOPIC+1, "Select ...", -1);
2593 dothis = gtk_tree_model_iter_next (GTK_TREE_MODEL(asearch -> atom_model), & child);
2594 }
2595 }
2596 }
2597 else
2598 {
2599 gtk_tree_store_set (asearch -> atom_model, iter, 5, "Select ...", -1);
2600 }
2601 }
2602 }
2603 if (update_this_search(asearch)) update_search_tree (asearch);
2604 }
2605}
2606
2615GtkTreeModel * replace_combo_tree (gboolean insert, int proj)
2616{
2617 GtkTreeIter iter, iter2, iter3;
2618 GtkTreeStore *store;
2619 int i, j;
2620 gchar * name, * word;
2621
2622 store = gtk_tree_store_new (1, G_TYPE_STRING);
2623
2624 if (insert)
2625 {
2626 gtk_tree_store_append (store, & iter, NULL);
2627 gtk_tree_store_set (store, & iter, 0, "Select ...", -1);
2628 }
2629 for (i=0; mol[i].type || mol[i].object; i++)
2630 {
2631 if (mol[i].type)
2632 {
2633 gtk_tree_store_append (store, & iter, NULL);
2634 gtk_tree_store_set (store, & iter, 0, mol[i].type, -1);
2635 }
2636 else if (mol[i].object)
2637 {
2638 gtk_tree_store_append (store, & iter2, & iter);
2639 gtk_tree_store_set (store, & iter2, 0, mol[i].object, -1);
2640 }
2641 }
2642 gboolean doit = FALSE;
2643 for (i=0; i<nprojects; i++)
2644 {
2645 if (get_project_by_id(i) -> steps == 1 && get_project_by_id(i) -> natomes)
2646 {
2647 doit = TRUE;
2648 break;
2649 }
2650 }
2651 if (doit)
2652 {
2653 gtk_tree_store_append (store, & iter, NULL);
2654 gtk_tree_store_set (store, & iter, 0, "Import from project", -1);
2655 for (i=0; i<nprojects; i++)
2656 {
2657 if (get_project_by_id(i) -> steps == 1 && get_project_by_id(i) -> natomes)
2658 {
2659 gtk_tree_store_append (store, & iter2, & iter);
2660 name = g_strdup_printf ("%s (%d)", get_project_by_id(i) -> name, i+1);
2661 gtk_tree_store_set (store, & iter2, 0, name, -1);
2662 for (j=0; j<3; j++)
2663 {
2664 gtk_tree_store_append (store, & iter3, & iter2);
2665 word = g_strdup_printf ("%s in %s", action_atoms[j], name);
2666 gtk_tree_store_set (store, & iter3, 0, word, -1);
2667 g_free (word);
2668 }
2669 g_free (name);
2670 }
2671 }
2672 }
2673 if (copied_object)
2674 {
2675 gtk_tree_store_append (store, &iter, NULL);
2676 gtk_tree_store_set (store, & iter, 0, "Copied data", -1);
2677 }
2678 if (get_project_by_id(proj) -> modelgl)
2679 {
2680 if (get_project_by_id(proj) -> modelgl -> builder_win)
2681 {
2682 gtk_tree_store_append (store, &iter, NULL);
2683 gtk_tree_store_set (store, & iter, 0, "Empty position", -1);
2684 }
2685 }
2686 return GTK_TREE_MODEL (store);
2687}
2688
2700void search_set_visible (GtkTreeViewColumn * col, GtkCellRenderer * renderer, GtkTreeModel * mod, GtkTreeIter * iter, gpointer data)
2701{
2702 int i, j;
2703 i = GPOINTER_TO_INT(data);
2704 i ++;
2705 gtk_tree_model_get (mod, iter, IDCOL, & j, -1);
2706 gboolean vis = (j < 0 && i == 2) ? FALSE : TRUE;
2707 gtk_cell_renderer_set_visible (renderer, vis);
2708 if (vis && (i < TOLAB || i > TOPIC))
2709 {
2710 gchar * str = NULL;
2711 gtk_tree_model_get (mod, iter, i, & str, -1);
2712 g_object_set (renderer, "markup", str, NULL, NULL);
2713 g_free (str);
2714 }
2715}
2716
2719
2728G_MODULE_EXPORT void set_occupancy (GtkEntry * res, gpointer data)
2729{
2730 const gchar * m = entry_get_text (res);
2731 double v = string_to_double ((gpointer)m);
2732 atomic_object * object = (atomic_object *)data;
2733 if (v > 0.0 && v<= 1.0)
2734 {
2735 object -> occ = v;
2736 }
2737 update_entry_double (res, object -> occ);
2738}
2739
2748G_MODULE_EXPORT void set_i_coord (GtkEntry * res, gpointer data)
2749{
2750 const gchar * m = entry_get_text (res);
2751 double v = string_to_double ((gpointer)m);
2752 int ax = GPOINTER_TO_INT (data);
2753 project * this_proj = get_project_by_id (csearch -> proj);
2754 int oid = (csearch -> pointer[0].c == 5) ? 1 : 2;
2755 atomic_object * object = get_atomic_object_by_origin (this_proj -> modelgl -> atom_win -> to_be_inserted[oid], 0, atom_to_edit+1);
2756 object -> baryc[ax] = v;
2757 update_entry_double (res, object -> baryc[ax]);
2758}
2759
2768G_MODULE_EXPORT void set_max_msd (GtkEntry * res, gpointer data)
2769{
2770 const gchar * m = entry_get_text (res);
2771 double v = string_to_double ((gpointer)m);
2772 int ax = GPOINTER_TO_INT (data);
2773 project * this_proj = get_project_by_id (csearch -> proj);
2774 if (! (v < 0.0))
2775 {
2776 if (ax > 0)
2777 {
2778 if (this_proj -> modelgl -> atom_win -> msd[ax-1] != v) csearch -> pick[this_proj -> atoms[0][ax-1].sp] = 0;
2779 this_proj -> modelgl -> atom_win -> msd[ax-1] = v;
2780 }
2781 else
2782 {
2783 ax = -ax-1;
2784 this_proj -> modelgl -> atom_win -> msd_all[ax] = v;
2785 if (! csearch -> passivating)
2786 {
2787 int object = get_asearch_object (csearch);
2789 int i, j, k, l;
2790 switch (filter)
2791 {
2792 case 0:
2793 for (i=0; i<this_proj -> natomes; i++)
2794 {
2795 if (this_proj -> atoms[0][i].sp == ax) this_proj -> modelgl -> atom_win -> msd[i] = v;
2796 }
2797 break;
2798 case 1:
2799 for (i=0; i<this_proj -> natomes; i++)
2800 {
2801 j = this_proj -> atoms[0][i].sp;
2802 if (this_proj -> atoms[0][i].numv == ax) this_proj -> modelgl -> atom_win -> msd[i] = v;
2803 }
2804 break;
2805 case 2:
2806 for (i=0; i<this_proj -> natomes; i++)
2807 {
2808 j = this_proj -> atoms[0][i].sp;
2809 k = this_proj -> atoms[0][i].coord[filter-1];
2810 for (l=0; l<j; l++) k += this_proj -> coord -> ntg[1][l];
2811 if (k == ax) this_proj -> modelgl -> atom_win -> msd[i] = v;
2812 }
2813 break;
2814 default:
2815 if (! object)
2816 {
2817 for (i=0; i<this_proj -> natomes; i++)
2818 {
2819 j = this_proj -> atoms[0][i].coord[filter-1];
2820 if (j == ax) this_proj -> modelgl -> atom_win -> msd[i] = v;
2821 }
2822 }
2823 break;
2824 }
2825 }
2826 }
2828 }
2829 else
2830 {
2831 //show_error ("MSD<sub>max</sub> must be > 0.0 !", 1, this_proj -> modelgl -> atom_win -> win);
2832 if (ax > 0)
2833 {
2834 v = this_proj -> modelgl -> atom_win -> msd[ax-1];
2835 }
2836 else
2837 {
2838 v = this_proj -> modelgl -> atom_win -> msd_all[-ax-1];
2839 }
2841 }
2842}
2843
2845
2854G_MODULE_EXPORT void set_max_action (GtkEntry * res, gpointer data)
2855{
2856 const gchar * m = entry_get_text (res);
2857 int v = (int)string_to_double ((gpointer)m);
2858 int ax = GPOINTER_TO_INT (data);
2859 if (v > -1 && v <= max_random)
2860 {
2861 csearch -> todo[-ax-1] = v;
2862 }
2863 update_entry_int (res, csearch -> todo[-ax-1]);
2864}
2865
2875void get_coord_iter_and_edit (gchar * path_string, gpointer data, GtkWidget * widg)
2876{
2877 tint * cid = (tint *)data;
2878 project * this_proj = get_project_by_id (cid -> a);
2879 csearch = this_proj -> modelgl -> search_widg[cid -> c];
2880 GtkTreeIter iter;
2881 GtkTreeModel * model = (csearch -> action == INSERT) ? GTK_TREE_MODEL(csearch -> obj_model) : GTK_TREE_MODEL(csearch -> atom_model);
2882 if (gtk_tree_model_get_iter (model, & iter, gtk_tree_path_new_from_string (path_string)))
2883 {
2884 int h, i, j, k, l;
2885 gtk_tree_model_get (model, & iter, IDCOL, & h, -1);
2886 if (h > 0 || csearch -> action == REPLACE || csearch -> action == REMOVE || csearch -> action == RANMOVE)
2887 {
2888
2889 atom_to_edit = h-1;
2890 GtkWidget * win = gtk_dialog_new ();
2891 if (this_proj -> modelgl -> builder_win)
2892 {
2893 gtk_window_set_transient_for (GTK_WINDOW (win), GTK_WINDOW(this_proj -> modelgl -> builder_win -> win));
2894 }
2895 else
2896 {
2897 gtk_window_set_transient_for (GTK_WINDOW (win), GTK_WINDOW(this_proj -> modelgl -> atom_win -> win));
2898 }
2899 gtk_window_set_resizable (GTK_WINDOW (win), FALSE);
2900 gchar * str;
2901 atomic_object * iobj;
2902 gchar * obj[5]={"atom(s)", "total coordination(s)", "partial coordination(s)", "in fragment", "in molecule"};
2903 gchar * act[2]={"Replace", "Remove"};
2904 int object = get_asearch_object (csearch);
2906 switch (csearch -> action)
2907 {
2908 case REPLACE:
2909 str = g_strdup_printf ("Replace %s randomly", obj[(object) ? filter : 0]);
2910 break;
2911 case REMOVE:
2912 str = g_strdup_printf ("Remove %s randomly", obj[(object) ? filter : 0]);
2913 break;
2914 case RANMOVE:
2915 str = g_strdup_printf ("Maximum Mean Square Displacement");
2916 break;
2917 default:
2918 i = (csearch -> pointer[0].c == 5) ? 1 : 2;
2919 iobj = get_atomic_object_by_origin (this_proj -> modelgl -> atom_win -> to_be_inserted[i], 0, atom_to_edit+1);
2920 if (cid -> b - TOLAB)
2921 {
2922 str = g_strdup_printf ("Site occupancy for %s", prepare_for_title(iobj -> name));
2923 }
2924 else
2925 {
2926 str = g_strdup_printf ("Insert %s at", prepare_for_title(iobj -> name));
2927 }
2928 break;
2929 }
2930 gtk_window_set_title (GTK_WINDOW(win), str);
2931 g_free (str);
2932 gtk_window_set_modal (GTK_WINDOW (win), TRUE);
2933 GtkWidget * vbox = dialog_get_content_area (win);
2934 GtkWidget * hbox;
2935 GtkWidget * entry;
2936 gchar * axis[3]={"x", "y", "z"};
2937 gchar * nran = NULL;
2938 switch (csearch -> action)
2939 {
2940 case INSERT:
2941 if (cid -> b - TOLAB && csearch -> pointer[0].c == 7)
2942 {
2943 hbox = create_hbox (5);
2944 str = g_strdup_printf ("Occupancy= ");
2945 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label(str, 100, -1, 0.0, 0.5), FALSE, FALSE, 0);
2946 g_free (str);
2947 entry = create_entry (G_CALLBACK(set_occupancy), 100, 15, FALSE, iobj);
2948 update_entry_double (GTK_ENTRY(entry), iobj -> occ);
2949 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, entry, FALSE, FALSE, 0);
2950 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 5);
2951 }
2952 else
2953 {
2954 for (i=0; i<3; i++)
2955 {
2956 hbox = create_hbox (5);
2957 str = g_strdup_printf ("%s =", axis[i]);
2958 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label(str, 100, -1, 0.0, 0.5), FALSE, FALSE, 0);
2959 g_free (str);
2960 entry = create_entry (G_CALLBACK(set_i_coord), 100, 15, FALSE, GINT_TO_POINTER(i));
2961 update_entry_double (GTK_ENTRY(entry), iobj -> baryc[i]);
2962 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, entry, FALSE, FALSE, 0);
2963 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 5);
2964 }
2965 }
2966 break;
2967 case RANMOVE:
2968 hbox = create_hbox (5);
2969 entry = create_entry (G_CALLBACK(set_max_msd), 100, 15, FALSE, GINT_TO_POINTER(h));
2970 if (h > 0)
2971 {
2972 j = this_proj -> atoms[0][atom_to_edit].sp;
2973 if (object)
2974 {
2975 str = g_strdup_printf ("MSD<sub>max</sub> for %s<sub>%d</sub> + neighbors = ", this_proj -> chemistry -> label[j], atom_to_edit+1);
2976 }
2977 else
2978 {
2979 str = g_strdup_printf ("MSD<sub>max</sub> for %s<sub>%d</sub> = ", this_proj -> chemistry -> label[j], atom_to_edit+1);
2980 }
2981 update_entry_double (GTK_ENTRY(entry), this_proj -> modelgl -> atom_win -> msd[atom_to_edit]);
2982 }
2983 else
2984 {
2985 switch (filter)
2986 {
2987 case 0:
2988 str = g_strdup_printf ("MSD<sub>max</sub> for all %s atom(s) = ", this_proj -> chemistry -> label[-h-1]);
2989 break;
2990 case 1:
2991 if (-h-1 == 0)
2992 {
2993 str = g_strdup_printf ("MSD<sub>max</sub> for all isolated atom(s) = ");
2994 }
2995 else if (object)
2996 {
2997 str = g_strdup_printf ("MSD<sub>max</sub> for all %d-fold atom(s) + neighbors = ", -h-1);
2998 }
2999 else
3000 {
3001 str = g_strdup_printf ("MSD<sub>max</sub> for all %d-fold atom(s) = ", -h-1);
3002 }
3003 break;
3004 case 2:
3005 i = 0;
3006 for (j=0; j<this_proj -> nspec; j++)
3007 {
3008 i += this_proj -> coord -> ntg[1][j];
3009 if (i > -h-1) break;
3010 }
3011 k = 0;
3012 for (l=0; l<j; l++) k += this_proj -> coord -> ntg[1][l];
3013 i = (-h-1) - k;
3014 nran = env_name(this_proj, i, j, 1, NULL);
3015 if (object)
3016 {
3017 str = g_strdup_printf ("MSD<sub>max</sub> for all %s + neighbors = ", nran);
3018 }
3019 else
3020 {
3021 str = g_strdup_printf ("MSD<sub>max</sub> for all %s = ", nran);
3022 }
3023 break;
3024 case 3:
3025 if (object)
3026 {
3027 str = g_strdup_printf ("MSD<sub>max</sub> for fragment N°%d = ", -h);
3028 }
3029 else
3030 {
3031 str = g_strdup_printf ("MSD<sub>max</sub> for the atom(s) in fragment N°%d = ", -h);
3032 }
3033 break;
3034 case 4:
3035 if (object)
3036 {
3037 str = g_strdup_printf ("MSD<sub>max</sub> for molecule N°%d = ", -h);
3038 }
3039 else
3040 {
3041 str = g_strdup_printf ("MSD<sub>max</sub> for the atom(s) in molecule N°%d = ", -h);
3042 }
3043 break;
3044 }
3045 update_entry_double (GTK_ENTRY(entry), this_proj -> modelgl -> atom_win -> msd_all[-h-1]);
3046 }
3047 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label(str, 100, -1, 0.0, 0.5), FALSE, FALSE, 15);
3048 g_free (str);
3049 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, entry, FALSE, FALSE, 0);
3050 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label("[&#xC5;<sup>2</sup>]", 50, -1, 0.0, 0.5), FALSE, FALSE, 0);
3051 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 5);
3052 break;
3053 default:
3054 max_random = 0;
3055 switch (filter)
3056 {
3057 case 0:
3058 if (csearch -> status == 2)
3059 {
3060 max_random = this_proj -> chemistry -> nsps[-h-1];
3061 nran = g_strdup_printf ("%s", this_proj -> chemistry -> label[-h-1]);
3062 }
3063 else
3064 {
3065 max_random = 0;
3066 for (i=0; i<this_proj -> natomes; i++)
3067 {
3068 if (this_proj -> atoms[0][i].sp == -h-1 && this_proj -> atoms[0][i].pick[0] == csearch -> status) max_random ++;
3069 }
3070 }
3071 break;
3072 case 1:
3073 for (i=0; i<this_proj -> natomes; i++)
3074 {
3075 if (this_proj -> atoms[0][i].numv == -h-1 && (this_proj -> atoms[0][i].pick[0] == csearch -> status || csearch -> status == 2)) max_random ++;
3076 }
3077 if (-h-1 > 0)
3078 {
3079 nran = g_strdup_printf ("%d-fold", -h-1);
3080 }
3081 else
3082 {
3083 nran = g_strdup_printf ("isolated");
3084 }
3085 break;
3086 case 2:
3087 i = 0;
3088 for (j=0; j<this_proj -> nspec; j++)
3089 {
3090 i += this_proj -> coord -> ntg[1][j];
3091 if (i > -h-1) break;
3092 }
3093 k = 0;
3094 for (l=0; l<j; l++) k += this_proj -> coord -> ntg[1][l];
3095 i = (-h-1) - k;
3096 for (k=0; k<this_proj -> natomes; k++)
3097 {
3098 if (this_proj -> atoms[0][k].sp == j && this_proj -> atoms[0][k].coord[1] == i)
3099 {
3100 if (this_proj -> atoms[0][k].pick[0] == csearch -> status || csearch -> status == 2) max_random ++;
3101 }
3102 }
3103 if (csearch -> action != RANMOVE) nran = env_name(this_proj, i, j, 1, NULL);
3104 break;
3105 default:
3106 if (object)
3107 {
3108 i = (-h-1);
3109 if (filter == 3)
3110 {
3111 max_random = this_proj -> coord -> totcoord[2];
3112 }
3113 else if (filter == 4)
3114 {
3115 max_random = this_proj -> modelfc -> mols[0][i].multiplicity;
3116 }
3117 }
3118 else
3119 {
3120 i = (-h-1);
3121 for (k=0; k<this_proj -> natomes; k++)
3122 {
3123 if (this_proj -> atoms[0][k].coord[filter-1] == i)
3124 {
3125 if (this_proj -> atoms[0][k].pick[0] == csearch -> status || csearch -> status == 2) max_random ++;
3126 }
3127 }
3128 nran = g_strdup_printf ("atom(s)");
3129 }
3130 break;
3131 }
3132
3133 hbox = create_hbox (5);
3134 entry = create_entry (G_CALLBACK(set_max_action), 100, 15, FALSE, GINT_TO_POINTER(h));
3135 if (object)
3136 {
3137 if (filter == 3)
3138 {
3139 str = g_strdup_printf ("%s randomly <i>n</i> <b>fragment(s)</b> in all fragments, <i>n</i>= ", act[csearch -> action - 3]);
3140 }
3141 else if (filter == 4)
3142 {
3143 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);
3144 }
3145 else
3146 {
3147 str = g_strdup_printf ("%s randomly <i>n</i> <b>%s</b> coordinations, <i>n</i>= ", act[csearch -> action - 3], nran);
3148 }
3149 }
3150 else
3151 {
3152 if (filter < 3)
3153 {
3154 str = g_strdup_printf ("%s randomly <i>n</i> <b>%s</b> %s, <i>n</i>= ", act[csearch -> action - 3], nran, obj[0]);
3155 }
3156 else
3157 {
3158 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);
3159 }
3160 }
3161 if (nran) g_free (nran);
3162 update_entry_int (GTK_ENTRY(entry), csearch -> todo[-h-1]);
3163 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label(str, 100, -1, 0.0, 0.5), FALSE, FALSE, 15);
3164 g_free (str);
3165 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, entry, FALSE, FALSE, 0);
3166 str = g_strdup_printf (" with <i>n</i><sub>max</sub> = <b>%d</b>", max_random);
3167 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label(str, 50, -1, 0.0, 0.5), FALSE, FALSE, 15);
3168 g_free (str);
3169 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 5);
3170 break;
3171 }
3172 run_this_gtk_dialog (win, G_CALLBACK(run_destroy_dialog), NULL);
3173 if (csearch -> action != RANMOVE)
3174 {
3176 }
3177 else
3178 {
3179 if (h > 0)
3180 {
3181 if (this_proj -> modelgl -> atom_win -> msd[atom_to_edit] > 0.0)
3182 {
3183 str = g_strdup_printf ("MSD<sub>max</sub>= %f", this_proj -> modelgl -> atom_win -> msd[atom_to_edit]);
3184 }
3185 else
3186 {
3187 str = g_strdup_printf ("Set MSD<sub>max</sub> for ...");
3188 }
3189 gtk_tree_store_set (csearch -> atom_model, & iter, TOPIC+2, str, -1);
3190 g_free (str);
3191 }
3192 else
3193 {
3194 if (this_proj -> modelgl -> atom_win -> msd_all[-h-1] > 0.0)
3195 {
3196 if (object && filter > 2)
3197 {
3198 str = g_strdup_printf ("MSD<sub>max</sub>= %f", this_proj -> modelgl -> atom_win -> msd_all[-h-1]);
3199 }
3200 else
3201 {
3202 str = g_strdup_printf ("For all: MSD<sub>max</sub>= %f", this_proj -> modelgl -> atom_win -> msd_all[-h-1]);
3203 }
3204 gtk_tree_store_set (csearch -> atom_model, & iter, TOPIC+2, str, -1);
3205 g_free (str);
3206 }
3207 else
3208 {
3209 if (object && filter > 2)
3210 {
3211 gtk_tree_store_set (csearch -> atom_model, &iter, TOPIC+2, "Set MSD<sub>max</sub> for ...", -1);
3212 }
3213 else
3214 {
3215 gtk_tree_store_set (csearch -> atom_model, & iter, TOPIC+2, "Set MSD<sub>max</sub> for all ...", -1);
3216 }
3217 }
3218 }
3219 check_all_trees (this_proj);
3220 }
3221 }
3222 }
3223}
3224
3235G_MODULE_EXPORT void to_edit_coords (GtkCellRenderer * cell, GtkCellEditable * editable, gchar * path_string, gpointer data)
3236{
3237 destroy_this_widget (GTK_WIDGET(editable));
3238 get_coord_iter_and_edit (path_string, data, NULL);
3239}
3240
3251G_MODULE_EXPORT void markup_action_renderer (GtkCellRendererCombo * cell, GtkCellEditable * editable, gchar * path_string, gpointer data)
3252{
3253 GtkComboBox * combo = GTK_COMBO_BOX(editable);
3254 GList * cell_list = gtk_cell_layout_get_cells(GTK_CELL_LAYOUT(combo));
3255 if (cell_list && cell_list -> data)
3256 {
3257 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo), cell_list -> data, "markup", 0, NULL);
3258 }
3259 /*GtkCellView * view = (GtkCellView *)gtk_bin_get_child(GTK_BIN(editable));
3260 GList * list = gtk_cell_view_get_cell_renderers (view);
3261 while (list)
3262 {
3263 GtkCellRenderer *render = (GtkCellRenderer *)list -> data;
3264 list = list -> next;
3265 gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT(combo), renderer1, TaskStatusComboCellData, NULL, NULL);
3266 }*/
3267}
3268
3277G_MODULE_EXPORT void set_max_msd_for_all (GtkEntry * res, gpointer data)
3278{
3279 const gchar * m = entry_get_text (res);
3280 double v = string_to_double ((gpointer)m);
3281 project * this_proj = get_project_by_id (csearch -> proj);
3282 int i, j;
3283 if (v <= 0.0)
3284 {
3285 // show_error ("MSD<sub>max</sub> must be > 0.0 !", 1, this_proj -> modelgl -> atom_win -> win);
3286 v = this_proj -> modelgl -> atom_win -> msd[0];
3287 }
3288 i = csearch -> todo_size;
3289 for (j=0; j<i; j++)
3290 {
3291 this_proj -> modelgl -> atom_win -> msd[j] = v;
3292 }
3294 for (j=0; j<i; j++)
3295 {
3296 this_proj -> modelgl -> atom_win -> msd_all[j] = v;
3297 }
3299}
3300
3311gboolean update_search_model (GtkTreeModel * model, GtkTreePath * path, GtkTreeIter * iter, gpointer data)
3312{
3313 int i;
3314 tint * dat = (tint *)data;
3315 project * this_proj = get_project_by_id(dat -> a);
3316 atom_search * asearch = this_proj -> modelgl -> search_widg[dat -> c];
3317 if (gtk_tree_model_get_iter (model, iter, path))
3318 {
3319 gtk_tree_model_get (model, iter, IDCOL, & i, -1);
3320 gtk_tree_store_set (GTK_TREE_STORE(model), iter, dat -> b, asearch -> int_b, -1);
3321 if (i > 0)
3322 {
3323 i --;
3324 adjust_this_tree_leaf (asearch, this_proj, dat -> b, i, asearch -> int_b, * iter);
3325 }
3326 else if (asearch -> object)
3327 {
3328 adjust_this_tree_branch (asearch, this_proj, dat -> b, abs(i) - 1, * iter);
3329 }
3330 return FALSE;
3331 }
3332 else
3333 {
3334 return TRUE;
3335 }
3336}
3337
3346G_MODULE_EXPORT void select_all_atoms (GtkTreeViewColumn * col, gpointer data)
3347{
3348 tint * dat = (tint *)data;
3349 project * this_proj = get_project_by_id(dat -> a);
3350 csearch = this_proj -> modelgl -> search_widg[dat -> c];
3351 int i, j, k;
3352 opengl_project_changed (dat -> a);
3353 if (dat -> b == TOPIC+2)
3354 {
3355 GtkWidget * win = gtk_dialog_new ();
3356 gtk_window_set_transient_for (GTK_WINDOW (win), GTK_WINDOW(this_proj -> modelgl -> atom_win -> win));
3357 gtk_window_set_resizable (GTK_WINDOW (win), FALSE);
3358 gchar * str = g_strdup_printf ("Maximum Mean Square Displacement");
3359 gtk_window_set_title (GTK_WINDOW(win), str);
3360 g_free (str);
3361 gtk_window_set_modal (GTK_WINDOW (win), TRUE);
3362 GtkWidget * vbox = dialog_get_content_area (win);
3363 GtkWidget * hbox = create_hbox (5);
3364 GtkWidget * entry = create_entry (G_CALLBACK(set_max_msd_for_all), 100, 15, FALSE, NULL);
3365 update_entry_double (GTK_ENTRY(entry), 0.0);
3366 str = g_strdup_printf ("MSD<sub>max</sub> for all object(s) = ");
3367 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label(str, 100, -1, 0.0, 0.5), FALSE, FALSE, 15);
3368 g_free (str);
3369 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, entry, FALSE, FALSE, 0);
3370 str = g_strdup_printf ("[&#xC5;<sup>2</sup>]");
3371 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label(str, 50, -1, 0.0, 0.5), FALSE, FALSE, 0);
3372 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 5);
3373 run_this_gtk_dialog (win, G_CALLBACK(run_destroy_dialog), NULL);
3375 }
3376 else
3377 {
3378 if (dat -> b == TOLAB)
3379 {
3380 if (csearch -> action == INSERT)
3381 {
3382 k = (csearch -> pointer[0].c == 5) ? 1 : 2;
3383 if (this_proj -> modelgl -> atom_win -> to_be_inserted[k])
3384 {
3385 j = ! csearch -> todo[0];
3386 for (i=0; i<csearch -> in_selection; i++) csearch -> todo[i] = j;
3387 }
3388 }
3389 else
3390 {
3391 k = this_proj -> modelgl -> anim -> last -> img -> step;
3392 if (csearch -> action < 2)
3393 {
3394 is_selected = -1;
3395 i = 0;
3396 }
3397 else
3398 {
3399 if (csearch -> status < 2)
3400 {
3402 for (i=0; i<this_proj -> natomes; i++)
3403 {
3404 if (this_proj -> atoms[k][i].pick[0] == is_selected) break;
3405 }
3406 }
3407 else
3408 {
3409 is_selected = -1;
3410 i = 0;
3411 }
3412 }
3413 j = ! this_proj -> atoms[k][i].label[0];
3414 selected_aspec = -1;
3415 column_label = TRUE;
3416#ifdef GTK4
3417 label_unlabel_atoms (NULL, NULL, & opengl_project -> modelgl -> colorp[0][j]);
3418#else
3419 label_unlabel_atoms (NULL, & opengl_project -> modelgl -> colorp[0][j]);
3420#endif
3421 column_label = FALSE;
3422 }
3423 }
3424 else
3425 {
3426 k = this_proj -> modelgl -> anim -> last -> img -> step;
3427 if (csearch -> action < 2)
3428 {
3429 j = ! this_proj -> atoms[k][0].pick[0];
3431#ifdef GTK4
3432 select_unselect_atoms (NULL, NULL, & opengl_project -> modelgl -> colorp[0][j]);
3433#else
3434 select_unselect_atoms (NULL, & opengl_project -> modelgl -> colorp[0][j]);
3435#endif
3436 }
3437 else
3438 {
3439 if (csearch -> action != RANMOVE)
3440 {
3441 j = (csearch -> set_for_all < 0) ? 0 : 1;
3442 }
3443 else
3444 {
3445 // The value depends on both translation (1), rotation (2), or both (3)
3446 switch (abs(csearch -> set_for_all))
3447 {
3448 case 0:
3449 if (dat -> b == TOPIC)
3450 {
3451 j = 1;
3452 }
3453 else
3454 {
3455 j = 2;
3456 }
3457 break;
3458 case 1:
3459 if (dat -> b == TOPIC)
3460 {
3461 j = 0;
3462 }
3463 else
3464 {
3465 j = 3;
3466 }
3467 break;
3468 case 2:
3469 if (dat -> b == TOPIC)
3470 {
3471 j = 3;
3472 }
3473 else
3474 {
3475 j = 0;
3476 }
3477 break;
3478 case 3:
3479 if (dat -> b == TOPIC)
3480 {
3481 j = 2;
3482 }
3483 else
3484 {
3485 j = 1;
3486 }
3487 break;
3488 }
3489 }
3490 }
3491 }
3492 if (csearch -> action > 1 && dat -> c != 7)
3493 {
3495 if (dat -> b != TOLAB) clean_todo (csearch);
3496 }
3497 csearch -> set_for_all = (dat -> b == TOLAB) ? 0 : j;
3499 }
3500 /*else
3501 {
3502 GtkTreeIter iter;
3503 if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL(csearch -> atom_model), & iter))
3504 {
3505 gtk_tree_model_get (GTK_TREE_MODEL(csearch -> atom_model), & iter, dat -> b, & j, -1);
3506 g_debug ("j= %d,", j);
3507 g_debug ("a= %d, b= %d, c= %d, aa= %d, bb= %d, cc= %d", dat -> a, dat -> b, dat -> c,
3508 csearch -> pointer[dat -> b-TOLAB].a, csearch -> pointer[dat -> b-TOLAB].b, csearch -> pointer[dat -> b-TOLAB].c);
3509 csearch -> int_b = ! j;
3510 gtk_tree_model_foreach (GTK_TREE_MODEL(csearch -> atom_model), update_search_model, & csearch -> pointer[dat -> b-TOLAB]);
3511 }
3512 }*/
3513}
3514
3524G_MODULE_EXPORT void move_up_down (GtkTreeModel * tree_model, GtkTreePath * path, gpointer data)
3525{
3526 atom_search * asearch = (atom_search *)data;
3527 project * this_proj = get_project_by_id(asearch -> proj);
3528 atomic_object * obja, * objb, * objc;
3529 GtkTreeIter iter;
3530 gboolean valid;
3531 int i, j;
3532 int * old_todo = duplicate_int (asearch -> in_selection, asearch -> todo);
3533 obja = duplicate_atomic_object (this_proj -> modelgl -> atom_win -> to_be_inserted[2]);
3534 obja -> next = this_proj -> modelgl -> atom_win -> to_be_inserted[2] -> next;
3535 g_free (this_proj -> modelgl -> atom_win -> to_be_inserted[2]);
3536 objb = NULL;
3537 valid = gtk_tree_model_get_iter_first (tree_model, & iter);
3538 j = 0;
3539 while (valid)
3540 {
3541 gtk_tree_model_get (tree_model, & iter, 0, & i, -1);
3542 i --;
3543 objc = obja;
3544 while (objc -> id != i) objc = objc -> next;
3545 if (objc)
3546 {
3547 if (! objb)
3548 {
3549 this_proj -> modelgl -> atom_win -> to_be_inserted[2] = duplicate_atomic_object (objc);
3550 objb = this_proj -> modelgl -> atom_win -> to_be_inserted[2];
3551 }
3552 else
3553 {
3554 objb -> next = duplicate_atomic_object (objc);
3555 objb -> next -> prev = objb;
3556 objb = objb -> next;
3557 }
3558 objb -> id = j;
3559 asearch -> todo[j] = old_todo[i];
3560 j ++;
3561 }
3562 valid = gtk_tree_model_iter_next (tree_model, & iter);
3563 }
3564 g_free (old_todo);
3565 i = 0;
3566 valid = gtk_tree_model_get_iter_first (tree_model, & iter);
3567 while (valid)
3568 {
3569 gtk_list_store_set (GTK_LIST_STORE(tree_model), & iter, IDCOL, i+1, 1, g_strdup_printf ("%d", i+1), -1);
3570 i ++;
3571 valid = gtk_tree_model_iter_next (tree_model, & iter);
3572 }
3573}
3574
3584GtkWidget * create_atoms_tree (atom_search * asearch, project * this_proj, int nats)
3585{
3586 int i, j, k, l;
3587 GtkTreeViewColumn * atom_col[5];
3588 GtkCellRenderer * atom_cell[5];
3589 gchar * ctitle[6][5]={{"Object", "Name", "Label", "Pick", " "},
3590 {"Object", "Name", "Label", "Move", " "},
3591 {"Object", "Name", "Label", "Replace", "By"},
3592 {"Object", "Name", "Label", "Remove", " "},
3593 {"Object", "Name", "Insert", "Position", "Occupancy"},
3594 {"Object", "Name", "Label", "Translate", "Max. MSD"}};
3595 gchar * ctype[3][5]={{"text", "text", "active", "active", "text"},
3596 {"text", "text", "active", "text", "text"},
3597 {"text", "text", "active", "active", "text"}};
3598 j = (asearch -> action == REPLACE || asearch -> action == RANMOVE) ? 1 : 0;
3599 k = (asearch -> action == RANMOVE) ? 2 : (asearch -> action == INSERT) ? 1 : 0;
3600 if (asearch -> action == INSERT && asearch -> pointer[0].c == 7) j ++;
3601 gboolean toggle;
3602 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},
3603 {G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT},
3604 {G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_INT}};
3605 if (asearch -> action == INSERT)
3606 {
3607 asearch -> obj_model = gtk_list_store_newv (8, coltype[k]);
3608 }
3609 else
3610 {
3611 asearch -> atom_model = gtk_tree_store_newv (8, coltype[k]);
3612 }
3613 if (! (nats > 10000) || asearch -> action == INSERT)
3614 {
3615 fill_atom_model (asearch, this_proj);
3616 }
3617 if (asearch -> action == INSERT)
3618 {
3619 asearch -> atom_tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(asearch -> obj_model));
3620 }
3621 else
3622 {
3623 asearch -> atom_tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(asearch -> atom_model));
3624 }
3625
3626 for (i=0; i<4+j; i++)
3627 {
3628 toggle = FALSE;
3629 if (i < 2 || (asearch -> action == INSERT && i > 2) || (asearch -> action == RANMOVE && i == 4))
3630 {
3631 atom_cell[i] = gtk_cell_renderer_text_new ();
3632 if ((asearch -> action == INSERT && i > 2) || (asearch -> action == RANMOVE && i == 4))
3633 {
3634 g_object_set (atom_cell[i], "editable", TRUE, NULL);
3635 g_signal_connect (G_OBJECT(atom_cell[i]), "editing-started", G_CALLBACK(to_edit_coords), & asearch -> pointer[i-3]);
3636 if (asearch -> action == RANMOVE) toggle = TRUE;
3637 }
3638 }
3639 else if (i < 4)
3640 {
3641 atom_cell[i] = gtk_cell_renderer_toggle_new ();
3642 g_signal_connect (G_OBJECT(atom_cell[i]), "toggled", G_CALLBACK(select_atom), & asearch -> pointer[i-2]);
3643 toggle = TRUE;
3644 }
3645 else
3646 {
3647 atom_cell[i] = gtk_cell_renderer_combo_new ();
3648 GtkTreeModel * model = replace_combo_tree (FALSE, this_proj -> id);
3649 g_object_set (atom_cell[i], "model", model, "text-column", 0, "has-entry", FALSE, "editable", TRUE, NULL);
3650 g_object_unref (model);
3651 g_signal_connect (G_OBJECT(atom_cell[i]), "editing-started", G_CALLBACK(markup_action_renderer), & asearch -> pointer[i-4]);
3652 g_signal_connect (G_OBJECT(atom_cell[i]), "changed", G_CALLBACK(changed_action_renderer), & asearch -> pointer[i-4]);
3653 }
3654 gtk_cell_renderer_set_fixed_size (atom_cell[i], -1, 25);
3655 l = (asearch -> action == RANMOVE && i == 4) ? i+1 : i;
3656 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);
3657 if (toggle && ! asearch -> passivating)
3658 {
3659 gtk_tree_view_column_set_clickable (atom_col[i], TRUE);
3660 g_signal_connect (G_OBJECT(atom_col[i]), "clicked", G_CALLBACK(select_all_atoms), & asearch -> pointer[l-2]);
3661 }
3662 gtk_tree_view_append_column(GTK_TREE_VIEW(asearch -> atom_tree), atom_col[i]);
3663 gtk_tree_view_column_set_alignment (atom_col[i], 0.5);
3664 gtk_tree_view_column_set_cell_data_func (atom_col[i], atom_cell[i], search_set_visible, GINT_TO_POINTER(l), NULL);
3665 }
3666 if (asearch -> pointer[0].c == 7)
3667 {
3668 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);
3669 gtk_tree_view_set_reorderable (GTK_TREE_VIEW(asearch -> atom_tree), TRUE);
3670 }
3671 return asearch -> atom_tree;
3672}
3673
3682{
3683 int object = get_asearch_object (asearch);
3684 int filter = get_asearch_filter (asearch);
3685 project * this_proj = get_project_by_id (asearch -> proj);
3686 int tsize = 0;
3687 switch (filter)
3688 {
3689 case 0:
3690 tsize = (asearch -> mode || asearch -> passivating) ? this_proj -> nspec : this_proj -> natomes;
3691 break;
3692 case 1:
3693 tsize = (asearch -> mode || asearch -> passivating) ? this_proj -> coord -> cmax+1 : this_proj -> natomes;
3694 break;
3695 default:
3696 if (asearch -> mode || asearch -> passivating)
3697 {
3698 tsize = this_proj -> coord -> totcoord[filter -1];
3699 }
3700 else
3701 {
3702 tsize = (object && filter > 2) ? this_proj -> coord -> totcoord[filter -1] : this_proj -> natomes;
3703 }
3704 break;
3705 }
3706 return tsize;
3707}
3708
3717void allocate_todo (atom_search * asearch, int tsize)
3718{
3719 asearch -> todo = allocint (tsize);
3720 asearch -> todo_size = tsize;
3721}
3722
3730void clean_todo (atom_search * asearch)
3731{
3732 project * this_proj = get_project_by_id (asearch -> proj);
3733 if (asearch -> todo) g_free (asearch -> todo);
3734 allocate_todo (asearch, get_todo_size(asearch));
3735 atomic_object * object;
3736 switch (asearch -> action)
3737 {
3738 case DISPL:
3739 if (this_proj -> modelgl -> atom_win -> to_be_moved[0])
3740 {
3741 object = this_proj -> modelgl -> atom_win -> to_be_moved[0];
3742 while (object -> next)
3743 {
3744 object = object -> next;
3745 g_free (object -> prev);
3746 }
3747 g_free (object);
3748 this_proj -> modelgl -> atom_win -> to_be_moved[0] = NULL;
3749 }
3750 break;
3751 case RANMOVE:
3752 if (this_proj -> modelgl -> atom_win -> to_be_moved[1])
3753 {
3754 object = this_proj -> modelgl -> atom_win -> to_be_moved[1];
3755 while (object -> next)
3756 {
3757 object = object -> next;
3758 g_free (object -> prev);
3759 }
3760 g_free (object);
3761 this_proj -> modelgl -> atom_win -> to_be_moved[1] = NULL;
3762 }
3763 g_free (this_proj -> modelgl -> atom_win -> msd);
3764 this_proj -> modelgl -> atom_win -> msd = allocfloat (asearch -> todo_size);
3765 break;
3766 case REPLACE:
3767 if (this_proj -> modelgl -> atom_win -> to_be_inserted[0])
3768 {
3769 object = this_proj -> modelgl -> atom_win -> to_be_inserted[0];
3770 while (object -> next)
3771 {
3772 object = object -> next;
3773 g_free (object -> prev);
3774 }
3775 g_free (object);
3776 this_proj -> modelgl -> atom_win -> to_be_inserted[0] = NULL;
3777 }
3778 asearch -> in_selection = 0;
3779 break;
3780 }
3781}
3782
3791void clean_picked_and_labelled (atom_search * asearch, gboolean clean_msd)
3792{
3793 project * this_proj;
3794 int val = get_asearch_num_objects (asearch);
3795 asearch -> lab = allocint(val);
3796 asearch -> pick = allocint(val);
3797 if (asearch -> action == RANMOVE)
3798 {
3799 this_proj = get_project_by_id (asearch -> proj);
3800 if (this_proj -> modelgl -> atom_win && clean_msd)
3801 {
3802 g_free (this_proj -> modelgl -> atom_win -> msd_all);
3803 this_proj -> modelgl -> atom_win -> msd_all = allocfloat (val);
3804 }
3805 }
3806 else if (asearch -> action == REPLACE)
3807 {
3808 this_proj = get_project_by_id (asearch -> proj);
3809 int i = (asearch -> pointer[0].c == 3) ? 0 : 1;
3810 if (this_proj -> modelgl -> atom_win)
3811 {
3812 if (this_proj -> modelgl -> atom_win -> win && this_proj -> modelgl -> atom_win -> replace_nodes[i])
3813 {
3814 g_free (this_proj -> modelgl -> atom_win -> replace_nodes[i]);
3815 }
3816 this_proj -> modelgl -> atom_win -> replace_nodes[i] = g_malloc0(val*sizeof*this_proj -> modelgl -> atom_win -> replace_nodes[i]);
3817 }
3818 }
3819}
3820
3829G_MODULE_EXPORT void set_spec_changed (GtkComboBox * box, gpointer data)
3830{
3831 atom_search * asearch = (atom_search *) data;
3832 int i = gtk_combo_box_get_active (box);
3833 asearch -> spec = i;
3834 update_search_tree (asearch);
3835 if (get_project_by_id(asearch -> proj) -> natomes >= 10000)
3836 {
3837 if (i > 0)
3838 {
3839 update_entry_text (GTK_ENTRY(asearch -> entry_a), exact_name(get_project_by_id(asearch -> proj) -> chemistry -> label[i-1]));
3840 }
3841 else
3842 {
3843 update_entry_text (GTK_ENTRY(asearch -> entry_a), "");
3844 }
3845 set_atom (GTK_ENTRY(asearch -> entry_a), asearch);
3846 widget_set_sensitive (asearch -> entry_a, ! i);
3847 }
3848}
3849
3858G_MODULE_EXPORT void set_filter_changed (GtkComboBox * box, gpointer data)
3859{
3860 atom_search * asearch = (atom_search *) data;
3861 asearch -> filter = gtk_combo_box_get_active (box);
3862 int object = get_asearch_object (asearch);
3863 int filter = get_asearch_filter (asearch);
3864 widget_set_sensitive (asearch -> atom_box, (object && filter > 2) ? 0 : 1);
3865 widget_set_sensitive (asearch -> id_box, (object && filter > 2) ? 0 : 1);
3866 if (object && filter > 2)
3867 {
3868 gtk_combo_box_set_active (GTK_COMBO_BOX(asearch -> atom_box), 0);
3869 }
3870 if (asearch -> action == DISPL) motion_to_zero (asearch);
3871 clean_todo (asearch);
3872 clean_picked_and_labelled (asearch, TRUE);
3873 set_spec_changed (GTK_COMBO_BOX(asearch -> atom_box), asearch);
3874}
3875
3884G_MODULE_EXPORT void set_object_changed (GtkComboBox * box, gpointer data)
3885{
3886 atom_search * asearch = (atom_search *) data;
3887 GtkTreeViewColumn * rot_c;
3888 int was_object;
3889 int object;
3890 int filter;
3891 if (get_project_by_id(asearch -> proj) -> natomes >= 10000)
3892 {
3893 was_object = ((! asearch -> mode && asearch -> object > 1) || (asearch -> mode && asearch -> object)) ? 1 : 0;
3894 asearch -> object = gtk_combo_box_get_active (box);
3895 filter = get_asearch_filter (asearch);
3896 object = ((! asearch -> mode && asearch -> object > 1) || (asearch -> mode && asearch -> object)) ? 1 : 0;
3897 if ((! asearch -> mode && (asearch -> object == 1 || asearch -> object == 3)) || (asearch -> mode && asearch -> object))
3898 {
3899 if (! asearch -> mode) asearch -> passivating = TRUE;
3900 if (is_the_widget_visible(asearch -> id_box)) hide_the_widgets (asearch -> id_box);
3901 if (is_the_widget_visible(asearch -> info[1])) hide_the_widgets (asearch -> info[1]);
3902 }
3903 else
3904 {
3905 asearch -> passivating = FALSE;
3906 if (((! asearch -> mode && asearch -> object == 2) || (asearch -> mode && asearch -> object)) && filter > 2)
3907 {
3908 if (is_the_widget_visible(asearch -> id_box)) hide_the_widgets (asearch -> id_box);
3909 if (is_the_widget_visible(asearch -> info[1])) hide_the_widgets (asearch -> info[1]);
3910 }
3911 else
3912 {
3913 if (! is_the_widget_visible(asearch -> id_box)) show_the_widgets (asearch -> id_box);
3914 if (! is_the_widget_visible(asearch -> info[1])) show_the_widgets (asearch -> info[1]);
3915 }
3916 }
3917 }
3918 else
3919 {
3920 was_object = (asearch -> object) ? 1 : 0;
3921 asearch -> object = gtk_combo_box_get_active (box);
3922 filter = get_asearch_filter (asearch);
3923 object = (asearch -> object) ? 1 : 0;
3924 if (is_the_widget_visible(asearch -> id_box)) hide_the_widgets (asearch -> id_box);
3925 if (is_the_widget_visible(asearch -> info[1])) hide_the_widgets (asearch -> info[1]);
3926 }
3927 if (was_object)
3928 {
3929 combo_text_prepend (asearch -> filter_box, "Chemical species");
3930 if (asearch -> action == RANMOVE)
3931 {
3932 rot_c = gtk_tree_view_get_column (GTK_TREE_VIEW(asearch -> atom_tree), 4);
3933 gtk_tree_view_remove_column (GTK_TREE_VIEW(asearch -> atom_tree), rot_c);
3934 }
3935 }
3936 if (object)
3937 {
3938 gtk_combo_box_text_remove ((GtkComboBoxText *)asearch -> filter_box, 0);
3939 if (asearch -> action == RANMOVE)
3940 {
3941 GtkCellRenderer * rot = gtk_cell_renderer_toggle_new ();
3942 g_signal_connect (G_OBJECT(rot), "toggled", G_CALLBACK(select_atom), & asearch -> pointer[2]);
3943 int i = 5;
3944 rot_c = gtk_tree_view_column_new_with_attributes ("Rotate", rot, "active", i, NULL);
3945 gtk_tree_view_column_set_clickable (rot_c, TRUE);
3946 g_signal_connect (G_OBJECT(rot_c), "clicked", G_CALLBACK(select_all_atoms), & asearch -> pointer[2]);
3947 gtk_tree_view_column_set_alignment (rot_c, 0.5);
3948 gtk_tree_view_insert_column (GTK_TREE_VIEW(asearch -> atom_tree), rot_c, i-1);
3949 }
3950 }
3951
3952 if (asearch -> action == DISPL) widget_set_sensitive (get_project_by_id(asearch -> proj) -> modelgl -> atom_win -> at_expand[2], object);
3953 gtk_combo_box_set_active (GTK_COMBO_BOX(asearch -> filter_box), 0);
3954 set_filter_changed (GTK_COMBO_BOX(asearch -> filter_box), asearch);
3955}
3956
3965{
3966 int i = 8 - asearch -> action;
3967 GtkCellRenderer * num = gtk_cell_renderer_text_new ();
3968 g_object_set (num, "editable", TRUE, NULL);
3969 g_signal_connect (G_OBJECT(num), "editing-started", G_CALLBACK(to_edit_coords), & asearch -> pointer[0]);
3970 GtkTreeViewColumn * num_c = gtk_tree_view_column_new_with_attributes ("Number", num, "text", i, NULL);
3971 gtk_tree_view_column_set_cell_data_func (num_c, num, search_set_visible, GINT_TO_POINTER(i), NULL);
3972 gtk_tree_view_append_column(GTK_TREE_VIEW(asearch -> atom_tree), num_c);
3973}
3974
3983G_MODULE_EXPORT void set_search_mode (GtkComboBox * box, gpointer data)
3984{
3985 atom_search * asearch = (atom_search *)data;
3986 project * this_proj = get_project_by_id(asearch -> proj);
3987 asearch -> mode = gtk_combo_box_get_active (box);
3988 if ((asearch -> action == REPLACE || asearch -> action == REMOVE) && asearch -> atom_tree)
3989 {
3990 if (! asearch -> mode)
3991 {
3992 GtkTreeViewColumn * num_c;
3993 num_c = gtk_tree_view_get_column (GTK_TREE_VIEW(asearch -> atom_tree), 8 - asearch -> action);
3994 gtk_tree_view_remove_column (GTK_TREE_VIEW(asearch -> atom_tree), num_c);
3995 }
3996 else
3997 {
3998 add_random_column (asearch);
3999 }
4000 }
4001 if (this_proj -> natomes >= 10000)
4002 {
4003 if (asearch -> object_box)
4004 {
4005 if (asearch -> mode)
4006 {
4007 gtk_combo_box_text_remove ((GtkComboBoxText *)asearch -> object_box, 3);
4008 gtk_combo_box_text_remove ((GtkComboBoxText *)asearch -> object_box, 1);
4009 }
4010 else
4011 {
4012 gtk_combo_box_text_insert ((GtkComboBoxText *)asearch -> object_box, 1, NULL, "Atom(s): all");
4013 combo_text_append (asearch -> object_box, "Group of atoms: all");
4014 }
4015 }
4016 }
4017 else
4018 {
4019 gtk_combo_box_text_remove_all ((GtkComboBoxText *)asearch -> object_box);
4020 combo_text_append (asearch -> object_box, "Atom(s)");
4021 combo_text_append (asearch -> object_box, "Group of atoms");
4022 }
4023
4024 /*if (asearch -> filter_box)
4025 {
4026 if (! this_proj -> modelgl -> adv_bonding[1] && this_proj -> modelgl -> atom_win -> adv_bonding[1])
4027 {
4028 gtk_combo_box_text_remove ((GtkComboBoxText *)asearch -> filter_box, 3+i);
4029 }
4030 if (! this_proj -> modelgl -> adv_bonding[0] && this_proj -> modelgl -> atom_win -> adv_bonding[0])
4031 {
4032 gtk_combo_box_text_remove ((GtkComboBoxText *)asearch -> filter_box, 2+i);
4033 }
4034 gtk_combo_box_set_active (GTK_COMBO_BOX(asearch -> filter_box), 0);
4035 set_filter_changed (GTK_COMBO_BOX(asearch -> filter_box), asearch);
4036 }*/
4037 gtk_combo_box_set_active (GTK_COMBO_BOX(asearch -> object_box), 0);
4038 set_object_changed (GTK_COMBO_BOX(asearch -> object_box), asearch);
4039}
4040
4049G_MODULE_EXPORT void set_search_digit (GtkEntry * res, gpointer data)
4050{
4051 atom_search * asearch = (atom_search *) data;
4052 const gchar * m = entry_get_text (res);
4053 double v = string_to_double ((gpointer)m);
4054 asearch -> search_digit = (int)v;
4055 if (asearch -> search_digit <= 0)
4056 {
4057 asearch -> search_digit --;
4058 update_entry_text (res, "");
4059 }
4060 else
4061 {
4062 update_entry_int (res, asearch -> search_digit);
4063 }
4064 set_spec_changed (GTK_COMBO_BOX(asearch -> atom_box), data);
4065}
4066
4076void prep_search_box (GtkWidget * vbox, GtkWidget * lab, GtkWidget * combo)
4077{
4078 GtkWidget * hbox = create_hbox (0);
4079 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 2);
4080 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 30);
4081 GtkWidget * fixed = gtk_fixed_new ();
4082 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, fixed, FALSE, FALSE, 10);
4083 gtk_widget_set_size_request (combo, 175, -1);
4084 gtk_fixed_put (GTK_FIXED(fixed), combo, 0, 0);
4085}
4086
4094GtkWidget * prepare_box_too_much (atom_search * asearch)
4095{
4096 GtkWidget * box;
4097 GtkWidget * widg;
4098 GtkWidget * too_box = create_vbox (BSEP);
4099 widg = bbox (too_box, "\t Atom species: ");
4100 gtk_widget_set_size_request (widg, 200, -1);
4101 asearch -> entry_a = create_entry (G_CALLBACK(set_atom), 90, 15, TRUE, asearch);
4102 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, widg, asearch -> entry_a, FALSE, FALSE, 0);
4103 asearch -> img_a = stock_image (DIAL_ERROR);
4104 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, widg, asearch -> img_a, FALSE, FALSE, 5);
4105 widg = bbox (too_box, "\t Atom Id: ");
4106 gtk_widget_set_size_request (widg, 200, -1);
4107 asearch -> entry_b = create_entry (G_CALLBACK(set_id), 90, 15, TRUE, asearch);
4108 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, widg, asearch -> entry_b, FALSE, FALSE, 0);
4109 asearch -> img_b = stock_image (DIAL_ERROR);
4110 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, widg, asearch -> img_b, FALSE, FALSE, 5);
4111 box = create_hbox (0);
4112 add_box_child_start (GTK_ORIENTATION_VERTICAL, too_box, box, FALSE, FALSE, 5);
4113 asearch -> but_a = create_button ("Add", IMG_NONE, NULL, 75, -1, GTK_RELIEF_NORMAL, G_CALLBACK(add_atom), asearch);
4114 widget_set_sensitive (asearch -> but_a, 0);
4115 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, box, asearch -> but_a, FALSE, FALSE, 75);
4116 asearch -> but_b = create_button ("Remove", IMG_NONE, NULL, 75, -1, GTK_RELIEF_NORMAL, G_CALLBACK(remove_atom), asearch);
4117 widget_set_sensitive (asearch -> but_b, 0);
4118 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, box, asearch -> but_b, FALSE, FALSE, 0);
4119 return too_box;
4120}
4121
4130GtkWidget * selection_tab (atom_search * asearch, int nats)
4131{
4132 project * this_proj = get_project_by_id (asearch -> proj);
4133 int i, j;
4134 i = (nats < 10000) ? 1 : 0;
4135 j = (asearch -> action == 5) ? 300 : -1;
4136 GtkWidget * selection = create_layout (j, 390 + (! i)*60 - i*100);
4137 GtkWidget * vbox = add_vbox_to_layout (selection, 0, (asearch -> action > 1) ? 0 : 10);
4138 GtkWidget * hbox, * vvbox;
4139 GtkWidget * lab;
4140 if (asearch -> action != 5)
4141 {
4142 // Later on simply hide info[1] (to much atoms info) if needed
4143 for (j=0; j<2; j++)
4144 {
4145 asearch -> info[j] = create_vbox (BSEP);
4146 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, asearch -> info[j], FALSE, FALSE, 0);
4147 }
4148 hbox = create_hbox (0);
4149 add_box_child_start (GTK_ORIENTATION_VERTICAL, asearch -> info[0], hbox, FALSE, FALSE, 2);
4150 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label("<b>.</b>", 5, -1, 0.0, 0.5), FALSE, FALSE, 10);
4151 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label("Search: ", 50, -1, 0.0, 0.5), FALSE, FALSE, 0);
4152 asearch -> object_box = create_combo ();
4153 combo_text_append (asearch -> object_box, "Atom(s)");
4154 if (! i) combo_text_append (asearch -> object_box, "Atom(s): all");
4155 combo_text_append (asearch -> object_box, "Group of atoms");
4156 if (! i) combo_text_append (asearch -> object_box, "Group of atoms: all");
4157 gtk_combo_box_set_active (GTK_COMBO_BOX(asearch -> object_box), asearch -> object);
4158 asearch -> filter_box = create_combo ();
4159 gchar * filters[5]={"Chemical species", "Total coordination", "Partial coordination", "Fragment", "Molecule"};
4160 for (j=0; j<3; j++) combo_text_append (asearch -> filter_box, filters[j]);
4161 if (this_proj -> modelgl -> adv_bonding[0]) combo_text_append (asearch -> filter_box, filters[3]);
4162 if (this_proj -> modelgl -> adv_bonding[1]) combo_text_append (asearch -> filter_box, filters[4]);
4163 gtk_combo_box_set_active (GTK_COMBO_BOX(asearch -> filter_box), asearch -> filter);
4164
4165 asearch -> atom_box = create_combo ();
4166 combo_text_append (asearch -> atom_box, "All");
4167 for (j=0; j<this_proj -> nspec; j++) combo_text_append (asearch -> atom_box, this_proj -> chemistry -> label[j]);
4168 gtk_combo_box_set_active (GTK_COMBO_BOX(asearch -> atom_box), asearch -> spec);
4169
4170 g_signal_connect (G_OBJECT (asearch -> object_box), "changed", G_CALLBACK(set_object_changed), asearch);
4171 g_signal_connect (G_OBJECT (asearch -> filter_box), "changed", G_CALLBACK(set_filter_changed), asearch);
4172 g_signal_connect (G_OBJECT (asearch -> atom_box), "changed", G_CALLBACK(set_spec_changed), asearch);
4173 GtkWidget * entry = create_entry (G_CALLBACK(set_search_digit), 90, 15, TRUE, asearch);
4174 if (asearch -> action < 2)
4175 {
4176 prep_search_box (asearch -> info[0], markup_label("For: ", 100, -1, 0.0, 0.5), asearch -> object_box);
4177 prep_search_box (asearch -> info[0], markup_label("Filter by: ", 100, -1, 0.0, 0.5), asearch -> filter_box);
4178 prep_search_box (asearch -> info[0], markup_label("Species: ", 100, -1, 0.0, 0.5), asearch -> atom_box);
4179 asearch -> id_box = create_hbox (0);
4180 add_box_child_start (GTK_ORIENTATION_VERTICAL, asearch -> info[0], asearch -> id_box, FALSE, FALSE, 0);
4181 prep_search_box (asearch -> id_box, markup_label("Atom Id: ", 100, -1, 0.0, 0.5), entry);
4182 }
4183 else
4184 {
4185 hbox = create_hbox (0);
4186 add_box_child_start (GTK_ORIENTATION_VERTICAL, asearch -> info[0], hbox, FALSE, FALSE, 5);
4187 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label("For: ", -1, -1, 0.0, 0.5), FALSE, FALSE, 10);
4188 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, asearch -> object_box, FALSE, FALSE, 0);
4189 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label("Filter by: ", -1, -1, 0.0, 0.5), FALSE, FALSE, 10);
4190 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, asearch -> filter_box, FALSE, FALSE, 0);
4191 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label("Species: ", -1, -1, 0.0, 0.5), FALSE, FALSE, 10);
4192 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, asearch -> atom_box, FALSE, FALSE, 0);
4193 asearch -> id_box = create_hbox (0);
4194 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, asearch -> id_box, FALSE, FALSE, 0);
4195 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, asearch -> id_box, markup_label("Atom Id: ", -1, -1, 0.0, 0.5), FALSE, FALSE, 10);
4196 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, asearch -> id_box, entry, FALSE, FALSE, 0);
4197 }
4198
4199 // If more than 10 000 atoms:
4200 if (asearch -> action < 2)
4201 {
4202 lab = markup_label("\t<b>The number of atoms in the model is too large</b>\n"
4203 "\t\t<b>to display and browse the entire list !</b>\n"
4204 "\t<b>You need to search for object(s) manually:</b>", -1, -1, 0.5, 0.5);
4205 }
4206 else
4207 {
4208 lab = markup_label("<b>The number of atoms in the model is too large to display and browse the entire list !</b>\n"
4209 "\t\t\t\t<b>You need to search for object(s) manually:</b>", -1, -1, 0.5, 0.5);
4210 }
4211 add_box_child_start (GTK_ORIENTATION_VERTICAL, asearch -> info[1], lab, FALSE, FALSE, 10);
4212 hbox = create_hbox (0);
4213 add_box_child_start (GTK_ORIENTATION_VERTICAL, asearch -> info[1], hbox, FALSE, FALSE, 0);
4214 /* vvbox = create_vbox (0);
4215 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, vvbox, FALSE, FALSE, 80);
4216 cbox = create_combo ();
4217 combo_text_append (cbox, "All objects");
4218 combo_text_append (cbox, "Selection");
4219 g_signal_connect (G_OBJECT(cbox), "changed", G_CALLBACK(set_too_much_type), asearch);
4220 gtk_combo_box_set_active (GTK_COMBO_BOX(cbox), asearch -> too_much);
4221 add_box_child_start (GTK_ORIENTATION_VERTICAL, vvbox, cbox, FALSE, FALSE, 30);
4222 // asearch -> big_box = // Combo box with "All objects", "Selection" */
4223 vvbox = create_vbox (0);
4224 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, vvbox, FALSE, FALSE, 120);
4225 add_box_child_start (GTK_ORIENTATION_VERTICAL, vvbox, prepare_box_too_much (asearch), FALSE, FALSE, 0);
4226 add_box_child_start (GTK_ORIENTATION_VERTICAL, asearch -> info[1],
4227 markup_label("The search must be performed using species and/or ID.\n"
4228 "Use the filters above to define the object(s) of the search", -1, -1, 0.5, 0.5), FALSE, FALSE, 5);
4229 }
4230
4231 abox (vbox, "Selection: ", 2);
4232 hbox = create_hbox (0);
4233 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 5);
4234 GtkWidget * scrollsets = create_scroll (NULL, -1, -1, GTK_SHADOW_ETCHED_IN);
4235 i = (asearch -> action < 2) ? 0 : 1;
4236 j = (asearch -> action < 2) ? 1 : 0;
4237 if (asearch -> action < 2)
4238 {
4239 gtk_widget_set_size_request (scrollsets, 400+i*100, 270);
4240 }
4241 else
4242 {
4243 gtk_widget_set_size_request (scrollsets, 400+i*100, 290-i*120);
4244 }
4245 gtk_widget_set_hexpand (scrollsets, TRUE);
4246 add_container_child (CONTAINER_SCR, scrollsets, create_atoms_tree (asearch, this_proj, nats));
4247 check_all_trees (this_proj);
4248 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, scrollsets, FALSE, FALSE, 100-j*75);
4249 return selection;
4250}
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:874
gchar * object
Definition global.h:875
coord_info * coord
Definition global.h:956
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:2844
GtkTreeModel * replace_combo_tree(gboolean insert, int proj)
replace combo box in the tree view
Definition w_search.c:2615
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:1481
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:2235
G_MODULE_EXPORT void select_all_atoms(GtkTreeViewColumn *col, gpointer data)
select all element(s) in the tree view column
Definition w_search.c:3346
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:1318
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:3235
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:3584
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:1506
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:3251
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:4130
G_MODULE_EXPORT void set_occupancy(GtkEntry *res, gpointer data)
set occupancy entry callback
Definition w_search.c:2728
G_MODULE_EXPORT void set_max_msd(GtkEntry *res, gpointer data)
set MSD max entry callback
Definition w_search.c:2768
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:2322
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:3681
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:2748
int atom_to_edit
Definition w_search.c:2717
G_MODULE_EXPORT void set_atom(GtkEntry *entry, gpointer data)
adjust atom search parameters if >= 10 000 atoms
Definition w_search.c:1345
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:3277
void update_search_tree(atom_search *asearch)
update search tree
Definition w_search.c:1294
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:2718
G_MODULE_EXPORT void set_filter_changed(GtkComboBox *box, gpointer data)
change the search filter
Definition w_search.c:3858
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:2385
void re_populate_tree_search(atom_search *asearch)
re populate search tree after atom action if >= 10 000 atoms
Definition w_search.c:1608
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:1463
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:3964
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:2875
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:2700
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:1745
void clean_picked_and_labelled(atom_search *asearch, gboolean clean_msd)
initialize atom search data buffers
Definition w_search.c:3791
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:2854
GtkWidget * prepare_box_too_much(atom_search *asearch)
if too many atoms, then individual search
Definition w_search.c:4094
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:3311
void clear_fields(atom_search *asearch)
clear all search fields if >= 10 000 atoms
Definition w_search.c:1385
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:1831
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:4049
gboolean remove_from_model(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
remove from the tree model
Definition w_search.c:1411
void allocate_todo(atom_search *asearch, int tsize)
allocate the selection list data buffer
Definition w_search.c:3717
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:4076
G_MODULE_EXPORT void set_object_changed(GtkComboBox *box, gpointer data)
change the search object
Definition w_search.c:3884
void clean_todo(atom_search *asearch)
clean atom search selection list
Definition w_search.c:3730
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:2516
G_MODULE_EXPORT void set_id(GtkEntry *entry, gpointer data)
set search id if >= 10 000 atoms
Definition w_search.c:1697
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:2452
G_MODULE_EXPORT void set_search_mode(GtkComboBox *box, gpointer data)
change search mode
Definition w_search.c:3983
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:3524
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:3829
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