atomes 1.3.1
atomes: an atomic scale modeling tool box
Loading...
Searching...
No Matches
tab-2.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
21
22/*
23* This file: 'tab-2.c'
24*
25* Contains:
26*
27
28 - The 2nd tab of the curve layout edition dialog
29
30*
31* List of functions:
32
33 void set_data_style (gpointer data);
34
35 static void fill_org_model (GtkListStore * store, gpointer data);
36
37 G_MODULE_EXPORT void set_data_glyph (GtkComboBox * gbox, gpointer data);
38 G_MODULE_EXPORT void set_data_dash (GtkComboBox * gbox, gpointer data);
39 G_MODULE_EXPORT void set_data_color (GtkColorChooser * colob, gpointer data);
40 G_MODULE_EXPORT void set_data_thickness (GtkEntry * thickd, gpointer data);
41 G_MODULE_EXPORT void set_data_glyph_size (GtkEntry * glsize, gpointer data);
42 G_MODULE_EXPORT void set_data_hist_width (GtkEntry * entry, gpointer data);
43 G_MODULE_EXPORT void set_data_hist_opac (GtkEntry * entry, gpointer data);
44 G_MODULE_EXPORT void set_data_hist_pos (GtkComboBox * gbox, gpointer data);
45 G_MODULE_EXPORT void set_data_glyph_freq (GtkEntry * glfreq, gpointer data);
46 G_MODULE_EXPORT void choose_set (GtkComboBox * box, gpointer data);
47 G_MODULE_EXPORT void set_data_aspect (GtkComboBox * box, gpointer data);
48 G_MODULE_EXPORT void move_back_front (GtkTreeModel * tree_model, GtkTreePath * path, gpointer data);
49 G_MODULE_EXPORT void set_bshift (GtkCheckButton * shift, gpointer data);
50 G_MODULE_EXPORT void set_bshift (GtkToggleButton * shift, gpointer data);
51
52 GtkWidget * create_org_list (gpointer data);
53 GtkWidget * create_tab_2 (gpointer data);
54
55 DataLayout * get_extra_layout (gpointer data, int i);
56 DataLayout * duplicate_curve_layout (DataLayout * old_layout);
57
58*/
59
60#ifdef HAVE_CONFIG_H
61# include <config.h>
62#endif
63
64#include <gtk/gtk.h>
65#include <cairo.h>
66#include <cairo-pdf.h>
67#include <cairo-svg.h>
68#include <string.h>
69#include <stdlib.h>
70#include <math.h>
71
72#include "global.h"
73#include "interface.h"
74#include "callbacks.h"
75#include "project.h"
76#include "curve.h"
77
78GtkTreeModel * orgmodel;
79
95cairo_surface_t * draw_surface (int aspect, double hwidth, double hopac, int da, double ti, ColRGBA dcol, ColRGBA bcol, int tglyph, double tgsize)
96{
97 cairo_surface_t * cst;
98 cairo_t * tcst;
99 curve_dash * tdash;
100 double x, y;
101 double x1, x2, y1, y2;
102 switch (aspect)
103 {
104 case 1:
105 cst = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 100, 100);
106 tcst = cairo_create(cst);
107 cairo_set_source_rgb (tcst, bcol.red, bcol.green, bcol.blue);
108 cairo_paint (tcst);
109 cairo_stroke (tcst);
110 cairo_set_source_rgba (tcst, dcol.red, dcol.green, dcol.blue, hopac);
111 x1 = (100.0-hwidth*50.0)/2.0;
112 x2 = hwidth*50.0;
113 y1 = 15.0;
114 y2 = 70.0;
115 cairo_rectangle (tcst, x1, y1, x2, y2);
116 cairo_fill (tcst);
117 cairo_set_source_rgba (tcst, dcol.red, dcol.green, dcol.blue, 1.0);
118 cairo_stroke (tcst);
119 if (da > 0)
120 {
121 tdash = selectdash (da);
122 cairo_set_dash (tcst, tdash -> a, tdash -> b, 0);
123 cairo_set_line_width (tcst, ti);
124 x2 += x1;
125 y2 = 100 - y1;
126 cairo_move_to (tcst, x1, y2);
127 cairo_line_to (tcst, x1, y1);
128 cairo_move_to (tcst, x1, y1);
129 cairo_line_to (tcst, x2, y1);
130 cairo_move_to (tcst, x2, y1);
131 cairo_line_to (tcst, x2, y2);
132 cairo_stroke (tcst);
133 g_free (tdash);
134 }
135 break;
136 default:
137 cst = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 100, 30);
138 tcst = cairo_create(cst);
139 cairo_set_source_rgb (tcst, bcol.red, bcol.green, bcol.blue);
140 cairo_paint (tcst);
141 cairo_stroke (tcst);
142 if (da > 0)
143 {
144 tdash = selectdash (da);
145 cairo_set_dash (tcst, tdash -> a, tdash -> b, 0);
146 cairo_set_source_rgb (tcst, dcol.red, dcol.green, dcol.blue);
147 cairo_set_line_width (tcst, ti);
148 cairo_move_to (tcst, 0, 15);
149 cairo_line_to (tcst, 100, 15);
150 cairo_stroke (tcst);
151 g_free (tdash);
152 }
153 x = 25.0;
154 y = 15.0;
155 draw_glyph (tcst, tglyph, x, y, dcol, tgsize);
156 x = 75.0;
157 draw_glyph (tcst, tglyph, x, y, dcol, tgsize);
158 break;
159 }
160 cairo_destroy (tcst);
161 return cst;
162}
163
172DataLayout * get_extra_layout (gpointer data, int i)
173{
174 int j;
175 CurveExtra * ctmp = get_curve_from_pointer (data) -> extrac -> first;
176 for (j=0; j<i; j++)
177 {
178 ctmp = ctmp -> next;
179 }
180 return ctmp -> layout;
181}
182
190void set_data_style (gpointer data)
191{
192 int i;
193 cairo_surface_t * pix;
194 Curve * this_curve = get_curve_from_pointer (data);
195 i = combo_get_active (this_curve -> curve_edit -> setcolorbox);
197 if (i > 0)
198 {
199 layout = get_extra_layout (data, i-1);
200 }
201 else
202 {
203 layout = this_curve -> layout;
204 }
205 pix = draw_surface (layout -> aspect,
206 layout -> hwidth,
207 layout -> hopac,
208 layout -> dash,
209 layout -> thickness,
210 layout -> datacolor,
211 this_curve -> backcolor,
212 layout -> glyph,
213 layout -> gsize);
214 this_curve -> curve_edit -> stylearea = destroy_this_widget (this_curve -> curve_edit -> stylearea);
215 this_curve -> curve_edit -> stylearea = create_image_from_data (IMG_SURFACE, pix);
216 cairo_surface_destroy (pix);
217 show_the_widgets (this_curve -> curve_edit -> stylearea);
218#ifdef GTK4
219 gtk_widget_set_hexpand (this_curve -> curve_edit -> stylearea, TRUE);
220#endif
221 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, this_curve -> curve_edit -> pixarea, this_curve -> curve_edit -> stylearea, TRUE, TRUE, 0);
222 update_curve (data);
223}
224
233G_MODULE_EXPORT void set_data_glyph (GtkComboBox * gbox, gpointer data)
234{
235 int i, j;
236 curve_edition * cedit = get_curve_from_pointer(data) -> curve_edit;
237 i = combo_get_active (cedit -> setcolorbox);
238 j = combo_get_active ((GtkWidget *)gbox);
239 if (i > 0)
240 {
241 get_extra_layout (data, i-1) -> glyph = j;
242 }
243 else
244 {
245 get_curve_from_pointer (data) -> layout -> glyph = j;
246 }
247 if (j == 0)
248 {
249 widget_set_sensitive (cedit -> data_glyph_size, 0);
250 widget_set_sensitive (cedit -> data_glyph_freq, 0);
251 }
252 else
253 {
254 widget_set_sensitive (cedit -> data_glyph_size, 1);
255 widget_set_sensitive (cedit -> data_glyph_freq, 1);
256 }
257 set_data_style (data);
258}
259
268G_MODULE_EXPORT void set_data_dash (GtkComboBox * gbox, gpointer data)
269{
270 int i, j;
271 curve_edition * cedit = get_curve_from_pointer(data) -> curve_edit;
272 i = combo_get_active (cedit -> setcolorbox);
273 j = combo_get_active ((GtkWidget *)gbox);
274 if (i > 0)
275 {
276 get_extra_layout (data, i-1) -> dash = j;
277 }
278 else
279 {
280 get_curve_from_pointer (data) -> layout -> dash = j;
281 }
282 if (j == 0)
283 {
284 widget_set_sensitive (cedit -> data_thickness, 0);
285 }
286 else
287 {
288 widget_set_sensitive (cedit -> data_thickness, 1);
289 }
290 set_data_style (data);
291}
292
301G_MODULE_EXPORT void set_data_color (GtkColorChooser * colob, gpointer data)
302{
303 int i;
304 i = combo_get_active (get_curve_from_pointer(data) -> curve_edit -> setcolorbox);
305 if (i > 0)
306 {
307 get_extra_layout (data, i-1) -> datacolor = get_button_color (colob);
308 }
309 else
310 {
311 get_curve_from_pointer (data) -> layout -> datacolor = get_button_color (colob);
312 }
313 set_data_style (data);
314}
315
324G_MODULE_EXPORT void set_data_thickness (GtkEntry * thickd, gpointer data)
325{
326 int i;
327 double k;
328 const gchar * wid;
329 Curve * this_curve = get_curve_from_pointer (data);
330 wid = entry_get_text (thickd);
331 k = string_to_double ((gpointer)wid);
332 i = combo_get_active (this_curve -> curve_edit -> setcolorbox);
333 if (k > 0.0)
334 {
335 if (i > 0)
336 {
337 get_extra_layout (data, i-1) -> thickness = k;
338 }
339 else
340 {
341 this_curve -> layout -> thickness = k;
342 }
343 update_entry_double (thickd, k);
344 set_data_style (data);
345 }
346 else
347 {
348 show_warning (_("Line width must be > 0.0"), this_curve -> window);
349 if (i > 0)
350 {
351 update_entry_double (thickd, get_extra_layout (data, i-1) -> thickness);
352 }
353 else
354 {
355 update_entry_double (thickd, this_curve -> layout -> thickness);
356 }
357 }
358}
359
368G_MODULE_EXPORT void set_data_glyph_size (GtkEntry * glsize, gpointer data)
369{
370 int i;
371 double k;
372 const gchar * wid;
373 Curve * this_curve = get_curve_from_pointer (data);
374 wid = entry_get_text (glsize);
375 k = string_to_double ((gpointer)wid);
376 i = combo_get_active (this_curve -> curve_edit -> setcolorbox);
377 if (k > 0.0)
378 {
379 if (i > 0)
380 {
381 get_extra_layout (data, i-1) -> gsize = k;
382 }
383 else
384 {
385 this_curve -> layout -> gsize = k;
386 }
387 update_entry_double (glsize, k);
388 set_data_style (data);
389 }
390 else
391 {
392 show_warning (_("Glyph size must be > 0.0"), this_curve -> window);
393 if (i > 0)
394 {
395 update_entry_double (glsize, get_extra_layout (data, i-1) -> gsize);
396 }
397 else
398 {
399 update_entry_double (glsize, this_curve -> layout -> gsize);
400 }
401 }
402}
403
412G_MODULE_EXPORT void set_data_hist_width (GtkEntry * entry, gpointer data)
413{
414 int i;
415 double k;
416 const gchar * wid;
417 Curve * this_curve = get_curve_from_pointer (data);
418 wid = entry_get_text (entry);
419 k = string_to_double ((gpointer)wid);
420 i = combo_get_active (this_curve -> curve_edit -> setcolorbox);
421 if (k > 0.0)
422 {
423 if (i > 0)
424 {
425 get_extra_layout (data, i-1) -> hwidth = k;
426 }
427 else
428 {
429 this_curve -> layout -> hwidth = k;
430 }
431 update_entry_double (entry, k);
432 set_data_style (data);
433 }
434 else
435 {
436 show_warning (_("Bar width must be > 0.0"), this_curve -> window);
437 if (i > 0)
438 {
439 update_entry_double (entry, get_extra_layout (data, i-1) -> hwidth);
440 }
441 else
442 {
443 update_entry_double (entry, this_curve -> layout -> hwidth);
444 }
445 }
446}
447
456G_MODULE_EXPORT void set_data_hist_opac (GtkEntry * entry, gpointer data)
457{
458 int i;
459 double k;
460 const gchar * wid;
461 Curve * this_curve = get_curve_from_pointer (data);
462 wid = entry_get_text (entry);
463 k = string_to_double ((gpointer)wid);
464 i = combo_get_active (this_curve -> curve_edit -> setcolorbox);
465 if (k >= 0.0 && k <= 1.0)
466 {
467 if (i > 0)
468 {
469 get_extra_layout (data, i-1) -> hopac = k;
470 }
471 else
472 {
473 this_curve -> layout -> hopac = k;
474 }
475 update_entry_double (entry, k);
476 set_data_style (data);
477 }
478 else
479 {
480 show_warning (_("Bar opacity must &#x2208; [0.0 - 1.0]"), this_curve -> window);
481 if (i > 0)
482 {
483 update_entry_double (entry, get_extra_layout (data, i-1) -> hopac);
484 }
485 else
486 {
487 update_entry_double (entry, this_curve -> layout -> hopac);
488 }
489 }
490}
491
500G_MODULE_EXPORT void set_data_hist_pos (GtkComboBox * gbox, gpointer data)
501{
502 int i, j;
503 i = combo_get_active (get_curve_from_pointer (data) -> curve_edit -> setcolorbox);
504 j = combo_get_active ((GtkWidget *)gbox);
505 if (i > 0)
506 {
507 get_extra_layout (data, i-1) -> hpos = j;
508 }
509 else
510 {
511 get_curve_from_pointer (data) -> layout -> hpos = j;
512 }
513 set_data_style (data);
514}
515
524G_MODULE_EXPORT void set_data_glyph_freq (GtkEntry * glfreq, gpointer data)
525{
526 int i, j;
527 const gchar * wid;
528 wid = entry_get_text (glfreq);
529 j = string_to_double ((gpointer)wid);
530 Curve * this_curve = get_curve_from_pointer (data);
531 i = combo_get_active (this_curve -> curve_edit -> setcolorbox);
532 if (j > 0)
533 {
534 if (i > 0)
535 {
536 get_extra_layout (data, i-1) -> gfreq = j;
537 }
538 else
539 {
540 this_curve -> layout -> gfreq = j;
541 }
542 update_entry_int (glfreq, j);
543 set_data_style (data);
544 }
545 else
546 {
547 show_warning (_("Glyph frequency must be > 0"), this_curve -> window);
548 if (i > 0)
549 {
550 update_entry_int (glfreq, get_extra_layout (data, i-1) -> thickness);
551 }
552 else
553 {
554 update_entry_int (glfreq, this_curve -> layout -> gfreq);
555 }
556 }
557}
558
567G_MODULE_EXPORT void choose_set (GtkComboBox * box, gpointer data)
568{
569 int i;
570 i = combo_get_active ((GtkWidget *)box);
572 if (i > 0)
573 {
574 layout = get_extra_layout (data, i-1);
575 }
576 else
577 {
579 }
580 curve_edition * cedit = get_curve_from_pointer (data) -> curve_edit;
581 GdkRGBA col = colrgba_togtkrgba (layout -> datacolor);
582 gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER(cedit -> data_color), & col);
583 combo_set_active (cedit -> data_dash, layout -> dash);
584 update_entry_double (GTK_ENTRY(cedit -> data_thickness), layout -> thickness);
585 combo_set_active (cedit -> data_glyph, layout -> glyph);
586 update_entry_double (GTK_ENTRY(cedit -> data_glyph_size), layout -> gsize);
587 update_entry_int (GTK_ENTRY(cedit -> data_glyph_freq), layout -> gfreq);
588 update_entry_double (GTK_ENTRY(cedit -> data_hist_width), layout -> hwidth);
589 update_entry_double (GTK_ENTRY(cedit -> data_hist_opac), layout -> hopac);
590 combo_set_active (cedit -> data_hist_pos, layout -> hpos);
591 combo_set_active (cedit -> data_aspect, layout -> aspect);
592 set_data_style (data);
593}
594
603G_MODULE_EXPORT void set_data_aspect (GtkComboBox * box, gpointer data)
604{
605 int i, j;
606 curve_edition * cedit = get_curve_from_pointer (data) -> curve_edit;
607 i = combo_get_active (cedit -> setcolorbox);
608 j = combo_get_active ((GtkWidget *)box);
609 if (j == 1)
610 {
611 combo_set_active (cedit -> data_glyph, 0);
612 widget_set_sensitive (cedit -> data_glyph, 0);
613 hide_the_widgets (cedit -> Glyph_box);
614 show_the_widgets (cedit -> Hist_box);
615 }
616 else
617 {
618 widget_set_sensitive (cedit -> data_glyph, 1);
619 hide_the_widgets (cedit -> Hist_box);
620 show_the_widgets (cedit -> Glyph_box);
621 }
622 if (i > 0)
623 {
624 get_extra_layout (data, i-1) -> aspect = j;
625 }
626 else
627 {
628 get_curve_from_pointer (data) -> layout -> aspect = j;
629 }
630 set_data_style (data);
631 update_curve (data);
632}
633
642static void fill_org_model (GtkListStore * store, gpointer data)
643{
644 GtkTreeIter curvelevel;
645 int i, j, k, l;
646 Curve * this_curve = get_curve_from_pointer (data);
647 gchar * str;
648 CurveExtra * ctmp;
649 ctmp = this_curve -> extrac -> first;
650 if (this_curve -> draw_id == this_curve -> extrac -> extras)
651 {
652 gtk_list_store_append (store, & curvelevel);
653 str = g_strdup_printf ("%s - %s", get_project_by_id(((tint *)data) -> a) -> name, this_curve -> name);
654 gtk_list_store_set (store, & curvelevel, 0, ((tint *)data) -> a, 1, ((tint *)data) -> b, 2, ((tint *)data) -> c, 3, str, -1);
655 g_free (str);
656 }
657 i = this_curve -> extrac -> extras;
658 while (ctmp)
659 {
660 gtk_list_store_append (store, & curvelevel);
661 j = ctmp -> id.a;
662 k = ctmp -> id.b;
663 l = ctmp -> id.c;
664 str = g_strdup_printf ("%s - %s", get_project_by_id(j) -> name, get_project_by_id(j) -> analysis[k] -> curves[l] -> name);
665 gtk_list_store_set (store, & curvelevel, 0, j, 1, k, 2, l, 3, str, -1);
666 g_free (str);
667 i --;
668 if (this_curve -> draw_id == i)
669 {
670 gtk_list_store_append (store, & curvelevel);
671 str = g_strdup_printf ("%s - %s", get_project_by_id(((tint *)data) -> a) -> name, this_curve -> name);
672 gtk_list_store_set (store, & curvelevel, 0, ((tint *)data) -> a, 1, ((tint *)data) -> b, 2, ((tint *)data) -> c, 3, str, -1);
673 g_free (str);
674 }
675 ctmp = ctmp -> next;
676 }
677}
678
687{
688 DataLayout * new_layout = g_malloc0(sizeof*new_layout);
689 new_layout -> datacolor.red = old_layout -> datacolor.red;
690 new_layout -> datacolor.green = old_layout -> datacolor.green;
691 new_layout -> datacolor.blue = old_layout -> datacolor.blue;
692 new_layout -> datacolor.alpha = 1.0;
693 new_layout -> thickness = old_layout -> thickness;
694 new_layout -> hwidth = old_layout -> hwidth;
695 new_layout -> hopac = old_layout -> hopac;
696 new_layout -> hpos = old_layout -> hpos;
697 new_layout -> dash = old_layout -> dash;
698 new_layout -> gfreq = old_layout -> gfreq;
699 new_layout -> aspect = old_layout -> aspect;
700 new_layout -> glyph = old_layout -> glyph;
701 new_layout -> gsize = old_layout -> gsize;
702 return new_layout;
703}
704
714G_MODULE_EXPORT void move_back_front (GtkTreeModel * tree_model, GtkTreePath * path, gpointer data)
715{
716 tint * cid = (tint *) data;
717 GtkTreeIter iter;
718 gboolean valid;
719 gboolean done;
720 int i, j, k, l, m;
721 tint cbid;
722 CurveExtra * ctmpa = NULL;
723 Curve * this_curve = get_curve_from_pointer (data);
724 curve_edition * cedit = this_curve -> curve_edit;
725 m = combo_get_active (cedit -> setcolorbox);
726 if (m > 0)
727 {
728 ctmpa = this_curve -> extrac -> first;
729 for (i=0; i<m-1; i++) ctmpa = ctmpa -> next;
730 cbid = ctmpa -> id;
731 }
732 l = this_curve -> extrac -> extras;
733 valid = gtk_tree_model_get_iter_first (tree_model, & iter);
734 CurveExtra * new_extra = NULL;
735 CurveExtra * tmp_extra;
736 while (valid)
737 {
738 gtk_tree_model_get (tree_model, & iter, 0, & i, 1, & j, 2, & k, -1);
739 if (i == cid -> a && j == cid -> b && k == cid -> c)
740 {
741 // To set the draw order for the host curve
742 this_curve -> draw_id = l;
743 }
744 else
745 {
746 l --;
747 ctmpa = this_curve -> extrac -> first;
748 done = FALSE;
749 while (! done && ctmpa)
750 {
751 if (ctmpa -> id.a == i && ctmpa -> id.b == j && ctmpa -> id.c == k)
752 {
753 done = TRUE;
754 }
755 else
756 {
757 ctmpa = ctmpa -> next;
758 done = FALSE;
759 }
760 }
761 if (ctmpa)
762 {
763 if (new_extra == NULL)
764 {
765 new_extra = g_malloc0(sizeof*tmp_extra);
766 tmp_extra = new_extra;
767 }
768 else
769 {
770 tmp_extra -> next = g_malloc0(sizeof*tmp_extra -> next);
771 tmp_extra -> next -> prev = tmp_extra;
772 tmp_extra = tmp_extra -> next;
773 }
774 tmp_extra -> id = ctmpa -> id;
775 tmp_extra -> layout = duplicate_curve_layout (ctmpa -> layout);
776 }
777 }
778 valid = gtk_tree_model_iter_next (tree_model, & iter);
779 }
780 ctmpa = this_curve -> extrac -> first -> next;
781 while (ctmpa)
782 {
783 if (ctmpa -> prev) g_free (ctmpa -> prev);
784 ctmpa = ctmpa -> next;
785 }
786 this_curve -> extrac -> first = new_extra;
787 this_curve -> extrac -> last = tmp_extra;
788 if (m > 0)
789 {
790 ctmpa = this_curve -> extrac -> first;
791 m = 0;
792 while (ctmpa)
793 {
794 if (cbid.a == ctmpa -> id.a && cbid.b == ctmpa -> id.b && cbid.c == ctmpa -> id.c) break;
795 m ++;
796 ctmpa = ctmpa -> next;
797 }
798 }
799 cedit -> setcolorbox = destroy_this_widget (cedit -> setcolorbox);
800 cedit -> setcolorbox = create_combo ();
801 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, cedit -> thesetbox, cedit -> setcolorbox, FALSE, FALSE, 0);
802 show_the_widgets (cedit -> setcolorbox);
803 prepbox (data);
804 combo_set_active (cedit -> setcolorbox, m);
805 choose_set (GTK_COMBO_BOX(cedit -> setcolorbox), data);
806 update_curve (data);
807}
808
820void curve_set_markup (GtkTreeViewColumn * col, GtkCellRenderer * renderer, GtkTreeModel * mod, GtkTreeIter * iter, gpointer data)
821{
822 set_renderer_markup (mod, iter, renderer, 3);
823}
824
832GtkWidget * create_org_list (gpointer data)
833{
834 int i;
835 GtkTreeViewColumn * orgcol[4];
836 GtkCellRenderer * orgcell[4];
837 gchar * ctype[4] = {"text", "text", "text", "text"};
838 GType col_type[4] = {G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_STRING};
839 GtkListStore * orglist = gtk_list_store_newv (4, col_type);
840 orgmodel = GTK_TREE_MODEL(orglist);
841 curve_edition * cedit = get_curve_from_pointer (data) -> curve_edit;
842 cedit -> orgtree = gtk_tree_view_new_with_model(orgmodel);
843 for (i=0; i<4; i++)
844 {
845 orgcell[i] = gtk_cell_renderer_text_new();
846 orgcol[i] = gtk_tree_view_column_new_with_attributes((i<3) ? " " : _("Data set(s)"), orgcell[i], ctype[i], i, NULL);
847 gtk_tree_view_append_column(GTK_TREE_VIEW(cedit -> orgtree), orgcol[i]);
848 if (i < 3)
849 {
850 gtk_tree_view_column_set_visible (orgcol[i], FALSE);
851 }
852 else
853 {
854 gtk_tree_view_column_set_cell_data_func (orgcol[i], orgcell[i], curve_set_markup, NULL, NULL);
855 }
856 }
857 fill_org_model (orglist, data);
858 g_object_unref (orglist);
859 g_signal_connect (G_OBJECT(orgmodel), "row-deleted", G_CALLBACK(move_back_front), data);
860 gtk_tree_view_expand_all (GTK_TREE_VIEW(cedit -> orgtree));
861 gtk_tree_view_set_activate_on_single_click (GTK_TREE_VIEW(cedit -> orgtree), TRUE);
862/*
863#ifdef GTK4
864 add_widget_gesture_and_key_action (cedit -> orgtree, "orgtree-pressed", NULL, NULL,
865 NULL, NULL, NULL, NULL, NULL, NULL,
866 NULL, NULL, NULL, NULL, NULL, NULL);
867#endif
868*/
869 gtk_tree_view_set_reorderable (GTK_TREE_VIEW(cedit -> orgtree), TRUE);
870 return cedit -> orgtree;
871}
872
873#ifdef GTK4
882G_MODULE_EXPORT void set_bshift (GtkCheckButton * shift, gpointer data)
883#else
892G_MODULE_EXPORT void set_bshift (GtkToggleButton * shift, gpointer data)
893#endif
894{
895 get_curve_from_pointer (data) -> bshift = button_get_status ((GtkWidget *)shift);
896 update_curve (data);
897}
898
907GtkWidget * create_tab_2 (curve_edition * cedit, gpointer data)
908{
909 GtkWidget * dhbox;
910 Curve * this_curve = get_curve_from_pointer (data);
911 int i;
912
913 GtkWidget * databox = create_vbox (BSEP);
914 cedit -> thesetbox = create_hbox (0);
915 add_box_child_start (GTK_ORIENTATION_VERTICAL, databox, cedit -> thesetbox, FALSE, FALSE, 10);
916 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, cedit -> thesetbox, markup_label(_("<b>Select set: </b>"), -1, -1, 0.0, 0.5), FALSE, FALSE, 20);
917 cedit -> setcolorbox = create_combo ();
918 prepbox (data);
919 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, cedit -> thesetbox, cedit -> setcolorbox, FALSE, FALSE, 10);
920
921 cedit -> pixarea = create_hbox (0);
922 add_box_child_start (GTK_ORIENTATION_VERTICAL, databox, cedit -> pixarea, FALSE, FALSE, 10);
923 dhbox = create_vbox (BSEP);
924 gtk_widget_set_size_request (dhbox, -1, 270);
925 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, cedit -> pixarea, dhbox, FALSE, FALSE, 0);
926
927 cedit -> data_aspect = create_combo ();
928 combo_text_append (cedit -> data_aspect, "x/y");
929 combo_text_append (cedit -> data_aspect, _("Bar"));
930 combo_set_active (cedit -> data_aspect, this_curve -> layout -> aspect);
931 gtk_widget_set_size_request (cedit -> data_aspect, 120, -1);
932 g_signal_connect (G_OBJECT(cedit -> data_aspect), "changed", G_CALLBACK(set_data_aspect), data);
933 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, bbox (dhbox, _("Plot type:")), cedit -> data_aspect, FALSE, FALSE, 0);
934 if (((tint *)data) -> b == MSD)
935 {
936 widget_set_sensitive (cedit -> data_aspect, 0);
937 }
938
939// Data color
940 cedit -> data_color = color_button (this_curve -> layout -> datacolor, TRUE, 120, -1, G_CALLBACK(set_data_color), data);
941 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, bbox (dhbox, _("Data color:")), cedit -> data_color, FALSE, FALSE, 0);
942
943// Line style
944 cedit -> data_dash = create_combo ();
945 combo_text_append (cedit -> data_dash, _("No Line"));
946 for ( i=1 ; i < ndash ; i++)
947 {
948 combo_text_append (cedit -> data_dash, g_strdup_printf("%d", i));
949 }
950 gtk_widget_set_size_request (cedit -> data_dash, 120, -1);
951 combo_set_active (cedit -> data_dash, this_curve -> layout -> dash);
952 g_signal_connect (G_OBJECT(cedit -> data_dash), "changed", G_CALLBACK(set_data_dash), data);
953 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, bbox (dhbox, _("Line style:")), cedit -> data_dash, FALSE, FALSE, 0);
954
955// Line line width
956 cedit -> data_thickness = create_entry (G_CALLBACK(set_data_thickness), 120, 10, FALSE, data);
957 update_entry_double (GTK_ENTRY(cedit -> data_thickness), this_curve -> layout -> thickness);
958 if (this_curve -> layout -> dash == 0)
959 {
960 widget_set_sensitive (cedit -> data_thickness, 0);
961 }
962 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, bbox (dhbox, _("Line width:")), cedit -> data_thickness, FALSE, FALSE, 0);
963
964 GtkWidget * data_shape = create_vbox (BSEP);
965 add_box_child_start (GTK_ORIENTATION_VERTICAL, dhbox, data_shape, FALSE, FALSE, 0);
966 cedit -> Glyph_box = create_vbox (BSEP);
967 add_box_child_start (GTK_ORIENTATION_VERTICAL, data_shape, cedit -> Glyph_box, FALSE, FALSE, 0);
968// Glyph type
969 cedit -> data_glyph = create_combo ();
970 combo_text_append (cedit -> data_glyph, _("No Glyph"));
971 for ( i=1 ; i < nglyph ; i++)
972 {
973 combo_text_append (cedit -> data_glyph, g_strdup_printf("%d", i));
974 }
975 gtk_widget_set_size_request (cedit -> data_glyph, 120, -1);
976 combo_set_active (cedit -> data_glyph, this_curve -> layout -> glyph);
977 g_signal_connect (G_OBJECT(cedit -> data_glyph), "changed", G_CALLBACK(set_data_glyph), data);
978 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, bbox (cedit -> Glyph_box, _("Glyph type:")), cedit -> data_glyph, FALSE, FALSE, 0);
979
980// Glyph size
981 cedit -> data_glyph_size = create_entry (G_CALLBACK(set_data_glyph_size), 120, 10, FALSE, data);
982 update_entry_double (GTK_ENTRY(cedit -> data_glyph_size), this_curve -> layout -> gsize);
983 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, bbox (cedit -> Glyph_box, _("Glyph size:")), cedit -> data_glyph_size, FALSE, FALSE, 0);
984
985// Glyph frequency
986 cedit -> data_glyph_freq = create_entry (G_CALLBACK(set_data_glyph_freq), 120, 10, FALSE, data);
987 update_entry_int (GTK_ENTRY(cedit -> data_glyph_freq), this_curve -> layout -> gfreq);
988 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, bbox (cedit -> Glyph_box, _("Glyph freq.:")), cedit -> data_glyph_freq, FALSE, FALSE, 0);
989 if (this_curve -> layout -> glyph == 0)
990 {
991 widget_set_sensitive (cedit -> data_glyph_size, 0);
992 widget_set_sensitive (cedit -> data_glyph_freq, 0);
993 }
994
995 cedit -> Hist_box = create_vbox (BSEP);
996 add_box_child_start (GTK_ORIENTATION_VERTICAL, data_shape, cedit -> Hist_box, FALSE, FALSE, 0);
997 // Histogram width
998 cedit -> data_hist_width = create_entry (G_CALLBACK(set_data_hist_width), 120, 10, FALSE, data);
999 update_entry_double (GTK_ENTRY(cedit -> data_hist_width), this_curve -> layout -> hwidth);
1000 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, bbox (cedit -> Hist_box, _("Bar width:")), cedit -> data_hist_width, FALSE, FALSE, 0);
1001 // Histogram opacity
1002 cedit -> data_hist_opac = create_entry (G_CALLBACK(set_data_hist_opac), 120, 10, FALSE, data);
1003 update_entry_double (GTK_ENTRY(cedit -> data_hist_opac), this_curve -> layout -> hopac);
1004 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, bbox (cedit -> Hist_box, _("Color opacity:")), cedit -> data_hist_opac, FALSE, FALSE, 0);
1005
1006 cedit -> data_hist_pos = create_combo ();
1007 combo_text_append (cedit -> data_hist_pos, _("Transparent"));
1008 combo_text_append (cedit -> data_hist_pos, _("Plain"));
1009 gtk_widget_set_size_request (cedit -> data_hist_pos, 120, -1);
1010 combo_set_active (cedit -> data_hist_pos, this_curve -> layout -> hpos);
1011 g_signal_connect (G_OBJECT(cedit -> data_hist_pos), "changed", G_CALLBACK(set_data_hist_pos), data);
1012 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, bbox (cedit -> Hist_box, _("Bar opacity:")), cedit -> data_hist_pos, FALSE, FALSE, 0);
1013
1014 add_box_child_start (GTK_ORIENTATION_VERTICAL, databox, gtk_separator_new (GTK_ORIENTATION_HORIZONTAL), FALSE, FALSE, 5);
1015 GtkWidget * hbox;
1016 if (((tint *)data) -> b != MSD)
1017 {
1018 hbox = create_hbox (0);
1019 add_box_child_start (GTK_ORIENTATION_VERTICAL, databox, hbox, FALSE, FALSE, 5);
1020 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox,
1021 check_button (_("Automatic <i>x axis</i> shift for bar diagram (to improve visibility)"), -1, -1, this_curve -> bshift, G_CALLBACK(set_bshift), data),
1022 FALSE, FALSE, 10);
1023 add_box_child_start (GTK_ORIENTATION_VERTICAL, databox, gtk_separator_new (GTK_ORIENTATION_HORIZONTAL), FALSE, FALSE, 5);
1024 }
1025 hbox = create_hbox (0);
1026 add_box_child_start (GTK_ORIENTATION_VERTICAL, databox, hbox, FALSE, FALSE, 10);
1027 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label(_("<b>Layers organization: </b>"), -1, -1, 0.0, 0.5), FALSE, FALSE, 20);
1028 GtkWidget * shbox = create_hbox (0);
1029 add_box_child_start (GTK_ORIENTATION_VERTICAL, databox, shbox, FALSE, FALSE, 5);
1030
1031 hbox = create_hbox (0);
1032 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, shbox, hbox, FALSE, FALSE, 75);
1033 cedit -> datascroll = create_scroll (hbox, 350, 200, GTK_SHADOW_ETCHED_IN);
1034 add_container_child (CONTAINER_SCR, cedit -> datascroll, create_org_list(data));
1035 widget_set_sensitive (cedit -> orgtree, this_curve -> extrac -> extras);
1036#ifndef GTK4
1037 gchar * str = _("\tMove up/down to adjust layer position (up to front, down to back)");
1038 add_box_child_start (GTK_ORIENTATION_VERTICAL, databox, markup_label(str, -1, -1, 0.0, 0.5), FALSE, FALSE, 5);
1039#endif
1040 return databox;
1041}
Callback declarations for main window.
G_MODULE_EXPORT void set_data_aspect(GtkComboBox *box, gpointer data)
change data aspect (x/y or histogram bars)
Definition tab-2.c:603
void prepbox(gpointer data)
prepare the curve selection combo box
Definition cedit.c:87
Curve * get_curve_from_pointer(gpointer data)
get Curve pointer from pointer
Definition curve.c:313
curve_dash * selectdash(int iddash)
setup dash pointer
Definition curve.c:135
int ndash
Definition curve.c:92
void update_curve(gpointer data)
update curve rendering
Definition curve.c:635
int nglyph
Definition curve.c:93
PangoLayout * layout
Definition curve.c:80
Variable declarations for the curve widget Functions for interactions with the curve widget.
void draw_glyph(cairo_t *in, int theglyph, double x, double y, ColRGBA gcolor, double size)
draw glyph at (x,y)
Definition glyph.c:88
ColRGBA col
Definition d_measures.c:77
int * shift
Definition d_measures.c:72
GtkTreePath * path
Definition datab.c:103
GType col_type[MAXDATA][12]
Definition dlp_field.c:946
double string_to_double(gpointer string)
convert string to double
Definition global.c:611
Global variable declarations Global convenience function declarations Global data structure defin...
@ IMG_SURFACE
Definition global.h:278
int combo_get_active(GtkWidget *combo)
retrieve the active item's position
Definition gtk-misc.c:935
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
GtkWidget * create_scroll(GtkWidget *box, int dimx, int dimy, int shadow)
create a scroll window
Definition gtk-misc.c:2139
void combo_set_active(GtkWidget *combo, int pos)
set the active item's position
Definition gtk-misc.c:958
const gchar * entry_get_text(GtkEntry *entry)
get the text in a GtkEntry
Definition gtk-misc.c:652
GdkRGBA colrgba_togtkrgba(ColRGBA col)
convert ColRGBA color to GdkRGBA color
Definition gtk-misc.c:1721
#define BSEP
Definition global.h:261
void update_entry_int(GtkEntry *entry, int intval)
update the content of a GtkEntry as int
Definition gtk-misc.c:669
void set_renderer_markup(GtkTreeModel *mod, GtkTreeIter *iter, GtkCellRenderer *renderer, int col)
set Pango text markup for a GtkCellRenderer
Definition gtk-misc.c:1764
GtkWidget * check_button(gchar *text, int dimx, int dimy, gboolean state, GCallback handler, gpointer data)
create a check button
Definition gtk-misc.c:1937
@ CONTAINER_SCR
Definition global.h:267
GtkWidget * create_combo()
create a GtkCombox widget, note deprecated in GTK4
Definition gtk-misc.c:1010
GtkWidget * markup_label(gchar *text, int dimx, int dimy, float ax, float ay)
create a GtkLabel with pango markup
Definition gtk-misc.c:1672
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
ColRGBA get_button_color(GtkColorChooser *colob)
get the ColRGBA color from a GtkColorChooser button
Definition gtk-misc.c:2406
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
GtkWidget * create_image_from_data(int format, gpointer item_image)
create Gtk image for data
Definition gtk-misc.c:1530
void combo_text_append(GtkWidget *combo, gchar *text)
append text in GtkComboBox widget
Definition gtk-misc.c:987
GtkWidget * destroy_this_widget(GtkWidget *widg)
destroy a GtkWidget
Definition gtk-misc.c:2213
GtkWidget * color_button(ColRGBA col, gboolean alpha, int dimx, int dimy, GCallback handler, gpointer data)
create a color selection button
Definition gtk-misc.c:1833
GtkWidget * bbox(GtkWidget *box, char *lab)
box creating routine, to help design faster elements for the GUI
Definition gtk-misc.c:2084
void add_container_child(int type, GtkWidget *widg, GtkWidget *child)
Add a GtkWidget into another GtkWidget.
Definition gtk-misc.c:267
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
int button_get_status(GtkWidget *button)
get status of check / toggle button
Definition gtk-misc.c:1899
#define MSD
Definition global.h:346
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 show_warning(char *warning, GtkWidget *win)
show warning
Definition interface.c:266
Messaging function declarations.
DataLayout * get_extra_layout(int i)
double y
Definition ogl_draw.c:63
double x
Definition ogl_draw.c:63
Function declarations for reading atomes project file Function declarations for saving atomes proje...
float blue
Definition global.h:138
float red
Definition global.h:136
float green
Definition global.h:137
Definition glwin.h:350
Definition global.h:118
int b
Definition global.h:120
int c
Definition global.h:121
int a
Definition global.h:119
cairo_surface_t * draw_surface(int aspect, double hwidth, double hopac, int da, double ti, ColRGBA dcol, ColRGBA bcol, int tglyph, double tgsize)
draw the data set preview
Definition tab-2.c:95
G_MODULE_EXPORT void set_data_hist_opac(GtkEntry *entry, gpointer data)
set histogram bar opacity entry callback
Definition tab-2.c:456
G_MODULE_EXPORT void set_data_hist_width(GtkEntry *entry, gpointer data)
set histogram bar width entry callback
Definition tab-2.c:412
void curve_set_markup(GtkTreeViewColumn *col, GtkCellRenderer *renderer, GtkTreeModel *mod, GtkTreeIter *iter, gpointer data)
Curve edit window, tab-2, Pango markup in tree view.
Definition tab-2.c:820
G_MODULE_EXPORT void set_data_hist_pos(GtkComboBox *gbox, gpointer data)
change histogram bar position
Definition tab-2.c:500
G_MODULE_EXPORT void choose_set(GtkComboBox *box, gpointer data)
change the data set to customize
Definition tab-2.c:567
void set_data_style(gpointer data)
update the data style widgets
Definition tab-2.c:190
G_MODULE_EXPORT void set_data_aspect(GtkComboBox *box, gpointer data)
change data aspect (x/y or histogram bars)
Definition tab-2.c:603
G_MODULE_EXPORT void set_data_thickness(GtkEntry *thickd, gpointer data)
set data thickness entry callback
Definition tab-2.c:324
DataLayout * duplicate_curve_layout(DataLayout *old_layout)
duplicate a curve layout
Definition tab-2.c:686
G_MODULE_EXPORT void move_back_front(GtkTreeModel *tree_model, GtkTreePath *path, gpointer data)
move up or down data set in the tree model to move it front or back in the data plot
Definition tab-2.c:714
DataLayout * get_extra_layout(gpointer data, int i)
retrieve the i data layout
Definition tab-2.c:172
GtkTreeModel * orgmodel
Definition tab-2.c:78
G_MODULE_EXPORT void set_bshift(GtkToggleButton *shift, gpointer data)
shift / not histogram bars toggle callback GTK3
Definition tab-2.c:892
G_MODULE_EXPORT void set_data_glyph_size(GtkEntry *glsize, gpointer data)
set glyph size entry callback
Definition tab-2.c:368
GtkWidget * create_org_list(gpointer data)
create the data set organisation widget
Definition tab-2.c:832
G_MODULE_EXPORT void set_data_glyph_freq(GtkEntry *glfreq, gpointer data)
set glyph frequency entry callback
Definition tab-2.c:524
G_MODULE_EXPORT void set_data_color(GtkColorChooser *colob, gpointer data)
set data color
Definition tab-2.c:301
GtkWidget * create_tab_2(curve_edition *cedit, gpointer data)
handle the creation of the 2nd tab of the curve edition dialog
Definition tab-2.c:907
G_MODULE_EXPORT void set_data_glyph(GtkComboBox *gbox, gpointer data)
change glyph type
Definition tab-2.c:233
G_MODULE_EXPORT void set_data_dash(GtkComboBox *gbox, gpointer data)
change data dash style
Definition tab-2.c:268
GdkPixbuf * pix
Definition workspace.c:69
GtkWidget * hbox
Definition workspace.c:71