atomes 1.1.14
atomes: an atomic scale modeling tool box
Loading...
Searching...
No Matches
tab-4.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-4.c'
24*
25* Contains:
26*
27
28 - The 4th tab of the curve layout edition dialog
29
30*
31* List of functions:
32
33 int get_active_axis ();
34
35 G_MODULE_EXPORT gboolean scroll_set_ticks_angle (GtkRange * range, GtkScrollType scroll, gdouble value, gpointer data);
36
37 void ticks_angle_has_changed (gpointer data, double value);
38
39 G_MODULE_EXPORT void set_axis_min (GtkEntry * res, gpointer data);
40 G_MODULE_EXPORT void set_axis_max (GtkEntry * res, gpointer data);
41 G_MODULE_EXPORT void set_max_div (GtkEntry * maj, gpointer data);
42 G_MODULE_EXPORT void set_min_div_spin (GtkSpinButton * res, gpointer data);
43 G_MODULE_EXPORT void set_ticks_size_major_spin (GtkSpinButton * res, gpointer data);
44 G_MODULE_EXPORT void set_ticks_size_minor_spin (GtkSpinButton * res, gpointer data);
45 G_MODULE_EXPORT void set_lab_digit_spin (GtkSpinButton * res, gpointer data);
46 G_MODULE_EXPORT void set_lab_shift_x_spin (GtkSpinButton * res, gpointer data);
47 G_MODULE_EXPORT void set_lab_shift_y_spin (GtkSpinButton * res, gpointer data);
48 G_MODULE_EXPORT void set_axis_title_x_spin (GtkSpinButton * res, gpointer data);
49 G_MODULE_EXPORT void set_axis_title_y_spin (GtkSpinButton * res, gpointer data);
50 G_MODULE_EXPORT void set_io_ticks (GtkComboBox * box, gpointer data);
51 G_MODULE_EXPORT void set_pos_ticks (GtkComboBox * box, gpointer data);
52 G_MODULE_EXPORT void set_pos_labels (GtkComboBox * box, gpointer data);
53 G_MODULE_EXPORT void set_ticks_labels_font (GtkFontButton * fontb, gpointer data);
54 G_MODULE_EXPORT void set_ticks_angle (GtkRange * range, gpointer data);
55 G_MODULE_EXPORT void to_axis_title (GtkCheckButton * but, gpointer data);
56 G_MODULE_EXPORT void to_axis_title (GtkToggleButton * but, gpointer data);
57 G_MODULE_EXPORT void set_grid (GtkCheckButton * grid, gpointer data);
58 G_MODULE_EXPORT void set_grid (GtkToggleButton * grid, gpointer data);
59 G_MODULE_EXPORT void set_autoscale (GtkButton * autosc, gpointer data);
60 G_MODULE_EXPORT void set_axis (GtkCheckButton * axis, gpointer data);
61 G_MODULE_EXPORT void set_axis (GtkToggleButton * axis, gpointer data);
62 G_MODULE_EXPORT void set_axis_legend (GtkEntry * xtit, gpointer data);
63 G_MODULE_EXPORT void set_axis_title_font (GtkFontButton * fontb, gpointer data);
64 G_MODULE_EXPORT void set_scale (GtkComboBox * sbox, gpointer data);
65 G_MODULE_EXPORT void update_axis (GtkComboBox * widg, gpointer data);
66
67 GtkWidget * create_tab_4 (gpointer data);
68
69*/
70
71#ifdef HAVE_CONFIG_H
72# include <config.h>
73#endif
74
75#include <gtk/gtk.h>
76#include <cairo.h>
77#include <cairo-pdf.h>
78#include <cairo-svg.h>
79#include <string.h>
80#include <stdlib.h>
81#include <math.h>
82
83#include "global.h"
84#include "interface.h"
85#include "callbacks.h"
86#include "project.h"
87#include "curve.h"
88#include "cedit.h"
89
90GtkWidget * axischoice = NULL;
91GtkWidget * scale_box = NULL;
92GtkWidget * ticks_inout_box = NULL;
93GtkWidget * ticks_pos_box = NULL;
94GtkWidget * labels_pos_box = NULL;
95GtkWidget * ticks_labels_angle = NULL;
96GtkWidget * ticks_labels_font = NULL;
97GtkWidget * show_axis = NULL;
98GtkWidget * show_grid = NULL;
99GtkWidget * auto_scale = NULL;
100GtkWidget * axis_default_title = NULL;
101GtkWidget * axis_title = NULL;
102GtkWidget * axis_title_font = NULL;
103GtkWidget * majt = NULL;
104GtkWidget * vmin = NULL;
105GtkWidget * vmax = NULL;
106GtkWidget * nmi[2], * ndi[2];
107GtkWidget * mats[2];
108GtkWidget * mits[2];
109GtkWidget * nptx[2], * npty[2];
110GtkWidget * tptx[2], * tpty[2];
111
112extern qint dataxe[2];
113extern qint framxe[4];
114extern int a, b, c, d;
115
122{
123 return gtk_combo_box_get_active (GTK_COMBO_BOX(axischoice));
124}
125
134G_MODULE_EXPORT void set_axis_min (GtkEntry * res, gpointer data)
135{
136 tint * ad = (tint *)data;
137 a = ad -> a;
138 b = ad -> b;
139 c = ad -> c;
140 project * this_proj = get_project_by_id(a);
141 int i = get_active_axis();
142 if (i > -1)
143 {
144 const gchar * m;
145 m = entry_get_text (res);
146 if (atof(m) < this_proj -> curves[b][c] -> axmax[i])
147 {
148 this_proj -> curves[b][c] -> axmin[i] = atof(m);
149 }
150 else
151 {
152 show_warning ("Axis min must be < to axis max", this_proj -> curves[b][c] -> window);
153 }
154 update_entry_double (res, this_proj -> curves[b][c] -> axmin[i]);
155 update_curve (data);
156 }
157}
158
167G_MODULE_EXPORT void set_axis_max (GtkEntry * res, gpointer data)
168{
169 tint * ad = (tint *)data;
170 a = ad -> a;
171 b = ad -> b;
172 c = ad -> c;
173 project * this_proj = get_project_by_id(a);
174 int i = get_active_axis ();
175 const gchar * m;
176 m = entry_get_text (res);
177 if (atof(m) > this_proj -> curves[b][c] -> axmin[i])
178 {
179 this_proj -> curves[b][c] -> axmax[i] = atof(m);
180 }
181 else
182 {
183 show_warning ("Axis max must be > to axis min", this_proj -> curves[b][c] -> window);
184 }
185 update_entry_double (res, this_proj -> curves[b][c] -> axmax[i]);
186 update_curve (data);
187}
188
197G_MODULE_EXPORT void set_max_div (GtkEntry * maj, gpointer data)
198{
199 double tmp;
200 tint * ad = (tint *)data;
201 a = ad -> a;
202 b = ad -> b;
203 c = ad -> c;
204 project * this_proj = get_project_by_id(a);
205 int i = get_active_axis ();
206 const gchar * m;
207 m = entry_get_text (maj);
208 tmp = atof(m);
209 if (tmp != 0.0)
210 {
211 this_proj -> curves[b][c] -> majt[i] = tmp;
212 update_curve (data);
213 }
214 else
215 {
216 show_warning ("Major tick must be > 0.0", this_proj -> curves[b][c] -> window);
217 }
218 update_entry_double (maj, this_proj -> curves[b][c] -> majt[i]);
219}
220
229G_MODULE_EXPORT void set_min_div_spin (GtkSpinButton * res, gpointer data)
230{
231 qint * ad = (qint *) data;
232 a = ad -> a;
233 b = ad -> b;
234 c = ad -> c;
235 d = ad -> d;
236 get_project_by_id(a) -> curves[b][c] -> mint[d] = gtk_spin_button_get_value_as_int(res) + 1;
237 tint cd;
238 cd.a = a;
239 cd.b = b;
240 cd.c = c;
241 update_curve ((gpointer)& cd);
242}
243
252G_MODULE_EXPORT void set_ticks_size_major_spin (GtkSpinButton * res, gpointer data)
253{
254 qint * ad = (qint *) data;
255 a = ad -> a;
256 b = ad -> b;
257 c = ad -> c;
258 d = ad -> d;
259 get_project_by_id(a) -> curves[b][c] -> majt_size[d] = gtk_spin_button_get_value_as_int(res);
260 tint cd;
261 cd.a = a;
262 cd.b = b;
263 cd.c = c;
264 update_curve ((gpointer)& cd);
265}
266
275G_MODULE_EXPORT void set_ticks_size_minor_spin (GtkSpinButton * res, gpointer data)
276{
277 qint * ad = (qint *) data;
278 a = ad -> a;
279 b = ad -> b;
280 c = ad -> c;
281 d = ad -> d;
282 project * this_proj = get_project_by_id(a);
283 this_proj -> curves[b][c]-> mint_size[d] = gtk_spin_button_get_value_as_int(res);
284 update_entry_int (GTK_ENTRY(res), this_proj -> curves[b][c] -> mint_size[d]);
285 tint cd;
286 cd.a = a;
287 cd.b = b;
288 cd.c = c;
289 update_curve ((gpointer)& cd);
290}
291
300G_MODULE_EXPORT void set_lab_digit_spin (GtkSpinButton * res, gpointer data)
301{
302 qint * ad = (qint *) data;
303 a = ad -> a;
304 b = ad -> b;
305 c = ad -> c;
306 d = ad -> d;
307 project * this_proj = get_project_by_id(a);
308 this_proj -> curves[b][c]-> labels_digit[d] = gtk_spin_button_get_value_as_int(res);
309 update_entry_int (GTK_ENTRY(res), this_proj -> curves[b][c] -> labels_digit[d]);
310 tint cd;
311 cd.a = a;
312 cd.b = b;
313 cd.c = c;
314 update_curve ((gpointer)& cd);
315}
316
325G_MODULE_EXPORT void set_lab_shift_x_spin (GtkSpinButton * res, gpointer data)
326{
327 qint * ad = (qint *) data;
328 a = ad -> a;
329 b = ad -> b;
330 c = ad -> c;
331 d = ad -> d;
332 project * this_proj = get_project_by_id(a);
333 this_proj -> curves[b][c] -> labels_shift_x[d] = gtk_spin_button_get_value_as_int(res);
334 update_entry_int (GTK_ENTRY(res), this_proj -> curves[b][c] -> labels_shift_x[d]);
335 tint cd;
336 cd.a = a;
337 cd.b = b;
338 cd.c = c;
339 update_curve ((gpointer)& cd);
340}
341
350G_MODULE_EXPORT void set_lab_shift_y_spin (GtkSpinButton * res, gpointer data)
351{
352 qint * ad = (qint *) data;
353 a = ad -> a;
354 b = ad -> b;
355 c = ad -> c;
356 d = ad -> d;
357 project * this_proj = get_project_by_id(a);
358 this_proj -> curves[b][c] -> labels_shift_y[d] = gtk_spin_button_get_value_as_int(res);
359 update_entry_int (GTK_ENTRY(res), this_proj -> curves[b][c]-> labels_shift_y[d]);
360 tint cd;
361 cd.a = a;
362 cd.b = b;
363 cd.c = c;
364 update_curve ((gpointer)& cd);
365}
366
375G_MODULE_EXPORT void set_axis_title_x_spin (GtkSpinButton * res, gpointer data)
376{
377 qint * ad = (qint *) data;
378 a = ad -> a;
379 b = ad -> b;
380 c = ad -> c;
381 d = ad -> d;
382 get_project_by_id(a) -> curves[b][c] -> axis_title_x[d] = gtk_spin_button_get_value_as_int(res);
383 tint cd;
384 cd.a = a;
385 cd.b = b;
386 cd.c = c;
387 update_curve ((gpointer)& cd);
388}
389
398G_MODULE_EXPORT void set_axis_title_y_spin (GtkSpinButton * res, gpointer data)
399{
400 qint * ad = (qint *) data;
401 a = ad -> a;
402 b = ad -> b;
403 c = ad -> c;
404 d = ad -> d;
405 get_project_by_id(a) -> curves[b][c] -> axis_title_y[d] = gtk_spin_button_get_value_as_int(res);
406 tint cd;
407 cd.a = a;
408 cd.b = b;
409 cd.c = c;
410 update_curve ((gpointer)& cd);
411}
412
421G_MODULE_EXPORT void set_io_ticks (GtkComboBox * box, gpointer data)
422{
423 tint * ad = (tint *)data;
424 a = ad -> a;
425 b = ad -> b;
426 c = ad -> c;
427 int i = get_active_axis ();
428 get_project_by_id(a) -> curves[b][c] -> ticks_io[i] = gtk_combo_box_get_active (box);
429 update_curve (data);
430}
431
440G_MODULE_EXPORT void set_pos_ticks (GtkComboBox * box, gpointer data)
441{
442 tint * ad = (tint *)data;
443 a = ad -> a;
444 b = ad -> b;
445 c = ad -> c;
446 int i = get_active_axis ();
447 get_project_by_id(a) -> curves[b][c] -> ticks_pos[i] = gtk_combo_box_get_active (box);
448 update_curve (data);
449}
450
459G_MODULE_EXPORT void set_pos_labels (GtkComboBox * box, gpointer data)
460{
461 tint * ad = (tint *)data;
462 a = ad -> a;
463 b = ad -> b;
464 c = ad -> c;
465 int i = get_active_axis ();
466 get_project_by_id(a) -> curves[b][c] -> labels_pos[i] = gtk_combo_box_get_active (box);
467 update_curve (data);
468}
469
478G_MODULE_EXPORT void set_ticks_labels_font (GtkFontButton * fontb, gpointer data)
479{
480 tint * ad = (tint *)data;
481 a = ad -> a;
482 b = ad -> b;
483 c = ad -> c;
484 int i = get_active_axis ();
485 project * this_proj = get_project_by_id(a);
486 g_free (this_proj -> curves[b][c] -> labels_font[i]);
487 this_proj -> curves[b][c] -> labels_font[i] = g_strdup_printf ("%s", gtk_font_chooser_get_font (GTK_FONT_CHOOSER(fontb)));
488 update_curve (data);
489}
490
499void ticks_angle_has_changed (gpointer data, double value)
500{
501 tint * ad = (tint *)data;
502 a = ad -> a;
503 b = ad -> b;
504 c = ad -> c;
505 int i = get_active_axis ();
506 get_project_by_id(a) -> curves[b][c] -> labels_angle[i] = value * (pi/180.0);
507 update_curve (data);
508}
509
520G_MODULE_EXPORT gboolean scroll_set_ticks_angle (GtkRange * range, GtkScrollType scroll, gdouble value, gpointer data)
521{
522 ticks_angle_has_changed (data, value);
523 return FALSE;
524}
525
534G_MODULE_EXPORT void set_ticks_angle (GtkRange * range, gpointer data)
535{
536 ticks_angle_has_changed (data, gtk_range_get_value (range));
537}
538
539#ifdef GTK4
548G_MODULE_EXPORT void to_axis_title (GtkCheckButton * but, gpointer data)
549#else
558G_MODULE_EXPORT void to_axis_title (GtkToggleButton * but, gpointer data)
559#endif
560{
561 tint * ad = (tint *)data;
562 a = ad -> a;
563 b = ad -> b;
564 c = ad -> c;
565 int i = get_active_axis ();
566#ifdef GTK4
567 if (gtk_check_button_get_active (but))
568#else
569 if (gtk_toggle_button_get_active (but))
570#endif
571 {
573 project * this_proj = get_project_by_id(a);
574 g_free (this_proj -> curves[b][c] -> axis_title[i]);
575 this_proj -> curves[b][c] -> axis_title[i] = g_strdup_printf ("%s", default_title (i, c));
576 update_entry_text (GTK_ENTRY(axis_title), this_proj -> curves[b][c] -> axis_title[i]);
577 }
578 else
579 {
581 }
582 update_curve (data);
583}
584
585#ifdef GTK4
594G_MODULE_EXPORT void set_grid (GtkCheckButton * grid, gpointer data)
595#else
604G_MODULE_EXPORT void set_grid (GtkToggleButton * grid, gpointer data)
605#endif
606{
607 tint * ad = (tint *)data;
608 a = ad -> a;
609 b = ad -> b;
610 c = ad -> c;
611 int i = get_active_axis ();
612#ifdef GTK4
613 get_project_by_id(a) -> curves[b][c] -> show_grid[i] = gtk_check_button_get_active (grid);
614#else
615 get_project_by_id(a) -> curves[b][c] -> show_grid[i] = gtk_toggle_button_get_active (grid);
616#endif
617 update_curve (data);
618}
619
628G_MODULE_EXPORT void set_autoscale (GtkButton * autosc, gpointer data)
629{
630 tint * ad = (tint *)data;
631 a = ad -> a;
632 b = ad -> b;
633 c = ad -> c;
634 int i = get_active_axis ();
635 get_project_by_id(a) -> curves[b][c] -> autoscale[i] = TRUE;
636 update_curve (data);
637}
638
639#ifdef GTK4
648G_MODULE_EXPORT void set_axis (GtkCheckButton * axis, gpointer data)
649#else
658G_MODULE_EXPORT void set_axis (GtkToggleButton * axis, gpointer data)
659#endif
660{
661 tint * ad = (tint *)data;
662 a = ad -> a;
663 b = ad -> b;
664 c = ad -> c;
665 int i = get_active_axis ();
666#ifdef GTK4
667 get_project_by_id(a) -> curves[b][c] -> show_axis[i] = gtk_check_button_get_active (axis);
668#else
669 get_project_by_id(a) -> curves[b][c] -> show_axis[i] = gtk_toggle_button_get_active (axis);
670#endif
671 update_curve (data);
672}
673
682G_MODULE_EXPORT void set_axis_legend (GtkEntry * xtit, gpointer data)
683{
684 tint * ad = (tint *)data;
685 a = ad -> a;
686 b = ad -> b;
687 c = ad -> c;
688 int i = get_active_axis ();
689 project * this_proj = get_project_by_id(a);
690 g_free (this_proj -> curves[b][c] -> axis_title[i]);
691 this_proj -> curves[b][c] -> axis_title[i] = g_strdup_printf ("%s", entry_get_text (xtit));
692 update_curve (data);
693}
694
703G_MODULE_EXPORT void set_axis_title_font (GtkFontButton * fontb, gpointer data)
704{
705 tint * ad = (tint *)data;
706 a = ad -> a;
707 b = ad -> b;
708 c = ad -> c;
709 project * this_proj = get_project_by_id(a);
710 int i = get_active_axis ();
711 g_free (this_proj -> curves[b][c] -> axis_title_font[i]);
712 this_proj -> curves[b][c] -> axis_title_font[i] = g_strdup_printf ("%s", gtk_font_chooser_get_font (GTK_FONT_CHOOSER(fontb)));
713 update_curve (data);
714}
715
724G_MODULE_EXPORT void set_scale (GtkComboBox * sbox, gpointer data)
725{
726 tint * ad = (tint *)data;
727 a = ad -> a;
728 b = ad -> b;
729 c = ad -> c;
730 project * this_proj = get_project_by_id(a);
731 int i = get_active_axis ();
732 this_proj -> curves[b][c] -> scale[i] = gtk_combo_box_get_active(sbox);
733 widget_set_sensitive (majt, ! gtk_combo_box_get_active(sbox));
734 widget_set_sensitive (nmi[i], ! gtk_combo_box_get_active(sbox));
735 this_proj -> curves[b][c]-> autoscale[i] = TRUE;
736 update_curve (data);
737}
738
740
749G_MODULE_EXPORT void update_axis (GtkComboBox * widg, gpointer data)
750{
751 int i;
752 tint * ad = (tint *)data;
753 a = ad -> a;
754 b = ad -> b;
755 c = ad -> c;
756 project * this_proj = get_project_by_id(a);
757 i = gtk_combo_box_get_active (widg);
758 update_entry_double (GTK_ENTRY(vmin), this_proj -> curves[b][c] -> axmin[i]);
759 update_entry_double (GTK_ENTRY(vmax), this_proj -> curves[b][c] -> axmax[i]);
760 update_entry_double (GTK_ENTRY(majt), this_proj -> curves[b][c] -> majt[i]);
761 gtk_combo_box_set_active (GTK_COMBO_BOX(ticks_inout_box), this_proj -> curves[b][c] -> ticks_io[i]);
762 gtk_combo_box_set_active (GTK_COMBO_BOX(ticks_pos_box), this_proj -> curves[b][c] -> ticks_pos[i]);
763 gtk_combo_box_set_active (GTK_COMBO_BOX(labels_pos_box), this_proj -> curves[b][c] -> labels_pos[i]);
764 gtk_font_chooser_set_font (GTK_FONT_CHOOSER(ticks_labels_font), this_proj -> curves[b][c] -> labels_font[i]);
765 gtk_range_set_value (GTK_RANGE(ticks_labels_angle), this_proj -> curves[b][c] -> labels_angle[i] * (180.0/pi));
766 if (b < MS)
767 {
769 }
770 else
771 {
772 g_signal_handler_disconnect (G_OBJECT(scale_box), handler_id);
773 gtk_combo_box_set_active (GTK_COMBO_BOX(scale_box), this_proj -> curves[b][c] -> scale[i]);
774 handler_id = g_signal_connect (G_OBJECT(scale_box), "changed", G_CALLBACK(set_scale), data);
776 /* widget_set_sensitive (vmax, ! this_proj -> curves[b][c] -> scale[i]);
777 widget_set_sensitive (vmin, ! this_proj -> curves[b][c] -> scale[i]); */
778 widget_set_sensitive (majt, ! this_proj -> curves[b][c] -> scale[i]);
779 widget_set_sensitive (nmi[i], ! this_proj -> curves[b][c] -> scale[i]);
780 }
781 gtk_widget_hide (nmi[! i]);
782 gtk_widget_hide (ndi[! i]);
783 gtk_widget_hide (mats[! i]);
784 gtk_widget_hide (mits[! i]);
785 gtk_widget_hide (nptx[! i]);
786 gtk_widget_hide (npty[! i]);
787 gtk_widget_hide (tptx[! i]);
788 gtk_widget_hide (tpty[! i]);
789
790 gtk_widget_show (nmi[i]);
791 gtk_widget_show (ndi[i]);
792 gtk_widget_show (mats[i]);
793 gtk_widget_show (mits[i]);
794 gtk_widget_show (nptx[i]);
795 gtk_widget_show (npty[i]);
796 gtk_widget_show (tptx[i]);
797 gtk_widget_show (tpty[i]);
798
799#ifdef GTK4
800 gtk_check_button_set_active (GTK_CHECK_BUTTON(show_axis), this_proj -> curves[b][c] -> show_axis[i]);
801 gtk_check_button_set_active (GTK_CHECK_BUTTON(show_grid), this_proj -> curves[b][c] -> show_grid[i]);
802 gtk_check_button_set_active (GTK_CHECK_BUTTON(axis_default_title), this_proj -> curves[b][c] -> axis_defaut_title[i]);
803#else
804 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(show_axis), this_proj -> curves[b][c] -> show_axis[i]);
805 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(show_grid), this_proj -> curves[b][c] -> show_grid[i]);
806 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(axis_default_title), this_proj -> curves[b][c] -> axis_defaut_title[i]);
807#endif
808 widget_set_sensitive (axis_title, ! this_proj -> curves[b][c] -> axis_defaut_title[i]);
809 update_entry_text (GTK_ENTRY(axis_title), this_proj -> curves[b][c] -> axis_title[i]);
810 gtk_font_chooser_set_font (GTK_FONT_CHOOSER(axis_title_font), this_proj -> curves[b][c] -> axis_title_font[i]);
811}
812
820GtkWidget * create_tab_4 (gpointer data)
821{
822
823 tint * cd = (tint *) data;
824 int i;
825
826 a = cd -> a;
827 b = cd -> b;
828 c = cd -> c;
829 project * this_proj = get_project_by_id(a);
830
831 GtkWidget * axisbox;
832#ifdef GTK4
833 axisbox = create_vbox (3);
834#else
835 axisbox = create_vbox (BSEP);
836#endif
837 GtkWidget * ahbox = create_hbox (0);
838 add_box_child_start (GTK_ORIENTATION_VERTICAL, axisbox, ahbox, FALSE, FALSE, 5);
839 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, markup_label("<b>Select axis:</b>", 175, -1, 1.0, 0.5), FALSE, FALSE, 0);
841 combo_text_append (axischoice, "X axis");
842 combo_text_append (axischoice, "Y axis");
843 gtk_combo_box_set_active (GTK_COMBO_BOX(axischoice), 0);
844 gtk_widget_set_size_request (axischoice, 80, 35);
845 g_signal_connect (G_OBJECT(axischoice), "changed", G_CALLBACK(update_axis), data);
846 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, axischoice, FALSE, FALSE, 25);
847
848 add_box_child_start (GTK_ORIENTATION_VERTICAL, axisbox, gtk_separator_new (GTK_ORIENTATION_HORIZONTAL), FALSE, FALSE, 5);
849
850 ahbox = create_hbox (0);
851 add_box_child_start (GTK_ORIENTATION_VERTICAL, axisbox, ahbox, FALSE, FALSE, 0);
852 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, markup_label("Scale type:", 100, -1, 0.0, 0.5), FALSE, FALSE, 0);
854 combo_text_append (scale_box, "Linear");
856 gtk_combo_box_set_active (GTK_COMBO_BOX(scale_box), this_proj -> curves[b][c] -> scale[0]);
857 gtk_widget_set_size_request (scale_box, 80, -1);
858 handler_id = g_signal_connect (G_OBJECT(scale_box), "changed", G_CALLBACK(set_scale), data);
859 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, scale_box, FALSE, FALSE, 0);
860 auto_scale = create_button ("Autoscale axis", IMG_NONE, NULL, -1, -1, GTK_RELIEF_NORMAL, G_CALLBACK(set_autoscale), data);
861 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, auto_scale, FALSE, FALSE, 30);
862
863// Axis min and max
864 ahbox = create_hbox (0);
865 add_box_child_start (GTK_ORIENTATION_VERTICAL, axisbox, ahbox, FALSE, FALSE, 5);
866 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, markup_label("Min:", 30, -1, 0.5, 0.5), FALSE, FALSE, 20);
867 vmin = create_entry (G_CALLBACK(set_axis_min), 100, 15, FALSE, data);
868 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, vmin, FALSE, FALSE, 0);
869 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, markup_label("Max:", 30, -1, 0.5, 0.5), FALSE, FALSE, 20);
870 vmax = create_entry (G_CALLBACK(set_axis_max), 100, 15, FALSE, data);
871 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, vmax, FALSE, FALSE, 0);
872
873// Major ticks spacing
874 ahbox = create_hbox (0);
875 add_box_child_start (GTK_ORIENTATION_VERTICAL, axisbox, ahbox, FALSE, FALSE, 1);
876 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, markup_label("Major ticks spacing:", 160, -1, 0.0, 0.5), FALSE, FALSE, 10);
877 majt = create_entry (G_CALLBACK(set_max_div), 100, 15, FALSE, data);
878 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, majt, FALSE, FALSE, 0);
879
880// Number of minors ticks
881 ahbox = create_hbox (0);
882 add_box_child_start (GTK_ORIENTATION_VERTICAL, axisbox, ahbox, FALSE, FALSE, 1);
883 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, markup_label("Number of minor ticks:", 160, -1, 0.0, 0.5), FALSE, FALSE, 10);
884 for (i=0; i<2; i++)
885 {
886 nmi[i] = spin_button (G_CALLBACK(set_min_div_spin), (double)this_proj -> curves[b][c] -> mint[i]-1.0, 0.0, 100.0, 1.0, 0, 50, & dataxe[i]);
887 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, nmi[i], FALSE, FALSE, 0);
888 }
889
890// Ticks ...
891 ahbox = create_hbox (0);
892 add_box_child_start (GTK_ORIENTATION_VERTICAL, axisbox, ahbox, FALSE, FALSE, 5);
893 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, markup_label("<u>Tick marks:</u>", -1, -1, 0.0, 0.5), FALSE, FALSE, 0);
894
895// ... position ...
896 ahbox = abox (axisbox, "Location:", 1);
900 gtk_widget_set_size_request (ticks_inout_box, 60, -1);
901 g_signal_connect (G_OBJECT(ticks_inout_box), "changed", G_CALLBACK(set_io_ticks), data);
902 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, ticks_inout_box, FALSE, FALSE, 3);
903
906 combo_text_append (ticks_pos_box, "Opposite");
909 gtk_widget_set_size_request (ticks_pos_box, 100, -1);
910 g_signal_connect (G_OBJECT(ticks_pos_box), "changed", G_CALLBACK(set_pos_ticks), data);
911 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, ticks_pos_box, FALSE, FALSE, 3);
912
913// ... sizes ...
914
915 ahbox = abox (axisbox, "Major ticks size:", 1);
916 for (i=0; i<2; i++)
917 {
918 mats[i] = spin_button (G_CALLBACK(set_ticks_size_major_spin), (double)this_proj -> curves[b][c] -> majt_size[i], 0.0, 100.0, 1.0, 0, 50, & dataxe[i]);
919 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, mats[i], FALSE, FALSE, 0);
920 }
921 ahbox = abox (axisbox, "Minor ticks size:", 1);
922 for (i=0; i<2; i++)
923 {
924 mits[i] = spin_button (G_CALLBACK(set_ticks_size_minor_spin), (double)this_proj -> curves[b][c] -> mint_size[i], 0.0, 100.0, 1.0, 0, 50, & dataxe[i]);
925 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, mits[i], FALSE, FALSE, 0);
926 }
927
928// Ticks labels ...
929 ahbox = create_hbox (0);
930 add_box_child_start (GTK_ORIENTATION_VERTICAL, axisbox, ahbox, FALSE, FALSE, 5);
931 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, markup_label("<u>Tick labels:</u>", -1, -1, 0.0, 0.5), FALSE, FALSE, 0);
932
933// ... position ...
934 ahbox = abox (axisbox, "Location:", 1);
937 combo_text_append (labels_pos_box, "Opposite");
940 gtk_widget_set_size_request (labels_pos_box, 150, -1);
941 g_signal_connect (G_OBJECT(labels_pos_box), "changed", G_CALLBACK(set_pos_labels), data);
942 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, labels_pos_box, FALSE, FALSE, 0);
943
944// ... significant digits ...
945 ahbox = abox (axisbox, "Significant digits:", 1);
946 for (i=0; i<2; i++)
947 {
948 ndi[i] = spin_button (G_CALLBACK(set_lab_digit_spin), (double)this_proj -> curves[b][c] -> labels_digit[i], 0.0, 100.0, 1.0, 0, 50, & dataxe[i]);
949 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, ndi[i], FALSE, FALSE, 0);
950 }
951
952// ... font ...
953 ticks_labels_font = font_button (this_proj -> curves[b][c] -> labels_font[0], 150, 35, G_CALLBACK(set_ticks_labels_font), data);
954 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, abox (axisbox, "Font:", 1), ticks_labels_font, FALSE, FALSE, 5);
955
956// ... angle ..
957 ticks_labels_angle = create_hscale (-180.0, 180.0, 1.0, 0.0, GTK_POS_LEFT, 0, 150, G_CALLBACK(set_ticks_angle), G_CALLBACK(scroll_set_ticks_angle), data);
958 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, abox (axisbox, "Angle:", 1), ticks_labels_angle, FALSE, FALSE, 5);
959
960// ...distance to axis
961 ahbox = abox (axisbox, "Position: ", 1);
962 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, markup_label("x:", -1, -1, 0.9, 0.5), FALSE, FALSE, 10);
963 for (i=0; i<2; i++)
964 {
965 nptx[i] = spin_button (G_CALLBACK(set_lab_shift_x_spin), (double)this_proj -> curves[b][c] -> labels_shift_x[i], -100.0, 100.0, 1.0, 0, 50, & dataxe[i]);
966 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, nptx[i], FALSE, FALSE, 0);
967 }
968 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, markup_label("y:", -1, -1, 0.9, 0.5), FALSE, FALSE, 10);
969 for (i=0; i<2; i++)
970 {
971 npty[i] = spin_button (G_CALLBACK(set_lab_shift_y_spin), (double) this_proj -> curves[b][c] -> labels_shift_y[i], -100.0, 100.0, 1.0, 0, 50, & dataxe[i]);
972 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, npty[i], FALSE, FALSE, 0);
973 }
974
975 show_axis = check_button ("Show/hide axis (if min[axis] &lt; 0.0 &lt; max[axis])", 100, 30, FALSE, G_CALLBACK(set_axis), data);
976 add_box_child_start (GTK_ORIENTATION_VERTICAL, axisbox, show_axis, FALSE, FALSE, 3);
977 show_grid = check_button ("Show/hide axis grid", 100, 30, FALSE, G_CALLBACK(set_grid), data);
978 add_box_child_start (GTK_ORIENTATION_VERTICAL, axisbox, show_grid, FALSE, FALSE, 1);
979
980// Axis title
981 ahbox = create_hbox (0);
982 add_box_child_start (GTK_ORIENTATION_VERTICAL, axisbox, ahbox, FALSE, FALSE,3);
983 axis_default_title = check_button ("Use default axis title", 175, -1, FALSE, G_CALLBACK(to_axis_title), data);
984 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, axis_default_title, FALSE, FALSE, 0);
985 axis_title = create_entry (G_CALLBACK(set_axis_legend), 150, 15, FALSE, data);
986 gtk_entry_set_alignment (GTK_ENTRY(axis_title), 0.0);
987 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, axis_title, FALSE, FALSE, 0);
988
989 axis_title_font = font_button (this_proj -> curves[b][c] -> axis_title_font[0], 150, 35, G_CALLBACK(set_axis_title_font), data);
990 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, abox (axisbox, "Font:", 3), axis_title_font, FALSE, FALSE, 0);
991
992 ahbox = abox (axisbox, "Position: ", 3);
993 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, markup_label("x:", -1, -1, 0.9, 0.5), FALSE, FALSE, 10);
994 for (i=0; i<2; i++)
995 {
996 tptx[i] = spin_button (G_CALLBACK(set_axis_title_x_spin), (double)this_proj -> curves[b][c] -> axis_title_x[i], -500.0, 500.0, 1.0, 0, 50, & dataxe[i]);
997 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, tptx[i], FALSE, FALSE, 0);
998 }
999 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, markup_label("y:", -1, -1, 0.9, 0.5), FALSE, FALSE, 10);
1000 for (i=0; i<2; i++)
1001 {
1002 tpty[i] = spin_button (G_CALLBACK(set_axis_title_y_spin), (double)this_proj -> curves[b][c] -> axis_title_y[i], -500.0, 500.0, 1.0, 0, 50, & dataxe[i]);
1003 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, tpty[i], FALSE, FALSE, 0);
1004 }
1005 return axisbox;
1006}
Callback declarations for main window.
Variable declarations for the curve layout edition window.
gchar * axis[3]
Definition w_axis.c:65
double scale(double axe)
find appropriate major tick spacing based on axis length
Definition curve.c:204
void update_curve(gpointer data)
update curve rendering
Definition curve.c:589
Variable declarations for the curve widget Functions for interactions with the curve widget.
const gchar * default_title(int ax, int c)
default title string
Definition title.c:54
double pi
Definition global.c:195
Global variable declarations Global convenience function declarations Global data structure defin...
@ IMG_NONE
Definition global.h:232
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 * font_button(gchar *font, int dimx, int dimy, GCallback handler, gpointer data)
create a font selection button
Definition gtk-misc.c:1730
const gchar * entry_get_text(GtkEntry *entry)
get the text in a GtkEntry
Definition gtk-misc.c:577
#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 * 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
GtkWidget * check_button(gchar *text, int dimx, int dimy, gboolean state, GCallback handler, gpointer data)
create a check button
Definition gtk-misc.c:1779
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 * 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
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
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 * create_hscale(float min, float max, float delta, float val, int pos, int round, int size, GCallback handler, GCallback scroll_handler, gpointer data)
create an horizontal scale GtkWidget
Definition gtk-misc.c:724
void update_entry_text(GtkEntry *entry, gchar *text)
update the content of a GtkEntry as string
Definition gtk-misc.c:651
GtkWidget * create_vbox(int spacing)
create a GtkBox with vertical orientation
Definition gtk-misc.c:781
GtkWidget * abox(GtkWidget *box, char *lab, int vspace)
box creating routine, to help design faster elements for the GUI
Definition gtk-misc.c:1892
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.
void autoscale(gpointer data)
autoscale callback
Definition m_curve.c:82
Function declarations for reading atomes project file Function declarations for saving atomes proje...
Definition global.h:106
Definition global.h:98
int b
Definition global.h:100
int c
Definition global.h:101
int a
Definition global.h:99
GtkWidget * mats[2]
Definition tab-4.c:107
G_MODULE_EXPORT void update_axis(GtkComboBox *widg, gpointer data)
change the axis
Definition tab-4.c:749
G_MODULE_EXPORT void set_lab_shift_x_spin(GtkSpinButton *res, gpointer data)
set ticks label position shift on x axis
Definition tab-4.c:325
GtkWidget * ticks_labels_angle
Definition tab-4.c:95
int b
Definition tab-4.c:114
GtkWidget * majt
Definition tab-4.c:103
G_MODULE_EXPORT void set_axis_title_font(GtkFontButton *fontb, gpointer data)
set axis title font
Definition tab-4.c:703
G_MODULE_EXPORT void set_lab_digit_spin(GtkSpinButton *res, gpointer data)
set ticks label number of digit(s)
Definition tab-4.c:300
GtkWidget * ticks_pos_box
Definition tab-4.c:93
GtkWidget * axis_title_font
Definition tab-4.c:102
G_MODULE_EXPORT void set_grid(GtkToggleButton *grid, gpointer data)
show / hide grid toggle callback GTK3
Definition tab-4.c:604
GtkWidget * npty[2]
Definition tab-4.c:109
G_MODULE_EXPORT gboolean scroll_set_ticks_angle(GtkRange *range, GtkScrollType scroll, gdouble value, gpointer data)
set ticks angle callback - scroll
Definition tab-4.c:520
GtkWidget * vmin
Definition tab-4.c:104
GtkWidget * nmi[2]
Definition tab-4.c:106
G_MODULE_EXPORT void set_axis_max(GtkEntry *res, gpointer data)
set axis max
Definition tab-4.c:167
GtkWidget * show_grid
Definition tab-4.c:98
G_MODULE_EXPORT void set_max_div(GtkEntry *maj, gpointer data)
set number of major tick divisions
Definition tab-4.c:197
int c
Definition tab-4.c:114
GtkWidget * nptx[2]
Definition tab-4.c:109
GtkWidget * axis_title
Definition tab-4.c:101
int d
Definition tab-4.c:114
GtkWidget * mits[2]
Definition tab-4.c:108
GtkWidget * scale_box
Definition tab-4.c:91
GtkWidget * show_axis
Definition tab-4.c:97
G_MODULE_EXPORT void set_io_ticks(GtkComboBox *box, gpointer data)
change tick marks location
Definition tab-4.c:421
GtkWidget * vmax
Definition tab-4.c:105
GtkWidget * ticks_labels_font
Definition tab-4.c:96
G_MODULE_EXPORT void set_pos_ticks(GtkComboBox *box, gpointer data)
change tick marks position
Definition tab-4.c:440
G_MODULE_EXPORT void set_pos_labels(GtkComboBox *box, gpointer data)
change ticks labels position
Definition tab-4.c:459
int handler_id
Definition tab-4.c:739
G_MODULE_EXPORT void set_scale(GtkComboBox *sbox, gpointer data)
change the axis scale
Definition tab-4.c:724
qint framxe[4]
Definition tab-1.c:93
GtkWidget * create_tab_4(gpointer data)
handle the creation of the 4th tab of the curve edition dialog
Definition tab-4.c:820
G_MODULE_EXPORT void set_axis_title_x_spin(GtkSpinButton *res, gpointer data)
set axis title position shift on x axis
Definition tab-4.c:375
G_MODULE_EXPORT void set_ticks_angle(GtkRange *range, gpointer data)
set ticks angle callback - range
Definition tab-4.c:534
GtkWidget * auto_scale
Definition tab-4.c:99
int a
Definition tab-1.c:95
G_MODULE_EXPORT void set_autoscale(GtkButton *autosc, gpointer data)
autoscale axis
Definition tab-4.c:628
G_MODULE_EXPORT void to_axis_title(GtkToggleButton *but, gpointer data)
show / hide axis title toggle callback GTK3
Definition tab-4.c:558
GtkWidget * ndi[2]
Definition tab-4.c:106
GtkWidget * ticks_inout_box
Definition tab-4.c:92
G_MODULE_EXPORT void set_axis_title_y_spin(GtkSpinButton *res, gpointer data)
set axis title position shift on y axis
Definition tab-4.c:398
G_MODULE_EXPORT void set_axis_min(GtkEntry *res, gpointer data)
set axis min
Definition tab-4.c:134
qint dataxe[2]
Definition tab-1.c:92
void ticks_angle_has_changed(gpointer data, double value)
set ticks angle
Definition tab-4.c:499
G_MODULE_EXPORT void set_axis(GtkToggleButton *axis, gpointer data)
show / hide axis toggle callback GTK3
Definition tab-4.c:658
G_MODULE_EXPORT void set_ticks_size_major_spin(GtkSpinButton *res, gpointer data)
set major ticks size
Definition tab-4.c:252
GtkWidget * axis_default_title
Definition tab-4.c:100
GtkWidget * axischoice
Definition tab-4.c:90
int get_active_axis()
get active axis
Definition tab-4.c:121
GtkWidget * tptx[2]
Definition tab-4.c:110
G_MODULE_EXPORT void set_lab_shift_y_spin(GtkSpinButton *res, gpointer data)
set ticks label position shift on y axis
Definition tab-4.c:350
G_MODULE_EXPORT void set_ticks_size_minor_spin(GtkSpinButton *res, gpointer data)
set minor ticks size
Definition tab-4.c:275
GtkWidget * labels_pos_box
Definition tab-4.c:94
G_MODULE_EXPORT void set_axis_legend(GtkEntry *xtit, gpointer data)
set axis legend entry callback
Definition tab-4.c:682
GtkWidget * tpty[2]
Definition tab-4.c:110
G_MODULE_EXPORT void set_min_div_spin(GtkSpinButton *res, gpointer data)
set number of minor tick division(s)
Definition tab-4.c:229
G_MODULE_EXPORT void set_ticks_labels_font(GtkFontButton *fontb, gpointer data)
set ticks labels font
Definition tab-4.c:478
GtkWidget * res[2]
Definition w_encode.c:212