atomes 1.1.14
atomes: an atomic scale modeling tool box
Loading...
Searching...
No Matches
m_map.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
23/*
24* This file: 'm_map.c'
25*
26* Contains:
27*
28
29 - The functions to create the 'OpenGL -> Color Scheme(s)' submenus
30 - The functions to handle custom color maps
31
32
33*
34* List of functions:
35
36 gboolean setup_custom_color_map (float * data, project * this_proj, gboolean init);
37 gboolean open_save_map (FILE * fp, int act, project * this_proj);
38 gboolean use_custom_color_map (int p);
39
40 void init_map_range (colormap * map, int pts);
41 void update_color_map ();
42 void fill_map_model (GtkTreeStore * store, project * this_proj);
43
44 G_MODULE_EXPORT void set_point_position (GtkSpinButton * res, gpointer data);
45 G_MODULE_EXPORT void set_point_color (GtkColorChooser * colob, gpointer data);
46 G_MODULE_EXPORT void add_map_points (GtkSpinButton * res, gpointer data);
47 G_MODULE_EXPORT void update_cmin_max (GtkEntry * res, gpointer data);
48 G_MODULE_EXPORT void run_custom_mize_map (GtkDialog * win, gint response_id, gpointer data);
49 G_MODULE_EXPORT void custom_mize_map (GtkWidget * but, gpointer data);
50 G_MODULE_EXPORT void edit_map_cell (GtkCellRendererText * cell, gchar * path_string, gchar * new_text, gpointer data);
51 G_MODULE_EXPORT void run_edit_data_map (GtkDialog * win, gint response_id, gpointer data);
52 G_MODULE_EXPORT void edit_data_map (GtkWidget * but, gpointer data);
53 G_MODULE_EXPORT void run_open_save_data_map (GtkNativeDialog * info, gint response_id, gpointer data);
54 G_MODULE_EXPORT void run_open_save_data_map (GtkDialog * info, gint response_id, gpointer data);
55 G_MODULE_EXPORT void open_save_data_map (GtkWidget * but, gpointer data);
56 G_MODULE_EXPORT void run_use_color_map (GtkDialog * win, gint response_id, gpointer data);
57 G_MODULE_EXPORT void set_color_map (GtkWidget * widg, gpointer data);
58 G_MODULE_EXPORT void change_color_radio (GSimpleAction * action, GVariant * parameter, gpointer data);
59
60 GtkWidget * create_css_color_bar (colormap * map);
61 GtkWidget * create_map_buttons ();
62 GtkWidget * create_map_tree (project * this_proj);
63 GtkWidget * mapw (glwin * view, int m, int mi, int mid, int cid, gchar * str);
64 GtkWidget * menump (glwin * view, gchar * ncm, int mid, int id, int cid);
65 GtkWidget * menu_map (glwin * view, int id);
66
67 GMenu * menump (glwin * view, int popm, int mid, int cid);
68 GMenu * menu_map (glwin * view, int popm);
69
70 colormap * allocate_color_map (int pts, project * this_proj);
71
72*/
73
74#include "global.h"
75#include "interface.h"
76#include "project.h"
77#include "glwindow.h"
78#include "glview.h"
79
80extern const gchar * dfi[2];
81gboolean cmap_changed = FALSE;
82GtkWidget * map_but[3];
83GtkTreeStore * map_model;
86GtkWidget * vcbox;
87GtkWidget * vbbox;
88GtkWidget * color_fix;
89GtkWidget * color_bar;
90float * tmp_data;
91
99GtkWidget * create_css_color_bar (colormap * map)
100{
101 GtkWidget * colob;
102 gchar * tmp;
103
104 tmp = g_strdup_printf ("rgba(%d,%d,%d,%d) 0%%",
105 (int)(map -> values[0].red*255.0),
106 (int)(map -> values[0].green*255.0),
107 (int)(map -> values[0].blue*255.0),
108 (int)map -> values[0].alpha);
109 int i, j, k;
110 j = (map -> positions[0] < map -> cmax) ? 0 : 1;
111 for (i=j; i<map -> points; i++)
112 {
113 k = (int)(100.0*(1.0 - (map -> positions[i] - map -> cmin)/(map -> cmax - map -> cmin)));
114 k = (i == map -> points-1 && map -> positions[i] == map -> cmin) ? 100 : k;
115 tmp = g_strdup_printf ("%s, rgba(%d,%d,%d,%d) %d%%", tmp,
116 (int)(map -> values[i].red*255.0),
117 (int)(map -> values[i].green*255.0),
118 (int)(map -> values[i].blue*255.0),
119 (int)map -> values[i].alpha,
120 k);
121 }
122 if (map -> positions[i-1] < map -> cmin)
123 {
124 tmp = g_strdup_printf ("%s, rgba(%d,%d,%d,%d) %d%%", tmp,
125 (int)(map -> values[i-1].red*255.0),
126 (int)(map -> values[i-1].green*255.0),
127 (int)(map -> values[i-1].blue*255.0),
128 (int)map -> values[i-1].alpha,
129 100);
130 }
131 gchar * gradient = g_strdup_printf ("image#gradient {\n"
132 " background-image: linear-gradient(to bottom, %s);\n"
133 " min-width: 50px;\n"
134 " min-height: 400px;\n"
135 "}", tmp);
136 g_free (tmp);
137 provide_gtk_css (gradient);
138 colob = gtk_image_new ();
139 gtk_widget_set_name (colob, "gradient");
140 gtk_widget_show (colob);
141 //gtk_widget_set_size_request (colob, 100, 400);
142 g_free (gradient);
143 return colob;
144}
145
154void init_map_range (colormap * map, int pts)
155{
156 map -> points = pts;
157 if (map -> positions != NULL)
158 {
159 g_free (map -> positions);
160 map -> positions = NULL;
161 }
162 if (map -> values != NULL)
163 {
164 g_free (map -> values);
165 map -> values = NULL;
166 }
167 map -> positions = allocfloat (pts);
168 map -> values = g_malloc (pts*sizeof*map -> values);
169 int i;
170 for (i=0; i<pts; i++)
171 {
172 map -> positions[i] = map -> cmax - i*(map -> cmax - map -> cmin)/(pts - 1.0);
173 map -> values[i].red = 1.0 - i / (pts - 1.0);
174 map -> values[i].green = 0.0;
175 map -> values[i].blue = i / (pts - 1.0);
176 map -> values[i].alpha = 1.0;
177 }
178}
179
188colormap * allocate_color_map (int pts, project * this_proj)
189{
190 colormap * map = g_malloc0 (sizeof*map);
191 map -> data = g_malloc (this_proj -> steps*sizeof*map -> data);
192 map -> colors = g_malloc (this_proj -> steps*sizeof*map -> colors);
193 int i;
194 for (i=0; i<this_proj -> steps; i++)
195 {
196 map -> data[i] = g_malloc0 (this_proj -> natomes*sizeof*map -> data[i]);
197 map -> colors[i] = g_malloc0 (this_proj -> natomes*sizeof*map -> colors[i]);
198 }
199 return map;
200}
201
211gboolean setup_custom_color_map (float * data, project * this_proj, gboolean init)
212{
213 int i, j, k;
214 gboolean action;
215 float cmin, cmax;
216 float delta;
217
218 if (data != NULL)
219 {
220 k = 0;
221 cmin = cmax = data[0];
222 for (i=0; i<this_proj -> steps; i++)
223 {
224 for (j=0; j<this_proj -> natomes; j++)
225 {
226 cmin = min(cmin, data[k]);
227 cmax = max(cmax, data[k]);
228 k ++;
229 }
230 }
231 }
232
233 if (init)
234 {
235 gchar * str = g_strdup_printf ("Range: [min-max] = %f - %f", cmin, cmax);
236 action = ask_yes_no ("Use this data set ?", str, GTK_MESSAGE_QUESTION, NULL);
237 }
238 else
239 {
240 action = TRUE;
241 }
242 if (action)
243 {
244 if (init)
245 {
246 this_proj -> modelgl -> custom_map = allocate_color_map (2, this_proj);
247 this_proj -> modelgl -> custom_map -> points = 2;
248 }
249 the_map = this_proj -> modelgl -> custom_map;
250 if (data != NULL)
251 {
252 the_map -> cmin = cmin;
253 the_map -> cmax = cmax;
254 init_map_range (the_map, the_map -> points);
255 k = 0;
256 for (i=0; i<this_proj -> steps; i++)
257 {
258 for (j=0; j<this_proj -> natomes; j++)
259 {
260 the_map -> data[i][j] = data[k];
261 k ++;
262 }
263 }
264 }
265 gboolean done;
266 for (i=0; i<this_proj -> steps; i++)
267 {
268 for (j=0; j<this_proj -> natomes; j++)
269 {
270 done = FALSE;
271 for (k=0; k<the_map -> points-1; k++)
272 {
273 if (the_map -> data[i][j] <= the_map -> positions[k] && the_map -> data[i][j] > the_map -> positions[k+1])
274 {
275 delta = (the_map -> data[i][j]-the_map -> positions[k])/(the_map -> positions[k] - the_map -> positions[k+1]);
276 the_map -> colors[i][j].red = the_map -> values[k].red + delta * (the_map -> values[k].red - the_map -> values[k+1].red);
277 the_map -> colors[i][j].green = the_map -> values[k].green + delta * (the_map -> values[k].green - the_map -> values[k+1].green);
278 the_map -> colors[i][j].blue = the_map -> values[k].blue + delta * (the_map -> values[k].blue - the_map -> values[k+1].blue);
279 the_map -> colors[i][j].alpha = 1.0;
280 done = TRUE;
281 }
282 }
283 if (! done)
284 {
285 if (the_map -> data[i][j] > the_map -> positions[0])
286 {
287 the_map -> colors[i][j].red = the_map -> values[0].red;
288 the_map -> colors[i][j].green = the_map -> values[0].green;
289 the_map -> colors[i][j].blue = the_map -> values[0].blue;
290 the_map -> colors[i][j].alpha = 1.0;
291 }
292 else if (the_map -> data[i][j] < the_map -> positions[the_map -> points-1])
293 {
294 the_map -> colors[i][j].red = the_map -> values[the_map -> points-1].red;
295 the_map -> colors[i][j].green = the_map -> values[the_map -> points-1].green;
296 the_map -> colors[i][j].blue = the_map -> values[the_map -> points-1].blue;
297 the_map -> colors[i][j].alpha = 1.0;
298 }
299 }
300 }
301 }
302 }
303 return action;
304}
305
314G_MODULE_EXPORT void set_point_position (GtkSpinButton * res, gpointer data)
315{
316 int pts = GPOINTER_TO_INT (data);
317 float pos = (float) gtk_spin_button_get_value (res);
318 gboolean update = FALSE;
319 if (pos >= tmp_map -> cmin && pos <= tmp_map -> cmax)
320 {
321 if (pos != tmp_map -> positions[pts])
322 {
323 if (pts == 0)
324 {
325 update = (pos > tmp_map -> positions[1]) ? TRUE : FALSE;
326 }
327 else if (pts == tmp_map -> points-1)
328 {
329 update = (pos < tmp_map -> positions[pts-1]) ? TRUE : FALSE;
330 }
331 else
332 {
333 update = (pos < tmp_map -> positions[pts-1] && pos > tmp_map -> positions[pts+1]) ? TRUE : FALSE;
334 }
335 if (update) tmp_map -> positions[pts] = pos;
336 }
337 }
338 gtk_spin_button_set_value (GTK_SPIN_BUTTON(res), tmp_map -> positions[pts]);
341 gtk_fixed_put (GTK_FIXED(color_fix), color_bar, 50, 0);
342}
343
352G_MODULE_EXPORT void set_point_color (GtkColorChooser * colob, gpointer data)
353{
354 int pts = GPOINTER_TO_INT (data);
355 tmp_map -> values[pts] =get_button_color (colob);
358 gtk_fixed_put (GTK_FIXED(color_fix), color_bar, 50, 0);
359}
360
361
367GtkWidget * create_map_buttons ()
368{
369 GtkWidget * vbox = create_vbox(5);
370 int i;
371 GtkWidget * hbox;
372 GtkWidget * fixed;
373 for (i=0; i<tmp_map -> points; i++)
374 {
375 hbox = create_hbox (5);
376 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 0);
377 fixed = gtk_fixed_new ();
378 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, fixed, FALSE, FALSE, 0);
379 gtk_fixed_put (GTK_FIXED(fixed), color_button(tmp_map -> values[i], FALSE, 100, 25, G_CALLBACK(set_point_color), GINT_TO_POINTER(i)), 0, 0);
380 fixed = gtk_fixed_new ();
381 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, fixed, FALSE, FALSE, 0);
382 gtk_fixed_put (GTK_FIXED(fixed), spin_button (G_CALLBACK(set_point_position), tmp_map -> positions[i], tmp_map -> cmin, tmp_map -> cmax, 0.01, 3, 100, GINT_TO_POINTER(i)), 0, 0);
383 }
384 return vbox;
385}
386
393{
396 add_box_child_start (GTK_ORIENTATION_VERTICAL, vcbox, vbbox, FALSE, FALSE, 0);
400 gtk_fixed_put (GTK_FIXED(color_fix), color_bar, 50, 0);
401}
402
411G_MODULE_EXPORT void add_map_points (GtkSpinButton * res, gpointer data)
412{
413 //project * this_proj = get_project_by_id(GPOINTER_TO_INT(data));
414 int id = gtk_spin_button_get_value_as_int (res);
415 if (id >= 2 && id != tmp_map -> points)
416 {
419 }
420 gtk_spin_button_set_value (GTK_SPIN_BUTTON(res), tmp_map -> points);
421}
422
431G_MODULE_EXPORT void update_cmin_max (GtkEntry * res, gpointer data)
432{
433 int i;
434 i = GPOINTER_TO_INT(data);
435 const gchar * m = entry_get_text (res);
436 double v = atof(m);
437 gboolean update_cmap = FALSE;
438 switch (i)
439 {
440 case 0:
441 if (v > tmp_map -> cmin && v != tmp_map -> cmax)
442 {
443 tmp_map -> cmax = v;
444 update_cmap = TRUE;
445 }
446 v = tmp_map -> cmax;
447 break;
448 case 1:
449 if (v < tmp_map -> cmax && v != tmp_map -> cmin)
450 {
451 tmp_map -> cmin = v;
452 update_cmap = TRUE;
453 }
454 v = tmp_map -> cmin;
455 break;
456 }
458 if (update_cmap)
459 {
460 //init_map_range (tmp_map, tmp_map -> points);
462 }
463}
464
474G_MODULE_EXPORT void run_custom_mize_map (GtkDialog * win, gint response_id, gpointer data)
475{
476 if (response_id == GTK_RESPONSE_APPLY)
477 {
478 project * this_proj = (project *)data;
479 the_map -> cmax = tmp_map -> cmax;
480 the_map -> cmin = tmp_map -> cmin;
481 the_map -> points = tmp_map -> points;
482 g_free (the_map -> positions);
483 the_map -> positions = duplicate_float (the_map -> points, tmp_map -> positions);
484 g_free (the_map -> values);
485 the_map -> values = duplicate_color (the_map -> points, tmp_map -> values);
486 setup_custom_color_map (NULL, this_proj, FALSE);
487 int shaders[2] = {ATOMS, BONDS};
488 re_create_md_shaders (2, shaders, this_proj);
489 update (this_proj -> modelgl);
490 }
492}
493
502G_MODULE_EXPORT void custom_mize_map (GtkWidget * but, gpointer data)
503{
504 project * this_proj = get_project_by_id(GPOINTER_TO_INT(data));
505 GtkWidget * win = dialogmodal ("Edit color map", GTK_WINDOW(this_proj -> modelgl -> win));
506 gtk_dialog_add_button (GTK_DIALOG(win), "Apply", GTK_RESPONSE_APPLY);
507 gtk_widget_set_size_request (win, 300, -1);
508 GtkWidget * vbox = dialog_get_content_area (win);
509 tmp_map = g_malloc0 (sizeof*tmp_map);
510 tmp_map -> cmin = the_map -> cmin;
511 tmp_map -> cmax = the_map -> cmax;
512 tmp_map -> points = the_map -> points;
513 tmp_map -> positions = duplicate_float (the_map -> points, the_map -> positions);
514 tmp_map -> values = duplicate_color (tmp_map -> points, the_map -> values);
515
516 // Button for number of colors
517 GtkWidget * hbox = create_hbox (0);
518 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 5);
519 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label("Number of color points for the gradient: ", 200, -1, 0.0, 0.5), FALSE, FALSE, 5);
520 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox,
521 spin_button (G_CALLBACK(add_map_points), tmp_map -> points, 2, 100, 1, 0, 150, data),
522 FALSE, FALSE, 25);
523
524 // Max
525 hbox = create_hbox (0);
526 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 5);
527 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label("Initial value (overall max): ", 200, -1, 0.0, 0.5), FALSE, FALSE, 5);
528 GtkWidget * entry = create_entry (G_CALLBACK(update_cmin_max), 100, 15, FALSE, GINT_TO_POINTER(0));
529 update_entry_double (GTK_ENTRY(entry), (double)tmp_map -> cmax);
530 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, entry, FALSE, FALSE, 25);
531
532 // Min
533 hbox = create_hbox (0);
534 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 5);
535 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label("Final value (overall min): ", 200, -1, 0.0, 0.5), FALSE, FALSE, 5);
536 entry = create_entry (G_CALLBACK(update_cmin_max), 100, 15, FALSE, GINT_TO_POINTER(1));
537 update_entry_double (GTK_ENTRY(entry), (double)tmp_map -> cmin);
538 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, entry, FALSE, FALSE, 25);
539
540 hbox = create_hbox(0);
541 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 5);
542 vcbox = create_vbox (5);
543 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, vcbox, FALSE, FALSE, 5);
545 add_box_child_start (GTK_ORIENTATION_VERTICAL, vcbox, vbbox, FALSE, FALSE, 0);
546
547 color_fix = gtk_fixed_new ();
549 gtk_fixed_put (GTK_FIXED(color_fix), color_bar, 50, 0);
550 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, color_fix, FALSE, FALSE, 0);
551
552 run_this_gtk_dialog (win, G_CALLBACK(run_custom_mize_map), this_proj);
553}
554
555/*void map_set_visible (GtkTreeViewColumn * col,
556 GtkCellRenderer * renderer,
557 GtkTreeModel * mod,
558 GtkTreeIter * iter,
559 gpointer data)
560{
561 int i, j;
562 j = GPOINTER_TO_INT(data);
563 gtk_tree_model_get (mod, iter, 0, & i, -1);
564 if (i > 0)
565 {
566 if (j == 0)
567 {
568 gtk_cell_renderer_set_visible (renderer, 1);
569 }
570 else
571 {
572 gtk_cell_renderer_set_visible (renderer, 0);
573 }
574 }
575 else
576 {
577 if (j == 0)
578 {
579 gtk_cell_renderer_set_visible (renderer, 0);
580 }
581 else
582 {
583 gtk_cell_renderer_set_visible (renderer, 1);
584 }
585 }
586}*/
587
596void fill_map_model (GtkTreeStore * store, project * this_proj)
597{
598 GtkTreeIter step_level, atom_level;
599 int h, i, j;
600 if (this_proj -> steps > 1)
601 {
602 for (h=0; h < this_proj -> steps; h++)
603 {
604 gtk_tree_store_append (store, & step_level, NULL);
605 gtk_tree_store_set (store, & step_level, 0, h+1,
606 1, 0,
607 2, 0,
608 3, 0, -1);
609 for (i=0; i < this_proj -> natomes; i++)
610 {
611 gtk_tree_store_append (store, & atom_level, & step_level);
612 j = this_proj -> atoms[h][i].sp;
613 gtk_tree_store_set (store, & atom_level, 0, -h-1, 1, this_proj -> chemistry -> label[j] , 2, i+1, 3, the_map -> data[h][i], -1);
614 }
615 }
616 }
617 else
618 {
619 for (i=0; i < this_proj -> natomes; i++)
620 {
621 gtk_tree_store_append (store, & atom_level, NULL);
622 j = this_proj -> atoms[0][i].sp;
623 gtk_tree_store_set (store, & atom_level, 0, this_proj -> chemistry -> label[j] , 1, i+1, 2, the_map -> data[0][i], -1);
624 }
625 }
626}
627
638G_MODULE_EXPORT void edit_map_cell (GtkCellRendererText * cell, gchar * path_string, gchar * new_text, gpointer data)
639{
640 int i, j;
641 project * this_proj = get_project_by_id(GPOINTER_TO_INT(data));
642 GtkTreeIter iter;
643 GtkTreePath * path = gtk_tree_path_new_from_string (path_string);
644 gtk_tree_model_get_iter (GTK_TREE_MODEL(map_model), & iter, path);
645 if (this_proj -> steps > 1)
646 {
647 gtk_tree_model_get (GTK_TREE_MODEL(map_model), & iter, 0, & i, -1);
648 gtk_tree_model_get (GTK_TREE_MODEL(map_model), & iter, 2, & j, -1);
649 }
650 else
651 {
652 i = -1;
653 gtk_tree_model_get (GTK_TREE_MODEL(map_model), & iter, 1, & j, -1);
654 }
655 tmp_data[(-i-1)*this_proj -> natomes + j - 1] = atof(new_text);
656 if (this_proj -> steps > 1)
657 {
658 gtk_tree_store_set (map_model, & iter, 3, tmp_data[(-i-1)*this_proj -> natomes + j - 1], -1);
659 }
660 else
661 {
662 gtk_tree_store_set (map_model, & iter, 2, tmp_data[(-i-1)*this_proj -> natomes + j - 1], -1);
663 }
664
665}
666
674GtkWidget * create_map_tree (project * this_proj)
675{
676 int i, j, k;
677 GtkTreeViewColumn * map_col[4];
678 GtkCellRenderer * map_cell[4];
679 gchar * ctitle[4]={"MD. step", "Element", "Id.", "Value"};
680 gchar * ctype[4]={"text", "text", "text", "text"};
681 GType col_type[2][4]= {{G_TYPE_STRING, G_TYPE_INT, G_TYPE_FLOAT},
682 {G_TYPE_INT, G_TYPE_STRING, G_TYPE_INT, G_TYPE_FLOAT}};
683 j = (this_proj -> steps > 1) ? 1: 0;
684 k = (this_proj -> steps > 1) ? 0: 1;
685 map_model = gtk_tree_store_newv (3+j, col_type[j]);
686 fill_map_model (map_model, this_proj);
687 GtkWidget * map_tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL(map_model));
688 for (i=0; i<3+j; i++)
689 {
690 map_cell[i] = gtk_cell_renderer_text_new ();
691 map_col[i] = gtk_tree_view_column_new_with_attributes (ctitle[i+k], map_cell[i], ctype[i], i, NULL);
692 gtk_tree_view_append_column(GTK_TREE_VIEW(map_tree), map_col[i]);
693 gtk_tree_view_column_set_alignment (map_col[i], 0.5);
694 //gtk_tree_view_column_set_cell_data_func (map_col[i], map_cell[i], map_set_visible, GINT_TO_POINTER(i), NULL);
695 if (i == 2+j)
696 {
697 g_object_set (map_cell[i], "editable", TRUE, NULL);
698 g_signal_connect (G_OBJECT(map_cell[i]), "edited", G_CALLBACK(edit_map_cell), GINT_TO_POINTER(this_proj -> id));
699 }
700 }
701 return map_tree;
702}
703
713G_MODULE_EXPORT void run_edit_data_map (GtkDialog * win, gint response_id, gpointer data)
714{
715 if (response_id == GTK_RESPONSE_APPLY)
716 {
717 project * this_proj = get_project_by_id(GPOINTER_TO_INT(data));
718 setup_custom_color_map (tmp_data, this_proj, FALSE);
719 int shaders[2] = {ATOMS, BONDS};
720 re_create_md_shaders (2, shaders, this_proj);
721 update (this_proj -> modelgl);
722 }
723 g_free (tmp_data);
725}
726
735G_MODULE_EXPORT void edit_data_map (GtkWidget * but, gpointer data)
736{
737 project * this_proj = get_project_by_id(GPOINTER_TO_INT(data));
738 GtkWidget * win = dialogmodal ("Edit color map data", GTK_WINDOW(this_proj -> modelgl -> win));
739 gtk_dialog_add_button (GTK_DIALOG(win), "Apply", GTK_RESPONSE_APPLY);
740 gtk_widget_set_size_request (win, 250, 600);
741 GtkWidget * vbox = dialog_get_content_area (win);
742 GtkWidget * maps = create_scroll(NULL, -1, -1, GTK_SHADOW_NONE);
743 tmp_data = allocfloat(this_proj -> natomes*this_proj -> steps);
744 int i, j, k;
745 k = 0;
746 for (i=0; i<this_proj -> steps; i++)
747 {
748 for (j=0; j<this_proj -> natomes; j++)
749 {
750 tmp_data[k] = the_map -> data[i][j];
751 k ++;
752 }
753 }
755 gtk_widget_set_size_request (maps, -1, 550);
756 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, maps, FALSE, FALSE, 0);
757 run_this_gtk_dialog (win, G_CALLBACK(run_edit_data_map), data);
758}
759
769gboolean open_save_map (FILE * fp, int act, project * this_proj)
770{
771 int i, j;
772 if (act == 0)
773 {
774 float * tmp_map = allocfloat(this_proj -> natomes*this_proj -> steps);
775 rewind (fp);
776 for (i=0; i<this_proj -> natomes*this_proj -> steps; i++)
777 {
778 if (fscanf (fp, "%f", & tmp_map[i]) != 1)
779 {
780 show_error ("Wrong file format !\n Expecting only a single column file\n"
781 " with Ns x Na lines, with:\n"
782 " - Ns = number of MD steps\n"
783 " - Na = number of atoms", 0, this_proj -> modelgl -> win);
784 g_free (tmp_map);
785 cmap_changed = FALSE;
786 return FALSE;
787 }
788 }
789 cmap_changed = setup_custom_color_map (tmp_map, this_proj, TRUE);
790 g_free (tmp_map);
793 return TRUE;
794 }
795 else
796 {
797 cmap_changed = FALSE;
798 for (i=0; i<this_proj -> steps; i++)
799 {
800 for (j=0; j<this_proj -> natomes; j++)
801 {
802 if (fprintf (fp, "%f\n", this_proj -> modelgl -> custom_map -> data[i][j]) < 0)
803 {
804 show_error ("Error while saving custom color map", 0, this_proj -> modelgl -> win);
805 return FALSE;
806 }
807 }
808 }
809 return TRUE;
810 }
811}
812
814
815#ifdef GTK4
825G_MODULE_EXPORT void run_open_save_data_map (GtkNativeDialog * info, gint response_id, gpointer data)
826{
827 GtkFileChooser * chooser = GTK_FILE_CHOOSER((GtkFileChooserNative *)info);
828#else
838G_MODULE_EXPORT void run_open_save_data_map (GtkDialog * info, gint response_id, gpointer data)
839{
840 GtkFileChooser * chooser = GTK_FILE_CHOOSER((GtkWidget *)info);
841#endif
842 gboolean status = FALSE;
843 gchar * datafile;
844 FILE * fp;
845 switch (response_id)
846 {
847 case GTK_RESPONSE_ACCEPT:
848 datafile = file_chooser_get_file_name (chooser);
849 fp = fopen (datafile, dfi[osmap.b]);
850 if (fp != NULL)
851 {
853 }
854 else
855 {
856 status = FALSE;
857 }
858 fclose (fp);
859 break;
860 default:
861 status = TRUE;
862 break;
863 }
864 if (status)
865 {
866#ifdef GTK4
868#else
869 destroy_this_dialog (info);
870#endif
871 }
872}
873
882G_MODULE_EXPORT void open_save_data_map (GtkWidget * but, gpointer data)
883{
884 GtkFileFilter * filter1, * filter2;
885 const gchar * res[2] = {"Open", "Save"};
886 GtkFileChooserAction act[2] = {GTK_FILE_CHOOSER_ACTION_OPEN, GTK_FILE_CHOOSER_ACTION_SAVE};
887 gchar * title[2] = {"Opening custom map for ", "Saving custom map for "};
888 osmap.a = GPOINTER_TO_INT (data);
889 project * this_proj = get_project_by_id(osmap.a);
890 gchar * str;
891 gboolean open_save = FALSE;
892 if (the_map != NULL)
893 {
894 str = g_strdup_printf ("Do you want to save the color map data");
895 open_save = ask_yes_no ("Save color map data to file ?", str, GTK_MESSAGE_QUESTION, this_proj -> modelgl -> win);
896 g_free (str);
897 if (open_save)
898 {
899 osmap.b = 1;
900 }
901 else
902 {
903 str = g_strdup_printf ("Do you want to read new color map data");
904 open_save = ask_yes_no ("Read color map data from file ?", str, GTK_MESSAGE_QUESTION, this_proj -> modelgl -> win);
905 g_free (str);
906 osmap.b = 0;
907 }
908 }
909 else
910 {
911 osmap.b = 0;
912 open_save = TRUE;
913 }
914 if (open_save)
915 {
916#ifdef GTK4
917 GtkFileChooserNative * info;
918#else
919 GtkWidget * info;
920#endif
921 str = g_strdup_printf ("%s%s", title[osmap.b], prepare_for_title(this_proj -> name));
922 info = create_file_chooser (str,
923 GTK_WINDOW(MainWindow),
924 act[osmap.b],
925 res[osmap.b]);
926 GtkFileChooser * chooser = GTK_FILE_CHOOSER(info);
927 g_free (str);
928#ifdef GTK3
929 if (osmap.b == 1) gtk_file_chooser_set_do_overwrite_confirmation (chooser, TRUE);
930#endif
932 filter1 = gtk_file_filter_new();
933 gtk_file_filter_set_name (GTK_FILE_FILTER(filter1), "Raw data (*.dat)");
934 gtk_file_filter_add_pattern (GTK_FILE_FILTER(filter1), "*.dat");
935 gtk_file_chooser_add_filter (chooser, filter1);
936 filter2 = gtk_file_filter_new();
937 gtk_file_filter_set_name (GTK_FILE_FILTER(filter2), "All files (*)");
938 gtk_file_filter_add_pattern (GTK_FILE_FILTER(filter2), "*");
939 gtk_file_chooser_add_filter (chooser, filter2);
940#ifdef GTK4
941 run_this_gtk_native_dialog ((GtkNativeDialog *)info, G_CALLBACK(run_open_save_data_map), NULL);
942#else
943 run_this_gtk_dialog (info, G_CALLBACK(run_open_save_data_map), NULL);
944#endif
945 }
946}
947
948gboolean res_use_map;
949
959G_MODULE_EXPORT void run_use_color_map (GtkDialog * win, gint response_id, gpointer data)
960{
961 if (response_id == GTK_RESPONSE_APPLY)
962 {
963 res_use_map = (cmap_changed || the_map != NULL) ? TRUE : FALSE;
964 }
965 else
966 {
967 res_use_map = the_map != NULL ? TRUE : FALSE;
968 }
970}
971
979gboolean use_custom_color_map (int p)
980{
981 project * this_proj = get_project_by_id(p);
982 GtkWidget * win = dialogmodal ("Custom color map settings", GTK_WINDOW(this_proj -> modelgl -> win));
983 gtk_dialog_add_button (GTK_DIALOG(win), "Apply", GTK_RESPONSE_APPLY);
984 GtkWidget * vbox = dialog_get_content_area (win);
985 gchar * btitle[3] = {"Import / Save data", "Edit data", "Customize color map"};
986 gchar * bimage[3] = {FOPEN, EDITA, EDITA};
987 GCallback handlers[3] = {G_CALLBACK(open_save_data_map), G_CALLBACK(edit_data_map), G_CALLBACK(custom_mize_map)};
988 int i;
989 for (i=0; i<3; i++)
990 {
991 map_but[i] = create_button (btitle[i], IMG_STOCK, bimage[i], 150, 50, GTK_RELIEF_NORMAL, handlers[i], GINT_TO_POINTER(p));
992 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, map_but[i], FALSE, FALSE, 10);
993 if (i > 0 && the_map == NULL)
994 {
996 }
997 }
998 run_this_gtk_dialog (win, G_CALLBACK(run_use_color_map), NULL);
999 // res_use_map is updated when running the dialog
1000 return res_use_map;
1001}
1002
1011G_MODULE_EXPORT void set_color_map (GtkWidget * widg, gpointer data)
1012{
1013 tint * the_data = (tint *) data;
1014 project * this_proj = get_project_by_id(the_data -> a);
1015 the_map = this_proj -> modelgl -> custom_map;
1016 int i, j, k, l;
1017 j = the_data -> b;
1018 k = j / ATOM_MAPS;
1019 i = this_proj -> modelgl -> anim -> last -> img -> color_map[k];
1020 l = j - k*ATOM_MAPS;
1021#ifdef GTK3
1022 if (i != l && gtk_check_menu_item_get_active ((GtkCheckMenuItem *)widg))
1023#else
1024 if (i != l)
1025#endif
1026 {
1027 gboolean change_map = TRUE;
1028 gboolean didit = FALSE;
1029 if (j == 6 && ! the_map && ! k)
1030 {
1031 change_map = use_custom_color_map (the_data -> a);
1032 didit = TRUE;
1033 }
1034 else if (j == 6 && k && ! the_map)
1035 {
1036 change_map = FALSE;
1037 }
1038 if (change_map)
1039 {
1040 this_proj -> modelgl -> anim -> last -> img -> color_map[k] = NONE;
1041#ifdef GTK3
1042 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)this_proj -> modelgl -> color_styles[k*ATOM_MAPS+i], FALSE);
1043 if (j == 6) widget_set_sensitive (this_proj -> modelgl -> color_styles[ATOM_MAPS+POLY_MAPS-1], TRUE);
1044 if (widg != this_proj -> modelgl -> color_styles[j])
1045 {
1046 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)this_proj -> modelgl -> color_styles[j], TRUE);
1047 }
1048#endif
1049 this_proj -> modelgl -> anim -> last -> img -> color_map[k] = l;
1050
1051 if (k == 0)
1052 {
1053 int shaders[2] = {ATOMS, BONDS};
1054 re_create_md_shaders (2, shaders, this_proj);
1055 this_proj -> modelgl -> create_shaders[LABEL] = TRUE;
1056 }
1057 else
1058 {
1059 int shaders[1] = {POLYS};
1060 re_create_md_shaders (1, shaders, this_proj);
1061 }
1062 update (this_proj -> modelgl);
1063 if (j == 6 && ! didit && ! reading_input && ! k) use_custom_color_map (the_data -> a);
1064 }
1065 }
1066#ifdef GTK3
1067 else if (k*ATOM_MAPS+i == j && ! gtk_check_menu_item_get_active ((GtkCheckMenuItem *)widg))
1068 {
1069 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)this_proj -> modelgl -> color_styles[j], TRUE);
1070 }
1071#endif
1072}
1073
1074#ifdef GTK3
1087GtkWidget * mapw (glwin * view, int m, int mi, int mid, int cid, gchar * str)
1088{
1089 int v = mi*ATOM_MAPS + mid;
1090 if (m == 0)
1091 {
1092 view -> color_styles[v] = gtk3_menu_item (NULL, str, IMG_NONE, NULL, G_CALLBACK(set_color_map), & view -> colorp[v][0], FALSE, 0, 0, TRUE, TRUE, (cid == mid) ? TRUE : FALSE);
1093 if ((mi && (! view -> bonding || ! view -> custom_map))
1094 || (mid == 3 && ! view -> adv_bonding[0])
1095 || (mid == 4 && ! view -> adv_bonding[1])
1096 || (mid == 5 && ! get_project_by_id(view -> proj) -> force_field[0]))
1097 {
1098 widget_set_sensitive (view -> color_styles[v], 0);
1099 }
1100 return view -> color_styles[v];
1101 }
1102 else
1103 {
1104 GtkWidget * ats = gtk3_menu_item (NULL, str, IMG_NONE, NULL, G_CALLBACK(set_color_map), & view -> colorp[v][0], FALSE, 0, 0, TRUE, TRUE, (cid == mid) ? TRUE : FALSE);
1105 if ((mi && (! view -> bonding || ! view -> custom_map))
1106 || (mid == 3 && ! view -> adv_bonding[0])
1107 || (mid == 4 && ! view -> adv_bonding[1])
1108 || (mid == 5 && ! get_project_by_id(view -> proj) -> force_field[0]))
1109 {
1110 widget_set_sensitive (ats, 0);
1111 }
1112 return ats;
1113 }
1114}
1115
1127GtkWidget * menump (glwin * view, gchar * ncm, int mid, int id, int cid)
1128{
1129 GtkWidget * map = create_menu_item (TRUE, ncm);
1130 GtkWidget * mapm = gtk_menu_new ();
1131 gtk_menu_item_set_submenu ((GtkMenuItem *)map, mapm);
1132 gtk_menu_shell_append ((GtkMenuShell *)mapm, mapw(view, mid, id, 0, cid, "Atomic Species"));
1133 GtkWidget * cp = create_menu_item (FALSE, "Atomic Coordination");
1134 gtk_menu_shell_append ((GtkMenuShell *)mapm, cp);
1135 GtkWidget * mapn = gtk_menu_new ();
1136 gtk_menu_item_set_submenu ((GtkMenuItem *)cp, mapn);
1137 gtk_menu_shell_append ((GtkMenuShell *)mapn, mapw(view, mid, id, 1, cid, "Total"));
1138 gtk_menu_shell_append ((GtkMenuShell *)mapn, mapw(view, mid, id, 2, cid, "Partial"));
1139 gtk_menu_shell_append ((GtkMenuShell *)mapm, mapw(view, mid, id, 3, cid, "Fragment(s)"));
1140 gtk_menu_shell_append ((GtkMenuShell *)mapm, mapw(view, mid, id, 4, cid, "Molecule(s)"));
1141 gtk_menu_shell_append ((GtkMenuShell *)mapm, mapw(view, mid, id, 5, cid, "Force Field (DL_POLY)"));
1142 if (id == 0)
1143 {
1144 gtk_menu_shell_append ((GtkMenuShell *)mapm, mapw(view, mid, id, 6, cid, "Custom"));
1145 }
1146 else
1147 {
1148 gtk_menu_shell_append ((GtkMenuShell *)mapm, mapw(view, mid, id, 6, cid, "Use Atom(s) Custom Map"));
1149 }
1150 return map;
1151}
1152
1161GtkWidget * menu_map (glwin * view, int id)
1162{
1163 GtkWidget * menum = gtk_menu_new ();
1164 gtk_menu_shell_append ((GtkMenuShell *)menum, menump(view, "Atoms & bonds", id, 0, view -> anim -> last -> img -> color_map[0]));
1165 gtk_menu_shell_append ((GtkMenuShell *)menum, menump(view, "Polyhedra", id, 1, view -> anim -> last -> img -> color_map[1]));
1166 widget_set_sensitive (menum, get_project_by_id(view -> proj) -> nspec);
1167 return menum;
1168}
1169#else
1179G_MODULE_EXPORT void change_color_radio (GSimpleAction * action, GVariant * parameter, gpointer data)
1180{
1181 glwin * view = (glwin *)data;
1182 const gchar * color = g_variant_get_string (parameter, NULL);
1183 int lgt = strlen (color);
1184 gchar * name = g_strdup_printf ("%c%c", color[lgt-2], color[lgt-1]);
1185 if (g_strcmp0(name, ".1") == 0)
1186 {
1187 g_free (name);
1188 name = g_strdup_printf ("%.*s", 8, color);
1189 if (g_strcmp0(name, "set-amap") == 0)
1190 {
1191 g_free (name);
1192 name = g_strdup_printf ("%.*s.0", lgt-2, color);
1193 g_action_group_activate_action ((GActionGroup *)view -> action_group, "set-amap", g_variant_new_string((const gchar *)name));
1194 }
1195 else
1196 {
1197 g_free (name);
1198 name = g_strdup_printf ("%.*s.0", lgt-2, color);
1199 g_action_group_activate_action ((GActionGroup *)view -> action_group, "set-pmap", g_variant_new_string((const gchar *)name));
1200 }
1201 g_free (name);
1202 }
1203 else
1204 {
1205 int i;
1206 gchar * dot = g_strdup_printf ("%c", color[lgt-4]);
1207 gchar * col;
1208 if (g_strcmp0(dot, ".") == 0)
1209 {
1210 col = g_strdup_printf ("%c", color[lgt-3]);
1211 }
1212 else
1213 {
1214 col = g_strdup_printf ("%c%c", color[lgt-4], color[lgt-3]);
1215 }
1216 i = (int)atof(col);
1217 set_color_map (NULL, & view -> colorp[i][0]);
1218 g_free (dot);
1219 g_free (col);
1220 g_action_change_state (G_ACTION (action), parameter);
1221 }
1222}
1223
1234GMenu * menump (glwin * view, int popm, int mid, int cid)
1235{
1236 gchar * mapname[2] = {"amap", "pmap"};
1237 gboolean sensitive;
1238 GMenu * menu = g_menu_new ();
1239 append_opengl_item (view, menu, "Atomic Species", mapname[mid], popm, mid*ATOM_MAPS, NULL, IMG_NONE, NULL,
1240 FALSE, G_CALLBACK(change_color_radio), (gpointer)view, FALSE, (cid == 0) ? TRUE : FALSE, TRUE, TRUE);
1241 GMenu * menuf = g_menu_new ();
1242 append_opengl_item (view, menuf, "Total(s)", mapname[mid], popm, mid*ATOM_MAPS+1, NULL, IMG_NONE, NULL,
1243 FALSE, G_CALLBACK(change_color_radio), (gpointer)view, FALSE, (cid == 1) ? TRUE : FALSE, TRUE, TRUE);
1244 append_opengl_item (view, menuf, "Partial(s)", mapname[mid], popm, mid*ATOM_MAPS+2, NULL, IMG_NONE, NULL,
1245 FALSE, G_CALLBACK(change_color_radio), (gpointer)view, FALSE, (cid == 2) ? TRUE : FALSE, TRUE, TRUE);
1246 append_submenu (menu, "Atomic Coordinations", menuf);
1247 g_object_unref (menuf);
1248
1249 sensitive = view -> adv_bonding[0];
1250 append_opengl_item (view, menu, "Fragment(s)", mapname[mid], popm, mid*ATOM_MAPS+3, NULL, IMG_NONE, NULL,
1251 FALSE, G_CALLBACK(change_color_radio), (gpointer)view, FALSE, (cid == 3) ? TRUE : FALSE, TRUE, sensitive);
1252 sensitive = view -> adv_bonding[1];
1253 append_opengl_item (view, menu, "Molecule(s)", mapname[mid], popm, mid*ATOM_MAPS+4, NULL, IMG_NONE, NULL,
1254 FALSE, G_CALLBACK(change_color_radio), (gpointer)view, FALSE, (cid == 4) ? TRUE : FALSE, TRUE, sensitive);
1255 sensitive = (get_project_by_id(view -> proj) -> force_field[0]) ? TRUE : FALSE;
1256 append_opengl_item (view, menu, "Force Field (DL_POLY)", mapname[mid], popm, mid*ATOM_MAPS+5, NULL, IMG_NONE, NULL,
1257 FALSE, G_CALLBACK(change_color_radio), (gpointer)view, FALSE, (cid == 5) ? TRUE : FALSE, TRUE, sensitive);
1258 sensitive = (! mid) ? TRUE : (view -> custom_map) ? TRUE : FALSE;
1259 append_opengl_item (view, menu, (! mid) ? "Custom" : "Use Atom(s) Custom Map", mapname[mid], popm, mid*ATOM_MAPS+6, NULL, IMG_NONE, NULL,
1260 FALSE, G_CALLBACK(change_color_radio), (gpointer)view, FALSE, (cid == 6) ? TRUE : FALSE, TRUE, sensitive);
1261 return menu;
1262}
1263
1272GMenu * menu_map (glwin * view, int popm)
1273{
1274 GMenu * menu = g_menu_new ();
1275 append_submenu (menu, "Atoms & Bonds", menump(view, popm, 0, view -> anim -> last -> img -> color_map[0]));
1276 append_submenu (menu, "Polyhedra", menump(view, popm, 1, view -> anim -> last -> img -> color_map[1]));
1277 return menu;
1278}
1279#endif
integer(kind=c_int) function bonding(scf, sbf, adv, bdist, bmin, delt_ij, sfil)
Definition bonds.F90:22
int open_save(FILE *fp, int i, int pid, int aid, int npi, gchar *pfile)
open or save project file
Definition callbacks.c:174
integer(kind=c_int) function chemistry()
Definition chemistry.F90:22
color colorp[64]
void label(cairo_t *cr, double val, int axe, int p, project *this_proj)
draw axis label
Definition labels.c:56
ColRGBA col
Definition d_measures.c:77
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
float * duplicate_float(int num, float *old_val)
copy a list of float
Definition global.c:604
FILE * fp
gboolean reading_input
Definition global.c:182
GtkWidget * MainWindow
Definition global.c:214
float * allocfloat(int val)
allocate a float * pointer
Definition global.c:410
Global variable declarations Global convenience function declarations Global data structure defin...
void run_this_gtk_dialog(GtkWidget *dial, GCallback handler, gpointer data)
run a GTK (3 and 4) basic GtkDialog
Definition gtk-misc.c:472
@ IMG_NONE
Definition global.h:232
@ IMG_STOCK
Definition global.h:236
void file_chooser_set_current_folder(GtkFileChooser *chooser)
set current folder in a GtkFilechooser
Definition gtk-misc.c:2164
GtkWidget * create_entry(GCallback handler, int dim, int cdim, gboolean key_release, gpointer data)
Create a GtkEntry.
Definition gtk-misc.c:1294
void update_entry_double(GtkEntry *entry, double doubleval)
update the content of a GtkEntry as double
Definition gtk-misc.c:613
GtkWidget * create_scroll(GtkWidget *box, int dimx, int dimy, int shadow)
create a scroll window
Definition gtk-misc.c:1940
GtkWidget * dialogmodal(gchar *str, GtkWindow *parent)
Create a new dialog modal window.
Definition gtk-misc.c:490
GtkWidget * gtk3_menu_item(GtkWidget *menu, gchar *name, int icon_format, gpointer item_icon, GCallback handler, gpointer data, gboolean accel, guint key, GdkModifierType mod, gboolean check, gboolean radio, gboolean status)
project * proj
gchar * file_chooser_get_file_name(GtkFileChooser *chooser)
get a file name from a GtkFileChooser (single file selected)
Definition gtk-misc.c:2112
const gchar * entry_get_text(GtkEntry *entry)
get the text in a GtkEntry
Definition gtk-misc.c:577
#define EDITA
Definition global.h:174
void append_submenu(GMenu *menu, const gchar *label, GMenu *submenu)
append a GMenuItem with a subenu to a GMenu, and use markup for the GMenuItem
Definition gui.c:602
GtkWidget * spin_button(GCallback handler, double value, double start, double end, double step, int digits, int dim, gpointer data)
create a spin button
Definition gtk-misc.c:1752
#define FOPEN
Definition global.h:180
@ CONTAINER_SCR
Definition global.h:223
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:1843
GtkWidget * dialog_get_content_area(GtkWidget *widg)
prepare GtkWidget to insert content in a GtkDialog window
Definition gtk-misc.c:805
GtkWidget * markup_label(gchar *text, int dimx, int dimy, float ax, float ay)
Definition gtk-misc.c:1565
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:279
ColRGBA get_button_color(GtkColorChooser *colob)
get the ColRGBA color from a GtkColorChooser button
Definition gtk-misc.c:2212
void widget_set_sensitive(GtkWidget *widg, gboolean sensitive)
Set sensitivity for a GtkWidget, ensuring it is a GtkWidget.
Definition gtk-misc.c:186
void destroy_this_dialog(GtkDialog *dialog)
destroy a GtkDialog
Definition gtk-misc.c:2041
GtkWidget * create_hbox(int spacing)
create a GtkBox with horizontal orientation
Definition gtk-misc.c:793
GtkWidget * create_menu_item(gboolean add_mnemo, gchar *action)
GtkWidget * destroy_this_widget(GtkWidget *widg)
destroy a GtkWidget
Definition gtk-misc.c:2010
GtkWidget * color_button(ColRGBA col, gboolean alpha, int dimx, int dimy, GCallback handler, gpointer data)
create a color selection button
Definition gtk-misc.c:1708
void provide_gtk_css(gchar *css)
create a css provider based on the css data
Definition gtk-misc.c:1986
#define min(a, b)
Definition global.h:75
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:206
GtkWidget * create_vbox(int spacing)
create a GtkBox with vertical orientation
Definition gtk-misc.c:781
ColRGBA * duplicate_color(int num, ColRGBA *col)
duplicate a ColRGBA pointer
Definition gtk-misc.c:1582
GtkWidget * create_file_chooser(const gchar *title, GtkWindow *parent, GtkFileChooserAction act, const gchar *act_name)
create a GtkFileChooser, utility to select file(s)
Definition gtk-misc.c:2199
void destroy_this_native_dialog(GtkNativeDialog *dialog)
destroy a GtkNativeDialog
Definition gtk-misc.c:2060
void show_the_widgets(GtkWidget *widg)
show GtkWidget
Definition gtk-misc.c:169
project * get_project_by_id(int p)
get project pointer using id number
Definition project.c:120
#define max(a, b)
Definition global.h:74
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
action
Definition glview.h:189
@ NONE
Definition glview.h:172
#define POLY_MAPS
Definition glwin.h:62
shaders
The different types of shaders in the atomes program.
Definition glwin.h:88
@ BONDS
Definition glwin.h:90
@ LABEL
Definition glwin.h:98
@ POLYS
Definition glwin.h:92
@ ATOMS
Definition glwin.h:89
#define ATOM_MAPS
Definition glwin.h:61
Function declarations for the creation of the OpenGL window.
void append_opengl_item(glwin *view, GMenu *menu, const gchar *name, gchar *key, int mpop, int item_id, gchar *accel, int image_format, gpointer icon, gboolean custom, GCallback handler, gpointer data, gboolean check, gboolean status, gboolean radio, gboolean sensitive)
void show_error(char *error, int val, GtkWidget *win)
show error message
Definition interface.c:293
gboolean ask_yes_no(gchar *title, gchar *text, int type, GtkWidget *widg)
ask yes or no for something: prepare dialog
Definition interface.c:356
Messaging function declarations.
GtkWidget * vcbox
Definition m_map.c:86
GtkWidget * create_map_buttons()
create custom color map position and color buttons
Definition m_map.c:367
GtkWidget * map_but[3]
Definition m_map.c:82
GtkWidget * create_css_color_bar(colormap *map)
create the custom color map visualization widget
Definition m_map.c:99
G_MODULE_EXPORT void edit_data_map(GtkWidget *but, gpointer data)
edit color map - creating the dialog
Definition m_map.c:735
GtkWidget * vbbox
Definition m_map.c:87
gboolean use_custom_color_map(int p)
use custom color map - creating the dialog
Definition m_map.c:979
colormap * the_map
Definition m_map.c:84
G_MODULE_EXPORT void update_cmin_max(GtkEntry *res, gpointer data)
update color map min / max
Definition m_map.c:431
G_MODULE_EXPORT void open_save_data_map(GtkWidget *but, gpointer data)
open / save color map data - creating the dialog
Definition m_map.c:882
gboolean cmap_changed
Definition m_map.c:81
gboolean res_use_map
Definition m_map.c:948
float * tmp_data
Definition m_map.c:90
GMenu * menump(glwin *view, int popm, int mid, int cid)
create the 'Color Scheme(s) - > *' submenus - GTK4
Definition m_map.c:1234
G_MODULE_EXPORT void add_map_points(GtkSpinButton *res, gpointer data)
add point to the custom color map
Definition m_map.c:411
G_MODULE_EXPORT void set_point_position(GtkSpinButton *res, gpointer data)
update color map point position
Definition m_map.c:314
void fill_map_model(GtkTreeStore *store, project *this_proj)
fill color map tree strore
Definition m_map.c:596
G_MODULE_EXPORT void change_color_radio(GSimpleAction *action, GVariant *parameter, gpointer data)
change color map callback - GTK4
Definition m_map.c:1179
G_MODULE_EXPORT void edit_map_cell(GtkCellRendererText *cell, gchar *path_string, gchar *new_text, gpointer data)
render color map tree store cell
Definition m_map.c:638
dint osmap
Definition m_map.c:813
gboolean setup_custom_color_map(float *data, project *this_proj, gboolean init)
prepare the custom color map data
Definition m_map.c:211
G_MODULE_EXPORT void custom_mize_map(GtkWidget *but, gpointer data)
customize the color map - creating the dialog
Definition m_map.c:502
GtkWidget * color_fix
Definition m_map.c:88
GtkTreeStore * map_model
Definition m_map.c:83
GtkWidget * color_bar
Definition m_map.c:89
G_MODULE_EXPORT void run_edit_data_map(GtkDialog *win, gint response_id, gpointer data)
edit color map - running the dialog
Definition m_map.c:713
GMenu * menu_map(glwin *view, int popm)
create the 'OpenGL -> Color Scheme(s)' submenu - GTK4
Definition m_map.c:1272
void init_map_range(colormap *map, int pts)
initialize custom color map
Definition m_map.c:154
colormap * tmp_map
Definition m_map.c:85
const gchar * dfi[2]
Definition main-b.c:75
G_MODULE_EXPORT void set_color_map(GtkWidget *widg, gpointer data)
set color map callback
Definition m_map.c:1011
void update_color_map()
update color map visualization widget
Definition m_map.c:392
colormap * allocate_color_map(int pts, project *this_proj)
allocate custom color map data
Definition m_map.c:188
gboolean open_save_map(FILE *fp, int act, project *this_proj)
open or save a custom color map to file
Definition m_map.c:769
GtkWidget * create_map_tree(project *this_proj)
create color map tree view
Definition m_map.c:674
G_MODULE_EXPORT void run_custom_mize_map(GtkDialog *win, gint response_id, gpointer data)
customize the color map - running the dialog
Definition m_map.c:474
G_MODULE_EXPORT void run_use_color_map(GtkDialog *win, gint response_id, gpointer data)
use custom color map - running the dialog
Definition m_map.c:959
G_MODULE_EXPORT void set_point_color(GtkColorChooser *colob, gpointer data)
select color map point color
Definition m_map.c:352
G_MODULE_EXPORT void run_open_save_data_map(GtkDialog *info, gint response_id, gpointer data)
open / save color map data - running the dialog GTK3
Definition m_map.c:838
Function declarations for reading atomes project file Function declarations for saving atomes proje...
Definition global.h:91
int b
Definition global.h:93
int a
Definition global.h:92
Definition glwin.h:875
Definition global.h:98
int b
Definition tab-1.c:95
int a
Definition tab-1.c:95
int status
Definition w_advance.c:160
GtkFileFilter * filter1
Definition w_data.c:52
GtkFileFilter * filter2
Definition w_data.c:52
GtkWidget * res[2]
Definition w_encode.c:212
GtkWidget * hbox
Definition workspace.c:71
GtkWidget * img
Definition workspace.c:70
GtkWidget * vbox
Definition workspace.c:72