atomes 1.3.1
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-2026 by CNRS and University of Strasbourg */
15
24
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 >= GTK_LIMIT)
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 >= GTK_LIMIT)
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 < GTK_LIMIT)
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 >= GTK_LIMIT && ! asearch -> passivating && ! asearch -> mode)
909 {
910 show_the_widgets (asearch -> info[1]);
911 hide_the_widgets (asearch -> id_box);
912 }
913 else
914 {
915 hide_the_widgets (asearch -> info[1]);
916 if (asearch -> mode)
917 {
918 hide_the_widgets (asearch -> id_box);
919 }
920 else
921 {
922 if (asearch -> passivating || (filter > 2 && obj == 2))
923 {
924 hide_the_widgets (asearch -> id_box);
925 }
926 else
927 {
928 show_the_widgets (asearch -> id_box);
929 }
930 }
931 int val = get_asearch_num_objects (asearch);
932 to_insert = allocbool(val);
933 n = 0;
934 if (asearch -> action == REPLACE)
935 {
936 picked_names = g_malloc0(val*sizeof*picked_names);
937 n = (asearch -> pointer[0].c == 3) ? 0 : 3;
938 }
939 switch (filter)
940 {
941 case 0:
942 for (h=0; h<val; h++)
943 {
944 doit = TRUE;
945 if (! asearch -> spec || asearch -> spec == h+1)
946 {
947 for (i=0; i<this_proj -> natomes; i++)
948 {
949 j = this_proj -> atoms[0][i].sp;
950 if (j == h)
951 {
952 to_insert[h] = append (asearch, this_proj, i, j);
953 if (to_insert[h])
954 {
955 if (asearch -> action == REPLACE && asearch -> in_selection)
956 {
957 picked_names[h] = adjust_picked (picked_names[h],
958 get_atomic_object_by_origin (this_proj -> modelgl -> atom_win -> to_be_inserted[n], (asearch -> mode) ? -(h+3) : (asearch -> passivating) ? h : i, 0),
959 doit);
960 doit = FALSE;
961 }
962 if (asearch -> action != REPLACE || n || ! picked_names[h] || asearch -> mode) break;
963 }
964 }
965 }
966 }
967 }
968 break;
969 case 1:
970 for (h=0; h<val; h++)
971 {
972 doit = TRUE;
973 for (i=0; i<this_proj -> natomes; i++)
974 {
975 if (this_proj -> atoms[0][i].numv == h)
976 {
977 j = this_proj -> atoms[0][i].sp;
978 to_insert[h] = append (asearch, this_proj, i, j);
979 if (to_insert[h])
980 {
981 if (asearch -> action == REPLACE && asearch -> in_selection)
982 {
983 picked_names[h] = adjust_picked (picked_names[h],
984 get_atomic_object_by_origin (this_proj -> modelgl -> atom_win -> to_be_inserted[n], (asearch -> mode) ? -(h+3) : (asearch -> passivating) ? h : i, 0),
985 doit);
986 }
987 if (asearch -> action != REPLACE || n || ! picked_names[h] || asearch -> mode) break;
988 }
989 }
990 }
991 }
992 break;
993 default:
994 if (val >= GTK_LIMIT && (obj == 1 || asearch -> object == 3))
995 {
996 // Improbable: more than 10 000 fragments or molecules
997 // Note: so far the selection and the test case functions are not ready yet
998 to_insert[0] = TRUE;
999 picked_names[0] = g_strdup_printf (_("All %s(s)"), (filter == 2) ? _("fragment") : _("molecule"));
1000 val = 1;
1001 }
1002 else
1003 {
1004 for (h=0; h<val; h++)
1005 {
1006 doit = TRUE;
1007 for (i=0; i<this_proj -> natomes; i++)
1008 {
1009 if (asearch -> spec == 0 || asearch -> spec == this_proj -> atoms[0][i].sp + 1)
1010 {
1011 j = this_proj -> atoms[step][i].coord[filter - 1];
1012 if (filter == 2)
1013 {
1014 for (k=0; k<this_proj -> atoms[0][i].sp; k++) j += this_proj -> coord -> ntg[filter - 1][k];
1015 }
1016 if (j == h)
1017 {
1018 to_insert[h] = append (asearch, this_proj, i, this_proj -> atoms[0][i].sp);
1019 if (to_insert[h])
1020 {
1021 if (asearch -> action == REPLACE && asearch -> in_selection)
1022 {
1023 picked_names[h] = adjust_picked (picked_names[h],
1024 get_atomic_object_by_origin (this_proj -> modelgl -> atom_win -> to_be_inserted[n], (asearch -> mode) ? -(h+3) : (asearch -> passivating) ? h : i, 0),
1025 doit);
1026 }
1027 if (asearch -> action != REPLACE || n || ! picked_names[h] || asearch -> mode) break;
1028 }
1029 }
1030 }
1031 }
1032 }
1033 }
1034 break;
1035 }
1036 if ((asearch -> action == REPLACE || asearch -> action == REMOVE) && asearch -> mode && obj && filter > 2)
1037 {
1038 if (filter == 3 && this_proj -> coord -> totcoord[2] > 1)
1039 {
1040 str = g_strdup_printf (_("Fragments"));
1041 gtk_tree_store_append (asearch -> atom_model, & spec_level, NULL);
1042 if (asearch -> set_for_all > 0) asearch -> pick[0] = asearch -> set_for_all;
1043 gtk_tree_store_set (asearch -> atom_model, & spec_level, IDCOL, -1, 1, str, TOPIC, asearch -> pick[0], -1);
1044 g_free (str);
1045 str = g_strdup_printf ("%d", asearch -> todo[0]);
1046 j = (asearch -> action == REMOVE) ? 1 : 2;
1047 gtk_tree_store_set (asearch -> atom_model, & spec_level, TOPIC+j, str, -1);
1048 g_free (str);
1049 if (asearch -> action == REPLACE)
1050 {
1051 if (picked_names[0])
1052 {
1053 str = g_strdup_printf (_("For all: %s"), picked_names[0]);
1054 gtk_tree_store_set (asearch -> atom_model, & spec_level, TOPIC+1, str, -1);
1055 g_free (str);
1056 }
1057 else
1058 {
1059 gtk_tree_store_set (asearch -> atom_model, & spec_level, TOPIC+1, _("Select for all ..."), -1);
1060 }
1061 }
1062 }
1063 else if (filter == 4 && this_proj -> modelfc)
1064 {
1065 for (k=0; k<this_proj -> modelfc -> mol_by_step[0]; k++)
1066 {
1067 if (this_proj -> modelfc -> mols[0][k].multiplicity > 1)
1068 {
1069 str = g_strdup_printf (_("Molecule N°%d"), k+1);
1070 gtk_tree_store_append (asearch -> atom_model, & spec_level, NULL);
1071 if (asearch -> set_for_all > 0) asearch -> pick[k] = asearch -> set_for_all;
1072 gtk_tree_store_set (asearch -> atom_model, & spec_level, IDCOL, -(k+1), 1, str, TOPIC, asearch -> pick[k], -1);
1073 g_free (str);
1074 str = g_strdup_printf ("%d", asearch -> todo[k]);
1075 gtk_tree_store_set (asearch -> atom_model, & spec_level, TOPIC+2, str, -1);
1076 g_free (str);
1077 if (asearch -> action == REPLACE)
1078 {
1079 if (picked_names[k])
1080 {
1081 str = g_strdup_printf (_("For all: %s"), picked_names[k]);
1082 gtk_tree_store_set (asearch -> atom_model, & spec_level, TOPIC+1, str, -1);
1083 g_free (str);
1084 }
1085 else
1086 {
1087 gtk_tree_store_set (asearch -> atom_model, & spec_level, TOPIC+1, _("Select for all ..."), -1);
1088 }
1089 }
1090 }
1091 }
1092 }
1093 }
1094 else
1095 {
1096 for (h=0; h<val; h++)
1097 {
1098 if (to_insert[h])
1099 {
1100 gtk_tree_store_append (asearch -> atom_model, & spec_level, NULL);
1101 if (asearch -> action == REPLACE && ! asearch -> mode)
1102 {
1103 g = (asearch -> pointer[0].c == 3) ? 0 : 1;
1104 this_proj -> modelgl -> atom_win -> replace_nodes[g][h] = gtk_tree_model_get_path (GTK_TREE_MODEL(asearch -> atom_model), & spec_level);
1105 }
1106 str = get_node_name (h, asearch, this_proj);
1107 if (asearch -> set_for_all > 0) asearch -> pick[h] = asearch -> set_for_all;
1109 {
1110 gtk_tree_store_set (asearch -> atom_model, & spec_level, IDCOL, -(h+1), 1, str, TOPIC, asearch -> pick[h], -1);
1111 if (asearch -> passivating)
1112 {
1113 gtk_tree_store_set (asearch -> atom_model, & spec_level, TOLAB, asearch -> lab[h], -1);
1114 }
1115
1116 if (asearch -> set_for_all > 0 && asearch -> action == DISPL && filter > 2)
1117 {
1118 asearch -> todo[h] = asearch -> set_for_all;
1119 adjust_object_to_move (this_proj, asearch, 0, h);
1120 }
1121 if (asearch -> mode)
1122 {
1123 g_free (str);
1124 str = g_strdup_printf ("%d", asearch -> todo[h]);
1125 gtk_tree_store_set (asearch -> atom_model, & spec_level, TOPIC+5-asearch -> action, str, -1);
1126 }
1127 }
1128 else if (asearch -> action == RANMOVE)
1129 {
1130 i = (asearch -> pick[h] == 1 || asearch -> pick[h] == 3) ? 1 : 0;
1131 gtk_tree_store_set (asearch -> atom_model, & spec_level, IDCOL, -(h+1), 1, str, TOPIC, i, -1);
1132 if (is_object)
1133 {
1134 i = (asearch -> pick[h] == 2 || asearch -> pick[h] == 3) ? 1 : 0;
1135 gtk_tree_store_set (asearch -> atom_model, & spec_level, TOPIC+1, i, -1);
1136 if (asearch -> set_for_all > 0)
1137 {
1138 if (filter > 2)
1139 {
1140 asearch -> todo[h] = asearch -> set_for_all;
1141 adjust_object_to_move (this_proj, asearch, 1, h);
1142 }
1143 }
1144 }
1145 }
1146 g_free (str);
1147 if (asearch -> action == REPLACE)
1148 {
1149 if (picked_names[h])
1150 {
1151 if (asearch -> mode || (obj && filter > 2))
1152 {
1153 str = g_strdup_printf ("%s", picked_names[h]);
1154 }
1155 else
1156 {
1157 str = g_strdup_printf (_("For all: %s"), picked_names[h]);
1158 }
1159 gtk_tree_store_set (asearch -> atom_model, & spec_level, TOPIC+1, str, -1);
1160 g_free (str);
1161 }
1162 else
1163 {
1164 if (asearch -> mode || (obj && filter > 2))
1165 {
1166 gtk_tree_store_set (asearch -> atom_model, & spec_level, TOPIC+1, _("Select ..."), -1);
1167 }
1168 else
1169 {
1170 gtk_tree_store_set (asearch -> atom_model, & spec_level, TOPIC+1, _("Select for all ..."), -1);
1171 }
1172 }
1173 }
1174 else if (asearch -> action == RANMOVE)
1175 {
1176 if (this_proj -> modelgl -> atom_win -> msd_all[h] > 0.0)
1177 {
1178 if (obj && filter > 2)
1179 {
1180 str = g_strdup_printf (_("MSD<sub>max</sub>= %f"), this_proj -> modelgl -> atom_win -> msd_all[h]);
1181 }
1182 else
1183 {
1184 str = g_strdup_printf (_("For all: MSD<sub>max</sub>= %f"), this_proj -> modelgl -> atom_win -> msd_all[h]);
1185 }
1186 gtk_tree_store_set (asearch -> atom_model, & spec_level, TOPIC+2, str, -1);
1187 g_free (str);
1188 }
1189 else
1190 {
1191 if (obj && filter > 2)
1192 {
1193 gtk_tree_store_set (asearch -> atom_model, & spec_level, TOPIC+2, _("Set MSD<sub>max</sub> for ..."), -1);
1194 }
1195 else
1196 {
1197 gtk_tree_store_set (asearch -> atom_model, & spec_level, TOPIC+2, _("Set MSD<sub>max</sub> for all ..."), -1);
1198 }
1199 }
1200 }
1201 doit = FALSE;
1202 if (asearch -> action > REMOVE && asearch -> action != RANMOVE)
1203 {
1204 doit = TRUE;
1205 }
1206 else
1207 {
1208 doit = (asearch -> passivating) ? FALSE : ! asearch -> mode;
1209 }
1210 if (doit && (! obj || (filter > 0 && filter < 3)))
1211 {
1212 for (i=0; i<this_proj -> natomes; i++)
1213 {
1214 do_append = FALSE;
1215 j = this_proj -> atoms[0][i].sp;
1216 if (! filter)
1217 {
1218 if (j == h && append (asearch, this_proj, i, j)) do_append=TRUE;
1219 }
1220 else
1221 {
1222 k = filter - 1;
1223 l = this_proj -> atoms[step][i].coord[k];
1224 if (filter == 1)
1225 {
1226 m = this_proj -> coord -> geolist[0][j][l];
1227 if (m == h && append (asearch, this_proj, i, j)) do_append=TRUE;
1228 }
1229 else
1230 {
1231 if (filter == 2) for (m=0; m<j; m++) l += this_proj -> coord -> ntg[1][m];
1232 if (l == h && append (asearch, this_proj, i, j)) do_append=TRUE;
1233 }
1234 }
1235 if (do_append)
1236 {
1237 gtk_tree_store_append (asearch -> atom_model, & atom_level, & spec_level);
1238 append_to_model (& atom_level, asearch, is_object, h, i, this_proj);
1239 }
1240 }
1241 }
1242 }
1243 }
1244 g_free (to_insert);
1245 if (asearch -> action == DISPL) check_motion_interactors (this_proj, asearch);
1246 if (asearch -> action == REPLACE) g_free (picked_names);
1247 }
1248 //if (asearch -> passivating)
1249 check_tree_for_this_search (this_proj, asearch);
1250 }
1251 }
1252 else
1253 {
1254 i = (asearch -> pointer[0].c == 7) ? 2 : 1;
1255 atomic_object * iobj = this_proj -> modelgl -> atom_win -> to_be_inserted[i];
1256 j = 0;
1257 while (iobj)
1258 {
1259 gtk_list_store_append (asearch -> obj_model, & atom_level);
1260 str = g_strdup_printf ("x= %f, y= %f, z= %f", iobj -> baryc[0], iobj -> baryc[1], iobj -> baryc[2]);
1261 gtk_list_store_set (asearch -> obj_model, & atom_level, IDCOL, j+1, 1, g_strdup_printf ("%d", j+1), 2, iobj -> name,
1262 TOLAB, asearch -> todo[j], TOPIC, str, -1);
1263 g_free (str);
1264 if (i == 2)
1265 {
1266 str = g_strdup_printf ("%f", iobj -> occ);
1267 gtk_list_store_set (asearch -> obj_model, & atom_level, TOPIC+1, str, -1);
1268 g_free (str);
1269 }
1270 j ++;
1271 iobj = iobj -> next;
1272 }
1273 }
1274 if (asearch -> set_for_all > 0) asearch -> set_for_all = -asearch -> set_for_all;
1275}
1276
1277G_MODULE_EXPORT void move_up_down (GtkTreeModel * tree_model, GtkTreePath * path, gpointer data);
1278void add_random_column (atom_search * asearch);
1279
1288{
1289 if (asearch -> pointer[0].c == 7 && asearch -> obj_model)
1290 {
1291 g_signal_handler_disconnect (G_OBJECT(GTK_TREE_MODEL(asearch -> obj_model)), asearch -> filter);
1292 gtk_list_store_clear (asearch -> obj_model);
1293 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);
1294 }
1295 else
1296 {
1297 if (asearch -> atom_model) gtk_tree_store_clear (asearch -> atom_model);
1298 if (asearch -> obj_model) gtk_list_store_clear (asearch -> obj_model);
1299 }
1300 fill_atom_model (asearch, get_project_by_id(asearch -> proj));
1301 //if (asearch -> action) gtk_tree_view_expand_all (GTK_TREE_VIEW(asearch -> atom_tree));
1302}
1303
1312{
1313 int object = get_asearch_object (asearch);
1314 int filter = get_asearch_filter (asearch);
1315 if (asearch -> passivating)
1316 {
1317 return FALSE;
1318 }
1319 else if (! asearch -> passivating && asearch -> todo_size >= GTK_LIMIT)
1320 {
1321 return FALSE;
1322 }
1323 else if (! (object && filter > 2))
1324 {
1325 return TRUE;
1326 }
1327 return FALSE;
1328}
1329
1338G_MODULE_EXPORT void set_atom (GtkEntry * entry, gpointer data)
1339{
1340 atom_search * asearch = (atom_search *)data;
1341 int i;
1342 project * this_proj = get_project_by_id(asearch -> proj);
1343 gchar * str_a, * str_b;
1344 str_a = g_strdup_printf ("%s", entry_get_text (GTK_ENTRY(asearch -> entry_a)));
1345 asearch -> spec_to_add = -1;
1346 for (i = 0; i < this_proj -> nspec; i++)
1347 {
1348 str_b = g_strdup_printf ("%s", exact_name(this_proj -> chemistry -> label[i]));
1349 if (g_strcmp0 (str_a, str_b) == 0)
1350 {
1351 asearch -> spec_to_add = i;
1352 }
1353 g_free (str_b);
1354 }
1355 g_free (str_a);
1356 if (asearch -> spec_to_add != -1)
1357 {
1358 widget_set_sensitive (asearch -> entry_b, 1);
1359 set_image_from_icon_name (asearch -> img_a, APPLY);
1360 }
1361 else
1362 {
1363 widget_set_sensitive (asearch -> entry_b, 0);
1364 widget_set_sensitive (asearch -> but_a, 0);
1365 widget_set_sensitive (asearch -> but_b, 0);
1366 update_entry_text (GTK_ENTRY(asearch -> entry_b), "");
1367 set_image_from_icon_name (asearch -> img_a, DIAL_ERROR);
1368 }
1369}
1370
1379{
1380 int i = combo_get_active (asearch -> atom_box);
1381 if (i)
1382 {
1383 update_entry_text (GTK_ENTRY(asearch -> entry_a), exact_name(get_project_by_id(asearch -> proj) -> chemistry -> label[i-1]));
1384 }
1385 else
1386 {
1387 update_entry_text (GTK_ENTRY(asearch -> entry_a), "");
1388 }
1389 set_atom (GTK_ENTRY(asearch -> entry_a), asearch);
1390 update_entry_text (GTK_ENTRY(asearch -> entry_b), "");
1391 set_image_from_icon_name (asearch -> img_b, DIAL_ERROR);
1392}
1393
1404gboolean remove_from_model (GtkTreeModel * model, GtkTreePath * path, GtkTreeIter * iter, gpointer data)
1405{
1406 int i, j;
1407 GtkTreeIter parent;
1408 atom_search * asearch = (atom_search *)data;
1409 project * this_proj;
1410 if (gtk_tree_model_get_iter (model, iter, path))
1411 {
1412 gtk_tree_model_get (model, iter, IDCOL, & i, -1);
1413 if (i == asearch -> int_b)
1414 {
1415 j = (i > 0) ? i -- : abs(i) - 1;
1416 asearch -> todo[j] = 0;
1417 if (asearch -> action == REPLACE)
1418 {
1419 j = (i > 0) ? i -- : i - 2;
1420 this_proj = get_project_by_id(asearch -> proj);
1421 clean_this_object (j, 0, this_proj, asearch);
1422 asearch -> in_selection --;
1423 }
1424 if (gtk_tree_model_iter_parent (model, & parent, iter))
1425 {
1426 gtk_tree_store_remove (GTK_TREE_STORE(model), iter);
1427 if (! gtk_tree_model_iter_has_child(model, & parent))
1428 {
1429 gtk_tree_store_remove (GTK_TREE_STORE(model), & parent);
1430 if (asearch -> action == REPLACE)
1431 {
1432 j = abs(i) - 1;
1433 gtk_tree_path_free (this_proj -> modelgl -> atom_win -> replace_nodes[0][j]);
1434 this_proj -> modelgl -> atom_win -> replace_nodes[0][j] = NULL;
1435 }
1436 }
1437 }
1438 else
1439 {
1440 gtk_tree_store_remove (GTK_TREE_STORE(model), iter);
1441 }
1442 return TRUE;
1443 }
1444 }
1445 return FALSE;
1446}
1447
1456G_MODULE_EXPORT void remove_atom (GtkButton * but, gpointer data)
1457{
1458 atom_search * asearch = (atom_search *)data;
1459 asearch -> int_b = (int )string_to_double ((gpointer)entry_get_text (GTK_ENTRY(asearch -> entry_b)));
1460 gtk_tree_model_foreach (GTK_TREE_MODEL(asearch -> atom_model), remove_from_model, asearch);
1461 clear_fields (asearch);
1462}
1463
1474gboolean atom_is_in_model (GtkTreeModel * model, GtkTreePath * path, GtkTreeIter * iter, gpointer data)
1475{
1476 int b;
1477 atom_search * asearch = (atom_search *)data;
1478 if (gtk_tree_model_get_iter (model, iter, path))
1479 {
1480 gtk_tree_model_get (model, iter, IDCOL, & b, -1);
1481 if (b == asearch -> int_b)
1482 {
1483 asearch -> was_selected = TRUE;
1484 asearch -> path = gtk_tree_model_get_path (model, iter);
1485 return TRUE;
1486 }
1487 }
1488 return FALSE;
1489}
1490
1499G_MODULE_EXPORT void add_atom (GtkButton * but, gpointer data)
1500{
1501 atom_search * asearch = (atom_search *)data;
1502 project * this_proj = get_project_by_id(asearch -> proj);
1503 GtkTreeIter spec_level, atom_level, new_level;
1504 int i, j, k, l, m;
1505 i = this_proj -> modelgl -> anim -> last -> img -> step;
1506 j = asearch -> spec_to_add;
1507 int filter = get_asearch_filter (asearch);
1508 gboolean is_object = get_asearch_is_object (asearch);
1509 if (! asearch -> mode)
1510 {
1511 if (append (asearch, this_proj, -1, j))
1512 {
1513 asearch -> was_selected = FALSE;
1514 m = asearch -> int_b;
1515 asearch -> int_b = j+1;
1516 gtk_tree_model_foreach (GTK_TREE_MODEL(asearch -> atom_model), atom_is_in_model, asearch);
1517 if (! asearch -> was_selected)
1518 {
1519 switch (filter)
1520 {
1521 case 0:
1522 l = j;
1523 break;
1524 case 1:
1525 l = this_proj -> atoms[i][asearch -> num_to_add].numv;
1526 break;
1527 case 2:
1528 l = this_proj -> atoms[i][asearch -> num_to_add].coord[filter - 1];
1529 for (k=0; k<j; k++) l += this_proj -> coord -> ntg[filter - 1][k];
1530 break;
1531 default:
1532 l = this_proj -> atoms[i][asearch -> num_to_add].coord[filter - 1];
1533 break;
1534 }
1535 asearch -> int_b = -(l+1);
1536 gchar * str = get_node_name (l, asearch, this_proj);
1537 asearch -> was_selected = FALSE;
1538 gtk_tree_model_foreach (GTK_TREE_MODEL(asearch -> atom_model), atom_is_in_model, asearch);
1539 if (! asearch -> was_selected)
1540 {
1541 gtk_tree_store_append (asearch -> atom_model, & spec_level, NULL);
1542 if (asearch -> action == REPLACE)
1543 {
1544 this_proj -> modelgl -> atom_win -> replace_nodes[0][l] = gtk_tree_model_get_path (GTK_TREE_MODEL(asearch -> atom_model), & spec_level);
1545 }
1546 gtk_tree_store_set (asearch -> atom_model, & spec_level, IDCOL, -(l+1), 1, str, -1);
1547 gtk_tree_store_append (asearch -> atom_model, & atom_level, & spec_level);
1548 append_to_model (& atom_level, asearch, is_object, l, asearch -> num_to_add, this_proj);
1549 }
1550 else
1551 {
1552 // Find out where to insert that node !
1553 gtk_tree_model_get_iter (GTK_TREE_MODEL(asearch -> atom_model), & spec_level, asearch -> path);
1554 if (gtk_tree_model_iter_children (GTK_TREE_MODEL(asearch -> atom_model), & atom_level, & spec_level))
1555 {
1556 gboolean append = FALSE;
1557 gboolean dothat = TRUE;
1558 k = 0;
1559 while (dothat)
1560 {
1561 gtk_tree_model_get (GTK_TREE_MODEL(asearch -> atom_model), & atom_level, IDCOL, & k, -1);
1562 if (k > asearch -> num_to_add)
1563 {
1564 dothat = FALSE;
1565 }
1566 else
1567 {
1568 dothat = gtk_tree_model_iter_next (GTK_TREE_MODEL(asearch -> atom_model), & atom_level);
1569 append = TRUE;
1570 }
1571 }
1572 gtk_tree_store_insert_before (asearch -> atom_model, & new_level, & spec_level, (append) ? NULL : & atom_level);
1573 append_to_model (& new_level, asearch, l, is_object, asearch -> num_to_add, this_proj);
1574 }
1575 }
1576 g_free (str);
1577 asearch -> int_b = m;
1578 if (asearch -> action == REPLACE)
1579 {
1580 gtk_tree_store_set (asearch -> atom_model, & spec_level, TOPIC+1, _("Select for all ..."), -1);
1581 }
1582 else if (asearch -> action == RANMOVE)
1583 {
1584 str = g_strdup_printf (_("Set MSD<sub>max</sub> for all ..."));
1585 gtk_tree_store_set (asearch -> atom_model, & spec_level, TOPIC+2, str, -1);
1586 g_free (str);
1587 }
1588 }
1589 }
1590 }
1591 clear_fields (asearch);
1592}
1593
1602{
1603 project * this_proj = get_project_by_id (asearch -> proj);
1604 GtkTreeIter spec_level, atom_level, new_level;
1605 int i, j, k, l, m;
1606 i = this_proj -> modelgl -> anim -> last -> img -> step;
1607 int filter = get_asearch_filter (asearch);
1608 gboolean is_object = get_asearch_is_object (asearch);
1609 int s_int_b = asearch -> int_b;
1610 for (j=0; j<asearch -> todo_size; j++)
1611 {
1612 if (asearch -> todo[j])
1613 {
1614 k = this_proj -> atoms[i][j].sp;
1615 if (append (asearch, this_proj, -1, k))
1616 {
1617 asearch -> was_selected = FALSE;
1618 switch (filter)
1619 {
1620 case 0:
1621 l = k;
1622 break;
1623 case 1:
1624 l = this_proj -> atoms[i][j].numv;
1625 break;
1626 case 2:
1627 l = this_proj -> atoms[i][j].coord[filter - 1];
1628 for (m=0; m<k; m++) l += this_proj -> coord -> ntg[filter - 1][m];
1629 break;
1630 default:
1631 l = this_proj -> atoms[i][j].coord[filter - 1];
1632 break;
1633 }
1634 asearch -> int_b = -(l+1);
1635 gtk_tree_model_foreach (GTK_TREE_MODEL(asearch -> atom_model), atom_is_in_model, asearch);
1636 if (! asearch -> was_selected)
1637 {
1638 gchar * str = get_node_name (l, asearch, this_proj);
1639 gtk_tree_store_append (asearch -> atom_model, & spec_level, NULL);
1640 gtk_tree_store_set (asearch -> atom_model, & spec_level, IDCOL, asearch -> int_b, 1, str, -1);
1641 if (asearch -> action == RANMOVE)
1642 {
1643 str = g_strdup_printf (_("Set MSD<sub>max</sub> for all ..."));
1644 gtk_tree_store_set (asearch -> atom_model, & spec_level, TOPIC+2, str, -1);
1645 g_free (str);
1646 }
1647 gtk_tree_store_append (asearch -> atom_model, & atom_level, & spec_level);
1648 append_to_model (& atom_level, asearch, is_object, l, j, this_proj);
1649 }
1650 else
1651 {
1652 // Find out where to insert that node !
1653 gtk_tree_model_get_iter (GTK_TREE_MODEL(asearch -> atom_model), & spec_level, asearch -> path);
1654 if (gtk_tree_model_iter_children (GTK_TREE_MODEL(asearch -> atom_model), & atom_level, & spec_level))
1655 {
1656 gboolean append = FALSE;
1657 gboolean dothat = TRUE;
1658 k = 0;
1659 while (dothat)
1660 {
1661 gtk_tree_model_get (GTK_TREE_MODEL(asearch -> atom_model), & atom_level, IDCOL, & k, -1);
1662 if (k > j)
1663 {
1664 dothat = FALSE;
1665 }
1666 else
1667 {
1668 dothat = gtk_tree_model_iter_next (GTK_TREE_MODEL(asearch -> atom_model), & atom_level);
1669 append = TRUE;
1670 }
1671 }
1672 gtk_tree_store_insert_before (asearch -> atom_model, & new_level, & spec_level, (append) ? NULL : & atom_level);
1673 append_to_model (& new_level, asearch, is_object, l, j, this_proj);
1674 }
1675 }
1676 }
1677 }
1678 }
1679 asearch -> int_b = s_int_b;
1680}
1681
1690G_MODULE_EXPORT void set_id (GtkEntry * entry, gpointer data)
1691{
1692 atom_search * asearch = (atom_search *)data;
1693 project * this_proj = get_project_by_id(asearch -> proj);
1694 asearch -> int_b = (int )string_to_double ((gpointer)entry_get_text (GTK_ENTRY(asearch -> entry_b)));
1695 if (asearch -> int_b > 0 && asearch -> int_b < this_proj -> natomes+1)
1696 {
1697 asearch -> was_selected = FALSE;
1698 gtk_tree_model_foreach (GTK_TREE_MODEL(asearch -> atom_model), atom_is_in_model, asearch);
1699 int s = this_proj -> modelgl -> anim -> last -> img -> step;
1700 asearch -> int_b --;
1701 if (asearch -> was_selected && this_proj -> atoms[s][asearch -> int_b].sp == asearch -> spec_to_add)
1702 {
1703 widget_set_sensitive (asearch -> but_a, 0);
1704 widget_set_sensitive (asearch -> but_b, 1);
1705 set_image_from_icon_name (asearch -> img_b, APPLY);
1706 }
1707 else
1708 {
1709 if (this_proj -> atoms[s][asearch -> int_b].sp == asearch -> spec_to_add)
1710 {
1711 asearch -> num_to_add = asearch -> int_b;
1712 widget_set_sensitive (asearch -> but_a, 1);
1713 widget_set_sensitive (asearch -> but_b, 0);
1714 set_image_from_icon_name (asearch -> img_b, APPLY);
1715 }
1716 else
1717 {
1718 widget_set_sensitive (asearch -> but_a, 0);
1719 widget_set_sensitive (asearch -> but_b, 0);
1720 set_image_from_icon_name (asearch -> img_b, DIAL_ERROR);
1721 }
1722 }
1723 }
1724}
1725
1738void adjust_search_param (atom_search * asearch, project * this_proj, int a, int s, int c, gboolean status)
1739{
1740 int i, j, k, l, m;
1741 opengl_project_changed (asearch -> proj);
1742 i = (a < 0) ? 0 : a;
1743 for (j=i; j<this_proj -> natomes; j++)
1744 {
1745 k = this_proj -> atoms[0][j].pick[0];
1746 l = this_proj -> atoms[0][j].sp;
1747 m = this_proj -> atoms[0][j].label[0];
1748 if (s < 0 || l == s)
1749 {
1750 if (asearch -> status == 2 || asearch -> status == k)
1751 {
1752 if (a == j || a < 0)
1753 {
1754 switch (c)
1755 {
1756 case TOLAB:
1757#ifdef GTK4
1758 if (m != status) label_unlabel_this_atom (NULL, NULL, GINT_TO_POINTER(j));
1759#else
1760 if (m != status) label_unlabel_this_atom (NULL, GINT_TO_POINTER(j));
1761#endif
1762 break;
1763 default:
1764 if (asearch -> action != RANMOVE)
1765 {
1766 asearch -> todo[j] = status;
1767 if (asearch -> action == DISPL && asearch -> object) adjust_object_to_move (this_proj, asearch, 0, j);
1768 }
1769 else
1770 {
1771 switch (asearch -> todo[j])
1772 {
1773 case 0:
1774 asearch -> todo[j] += (c-TOLAB);
1775 break;
1776 case 1:
1777 if (c == TOPIC)
1778 {
1779 asearch -> todo[j] -= (c-TOLAB);
1780 }
1781 else
1782 {
1783 asearch -> todo[j] += (c-TOLAB);
1784 }
1785 break;
1786 case 2:
1787 if (c == TOPIC)
1788 {
1789 asearch -> todo[j] += (c-TOLAB);
1790 }
1791 else
1792 {
1793 asearch -> todo[j] -= (c-TOLAB);
1794 }
1795 break;
1796 case 3:
1797 asearch -> todo[j] -= (c-TOLAB);
1798 break;
1799 }
1800 if (asearch -> object) adjust_object_to_move (this_proj, asearch, 1, j);
1801 }
1802 break;
1803 }
1804 }
1805 if (a == j) break;
1806 }
1807 }
1808 }
1809}
1810
1811G_MODULE_EXPORT void set_spec_changed (GtkComboBox * box, gpointer data);
1812
1824void adjust_this_tree_branch (atom_search * asearch, project * this_proj, int oid, int sid, GtkTreeIter iter)
1825{
1826 int k, l, m, n, o, p, q;
1827 int status;
1828 int * to_label = NULL;
1829 int is_clone = (asearch -> action == 1) ? 1 : 0;
1830 int object = get_asearch_object (asearch);
1831 int filter = get_asearch_filter (asearch);
1832 gboolean doit;
1833 GtkTreeModel * model = (asearch -> action == INSERT) ? GTK_TREE_MODEL(asearch -> obj_model) : GTK_TREE_MODEL(asearch -> atom_model);
1834 opengl_project_changed (this_proj -> id);
1835 gtk_tree_model_get (model, & iter, oid, & status, -1);
1836 atom_in_selection * selected;
1837 if (asearch -> action < 2 && oid == TOPIC)
1838 {
1840 switch (filter)
1841 {
1842 case 0:
1843 selected_aspec = sid;
1844#ifdef GTK4
1845 select_unselect_atoms (NULL, NULL, & this_proj -> modelgl -> colorp[0][! status]);
1846#else
1847 select_unselect_atoms (NULL, & this_proj -> modelgl -> colorp[0][! status]);
1848#endif
1849 break;
1850 default:
1851 if (filter < 3)
1852 {
1853 k = this_proj -> modelgl -> selection_mode;
1854 this_proj -> modelgl -> selection_mode = object;
1855 }
1856 p = this_proj -> modelgl -> anim -> last -> img -> step;
1857 for (l=0; l<this_proj -> natomes; l++)
1858 {
1859 n = this_proj -> atoms[p][l].sp;
1860 o = this_proj -> atoms[p][l].coord[filter-1];
1861 doit = FALSE;
1862 if (filter == 1)
1863 {
1864 if (this_proj -> atoms[p][l].numv == sid && append (asearch, this_proj, l, n)) doit = TRUE;
1865 }
1866 else
1867 {
1868 if (filter == 2)
1869 {
1870 for (m=0; m<n; m++)
1871 {
1872 o += this_proj -> coord -> ntg[1][m];
1873 }
1874 }
1875 if (o == sid && append (asearch, this_proj, l, n)) doit = TRUE;
1876 }
1877 if (doit)
1878 {
1879 o = get_to_be_selected (this_proj -> modelgl);
1880#ifdef GTK4
1881 if (this_proj -> atoms[p][l].pick[o] != status)
1882 {
1883 select_unselect_this_atom (NULL, NULL, GINT_TO_POINTER(l));
1884 }
1885 select_unselect_this_atom (NULL, NULL, GINT_TO_POINTER(l));
1886#else
1887 if (this_proj -> atoms[p][l].pick[o] != status)
1888 {
1889 select_unselect_this_atom (NULL, GINT_TO_POINTER(l));
1890 }
1891 select_unselect_this_atom (NULL, GINT_TO_POINTER(l));
1892#endif
1893 }
1894 }
1895 if (filter < 3) this_proj -> modelgl -> selection_mode = k;
1896 break;
1897 }
1898 }
1899 else
1900 {
1901 if (asearch -> action != INSERT)
1902 {
1903 if (oid == TOLAB)
1904 {
1905 if (asearch -> pointer[0].c == 8)
1906 {
1907 preserve_ogl_selection (this_proj -> modelgl);
1908 this_proj -> modelgl -> cell_win -> cut_this_slab = TRUE;
1909 save_all_selections (this_proj -> modelgl, 0);
1910 create_slab_lists (this_proj);
1911 update_all_selections (this_proj -> modelgl, 0);
1912 q = 0;
1913 if (this_proj -> modelgl -> anim -> last -> img -> selected[0] -> selected)
1914 {
1915 to_label = allocint (this_proj -> modelgl -> anim -> last -> img -> selected[0] -> selected);
1916 }
1917 }
1918 p = this_proj -> modelgl -> anim -> last -> img -> step;
1919 switch (filter)
1920 {
1921 case 0:
1922 if (asearch -> pointer[0].c == 8)
1923 {
1924 if (this_proj -> modelgl -> anim -> last -> img -> selected[0] -> selected)
1925 {
1926 selected = this_proj -> modelgl -> anim -> last -> img -> selected[0] -> first;
1927 while (selected)
1928 {
1929 if (selected -> sp == sid)
1930 {
1931 to_label[q] = selected -> id;
1932 q ++;
1933 }
1934 selected = selected -> next;
1935 }
1936 }
1937 }
1938 else
1939 {
1940#ifdef GTK4
1941 show_hide_labels (NULL, NULL, & this_proj -> modelgl -> colorp[is_clone][sid]);
1942#else
1943 // GTK3 Menu Action To Check
1944 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)this_proj -> modelgl -> ogl_lab[is_clone][sid], ! status);
1945 show_hide_labels (this_proj -> modelgl -> ogl_lab[is_clone][sid], & this_proj -> modelgl -> colorp[is_clone][sid]);
1946#endif
1947 }
1948 break;
1949 default:
1950 if (filter < 3)
1951 {
1952 k = this_proj -> modelgl -> selection_mode;
1953 this_proj -> modelgl -> selection_mode = object;
1954 }
1955 for (l=0; l<this_proj -> natomes; l++)
1956 {
1957 n = this_proj -> atoms[p][l].sp;
1958 o = this_proj -> atoms[p][l].coord[filter-1];
1959 doit = FALSE;
1960 if (filter == 1)
1961 {
1962 if (this_proj -> atoms[p][l].numv == sid && append (asearch, this_proj, l, n)) doit = TRUE;
1963 }
1964 else if (filter == 2 || filter == 4)
1965 {
1966 if (filter == 2)
1967 {
1968 for (m=0; m<n; m++)
1969 {
1970 o += this_proj -> coord -> ntg[1][m];
1971 }
1972 }
1973 if (o == sid && append (asearch, this_proj, l, n)) doit = TRUE;
1974 }
1975 else if (filter == 3)
1976 {
1977 if (asearch -> mode && object)
1978 {
1979 doit = TRUE;
1980 }
1981 else
1982 {
1983 if (o == sid && append (asearch, this_proj, l, n)) doit = TRUE;
1984 }
1985 }
1986 if (doit)
1987 {
1988 if (asearch -> pointer[0].c == 8)
1989 {
1990 if (this_proj -> modelgl -> anim -> last -> img -> selected[0] -> selected)
1991 {
1992 selected = this_proj -> modelgl -> anim -> last -> img -> selected[0] -> first;
1993 while (selected)
1994 {
1995 if (selected -> id == l)
1996 {
1997 to_label[q] = l;
1998 q ++;
1999 }
2000 selected = selected -> next;
2001 }
2002 }
2003 }
2004 else
2005 {
2006 this_proj -> atoms[p][l].label[0] = status;
2007#ifdef GTK4
2008 label_unlabel_this_atom (NULL, NULL, GINT_TO_POINTER(l));
2009#else
2010 label_unlabel_this_atom (NULL, GINT_TO_POINTER(l));
2011#endif
2012 }
2013 }
2014 }
2015 if (filter < 3) this_proj -> modelgl -> selection_mode = k;
2016 break;
2017 }
2018
2019 if (asearch -> pointer[0].c == 8)
2020 {
2021 restore_ogl_selection (this_proj -> modelgl);
2022 if (q)
2023 {
2024 for (l=0; l<q; l++)
2025 {
2026 m = to_label[l];
2027 this_proj -> atoms[0][m].label[0] = ! status;
2028 this_proj -> atoms[0][m].label[1] = ! status;
2029 }
2030 g_free (to_label);
2031 }
2032 this_proj -> modelgl -> cell_win -> cut_this_slab = FALSE;
2033 this_proj -> modelgl -> create_shaders[SLABS] = TRUE;
2034 gtk_tree_store_set (asearch -> atom_model, & iter, TOLAB, ! status, -1);
2035 }
2036 }
2037 else
2038 {
2039 if (asearch -> passivating || (object && filter > 2))
2040 {
2041 if (asearch -> action == RANMOVE)
2042 {
2043 if (! status)
2044 {
2045 asearch -> todo[sid] += (oid-TOLAB);
2046 }
2047 else
2048 {
2049 asearch -> todo[sid] -= (oid-TOLAB);
2050 }
2051 if (object && ! asearch -> passivating) adjust_object_to_move (this_proj, asearch, 1, sid);
2052 }
2053 else
2054 {
2055 asearch -> todo[sid] = ! status;
2056 if (asearch -> action == DISPL)
2057 {
2058 if (object && ! asearch -> passivating) adjust_object_to_move (this_proj, asearch, 0, sid);
2059 motion_to_zero (asearch);
2060 }
2061 }
2062 }
2063 else if (! asearch -> mode)
2064 {
2065 switch (filter)
2066 {
2067 case 0:
2068 for (l=0; l<this_proj -> natomes; l++)
2069 {
2070 n = this_proj -> atoms[0][l].sp;
2071 if (n == sid && append (asearch, this_proj, l, n))
2072 {
2073 if (asearch -> action == RANMOVE)
2074 {
2075 if (! status)
2076 {
2077 asearch -> todo[l] += (oid-TOLAB);
2078 }
2079 else
2080 {
2081 asearch -> todo[l] -= (oid-TOLAB);
2082 }
2083 if (object) adjust_object_to_move (this_proj, asearch, 1, l);
2084 }
2085 else
2086 {
2087 asearch -> todo[l] = ! status;
2088 if (asearch -> action == DISPL && object) adjust_object_to_move (this_proj, asearch, 0, l);
2089 }
2090 }
2091 }
2092 break;
2093 case 1:
2094 for (l=0; l<this_proj -> natomes; l++)
2095 {
2096 n = this_proj -> atoms[0][l].sp;
2097 if (this_proj -> atoms[0][l].numv == sid && append (asearch, this_proj, l, n))
2098 {
2099 if (asearch -> action == RANMOVE)
2100 {
2101 if (! status)
2102 {
2103 asearch -> todo[l] += (oid-TOLAB);
2104 }
2105 else
2106 {
2107 asearch -> todo[l] -= (oid-TOLAB);
2108 }
2109 if (object) adjust_object_to_move (this_proj, asearch, 1, l);
2110 }
2111 else
2112 {
2113 asearch -> todo[l] = ! status;
2114 if (asearch -> action == DISPL && object) adjust_object_to_move (this_proj, asearch, 0, l);
2115 }
2116 }
2117 }
2118 break;
2119 case 2:
2120 for (l=0; l<this_proj -> natomes; l++)
2121 {
2122 n = this_proj -> atoms[0][l].sp;
2123 o = this_proj -> atoms[0][l].coord[filter-1];
2124 for (m=0; m<n; m++)
2125 {
2126 o += this_proj -> coord -> ntg[1][m];
2127 }
2128 if (o == sid && append (asearch, this_proj, l, n))
2129 {
2130 if (asearch -> action == RANMOVE)
2131 {
2132 if (! status)
2133 {
2134 asearch -> todo[l] += (oid-TOLAB);
2135 }
2136 else
2137 {
2138 asearch -> todo[l] -= (oid-TOLAB);
2139 }
2140 if (object) adjust_object_to_move (this_proj, asearch, 1, l);
2141 }
2142 else
2143 {
2144 asearch -> todo[l] = ! status;
2145 if (asearch -> action == DISPL && object) adjust_object_to_move (this_proj, asearch, 0, l);
2146 }
2147 }
2148 }
2149 break;
2150 default:
2151 for (l=0; l<this_proj -> natomes; l++)
2152 {
2153 n = this_proj -> atoms[0][l].sp;
2154 o = this_proj -> atoms[0][l].coord[filter-1];
2155 if (o == sid && append (asearch, this_proj, l, n))
2156 {
2157 if (asearch -> action == RANMOVE)
2158 {
2159 if (! status)
2160 {
2161 asearch -> todo[l] += (oid-TOLAB);
2162 }
2163 else
2164 {
2165 asearch -> todo[l] -= (oid-TOLAB);
2166 }
2167 if (object) adjust_object_to_move (this_proj, asearch, 1, l);
2168 }
2169 else
2170 {
2171 asearch -> todo[l] = ! status;
2172 if (asearch -> action == DISPL && object) adjust_object_to_move (this_proj, asearch, 0, l);
2173 }
2174 }
2175 }
2176 break;
2177 }
2178 }
2179 }
2180 }
2181 else
2182 {
2183 for (k=0; k<asearch -> in_selection; k++)
2184 {
2185 asearch -> todo[k] = ! status;
2186 }
2187 }
2188 }
2189 switch (oid)
2190 {
2191 case TOLAB:
2192 if (asearch -> action == INSERT) asearch -> pick[sid] = ! status;
2193 asearch -> lab[sid] = ! status;
2194 break;
2195 default:
2196 if (asearch -> action == RANMOVE)
2197 {
2198 if (! status)
2199 {
2200 asearch -> pick[sid] += (oid-TOLAB);
2201 }
2202 else
2203 {
2204 asearch -> pick[sid] -= (oid-TOLAB);
2205 }
2206 }
2207 else
2208 {
2209 asearch -> pick[sid] = ! status;
2210 }
2211 break;
2212 }
2213 if (asearch -> todo_size < GTK_LIMIT || asearch -> passivating || (object == 2 && filter > 2)) update_search_tree (asearch);
2214}
2215
2228void adjust_this_tree_leaf (atom_search * asearch, project * this_proj, int oid, int aid, int new_status, GtkTreeIter iter)
2229{
2230 int status;
2231 int k, l, p;
2232 opengl_project_changed (this_proj -> id);
2233 int sel = this_proj -> modelgl -> selection_mode;
2234 int is_clone = (asearch -> action == 1) ? 1 : 0;
2235 int object = (asearch -> object) ? 1 : 0;
2236 this_proj -> modelgl -> selection_mode = object;
2237 p = this_proj -> modelgl -> anim -> last -> img -> step;
2238 // For atom i
2239 if (oid == TOLAB)
2240 {
2241 if (asearch -> action == INSERT)
2242 {
2243 if (asearch -> todo[aid] != new_status || new_status < 0)
2244 {
2245 status = ! asearch -> todo[aid];
2246 asearch -> todo[aid] = status;
2247 }
2248 }
2249 else if (this_proj -> atoms[p][aid].label[is_clone] != new_status || new_status < 0)
2250 {
2251#ifdef GTK4
2252 label_unlabel_this_atom (NULL, NULL, GINT_TO_POINTER(aid));
2253#else
2254 label_unlabel_this_atom (NULL, GINT_TO_POINTER(aid));
2255#endif
2256 status = this_proj -> atoms[p][aid].label[is_clone];
2257 }
2258 }
2259 else
2260 {
2261 if (asearch -> action < 2)
2262 {
2263 if (this_proj -> atoms[p][aid].pick[0] != new_status || new_status < 0)
2264 {
2265 // selected_status = ! this_proj -> atoms[p][aid].pick[get_to_be_selected (this_proj -> modelgl)];
2266 selected_status = ! this_proj -> atoms[p][aid].pick[0];
2267#ifdef GTK4
2268 select_unselect_this_atom (NULL, NULL, GINT_TO_POINTER(aid));
2269#else
2270 select_unselect_this_atom (NULL, GINT_TO_POINTER(aid));
2271#endif
2272 status = this_proj -> atoms[p][aid].pick[0];
2273 }
2274 }
2275 else
2276 {
2277 if (asearch -> todo[aid] != new_status || new_status < 0)
2278 {
2279 status = ! asearch -> todo[aid];
2280 adjust_search_param (asearch, this_proj, aid, this_proj -> atoms[p][aid].sp, oid, status);
2281 }
2282 }
2283 }
2284 status = (new_status < 0) ? status : new_status;
2285 if (asearch -> action == RANMOVE && oid != TOLAB)
2286 {
2287 k = (asearch -> todo[aid] == 1 || asearch -> todo[aid] == 3) ? 1 : 0;
2288 l = (asearch -> todo[aid] == 2 || asearch -> todo[aid] == 3) ? 1 : 0;
2289 // Check 'for all'
2290 gtk_tree_store_set (asearch -> atom_model, & iter, TOPIC, k, -1);
2291 if (object) gtk_tree_store_set (asearch -> atom_model, & iter, TOPIC+1, l, -1);
2292 }
2293 else if (asearch -> action == INSERT)
2294 {
2295 gtk_list_store_set (asearch -> obj_model, & iter, oid, status, -1);
2296 }
2297 else
2298 {
2299 if (asearch -> action == DISPL && oid != TOLAB) motion_to_zero (asearch);
2300 gtk_tree_store_set (asearch -> atom_model, & iter, oid, status, -1);
2301 }
2302 this_proj -> modelgl -> selection_mode = sel;
2303 check_all_trees (this_proj);
2304}
2305
2315G_MODULE_EXPORT void select_atom (GtkCellRendererToggle * cell_renderer, gchar * string_path, gpointer data)
2316{
2317 int i, j, k;
2318 GtkTreeIter iter;
2319 tint * dat = (tint *)data;
2320 project * this_proj = get_project_by_id(dat -> a);
2321 atom_search * asearch = this_proj -> modelgl -> search_widg[dat -> c];
2322 GtkTreePath * path = gtk_tree_path_new_from_string (string_path);
2323 GtkTreeModel * model = (asearch -> action == INSERT) ? GTK_TREE_MODEL(asearch -> obj_model) : GTK_TREE_MODEL(asearch -> atom_model);
2324 gtk_tree_model_get_iter (model, & iter, path);
2325 gtk_tree_model_get (model, & iter, IDCOL, & i, -1);
2326 check_label = FALSE;
2327 if (this_proj -> modelgl -> atom_win)
2328 {
2329 this_proj -> modelgl -> atom_win -> rebuilt[(asearch -> action == RANMOVE) ? 1 : 0] = FALSE;
2330 }
2331 if (i > 0)
2332 {
2333 i --;
2334 // For atom i
2335 adjust_this_tree_leaf (asearch, this_proj, dat -> b, i, -1, iter);
2336 }
2337 else
2338 {
2339 // For spec i
2340 if (asearch -> todo_size >= GTK_LIMIT && ! asearch -> passivating)
2341 {
2342 GtkTreeIter child;
2343 gtk_tree_model_get (GTK_TREE_MODEL(asearch -> atom_model), & iter, dat -> b, & j, -1);
2344 gtk_tree_store_set (asearch -> atom_model, & iter, dat -> b, ! j, -1);
2345 if (gtk_tree_model_iter_children (GTK_TREE_MODEL(asearch -> atom_model), & child, & iter))
2346 {
2347 gboolean dothis = TRUE;
2348 while (dothis)
2349 {
2350 gtk_tree_model_get (GTK_TREE_MODEL(asearch -> atom_model), & child, IDCOL, & k, -1);
2351 k --;
2352 adjust_this_tree_leaf (asearch, this_proj, dat -> b, k, ! j, child);
2353 dothis = gtk_tree_model_iter_next (GTK_TREE_MODEL(asearch -> atom_model), & child);
2354 }
2355 }
2356 }
2357 else
2358 {
2359 adjust_this_tree_branch (asearch, this_proj, dat -> b, abs(i) - 1, iter);
2360 }
2361 }
2362 if (asearch -> action == DISPL) check_motion_interactors (this_proj, asearch);
2363 check_label = TRUE;
2364 this_proj -> modelgl -> labelled = check_label_numbers (this_proj, 2);
2365 update (this_proj -> modelgl);
2366}
2367
2378int get_selected_object_id (gboolean visible, int p, gchar * str, atom_search * asearch)
2379{
2380 int i, j;
2381 gchar * word, * name;
2382 gchar * cmp;
2383 for (i = 1; mol[i].type || mol[i].object; i++)
2384 {
2385 if (mol[i].object != NULL)
2386 {
2387 cmp = g_strdup_printf ("%s", (i == 9 || i == 13 || i == 16 || i == 17) ? _(mol[i].object) : mol[i].object);
2388 if (g_strcmp0 (cmp, str) == 0)
2389 {
2390 g_free (cmp);
2391 if (i < 9)
2392 {
2393 return (int) mol[i].Z;
2394 }
2395 else if (i == 9)
2396 {
2397 return get_atom_id_from_periodic_table (asearch);
2398 }
2399 else if (i > 10 && i < 17)
2400 {
2401 return insert_this_project_from_lib (i-11, visible, get_project_by_id(p), asearch);
2402 }
2403 else if (i == 17)
2404 {
2405 return select_from_library (visible, get_project_by_id(p), asearch);
2406 }
2407 }
2408 g_free (cmp);
2409 }
2410 }
2411 for (i=0; i<nprojects; i++)
2412 {
2413 name = g_strdup_printf ("%s (%d)", get_project_by_id(i) -> name, i+1);
2414 for (j=0; j<3; j++)
2415 {
2416 word = g_strdup_printf (_("%s in %s"), _(action_atoms[j]), name);
2417 if (g_strcmp0 (word, str) == 0)
2418 {
2419 g_free (word);
2420 g_free (name);
2421 get_project_by_id(p) -> modelgl -> other_status = j;
2423 }
2424 else
2425 {
2426 g_free (word);
2427 }
2428 }
2429 g_free (name);
2430 }
2431 if (g_strcmp0 (_("Copied data"), str) == 0)
2432 {
2433 return FROM_DATA;
2434 }
2435 if (g_strcmp0 (_("Empty position"), str) == 0) return 120;
2436 return 0;
2437}
2438
2449void adjust_data_model_to_replace (project * this_proj, atom_search * asearch, int sid, int vid)
2450{
2451 int i, j, k, l;
2452 int filter = get_asearch_filter (asearch);
2453 switch (filter)
2454 {
2455 case 0:
2456 for (i=0; i<this_proj -> natomes; i++)
2457 {
2458 if (this_proj -> atoms[0][i].sp == sid && append (asearch, this_proj, i, this_proj -> atoms[0][i].sp))
2459 {
2460 to_insert_in_project (vid, i, this_proj, asearch, TRUE);
2461 }
2462 }
2463 break;
2464 case 1:
2465 for (i=0; i<this_proj -> natomes; i++)
2466 {
2467 if (this_proj -> atoms[0][i].numv == sid)
2468 {
2469 j = this_proj -> atoms[0][i].sp;
2470 if (append (asearch, this_proj, i, j))
2471 {
2472 to_insert_in_project (vid, i, this_proj, asearch, TRUE);
2473 }
2474 }
2475 }
2476 break;
2477 case 2:
2478 for (i=0; i<this_proj -> natomes; i++)
2479 {
2480 j = this_proj -> atoms[0][i].sp;
2481 k = this_proj -> atoms[0][i].coord[1];
2482 for (l=0; l<j; l++) k += this_proj -> coord -> ntg[1][l];
2483 if (k == sid && append (asearch, this_proj, i, j))
2484 {
2485 to_insert_in_project (vid, i, this_proj, asearch, TRUE);
2486 }
2487 }
2488 break;
2489 default:
2490 for (i=0; i<this_proj -> natomes; i++)
2491 {
2492 j = this_proj -> atoms[0][i].sp;
2493 k = this_proj -> atoms[0][i].coord[filter-1];
2494 if (k == sid && append (asearch, this_proj, i, j))
2495 {
2496 to_insert_in_project (vid, i, this_proj, asearch, TRUE);
2497 }
2498 }
2499 break;
2500 }
2501}
2502
2513G_MODULE_EXPORT void changed_action_renderer (GtkCellRendererCombo * combo, gchar * path_string, GtkTreeIter * iter, gpointer data)
2514{
2515 tint * dat = (tint *)data;
2516 project * this_proj = get_project_by_id(dat -> a);
2517 int h, i, j, k;
2518 atom_search * asearch = this_proj -> modelgl -> search_widg[dat -> c];
2519 GValue val = {0, };
2520 GObject * cmodel;
2521 g_object_get (combo, "model", & cmodel, NULL);
2522 gtk_tree_model_get_value ((GtkTreeModel *)cmodel, iter, 0, & val);
2523 GtkTreeIter child;
2524 gboolean dothis;
2525 GtkTreeModel * model = (asearch -> action == INSERT) ? GTK_TREE_MODEL(asearch -> obj_model) : GTK_TREE_MODEL(asearch -> atom_model);
2526 if (gtk_tree_model_get_iter_from_string (model, iter, path_string))
2527 {
2528 gtk_tree_model_get (model, iter, IDCOL, & h, -1);
2529 gchar * str = g_strdup_printf ("%s", (char *)g_value_get_string (& val));
2530 i = get_selected_object_id (TRUE, this_proj -> id, str, asearch);
2531 g_free (str);
2532 int object = get_asearch_object (asearch);
2533 int filter = get_asearch_filter (asearch);
2534 k = (asearch -> pointer[0].c == 3) ? 0 : (asearch -> pointer[0].c == 5) ? 1 : 3;
2535 if (h > 0 || (object && ! asearch -> passivating && filter > 2) || asearch -> passivating || asearch -> mode)
2536 {
2537 // Single atom or object
2538 if (i)
2539 {
2540 j = (asearch -> mode) ? h - 2 : abs(h) - 1;
2541 to_insert_in_project (i, j, this_proj, asearch, TRUE);
2542 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);
2543 gtk_tree_store_set (asearch -> atom_model, iter, TOPIC+1, str, -1);
2544 g_free (str);
2545 }
2546 else
2547 {
2548 gtk_tree_store_set (asearch -> atom_model, iter, TOPIC+1, (h > 0) ? _("Select ...") : _("Select for all ..."), -1);
2549 }
2550 }
2551 else
2552 {
2553 // The entire species
2554 if (i)
2555 {
2556 if (! asearch -> passivating && this_proj -> natomes >= GTK_LIMIT)
2557 {
2558 if (gtk_tree_model_iter_children (GTK_TREE_MODEL(asearch -> atom_model), & child, iter))
2559 {
2560 dothis = TRUE;
2561 while (dothis)
2562 {
2563 gtk_tree_model_get (GTK_TREE_MODEL(asearch -> atom_model), & child, IDCOL, & j, -1);
2564 j --;
2565 to_insert_in_project (i, j, this_proj, asearch, TRUE);
2566 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);
2567 dothis = gtk_tree_model_iter_next (GTK_TREE_MODEL(asearch -> atom_model), & child);
2568 }
2569 }
2570 str = g_strdup_printf (_("For all: %s"), get_atomic_object_by_origin(this_proj -> modelgl -> atom_win -> to_be_inserted[k], j, 0) -> name);
2571 gtk_tree_store_set (asearch -> atom_model, iter, TOPIC+1, str, -1);
2572 g_free (str);
2573 }
2574 else
2575 {
2576 adjust_data_model_to_replace (this_proj, asearch, abs(h)-1, i);
2577 }
2578 }
2579 else
2580 {
2581 if (! asearch -> passivating && this_proj -> natomes >= GTK_LIMIT)
2582 {
2583 gtk_tree_store_set (asearch -> atom_model, iter, 5, _("Select for all ..."), -1);
2584 if (gtk_tree_model_iter_children (GTK_TREE_MODEL(asearch -> atom_model), & child, iter))
2585 {
2586 dothis = TRUE;
2587 while (dothis)
2588 {
2589 gtk_tree_store_set (asearch -> atom_model, & child, TOPIC+1, _("Select ..."), -1);
2590 dothis = gtk_tree_model_iter_next (GTK_TREE_MODEL(asearch -> atom_model), & child);
2591 }
2592 }
2593 }
2594 else
2595 {
2596 gtk_tree_store_set (asearch -> atom_model, iter, 5, _("Select ..."), -1);
2597 }
2598 }
2599 }
2600 if (update_this_search(asearch)) update_search_tree (asearch);
2601 }
2602}
2603
2612GtkTreeModel * replace_combo_tree (gboolean insert, int proj)
2613{
2614 GtkTreeIter iter, iter2, iter3;
2615 GtkTreeStore *store;
2616 int i, j;
2617 gchar * name, * word;
2618
2619 store = gtk_tree_store_new (1, G_TYPE_STRING);
2620
2621 if (insert)
2622 {
2623 gtk_tree_store_append (store, & iter, NULL);
2624 gtk_tree_store_set (store, & iter, 0, _("Select ..."), -1);
2625 }
2626 for (i=0; mol[i].type || mol[i].object; i++)
2627 {
2628 if (mol[i].type)
2629 {
2630 gtk_tree_store_append (store, & iter, NULL);
2631 gtk_tree_store_set (store, & iter, 0, _(mol[i].type), -1);
2632 }
2633 else if (mol[i].object)
2634 {
2635 gtk_tree_store_append (store, & iter2, & iter);
2636 if (i == 9 || i == 13 || i == 16 || i == 17)
2637 {
2638 gtk_tree_store_set (store, & iter2, 0, _(mol[i].object), -1);
2639 }
2640 else
2641 {
2642 gtk_tree_store_set (store, & iter2, 0, mol[i].object, -1);
2643 }
2644 }
2645 }
2646 gboolean doit = FALSE;
2647 for (i=0; i<nprojects; i++)
2648 {
2649 if (get_project_by_id(i) -> steps == 1 && get_project_by_id(i) -> natomes)
2650 {
2651 doit = TRUE;
2652 break;
2653 }
2654 }
2655 if (doit)
2656 {
2657 gtk_tree_store_append (store, & iter, NULL);
2658 gtk_tree_store_set (store, & iter, 0, _("Import From Project"), -1);
2659 for (i=0; i<nprojects; i++)
2660 {
2661 if (get_project_by_id(i) -> steps == 1 && get_project_by_id(i) -> natomes)
2662 {
2663 gtk_tree_store_append (store, & iter2, & iter);
2664 name = g_strdup_printf ("%s (%d)", get_project_by_id(i) -> name, i+1);
2665 gtk_tree_store_set (store, & iter2, 0, name, -1);
2666 for (j=0; j<3; j++)
2667 {
2668 gtk_tree_store_append (store, & iter3, & iter2);
2669 word = g_strdup_printf (_("%s in %s"), _(action_atoms[j]), name);
2670 gtk_tree_store_set (store, & iter3, 0, word, -1);
2671 g_free (word);
2672 }
2673 g_free (name);
2674 }
2675 }
2676 }
2677 if (copied_object)
2678 {
2679 gtk_tree_store_append (store, &iter, NULL);
2680 gtk_tree_store_set (store, & iter, 0, _("Copied data"), -1);
2681 }
2682 if (get_project_by_id(proj) -> modelgl)
2683 {
2684 if (get_project_by_id(proj) -> modelgl -> builder_win)
2685 {
2686 gtk_tree_store_append (store, &iter, NULL);
2687 gtk_tree_store_set (store, & iter, 0, _("Empty position"), -1);
2688 }
2689 }
2690 return GTK_TREE_MODEL (store);
2691}
2692
2704void search_set_visible (GtkTreeViewColumn * col, GtkCellRenderer * renderer, GtkTreeModel * mod, GtkTreeIter * iter, gpointer data)
2705{
2706 int i, j;
2707 i = GPOINTER_TO_INT(data);
2708 i ++;
2709 gtk_tree_model_get (mod, iter, IDCOL, & j, -1);
2710 gboolean vis = (j < 0 && i == 2) ? FALSE : TRUE;
2711 gtk_cell_renderer_set_visible (renderer, vis);
2712 if (vis && (i < TOLAB || i > TOPIC))
2713 {
2714 set_renderer_markup (mod, iter, renderer, i);
2715 }
2716}
2717
2720
2729G_MODULE_EXPORT void set_occupancy (GtkEntry * res, gpointer data)
2730{
2731 const gchar * m = entry_get_text (res);
2732 double v = string_to_double ((gpointer)m);
2733 atomic_object * object = (atomic_object *)data;
2734 if (v > 0.0 && v<= 1.0)
2735 {
2736 object -> occ = v;
2737 }
2738 update_entry_double (res, object -> occ);
2739}
2740
2749G_MODULE_EXPORT void set_i_coord (GtkEntry * res, gpointer data)
2750{
2751 const gchar * m = entry_get_text (res);
2752 double v = string_to_double ((gpointer)m);
2753 int ax = GPOINTER_TO_INT (data);
2754 project * this_proj = get_project_by_id (csearch -> proj);
2755 int oid = (csearch -> pointer[0].c == 5) ? 1 : 2;
2756 atomic_object * object = get_atomic_object_by_origin (this_proj -> modelgl -> atom_win -> to_be_inserted[oid], 0, atom_to_edit+1);
2757 object -> baryc[ax] = v;
2758 update_entry_double (res, object -> baryc[ax]);
2759}
2760
2769G_MODULE_EXPORT void set_max_msd (GtkEntry * res, gpointer data)
2770{
2771 const gchar * m = entry_get_text (res);
2772 double v = string_to_double ((gpointer)m);
2773 int ax = GPOINTER_TO_INT (data);
2774 project * this_proj = get_project_by_id (csearch -> proj);
2775 if (! (v < 0.0))
2776 {
2777 if (ax > 0)
2778 {
2779 if (this_proj -> modelgl -> atom_win -> msd[ax-1] != v) csearch -> pick[this_proj -> atoms[0][ax-1].sp] = 0;
2780 this_proj -> modelgl -> atom_win -> msd[ax-1] = v;
2781 }
2782 else
2783 {
2784 ax = -ax-1;
2785 this_proj -> modelgl -> atom_win -> msd_all[ax] = v;
2786 if (! csearch -> passivating)
2787 {
2788 int object = get_asearch_object (csearch);
2790 int i, j, k, l;
2791 switch (filter)
2792 {
2793 case 0:
2794 for (i=0; i<this_proj -> natomes; i++)
2795 {
2796 if (this_proj -> atoms[0][i].sp == ax) this_proj -> modelgl -> atom_win -> msd[i] = v;
2797 }
2798 break;
2799 case 1:
2800 for (i=0; i<this_proj -> natomes; i++)
2801 {
2802 j = this_proj -> atoms[0][i].sp;
2803 if (this_proj -> atoms[0][i].numv == ax) this_proj -> modelgl -> atom_win -> msd[i] = v;
2804 }
2805 break;
2806 case 2:
2807 for (i=0; i<this_proj -> natomes; i++)
2808 {
2809 j = this_proj -> atoms[0][i].sp;
2810 k = this_proj -> atoms[0][i].coord[filter-1];
2811 for (l=0; l<j; l++) k += this_proj -> coord -> ntg[1][l];
2812 if (k == ax) this_proj -> modelgl -> atom_win -> msd[i] = v;
2813 }
2814 break;
2815 default:
2816 if (! object)
2817 {
2818 for (i=0; i<this_proj -> natomes; i++)
2819 {
2820 j = this_proj -> atoms[0][i].coord[filter-1];
2821 if (j == ax) this_proj -> modelgl -> atom_win -> msd[i] = v;
2822 }
2823 }
2824 break;
2825 }
2826 }
2827 }
2829 }
2830 else
2831 {
2832 //show_error (_("MSD<sub>max</sub> must be > 0.0 !"), 1, this_proj -> modelgl -> atom_win -> win);
2833 if (ax > 0)
2834 {
2835 v = this_proj -> modelgl -> atom_win -> msd[ax-1];
2836 }
2837 else
2838 {
2839 v = this_proj -> modelgl -> atom_win -> msd_all[-ax-1];
2840 }
2842 }
2843}
2844
2846
2855G_MODULE_EXPORT void set_max_action (GtkEntry * res, gpointer data)
2856{
2857 const gchar * m = entry_get_text (res);
2858 int v = (int)string_to_double ((gpointer)m);
2859 int ax = GPOINTER_TO_INT (data);
2860 if (v > -1 && v <= max_random)
2861 {
2862 csearch -> todo[-ax-1] = v;
2863 }
2864 update_entry_int (res, csearch -> todo[-ax-1]);
2865}
2866
2876void get_coord_iter_and_edit (gchar * path_string, gpointer data, GtkWidget * widg)
2877{
2878 tint * cid = (tint *)data;
2879 project * this_proj = get_project_by_id (cid -> a);
2880 csearch = this_proj -> modelgl -> search_widg[cid -> c];
2881 GtkTreeIter iter;
2882 GtkTreeModel * model = (csearch -> action == INSERT) ? GTK_TREE_MODEL(csearch -> obj_model) : GTK_TREE_MODEL(csearch -> atom_model);
2883 if (gtk_tree_model_get_iter (model, & iter, gtk_tree_path_new_from_string (path_string)))
2884 {
2885 int h, i, j, k, l;
2886 gtk_tree_model_get (model, & iter, IDCOL, & h, -1);
2887 if (h > 0 || csearch -> action == REPLACE || csearch -> action == REMOVE || csearch -> action == RANMOVE)
2888 {
2889
2890 atom_to_edit = h-1;
2891 GtkWidget * win = gtk_dialog_new ();
2892 if (this_proj -> modelgl -> builder_win)
2893 {
2894 gtk_window_set_transient_for (GTK_WINDOW (win), GTK_WINDOW(this_proj -> modelgl -> builder_win -> win));
2895 }
2896 else
2897 {
2898 gtk_window_set_transient_for (GTK_WINDOW (win), GTK_WINDOW(this_proj -> modelgl -> atom_win -> win));
2899 }
2900 gtk_window_set_resizable (GTK_WINDOW (win), FALSE);
2901 gchar * str;
2902 atomic_object * iobj;
2903 gchar * obj[5]={_("atom(s)"), _("total coordination(s)"), _("partial coordination(s)"), _("in fragment"), _("in molecule")};
2904 gchar * act[2]={_("Replace"), _("Remove")};
2905 int object = get_asearch_object (csearch);
2907 switch (csearch -> action)
2908 {
2909 case REPLACE:
2910 str = g_strdup_printf (_("%s %s randomly"), _("Replace"), obj[(object) ? filter : 0]);
2911 break;
2912 case REMOVE:
2913 str = g_strdup_printf (_("%s %s randomly"), _("Remove"), obj[(object) ? filter : 0]);
2914 break;
2915 case RANMOVE:
2916 str = g_strdup_printf (_("Maximum Mean Square Displacement"));
2917 break;
2918 default:
2919 i = (csearch -> pointer[0].c == 5) ? 1 : 2;
2920 iobj = get_atomic_object_by_origin (this_proj -> modelgl -> atom_win -> to_be_inserted[i], 0, atom_to_edit+1);
2921 if (cid -> b - TOLAB)
2922 {
2923 str = g_strdup_printf (_("Site occupancy for %s"), prepare_for_title(iobj -> name));
2924 }
2925 else
2926 {
2927 str = g_strdup_printf (_("Insert %s at"), prepare_for_title(iobj -> name));
2928 }
2929 break;
2930 }
2931 gtk_window_set_title (GTK_WINDOW(win), str);
2932 g_free (str);
2933 gtk_window_set_modal (GTK_WINDOW (win), TRUE);
2934 GtkWidget * vbox = dialog_get_content_area (win);
2935 GtkWidget * hbox;
2936 GtkWidget * entry;
2937 gchar * axis[3]={"x", "y", "z"};
2938 gchar * nran = NULL;
2939 switch (csearch -> action)
2940 {
2941 case INSERT:
2942 if (cid -> b - TOLAB && csearch -> pointer[0].c == 7)
2943 {
2944 hbox = create_hbox (5);
2945 str = g_strdup_printf (_("Occupancy= "));
2946 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label(str, 100, -1, 0.0, 0.5), FALSE, FALSE, 0);
2947 g_free (str);
2948 entry = create_entry (G_CALLBACK(set_occupancy), 100, 15, FALSE, iobj);
2949 update_entry_double (GTK_ENTRY(entry), iobj -> occ);
2950 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, entry, FALSE, FALSE, 0);
2951 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 5);
2952 }
2953 else
2954 {
2955 for (i=0; i<3; i++)
2956 {
2957 hbox = create_hbox (5);
2958 str = g_strdup_printf ("%s =", axis[i]);
2959 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label(str, 100, -1, 0.0, 0.5), FALSE, FALSE, 0);
2960 g_free (str);
2961 entry = create_entry (G_CALLBACK(set_i_coord), 100, 15, FALSE, GINT_TO_POINTER(i));
2962 update_entry_double (GTK_ENTRY(entry), iobj -> baryc[i]);
2963 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, entry, FALSE, FALSE, 0);
2964 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 5);
2965 }
2966 }
2967 break;
2968 case RANMOVE:
2969 hbox = create_hbox (5);
2970 entry = create_entry (G_CALLBACK(set_max_msd), 100, 15, FALSE, GINT_TO_POINTER(h));
2971 if (h > 0)
2972 {
2973 j = this_proj -> atoms[0][atom_to_edit].sp;
2974 if (object)
2975 {
2976 str = g_strdup_printf (_("MSD<sub>max</sub> for %s<sub>%d</sub> + neighbors = "), this_proj -> chemistry -> label[j], atom_to_edit+1);
2977 }
2978 else
2979 {
2980 str = g_strdup_printf (_("MSD<sub>max</sub> for %s<sub>%d</sub> = "), this_proj -> chemistry -> label[j], atom_to_edit+1);
2981 }
2982 update_entry_double (GTK_ENTRY(entry), this_proj -> modelgl -> atom_win -> msd[atom_to_edit]);
2983 }
2984 else
2985 {
2986 switch (filter)
2987 {
2988 case 0:
2989 str = g_strdup_printf (_("MSD<sub>max</sub> for all %s atom(s) = "), this_proj -> chemistry -> label[-h-1]);
2990 break;
2991 case 1:
2992 if (-h-1 == 0)
2993 {
2994 str = g_strdup_printf (_("MSD<sub>max</sub> for all isolated atom(s) = "));
2995 }
2996 else if (object)
2997 {
2998 str = g_strdup_printf (_("MSD<sub>max</sub> for all %d-fold atom(s) + neighbors = "), -h-1);
2999 }
3000 else
3001 {
3002 str = g_strdup_printf (_("MSD<sub>max</sub> for all %d-fold atom(s) = "), -h-1);
3003 }
3004 break;
3005 case 2:
3006 i = 0;
3007 for (j=0; j<this_proj -> nspec; j++)
3008 {
3009 i += this_proj -> coord -> ntg[1][j];
3010 if (i > -h-1) break;
3011 }
3012 k = 0;
3013 for (l=0; l<j; l++) k += this_proj -> coord -> ntg[1][l];
3014 i = (-h-1) - k;
3015 nran = env_name(this_proj, i, j, 1, NULL);
3016 if (object)
3017 {
3018 str = g_strdup_printf (_("MSD<sub>max</sub> for all %s + neighbors = "), nran);
3019 }
3020 else
3021 {
3022 str = g_strdup_printf (_("MSD<sub>max</sub> for all %s = "), nran);
3023 }
3024 break;
3025 case 3:
3026 if (object)
3027 {
3028 str = g_strdup_printf (_("MSD<sub>max</sub> for fragment N°%d = "), -h);
3029 }
3030 else
3031 {
3032 str = g_strdup_printf (_("MSD<sub>max</sub> for the atom(s) in fragment N°%d = "), -h);
3033 }
3034 break;
3035 case 4:
3036 if (object)
3037 {
3038 str = g_strdup_printf (_("MSD<sub>max</sub> for molecule N°%d = "), -h);
3039 }
3040 else
3041 {
3042 str = g_strdup_printf (_("MSD<sub>max</sub> for the atom(s) in molecule N°%d = "), -h);
3043 }
3044 break;
3045 }
3046 update_entry_double (GTK_ENTRY(entry), this_proj -> modelgl -> atom_win -> msd_all[-h-1]);
3047 }
3048 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label(str, 100, -1, 0.0, 0.5), FALSE, FALSE, 15);
3049 g_free (str);
3050 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, entry, FALSE, FALSE, 0);
3051 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label("[&#xC5;<sup>2</sup>]", 50, -1, 0.0, 0.5), FALSE, FALSE, 0);
3052 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 5);
3053 break;
3054 default:
3055 max_random = 0;
3056 switch (filter)
3057 {
3058 case 0:
3059 if (csearch -> status == 2)
3060 {
3061 max_random = this_proj -> chemistry -> nsps[-h-1];
3062 nran = g_strdup_printf ("%s", this_proj -> chemistry -> label[-h-1]);
3063 }
3064 else
3065 {
3066 max_random = 0;
3067 for (i=0; i<this_proj -> natomes; i++)
3068 {
3069 if (this_proj -> atoms[0][i].sp == -h-1 && this_proj -> atoms[0][i].pick[0] == csearch -> status) max_random ++;
3070 }
3071 }
3072 break;
3073 case 1:
3074 for (i=0; i<this_proj -> natomes; i++)
3075 {
3076 if (this_proj -> atoms[0][i].numv == -h-1 && (this_proj -> atoms[0][i].pick[0] == csearch -> status || csearch -> status == 2)) max_random ++;
3077 }
3078 if (-h-1 > 0)
3079 {
3080 nran = g_strdup_printf (_("%d-fold"), -h-1);
3081 }
3082 else
3083 {
3084 nran = g_strdup_printf (_("isolated"));
3085 }
3086 break;
3087 case 2:
3088 i = 0;
3089 for (j=0; j<this_proj -> nspec; j++)
3090 {
3091 i += this_proj -> coord -> ntg[1][j];
3092 if (i > -h-1) break;
3093 }
3094 k = 0;
3095 for (l=0; l<j; l++) k += this_proj -> coord -> ntg[1][l];
3096 i = (-h-1) - k;
3097 for (k=0; k<this_proj -> natomes; k++)
3098 {
3099 if (this_proj -> atoms[0][k].sp == j && this_proj -> atoms[0][k].coord[1] == i)
3100 {
3101 if (this_proj -> atoms[0][k].pick[0] == csearch -> status || csearch -> status == 2) max_random ++;
3102 }
3103 }
3104 if (csearch -> action != RANMOVE) nran = env_name(this_proj, i, j, 1, NULL);
3105 break;
3106 default:
3107 if (object)
3108 {
3109 i = (-h-1);
3110 if (filter == 3)
3111 {
3112 max_random = this_proj -> coord -> totcoord[2];
3113 }
3114 else if (filter == 4)
3115 {
3116 max_random = this_proj -> modelfc -> mols[0][i].multiplicity;
3117 }
3118 }
3119 else
3120 {
3121 i = (-h-1);
3122 for (k=0; k<this_proj -> natomes; k++)
3123 {
3124 if (this_proj -> atoms[0][k].coord[filter-1] == i)
3125 {
3126 if (this_proj -> atoms[0][k].pick[0] == csearch -> status || csearch -> status == 2) max_random ++;
3127 }
3128 }
3129 nran = g_strdup_printf (_("atom(s)"));
3130 }
3131 break;
3132 }
3133
3134 hbox = create_hbox (5);
3135 entry = create_entry (G_CALLBACK(set_max_action), 100, 15, FALSE, GINT_TO_POINTER(h));
3136 if (object)
3137 {
3138 if (filter == 3)
3139 {
3140 str = g_strdup_printf (_("%s randomly <i>n</i> <b>fragment(s)</b> in all fragments, <i>n</i>= "), act[csearch -> action - 3]);
3141 }
3142 else if (filter == 4)
3143 {
3144 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);
3145 }
3146 else
3147 {
3148 str = g_strdup_printf (_("%s randomly <i>n</i> <b>%s</b> coordinations, <i>n</i>= "), act[csearch -> action - 3], nran);
3149 }
3150 }
3151 else
3152 {
3153 if (filter < 3)
3154 {
3155 str = g_strdup_printf (_("%s randomly <i>n</i> <b>%s</b> %s, <i>n</i>= "), act[csearch -> action - 3], nran, obj[0]);
3156 }
3157 else
3158 {
3159 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);
3160 }
3161 }
3162 if (nran) g_free (nran);
3163 update_entry_int (GTK_ENTRY(entry), csearch -> todo[-h-1]);
3164 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label(str, 100, -1, 0.0, 0.5), FALSE, FALSE, 15);
3165 g_free (str);
3166 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, entry, FALSE, FALSE, 0);
3167 str = g_strdup_printf (_(" with <i>n</i><sub>max</sub> = <b>%d</b>"), max_random);
3168 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label(str, 50, -1, 0.0, 0.5), FALSE, FALSE, 15);
3169 g_free (str);
3170 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 5);
3171 break;
3172 }
3173 run_this_gtk_dialog (win, G_CALLBACK(run_destroy_dialog), NULL);
3174 if (csearch -> action != RANMOVE)
3175 {
3177 }
3178 else
3179 {
3180 if (h > 0)
3181 {
3182 if (this_proj -> modelgl -> atom_win -> msd[atom_to_edit] > 0.0)
3183 {
3184 str = g_strdup_printf (_("MSD<sub>max</sub>= %f"), this_proj -> modelgl -> atom_win -> msd[atom_to_edit]);
3185 }
3186 else
3187 {
3188 str = g_strdup_printf (_("Set MSD<sub>max</sub> for ..."));
3189 }
3190 gtk_tree_store_set (csearch -> atom_model, & iter, TOPIC+2, str, -1);
3191 g_free (str);
3192 }
3193 else
3194 {
3195 if (this_proj -> modelgl -> atom_win -> msd_all[-h-1] > 0.0)
3196 {
3197 if (object && filter > 2)
3198 {
3199 str = g_strdup_printf (_("MSD<sub>max</sub>= %f"), this_proj -> modelgl -> atom_win -> msd_all[-h-1]);
3200 }
3201 else
3202 {
3203 str = g_strdup_printf (_("For all: MSD<sub>max</sub>= %f"), this_proj -> modelgl -> atom_win -> msd_all[-h-1]);
3204 }
3205 gtk_tree_store_set (csearch -> atom_model, & iter, TOPIC+2, str, -1);
3206 g_free (str);
3207 }
3208 else
3209 {
3210 if (object && filter > 2)
3211 {
3212 gtk_tree_store_set (csearch -> atom_model, &iter, TOPIC+2, _("Set MSD<sub>max</sub> for ..."), -1);
3213 }
3214 else
3215 {
3216 gtk_tree_store_set (csearch -> atom_model, & iter, TOPIC+2, _("Set MSD<sub>max</sub> for all ..."), -1);
3217 }
3218 }
3219 }
3220 check_all_trees (this_proj);
3221 }
3222 }
3223 }
3224}
3225
3236G_MODULE_EXPORT void to_edit_coords (GtkCellRenderer * cell, GtkCellEditable * editable, gchar * path_string, gpointer data)
3237{
3238 destroy_this_widget (GTK_WIDGET(editable));
3239 get_coord_iter_and_edit (path_string, data, NULL);
3240}
3241
3252G_MODULE_EXPORT void markup_action_renderer (GtkCellRendererCombo * cell, GtkCellEditable * editable, gchar * path_string, gpointer data)
3253{
3254 combo_set_markup ((GtkWidget *)editable);
3255}
3256
3265G_MODULE_EXPORT void set_max_msd_for_all (GtkEntry * res, gpointer data)
3266{
3267 const gchar * m = entry_get_text (res);
3268 double v = string_to_double ((gpointer)m);
3269 project * this_proj = get_project_by_id (csearch -> proj);
3270 int i, j;
3271 if (v <= 0.0)
3272 {
3273 // show_error (_("MSD<sub>max</sub> must be > 0.0 !"), 1, this_proj -> modelgl -> atom_win -> win);
3274 v = this_proj -> modelgl -> atom_win -> msd[0];
3275 }
3276 i = csearch -> todo_size;
3277 for (j=0; j<i; j++)
3278 {
3279 this_proj -> modelgl -> atom_win -> msd[j] = v;
3280 }
3282 for (j=0; j<i; j++)
3283 {
3284 this_proj -> modelgl -> atom_win -> msd_all[j] = v;
3285 }
3287}
3288
3299gboolean update_search_model (GtkTreeModel * model, GtkTreePath * path, GtkTreeIter * iter, gpointer data)
3300{
3301 int i;
3302 tint * dat = (tint *)data;
3303 project * this_proj = get_project_by_id(dat -> a);
3304 atom_search * asearch = this_proj -> modelgl -> search_widg[dat -> c];
3305 if (gtk_tree_model_get_iter (model, iter, path))
3306 {
3307 gtk_tree_model_get (model, iter, IDCOL, & i, -1);
3308 gtk_tree_store_set (GTK_TREE_STORE(model), iter, dat -> b, asearch -> int_b, -1);
3309 if (i > 0)
3310 {
3311 i --;
3312 adjust_this_tree_leaf (asearch, this_proj, dat -> b, i, asearch -> int_b, * iter);
3313 }
3314 else if (asearch -> object)
3315 {
3316 adjust_this_tree_branch (asearch, this_proj, dat -> b, abs(i) - 1, * iter);
3317 }
3318 return FALSE;
3319 }
3320 else
3321 {
3322 return TRUE;
3323 }
3324}
3325
3334G_MODULE_EXPORT void select_all_atoms (GtkTreeViewColumn * col, gpointer data)
3335{
3336 tint * dat = (tint *)data;
3337 project * this_proj = get_project_by_id(dat -> a);
3338 csearch = this_proj -> modelgl -> search_widg[dat -> c];
3339 int i, j, k;
3340 opengl_project_changed (dat -> a);
3341 if (dat -> b == TOPIC+2)
3342 {
3343 GtkWidget * win = gtk_dialog_new ();
3344 gtk_window_set_transient_for (GTK_WINDOW (win), GTK_WINDOW(this_proj -> modelgl -> atom_win -> win));
3345 gtk_window_set_resizable (GTK_WINDOW (win), FALSE);
3346 gchar * str = g_strdup_printf (_("Maximum Mean Square Displacement"));
3347 gtk_window_set_title (GTK_WINDOW(win), str);
3348 g_free (str);
3349 gtk_window_set_modal (GTK_WINDOW (win), TRUE);
3350 GtkWidget * vbox = dialog_get_content_area (win);
3351 GtkWidget * hbox = create_hbox (5);
3352 GtkWidget * entry = create_entry (G_CALLBACK(set_max_msd_for_all), 100, 15, FALSE, NULL);
3353 update_entry_double (GTK_ENTRY(entry), 0.0);
3354 str = g_strdup_printf (_("MSD<sub>max</sub> for all objects = "));
3355 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label(str, 100, -1, 0.0, 0.5), FALSE, FALSE, 15);
3356 g_free (str);
3357 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, entry, FALSE, FALSE, 0);
3358 str = g_strdup_printf ("[&#xC5;<sup>2</sup>]");
3359 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label(str, 50, -1, 0.0, 0.5), FALSE, FALSE, 0);
3360 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 5);
3361 run_this_gtk_dialog (win, G_CALLBACK(run_destroy_dialog), NULL);
3363 }
3364 else
3365 {
3366 if (dat -> b == TOLAB)
3367 {
3368 if (csearch -> action == INSERT)
3369 {
3370 k = (csearch -> pointer[0].c == 5) ? 1 : 2;
3371 if (this_proj -> modelgl -> atom_win -> to_be_inserted[k])
3372 {
3373 j = ! csearch -> todo[0];
3374 for (i=0; i<csearch -> in_selection; i++) csearch -> todo[i] = j;
3375 }
3376 }
3377 else
3378 {
3379 k = this_proj -> modelgl -> anim -> last -> img -> step;
3380 if (csearch -> action < 2)
3381 {
3382 is_selected = -1;
3383 i = 0;
3384 }
3385 else
3386 {
3387 if (csearch -> status < 2)
3388 {
3390 for (i=0; i<this_proj -> natomes; i++)
3391 {
3392 if (this_proj -> atoms[k][i].pick[0] == is_selected) break;
3393 }
3394 }
3395 else
3396 {
3397 is_selected = -1;
3398 i = 0;
3399 }
3400 }
3401 j = ! this_proj -> atoms[k][i].label[0];
3402 selected_aspec = -1;
3403 column_label = TRUE;
3404#ifdef GTK4
3405 label_unlabel_atoms (NULL, NULL, & opengl_project -> modelgl -> colorp[0][j]);
3406#else
3407 label_unlabel_atoms (NULL, & opengl_project -> modelgl -> colorp[0][j]);
3408#endif
3409 column_label = FALSE;
3410 }
3411 }
3412 else
3413 {
3414 k = this_proj -> modelgl -> anim -> last -> img -> step;
3415 if (csearch -> action < 2)
3416 {
3417 j = ! this_proj -> atoms[k][0].pick[0];
3419#ifdef GTK4
3420 select_unselect_atoms (NULL, NULL, & opengl_project -> modelgl -> colorp[0][j]);
3421#else
3422 select_unselect_atoms (NULL, & opengl_project -> modelgl -> colorp[0][j]);
3423#endif
3424 }
3425 else
3426 {
3427 if (csearch -> action != RANMOVE)
3428 {
3429 j = (csearch -> set_for_all < 0) ? 0 : 1;
3430 }
3431 else
3432 {
3433 // The value depends on both translation (1), rotation (2), or both (3)
3434 switch (abs(csearch -> set_for_all))
3435 {
3436 case 0:
3437 if (dat -> b == TOPIC)
3438 {
3439 j = 1;
3440 }
3441 else
3442 {
3443 j = 2;
3444 }
3445 break;
3446 case 1:
3447 if (dat -> b == TOPIC)
3448 {
3449 j = 0;
3450 }
3451 else
3452 {
3453 j = 3;
3454 }
3455 break;
3456 case 2:
3457 if (dat -> b == TOPIC)
3458 {
3459 j = 3;
3460 }
3461 else
3462 {
3463 j = 0;
3464 }
3465 break;
3466 case 3:
3467 if (dat -> b == TOPIC)
3468 {
3469 j = 2;
3470 }
3471 else
3472 {
3473 j = 1;
3474 }
3475 break;
3476 }
3477 }
3478 }
3479 }
3480 if (csearch -> action > 1 && dat -> c != 7)
3481 {
3483 if (dat -> b != TOLAB) clean_todo (csearch);
3484 }
3485 csearch -> set_for_all = (dat -> b == TOLAB) ? 0 : j;
3487 }
3488 /*else
3489 {
3490 GtkTreeIter iter;
3491 if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL(csearch -> atom_model), & iter))
3492 {
3493 gtk_tree_model_get (GTK_TREE_MODEL(csearch -> atom_model), & iter, dat -> b, & j, -1);
3494 g_debug ("j= %d,", j);
3495 g_debug ("a= %d, b= %d, c= %d, aa= %d, bb= %d, cc= %d", dat -> a, dat -> b, dat -> c,
3496 csearch -> pointer[dat -> b-TOLAB].a, csearch -> pointer[dat -> b-TOLAB].b, csearch -> pointer[dat -> b-TOLAB].c);
3497 csearch -> int_b = ! j;
3498 gtk_tree_model_foreach (GTK_TREE_MODEL(csearch -> atom_model), update_search_model, & csearch -> pointer[dat -> b-TOLAB]);
3499 }
3500 }*/
3501}
3502
3512G_MODULE_EXPORT void move_up_down (GtkTreeModel * tree_model, GtkTreePath * path, gpointer data)
3513{
3514 atom_search * asearch = (atom_search *)data;
3515 project * this_proj = get_project_by_id(asearch -> proj);
3516 atomic_object * obja, * objb, * objc;
3517 GtkTreeIter iter;
3518 gboolean valid;
3519 int i, j;
3520 int * old_todo = duplicate_int (asearch -> in_selection, asearch -> todo);
3521 obja = duplicate_atomic_object (this_proj -> modelgl -> atom_win -> to_be_inserted[2]);
3522 obja -> next = this_proj -> modelgl -> atom_win -> to_be_inserted[2] -> next;
3523 g_free (this_proj -> modelgl -> atom_win -> to_be_inserted[2]);
3524 objb = NULL;
3525 valid = gtk_tree_model_get_iter_first (tree_model, & iter);
3526 j = 0;
3527 while (valid)
3528 {
3529 gtk_tree_model_get (tree_model, & iter, 0, & i, -1);
3530 i --;
3531 objc = obja;
3532 while (objc -> id != i) objc = objc -> next;
3533 if (objc)
3534 {
3535 if (! objb)
3536 {
3537 this_proj -> modelgl -> atom_win -> to_be_inserted[2] = duplicate_atomic_object (objc);
3538 objb = this_proj -> modelgl -> atom_win -> to_be_inserted[2];
3539 }
3540 else
3541 {
3542 objb -> next = duplicate_atomic_object (objc);
3543 objb -> next -> prev = objb;
3544 objb = objb -> next;
3545 }
3546 objb -> id = j;
3547 asearch -> todo[j] = old_todo[i];
3548 j ++;
3549 }
3550 valid = gtk_tree_model_iter_next (tree_model, & iter);
3551 }
3552 g_free (old_todo);
3553 i = 0;
3554 valid = gtk_tree_model_get_iter_first (tree_model, & iter);
3555 while (valid)
3556 {
3557 gtk_list_store_set (GTK_LIST_STORE(tree_model), & iter, IDCOL, i+1, 1, g_strdup_printf ("%d", i+1), -1);
3558 i ++;
3559 valid = gtk_tree_model_iter_next (tree_model, & iter);
3560 }
3561}
3562
3572GtkWidget * create_atoms_tree (atom_search * asearch, project * this_proj, int nats)
3573{
3574 int i, j, k, l;
3575 GtkTreeViewColumn * atom_col[5];
3576 GtkCellRenderer * atom_cell[5];
3577 gchar * ctitle[6][5]={{i18n("Object"), i18n("Name"), i18n("Label"), i18n("Pick"), " "},
3578 {i18n("Object"), i18n("Name"), i18n("Label"), i18n("Move"), " "},
3579 {i18n("Object"), i18n("Name"), i18n("Label"), i18n("Replace"), i18n("By")},
3580 {i18n("Object"), i18n("Name"), i18n("Label"), i18n("Remove"), " "},
3581 {i18n("Object"), i18n("Name"), i18n("Insert"), i18n("Position"), i18n("Occupancy")},
3582 {i18n("Object"), i18n("Name"), i18n("Label"), i18n("Translate"), i18n("Max. MSD")}};
3583 gchar * ctype[3][5]={{"text", "text", "active", "active", "text"},
3584 {"text", "text", "active", "text", "text"},
3585 {"text", "text", "active", "active", "text"}};
3586 j = (asearch -> action == REPLACE || asearch -> action == RANMOVE) ? 1 : 0;
3587 k = (asearch -> action == RANMOVE) ? 2 : (asearch -> action == INSERT) ? 1 : 0;
3588 if (asearch -> action == INSERT && asearch -> pointer[0].c == 7) j ++;
3589 gboolean toggle;
3590 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},
3591 {G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT},
3592 {G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_INT}};
3593 if (asearch -> action == INSERT)
3594 {
3595 asearch -> obj_model = gtk_list_store_newv (8, coltype[k]);
3596 }
3597 else
3598 {
3599 asearch -> atom_model = gtk_tree_store_newv (8, coltype[k]);
3600 }
3601 if (! (nats >= GTK_LIMIT) || asearch -> action == INSERT)
3602 {
3603 fill_atom_model (asearch, this_proj);
3604 }
3605 if (asearch -> action == INSERT)
3606 {
3607 asearch -> atom_tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(asearch -> obj_model));
3608 }
3609 else
3610 {
3611 asearch -> atom_tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(asearch -> atom_model));
3612 }
3613
3614 for (i=0; i<4+j; i++)
3615 {
3616 toggle = FALSE;
3617 if (i < 2 || (asearch -> action == INSERT && i > 2) || (asearch -> action == RANMOVE && i == 4))
3618 {
3619 atom_cell[i] = gtk_cell_renderer_text_new ();
3620 if ((asearch -> action == INSERT && i > 2) || (asearch -> action == RANMOVE && i == 4))
3621 {
3622 g_object_set (atom_cell[i], "editable", TRUE, NULL);
3623 g_signal_connect (G_OBJECT(atom_cell[i]), "editing-started", G_CALLBACK(to_edit_coords), & asearch -> pointer[i-3]);
3624 if (asearch -> action == RANMOVE) toggle = TRUE;
3625 }
3626 }
3627 else if (i < 4)
3628 {
3629 atom_cell[i] = gtk_cell_renderer_toggle_new ();
3630 g_signal_connect (G_OBJECT(atom_cell[i]), "toggled", G_CALLBACK(select_atom), & asearch -> pointer[i-2]);
3631 toggle = TRUE;
3632 }
3633 else
3634 {
3635 atom_cell[i] = gtk_cell_renderer_combo_new ();
3636 GtkTreeModel * model = replace_combo_tree (FALSE, this_proj -> id);
3637 g_object_set (atom_cell[i], "model", model, "text-column", 0, "has-entry", FALSE, "editable", TRUE, NULL);
3638 g_object_unref (model);
3639 g_signal_connect (G_OBJECT(atom_cell[i]), "editing-started", G_CALLBACK(markup_action_renderer), & asearch -> pointer[i-4]);
3640 g_signal_connect (G_OBJECT(atom_cell[i]), "changed", G_CALLBACK(changed_action_renderer), & asearch -> pointer[i-4]);
3641 }
3642 gtk_cell_renderer_set_fixed_size (atom_cell[i], -1, 25);
3643 l = (asearch -> action == RANMOVE && i == 4) ? i+1 : i;
3644 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);
3645 if (toggle && ! asearch -> passivating)
3646 {
3647 gtk_tree_view_column_set_clickable (atom_col[i], TRUE);
3648 g_signal_connect (G_OBJECT(atom_col[i]), "clicked", G_CALLBACK(select_all_atoms), & asearch -> pointer[l-2]);
3649 }
3650 gtk_tree_view_append_column(GTK_TREE_VIEW(asearch -> atom_tree), atom_col[i]);
3651 gtk_tree_view_column_set_alignment (atom_col[i], 0.5);
3652 gtk_tree_view_column_set_cell_data_func (atom_col[i], atom_cell[i], search_set_visible, GINT_TO_POINTER(l), NULL);
3653 }
3654 if (asearch -> pointer[0].c == 7)
3655 {
3656 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);
3657 gtk_tree_view_set_reorderable (GTK_TREE_VIEW(asearch -> atom_tree), TRUE);
3658 }
3659 return asearch -> atom_tree;
3660}
3661
3670{
3671 int object = get_asearch_object (asearch);
3672 int filter = get_asearch_filter (asearch);
3673 project * this_proj = get_project_by_id (asearch -> proj);
3674 int tsize = 0;
3675 switch (filter)
3676 {
3677 case 0:
3678 tsize = (asearch -> mode || asearch -> passivating) ? this_proj -> nspec : this_proj -> natomes;
3679 break;
3680 case 1:
3681 tsize = (asearch -> mode || asearch -> passivating) ? this_proj -> coord -> cmax+1 : this_proj -> natomes;
3682 break;
3683 default:
3684 if (asearch -> mode || asearch -> passivating)
3685 {
3686 tsize = this_proj -> coord -> totcoord[filter -1];
3687 }
3688 else
3689 {
3690 tsize = (object && filter > 2) ? this_proj -> coord -> totcoord[filter -1] : this_proj -> natomes;
3691 }
3692 break;
3693 }
3694 return tsize;
3695}
3696
3705void allocate_todo (atom_search * asearch, int tsize)
3706{
3707 asearch -> todo = allocint (tsize);
3708 asearch -> todo_size = tsize;
3709}
3710
3718void clean_todo (atom_search * asearch)
3719{
3720 project * this_proj = get_project_by_id (asearch -> proj);
3721 if (asearch -> todo) g_free (asearch -> todo);
3722 allocate_todo (asearch, get_todo_size(asearch));
3723 atomic_object * object;
3724 switch (asearch -> action)
3725 {
3726 case DISPL:
3727 if (this_proj -> modelgl -> atom_win -> to_be_moved[0])
3728 {
3729 object = this_proj -> modelgl -> atom_win -> to_be_moved[0];
3730 while (object -> next)
3731 {
3732 object = object -> next;
3733 g_free (object -> prev);
3734 }
3735 g_free (object);
3736 this_proj -> modelgl -> atom_win -> to_be_moved[0] = NULL;
3737 }
3738 break;
3739 case RANMOVE:
3740 if (this_proj -> modelgl -> atom_win -> to_be_moved[1])
3741 {
3742 object = this_proj -> modelgl -> atom_win -> to_be_moved[1];
3743 while (object -> next)
3744 {
3745 object = object -> next;
3746 g_free (object -> prev);
3747 }
3748 g_free (object);
3749 this_proj -> modelgl -> atom_win -> to_be_moved[1] = NULL;
3750 }
3751 g_free (this_proj -> modelgl -> atom_win -> msd);
3752 this_proj -> modelgl -> atom_win -> msd = allocfloat (asearch -> todo_size);
3753 break;
3754 case REPLACE:
3755 if (this_proj -> modelgl -> atom_win -> to_be_inserted[0])
3756 {
3757 object = this_proj -> modelgl -> atom_win -> to_be_inserted[0];
3758 while (object -> next)
3759 {
3760 object = object -> next;
3761 g_free (object -> prev);
3762 }
3763 g_free (object);
3764 this_proj -> modelgl -> atom_win -> to_be_inserted[0] = NULL;
3765 }
3766 asearch -> in_selection = 0;
3767 break;
3768 }
3769}
3770
3779void clean_picked_and_labelled (atom_search * asearch, gboolean clean_msd)
3780{
3781 project * this_proj;
3782 int val = get_asearch_num_objects (asearch);
3783 asearch -> lab = allocint (val);
3784 asearch -> pick = allocint (val);
3785 if (asearch -> action == RANMOVE)
3786 {
3787 this_proj = get_project_by_id (asearch -> proj);
3788 if (this_proj -> modelgl -> atom_win && clean_msd)
3789 {
3790 g_free (this_proj -> modelgl -> atom_win -> msd_all);
3791 this_proj -> modelgl -> atom_win -> msd_all = allocfloat (val);
3792 }
3793 }
3794 else if (asearch -> action == REPLACE)
3795 {
3796 this_proj = get_project_by_id (asearch -> proj);
3797 int i = (asearch -> pointer[0].c == 3) ? 0 : 1;
3798 if (this_proj -> modelgl -> atom_win)
3799 {
3800 if (this_proj -> modelgl -> atom_win -> win && this_proj -> modelgl -> atom_win -> replace_nodes[i])
3801 {
3802 g_free (this_proj -> modelgl -> atom_win -> replace_nodes[i]);
3803 }
3804 this_proj -> modelgl -> atom_win -> replace_nodes[i] = g_malloc0(val*sizeof*this_proj -> modelgl -> atom_win -> replace_nodes[i]);
3805 }
3806 }
3807}
3808
3817G_MODULE_EXPORT void set_spec_changed (GtkComboBox * box, gpointer data)
3818{
3819 atom_search * asearch = (atom_search *) data;
3820 int i = combo_get_active ((GtkWidget *)box);
3821 asearch -> spec = i;
3822 update_search_tree (asearch);
3823 if (get_project_by_id(asearch -> proj) -> natomes >= GTK_LIMIT)
3824 {
3825 if (i > 0)
3826 {
3827 update_entry_text (GTK_ENTRY(asearch -> entry_a), exact_name(get_project_by_id(asearch -> proj) -> chemistry -> label[i-1]));
3828 }
3829 else
3830 {
3831 update_entry_text (GTK_ENTRY(asearch -> entry_a), "");
3832 }
3833 set_atom (GTK_ENTRY(asearch -> entry_a), asearch);
3834 widget_set_sensitive (asearch -> entry_a, ! i);
3835 }
3836}
3837
3846G_MODULE_EXPORT void set_filter_changed (GtkComboBox * box, gpointer data)
3847{
3848 atom_search * asearch = (atom_search *) data;
3849 asearch -> filter = combo_get_active ((GtkWidget *)box);
3850 int object = get_asearch_object (asearch);
3851 int filter = get_asearch_filter (asearch);
3852 widget_set_sensitive (asearch -> atom_box, (object && filter > 2) ? 0 : 1);
3853 widget_set_sensitive (asearch -> id_box, (object && filter > 2) ? 0 : 1);
3854 if (object && filter > 2)
3855 {
3856 combo_set_active (asearch -> atom_box, 0);
3857 }
3858 if (asearch -> action == DISPL) motion_to_zero (asearch);
3859 clean_todo (asearch);
3860 clean_picked_and_labelled (asearch, TRUE);
3861 set_spec_changed (GTK_COMBO_BOX(asearch -> atom_box), asearch);
3862}
3863
3872G_MODULE_EXPORT void set_object_changed (GtkComboBox * box, gpointer data)
3873{
3874 atom_search * asearch = (atom_search *) data;
3875 GtkTreeViewColumn * rot_c;
3876 int was_object;
3877 int object;
3878 int filter;
3879 if (get_project_by_id(asearch -> proj) -> natomes >= GTK_LIMIT)
3880 {
3881 was_object = ((! asearch -> mode && asearch -> object > 1) || (asearch -> mode && asearch -> object)) ? 1 : 0;
3882 asearch -> object = combo_get_active ((GtkWidget *)box);
3883 filter = get_asearch_filter (asearch);
3884 object = ((! asearch -> mode && asearch -> object > 1) || (asearch -> mode && asearch -> object)) ? 1 : 0;
3885 if ((! asearch -> mode && (asearch -> object == 1 || asearch -> object == 3)) || (asearch -> mode && asearch -> object))
3886 {
3887 if (! asearch -> mode) asearch -> passivating = TRUE;
3888 hide_the_widgets (asearch -> id_box);
3889 hide_the_widgets (asearch -> info[1]);
3890 }
3891 else
3892 {
3893 asearch -> passivating = FALSE;
3894 if (((! asearch -> mode && asearch -> object == 2) || (asearch -> mode && asearch -> object)) && filter > 2)
3895 {
3896 hide_the_widgets (asearch -> id_box);
3897 hide_the_widgets (asearch -> info[1]);
3898 }
3899 else
3900 {
3901 show_the_widgets (asearch -> id_box);
3902 show_the_widgets (asearch -> info[1]);
3903 }
3904 }
3905 }
3906 else
3907 {
3908 was_object = (asearch -> object) ? 1 : 0;
3909 asearch -> object = combo_get_active ((GtkWidget *)box);
3910 filter = get_asearch_filter (asearch);
3911 object = (asearch -> object) ? 1 : 0;
3912 hide_the_widgets (asearch -> id_box);
3913 hide_the_widgets (asearch -> info[1]);
3914 }
3915 if (was_object)
3916 {
3917 combo_text_prepend (asearch -> filter_box, _("Chemical Species"));
3918 if (asearch -> action == RANMOVE)
3919 {
3920 rot_c = gtk_tree_view_get_column (GTK_TREE_VIEW(asearch -> atom_tree), 4);
3921 gtk_tree_view_remove_column (GTK_TREE_VIEW(asearch -> atom_tree), rot_c);
3922 }
3923 }
3924 if (object)
3925 {
3926 gtk_combo_box_text_remove ((GtkComboBoxText *)asearch -> filter_box, 0);
3927 if (asearch -> action == RANMOVE)
3928 {
3929 GtkCellRenderer * rot = gtk_cell_renderer_toggle_new ();
3930 g_signal_connect (G_OBJECT(rot), "toggled", G_CALLBACK(select_atom), & asearch -> pointer[2]);
3931 int i = 5;
3932 rot_c = gtk_tree_view_column_new_with_attributes (_("Rotate"), rot, "active", i, NULL);
3933 gtk_tree_view_column_set_clickable (rot_c, TRUE);
3934 g_signal_connect (G_OBJECT(rot_c), "clicked", G_CALLBACK(select_all_atoms), & asearch -> pointer[2]);
3935 gtk_tree_view_column_set_alignment (rot_c, 0.5);
3936 gtk_tree_view_insert_column (GTK_TREE_VIEW(asearch -> atom_tree), rot_c, i-1);
3937 }
3938 }
3939
3940 if (asearch -> action == DISPL) widget_set_sensitive (get_project_by_id(asearch -> proj) -> modelgl -> atom_win -> at_expand[2], object);
3941 combo_set_active (asearch -> filter_box, 0);
3942 set_filter_changed (GTK_COMBO_BOX(asearch -> filter_box), asearch);
3943}
3944
3953{
3954 int i = 8 - asearch -> action;
3955 GtkCellRenderer * num = gtk_cell_renderer_text_new ();
3956 g_object_set (num, "editable", TRUE, NULL);
3957 g_signal_connect (G_OBJECT(num), "editing-started", G_CALLBACK(to_edit_coords), & asearch -> pointer[0]);
3958 GtkTreeViewColumn * num_c = gtk_tree_view_column_new_with_attributes (_("Number"), num, "text", i, NULL);
3959 gtk_tree_view_column_set_cell_data_func (num_c, num, search_set_visible, GINT_TO_POINTER(i), NULL);
3960 gtk_tree_view_append_column(GTK_TREE_VIEW(asearch -> atom_tree), num_c);
3961}
3962
3971G_MODULE_EXPORT void set_search_mode (GtkComboBox * box, gpointer data)
3972{
3973 atom_search * asearch = (atom_search *)data;
3974 project * this_proj = get_project_by_id(asearch -> proj);
3975 asearch -> mode = combo_get_active ((GtkWidget *)box);
3976 if ((asearch -> action == REPLACE || asearch -> action == REMOVE) && asearch -> atom_tree)
3977 {
3978 if (! asearch -> mode)
3979 {
3980 GtkTreeViewColumn * num_c;
3981 num_c = gtk_tree_view_get_column (GTK_TREE_VIEW(asearch -> atom_tree), 8 - asearch -> action);
3982 gtk_tree_view_remove_column (GTK_TREE_VIEW(asearch -> atom_tree), num_c);
3983 }
3984 else
3985 {
3986 add_random_column (asearch);
3987 }
3988 }
3989 if (this_proj -> natomes >= GTK_LIMIT)
3990 {
3991 if (asearch -> object_box)
3992 {
3993 if (asearch -> mode)
3994 {
3995 gtk_combo_box_text_remove ((GtkComboBoxText *)asearch -> object_box, 3);
3996 gtk_combo_box_text_remove ((GtkComboBoxText *)asearch -> object_box, 1);
3997 }
3998 else
3999 {
4000 gtk_combo_box_text_insert ((GtkComboBoxText *)asearch -> object_box, 1, NULL, _("Atom(s): All"));
4001 combo_text_append (asearch -> object_box, _("Group of Atoms: All"));
4002 }
4003 }
4004 }
4005 else
4006 {
4007 gtk_combo_box_text_remove_all ((GtkComboBoxText *)asearch -> object_box);
4008 combo_text_append (asearch -> object_box, _("Atom(s)"));
4009 combo_text_append (asearch -> object_box, _("Group of Atoms"));
4010 }
4011
4012 /*if (asearch -> filter_box)
4013 {
4014 if (! this_proj -> modelgl -> adv_bonding[1] && this_proj -> modelgl -> atom_win -> adv_bonding[1])
4015 {
4016 gtk_combo_box_text_remove ((GtkComboBoxText *)asearch -> filter_box, 3+i);
4017 }
4018 if (! this_proj -> modelgl -> adv_bonding[0] && this_proj -> modelgl -> atom_win -> adv_bonding[0])
4019 {
4020 gtk_combo_box_text_remove ((GtkComboBoxText *)asearch -> filter_box, 2+i);
4021 }
4022 combo_set_active (asearch -> filter_box, 0);
4023 set_filter_changed (GTK_COMBO_BOX(asearch -> filter_box), asearch);
4024 }*/
4025 combo_set_active (asearch -> object_box, 0);
4026 set_object_changed (GTK_COMBO_BOX(asearch -> object_box), asearch);
4027}
4028
4037G_MODULE_EXPORT void set_search_digit (GtkEntry * res, gpointer data)
4038{
4039 atom_search * asearch = (atom_search *) data;
4040 const gchar * m = entry_get_text (res);
4041 double v = string_to_double ((gpointer)m);
4042 asearch -> search_digit = (int)v;
4043 if (asearch -> search_digit <= 0)
4044 {
4045 asearch -> search_digit --;
4046 update_entry_text (res, "");
4047 }
4048 else
4049 {
4050 update_entry_int (res, asearch -> search_digit);
4051 }
4052 set_spec_changed (GTK_COMBO_BOX(asearch -> atom_box), data);
4053}
4054
4064void prep_search_box (GtkWidget * vbox, GtkWidget * lab, GtkWidget * combo)
4065{
4066 GtkWidget * hbox = create_hbox (0);
4067 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 2);
4068 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 30);
4069 GtkWidget * fixed = gtk_fixed_new ();
4070 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, fixed, FALSE, FALSE, 10);
4071 gtk_widget_set_size_request (combo, 175, -1);
4072 gtk_fixed_put (GTK_FIXED(fixed), combo, 0, 0);
4073}
4074
4082GtkWidget * prepare_box_too_much (atom_search * asearch)
4083{
4084 GtkWidget * box;
4085 GtkWidget * widg;
4086 GtkWidget * too_box = create_vbox (BSEP);
4087 widg = bbox (too_box, _("\t Atom species: "));
4088 gtk_widget_set_size_request (widg, 200, -1);
4089 asearch -> entry_a = create_entry (G_CALLBACK(set_atom), 90, 15, TRUE, asearch);
4090 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, widg, asearch -> entry_a, FALSE, FALSE, 0);
4091 asearch -> img_a = stock_image (DIAL_ERROR);
4092 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, widg, asearch -> img_a, FALSE, FALSE, 5);
4093 widg = bbox (too_box, _("\t Atom Id: "));
4094 gtk_widget_set_size_request (widg, 200, -1);
4095 asearch -> entry_b = create_entry (G_CALLBACK(set_id), 90, 15, TRUE, asearch);
4096 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, widg, asearch -> entry_b, FALSE, FALSE, 0);
4097 asearch -> img_b = stock_image (DIAL_ERROR);
4098 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, widg, asearch -> img_b, FALSE, FALSE, 5);
4099 box = create_hbox (0);
4100 add_box_child_start (GTK_ORIENTATION_VERTICAL, too_box, box, FALSE, FALSE, 5);
4101 asearch -> but_a = create_button (_("Add"), IMG_NONE, NULL, 75, -1, GTK_RELIEF_NORMAL, G_CALLBACK(add_atom), asearch);
4102 widget_set_sensitive (asearch -> but_a, 0);
4103 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, box, asearch -> but_a, FALSE, FALSE, 75);
4104 asearch -> but_b = create_button (_("Remove"), IMG_NONE, NULL, 75, -1, GTK_RELIEF_NORMAL, G_CALLBACK(remove_atom), asearch);
4105 widget_set_sensitive (asearch -> but_b, 0);
4106 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, box, asearch -> but_b, FALSE, FALSE, 0);
4107 return too_box;
4108}
4109
4118GtkWidget * selection_tab (atom_search * asearch, int nats)
4119{
4120 project * this_proj = get_project_by_id (asearch -> proj);
4121 int i, j;
4122 i = (nats < GTK_LIMIT) ? 1 : 0;
4123 j = (asearch -> action == 5) ? 300 : -1;
4124 GtkWidget * selection = create_layout (j, 390 + (! i)*60 - i*100);
4125 GtkWidget * vbox = add_vbox_to_layout (selection, 0, (asearch -> action > 1) ? 0 : 10);
4126 GtkWidget * hbox, * vvbox;
4127 GtkWidget * lab;
4128 if (asearch -> action != 5)
4129 {
4130 // Later on simply hide info[1] (to much atoms info) if needed
4131 for (j=0; j<2; j++)
4132 {
4133 asearch -> info[j] = create_vbox (BSEP);
4134 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, asearch -> info[j], FALSE, FALSE, 0);
4135 }
4136 hbox = create_hbox (0);
4137 add_box_child_start (GTK_ORIENTATION_VERTICAL, asearch -> info[0], hbox, FALSE, FALSE, 2);
4138 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label("<b>.</b>", 5, -1, 0.0, 0.5), FALSE, FALSE, 10);
4139 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label(_("Search "), 50, -1, 0.0, 0.5), FALSE, FALSE, 0);
4140 asearch -> object_box = create_combo ();
4141 combo_text_append (asearch -> object_box, _("Atom(s)"));
4142 if (! i) combo_text_append (asearch -> object_box, _("Atom(s): All"));
4143 combo_text_append (asearch -> object_box, _("Group of Atoms"));
4144 if (! i) combo_text_append (asearch -> object_box, _("Group of Atoms: All"));
4145 combo_set_active (asearch -> object_box, asearch -> object);
4146 asearch -> filter_box = create_combo ();
4147 gchar * filters[5]={i18n("Chemical Species"), i18n("Total Coordination"), i18n("Partial Coordination"), i18n("Fragment"), i18n("Molecule")};
4148 for (j=0; j<3; j++) combo_text_append (asearch -> filter_box, _(filters[j]));
4149 if (this_proj -> modelgl -> adv_bonding[0]) combo_text_append (asearch -> filter_box, _(filters[3]));
4150 if (this_proj -> modelgl -> adv_bonding[1]) combo_text_append (asearch -> filter_box, _(filters[4]));
4151 combo_set_active (asearch -> filter_box, asearch -> filter);
4152
4153 asearch -> atom_box = create_combo ();
4154 combo_text_append (asearch -> atom_box, _("All"));
4155 for (j=0; j<this_proj -> nspec; j++) combo_text_append (asearch -> atom_box, this_proj -> chemistry -> label[j]);
4156 combo_set_active (asearch -> atom_box, asearch -> spec);
4157
4158 g_signal_connect (G_OBJECT (asearch -> object_box), "changed", G_CALLBACK(set_object_changed), asearch);
4159 g_signal_connect (G_OBJECT (asearch -> filter_box), "changed", G_CALLBACK(set_filter_changed), asearch);
4160 g_signal_connect (G_OBJECT (asearch -> atom_box), "changed", G_CALLBACK(set_spec_changed), asearch);
4161 GtkWidget * entry = create_entry (G_CALLBACK(set_search_digit), 90, 15, TRUE, asearch);
4162 if (asearch -> action < 2)
4163 {
4164 prep_search_box (asearch -> info[0], markup_label(_("For "), 100, -1, 0.0, 0.5), asearch -> object_box);
4165 prep_search_box (asearch -> info[0], markup_label(_("Filter by "), 100, -1, 0.0, 0.5), asearch -> filter_box);
4166 prep_search_box (asearch -> info[0], markup_label(_("Species "), 100, -1, 0.0, 0.5), asearch -> atom_box);
4167 asearch -> id_box = create_hbox (0);
4168 add_box_child_start (GTK_ORIENTATION_VERTICAL, asearch -> info[0], asearch -> id_box, FALSE, FALSE, 0);
4169 prep_search_box (asearch -> id_box, markup_label(_("Atom Id."), 100, -1, 0.0, 0.5), entry);
4170 }
4171 else
4172 {
4173 hbox = create_hbox (0);
4174 add_box_child_start (GTK_ORIENTATION_VERTICAL, asearch -> info[0], hbox, FALSE, FALSE, 5);
4175 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label(_("For "), -1, -1, 0.0, 0.5), FALSE, FALSE, 10);
4176 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, asearch -> object_box, FALSE, FALSE, 0);
4177 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label(_("Filter by "), -1, -1, 0.0, 0.5), FALSE, FALSE, 10);
4178 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, asearch -> filter_box, FALSE, FALSE, 0);
4179 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label(_("Species "), -1, -1, 0.0, 0.5), FALSE, FALSE, 10);
4180 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, asearch -> atom_box, FALSE, FALSE, 0);
4181 asearch -> id_box = create_hbox (0);
4182 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, asearch -> id_box, FALSE, FALSE, 0);
4183 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, asearch -> id_box, markup_label(_("Atom Id "), -1, -1, 0.0, 0.5), FALSE, FALSE, 10);
4184 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, asearch -> id_box, entry, FALSE, FALSE, 0);
4185 }
4186
4187 // If more than 10 000 atoms:
4188 if (asearch -> action < 2)
4189 {
4190 lab = markup_label(_("\t<b>The number of atoms in the model is too large</b>\n"
4191 "\t\t<b>to display and browse the entire list !</b>\n"
4192 "\t<b>You need to search for object(s) individually:</b>"), -1, -1, 0.5, 0.5);
4193 }
4194 else
4195 {
4196 lab = markup_label(_("<b>The number of atoms in the model is too large to display and browse the entire list !</b>\n"
4197 "\t\t\t\t<b>You need to search for object(s) individually:</b>"), -1, -1, 0.5, 0.5);
4198 }
4199 add_box_child_start (GTK_ORIENTATION_VERTICAL, asearch -> info[1], lab, FALSE, FALSE, 10);
4200 hbox = create_hbox (0);
4201 add_box_child_start (GTK_ORIENTATION_VERTICAL, asearch -> info[1], hbox, FALSE, FALSE, 0);
4202 /* vvbox = create_vbox (0);
4203 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, vvbox, FALSE, FALSE, 80);
4204 cbox = create_combo ();
4205 combo_text_append (cbox, _("All objects"));
4206 combo_text_append (cbox, _("Selection"));
4207 g_signal_connect (G_OBJECT(cbox), "changed", G_CALLBACK(set_too_much_type), asearch);
4208 combo_set_active (cbox, asearch -> too_much);
4209 add_box_child_start (GTK_ORIENTATION_VERTICAL, vvbox, cbox, FALSE, FALSE, 30);
4210 // asearch -> big_box = // Combo box with _("All objects"), _("Selection") */
4211 vvbox = create_vbox (0);
4212 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, vvbox, FALSE, FALSE, 120);
4213 add_box_child_start (GTK_ORIENTATION_VERTICAL, vvbox, prepare_box_too_much (asearch), FALSE, FALSE, 0);
4214 add_box_child_start (GTK_ORIENTATION_VERTICAL, asearch -> info[1],
4215 markup_label(_("The search must be performed using species and/or Id.\n"
4216 "Use the filters above to define the object(s) of the search"), -1, -1, 0.5, 0.5), FALSE, FALSE, 5);
4217 }
4218
4219 abox (vbox, _("Selection "), 2);
4220 hbox = create_hbox (0);
4221 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 5);
4222 GtkWidget * scrollsets = create_scroll (NULL, -1, -1, GTK_SHADOW_ETCHED_IN);
4223 i = (asearch -> action < 2) ? 0 : 1;
4224 j = (asearch -> action < 2) ? 1 : 0;
4225 if (asearch -> action < 2)
4226 {
4227 gtk_widget_set_size_request (scrollsets, 400+i*100, 270);
4228 }
4229 else
4230 {
4231 gtk_widget_set_size_request (scrollsets, 400+i*100, 290-i*120);
4232 }
4233 gtk_widget_set_hexpand (scrollsets, TRUE);
4234 add_container_child (CONTAINER_SCR, scrollsets, create_atoms_tree (asearch, this_proj, nats));
4235 check_all_trees (this_proj);
4236 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, scrollsets, FALSE, FALSE, 100-j*75);
4237 return selection;
4238}
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:181
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:1196
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
G_MODULE_EXPORT void set_object_changed(GtkComboBox *box, gpointer data)
change the search object
Definition w_search.c:3872
atomic_object * get_atomic_object_by_origin(atomic_object *first, int oid, int aid)
get insert object from a list by id
Definition w_search.c:474
void check_motion_interactors(project *this_proj, atom_search *asearch)
add motion check button
Definition atom_move.c:1155
insertion_menu mol[]
Definition w_library.c:193
G_MODULE_EXPORT void set_spec_changed(GtkComboBox *box, gpointer data)
change the search chemical species
Definition w_search.c:3817
G_MODULE_EXPORT void set_filter_changed(GtkComboBox *box, gpointer data)
change the search filter
Definition w_search.c:3846
int selected_aspec
Definition popup.c:179
GtkFileFilter * filter[NCFORMATS+1]
Definition callbacks.c:1557
GtkWidget * builder_win(project *this_proj, gpointer data)
create crystal builder window
GtkWidget * create_atoms_tree(atom_search *asearch, project *this_proj, int na)
create atom search tree view
Definition w_search.c:3572
G_MODULE_EXPORT void cut_this_slab(GtkButton *but, gpointer data)
cut this slab callback
Definition cell_cut.c:488
integer(kind=c_int) function chemistry()
Definition chemistry.F90:22
color colorp[64]
double ax
Definition curve.c:71
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
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:3252
gchar * ctitle[MAXDATA][12]
Definition dlp_field.c:924
int * duplicate_int(int num, int *old_val)
copy a list of int
Definition global.c:547
gboolean * allocbool(int val)
allocate a gboolean * pointer
Definition global.c:241
int nprojects
Definition global.c:161
gboolean selected_status
Definition global.c:191
gboolean column_label
Definition global.c:188
gboolean check_label
Definition global.c:189
int * allocint(int val)
allocate an int * pointer
Definition global.c:301
gboolean object_motion
Definition global.c:190
#define i18n(String)
Definition global.c:80
float * allocfloat(int val)
allocate a float * pointer
Definition global.c:385
double string_to_double(gpointer string)
convert string to double
Definition global.c:611
void run_this_gtk_dialog(GtkWidget *dial, GCallback handler, gpointer data)
run a GTK (3 and 4) basic GtkDialog
Definition gtk-misc.c:533
@ IMG_NONE
Definition global.h:276
int combo_get_active(GtkWidget *combo)
retrieve the active item's position
Definition gtk-misc.c:935
#define GTK_LIMIT
maximum number of elements in GTK widgets like GtkTreeView, GtkTreeStore or similar rendering widgets...
Definition global.h:77
GtkWidget * create_entry(GCallback handler, int dim, int cdim, gboolean key_release, gpointer data)
Create a GtkEntry.
Definition gtk-misc.c:1401
void update_entry_double(GtkEntry *entry, double doubleval)
update the content of a GtkEntry as double
Definition gtk-misc.c:688
G_MODULE_EXPORT void show_hide_labels(GtkWidget *widg, gpointer data)
#define DIAL_ERROR
Definition global.h:239
GtkWidget * create_scroll(GtkWidget *box, int dimx, int dimy, int shadow)
create a scroll window
Definition gtk-misc.c:2139
void combo_set_markup(GtkWidget *combo)
use pango markup in combo widget
Definition gtk-misc.c:970
project * proj
void combo_set_active(GtkWidget *combo, int pos)
set the active item's position
Definition gtk-misc.c:958
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:900
const gchar * entry_get_text(GtkEntry *entry)
get the text in a GtkEntry
Definition gtk-misc.c:652
#define BSEP
Definition global.h:261
void opengl_project_changed(int id)
change the OpenGL project
Definition update_p.c:296
void update_entry_int(GtkEntry *entry, int intval)
update the content of a GtkEntry as int
Definition gtk-misc.c:669
G_MODULE_EXPORT void select_unselect_this_atom(GtkWidget *widg, gpointer data)
select / unselect this atom callback GTK3
Definition popup.c:1196
GtkWidget * stock_image(const gchar *stock_id)
create a GtkImage for the Gtk database
Definition gtk-misc.c:1451
void set_renderer_markup(GtkTreeModel *mod, GtkTreeIter *iter, GtkCellRenderer *renderer, int col)
set Pango text markup for a GtkCellRenderer
Definition gtk-misc.c:1764
#define APPLY
Definition global.h:236
@ CONTAINER_SCR
Definition global.h:267
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:1999
G_MODULE_EXPORT void label_unlabel_atoms(GtkWidget *widg, gpointer data)
label / unlabel a type of atom(s) callback GTK3
Definition popup.c:1522
GtkWidget * create_combo()
create a GtkCombox widget, note deprecated in GTK4
Definition gtk-misc.c:1010
GtkWidget * dialog_get_content_area(GtkWidget *widg)
prepare GtkWidget to insert content in a GtkDialog window
Definition gtk-misc.c:861
GtkWidget * markup_label(gchar *text, int dimx, int dimy, float ax, float ay)
create a GtkLabel with pango markup
Definition gtk-misc.c:1672
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:340
void widget_set_sensitive(GtkWidget *widg, gboolean sensitive)
Set sensitivity for a GtkWidget, ensuring it is a GtkWidget.
Definition gtk-misc.c:247
GtkWidget * create_hbox(int spacing)
create a GtkBox with horizontal orientation
Definition gtk-misc.c:849
G_MODULE_EXPORT void select_unselect_atoms(GtkWidget *widg, gpointer data)
select / unselect a type of atom(s) callback GTK3
Definition popup.c:1570
void combo_text_append(GtkWidget *combo, gchar *text)
append text in GtkComboBox widget
Definition gtk-misc.c:987
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:2272
GtkWidget * create_layout(int x, int y)
create a GtkLayout / GtkFixed widget
Definition gtk-misc.c:916
GtkWidget * destroy_this_widget(GtkWidget *widg)
destroy a GtkWidget
Definition gtk-misc.c:2213
GtkWidget * bbox(GtkWidget *box, char *lab)
box creating routine, to help design faster elements for the GUI
Definition gtk-misc.c:2084
void update_entry_text(GtkEntry *entry, gchar *text)
update the content of a GtkEntry as string
Definition gtk-misc.c:726
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:267
void set_image_from_icon_name(GtkWidget *widg, gchar *icon)
set a image from a stock icon name
Definition gtk-misc.c:2030
void combo_text_prepend(GtkWidget *combo, gchar *text)
prepend text in GtkComboBox widget
Definition gtk-misc.c:1000
void hide_the_widgets(GtkWidget *widg)
hide GtkWidget
Definition gtk-misc.c:224
GtkWidget * create_vbox(int spacing)
create a GtkBox with vertical orientation
Definition gtk-misc.c:837
GtkWidget * abox(GtkWidget *box, char *lab, int vspace)
box creating routine, to help design faster elements for the GUI
Definition gtk-misc.c:2067
G_MODULE_EXPORT void label_unlabel_this_atom(GtkWidget *widg, gpointer data)
label / unlabel this atom callback GTK3
Definition popup.c:1147
atomic_object * copied_object
Definition glwindow.c:124
void show_the_widgets(GtkWidget *widg)
show GtkWidget
Definition gtk-misc.c:202
project * get_project_by_id(int p)
get project pointer using id number
Definition project.c:120
void update(glwin *view)
update the rendering of the OpenGL window
Definition glview.c:461
action
Definition glview.h:198
gboolean pick
int step
Definition ogl_draw.c:76
void update_all_selections(glwin *view, int pi)
update the selection data: bonds, angles and dihedrals
Definition selection.c:387
void save_all_selections(glwin *view, int pi)
save all selection data
Definition selection.c:372
@ DISPL
Definition glview.h:234
@ RANMOVE
Definition glview.h:238
@ REPLACE
Definition glview.h:235
@ REMOVE
Definition glview.h:236
@ INSERT
Definition glview.h:237
@ 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)
output the name of a coordination sphere
Definition interface.c:1022
gchar * exact_name(gchar *name)
short cut to print string without spaces
Definition interface.c:434
integer(kind=c_int) function msd(dlt, ndts)
Definition msd.F90:22
Definition glwin.h:332
Definition glwin.h:350
Definition glwin.h:967
Definition global.h:118
int status
Definition w_advance.c:173
GtkTreeStore * atom_model
GtkWidget * res[2]
Definition w_encode.c:342
int max_random
Definition w_search.c:2845
GtkTreeModel * replace_combo_tree(gboolean insert, int proj)
replace combo box in the tree view
Definition w_search.c:2612
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:1474
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:2228
G_MODULE_EXPORT void select_all_atoms(GtkTreeViewColumn *col, gpointer data)
select all element(s) in the tree view column
Definition w_search.c:3334
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:1311
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:3236
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:3572
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:1499
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:3252
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:4118
G_MODULE_EXPORT void set_occupancy(GtkEntry *res, gpointer data)
set occupancy entry callback
Definition w_search.c:2729
G_MODULE_EXPORT void set_max_msd(GtkEntry *res, gpointer data)
set MSD max entry callback
Definition w_search.c:2769
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:2315
int check_label_numbers(project *this_proj, int types)
check how many atom label(s) are visible
Definition popup.c:1059
int get_todo_size(atom_search *asearch)
get the size of the atom search selection list
Definition w_search.c:3669
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:2749
int atom_to_edit
Definition w_search.c:2718
G_MODULE_EXPORT void set_atom(GtkEntry *entry, gpointer data)
adjust atom search parameters if >= 10 000 atoms
Definition w_search.c:1338
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:3265
void update_search_tree(atom_search *asearch)
update search tree
Definition w_search.c:1287
void create_slab_lists(project *this_proj)
prepare slab(s) OpenGL rendering
Definition d_box.c:906
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:2719
G_MODULE_EXPORT void set_filter_changed(GtkComboBox *box, gpointer data)
change the search filter
Definition w_search.c:3846
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:2378
void re_populate_tree_search(atom_search *asearch)
re populate search tree after atom action if >= 10 000 atoms
Definition w_search.c:1601
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:1456
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:3952
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:2876
int get_to_be_selected(glwin *view)
find which atom(s) are to be selected
Definition popup.c:196
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:2704
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:1738
void clean_picked_and_labelled(atom_search *asearch, gboolean clean_msd)
initialize atom search data buffers
Definition w_search.c:3779
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:2855
GtkWidget * prepare_box_too_much(atom_search *asearch)
if too many atoms, then individual search
Definition w_search.c:4082
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:3299
void clear_fields(atom_search *asearch)
clear all search fields if >= 10 000 atoms
Definition w_search.c:1378
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:1824
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:4037
gboolean remove_from_model(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
remove from the tree model
Definition w_search.c:1404
void allocate_todo(atom_search *asearch, int tsize)
allocate the selection list data buffer
Definition w_search.c:3705
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
void prep_search_box(GtkWidget *vbox, GtkWidget *lab, GtkWidget *combo)
prepare some search widgets
Definition w_search.c:4064
G_MODULE_EXPORT void set_object_changed(GtkComboBox *box, gpointer data)
change the search object
Definition w_search.c:3872
void clean_todo(atom_search *asearch)
clean atom search selection list
Definition w_search.c:3718
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:2513
G_MODULE_EXPORT void set_id(GtkEntry *entry, gpointer data)
set search id if >= 10 000 atoms
Definition w_search.c:1690
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:2449
G_MODULE_EXPORT void set_search_mode(GtkComboBox *box, gpointer data)
change search mode
Definition w_search.c:3971
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:3512
int select_from_library(gboolean visible, project *this_proj, atom_search *asearch)
select object to insert from the library
Definition w_library.c:1124
G_MODULE_EXPORT void set_spec_changed(GtkComboBox *box, gpointer data)
change the search chemical species
Definition w_search.c:3817
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