atomes 1.1.15
atomes: an atomic scale modeling tool box
Loading...
Searching...
No Matches
w_rings.c
Go to the documentation of this file.
1/* This file is part of the 'atomes' software
2
3'atomes' is free software: you can redistribute it and/or modify it under the terms
4of the GNU Affero General Public License as published by the Free Software Foundation,
5either version 3 of the License, or (at your option) any later version.
6
7'atomes' is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
8without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9See the GNU General Public License for more details.
10
11You should have received a copy of the GNU Affero General Public License along with 'atomes'.
12If not, see <https://www.gnu.org/licenses/>
13
14Copyright (C) 2022-2024 by CNRS and University of Strasbourg */
15
22/*
23* This file: 'w_rings.c'
24*
25* Contains:
26*
27
28 - The functions to create the ring(s) tab for the advanced environments window
29
30*
31* List of functions:
32
33 int get_rmin (project * this_proj, int rid, int step);
34 int get_rmax (project * this_proj, int rid, int step);
35
36 void rings_set_visible (GtkTreeViewColumn * col, GtkCellRenderer * renderer, GtkTreeModel * mod, GtkTreeIter * iter, gpointer data);
37 void fill_rings_model (GtkTreeStore * store, project * this_proj, int rid);
38 void add_this_ring_to_search_tree (project * this_proj, int rid);
39
40 G_MODULE_EXPORT void on_select_rings (GtkCellRendererToggle * cell_renderer, gchar * string_path, gpointer data);
41 G_MODULE_EXPORT void update_rings_search (GtkEntry * res, gpointer data);
42
43 GtkWidget * create_rings_tree (project * this_proj, int rid, gboolean fill_this);
44 GtkWidget * create_rings_search (project * this_proj, int rid);
45 GtkWidget * rings_tab (glwin * view, int rid);
46
47*/
48
49#include "global.h"
50#include "interface.h"
51#include "glview.h"
52#include "glwindow.h"
53
63G_MODULE_EXPORT void on_select_rings (GtkCellRendererToggle * cell_renderer, gchar * string_path, gpointer data)
64{
65 tint * dat = (tint * )data;
66 gboolean saved_label[2];
67 int i, j, g, c, s, v, u, a, b;
69 coord_edition * coord = opengl_project -> modelgl -> coord_win;
70 b = (opengl_project -> steps > 1) ? 1: 0;
71 for (i=0; i<5; i++)
72 {
73 if (i*10 > dat -> b) break;
74 }
75 g = i - 1;
76 for (i=2+b; i<5+b; i++)
77 {
78 if (10*g+i == dat -> b) break;
79 }
80 c = i;
81 if (gtk_cell_renderer_toggle_get_active(cell_renderer))
82 {
83 v = 0;
84 }
85 else
86 {
87 v = 1;
88 }
89 GtkTreeIter iter;
90 GtkTreePath * path = gtk_tree_path_new_from_string (string_path);
91 gtk_tree_model_get_iter (GTK_TREE_MODEL(coord -> rings_model[g]), & iter, path);
92 gtk_tree_store_set (coord -> rings_model[g], & iter, c, v, -1);
93 if (b)
94 {
95 gtk_tree_model_get (GTK_TREE_MODEL(coord -> rings_model[g]), & iter, 0, & s, -1);
96 s = - s - 1;
97 }
98 else
99 {
100 s = 0;
101 }
102 gtk_tree_model_get (GTK_TREE_MODEL(coord -> rings_model[g]), & iter, b, & i, -1);
103 i = -i;
104 gtk_tree_model_get (GTK_TREE_MODEL(coord -> rings_model[g]), & iter, b+1, & j, -1);
105 switch (c-b)
106 {
107 case 2:
108 // Viz
109 for (u=0; u<i; u++)
110 {
111 a = opengl_project -> modelgl -> all_rings[g][s][i-1][j-1][u];
112#ifdef GTK4
113 if (opengl_project -> atoms[s][a].show[0] != v) show_hide_this_atom (NULL, NULL, GINT_TO_POINTER(a));
114#else
115 if (opengl_project -> atoms[s][a].show[0] != v) show_hide_this_atom (NULL, GINT_TO_POINTER(a));
116#endif // GTK4
117 }
118 break;
119 case 3:
120 // Show poly
121 opengl_project -> modelgl -> show_rpoly[g][s][i-1][j-1] = v;
122 int shaders[1] = {RINGS};
124 break;
125 case 4:
126 // Label
127 for (u=0; u<i; u++)
128 {
129 a = opengl_project -> modelgl -> all_rings[g][s][i-1][j-1][u];
130 opengl_project -> atoms[s][a].label[0] = opengl_project -> atoms[s][a].label[1] = v;
131 }
132 opengl_project -> modelgl -> create_shaders[LABEL] = TRUE;
133 break;
134 case 5:
135 // Pick
136 for (u=0; u<i; u++)
137 {
138 a = opengl_project -> modelgl -> all_rings[g][s][i-1][j-1][u];
139 saved_label[0] = opengl_project -> atoms[s][a].label[0];
140 saved_label[1] = opengl_project -> atoms[s][a].label[1];
141#ifdef GTK4
142 if (opengl_project -> atoms[s][a].pick[0] != v) select_unselect_this_atom (NULL, NULL, GINT_TO_POINTER(a));
143#else
144 if (opengl_project -> atoms[s][a].pick[0] != v) select_unselect_this_atom (NULL, GINT_TO_POINTER(a));
145#endif // GTK4
146 opengl_project -> atoms[s][a].label[0] = saved_label[0];
147 opengl_project -> atoms[s][a].label[1] = saved_label[1];
148 }
149 break;
150 }
151 update (opengl_project -> modelgl);
152}
153
165void rings_set_visible (GtkTreeViewColumn * col, GtkCellRenderer * renderer, GtkTreeModel * mod, GtkTreeIter * iter, gpointer data)
166{
167 tint * id = (tint *)data;
168 int i, j, k;
169 project * this_proj = get_project_by_id(id -> a);
170 i = id -> b;
171 j = (this_proj -> steps > 1) ? 1: 0;
172 gtk_tree_model_get (mod, iter, j, & k, -1);
173 if (j)
174 {
175 gtk_tree_model_get (mod, iter, 0, & k, -1);
176 if (i == 0)
177 {
178 if (k > 0)
179 {
180 gtk_cell_renderer_set_visible (renderer, 1);
181 }
182 else
183 {
184 gtk_cell_renderer_set_visible (renderer, 0);
185 }
186 }
187 else if (k > 0)
188 {
189 gtk_cell_renderer_set_visible (renderer, 0);
190 }
191 else
192 {
193 gtk_tree_model_get (mod, iter, j, & k, -1);
194 if (i == 1)
195 {
196 if (k > 0)
197 {
198 gtk_cell_renderer_set_visible (renderer, 1);
199 }
200 else
201 {
202 gtk_cell_renderer_set_visible (renderer, 0);
203 }
204 }
205 else
206 {
207 if (k > 0)
208 {
209 gtk_cell_renderer_set_visible (renderer, 0);
210 }
211 else
212 {
213 gtk_cell_renderer_set_visible (renderer, 1);
214 }
215 }
216 }
217 }
218 else
219 {
220 if (i == 0)
221 {
222 if (k > 0)
223 {
224 gtk_cell_renderer_set_visible (renderer, 1);
225 }
226 else
227 {
228 gtk_cell_renderer_set_visible (renderer, 0);
229 }
230 }
231 else
232 {
233 if (k > 0)
234 {
235 gtk_cell_renderer_set_visible (renderer, 0);
236 }
237 else
238 {
239 gtk_cell_renderer_set_visible (renderer, 1);
240 }
241 }
242 }
243}
244
254void fill_rings_model (GtkTreeStore * store, project * this_proj, int rid)
255{
256 GtkTreeIter step_level, size_level, ring_level;
257 int h, i, j, k, l;
258 if (this_proj -> coord -> totcoord[rid+4])
259 {
260 for (h=0; h < this_proj -> steps; h++)
261 {
262 if (this_proj -> steps > 1)
263 {
264 gtk_tree_store_append (store, & step_level, NULL);
265 gtk_tree_store_set (store, & step_level, 0, h+1,
266 1, 0,
267 2, 0,
268 3, 0,
269 4, 0,
270 5, 0,
271 6, 0, -1);
272 }
273 for (i=0; i < this_proj -> coord -> totcoord[rid+4]; i++)
274 {
275 j = this_proj -> coord -> geolist[rid+4][0][i];
276 k = this_proj -> modelgl -> num_rings[rid][h][j-1];
277 if (this_proj -> steps > 1 && k > 0)
278 {
279 gtk_tree_store_append (store, & size_level, & step_level);
280 gtk_tree_store_set (store, & size_level, 0, 0,
281 1, j,
282 2, 0,
283 3, 0,
284 4, 0,
285 5, 0,
286 6, 0, -1);
287 }
288 else if (this_proj -> steps == 1)
289 {
290 gtk_tree_store_append (store, & size_level, NULL);
291 gtk_tree_store_set (store, & size_level, 0, j,
292 1, 0,
293 2, 0,
294 3, 0,
295 4, 0,
296 5, 0, -1);
297 }
298 for (l=0; l<k; l++)
299 {
300 gtk_tree_store_append (store, & ring_level, & size_level);
301 if (this_proj -> steps > 1)
302 {
303 gtk_tree_store_set (store, & ring_level, 0, -(h+1),
304 1, -j,
305 2, l+1,
306 3, FALSE,
307 4, this_proj -> modelgl -> show_rpoly[rid][h][j-1][l],
308 5, FALSE,
309 6, FALSE, -1);
310 }
311 else
312 {
313 gtk_tree_store_set (store, & ring_level, 0, -j,
314 1, l+1,
315 2, FALSE,
316 3, this_proj -> modelgl -> show_rpoly[rid][h][j-1][l],
317 4, FALSE,
318 5, FALSE, -1);
319 }
320 }
321 }
322 }
323 }
324}
325
335GtkWidget * create_rings_tree (project * this_proj, int rid, gboolean fill_this)
336{
337 int i, j, k;
338 GtkTreeViewColumn * rings_col[7];
339 GtkCellRenderer * rings_cell[7];
340 gchar * ctitle[7]={"MD. step", "Ring(s) size", "Id.", "Show", "Poly.", "Label", "Pick"};
341 gchar * ctype[7]={"text", "text", "text", "active", "active", "active", "active"};
342 GType col_type[7]={G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN};
343 coord_edition * coord = this_proj -> modelgl -> coord_win;
344 j = (this_proj -> steps > 1) ? 1: 0;
345 k = (this_proj -> steps > 1) ? 0: 1;
346 coord -> rings_model[rid] = gtk_tree_store_newv (6+j, col_type);
347 if (fill_this) fill_rings_model (coord -> rings_model[rid], this_proj, rid);
348 GtkWidget * rings_tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL(coord -> rings_model[rid]));
349 for (i=0; i<6+j; i++)
350 {
351 if (i < 2+j)
352 {
353 rings_cell[i] = gtk_cell_renderer_text_new ();
354 }
355 else
356 {
357 rings_cell[i] = gtk_cell_renderer_toggle_new ();
358 g_signal_connect (G_OBJECT(rings_cell[i]), "toggled", G_CALLBACK(on_select_rings), & this_proj -> modelgl -> colorp[rid*10+i][0]);
359 }
360 gtk_cell_renderer_set_fixed_size (rings_cell[i], -1, 25);
361 rings_col[i] = gtk_tree_view_column_new_with_attributes (ctitle[i+k], rings_cell[i], ctype[i+k], i, NULL);
362 gtk_tree_view_append_column(GTK_TREE_VIEW(rings_tree), rings_col[i]);
363 gtk_tree_view_column_set_alignment (rings_col[i], 0.5);
364 gtk_tree_view_column_set_cell_data_func (rings_col[i], rings_cell[i], rings_set_visible, & this_proj -> modelgl -> colorp[i][0], NULL);
365 }
366 return rings_tree;
367}
368
377void add_this_ring_to_search_tree (project * this_proj, int rid)
378{
379 GtkTreeIter step_level, size_level, ring_level;
380 GtkTreeIter new_level;
381 coord_edition * coord = this_proj -> modelgl -> coord_win;
382 GtkTreeStore * store = (GtkTreeStore *) coord -> rings_model[rid];
383 GtkTreeModel * mod = GTK_TREE_MODEL(coord -> rings_model[rid]);
384 gboolean valid;
385 gboolean insert = TRUE;
386 int f, h, i, j, k, l, m;
387 int prepend = 0;
388 if (this_proj -> steps > 1)
389 {
390 valid = gtk_tree_model_get_iter_first(mod, & step_level);
391 while (valid)
392 {
393 gtk_tree_model_get (mod, & step_level, 0, & f, -1);
394 if (f > coord -> rst[rid])
395 {
396 prepend = 1;
397 valid = FALSE;
398 }
399 else if (f == coord -> rst[rid])
400 {
401 if (gtk_tree_model_iter_has_child (mod, &step_level))
402 {
403 h = gtk_tree_model_iter_n_children (mod, &step_level);
404 for (i=0; i<h; i++)
405 {
406 if (gtk_tree_model_iter_nth_child (mod, &size_level, &step_level, i))
407 {
408 gtk_tree_model_get (mod, &size_level, 1, & j, -1);
409 if (j > coord -> rsz[rid])
410 {
411 prepend = 3;
412 valid = FALSE;
413 break;
414 }
415 else if (j == coord -> rsz[rid])
416 {
417 if (gtk_tree_model_iter_has_child (mod, &size_level))
418 {
419 k = gtk_tree_model_iter_n_children (mod, &size_level);
420 for (l=0; l<k; l++)
421 {
422 if (gtk_tree_model_iter_nth_child (mod, &ring_level, &size_level, l))
423 {
424 gtk_tree_model_get (mod, &ring_level, 2, & m, -1);
425 if (m > coord -> ri[rid])
426 {
427 prepend = 5;
428 valid = FALSE;
429 break;
430 }
431 else if (m == coord -> ri[rid])
432 {
433 insert = valid = FALSE;
434 break;
435 }
436 }
437 }
438 if (valid)
439 {
440 prepend = 4;
441 valid = FALSE;
442 break;
443 }
444 }
445 }
446 }
447 }
448 if (valid)
449 {
450 prepend = 2;
451 valid = FALSE;
452 }
453 }
454 }
455 else
456 {
457 valid = gtk_tree_model_iter_next(mod, & step_level);
458 }
459 }
460 if (insert)
461 {
462 switch (prepend)
463 {
464 case 0:
465 gtk_tree_store_append (store, & step_level, NULL);
466 gtk_tree_store_set (store, & step_level, 0, coord -> rst[rid],
467 1, 0,
468 2, 0,
469 3, 0,
470 4, 0,
471 5, 0,
472 6, 0, -1);
473 gtk_tree_store_append (store, & size_level, & step_level);
474 gtk_tree_store_set (store, & size_level, 0, 0,
475 1, coord -> rsz[rid],
476 2, 0,
477 3, 0,
478 4, 0,
479 5, 0,
480 6, 0, -1);
481 gtk_tree_store_append (store, & ring_level, & size_level);
482 gtk_tree_store_set (store, & ring_level, 0, -coord -> rst[rid],
483 1, -coord -> rsz[rid],
484 2, coord -> ri[rid],
485 3, FALSE,
486 4, this_proj -> modelgl -> show_rpoly[rid][coord -> rst[rid]-1][coord -> rsz[rid]-1][coord -> ri[rid]-1],
487 5, FALSE,
488 6, FALSE, -1);
489 break;
490 case 1:
491 gtk_tree_store_insert_before (store, & new_level, NULL, & step_level);
492 gtk_tree_store_set (store, & new_level, 0, coord -> rst[rid],
493 1, 0,
494 2, 0,
495 3, 0,
496 4, 0,
497 5, 0,
498 6, 0, -1);
499 gtk_tree_store_append (store, & size_level, & new_level);
500 gtk_tree_store_set (store, & size_level, 0, 0,
501 1, coord -> rsz[rid],
502 2, 0,
503 3, 0,
504 4, 0,
505 5, 0,
506 6, 0, -1);
507 gtk_tree_store_append (store, & ring_level, & size_level);
508 gtk_tree_store_set (store, & ring_level, 0, -coord -> rst[rid],
509 1, -coord -> rsz[rid],
510 2, coord -> ri[rid],
511 3, FALSE,
512 4, this_proj -> modelgl -> show_rpoly[rid][coord -> rst[rid]-1][coord -> rsz[rid]-1][coord -> ri[rid]-1],
513 5, FALSE,
514 6, FALSE, -1);
515 break;
516 case 2:
517 gtk_tree_store_insert_after (store, & new_level, & step_level, & size_level);
518 gtk_tree_store_set (store, & new_level, 0, 0,
519 1, coord -> rsz[rid],
520 2, 0,
521 3, 0,
522 4, 0,
523 5, 0,
524 6, 0, -1);
525 gtk_tree_store_append (store, & ring_level, & new_level);
526 gtk_tree_store_set (store, & ring_level, 0, -coord -> rst[rid],
527 1, -coord -> rsz[rid],
528 2, coord -> ri[rid],
529 3, FALSE,
530 4, this_proj -> modelgl -> show_rpoly[rid][coord -> rst[rid]-1][coord -> rsz[rid]-1][coord -> ri[rid]-1],
531 5, FALSE,
532 6, FALSE, -1);
533 break;
534 case 3:
535 gtk_tree_store_insert_before (store, & new_level, & step_level, & size_level);
536 gtk_tree_store_set (store, & new_level, 0, 0,
537 1, coord -> rsz[rid],
538 2, 0,
539 3, 0,
540 4, 0,
541 5, 0,
542 6, 0, -1);
543 gtk_tree_store_append (store, & ring_level, & new_level);
544 gtk_tree_store_set (store, & ring_level, 0, -coord -> rst[rid],
545 1, -coord -> rsz[rid],
546 2, coord -> ri[rid],
547 3, FALSE,
548 4, this_proj -> modelgl -> show_rpoly[rid][coord -> rst[rid]-1][coord -> rsz[rid]-1][coord -> ri[rid]-1],
549 5, FALSE,
550 6, FALSE, -1);
551 break;
552 case 4:
553 gtk_tree_store_insert_after (store, & new_level, & size_level, & ring_level);
554 gtk_tree_store_set (store, & new_level, 0, -coord -> rst[rid],
555 1, -coord -> rsz[rid],
556 2, coord -> ri[rid],
557 3, FALSE,
558 4, this_proj -> modelgl -> show_rpoly[rid][coord -> rst[rid]-1][coord -> rsz[rid]-1][coord -> ri[rid]-1],
559 5, FALSE,
560 6, FALSE, -1);
561 break;
562 case 5:
563 gtk_tree_store_insert_before (store, & new_level, & size_level, & ring_level);
564 gtk_tree_store_set (store, & new_level, 0, -coord -> rst[rid],
565 1, -coord -> rsz[rid],
566 2, coord -> ri[rid],
567 3, FALSE,
568 4, this_proj -> modelgl -> show_rpoly[rid][coord -> rst[rid]-1][coord -> rsz[rid]-1][coord -> ri[rid]-1],
569 5, FALSE,
570 6, FALSE, -1);
571 break;
572 }
573 }
574 }
575 else
576 {
577 valid = gtk_tree_model_get_iter_first(mod, & size_level);
578 while (valid)
579 {
580 gtk_tree_model_get (mod, & size_level, 0, & i, -1);
581 if (i > coord -> rsz[rid])
582 {
583 prepend = 1;
584 valid = FALSE;
585 }
586 else if (i == coord -> rsz[rid])
587 {
588 if (gtk_tree_model_iter_has_child (mod, &size_level))
589 {
590 j = gtk_tree_model_iter_n_children (mod, &size_level);
591 for (k=0; k<j; k++)
592 {
593 if (gtk_tree_model_iter_nth_child (mod, &ring_level, &size_level, k))
594 {
595 gtk_tree_model_get (mod, &ring_level, 1, & l, -1);
596 if (l > coord -> ri[rid])
597 {
598 prepend = 2;
599 valid = FALSE;
600 break;
601 }
602 else if (l == coord -> ri[rid])
603 {
604 insert = valid = FALSE;
605 break;
606 }
607 }
608 }
609 if (valid)
610 {
611 prepend = 3;
612 valid = FALSE;
613 }
614 }
615 }
616 else
617 {
618 valid = gtk_tree_model_iter_next(mod, & step_level);
619 }
620 }
621 if (insert)
622 {
623 switch (prepend)
624 {
625 case 0:
626 gtk_tree_store_append (store, & size_level, NULL);
627 gtk_tree_store_set (store, & size_level, 0, coord -> rsz[rid],
628 1, 0,
629 2, 0,
630 3, 0,
631 4, 0,
632 5, 0, -1);
633 gtk_tree_store_append (store, & ring_level, & size_level);
634 gtk_tree_store_set (store, & ring_level, 0, -coord -> rsz[rid],
635 1, coord -> ri[rid],
636 2, FALSE,
637 3, this_proj -> modelgl -> show_rpoly[rid][coord -> rst[rid]-1][coord -> rsz[rid]-1][coord -> ri[rid]-1],
638 4, FALSE,
639 5, FALSE, -1);
640 break;
641 case 1:
642 gtk_tree_store_insert_before (store, & new_level, NULL, & size_level);
643 gtk_tree_store_set (store, & new_level, 0, coord -> rsz[rid],
644 1, 0,
645 2, 0,
646 3, 0,
647 4, 0,
648 5, 0, -1);
649 gtk_tree_store_append (store, & ring_level, & new_level);
650 gtk_tree_store_set (store, & ring_level, 0, -coord -> rsz[rid],
651 1, coord -> ri[rid],
652 2, FALSE,
653 3, this_proj -> modelgl -> show_rpoly[rid][coord -> rst[rid]-1][coord -> rsz[rid]-1][coord -> ri[rid]-1],
654 4, FALSE,
655 5, FALSE, -1);
656 break;
657 case 2:
658 gtk_tree_store_insert_before (store, & new_level, & size_level, & ring_level);
659 gtk_tree_store_set (store, & new_level, 0, -coord -> rsz[rid],
660 1, coord -> ri[rid],
661 2, FALSE,
662 3, this_proj -> modelgl -> show_rpoly[rid][coord -> rst[rid]-1][coord -> rsz[rid]-1][coord -> ri[rid]-1],
663 4, FALSE,
664 5, FALSE, -1);
665 break;
666 case 3:
667 gtk_tree_store_insert_after (store, & new_level, & size_level, & ring_level);
668 gtk_tree_store_set (store, & new_level, 0, -coord -> rsz[rid],
669 1, coord -> ri[rid],
670 2, FALSE,
671 3, this_proj -> modelgl -> show_rpoly[rid][coord -> rst[rid]-1][coord -> rsz[rid]-1][coord -> ri[rid]-1],
672 4, FALSE,
673 5, FALSE, -1);
674 break;
675 }
676 }
677 }
678}
679
689int get_rmin (project * this_proj, int rid, int step)
690{
691 int i, j;
692 for (i=0; i<this_proj -> coord -> totcoord[rid+4]; i++)
693 {
694 j = this_proj -> coord -> geolist[rid+4][0][i];
695 if (this_proj -> modelgl -> num_rings[rid][step-1][j-1]) break;
696 }
697 return j;
698}
699
709int get_rmax (project * this_proj, int rid, int step)
710{
711 int i, j;
712 for (i=this_proj -> coord -> totcoord[rid+4]-1; i>-1; i--)
713 {
714 j = this_proj -> coord -> geolist[rid+4][0][i];
715 if (this_proj -> modelgl -> num_rings[rid][step-1][j-1]) break;
716 }
717 return j;
718}
719
728G_MODULE_EXPORT void update_rings_search (GtkEntry * res, gpointer data)
729{
730 tint * dat = (tint * )data;
731 gchar * str;
732 int i, j, k, v;
733 int rid;
734 const gchar * m = entry_get_text (res);
735 v = (int)string_to_double ((gpointer)m);
736 project * this_proj = get_project_by_id(dat -> a);
737 coord_edition * coord = this_proj -> modelgl -> coord_win;
738 for (i=0; i<5; i++)
739 {
740 if (i*10 > dat -> b) break;
741 }
742 rid = i - 1;
743 for (i=0; i<3; i++)
744 {
745 if (10*rid+i == dat -> b) break;
746 }
747 switch (i)
748 {
749 case 0:
750 if (v > 0 && v < this_proj -> steps+1)
751 {
752 if (v != coord -> rst[rid])
753 {
754 coord -> rst[rid] = v;
755 coord -> rsz[rid] = coord -> ri[rid] = -1;
756 for (j=1; j<3; j++) gtk_label_set_text (GTK_LABEL(coord -> rilab[rid][j]), "");
757 }
758 }
759 else
760 {
761 coord -> rst[rid] = coord -> rsz[rid] = coord -> ri[rid] = -1;
762 }
763 if (coord -> rst[rid] > 0)
764 {
765 update_entry_int(res, coord -> rst[rid]);
766 str = g_strdup_printf ("in [%d - %d]", get_rmin(this_proj, rid, coord -> rst[rid]), get_rmax(this_proj, rid, coord -> rst[rid]));
767 gtk_label_set_text (GTK_LABEL(coord -> rilab[rid][1]), str);
768 g_free (str);
769 }
770 else
771 {
773 }
774 break;
775 case 1:
776 if (coord -> rst[rid] > -1)
777 {
778 j = get_rmin(this_proj, rid, coord -> rst[rid]);
779 k = get_rmax(this_proj, rid, coord -> rst[rid]);
780 if (v >= j && v <= k)
781 {
782 if (v != coord -> rsz[rid])
783 {
784 if (this_proj -> modelgl -> num_rings[rid][coord -> rst[rid]-1][v-1])
785 {
786 coord -> rsz[rid] = v;
787 coord -> ri[rid] = -1;
788 }
789 else
790 {
791 coord -> rsz[rid] = -1;
792 }
793 }
794 }
795 }
796 else
797 {
798 coord -> rsz[rid] = coord -> ri[rid] = -1;
799 }
800 if (coord -> rsz[rid] > 0)
801 {
802 update_entry_int(res, coord -> rsz[rid]);
803 str = g_strdup_printf ("in [1 - %d]", this_proj -> modelgl -> num_rings[rid][coord -> rst[rid]-1][coord -> rsz[rid]-1]);
804 gtk_label_set_text (GTK_LABEL(coord -> rilab[rid][2]), str);
805 g_free (str);
806 }
807 else
808 {
810 gtk_label_set_text (GTK_LABEL(coord -> rilab[rid][2]), "");
811 }
812 break;
813 case 2:
814 if (coord -> rst[rid] > -1 && coord -> rsz[rid] > -1)
815 {
816 if (v > 0 && v < this_proj -> modelgl -> num_rings[rid][coord -> rst[rid]-1][coord -> rsz[rid]-1]+1)
817 {
818 coord -> ri[rid] = v;
819 }
820 else
821 {
822 coord -> ri[rid] = -1;
823 }
824 }
825 else
826 {
827 coord -> ri[rid] = -1;
828 }
829 if (coord -> ri[rid] > 0)
830 {
831 update_entry_int(res, coord -> ri[rid]);
832 }
833 else
834 {
836 }
837 break;
838 }
839 if (coord -> rst[rid] > 0 && coord -> rsz[rid] > 0 && coord -> ri[rid] > 0)
840 {
841 add_this_ring_to_search_tree (this_proj, rid);
842 }
843}
844
853GtkWidget * create_rings_search (project * this_proj, int rid)
854{
855 GtkWidget * rings_search = create_vbox (BSEP);
856 gchar * str = g_strdup_printf ("Too many <b>%s</b> rings in your model !\n"
857 " It is impossible to display the entire list ...\n"
858 "... instead you can look for ring(s) 'manually':\n", rings_type[rid]);
859 add_box_child_start (GTK_ORIENTATION_VERTICAL, rings_search, markup_label(str, 200, -1, 0.5, 0.5), FALSE, FALSE, 10);
860 g_free (str);
861 gchar * search_item[3]={"MD step:", "Ring size:", "Ring ID:"};
862 int i, j;
863 GtkWidget * hbox;
864 GtkWidget * entry;
865 j = (this_proj -> steps) > 1 ? 0 : 1;
866 coord_edition * coord = this_proj -> modelgl -> coord_win;
867 coord -> rst[rid] = 1;
868 for (i=j; i<3; i++)
869 {
870 hbox = create_hbox (0);
871 add_box_child_start (GTK_ORIENTATION_VERTICAL, rings_search, hbox, FALSE, FALSE, 0);
872 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label(search_item[i], 100, -1, 0.0, 0.5), FALSE, FALSE, 20);
873 entry = create_entry (G_CALLBACK(update_rings_search), 100, 15, FALSE, & this_proj -> modelgl -> colorp[rid*10+i][0]);
874 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox,entry, FALSE, FALSE, 0);
875 if (i==0)
876 {
877 str = g_strdup_printf ("in [1 - %d]", this_proj -> steps);
878 coord -> rilab[rid][i] = markup_label(str, 50, -1, 0.0, 0.5);
879 g_free (str);
880 }
881 else if (i == 1)
882 {
883 str = g_strdup_printf ("in [%d - %d]", get_rmin(this_proj, rid, coord -> rst[rid]), get_rmax(this_proj, rid, coord -> rst[rid]));
884 coord -> rilab[rid][i] = markup_label(str, 50, -1, 0.0, 0.5);
885 g_free (str);
886 }
887 else
888 {
889 coord -> rilab[rid][i] = markup_label("", 50, -1, 0.0, 0.5);
890 }
891 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, coord -> rilab[rid][i], FALSE, FALSE, 5);
892 }
893 add_box_child_start (GTK_ORIENTATION_VERTICAL, rings_search, markup_label("<b>Search result(s)</b>", 200, -1, 0.5, 0.5), FALSE, FALSE, 10);
894 add_box_child_start (GTK_ORIENTATION_VERTICAL, rings_search, create_rings_tree (this_proj, rid, FALSE), FALSE, FALSE, 0);
895 return rings_search;
896}
897
906GtkWidget * rings_tab (glwin * view, int rid)
907{
908 GtkWidget * rings = create_scroll(NULL, -1, -1, GTK_SHADOW_NONE);
909 gtk_widget_set_hexpand (rings, TRUE);
910 gtk_widget_set_vexpand (rings, TRUE);
911 int h, i, j, k;
912 project * this_proj = get_project_by_id(view -> proj);
913 k = 0;
914 for (h=0; h < this_proj -> steps; h++)
915 {
916 for (i=0; i < this_proj -> coord -> totcoord[rid+4]; i++)
917 {
918 j = this_proj -> coord -> geolist[rid+4][0][i];
919 k += this_proj -> modelgl -> num_rings[rid][h][j-1];
920 }
921 }
922 if (k < 10000)
923 {
924 add_container_child (CONTAINER_SCR, rings, create_rings_tree (this_proj, rid, TRUE));
925 }
926 else
927 {
928 add_container_child (CONTAINER_SCR, rings, create_rings_search (this_proj, rid));
929 }
930 return rings;
931}
color colorp[64]
ColRGBA col
Definition d_measures.c:77
int atoms[NUM_STYLES][2]
GtkTreePath * path
Definition datab.c:103
gchar * ctitle[MAXDATA][12]
Definition dlp_field.c:834
GType col_type[MAXDATA][12]
Definition dlp_field.c:856
char * rings_type[5]
Definition global.c:143
double string_to_double(gpointer string)
convert string to double
Definition global.c:624
Global variable declarations Global convenience function declarations Global data structure defin...
GtkWidget * create_entry(GCallback handler, int dim, int cdim, gboolean key_release, gpointer data)
Create a GtkEntry.
Definition gtk-misc.c:1314
GtkWidget * create_scroll(GtkWidget *box, int dimx, int dimy, int shadow)
create a scroll window
Definition gtk-misc.c:1960
project * proj
const gchar * entry_get_text(GtkEntry *entry)
get the text in a GtkEntry
Definition gtk-misc.c:597
#define BSEP
Definition global.h:245
void opengl_project_changed(int id)
change the OpenGL project
Definition update_p.c:245
void update_entry_int(GtkEntry *entry, int intval)
update the content of a GtkEntry as int
Definition gtk-misc.c:614
G_MODULE_EXPORT void select_unselect_this_atom(GtkWidget *widg, gpointer data)
select / unselect this atom callback GTK3
Definition popup.c:1177
@ CONTAINER_SCR
Definition global.h:251
G_MODULE_EXPORT void show_hide_this_atom(GtkWidget *widg, gpointer data)
show / hide this atom callback GTK3
Definition popup.c:1019
GtkWidget * markup_label(gchar *text, int dimx, int dimy, float ax, float ay)
Definition gtk-misc.c:1585
project * opengl_project
Definition project.c:54
void add_box_child_start(int orientation, GtkWidget *widg, GtkWidget *child, gboolean expand, gboolean fill, int padding)
Add a GtkWidget in a GtkBox at the initial position.
Definition gtk-misc.c:299
GtkWidget * create_hbox(int spacing)
create a GtkBox with horizontal orientation
Definition gtk-misc.c:813
void update_entry_text(GtkEntry *entry, gchar *text)
update the content of a GtkEntry as string
Definition gtk-misc.c:671
void add_container_child(int type, GtkWidget *widg, GtkWidget *child)
Add a GtkWidget into another GtkWidget.
Definition gtk-misc.c:226
GtkWidget * create_vbox(int spacing)
create a GtkBox with vertical orientation
Definition gtk-misc.c:801
project * get_project_by_id(int p)
get project pointer using id number
Definition project.c:120
void update(glwin *view)
update the rendering of the OpenGL window
Definition glview.c:439
Variable declarations related to the OpenGL window Function declarations related to the OpenGL wind...
void re_create_md_shaders(int nshaders, int shaders[nshaders], project *this_proj)
re-initialize some MD dependent OpenGL shaders
gboolean pick
int step
Definition ogl_draw.c:70
shaders
The different types of shaders in the atomes program.
Definition glwin.h:88
@ LABEL
Definition glwin.h:98
@ RINGS
Definition glwin.h:96
Function declarations for the creation of the OpenGL window.
Messaging function declarations.
Definition glwin.h:875
Definition global.h:104
int b
Definition tab-1.c:95
int c
Definition tab-1.c:95
int a
Definition tab-1.c:95
GtkWidget * res[2]
Definition w_encode.c:212
GtkWidget * create_rings_search(project *this_proj, int rid)
create the ring(s) search widget
Definition w_rings.c:853
void add_this_ring_to_search_tree(project *this_proj, int rid)
add ring in the search tree based on ring size and id
Definition w_rings.c:377
GtkWidget * rings_tab(glwin *view, int rid)
create the ring(s) tab for the advanced environments window
Definition w_rings.c:906
void fill_rings_model(GtkTreeStore *store, project *this_proj, int rid)
fill the entire ring(s) tree store
Definition w_rings.c:254
int get_rmin(project *this_proj, int rid, int step)
get ring(s) max size for the MD step
Definition w_rings.c:689
G_MODULE_EXPORT void update_rings_search(GtkEntry *res, gpointer data)
update the ring(s) search widget
Definition w_rings.c:728
GtkWidget * create_rings_tree(project *this_proj, int rid, gboolean fill_this)
create the ring(s) search tree store
Definition w_rings.c:335
G_MODULE_EXPORT void on_select_rings(GtkCellRendererToggle *cell_renderer, gchar *string_path, gpointer data)
on select ring toggle callback
Definition w_rings.c:63
void rings_set_visible(GtkTreeViewColumn *col, GtkCellRenderer *renderer, GtkTreeModel *mod, GtkTreeIter *iter, gpointer data)
show / hide cell renderer in the ring search tree store
Definition w_rings.c:165
int get_rmax(project *this_proj, int rid, int step)
get ring(s) min size for the MD step
Definition w_rings.c:709
GtkWidget * hbox
Definition workspace.c:71