atomes 1.3.1
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-2026 by CNRS and University of Strasbourg */
15
21
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 (this_curve -> curve_edit);
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
97{
98 return combo_get_active (cedit -> axischoice);
99}
100
109G_MODULE_EXPORT void set_axis_min (GtkEntry * res, gpointer data)
110{
111 Curve * this_curve = get_curve_from_pointer (data);
112 int i = get_active_axis (this_curve -> curve_edit);
113 if (i > -1)
114 {
115 const gchar * m;
116 m = entry_get_text (res);
117 if (string_to_double ((gpointer)m) < this_curve -> axmax[i])
118 {
119 this_curve -> axmin[i] = string_to_double ((gpointer)m);
120 }
121 else
122 {
123 show_warning (_("Axis min must be < to axis max"), this_curve -> window);
124 }
125 update_entry_double (res, this_curve -> axmin[i]);
126 update_curve (data);
127 }
128}
129
138G_MODULE_EXPORT void set_axis_max (GtkEntry * res, gpointer data)
139{
140 Curve * this_curve = get_curve_from_pointer (data);
141 int i = get_active_axis (this_curve -> curve_edit);
142 const gchar * m;
143 m = entry_get_text (res);
144 if (string_to_double ((gpointer)m) > this_curve -> axmin[i])
145 {
146 this_curve -> axmax[i] = string_to_double ((gpointer)m);
147 }
148 else
149 {
150 show_warning (_("Axis max must be > to axis min"), this_curve -> window);
151 }
152 update_entry_double (res, this_curve -> axmax[i]);
153 update_curve (data);
154}
155
164G_MODULE_EXPORT void set_max_div (GtkEntry * maj, gpointer data)
165{
166 Curve * this_curve = get_curve_from_pointer (data);
167 int i = get_active_axis (this_curve -> curve_edit);
168 double tmp;
169 const gchar * m;
170 m = entry_get_text (maj);
171 tmp = string_to_double ((gpointer)m);
172 if (tmp != 0.0)
173 {
174 this_curve -> majt[i] = tmp;
175 update_curve (data);
176 }
177 else
178 {
179 show_warning (_("Major tick must be > 0.0"), this_curve -> window);
180 }
181 update_entry_double (maj, this_curve -> majt[i]);
182}
183
192G_MODULE_EXPORT void set_min_div_spin (GtkSpinButton * res, gpointer data)
193{
194 qint * ad = (qint *) data;
195 tint cd;
196 cd.a = ad -> a;
197 cd.b = ad -> b;
198 cd.c = ad -> c;
199 get_curve_from_pointer ((gpointer)& cd) -> mint[ad -> d] = gtk_spin_button_get_value_as_int(res) + 1;
200 update_curve ((gpointer)& cd);
201}
202
211G_MODULE_EXPORT void set_ticks_size_major_spin (GtkSpinButton * res, gpointer data)
212{
213 qint * ad = (qint *) data;
214 tint cd;
215 cd.a = ad -> a;
216 cd.b = ad -> b;
217 cd.c = ad -> c;
218 get_curve_from_pointer ((gpointer)& cd) -> majt_size[ad -> d] = gtk_spin_button_get_value_as_int(res);
219 update_curve ((gpointer)& cd);
220}
221
230G_MODULE_EXPORT void set_ticks_size_minor_spin (GtkSpinButton * res, gpointer data)
231{
232 qint * ad = (qint *) data;
233 tint cd;
234 cd.a = ad -> a;
235 cd.b = ad -> b;
236 cd.c = ad -> c;
237 Curve * this_curve = get_curve_from_pointer ((gpointer)& cd);
238 this_curve -> mint_size[ad -> d] = gtk_spin_button_get_value_as_int(res);
239 update_entry_int (GTK_ENTRY(res), this_curve -> mint_size[ad -> d]);
240 update_curve ((gpointer)& cd);
241}
242
251G_MODULE_EXPORT void set_lab_digit_spin (GtkSpinButton * res, gpointer data)
252{
253 qint * ad = (qint *) data;
254 tint cd;
255 cd.a = ad -> a;
256 cd.b = ad -> b;
257 cd.c = ad -> c;
258 Curve * this_curve = get_curve_from_pointer ((gpointer)& cd);
259 this_curve -> labels_digit[ad -> d] = gtk_spin_button_get_value_as_int(res);
260 update_entry_int (GTK_ENTRY(res), this_curve -> labels_digit[ad -> d]);
261 update_curve ((gpointer)& cd);
262}
263
272G_MODULE_EXPORT void set_lab_shift_x_spin (GtkSpinButton * res, gpointer data)
273{
274 qint * ad = (qint *) data;
275 tint cd;
276 cd.a = ad -> a;
277 cd.b = ad -> b;
278 cd.c = ad -> c;
279 Curve * this_curve = get_curve_from_pointer ((gpointer)& cd);
280 this_curve -> labels_shift_x[ad -> d] = gtk_spin_button_get_value_as_int(res);
281 update_entry_int (GTK_ENTRY(res), this_curve -> labels_shift_x[ad -> d]);
282 update_curve ((gpointer)& cd);
283}
284
293G_MODULE_EXPORT void set_lab_shift_y_spin (GtkSpinButton * res, gpointer data)
294{
295 qint * ad = (qint *) data;
296 tint cd;
297 cd.a = ad -> a;
298 cd.b = ad -> b;
299 cd.c = ad -> c;
300 Curve * this_curve = get_curve_from_pointer ((gpointer)& cd);
301 this_curve -> labels_shift_y[ad -> d] = gtk_spin_button_get_value_as_int(res);
302 update_entry_int (GTK_ENTRY(res), this_curve -> labels_shift_y[ad -> d]);
303 update_curve ((gpointer)& cd);
304}
305
314G_MODULE_EXPORT void set_axis_title_x_spin (GtkSpinButton * res, gpointer data)
315{
316 qint * ad = (qint *) data;
317 tint cd;
318 cd.a = ad -> a;
319 cd.b = ad -> b;
320 cd.c = ad -> c;
321 get_curve_from_pointer ((gpointer)& cd) -> axis_title_x[ad -> d] = gtk_spin_button_get_value_as_int(res);
322 update_curve ((gpointer)& cd);
323}
324
333G_MODULE_EXPORT void set_axis_title_y_spin (GtkSpinButton * res, gpointer data)
334{
335 qint * ad = (qint *) data;
336 tint cd;
337 cd.a = ad -> a;
338 cd.b = ad -> b;
339 cd.c = ad -> c;
340 get_curve_from_pointer ((gpointer)& cd) -> axis_title_y[ad -> d] = gtk_spin_button_get_value_as_int(res);
341 update_curve ((gpointer)& cd);
342}
343
352G_MODULE_EXPORT void set_io_ticks (GtkComboBox * box, gpointer data)
353{
354 Curve * this_curve = get_curve_from_pointer(data);
355 int i = get_active_axis (this_curve -> curve_edit);
356 this_curve -> ticks_io[i] = combo_get_active ((GtkWidget *)box);
357 update_curve (data);
358}
359
368G_MODULE_EXPORT void set_pos_ticks (GtkComboBox * box, gpointer data)
369{
370 Curve * this_curve = get_curve_from_pointer(data);
371 int i = get_active_axis (this_curve -> curve_edit);
372 this_curve -> ticks_pos[i] = combo_get_active ((GtkWidget *)box);
373 update_curve (data);
374}
375
384G_MODULE_EXPORT void set_pos_labels (GtkComboBox * box, gpointer data)
385{
386 Curve * this_curve = get_curve_from_pointer(data);
387 int i = get_active_axis (this_curve -> curve_edit);
388 this_curve -> labels_pos[i] = combo_get_active ((GtkWidget *)box);
389 update_curve (data);
390}
391
400G_MODULE_EXPORT void set_ticks_labels_font (GtkFontButton * fontb, gpointer data)
401{
402 Curve * this_curve = get_curve_from_pointer (data);
403 int i = get_active_axis (this_curve -> curve_edit);
404 g_free (this_curve -> labels_font[i]);
405 this_curve -> labels_font[i] = g_strdup_printf ("%s", gtk_font_chooser_get_font (GTK_FONT_CHOOSER(fontb)));
406 update_curve (data);
407}
408
417void ticks_angle_has_changed (gpointer data, double value)
418{
419 Curve * this_curve = get_curve_from_pointer (data);
420 int i = get_active_axis (this_curve -> curve_edit);
421 this_curve -> labels_angle[i] = value * (pi/180.0);
422 update_curve (data);
423}
424
435G_MODULE_EXPORT gboolean scroll_set_ticks_angle (GtkRange * range, GtkScrollType scroll, gdouble value, gpointer data)
436{
437 ticks_angle_has_changed (data, value);
438 return FALSE;
439}
440
449G_MODULE_EXPORT void set_ticks_angle (GtkRange * range, gpointer data)
450{
451 ticks_angle_has_changed (data, gtk_range_get_value (range));
452}
453
454#ifdef GTK4
463G_MODULE_EXPORT void to_axis_title (GtkCheckButton * but, gpointer data)
464#else
473G_MODULE_EXPORT void to_axis_title (GtkToggleButton * but, gpointer data)
474#endif
475{
476 Curve * this_curve = get_curve_from_pointer (data);
477 curve_edition * cedit = this_curve -> curve_edit;
478 int i = get_active_axis (cedit);
479 if (button_get_status ((GtkWidget *)but))
480 {
481 widget_set_sensitive (cedit -> axis_title, 0);
482 g_free (this_curve -> axis_title[i]);
483 this_curve -> axis_title[i] = g_strdup_printf ("%s", default_title (i, data));
484 update_entry_text (GTK_ENTRY(cedit -> axis_title), this_curve -> axis_title[i]);
485 }
486 else
487 {
488 widget_set_sensitive (cedit -> axis_title, 1);
489 }
490 update_curve (data);
491}
492
493#ifdef GTK4
502G_MODULE_EXPORT void set_grid (GtkCheckButton * grid, gpointer data)
503#else
512G_MODULE_EXPORT void set_grid (GtkToggleButton * grid, gpointer data)
513#endif
514{
515 Curve * this_curve = get_curve_from_pointer (data);
516 int i = get_active_axis (this_curve -> curve_edit);
517 this_curve -> show_grid[i] = button_get_status ((GtkWidget *)grid);
518 update_curve (data);
519}
520
529G_MODULE_EXPORT void set_autoscale (GtkButton * autosc, gpointer data)
530{
531 Curve * this_curve = get_curve_from_pointer (data);
532 int i = get_active_axis (this_curve -> curve_edit);
533 this_curve -> autoscale[i] = TRUE;
534 update_curve (data);
535}
536
537#ifdef GTK4
546G_MODULE_EXPORT void set_axis (GtkCheckButton * axis, gpointer data)
547#else
556G_MODULE_EXPORT void set_axis (GtkToggleButton * axis, gpointer data)
557#endif
558{
559 Curve * this_curve = get_curve_from_pointer (data);
560 int i = get_active_axis (this_curve -> curve_edit);
561 this_curve -> show_axis[i] = button_get_status ((GtkWidget *)axis);
562 update_curve (data);
563}
564
573G_MODULE_EXPORT void set_axis_legend (GtkEntry * xtit, gpointer data)
574{
575 Curve * this_curve = get_curve_from_pointer (data);
576 int i = get_active_axis (this_curve -> curve_edit);
577 g_free (this_curve -> axis_title[i]);
578 this_curve -> axis_title[i] = g_strdup_printf ("%s", entry_get_text (xtit));
579 update_curve (data);
580}
581
590G_MODULE_EXPORT void set_axis_title_font (GtkFontButton * fontb, gpointer data)
591{
592 Curve * this_curve = get_curve_from_pointer (data);
593 int i = get_active_axis (this_curve -> curve_edit);
594 g_free (this_curve -> axis_title_font[i]);
595 this_curve -> axis_title_font[i] = g_strdup_printf ("%s", gtk_font_chooser_get_font (GTK_FONT_CHOOSER(fontb)));
596 update_curve (data);
597}
598
607G_MODULE_EXPORT void set_scale (GtkComboBox * sbox, gpointer data)
608{
609 Curve * this_curve = get_curve_from_pointer (data);
610 int i = get_active_axis (this_curve -> curve_edit);
611 int j = combo_get_active((GtkWidget *)sbox);
612 this_curve -> scale[i] = j;
613 widget_set_sensitive (this_curve -> curve_edit -> majt, ! j);
614 widget_set_sensitive (this_curve -> curve_edit -> nmi[i], ! j);
615 this_curve -> autoscale[i] = TRUE;
616 update_curve (data);
617}
618
627G_MODULE_EXPORT void update_axis (GtkComboBox * box, gpointer data)
628{
629 int i;
630 Curve * this_curve = get_curve_from_pointer (data);
631 curve_edition * cedit = this_curve -> curve_edit;
632 i = combo_get_active ((GtkWidget *)box);
633 update_entry_double (GTK_ENTRY(cedit -> vmin), this_curve -> axmin[i]);
634 update_entry_double (GTK_ENTRY(cedit -> vmax), this_curve -> axmax[i]);
635 update_entry_double (GTK_ENTRY(cedit -> majt), this_curve -> majt[i]);
636 combo_set_active (cedit -> ticks_inout_box, this_curve -> ticks_io[i]);
637 combo_set_active (cedit -> ticks_pos_box, this_curve -> ticks_pos[i]);
638 combo_set_active (cedit -> labels_pos_box, this_curve -> labels_pos[i]);
639 gtk_font_chooser_set_font (GTK_FONT_CHOOSER(cedit -> ticks_labels_font), this_curve -> labels_font[i]);
640 gtk_range_set_value (GTK_RANGE(cedit -> ticks_labels_angle), this_curve -> labels_angle[i] * (180.0/pi));
641 if (((tint *)data) -> b < MSD)
642 {
643 widget_set_sensitive (cedit -> scale_box, 0);
644 }
645 else
646 {
647 g_signal_handler_disconnect (G_OBJECT(cedit -> scale_box), cedit -> handler_id);
648 combo_set_active (cedit -> scale_box, this_curve -> scale[i]);
649 cedit -> handler_id = g_signal_connect (G_OBJECT(cedit -> scale_box), "changed", G_CALLBACK(set_scale), data);
650 widget_set_sensitive (cedit -> scale_box, 1);
651 /* widget_set_sensitive (cedit -> vmax, ! this_curve -> scale[i]);
652 widget_set_sensitive (cedit -> vmin, ! this_curve -> scale[i]); */
653 widget_set_sensitive (cedit -> majt, ! this_curve -> scale[i]);
654 widget_set_sensitive (cedit -> nmi[i], ! this_curve -> scale[i]);
655 }
656 hide_the_widgets (cedit -> nmi[! i]);
657 hide_the_widgets (cedit -> ndi[! i]);
658 hide_the_widgets (cedit -> mats[! i]);
659 hide_the_widgets (cedit -> mits[! i]);
660 hide_the_widgets (cedit -> nptx[! i]);
661 hide_the_widgets (cedit -> npty[! i]);
662 hide_the_widgets (cedit -> tptx[! i]);
663 hide_the_widgets (cedit -> tpty[! i]);
664
665 show_the_widgets (cedit -> nmi[i]);
666 show_the_widgets (cedit -> ndi[i]);
667 show_the_widgets (cedit -> mats[i]);
668 show_the_widgets (cedit -> mits[i]);
669 show_the_widgets (cedit -> nptx[i]);
670 show_the_widgets (cedit -> npty[i]);
671 show_the_widgets (cedit -> tptx[i]);
672 show_the_widgets (cedit -> tpty[i]);
673
674 button_set_status (cedit -> show_axis, this_curve -> show_axis[i]);
675 button_set_status (cedit -> show_grid, this_curve -> show_grid[i]);
676 button_set_status (cedit -> axis_default_title, this_curve -> axis_defaut_title[i]);
677
678 widget_set_sensitive (cedit -> axis_title, ! this_curve -> axis_defaut_title[i]);
679 update_entry_text (GTK_ENTRY(cedit -> axis_title), this_curve -> axis_title[i]);
680 gtk_font_chooser_set_font (GTK_FONT_CHOOSER(cedit -> axis_title_font), this_curve -> axis_title_font[i]);
681}
682
691GtkWidget * create_tab_4 (curve_edition * cedit, gpointer data)
692{
693 Curve * this_curve = get_curve_from_pointer (data);
694 int i;
695 GtkWidget * axisbox;
696#ifdef GTK4
697 axisbox = create_vbox (3);
698#else
699 axisbox = create_vbox (BSEP);
700#endif
701 GtkWidget * ahbox = create_hbox (0);
702 add_box_child_start (GTK_ORIENTATION_VERTICAL, axisbox, ahbox, FALSE, FALSE, 5);
703 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, markup_label(_("<b>Select axis:</b>"), 175, -1, 1.0, 0.5), FALSE, FALSE, 0);
704 cedit -> axischoice = create_combo ();
705 combo_text_append (cedit -> axischoice, _("X axis"));
706 combo_text_append (cedit -> axischoice, _("Y axis"));
707 combo_set_active (cedit -> axischoice, 0);
708 gtk_widget_set_size_request (cedit -> axischoice, 80, 35);
709 g_signal_connect (G_OBJECT(cedit -> axischoice), "changed", G_CALLBACK(update_axis), data);
710 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, cedit -> axischoice, FALSE, FALSE, 25);
711
712 add_box_child_start (GTK_ORIENTATION_VERTICAL, axisbox, gtk_separator_new (GTK_ORIENTATION_HORIZONTAL), FALSE, FALSE, 5);
713
714 ahbox = create_hbox (0);
715 add_box_child_start (GTK_ORIENTATION_VERTICAL, axisbox, ahbox, FALSE, FALSE, 0);
716 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, markup_label(_("Scale type:"), 100, -1, 0.0, 0.5), FALSE, FALSE, 0);
717 cedit -> scale_box = create_combo ();
718 combo_text_append (cedit -> scale_box, _("Linear"));
719 combo_text_append (cedit -> scale_box, "Log");
720 combo_set_active (cedit -> scale_box, this_curve -> scale[0]);
721 gtk_widget_set_size_request (cedit -> scale_box, 80, -1);
722 cedit -> handler_id = g_signal_connect (G_OBJECT(cedit -> scale_box), "changed", G_CALLBACK(set_scale), data);
723 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, cedit -> scale_box, FALSE, FALSE, 0);
724 cedit -> auto_scale = create_button (_("Autoscale axis"), IMG_NONE, NULL, -1, -1, GTK_RELIEF_NORMAL, G_CALLBACK(set_autoscale), data);
725 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, cedit -> auto_scale, FALSE, FALSE, 30);
726
727// Axis min and max
728 ahbox = create_hbox (0);
729 add_box_child_start (GTK_ORIENTATION_VERTICAL, axisbox, ahbox, FALSE, FALSE, 5);
730 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, markup_label(_("Min:"), 30, -1, 0.5, 0.5), FALSE, FALSE, 20);
731 cedit -> vmin = create_entry (G_CALLBACK(set_axis_min), 100, 15, FALSE, data);
732 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, cedit -> vmin, FALSE, FALSE, 0);
733 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, markup_label(_("Max:"), 30, -1, 0.5, 0.5), FALSE, FALSE, 20);
734 cedit -> vmax = create_entry (G_CALLBACK(set_axis_max), 100, 15, FALSE, data);
735 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, cedit -> vmax, FALSE, FALSE, 0);
736
737// Major ticks spacing
738 ahbox = create_hbox (0);
739 add_box_child_start (GTK_ORIENTATION_VERTICAL, axisbox, ahbox, FALSE, FALSE, 1);
740 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, markup_label(_("Major ticks spacing:"), 160, -1, 0.0, 0.5), FALSE, FALSE, 10);
741 cedit -> majt = create_entry (G_CALLBACK(set_max_div), 100, 15, FALSE, data);
742 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, cedit -> majt, FALSE, FALSE, 0);
743
744// Number of minors ticks
745 ahbox = create_hbox (0);
746 add_box_child_start (GTK_ORIENTATION_VERTICAL, axisbox, ahbox, FALSE, FALSE, 1);
747 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, markup_label(_("Number of minor ticks:"), 160, -1, 0.0, 0.5), FALSE, FALSE, 10);
748 for (i=0; i<2; i++)
749 {
750 cedit -> nmi[i] = spin_button (G_CALLBACK(set_min_div_spin), (double)this_curve -> mint[i]-1.0, 0.0, 100.0, 1.0, 0, 50, & cedit -> dataxe[i]);
751 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, cedit -> nmi[i], FALSE, FALSE, 0);
752 }
753
754// Ticks ...
755 ahbox = create_hbox (0);
756 add_box_child_start (GTK_ORIENTATION_VERTICAL, axisbox, ahbox, FALSE, FALSE, 5);
757 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, markup_label(_("<u>Tick marks:</u>"), -1, -1, 0.0, 0.5), FALSE, FALSE, 0);
758
759// ... position ...
760 ahbox = abox (axisbox, _("Location:"), 1);
761 cedit -> ticks_inout_box = create_combo ();
762 combo_text_append (cedit -> ticks_inout_box, _("In"));
763 combo_text_append (cedit -> ticks_inout_box, _("Out"));
764 gtk_widget_set_size_request (cedit -> ticks_inout_box, 60, -1);
765 g_signal_connect (G_OBJECT(cedit -> ticks_inout_box), "changed", G_CALLBACK(set_io_ticks), data);
766 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, cedit -> ticks_inout_box, FALSE, FALSE, 3);
767
768 cedit -> ticks_pos_box = create_combo ();
769 combo_text_append (cedit -> ticks_pos_box, _("Normal"));
770 combo_text_append (cedit -> ticks_pos_box, _("Opposite"));
771 combo_text_append (cedit -> ticks_pos_box, _("Both"));
772 combo_text_append (cedit -> ticks_pos_box, _("None"));
773 gtk_widget_set_size_request (cedit -> ticks_pos_box, 100, -1);
774 g_signal_connect (G_OBJECT(cedit -> ticks_pos_box), "changed", G_CALLBACK(set_pos_ticks), data);
775 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, cedit -> ticks_pos_box, FALSE, FALSE, 3);
776
777// ... sizes ...
778
779 ahbox = abox (axisbox, _("Major ticks size:"), 1);
780 for (i=0; i<2; i++)
781 {
782 cedit -> mats[i] = spin_button (G_CALLBACK(set_ticks_size_major_spin), (double)this_curve -> majt_size[i], 0.0, 100.0, 1.0, 0, 50, & cedit -> dataxe[i]);
783 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, cedit -> mats[i], FALSE, FALSE, 0);
784 }
785 ahbox = abox (axisbox, _("Minor ticks size:"), 1);
786 for (i=0; i<2; i++)
787 {
788 cedit -> mits[i] = spin_button (G_CALLBACK(set_ticks_size_minor_spin), (double)this_curve -> mint_size[i], 0.0, 100.0, 1.0, 0, 50, & cedit -> dataxe[i]);
789 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, cedit -> mits[i], FALSE, FALSE, 0);
790 }
791
792// Ticks labels ...
793 ahbox = create_hbox (0);
794 add_box_child_start (GTK_ORIENTATION_VERTICAL, axisbox, ahbox, FALSE, FALSE, 5);
795 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, markup_label(_("<u>Tick labels:</u>"), -1, -1, 0.0, 0.5), FALSE, FALSE, 0);
796
797// ... position ...
798 ahbox = abox (axisbox, _("Location:"), 1);
799 cedit -> labels_pos_box = create_combo ();
800 combo_text_append (cedit -> labels_pos_box, _("Normal"));
801 combo_text_append (cedit -> labels_pos_box, _("Opposite"));
802 combo_text_append (cedit -> labels_pos_box, _("Both"));
803 combo_text_append (cedit -> labels_pos_box, _("None"));
804 gtk_widget_set_size_request (cedit -> labels_pos_box, 150, -1);
805 g_signal_connect (G_OBJECT(cedit -> labels_pos_box), "changed", G_CALLBACK(set_pos_labels), data);
806 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, cedit -> labels_pos_box, FALSE, FALSE, 0);
807
808// ... significant digits ...
809 ahbox = abox (axisbox, _("Significant digits:"), 1);
810 for (i=0; i<2; i++)
811 {
812 cedit -> ndi[i] = spin_button (G_CALLBACK(set_lab_digit_spin), (double)this_curve -> labels_digit[i], 0.0, 100.0, 1.0, 0, 50, & cedit -> dataxe[i]);
813 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, cedit -> ndi[i], FALSE, FALSE, 0);
814 }
815
816// ... font ...
817 cedit -> ticks_labels_font = font_button (this_curve -> labels_font[0], 150, 35, G_CALLBACK(set_ticks_labels_font), data);
818 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, abox (axisbox, _("Font:"), 1), cedit -> ticks_labels_font, FALSE, FALSE, 5);
819
820// ... angle ..
821 cedit -> 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);
822 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, abox (axisbox, _("Angle:"), 1), cedit -> ticks_labels_angle, FALSE, FALSE, 5);
823
824// ...distance to axis
825 ahbox = abox (axisbox, _("Position: "), 1);
826 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, markup_label("x:", -1, -1, 0.9, 0.5), FALSE, FALSE, 10);
827 for (i=0; i<2; i++)
828 {
829 cedit -> nptx[i] = spin_button (G_CALLBACK(set_lab_shift_x_spin), (double)this_curve -> labels_shift_x[i], -100.0, 100.0, 1.0, 0, 50, & cedit -> dataxe[i]);
830 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, cedit -> nptx[i], FALSE, FALSE, 0);
831 }
832 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, markup_label("y:", -1, -1, 0.9, 0.5), FALSE, FALSE, 10);
833 for (i=0; i<2; i++)
834 {
835 cedit -> npty[i] = spin_button (G_CALLBACK(set_lab_shift_y_spin), (double) this_curve -> labels_shift_y[i], -100.0, 100.0, 1.0, 0, 50, & cedit -> dataxe[i]);
836 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, cedit -> npty[i], FALSE, FALSE, 0);
837 }
838
839 cedit -> show_axis = check_button (_("Show/Hide axis (if min[axis] &lt; 0.0 &lt; max[axis])"), 100, 30, FALSE, G_CALLBACK(set_axis), data);
840 add_box_child_start (GTK_ORIENTATION_VERTICAL, axisbox, cedit -> show_axis, FALSE, FALSE, 3);
841 cedit -> show_grid = check_button (_("Show/Hide axis grid"), 100, 30, FALSE, G_CALLBACK(set_grid), data);
842 add_box_child_start (GTK_ORIENTATION_VERTICAL, axisbox, cedit -> show_grid, FALSE, FALSE, 1);
843
844// Axis title
845 ahbox = create_hbox (0);
846 add_box_child_start (GTK_ORIENTATION_VERTICAL, axisbox, ahbox, FALSE, FALSE,3);
847 cedit -> axis_default_title = check_button (_("Use default axis title"), 175, -1, FALSE, G_CALLBACK(to_axis_title), data);
848 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, cedit -> axis_default_title, FALSE, FALSE, 0);
849 cedit -> axis_title = create_entry (G_CALLBACK(set_axis_legend), 150, 15, FALSE, data);
850 gtk_entry_set_alignment (GTK_ENTRY(cedit -> axis_title), 0.0);
851 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, cedit -> axis_title, FALSE, FALSE, 0);
852
853 cedit -> axis_title_font = font_button (this_curve -> axis_title_font[0], 150, 35, G_CALLBACK(set_axis_title_font), data);
854 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, abox (axisbox, _("Font:"), 3), cedit -> axis_title_font, FALSE, FALSE, 0);
855
856 ahbox = abox (axisbox, _("Position: "), 3);
857 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, markup_label("x:", -1, -1, 0.9, 0.5), FALSE, FALSE, 10);
858 for (i=0; i<2; i++)
859 {
860 cedit -> tptx[i] = spin_button (G_CALLBACK(set_axis_title_x_spin), (double)this_curve -> axis_title_x[i], -500.0, 500.0, 1.0, 0, 50, & cedit -> dataxe[i]);
861 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, cedit -> tptx[i], FALSE, FALSE, 0);
862 }
863 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, markup_label("y:", -1, -1, 0.9, 0.5), FALSE, FALSE, 10);
864 for (i=0; i<2; i++)
865 {
866 cedit -> tpty[i] = spin_button (G_CALLBACK(set_axis_title_y_spin), (double)this_curve -> axis_title_y[i], -500.0, 500.0, 1.0, 0, 50, & cedit -> dataxe[i]);
867 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, cedit -> tpty[i], FALSE, FALSE, 0);
868 }
869 return axisbox;
870}
Callback declarations for main window.
G_MODULE_EXPORT void update_axis(GtkComboBox *widg, gpointer data)
change the axis
Definition tab-4.c:627
double scale(double axe)
find appropriate major tick spacing based on axis length
Definition curve.c:205
Curve * get_curve_from_pointer(gpointer data)
get Curve pointer from pointer
Definition curve.c:313
void update_curve(gpointer data)
update curve rendering
Definition curve.c:635
Variable declarations for the curve widget Functions for interactions with the curve widget.
GtkWidget * majt
GtkWidget * vmin
GtkWidget * nmi[2]
const gchar * default_title(int ax, gpointer data)
default title string
Definition title.c:54
GtkWidget * axischoice
GtkWidget * vmax
Definition curve.h:58
double pi
Definition global.c:202
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_NONE
Definition global.h:276
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 * font_button(gchar *font, int dimx, int dimy, GCallback handler, gpointer data)
create a font selection button
Definition gtk-misc.c:1855
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
#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 button_set_status(GtkWidget *button, int status)
set status of check / toggle button
Definition gtk-misc.c:1916
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:1877
GtkWidget * check_button(gchar *text, int dimx, int dimy, gboolean state, GCallback handler, gpointer data)
create a check button
Definition gtk-misc.c:1937
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:1999
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
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
void combo_text_append(GtkWidget *combo, gchar *text)
append text in GtkComboBox widget
Definition gtk-misc.c:987
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:780
void update_entry_text(GtkEntry *entry, gchar *text)
update the content of a GtkEntry as string
Definition gtk-misc.c:726
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
GtkWidget * abox(GtkWidget *box, char *lab, int vspace)
box creating routine, to help design faster elements for the GUI
Definition gtk-misc.c:2067
#define MSD
Definition global.h:346
void show_the_widgets(GtkWidget *widg)
show GtkWidget
Definition gtk-misc.c:202
void show_warning(char *warning, GtkWidget *win)
show warning
Definition interface.c:266
Messaging function declarations.
void autoscale(gpointer data)
autoscale callback
Definition m_curve.c:99
Function declarations for reading atomes project file Function declarations for saving atomes proje...
Definition glwin.h:332
Definition glwin.h:350
Definition global.h:126
Definition global.h:118
int b
Definition global.h:120
int c
Definition global.h:121
int a
Definition global.h:119
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:272
G_MODULE_EXPORT void set_axis_title_font(GtkFontButton *fontb, gpointer data)
set axis title font
Definition tab-4.c:590
G_MODULE_EXPORT void set_lab_digit_spin(GtkSpinButton *res, gpointer data)
set ticks label number of digit(s)
Definition tab-4.c:251
G_MODULE_EXPORT void update_axis(GtkComboBox *box, gpointer data)
change the axis
Definition tab-4.c:627
G_MODULE_EXPORT void set_grid(GtkToggleButton *grid, gpointer data)
show / hide grid toggle callback GTK3
Definition tab-4.c:512
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:435
G_MODULE_EXPORT void set_axis_max(GtkEntry *res, gpointer data)
set axis max
Definition tab-4.c:138
G_MODULE_EXPORT void set_max_div(GtkEntry *maj, gpointer data)
set number of major tick divisions
Definition tab-4.c:164
GtkWidget * create_tab_4(curve_edition *cedit, gpointer data)
handle the creation of the 4th tab of the curve edition dialog
Definition tab-4.c:691
G_MODULE_EXPORT void set_io_ticks(GtkComboBox *box, gpointer data)
change tick marks location
Definition tab-4.c:352
G_MODULE_EXPORT void set_pos_ticks(GtkComboBox *box, gpointer data)
change tick marks position
Definition tab-4.c:368
G_MODULE_EXPORT void set_pos_labels(GtkComboBox *box, gpointer data)
change ticks labels position
Definition tab-4.c:384
G_MODULE_EXPORT void set_scale(GtkComboBox *sbox, gpointer data)
change the axis scale
Definition tab-4.c:607
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:314
G_MODULE_EXPORT void set_ticks_angle(GtkRange *range, gpointer data)
set ticks angle callback - range
Definition tab-4.c:449
G_MODULE_EXPORT void set_autoscale(GtkButton *autosc, gpointer data)
autoscale axis
Definition tab-4.c:529
G_MODULE_EXPORT void to_axis_title(GtkToggleButton *but, gpointer data)
show / hide axis title toggle callback GTK3
Definition tab-4.c:473
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:333
G_MODULE_EXPORT void set_axis_min(GtkEntry *res, gpointer data)
set axis min
Definition tab-4.c:109
void ticks_angle_has_changed(gpointer data, double value)
set ticks angle
Definition tab-4.c:417
G_MODULE_EXPORT void set_axis(GtkToggleButton *axis, gpointer data)
show / hide axis toggle callback GTK3
Definition tab-4.c:556
G_MODULE_EXPORT void set_ticks_size_major_spin(GtkSpinButton *res, gpointer data)
set major ticks size
Definition tab-4.c:211
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:293
G_MODULE_EXPORT void set_ticks_size_minor_spin(GtkSpinButton *res, gpointer data)
set minor ticks size
Definition tab-4.c:230
G_MODULE_EXPORT void set_axis_legend(GtkEntry *xtit, gpointer data)
set axis legend entry callback
Definition tab-4.c:573
G_MODULE_EXPORT void set_min_div_spin(GtkSpinButton *res, gpointer data)
set number of minor tick division(s)
Definition tab-4.c:192
int get_active_axis(curve_edition *cedit)
get active axis
Definition tab-4.c:96
G_MODULE_EXPORT void set_ticks_labels_font(GtkFontButton *fontb, gpointer data)
set ticks labels font
Definition tab-4.c:400
GtkWidget * res[2]
Definition w_encode.c:342