atomes 1.1.14
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-2024 by CNRS and University of Strasbourg */
15
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 (int i);
56
57*/
58
59#ifdef HAVE_CONFIG_H
60# include <config.h>
61#endif
62
63#include <gtk/gtk.h>
64#include <cairo.h>
65#include <cairo-pdf.h>
66#include <cairo-svg.h>
67#include <string.h>
68#include <stdlib.h>
69#include <math.h>
70
71#include "global.h"
72#include "interface.h"
73#include "callbacks.h"
74#include "project.h"
75#include "curve.h"
76#include "cedit.h"
77
78GtkWidget * data_shape = NULL;
79GtkWidget * data_color = NULL;
80GtkWidget * data_aspect = NULL;
81GtkWidget * data_thickness = NULL;
82GtkWidget * data_glyph = NULL;
83GtkWidget * data_glyph_size = NULL;
84GtkWidget * data_glyph_freq = NULL;
85GtkWidget * data_hist_width = NULL;
86GtkWidget * data_hist_opac = NULL;
87GtkWidget * data_hist_pos = NULL;
88GtkWidget * data_dash = NULL;
89GtkWidget * stylearea = NULL;
90GtkWidget * pixarea = NULL;
91
92GtkWidget * Glyph_box = NULL;
93GtkWidget * Hist_box = NULL;
94
95GtkWidget * xyl[2];
96
97GtkWidget * orgtree = NULL;
98GtkTreeModel * orgmodel = NULL;
99GtkWidget * datascroll = NULL;
100
101extern qint dataxe[2];
102extern int a, b, c, d;
103
119cairo_surface_t * draw_surface (int aspect, double hwidth, double hopac, int da, double ti, ColRGBA dcol, ColRGBA bcol, int tglyph, double tgsize)
120{
121 cairo_surface_t * cst;
122 cairo_t * tcst;
123 curve_dash * tdash;
124 double x, y;
125 double x1, x2, y1, y2;
126 switch (aspect)
127 {
128 case 1:
129 cst = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 100, 100);
130 tcst = cairo_create(cst);
131 cairo_set_source_rgb (tcst, bcol.red, bcol.green, bcol.blue);
132 cairo_paint (tcst);
133 cairo_stroke (tcst);
134 cairo_set_source_rgba (tcst, dcol.red, dcol.green, dcol.blue, hopac);
135 x1 = (100.0-hwidth*50.0)/2.0;
136 x2 = hwidth*50.0;
137 y1 = 15.0;
138 y2 = 70.0;
139 cairo_rectangle (tcst, x1, y1, x2, y2);
140 cairo_fill (tcst);
141 cairo_set_source_rgba (tcst, dcol.red, dcol.green, dcol.blue, 1.0);
142 cairo_stroke (tcst);
143 if (da > 0)
144 {
145 tdash = selectdash (da);
146 cairo_set_dash (tcst, tdash -> a, tdash -> b, 0);
147 cairo_set_line_width (tcst, ti);
148 x2 += x1;
149 y2 = 100 - y1;
150 cairo_move_to (tcst, x1, y2);
151 cairo_line_to (tcst, x1, y1);
152 cairo_move_to (tcst, x1, y1);
153 cairo_line_to (tcst, x2, y1);
154 cairo_move_to (tcst, x2, y1);
155 cairo_line_to (tcst, x2, y2);
156 cairo_stroke (tcst);
157 g_free (tdash);
158 }
159 break;
160 default:
161 cst = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 100, 30);
162 tcst = cairo_create(cst);
163 cairo_set_source_rgb (tcst, bcol.red, bcol.green, bcol.blue);
164 cairo_paint (tcst);
165 cairo_stroke (tcst);
166 if (da > 0)
167 {
168 tdash = selectdash (da);
169 cairo_set_dash (tcst, tdash -> a, tdash -> b, 0);
170 cairo_set_source_rgb (tcst, dcol.red, dcol.green, dcol.blue);
171 cairo_set_line_width (tcst, ti);
172 cairo_move_to (tcst, 0, 15);
173 cairo_line_to (tcst, 100, 15);
174 cairo_stroke (tcst);
175 g_free (tdash);
176 }
177 x = 25.0;
178 y = 15.0;
179 draw_glyph (tcst, tglyph, x, y, dcol, tgsize);
180 x = 75.0;
181 draw_glyph (tcst, tglyph, x, y, dcol, tgsize);
182 break;
183 }
184 cairo_destroy (tcst);
185 return cst;
186}
187
196{
197 int j;
198 CurveExtra * ctmp = get_project_by_id(a) -> curves[b][c] -> extrac -> first;
199 for (j=0; j<i; j++)
200 {
201 ctmp = ctmp -> next;
202 }
203 return ctmp -> layout;
204}
205
213void set_data_style (gpointer data)
214{
215 int i;
216 cairo_surface_t * pix;
217 tint * cd = (tint *)data;
218 a = cd -> a;
219 b = cd -> b;
220 c = cd -> c;
221 i = gtk_combo_box_get_active (GTK_COMBO_BOX(setcolorbox));
222 project * this_proj = get_project_by_id(a);
224 if (i > 0)
225 {
226 layout = get_extra_layout (i-1);
227 }
228 else
229 {
230 layout = this_proj -> curves[b][c] -> layout;
231 }
232 pix = draw_surface (layout -> aspect,
233 layout -> hwidth,
234 layout -> hopac,
235 layout -> dash,
236 layout -> thickness,
237 layout -> datacolor,
238 this_proj -> curves[b][c] -> backcolor,
239 layout -> glyph,
240 layout -> gsize);
243 cairo_surface_destroy (pix);
244 gtk_widget_show (stylearea);
245#ifdef GTK4
246 gtk_widget_set_hexpand (stylearea, TRUE);
247#endif
248 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, pixarea, stylearea, TRUE, TRUE, 0);
249 update_curve (data);
250}
251
260G_MODULE_EXPORT void set_data_glyph (GtkComboBox * gbox, gpointer data)
261{
262 int i, j;
263 tint * cd = (tint *)data;
264 a = cd -> a;
265 b = cd -> b;
266 c = cd -> c;
267 i = gtk_combo_box_get_active (GTK_COMBO_BOX(setcolorbox));
268 j = gtk_combo_box_get_active (GTK_COMBO_BOX(gbox));
269 if (i > 0)
270 {
271 get_extra_layout (i-1) -> glyph = j;
272 }
273 else
274 {
275 get_project_by_id(a) -> curves[b][c] -> layout -> glyph = j;
276 }
277 if (j == 0)
278 {
281 }
282 else
283 {
286 }
287 set_data_style (data);
288}
289
298G_MODULE_EXPORT void set_data_dash (GtkComboBox * gbox, gpointer data)
299{
300 int i, j;
301 tint * cd = (tint *)data;
302 a = cd -> a;
303 b = cd -> b;
304 c = cd -> c;
305 i = gtk_combo_box_get_active (GTK_COMBO_BOX(setcolorbox));
306 j = gtk_combo_box_get_active (GTK_COMBO_BOX(gbox));
307 if (i > 0)
308 {
309 get_extra_layout (i-1) -> dash = j;
310 }
311 else
312 {
313 get_project_by_id(a) -> curves[b][c] -> layout -> dash = j;
314 }
315 if (j == 0)
316 {
318 }
319 else
320 {
322 }
323 set_data_style (data);
324}
325
334G_MODULE_EXPORT void set_data_color (GtkColorChooser * colob, gpointer data)
335{
336 int i;
337 tint * cd = (tint *)data;
338 a = cd -> a;
339 b = cd -> b;
340 c = cd -> c;
341 project * this_proj = get_project_by_id(a);
342 i = gtk_combo_box_get_active (GTK_COMBO_BOX(setcolorbox));
343 if (i > 0)
344 {
345 get_extra_layout (i-1) -> datacolor = get_button_color (colob);
346 }
347 else
348 {
349 this_proj -> curves[b][c] -> layout -> datacolor = get_button_color (colob);
350 }
351 set_data_style (data);
352}
353
362G_MODULE_EXPORT void set_data_thickness (GtkEntry * thickd, gpointer data)
363{
364 int i;
365 double k;
366 const gchar * wid;
367 tint * cd = (tint *)data;
368 a = cd -> a;
369 b = cd -> b;
370 c = cd -> c;
371 wid = entry_get_text (thickd);
372 k = atof(wid);
373 project * this_proj = get_project_by_id(a);
374 i = gtk_combo_box_get_active (GTK_COMBO_BOX(setcolorbox));
375 if (k > 0.0)
376 {
377 if (i > 0)
378 {
379 get_extra_layout (i-1) -> thickness = k;
380 }
381 else
382 {
383 this_proj -> curves[b][c] -> layout -> thickness = k;
384 }
385 update_entry_double (thickd, k);
386 set_data_style (data);
387 }
388 else
389 {
390 show_warning ("Line width must be > 0.0", this_proj -> curves[b][c] -> window);
391 if (i > 0)
392 {
393 update_entry_double (thickd, get_extra_layout (i-1) -> thickness);
394 }
395 else
396 {
397 update_entry_double (thickd, this_proj -> curves[b][c] -> layout -> thickness);
398 }
399 }
400}
401
410G_MODULE_EXPORT void set_data_glyph_size (GtkEntry * glsize, gpointer data)
411{
412 int i;
413 double k;
414 const gchar * wid;
415 tint * cd = (tint *)data;
416 a = cd -> a;
417 b = cd -> b;
418 c = cd -> c;
419 wid = entry_get_text (glsize);
420 k = atof(wid);
421 project * this_proj = get_project_by_id(a);
422 i = gtk_combo_box_get_active (GTK_COMBO_BOX(setcolorbox));
423 if (k > 0.0)
424 {
425 if (i > 0)
426 {
427 get_extra_layout (i-1) -> gsize = k;
428 }
429 else
430 {
431 this_proj -> curves[b][c] -> layout -> gsize = k;
432 }
433 update_entry_double (glsize, k);
434 set_data_style (data);
435 }
436 else
437 {
438 show_warning ("Glyph size must be > 0.0", this_proj -> curves[b][c] -> window);
439 if (i > 0)
440 {
441 update_entry_double (glsize, get_extra_layout (i-1) -> gsize);
442 }
443 else
444 {
445 update_entry_double (glsize, this_proj -> curves[b][c] -> layout -> gsize);
446 }
447 }
448}
449
458G_MODULE_EXPORT void set_data_hist_width (GtkEntry * entry, gpointer data)
459{
460 int i;
461 double k;
462 const gchar * wid;
463 tint * cd = (tint *)data;
464 a = cd -> a;
465 b = cd -> b;
466 c = cd -> c;
467 wid = entry_get_text (entry);
468 k = atof(wid);
469 project * this_proj = get_project_by_id(a);
470 i = gtk_combo_box_get_active (GTK_COMBO_BOX(setcolorbox));
471 if (k > 0.0)
472 {
473 if (i > 0)
474 {
475 get_extra_layout (i-1) -> hwidth = k;
476 }
477 else
478 {
479 this_proj -> curves[b][c] -> layout -> hwidth = k;
480 }
481 update_entry_double (entry, k);
482 set_data_style (data);
483 }
484 else
485 {
486 show_warning ("Bar width must be > 0.0", this_proj -> curves[b][c] -> window);
487 if (i > 0)
488 {
489 update_entry_double (entry, get_extra_layout (i-1) -> hwidth);
490 }
491 else
492 {
493 update_entry_double (entry, this_proj -> curves[b][c] -> layout -> hwidth);
494 }
495 }
496}
497
506G_MODULE_EXPORT void set_data_hist_opac (GtkEntry * entry, gpointer data)
507{
508 int i;
509 double k;
510 const gchar * wid;
511 tint * cd = (tint *)data;
512 a = cd -> a;
513 b = cd -> b;
514 c = cd -> c;
515 wid = entry_get_text (entry);
516 k = atof(wid);
517 project * this_proj = get_project_by_id(a);
518 i = gtk_combo_box_get_active (GTK_COMBO_BOX(setcolorbox));
519 if (k >= 0.0 && k <= 1.0)
520 {
521 if (i > 0)
522 {
523 get_extra_layout (i-1) -> hopac = k;
524 }
525 else
526 {
527 this_proj -> curves[b][c] -> layout -> hopac = k;
528 }
529 update_entry_double (entry, k);
530 set_data_style (data);
531 }
532 else
533 {
534 show_warning ("Bar opacity must be in [0.0 - 1.0]", this_proj -> curves[b][c] -> window);
535 if (i > 0)
536 {
537 update_entry_double (entry, get_extra_layout (i-1) -> hopac);
538 }
539 else
540 {
541 update_entry_double (entry, this_proj -> curves[b][c] -> layout -> hopac);
542 }
543 }
544}
545
554G_MODULE_EXPORT void set_data_hist_pos (GtkComboBox * gbox, gpointer data)
555{
556 int i, j;
557 tint * cd = (tint *)data;
558 a = cd -> a;
559 b = cd -> b;
560 c = cd -> c;
561 i = gtk_combo_box_get_active (GTK_COMBO_BOX(setcolorbox));
562 j = gtk_combo_box_get_active (GTK_COMBO_BOX(gbox));
563 if (i > 0)
564 {
565 get_extra_layout (i-1) -> hpos = j;
566 }
567 else
568 {
569 get_project_by_id(a) -> curves[b][c] -> layout -> hpos = j;
570 }
571 set_data_style (data);
572}
573
582G_MODULE_EXPORT void set_data_glyph_freq (GtkEntry * glfreq, gpointer data)
583{
584 int i, j;
585 const gchar * wid;
586 tint * cd = (tint *)data;
587 a = cd -> a;
588 b = cd -> b;
589 c = cd -> c;
590 wid = entry_get_text (glfreq);
591 j = atof(wid);
592 project * this_proj = get_project_by_id(a);
593 i = gtk_combo_box_get_active (GTK_COMBO_BOX(setcolorbox));
594 if (j > 0)
595 {
596 if (i > 0)
597 {
598 get_extra_layout (i-1) -> gfreq = j;
599 }
600 else
601 {
602 this_proj -> curves[b][c] -> layout -> gfreq = j;
603 }
604 update_entry_int (glfreq, j);
605 set_data_style (data);
606 }
607 else
608 {
609 show_warning ("Glyph frequency must be > 0", this_proj -> curves[b][c] -> window);
610 if (i > 0)
611 {
612 update_entry_int (glfreq, get_extra_layout (i-1) -> thickness);
613 }
614 else
615 {
616 update_entry_int (glfreq, this_proj -> curves[b][c] -> layout -> gfreq);
617 }
618 }
619}
620
629G_MODULE_EXPORT void choose_set (GtkComboBox * box, gpointer data)
630{
631 int i, j, k, l;
632 tint ad;
633
634 i = gtk_combo_box_get_active (box);
635 j = dataxe[0].a;
636 k = dataxe[0].b;
637 l = dataxe[0].c;
638 ad.a = j;
639 ad.b = k;
640 ad.c = l;
642 if (i > 0)
643 {
644 layout = get_extra_layout (i-1);
645 }
646 else
647 {
648 layout = get_project_by_id(j) -> curves[k][l] -> layout;
649 }
650 GdkRGBA col = colrgba_togtkrgba (layout -> datacolor);
651 gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER(data_color), & col);
652 gtk_combo_box_set_active (GTK_COMBO_BOX(data_dash), layout -> dash);
653 update_entry_double (GTK_ENTRY(data_thickness), layout -> thickness);
654 gtk_combo_box_set_active (GTK_COMBO_BOX(data_glyph), layout -> glyph);
655 update_entry_double (GTK_ENTRY(data_glyph_size), layout -> gsize);
656 update_entry_int (GTK_ENTRY(data_glyph_freq), layout -> gfreq);
657 update_entry_double (GTK_ENTRY(data_hist_width), layout -> hwidth);
658 update_entry_double (GTK_ENTRY(data_hist_opac), layout -> hopac);
659 gtk_combo_box_set_active (GTK_COMBO_BOX(data_hist_pos), layout -> hpos);
660 gtk_combo_box_set_active (GTK_COMBO_BOX(data_aspect), layout -> aspect);
661 set_data_style (& ad);
662}
663
672G_MODULE_EXPORT void set_data_aspect (GtkComboBox * box, gpointer data)
673{
674 int i, j;
675 tint * cd = (tint *)data;
676 a = cd -> a;
677 b = cd -> b;
678 c = cd -> c;
679 i = gtk_combo_box_get_active (GTK_COMBO_BOX(setcolorbox));
680 j = gtk_combo_box_get_active (box);
681 if (j == 1)
682 {
683 gtk_combo_box_set_active (GTK_COMBO_BOX(data_glyph), 0);
685 gtk_widget_hide (Glyph_box);
686 gtk_widget_show (Hist_box);
687 }
688 else
689 {
691 gtk_widget_hide (Hist_box);
692 gtk_widget_show (Glyph_box);
693 }
694 if (i > 0)
695 {
696 get_extra_layout (i-1) -> aspect = j;
697 }
698 else
699 {
700 get_project_by_id(a) -> curves[b][c] -> layout -> aspect = j;
701 }
702 set_data_style (data);
703 update_curve (data);
704}
705
714static void fill_org_model (GtkListStore * store, gpointer data)
715{
716 GtkTreeIter curvelevel;
717 int i, j, k, l;
718 tint * cd = (tint *) data;
719 gchar * str;
720 a = cd -> a;
721 b = cd -> b;
722 c = cd -> c;
723 project * this_proj = get_project_by_id (a);
724 CurveExtra * ctmp;
725 ctmp = this_proj -> curves[b][c] -> extrac -> first;
726 if (this_proj -> curves[b][c] -> draw_id == this_proj -> curves[b][c] -> extrac -> extras)
727 {
728 gtk_list_store_append (store, & curvelevel);
729 str = g_strdup_printf ("%s - %s", prepare_for_title(this_proj -> name), this_proj -> curves[b][c] -> name);
730 gtk_list_store_set (store, & curvelevel, 0, a, 1, b, 2, c, 3, str, -1);
731 g_free (str);
732 }
733 i = this_proj -> curves[b][c] -> extrac -> extras;
734 while (ctmp)
735 {
736 gtk_list_store_append (store, & curvelevel);
737 j = ctmp -> id.a;
738 k = ctmp -> id.b;
739 l = ctmp -> id.c;
740 str = g_strdup_printf ("%s - %s", prepare_for_title(get_project_by_id(j) -> name),
741 get_project_by_id(j) -> curves[k][l] -> name);
742 gtk_list_store_set (store, & curvelevel, 0, j, 1, k, 2, l, 3, str, -1);
743 g_free (str);
744 i --;
745 if (this_proj -> curves[b][c] -> draw_id == i)
746 {
747 gtk_list_store_append (store, & curvelevel);
748 str = g_strdup_printf ("%s - %s", prepare_for_title(this_proj -> name), this_proj -> curves[b][c] -> name);
749 gtk_list_store_set (store, & curvelevel, 0, a, 1, b, 2, c, 3, str, -1);
750 g_free (str);
751 }
752 ctmp = ctmp -> next;
753 }
754}
755
765G_MODULE_EXPORT void move_back_front (GtkTreeModel * tree_model, GtkTreePath * path, gpointer data)
766{
767 tint * cid = (tint *) data;
768 GtkTreeIter iter;
769 gboolean valid;
770 gboolean done;
771 int i, j, k, l, m;
772 tint cbid;
773 CurveExtra * ctmpa, * ctmpb, * ctmpc, * ctmpd;
774 project * this_proj = get_project_by_id(cid -> a);
775 l = this_proj -> curves[cid -> b][cid -> c] -> extrac -> extras;
776 m = gtk_combo_box_get_active (GTK_COMBO_BOX (setcolorbox));
777 if (m > 0)
778 {
779 ctmpa = this_proj -> curves[cid -> b][cid -> c] -> extrac -> first;
780 for (i=0; i<m-1; i++) ctmpa = ctmpa -> next;
781 cbid = ctmpa -> id;
782 }
783 ctmpa = this_proj -> curves[cid -> b][cid -> c] -> extrac -> first;
784 valid = gtk_tree_model_get_iter_first (tree_model, & iter);
785 while (valid)
786 {
787 gtk_tree_model_get (tree_model, & iter, 0, & i, 1, & j, 2, & k, -1);
788 if (i == cid -> a && j == cid -> b && k == cid -> c)
789 {
790 this_proj -> curves[cid -> b][cid -> c] -> draw_id = l;
791 }
792 else if (ctmpa -> id.a != i || ctmpa -> id.b != j || ctmpa -> id.c != k)
793 {
794 ctmpb = ctmpa -> next;
795 done = FALSE;
796 while (! done && ctmpb)
797 {
798 if (ctmpb -> id.a == i && ctmpb -> id.b == j && ctmpb -> id.c == k)
799 {
800 done = TRUE;
801 }
802 else
803 {
804 ctmpb = ctmpb -> next;
805 done = FALSE;
806 }
807 }
808
809 if (done)
810 {
811 ctmpc = ctmpa -> prev;
812 if (ctmpb -> prev != ctmpa)
813 {
814 ctmpb -> prev -> next = ctmpa;
815 ctmpa -> prev = ctmpb -> prev;
816 ctmpd = ctmpa -> next;
817 }
818 else
819 {
820 ctmpa -> prev = ctmpb;
821 ctmpd = NULL;
822 }
823
824 if (ctmpb -> next)
825 {
826 ctmpb -> next -> prev = ctmpa;
827 ctmpa -> next = ctmpb -> next;
828 }
829 else
830 {
831 ctmpa -> next = NULL;
832 this_proj -> curves[cid -> b][cid -> c] -> extrac -> last = ctmpa;
833 }
834
835 if (ctmpc)
836 {
837 ctmpb -> prev = ctmpc;
838 ctmpc -> next = ctmpb;
839 }
840 else
841 {
842 ctmpb -> prev = NULL;
843 this_proj -> curves[cid -> b][cid -> c] -> extrac -> first = ctmpb;
844 }
845 if (ctmpd)
846 {
847 ctmpd -> prev = ctmpb;
848 ctmpb -> next = ctmpd;
849 }
850 else
851 {
852 ctmpb -> next = ctmpa;
853 ctmpa -> prev = ctmpb;
854 }
855 ctmpa = ctmpb;
856 }
857 ctmpa = ctmpa -> next;
858 }
859 else
860 {
861 ctmpa = ctmpa -> next;
862 }
863 l --;
864 valid = gtk_tree_model_iter_next (tree_model, & iter);
865 }
866 if (m > 0)
867 {
868 ctmpa = this_proj -> curves[cid -> b][cid -> c] -> extrac -> first;
869 m = 0;
870 while (ctmpa)
871 {
872 if (cbid.a == ctmpa -> id.a && cbid.b == ctmpa -> id.b && cbid.c == ctmpa -> id.c) break;
873 m ++;
874 ctmpa = ctmpa -> next;
875 }
876 m ++;
877 }
880 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, thesetbox, setcolorbox, FALSE, FALSE, 0);
881 gtk_widget_show(setcolorbox);
882 prepbox (this_proj -> id, cid -> b, cid -> c);
883 gtk_combo_box_set_active (GTK_COMBO_BOX (setcolorbox), m);
884 choose_set (GTK_COMBO_BOX(setcolorbox), NULL);
885 update_curve (data);
886}
887
895GtkWidget * create_org_list (gpointer data)
896{
897 int i;
898 GtkTreeViewColumn * orgcol[4];
899 GtkCellRenderer * orgcell[4];
900 gchar * col_title[4] = {" ", " ", " ", "Data set(s)"};
901 gchar * ctype[4] = {"text", "text", "text", "text"};
902 GType col_type[4] = {G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_STRING};
903 GtkListStore * orglist = gtk_list_store_newv (4, col_type);
904 orgmodel = GTK_TREE_MODEL(orglist);
905 orgtree = gtk_tree_view_new_with_model(orgmodel);
906 for (i=0; i<4; i++)
907 {
908 orgcell[i] = gtk_cell_renderer_text_new();
909 orgcol[i] = gtk_tree_view_column_new_with_attributes(col_title[i], orgcell[i], ctype[i], i, NULL);
910 gtk_tree_view_append_column(GTK_TREE_VIEW(orgtree), orgcol[i]);
911 if (i < 3) gtk_tree_view_column_set_visible (orgcol[i], FALSE);
912 }
913 fill_org_model (orglist, data);
914 g_object_unref (orglist);
915 g_signal_connect (G_OBJECT(orgmodel), "row-deleted", G_CALLBACK(move_back_front), data);
916 gtk_tree_view_expand_all (GTK_TREE_VIEW(orgtree));
917 gtk_tree_view_set_activate_on_single_click (GTK_TREE_VIEW(orgtree), TRUE);
918/*
919#ifdef GTK4
920 add_widget_gesture_and_key_action (orgtree, "orgtree-pressed", NULL, NULL,
921 NULL, NULL, NULL, NULL, NULL, NULL,
922 NULL, NULL, NULL, NULL, NULL, NULL);
923#endif
924*/
925 gtk_tree_view_set_reorderable (GTK_TREE_VIEW(orgtree), TRUE);
926 return orgtree;
927}
928
929#ifdef GTK4
938G_MODULE_EXPORT void set_bshift (GtkCheckButton * shift, gpointer data)
939#else
948G_MODULE_EXPORT void set_bshift (GtkToggleButton * shift, gpointer data)
949#endif
950{
951 tint * cd = (tint *)data;
952 a = cd -> a;
953 b = cd -> b;
954 c = cd -> c;
955 project * this_proj = get_project_by_id(a);
956#ifdef GTK4
957 this_proj -> curves[b][c] -> bshift = gtk_check_button_get_active (shift);
958#else
959 this_proj -> curves[b][c] -> bshift = gtk_toggle_button_get_active (shift);
960#endif
961 update_curve (data);
962}
963
971GtkWidget * create_tab_2 (gpointer data)
972{
973 GtkWidget * databox;
974 GtkWidget * dhbox;
975
976 tint * cd = (tint *) data;
977 int i;
978
979 a = cd -> a;
980 b = cd -> b;
981 c = cd -> c;
982 project * this_proj = get_project_by_id(a);
983
984 const int naspects = 2;
985 char * aspects[2];
986 aspects[0]="x/y";
987 aspects[1]="bar";
988
989 databox = create_vbox (BSEP);
991 add_box_child_start (GTK_ORIENTATION_VERTICAL, databox, thesetbox, FALSE, FALSE, 10);
992 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, thesetbox, markup_label("<b>Select set: </b>", -1, -1, 0.0, 0.5), FALSE, FALSE, 20);
994 prepbox (a, b, c);
995 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, thesetbox, setcolorbox, FALSE, FALSE, 10);
996
997 pixarea = create_hbox (0);
998 add_box_child_start (GTK_ORIENTATION_VERTICAL, databox, pixarea, FALSE, FALSE, 10);
999 dhbox = create_vbox (BSEP);
1000 gtk_widget_set_size_request (dhbox, -1, 270);
1001 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, pixarea, dhbox, FALSE, FALSE, 0);
1002
1004 for ( i=0 ; i < naspects ; i++ )
1005 {
1006 combo_text_append (data_aspect, aspects[i]);
1007 }
1008 gtk_combo_box_set_active (GTK_COMBO_BOX(data_aspect), this_proj -> curves[b][c] -> layout -> aspect);
1009 gtk_widget_set_size_request (data_aspect, 120, -1);
1010 g_signal_connect (G_OBJECT(data_aspect), "changed", G_CALLBACK(set_data_aspect), data);
1011 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, bbox (dhbox, "Plot type:"), data_aspect, FALSE, FALSE, 0);
1012 if (b == MS)
1013 {
1015 }
1016
1017// Data color
1018 data_color = color_button (this_proj -> curves[b][c] -> layout -> datacolor, TRUE, 120, -1, G_CALLBACK(set_data_color), data);
1019 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, bbox (dhbox, "Data color:"), data_color, FALSE, FALSE, 0);
1020
1021// Line style
1023 combo_text_append (data_dash, "No line");
1024 for ( i=1 ; i < ndash ; i++)
1025 {
1026 combo_text_append (data_dash, g_strdup_printf("%d", i));
1027 }
1028 gtk_widget_set_size_request (data_dash, 120, -1);
1029 gtk_combo_box_set_active(GTK_COMBO_BOX(data_dash), this_proj -> curves[b][c] -> layout -> dash);
1030 g_signal_connect (G_OBJECT(data_dash), "changed", G_CALLBACK(set_data_dash), data);
1031 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, bbox (dhbox, "Line style:"), data_dash, FALSE, FALSE, 0);
1032
1033// Line line width
1034 data_thickness = create_entry (G_CALLBACK(set_data_thickness), 120, 10, FALSE, data);
1035 update_entry_double (GTK_ENTRY(data_thickness), this_proj -> curves[b][c] -> layout -> thickness);
1036 if (this_proj -> curves[b][c] -> layout -> dash == 0)
1037 {
1039 }
1040 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, bbox (dhbox, "Line width:"), data_thickness, FALSE, FALSE, 0);
1041
1042 GtkWidget * data_shape = create_vbox (BSEP);
1043 add_box_child_start (GTK_ORIENTATION_VERTICAL, dhbox, data_shape, FALSE, FALSE, 0);
1045 add_box_child_start (GTK_ORIENTATION_VERTICAL, data_shape, Glyph_box, FALSE, FALSE, 0);
1046// Glyph type
1048 combo_text_append (data_glyph, "No glyph");
1049 for ( i=1 ; i < nglyph ; i++)
1050 {
1051 combo_text_append (data_glyph, g_strdup_printf("%d", i));
1052 }
1053 gtk_widget_set_size_request (data_glyph, 120, -1);
1054 gtk_combo_box_set_active (GTK_COMBO_BOX(data_glyph), this_proj -> curves[b][c] -> layout -> glyph);
1055 g_signal_connect (G_OBJECT(data_glyph), "changed", G_CALLBACK(set_data_glyph), data);
1056 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, bbox (Glyph_box, "Glyph type:"), data_glyph, FALSE, FALSE, 0);
1057
1058// Glyph size
1059 data_glyph_size = create_entry (G_CALLBACK(set_data_glyph_size), 120, 10, FALSE, data);
1060 update_entry_double (GTK_ENTRY(data_glyph_size), this_proj -> curves[b][c] -> layout -> gsize);
1061 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, bbox (Glyph_box, "Glyph size:"), data_glyph_size, FALSE, FALSE, 0);
1062
1063// Glyph frequency
1064 data_glyph_freq = create_entry (G_CALLBACK(set_data_glyph_freq), 120, 10, FALSE, data);
1065 update_entry_int (GTK_ENTRY(data_glyph_freq), this_proj -> curves[b][c] -> layout -> gfreq);
1066 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, bbox (Glyph_box, "Glyph freq.:"), data_glyph_freq, FALSE, FALSE, 0);
1067 if (this_proj -> curves[b][c] -> layout -> glyph == 0)
1068 {
1071 }
1072
1074 add_box_child_start (GTK_ORIENTATION_VERTICAL, data_shape, Hist_box, FALSE, FALSE, 0);
1075 // Histogram width
1076 data_hist_width = create_entry (G_CALLBACK(set_data_hist_width), 120, 10, FALSE, data);
1077 update_entry_double (GTK_ENTRY(data_hist_width), this_proj -> curves[b][c] -> layout -> hwidth);
1078 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, bbox (Hist_box, "Bar width:"), data_hist_width, FALSE, FALSE, 0);
1079 // Histogram opacity
1080 data_hist_opac = create_entry (G_CALLBACK(set_data_hist_opac), 120, 10, FALSE, data);
1081 update_entry_double (GTK_ENTRY(data_hist_opac), this_proj -> curves[b][c] -> layout -> hopac);
1082 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, bbox (Hist_box, "Color opacity:"), data_hist_opac, FALSE, FALSE, 0);
1083
1085 combo_text_append (data_hist_pos, "Transparent");
1087 gtk_widget_set_size_request (data_hist_pos, 120, -1);
1088 gtk_combo_box_set_active (GTK_COMBO_BOX(data_hist_pos), this_proj -> curves[b][c] -> layout -> hpos);
1089 g_signal_connect (G_OBJECT(data_hist_pos), "changed", G_CALLBACK(set_data_hist_pos), data);
1090 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, bbox (Hist_box, "Bar opacity:"), data_hist_pos, FALSE, FALSE, 0);
1091
1092
1093 add_box_child_start (GTK_ORIENTATION_VERTICAL, databox, gtk_separator_new (GTK_ORIENTATION_HORIZONTAL), FALSE, FALSE, 5);
1094 GtkWidget * hbox;
1095 if (b != MS)
1096 {
1097 hbox = create_hbox (0);
1098 add_box_child_start (GTK_ORIENTATION_VERTICAL, databox, hbox, FALSE, FALSE, 5);
1099 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox,
1100 check_button ("Automatic <i>x axis</i> shift for bar diagram (to improve visibility)", -1, -1, this_proj -> curves[b][c] -> bshift, G_CALLBACK(set_bshift), data),
1101 FALSE, FALSE, 10);
1102 add_box_child_start (GTK_ORIENTATION_VERTICAL, databox, gtk_separator_new (GTK_ORIENTATION_HORIZONTAL), FALSE, FALSE, 5);
1103 }
1104 hbox = create_hbox (0);
1105 add_box_child_start (GTK_ORIENTATION_VERTICAL, databox, hbox, FALSE, FALSE, 10);
1106 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label("<b>Layers organization: </b>", -1, -1, 0.0, 0.5), FALSE, FALSE, 20);
1107 GtkWidget * shbox = create_hbox (0);
1108 add_box_child_start (GTK_ORIENTATION_VERTICAL, databox, shbox, FALSE, FALSE, 5);
1109
1110 hbox = create_hbox (0);
1111 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, shbox, hbox, FALSE, FALSE, 75);
1112 datascroll = create_scroll (hbox, 350, 200, GTK_SHADOW_ETCHED_IN);
1114 widget_set_sensitive (orgtree, this_proj -> curves[b][c] -> extrac -> extras);
1115#ifndef GTK4
1116 gchar * str = "\tMove up/down to adjust layer position (up to front, down to back)";
1117 add_box_child_start (GTK_ORIENTATION_VERTICAL, databox, markup_label(str, -1, -1, 0.0, 0.5), FALSE, FALSE, 5);
1118#endif
1119 return databox;
1120}
Callback declarations for main window.
GtkWidget * setcolorbox
Definition cedit.c:81
GtkWidget * thesetbox
Definition cedit.c:82
void prepbox(int k, int l, int m)
prepare the curve selection combo box
Definition cedit.c:100
Variable declarations for the curve layout edition window.
curve_dash * selectdash(int iddash)
setup dash pointer
Definition curve.c:134
int ndash
Definition curve.c:91
void update_curve(gpointer data)
update curve rendering
Definition curve.c:589
int nglyph
Definition curve.c:92
PangoLayout * layout
Definition curve.c:79
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:856
Global variable declarations Global convenience function declarations Global data structure defin...
@ IMG_SURFACE
Definition global.h:234
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
const gchar * entry_get_text(GtkEntry *entry)
get the text in a GtkEntry
Definition gtk-misc.c:577
GdkRGBA colrgba_togtkrgba(ColRGBA col)
convert ColRGBA color to GdkRGBA color
Definition gtk-misc.c:1614
#define BSEP
Definition global.h:217
void update_entry_int(GtkEntry *entry, int intval)
update the content of a GtkEntry as int
Definition gtk-misc.c:594
GtkWidget * check_button(gchar *text, int dimx, int dimy, gboolean state, GCallback handler, gpointer data)
create a check button
Definition gtk-misc.c:1779
@ CONTAINER_SCR
Definition global.h:223
GtkWidget * create_combo()
create a GtkCombox widget, note deprecated in GTK4
Definition gtk-misc.c:903
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
GtkWidget * create_hbox(int spacing)
create a GtkBox with horizontal orientation
Definition gtk-misc.c:793
GtkWidget * create_image_from_data(int format, gpointer item_image)
create Gtk image for data
Definition gtk-misc.c:1423
void combo_text_append(GtkWidget *combo, gchar *text)
append text in GtkComboBox widget
Definition gtk-misc.c:880
#define MS
Definition global.h:303
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
GtkWidget * bbox(GtkWidget *box, char *lab)
Definition gtk-misc.c:1901
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
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:260
Messaging function declarations.
double y
Definition ogl_draw.c:57
double x
Definition ogl_draw.c:57
Function declarations for reading atomes project file Function declarations for saving atomes proje...
float blue
Definition global.h:118
float red
Definition global.h:116
float green
Definition global.h:117
Definition global.h:106
int b
Definition global.h:108
int c
Definition global.h:109
int a
Definition global.h:107
Definition global.h:98
int b
Definition global.h:100
int c
Definition global.h:101
int a
Definition global.h:99
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:119
DataLayout * get_extra_layout(int i)
retrieve the i data layout
Definition tab-2.c:195
GtkWidget * data_hist_width
Definition tab-2.c:85
G_MODULE_EXPORT void set_data_hist_opac(GtkEntry *entry, gpointer data)
set histogram bar opacity entry callback
Definition tab-2.c:506
int b
Definition tab-2.c:102
GtkWidget * datascroll
Definition tab-2.c:99
G_MODULE_EXPORT void set_data_hist_width(GtkEntry *entry, gpointer data)
set histogram bar width entry callback
Definition tab-2.c:458
GtkWidget * data_color
Definition tab-2.c:79
GtkWidget * data_hist_pos
Definition tab-2.c:87
G_MODULE_EXPORT void set_data_hist_pos(GtkComboBox *gbox, gpointer data)
change histogram bar position
Definition tab-2.c:554
GtkWidget * create_tab_2(gpointer data)
handle the creation of the 2nd tab of the curve edition dialog
Definition tab-2.c:971
GtkWidget * xyl[2]
Definition tab-2.c:95
GtkWidget * data_thickness
Definition tab-2.c:81
GtkWidget * data_glyph_freq
Definition tab-2.c:84
G_MODULE_EXPORT void choose_set(GtkComboBox *box, gpointer data)
change the data set to customize
Definition tab-2.c:629
void set_data_style(gpointer data)
update the data style widgets
Definition tab-2.c:213
G_MODULE_EXPORT void set_data_aspect(GtkComboBox *box, gpointer data)
change data aspect (x/y or histogram bars)
Definition tab-2.c:672
int c
Definition tab-2.c:102
G_MODULE_EXPORT void set_data_thickness(GtkEntry *thickd, gpointer data)
set data thickness entry callback
Definition tab-2.c:362
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:765
GtkTreeModel * orgmodel
Definition tab-2.c:98
G_MODULE_EXPORT void set_bshift(GtkToggleButton *shift, gpointer data)
shift / not histogram bars toggle callback GTK3
Definition tab-2.c:948
int d
Definition tab-2.c:102
G_MODULE_EXPORT void set_data_glyph_size(GtkEntry *glsize, gpointer data)
set glyph size entry callback
Definition tab-2.c:410
GtkWidget * orgtree
Definition tab-2.c:97
GtkWidget * pixarea
Definition tab-2.c:90
GtkWidget * create_org_list(gpointer data)
create the data set organisation widget
Definition tab-2.c:895
GtkWidget * data_shape
Definition tab-2.c:78
GtkWidget * data_dash
Definition tab-2.c:88
G_MODULE_EXPORT void set_data_glyph_freq(GtkEntry *glfreq, gpointer data)
set glyph frequency entry callback
Definition tab-2.c:582
int a
Definition tab-1.c:95
GtkWidget * Glyph_box
Definition tab-2.c:92
G_MODULE_EXPORT void set_data_color(GtkColorChooser *colob, gpointer data)
set data color
Definition tab-2.c:334
G_MODULE_EXPORT void set_data_glyph(GtkComboBox *gbox, gpointer data)
change glyph type
Definition tab-2.c:260
qint dataxe[2]
Definition tab-1.c:92
GtkWidget * data_glyph
Definition tab-2.c:82
G_MODULE_EXPORT void set_data_dash(GtkComboBox *gbox, gpointer data)
change data dash style
Definition tab-2.c:298
GtkWidget * data_aspect
Definition tab-2.c:80
GtkWidget * data_hist_opac
Definition tab-2.c:86
GtkWidget * data_glyph_size
Definition tab-2.c:83
GtkWidget * stylearea
Definition tab-2.c:89
GtkWidget * Hist_box
Definition tab-2.c:93
GdkPixbuf * pix
Definition workspace.c:69
GtkWidget * hbox
Definition workspace.c:71