atomes 1.2.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-2025 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{
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 (string_to_double ((gpointer)m) < this_proj -> curves[b][c] -> axmax[i])
147 {
148 this_proj -> curves[b][c] -> axmin[i] = string_to_double ((gpointer)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 (string_to_double ((gpointer)m) > this_proj -> curves[b][c] -> axmin[i])
178 {
179 this_proj -> curves[b][c] -> axmax[i] = string_to_double ((gpointer)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 = string_to_double ((gpointer)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] = combo_get_active ((GtkWidget *)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] = combo_get_active ((GtkWidget *)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] = combo_get_active ((GtkWidget *)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 if (button_get_status ((GtkWidget *)but))
567 {
569 project * this_proj = get_project_by_id(a);
570 g_free (this_proj -> curves[b][c] -> axis_title[i]);
571 this_proj -> curves[b][c] -> axis_title[i] = g_strdup_printf ("%s", default_title (i, c));
572 update_entry_text (GTK_ENTRY(axis_title), this_proj -> curves[b][c] -> axis_title[i]);
573 }
574 else
575 {
577 }
578 update_curve (data);
579}
580
581#ifdef GTK4
590G_MODULE_EXPORT void set_grid (GtkCheckButton * grid, gpointer data)
591#else
600G_MODULE_EXPORT void set_grid (GtkToggleButton * grid, gpointer data)
601#endif
602{
603 tint * ad = (tint *)data;
604 a = ad -> a;
605 b = ad -> b;
606 c = ad -> c;
607 int i = get_active_axis ();
608 get_project_by_id(a) -> curves[b][c] -> show_grid[i] = button_get_status ((GtkWidget *)grid);
609 update_curve (data);
610}
611
620G_MODULE_EXPORT void set_autoscale (GtkButton * autosc, gpointer data)
621{
622 tint * ad = (tint *)data;
623 a = ad -> a;
624 b = ad -> b;
625 c = ad -> c;
626 int i = get_active_axis ();
627 get_project_by_id(a) -> curves[b][c] -> autoscale[i] = TRUE;
628 update_curve (data);
629}
630
631#ifdef GTK4
640G_MODULE_EXPORT void set_axis (GtkCheckButton * axis, gpointer data)
641#else
650G_MODULE_EXPORT void set_axis (GtkToggleButton * axis, gpointer data)
651#endif
652{
653 tint * ad = (tint *)data;
654 a = ad -> a;
655 b = ad -> b;
656 c = ad -> c;
657 int i = get_active_axis ();
658 get_project_by_id(a) -> curves[b][c] -> show_axis[i] = button_get_status ((GtkWidget *)axis);
659 update_curve (data);
660}
661
670G_MODULE_EXPORT void set_axis_legend (GtkEntry * xtit, gpointer data)
671{
672 tint * ad = (tint *)data;
673 a = ad -> a;
674 b = ad -> b;
675 c = ad -> c;
676 int i = get_active_axis ();
677 project * this_proj = get_project_by_id(a);
678 g_free (this_proj -> curves[b][c] -> axis_title[i]);
679 this_proj -> curves[b][c] -> axis_title[i] = g_strdup_printf ("%s", entry_get_text (xtit));
680 update_curve (data);
681}
682
691G_MODULE_EXPORT void set_axis_title_font (GtkFontButton * fontb, gpointer data)
692{
693 tint * ad = (tint *)data;
694 a = ad -> a;
695 b = ad -> b;
696 c = ad -> c;
697 project * this_proj = get_project_by_id(a);
698 int i = get_active_axis ();
699 g_free (this_proj -> curves[b][c] -> axis_title_font[i]);
700 this_proj -> curves[b][c] -> axis_title_font[i] = g_strdup_printf ("%s", gtk_font_chooser_get_font (GTK_FONT_CHOOSER(fontb)));
701 update_curve (data);
702}
703
712G_MODULE_EXPORT void set_scale (GtkComboBox * sbox, gpointer data)
713{
714 tint * ad = (tint *)data;
715 a = ad -> a;
716 b = ad -> b;
717 c = ad -> c;
718 project * this_proj = get_project_by_id(a);
719 int i = get_active_axis ();
720 int j = combo_get_active((GtkWidget *)sbox);
721 this_proj -> curves[b][c] -> scale[i] = j;
723 widget_set_sensitive (nmi[i], ! j);
724 this_proj -> curves[b][c]-> autoscale[i] = TRUE;
725 update_curve (data);
726}
727
729
738G_MODULE_EXPORT void update_axis (GtkComboBox * box, gpointer data)
739{
740 int i;
741 tint * ad = (tint *)data;
742 a = ad -> a;
743 b = ad -> b;
744 c = ad -> c;
745 project * this_proj = get_project_by_id(a);
746 i = combo_get_active ((GtkWidget *)box);
747 update_entry_double (GTK_ENTRY(vmin), this_proj -> curves[b][c] -> axmin[i]);
748 update_entry_double (GTK_ENTRY(vmax), this_proj -> curves[b][c] -> axmax[i]);
749 update_entry_double (GTK_ENTRY(majt), this_proj -> curves[b][c] -> majt[i]);
750 combo_set_active (ticks_inout_box, this_proj -> curves[b][c] -> ticks_io[i]);
751 combo_set_active (ticks_pos_box, this_proj -> curves[b][c] -> ticks_pos[i]);
752 combo_set_active (labels_pos_box, this_proj -> curves[b][c] -> labels_pos[i]);
753 gtk_font_chooser_set_font (GTK_FONT_CHOOSER(ticks_labels_font), this_proj -> curves[b][c] -> labels_font[i]);
754 gtk_range_set_value (GTK_RANGE(ticks_labels_angle), this_proj -> curves[b][c] -> labels_angle[i] * (180.0/pi));
755 if (b < MS)
756 {
758 }
759 else
760 {
761 g_signal_handler_disconnect (G_OBJECT(scale_box), handler_id);
762 combo_set_active (scale_box, this_proj -> curves[b][c] -> scale[i]);
763 handler_id = g_signal_connect (G_OBJECT(scale_box), "changed", G_CALLBACK(set_scale), data);
765 /* widget_set_sensitive (vmax, ! this_proj -> curves[b][c] -> scale[i]);
766 widget_set_sensitive (vmin, ! this_proj -> curves[b][c] -> scale[i]); */
767 widget_set_sensitive (majt, ! this_proj -> curves[b][c] -> scale[i]);
768 widget_set_sensitive (nmi[i], ! this_proj -> curves[b][c] -> scale[i]);
769 }
770 hide_the_widgets (nmi[! i]);
771 hide_the_widgets (ndi[! i]);
772 hide_the_widgets (mats[! i]);
773 hide_the_widgets (mits[! i]);
774 hide_the_widgets (nptx[! i]);
775 hide_the_widgets (npty[! i]);
776 hide_the_widgets (tptx[! i]);
777 hide_the_widgets (tpty[! i]);
778
787
788 button_set_status (show_axis, this_proj -> curves[b][c] -> show_axis[i]);
789 button_set_status (show_grid, this_proj -> curves[b][c] -> show_grid[i]);
790 button_set_status (axis_default_title, this_proj -> curves[b][c] -> axis_defaut_title[i]);
791
792 widget_set_sensitive (axis_title, ! this_proj -> curves[b][c] -> axis_defaut_title[i]);
793 update_entry_text (GTK_ENTRY(axis_title), this_proj -> curves[b][c] -> axis_title[i]);
794 gtk_font_chooser_set_font (GTK_FONT_CHOOSER(axis_title_font), this_proj -> curves[b][c] -> axis_title_font[i]);
795}
796
804GtkWidget * create_tab_4 (gpointer data)
805{
806
807 tint * cd = (tint *) data;
808 int i;
809
810 a = cd -> a;
811 b = cd -> b;
812 c = cd -> c;
813 project * this_proj = get_project_by_id(a);
814
815 GtkWidget * axisbox;
816#ifdef GTK4
817 axisbox = create_vbox (3);
818#else
819 axisbox = create_vbox (BSEP);
820#endif
821 GtkWidget * ahbox = create_hbox (0);
822 add_box_child_start (GTK_ORIENTATION_VERTICAL, axisbox, ahbox, FALSE, FALSE, 5);
823 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, markup_label("<b>Select axis:</b>", 175, -1, 1.0, 0.5), FALSE, FALSE, 0);
825 combo_text_append (axischoice, "X axis");
826 combo_text_append (axischoice, "Y axis");
828 gtk_widget_set_size_request (axischoice, 80, 35);
829 g_signal_connect (G_OBJECT(axischoice), "changed", G_CALLBACK(update_axis), data);
830 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, axischoice, FALSE, FALSE, 25);
831
832 add_box_child_start (GTK_ORIENTATION_VERTICAL, axisbox, gtk_separator_new (GTK_ORIENTATION_HORIZONTAL), FALSE, FALSE, 5);
833
834 ahbox = create_hbox (0);
835 add_box_child_start (GTK_ORIENTATION_VERTICAL, axisbox, ahbox, FALSE, FALSE, 0);
836 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, markup_label("Scale type:", 100, -1, 0.0, 0.5), FALSE, FALSE, 0);
838 combo_text_append (scale_box, "Linear");
840 combo_set_active (scale_box, this_proj -> curves[b][c] -> scale[0]);
841 gtk_widget_set_size_request (scale_box, 80, -1);
842 handler_id = g_signal_connect (G_OBJECT(scale_box), "changed", G_CALLBACK(set_scale), data);
843 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, scale_box, FALSE, FALSE, 0);
844 auto_scale = create_button ("Autoscale axis", IMG_NONE, NULL, -1, -1, GTK_RELIEF_NORMAL, G_CALLBACK(set_autoscale), data);
845 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, auto_scale, FALSE, FALSE, 30);
846
847// Axis min and max
848 ahbox = create_hbox (0);
849 add_box_child_start (GTK_ORIENTATION_VERTICAL, axisbox, ahbox, FALSE, FALSE, 5);
850 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, markup_label("Min:", 30, -1, 0.5, 0.5), FALSE, FALSE, 20);
851 vmin = create_entry (G_CALLBACK(set_axis_min), 100, 15, FALSE, data);
852 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, vmin, FALSE, FALSE, 0);
853 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, markup_label("Max:", 30, -1, 0.5, 0.5), FALSE, FALSE, 20);
854 vmax = create_entry (G_CALLBACK(set_axis_max), 100, 15, FALSE, data);
855 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, vmax, FALSE, FALSE, 0);
856
857// Major ticks spacing
858 ahbox = create_hbox (0);
859 add_box_child_start (GTK_ORIENTATION_VERTICAL, axisbox, ahbox, FALSE, FALSE, 1);
860 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, markup_label("Major ticks spacing:", 160, -1, 0.0, 0.5), FALSE, FALSE, 10);
861 majt = create_entry (G_CALLBACK(set_max_div), 100, 15, FALSE, data);
862 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, majt, FALSE, FALSE, 0);
863
864// Number of minors ticks
865 ahbox = create_hbox (0);
866 add_box_child_start (GTK_ORIENTATION_VERTICAL, axisbox, ahbox, FALSE, FALSE, 1);
867 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, markup_label("Number of minor ticks:", 160, -1, 0.0, 0.5), FALSE, FALSE, 10);
868 for (i=0; i<2; i++)
869 {
870 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]);
871 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, nmi[i], FALSE, FALSE, 0);
872 }
873
874// Ticks ...
875 ahbox = create_hbox (0);
876 add_box_child_start (GTK_ORIENTATION_VERTICAL, axisbox, ahbox, FALSE, FALSE, 5);
877 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, markup_label("<u>Tick marks:</u>", -1, -1, 0.0, 0.5), FALSE, FALSE, 0);
878
879// ... position ...
880 ahbox = abox (axisbox, "Location:", 1);
884 gtk_widget_set_size_request (ticks_inout_box, 60, -1);
885 g_signal_connect (G_OBJECT(ticks_inout_box), "changed", G_CALLBACK(set_io_ticks), data);
886 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, ticks_inout_box, FALSE, FALSE, 3);
887
890 combo_text_append (ticks_pos_box, "Opposite");
893 gtk_widget_set_size_request (ticks_pos_box, 100, -1);
894 g_signal_connect (G_OBJECT(ticks_pos_box), "changed", G_CALLBACK(set_pos_ticks), data);
895 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, ticks_pos_box, FALSE, FALSE, 3);
896
897// ... sizes ...
898
899 ahbox = abox (axisbox, "Major ticks size:", 1);
900 for (i=0; i<2; i++)
901 {
902 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]);
903 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, mats[i], FALSE, FALSE, 0);
904 }
905 ahbox = abox (axisbox, "Minor ticks size:", 1);
906 for (i=0; i<2; i++)
907 {
908 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]);
909 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, mits[i], FALSE, FALSE, 0);
910 }
911
912// Ticks labels ...
913 ahbox = create_hbox (0);
914 add_box_child_start (GTK_ORIENTATION_VERTICAL, axisbox, ahbox, FALSE, FALSE, 5);
915 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, markup_label("<u>Tick labels:</u>", -1, -1, 0.0, 0.5), FALSE, FALSE, 0);
916
917// ... position ...
918 ahbox = abox (axisbox, "Location:", 1);
921 combo_text_append (labels_pos_box, "Opposite");
924 gtk_widget_set_size_request (labels_pos_box, 150, -1);
925 g_signal_connect (G_OBJECT(labels_pos_box), "changed", G_CALLBACK(set_pos_labels), data);
926 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, labels_pos_box, FALSE, FALSE, 0);
927
928// ... significant digits ...
929 ahbox = abox (axisbox, "Significant digits:", 1);
930 for (i=0; i<2; i++)
931 {
932 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]);
933 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, ndi[i], FALSE, FALSE, 0);
934 }
935
936// ... font ...
937 ticks_labels_font = font_button (this_proj -> curves[b][c] -> labels_font[0], 150, 35, G_CALLBACK(set_ticks_labels_font), data);
938 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, abox (axisbox, "Font:", 1), ticks_labels_font, FALSE, FALSE, 5);
939
940// ... angle ..
941 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);
942 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, abox (axisbox, "Angle:", 1), ticks_labels_angle, FALSE, FALSE, 5);
943
944// ...distance to axis
945 ahbox = abox (axisbox, "Position: ", 1);
946 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, markup_label("x:", -1, -1, 0.9, 0.5), FALSE, FALSE, 10);
947 for (i=0; i<2; i++)
948 {
949 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]);
950 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, nptx[i], FALSE, FALSE, 0);
951 }
952 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, markup_label("y:", -1, -1, 0.9, 0.5), FALSE, FALSE, 10);
953 for (i=0; i<2; i++)
954 {
955 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]);
956 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, npty[i], FALSE, FALSE, 0);
957 }
958
959 show_axis = check_button ("Show/hide axis (if min[axis] &lt; 0.0 &lt; max[axis])", 100, 30, FALSE, G_CALLBACK(set_axis), data);
960 add_box_child_start (GTK_ORIENTATION_VERTICAL, axisbox, show_axis, FALSE, FALSE, 3);
961 show_grid = check_button ("Show/hide axis grid", 100, 30, FALSE, G_CALLBACK(set_grid), data);
962 add_box_child_start (GTK_ORIENTATION_VERTICAL, axisbox, show_grid, FALSE, FALSE, 1);
963
964// Axis title
965 ahbox = create_hbox (0);
966 add_box_child_start (GTK_ORIENTATION_VERTICAL, axisbox, ahbox, FALSE, FALSE,3);
967 axis_default_title = check_button ("Use default axis title", 175, -1, FALSE, G_CALLBACK(to_axis_title), data);
968 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, axis_default_title, FALSE, FALSE, 0);
969 axis_title = create_entry (G_CALLBACK(set_axis_legend), 150, 15, FALSE, data);
970 gtk_entry_set_alignment (GTK_ENTRY(axis_title), 0.0);
971 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, axis_title, FALSE, FALSE, 0);
972
973 axis_title_font = font_button (this_proj -> curves[b][c] -> axis_title_font[0], 150, 35, G_CALLBACK(set_axis_title_font), data);
974 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, abox (axisbox, "Font:", 3), axis_title_font, FALSE, FALSE, 0);
975
976 ahbox = abox (axisbox, "Position: ", 3);
977 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, markup_label("x:", -1, -1, 0.9, 0.5), FALSE, FALSE, 10);
978 for (i=0; i<2; i++)
979 {
980 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]);
981 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, tptx[i], FALSE, FALSE, 0);
982 }
983 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, markup_label("y:", -1, -1, 0.9, 0.5), FALSE, FALSE, 10);
984 for (i=0; i<2; i++)
985 {
986 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]);
987 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, tpty[i], FALSE, FALSE, 0);
988 }
989 return axisbox;
990}
Callback declarations for main window.
Variable declarations for the curve layout edition window.
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
double string_to_double(gpointer string)
convert string to double
Definition global.c:624
Global variable declarations Global convenience function declarations Global data structure defin...
@ IMG_NONE
Definition global.h:262
int combo_get_active(GtkWidget *combo)
retrieve the active item's position
Definition gtk-misc.c:909
GtkWidget * create_entry(GCallback handler, int dim, int cdim, gboolean key_release, gpointer data)
Create a GtkEntry.
Definition gtk-misc.c:1375
void update_entry_double(GtkEntry *entry, double doubleval)
update the content of a GtkEntry as double
Definition gtk-misc.c:643
GtkWidget * font_button(gchar *font, int dimx, int dimy, GCallback handler, gpointer data)
create a font selection button
Definition gtk-misc.c:1811
void combo_set_active(GtkWidget *combo, int pos)
set the active item's position
Definition gtk-misc.c:932
const gchar * entry_get_text(GtkEntry *entry)
get the text in a GtkEntry
Definition gtk-misc.c:607
#define BSEP
Definition global.h:247
void update_entry_int(GtkEntry *entry, int intval)
update the content of a GtkEntry as int
Definition gtk-misc.c:624
void button_set_status(GtkWidget *button, int status)
set status of check / toggle button
Definition gtk-misc.c:1872
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:1833
GtkWidget * check_button(gchar *text, int dimx, int dimy, gboolean state, GCallback handler, gpointer data)
create a check button
Definition gtk-misc.c:1893
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:1955
GtkWidget * create_combo()
create a GtkCombox widget, note deprecated in GTK4
Definition gtk-misc.c:984
GtkWidget * markup_label(gchar *text, int dimx, int dimy, float ax, float ay)
create a GtkLabel with pango markup
Definition gtk-misc.c:1646
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:308
void widget_set_sensitive(GtkWidget *widg, gboolean sensitive)
Set sensitivity for a GtkWidget, ensuring it is a GtkWidget.
Definition gtk-misc.c:215
GtkWidget * create_hbox(int spacing)
create a GtkBox with horizontal orientation
Definition gtk-misc.c:823
void combo_text_append(GtkWidget *combo, gchar *text)
append text in GtkComboBox widget
Definition gtk-misc.c:961
#define MS
Definition global.h:333
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:754
void update_entry_text(GtkEntry *entry, gchar *text)
update the content of a GtkEntry as string
Definition gtk-misc.c:681
void hide_the_widgets(GtkWidget *widg)
hide GtkWidget
Definition gtk-misc.c:198
GtkWidget * create_vbox(int spacing)
create a GtkBox with vertical orientation
Definition gtk-misc.c:811
int button_get_status(GtkWidget *button)
get status of check / toggle button
Definition gtk-misc.c:1855
GtkWidget * abox(GtkWidget *box, char *lab, int vspace)
box creating routine, to help design faster elements for the GUI
Definition gtk-misc.c:2023
void show_the_widgets(GtkWidget *widg)
show GtkWidget
Definition gtk-misc.c:182
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:100
Function declarations for reading atomes project file Function declarations for saving atomes proje...
Definition glwin.h:333
Definition glwin.h:351
Definition global.h:114
Definition global.h:106
int b
Definition global.h:108
int c
Definition global.h:109
int a
Definition global.h:107
GtkWidget * mats[2]
Definition tab-4.c:107
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:691
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 update_axis(GtkComboBox *box, gpointer data)
change the axis
Definition tab-4.c:738
G_MODULE_EXPORT void set_grid(GtkToggleButton *grid, gpointer data)
show / hide grid toggle callback GTK3
Definition tab-4.c:600
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:728
G_MODULE_EXPORT void set_scale(GtkComboBox *sbox, gpointer data)
change the axis scale
Definition tab-4.c:712
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:804
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:620
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:650
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:670
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