atomes 1.2.1
atomes: an atomic scale modeling tool box
Loading...
Searching...
No Matches
w_labels.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
23/*
24* This file: 'w_labels.c'
25*
26* Contains:
27*
28
29 - The functions to create the 'atomic labels' tab of the atom(s) / clone(s) advanced configuration window
30 - The functions to create the measure labels window of the 'Measures' window
31
32*
33* List of functions:
34
35 G_MODULE_EXPORT gboolean scroll_set_label_shift (GtkRange * range, GtkScrollType scroll, gdouble value, gpointer data);
36 G_MODULE_EXPORT gboolean scroll_set_measure_factor (GtkRange * range, GtkScrollType scroll, gdouble value, gpointer data);
37 G_MODULE_EXPORT gboolean scroll_set_measure_width (GtkRange * range, GtkScrollType scroll, gdouble value, gpointer data);
38
39 void init_labels_colors (image * img, int sp, int id);
40 void label_shift_has_changed (gpointer data, double value);
41 void mesure_factor_has_changed (gpointer data, double value);
42 void measure_width_has_changed (gpointer data, double value);
43
44 G_MODULE_EXPORT void set_measure_style (GtkComboBox * box, gpointer data);
45 G_MODULE_EXPORT void set_labels_format (GtkComboBox * box, gpointer data);
46 G_MODULE_EXPORT void set_labels_render (GtkComboBox * box, gpointer data);
47 G_MODULE_EXPORT void use_atom_default_colors (GtkCheckButton * but, gpointer data);
48 G_MODULE_EXPORT void use_atom_default_colors (GtkToggleButton * but, gpointer data);
49 G_MODULE_EXPORT void set_labels_font (GtkFontButton * fontb, gpointer data);
50 G_MODULE_EXPORT void set_label_color (GtkColorChooser * colob, gpointer data);
51 G_MODULE_EXPORT void set_labels_position (GtkComboBox * box, gpointer data);
52 G_MODULE_EXPORT void set_label_shift (GtkRange * range, gpointer data);
53 G_MODULE_EXPORT void set_labels_scale (GtkCheckButton * but, gpointer data);
54 G_MODULE_EXPORT void set_labels_scale (GtkToggleButton * but, gpointer data);
55 G_MODULE_EXPORT void set_labels_tilt (GtkComboBox * box, gpointer data);
56 G_MODULE_EXPORT void set_measure_factor (GtkRange * range, gpointer data);
57 G_MODULE_EXPORT void set_measure_width (GtkRange * range, gpointer data);
58 G_MODULE_EXPORT void enable_lines (GtkCheckButton * but, gpointer data);
59 G_MODULE_EXPORT void enable_lines (GtkToggleButton * but, gpointer data);
60
61 GtkWidget * labels_tab (glwin * view, int id);
62
63*/
64
65#include "global.h"
66#include "interface.h"
67#include "glview.h"
68#include "glwindow.h"
69#include "preferences.h"
70
71#define LABEL_FORMATS 4
72
73gchar * lab_formats[LABEL_FORMATS] = {"Element name", "Atomic symbol", "Atomic symbol + ID number", "ID number"};
74
75GtkWidget * atom_color_box;
76GtkWidget ** color_title;
77GtkWidget * tilt;
78
87G_MODULE_EXPORT void set_measure_style (GtkComboBox * box, gpointer data)
88{
89 tint * id = (tint *) data;
90 if (id -> a != -1)
91 {
92 glwin * view = get_project_by_id(id -> a) -> modelgl;
93 view -> anim -> last -> img -> mpattern[id -> b] = combo_get_active ((GtkWidget *)box);
94 view -> create_shaders[MEASU] = TRUE;
95 update (view);
96 }
97 else
98 {
99 tmp_mpattern[id -> b] = combo_get_active ((GtkWidget *)box);
100 }
101}
102
111G_MODULE_EXPORT void set_labels_format (GtkComboBox * box, gpointer data)
112{
113 tint * id = (tint *) data;
114 int i = combo_get_active ((GtkWidget *)box);
115 if (! preferences)
116 {
117 glwin * view = get_project_by_id(id -> a) -> modelgl;
118 if (i != view -> anim -> last -> img -> acl_format[id -> b])
119 {
120 view -> anim -> last -> img -> acl_format[id -> b] = i;
121 if (id -> b < 2) view -> create_shaders[LABEL] = TRUE;
122 if (id -> b == 3 || id -> b == 4) view -> create_shaders[MEASU] = TRUE;
123 update (view);
124 }
125 }
126 else
127 {
128 tmp_acl_format[id -> b] = i;
129 }
130}
131
140G_MODULE_EXPORT void set_labels_render (GtkComboBox * box, gpointer data)
141{
142 tint * id = (tint *) data;
143 int i = combo_get_active ((GtkWidget *)box);
144 if (! preferences)
145 {
146 glwin * view = get_project_by_id(id -> a) -> modelgl;
147 if (i != view -> anim -> last -> img -> labels[id -> b].render)
148 {
149 view -> anim -> last -> img -> labels[id -> b].render = i;
150 if (id -> b < 2)
151 {
152 view -> create_shaders[LABEL] = TRUE;
153 }
154 else if (id -> b == 2)
155 {
156 view -> create_shaders[MAXIS] = TRUE;
157 }
158 else if (id -> b == 3 || id -> b == 4)
159 {
160 combo_set_active (tilt, view -> anim -> last -> img -> mtilt[id -> b-3]);
161 view -> create_shaders[MEASU] = TRUE;
162 }
163 update (view);
164 }
165 }
166 else
167 {
168 tmp_label[id -> b] -> render = i;
169 }
170}
171
181void init_labels_colors (image * img, int sp, int id)
182{
183 int i;
184 for (i = 0; i < sp; i++)
185 {
186 img -> labels[id].color[i].red = img -> at_color[i+id*sp].red;
187 img -> labels[id].color[i].green = img -> at_color[i+id*sp].green;
188 img -> labels[id].color[i].blue = img -> at_color[i+id*sp].blue;
189 img -> labels[id].color[i].alpha = 1.0;
190 GdkRGBA col = colrgba_togtkrgba (img -> labels[id].color[i]);
191 gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER(color_title[i]), & col);
192 }
193}
194
195#ifdef GTK4
204G_MODULE_EXPORT void use_atom_default_colors (GtkCheckButton * but, gpointer data)
205#else
214G_MODULE_EXPORT void use_atom_default_colors (GtkToggleButton * but, gpointer data)
215#endif
216{
217 tint * id = (tint *) data;
218 gboolean val = button_get_status ((GtkWidget *)but);
219 int b = id -> b;
220 project * this_proj = get_project_by_id(id -> a);
221 if (val)
222 {
223 if (this_proj -> modelgl -> anim -> last -> img -> labels[b].color != NULL)
224 {
225 init_labels_colors (this_proj -> modelgl -> anim -> last -> img, this_proj -> nspec, b);
226 g_free (this_proj -> modelgl -> anim -> last -> img -> labels[b].color);
227 }
228 this_proj -> modelgl -> anim -> last -> img -> labels[b].color = NULL;
229 this_proj -> modelgl -> anim -> last -> img -> labels[b].n_colors = 0;
230 }
231 else
232 {
233 this_proj -> modelgl -> anim -> last -> img -> labels[b].color = g_malloc (2*this_proj -> nspec*sizeof*this_proj -> modelgl -> anim -> last -> img -> labels[b].color);
234 init_labels_colors (this_proj -> modelgl -> anim -> last -> img, this_proj -> nspec, b);
235 this_proj -> modelgl -> anim -> last -> img -> labels[b].n_colors = 2*this_proj -> nspec;
236 }
238 this_proj -> modelgl -> create_shaders[LABEL] = TRUE;
239 update (this_proj -> modelgl);
240}
241
250G_MODULE_EXPORT void set_labels_font (GtkFontButton * fontb, gpointer data)
251{
252 tint * id = (tint *) data;
253 if (id -> a != -1)
254 {
255 glwin * view = get_project_by_id(id -> a) -> modelgl;
256 g_free (view -> anim -> last -> img -> labels[id -> b].font);
257 view -> anim -> last -> img -> labels[id -> b].font = g_strdup_printf ("%s", gtk_font_chooser_get_font (GTK_FONT_CHOOSER(fontb)));
258 if (id -> b < 2)
259 {
260 view -> create_shaders[LABEL] = TRUE;
261 }
262 else if (id -> b == 2)
263 {
264 view -> create_shaders[MAXIS] = TRUE;
265 }
266 else if (id -> b == 3 || id -> b == 4)
267 {
268 view -> create_shaders[MEASU] = TRUE;
269 }
270 update (view);
271 }
272 else
273 {
274 tmp_label[id -> b] -> font = g_strdup_printf ("%s", gtk_font_chooser_get_font (GTK_FONT_CHOOSER(fontb)));
275 }
276}
277
286G_MODULE_EXPORT void set_label_color (GtkColorChooser * colob, gpointer data)
287{
288 tint * id = (tint *) data;
289 if (id -> a != -1)
290 {
291 glwin * view = get_project_by_id(id -> a) -> modelgl;
292 view -> anim -> last -> img -> labels[id -> b].color[id -> c] = get_button_color (colob);
293 if (id -> b < 2) view -> create_shaders[LABEL] = TRUE;
294 if (id -> b == 3 || id -> b == 4) view -> create_shaders[MEASU] = TRUE;
295 update (view);
296 }
297 else
298 {
299 tmp_label[id -> b] -> color[0] = get_button_color (colob);
300 }
301}
302
311G_MODULE_EXPORT void set_labels_position (GtkComboBox * box, gpointer data)
312{
313 tint * id = (tint *) data;
314 int i = combo_get_active ((GtkWidget *)box);
315 if (id -> a != -1)
316 {
317 glwin * view = get_project_by_id(id -> a) -> modelgl;
318 view -> anim -> last -> img -> labels[id -> b].position = i;
319 if (id -> b < 2) view -> create_shaders[LABEL] = TRUE;
320 if (id -> b == 3 || id -> b == 4) view -> create_shaders[MEASU] = TRUE;
321 update (view);
322 }
323 else
324 {
325 tmp_label[id -> b] -> position = i;
326 }
327}
328
337void label_shift_has_changed (gpointer data, double value)
338{
339 tint * id = (tint *) data;
340 int i = id -> b / 10;
341 int j = id -> b - i * 10;
342 if (id -> a != -1)
343 {
344 glwin * view = get_project_by_id(id -> a) -> modelgl;
345 view -> anim -> last -> img -> labels[i].shift[j] = value;
346 if (id -> b < 2) view -> create_shaders[LABEL] = TRUE;
347 update (view);
348 }
349 else
350 {
351 tmp_label[i] -> shift[j] = value;
352 }
353}
354
365G_MODULE_EXPORT gboolean scroll_set_label_shift (GtkRange * range, GtkScrollType scroll, gdouble value, gpointer data)
366{
367 label_shift_has_changed (data, value);
368 return FALSE;
369}
370
379G_MODULE_EXPORT void set_label_shift (GtkRange * range, gpointer data)
380{
381 label_shift_has_changed (data, gtk_range_get_value (range));
382}
383
384#ifdef GTK4
393G_MODULE_EXPORT void set_labels_scale (GtkCheckButton * but, gpointer data)
394#else
403G_MODULE_EXPORT void set_labels_scale (GtkToggleButton * but, gpointer data)
404#endif
405{
406 tint * id = (tint *) data;
407 int i = button_get_status ((GtkWidget *)but);
408 if (id -> a != -1)
409 {
410 glwin * view = get_project_by_id(id -> a) -> modelgl;
411 view -> anim -> last -> img -> labels[id -> b].scale = i;
412 if (id -> b < 2) view -> create_shaders[LABEL] = TRUE;
413 if (id -> b == 2) view -> create_shaders[MAXIS] = TRUE;
414 if (id -> b == 3 || id -> b == 4) view -> create_shaders[MEASU] = TRUE;
415 update (view);
416 }
417 else
418 {
419 tmp_label[id -> b] -> scale = i;
420 }
421}
422
431G_MODULE_EXPORT void set_labels_tilt (GtkComboBox * box, gpointer data)
432{
433 tint * id = (tint *) data;
434 int i = combo_get_active ((GtkWidget *)box);
435 if (id -> a != -1)
436 {
437 glwin * view = get_project_by_id(id -> a) -> modelgl;
438 view -> anim -> last -> img -> mtilt[id -> b] = i;
439 if (id -> b < 2) view -> create_shaders[LABEL] = TRUE;
440 if (id -> b == 3 || id -> b == 4) view -> create_shaders[MEASU] = TRUE;
441 update (view);
442 }
443 else
444 {
445 tmp_mtilt[id -> b] = i;
446 }
447}
448
457void mesure_factor_has_changed (gpointer data, double value)
458{
459 tint * id = (tint *) data;
460 if (id -> a != -1)
461 {
462 glwin * view = get_project_by_id(id -> a) -> modelgl;
463 view -> anim -> last -> img -> mfactor[id -> b] = (int)value;
464 view -> create_shaders[MEASU] = TRUE;
465 update (view);
466 }
467 else
468 {
469 tmp_mfactor[id -> b] = (int)value;
470 }
471}
472
483G_MODULE_EXPORT gboolean scroll_set_measure_factor (GtkRange * range, GtkScrollType scroll, gdouble value, gpointer data)
484{
485 mesure_factor_has_changed (data, value);
486 return FALSE;
487}
488
497G_MODULE_EXPORT void set_measure_factor (GtkRange * range, gpointer data)
498{
499 mesure_factor_has_changed (data, gtk_range_get_value (range));
500}
501
510void measure_width_has_changed (gpointer data, double value)
511{
512 tint * id = (tint *) data;
513 if (id -> a != -1)
514 {
515 glwin * view = get_project_by_id(id -> a) -> modelgl;
516 view -> anim -> last -> img -> mwidth[id -> b] = value;
517 view -> create_shaders[MEASU] = TRUE;
518 update (view);
519 }
520 else
521 {
522 tmp_mwidth[id -> b] = value;
523 }
524}
525
536G_MODULE_EXPORT gboolean scroll_set_measure_width (GtkRange * range, GtkScrollType scroll, gdouble value, gpointer data)
537{
538 measure_width_has_changed (data, value);
539 return FALSE;
540}
541
550G_MODULE_EXPORT void set_measure_width (GtkRange * range, gpointer data)
551{
552 measure_width_has_changed (data, gtk_range_get_value (range));
553}
554
555GtkWidget * line_box;
556GtkWidget * lstyle;
557
558#ifdef GTK4
567G_MODULE_EXPORT void enable_lines (GtkCheckButton * but, gpointer data)
568#else
577G_MODULE_EXPORT void enable_lines (GtkToggleButton * but, gpointer data)
578#endif
579{
580 tint * id = (tint *) data;
581 glwin * view;
582 if (id -> a != -1) view = get_project_by_id(id -> a) -> modelgl;
583 int i, j;
584 i = button_get_status ((GtkWidget *)but);
586 if (i)
587 {
588 if (id -> a != -1)
589 {
590 j = view -> anim -> last -> img -> mpattern[id -> b] = 0;
591 }
592 else
593 {
594 j = tmp_mpattern[id -> b] = 0;
595 }
596 }
597 else
598 {
599 if (id -> a != -1)
600 {
601 j = view -> anim -> last -> img -> mpattern[id -> b] = -1;
602 }
603 else
604 {
605 j = tmp_mpattern[id -> b] = -1;
606 }
607 }
609 if (id -> a != -1)
610 {
611 view -> create_shaders[MEASU] = TRUE;
612 update (view);
613 }
614}
615
624GtkWidget * labels_tab (glwin * view, int lid)
625{
626 int i;
627 gchar * lpos[3] = {"x", "y", "z"};
628 project * this_proj;
630 int acl_format;
631 gboolean mtilt;
632 int mpattern;
633 int mfactor;
634 double mwidth;
635 tint * lab_pointer;
636 tint * measure_pointer;
637 tint * shift_pointer[2];
638 if (! preferences)
639 {
640 this_proj = get_project_by_id (view -> proj);
641 label = & view -> anim -> last -> img -> labels[lid];
642 lab_pointer = & view -> colorp[lid][0];
643 measure_pointer = (lid > 2) ? & view -> colorp[lid-3][0] : NULL;
644 for (i=0; i<2; i++) shift_pointer[i] = & view -> colorp[lid*10+i][0];
645 if (lid < 2)
646 {
647 acl_format = view -> anim -> last -> img -> acl_format[lid];
648 }
649 else
650 {
651 mtilt = view -> anim -> last -> img -> mtilt[lid-3];
652 mpattern = view -> anim -> last -> img -> mpattern[lid-3];
653 mfactor = view -> anim -> last -> img -> mfactor[lid-3];
654 mwidth = view -> anim -> last -> img -> mwidth[lid-3];
655 }
656 }
657 else
658 {
659 label = tmp_label[lid];
660 lab_pointer = & pref_pointer[lid];
661 measure_pointer = (lid > 2) ? & pref_pointer[lid-3] : NULL;
662 for (i=0; i<2; i++) shift_pointer[i] = & pref_pointer[lid*10+i];
663 if (lid < 2)
664 {
665 acl_format = tmp_acl_format[lid];
666 }
667 else
668 {
669 mtilt = tmp_mtilt[lid-3];
670 mpattern = tmp_mpattern[lid-3];
671 mfactor = tmp_mfactor[lid-3];
672 mwidth = tmp_mwidth[lid-3];
673 }
674 }
675 GtkWidget * tbox = create_vbox (BSEP);
676 GtkWidget * vbox = create_vbox (5);
677 add_box_child_start (GTK_ORIENTATION_VERTICAL, tbox, vbox, FALSE, FALSE, 5);
678
679 GtkWidget * box;
680 if (lid < 2)
681 {
682 box = abox (vbox, "Templates ", 0);
683 GtkWidget * formats = create_combo ();
684 for (i=0; i<LABEL_FORMATS; i++)
685 {
686 combo_text_append (formats, lab_formats[i]);
687 }
688 combo_set_active (formats, acl_format);
689 gtk_widget_set_size_request (formats, 220, -1);
690 g_signal_connect (G_OBJECT (formats), "changed", G_CALLBACK(set_labels_format), lab_pointer);
691 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, box, formats, FALSE, FALSE, 10);
692 }
693 else
694 {
695 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, markup_label("<b><u>Label(s):</u></b>", -1, 40, 0.0, 0.5), FALSE, FALSE, 0);
696 }
697 // Rendering
698 box = abox (vbox, "Rendering ", 0);
699 GtkWidget * config = create_combo ();
700 combo_text_append (config, "Basic text");
701 combo_text_append (config, "Highlighted");
702 combo_set_active (config, label -> render);
703 gtk_widget_set_size_request (config, 220, -1);
704 g_signal_connect (G_OBJECT (config), "changed", G_CALLBACK(set_labels_render), lab_pointer);
705 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, box, config, FALSE, FALSE, 10);
706 // Font
707 box = abox (vbox, "Font", 0);
708 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, box, font_button (label -> font, 220, -1, G_CALLBACK(set_labels_font), lab_pointer), FALSE, FALSE, 10);
709 if (lid == 3 || lid == 4)
710 {
711 box = abox (vbox, "Font color", 0);
712 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, box, color_button (label -> color[0], TRUE, 220, -1, G_CALLBACK(set_label_color), lab_pointer), FALSE, FALSE, 10);
713 }
714
715 // Position
716 box = abox (vbox, "Position", 0);
717 GtkWidget * position = create_combo ();
718 combo_text_append (position, "Always visible");
719 combo_text_append (position, "Normal");
721 gtk_widget_set_size_request (position, 220, -1);
722 g_signal_connect (G_OBJECT (position), "changed", G_CALLBACK(set_labels_position), lab_pointer);
723 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, box, position, FALSE, FALSE, 10);
724
725 // Size / scale
726 box = abox (vbox, "Size", 0);
727 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, box,
728 check_button ("scale with zoom in/out", 220, -1, label -> scale, G_CALLBACK(set_labels_scale), lab_pointer),
729 FALSE, FALSE, 10);
730
731 if (lid == 3 || lid == 4)
732 {
733 // Tilt
734 box = abox (vbox, "Tilt", 0);
735 tilt = create_combo ();
736 combo_text_append (tilt, "None");
737 combo_text_append (tilt, "Adapted");
738 combo_set_active (tilt, mtilt);
739 gtk_widget_set_size_request (tilt, 220, -1);
740 g_signal_connect (G_OBJECT (tilt), "changed", G_CALLBACK(set_labels_tilt), measure_pointer);
741 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, box, tilt, FALSE, FALSE, 10);
742 }
743
744 GtkWidget * chbox;
745 if (lid < 3)
746 {
747 box = abox (vbox, "Distance to atom [&#xC5;]", 0);
748 chbox = create_hbox (0);
749 for (i=0; i<2; i++)
750 {
751 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, chbox, markup_label(lpos[i], 30, -1, 0.5, 0.5), FALSE, FALSE, 10);
752 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, chbox,
753 create_hscale(-5.0, 5.0, 0.01, label -> shift[i], (preferences) ? GTK_POS_RIGHT : GTK_POS_TOP, 3, 100, G_CALLBACK(set_label_shift), G_CALLBACK(scroll_set_label_shift), shift_pointer[i]),
754 FALSE, FALSE, 0);
755 }
756 if (preferences)
757 {
758 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, box, chbox, FALSE, FALSE, 0);
759 }
760 else
761 {
762 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, chbox, FALSE, FALSE, 0);
763 }
764 }
765
766 // Colors
767 gboolean ac;
768 if (label -> color == NULL)
769 {
770 ac = TRUE;
771 }
772 else
773 {
774 ac = FALSE;
775 }
776 if (lid < 3 && ! preferences)
777 {
778 box = abox (vbox, "Color(s)", 0);
779 GtkWidget * col_box = create_vbox (BSEP);
780 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, col_box, FALSE, FALSE, 0);
781 add_box_child_start (GTK_ORIENTATION_VERTICAL, col_box,
782 check_button ("Use atom colors", 100, 40, ac, G_CALLBACK(use_atom_default_colors), (gpointer)lab_pointer),
783 FALSE, FALSE, 0);
785 add_box_child_start (GTK_ORIENTATION_VERTICAL, col_box, atom_color_box, FALSE, FALSE, 0);
786 add_box_child_start (GTK_ORIENTATION_VERTICAL, atom_color_box, markup_label ("Please select atom label colors:", -1, -1, 0.25, 0.5), FALSE, FALSE, 5);
787 color_title = g_malloc (this_proj -> nspec*sizeof*color_title);
788 for (i=0; i< this_proj -> nspec; i++)
789 {
790 chbox = create_hbox (0);
791 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, chbox, markup_label(this_proj -> chemistry -> label[i], 120, -1, 0.5, 0.5), FALSE, FALSE, 20);
792 if (label -> color == NULL)
793 {
794 color_title[i] = color_button(view -> anim -> last -> img -> at_color[i], TRUE, 80, -1, G_CALLBACK(set_label_color), & view -> colorp[lid][i]);
795 }
796 else
797 {
798 color_title[i] = color_button(label -> color[i], TRUE, 80, -1, G_CALLBACK(set_label_color), & view -> colorp[lid][i]);
799 }
800 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, chbox, color_title[i], FALSE, FALSE, 0);
801 add_box_child_start (GTK_ORIENTATION_VERTICAL, atom_color_box, chbox, FALSE, FALSE, 0);
802 }
804 }
805 else if (lid >= 3)
806 {
807 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, markup_label("<b><u>Line(s):</u></b>", -1, 40, 0.0, 0.5), FALSE, FALSE, 0);
808 GtkWidget * hbox = create_hbox (BSEP);
809 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 0);
810 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, check_button ("Show / hide", -1, 40, mpattern+1, G_CALLBACK(enable_lines), measure_pointer), FALSE, FALSE, 30);
812 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, line_box, TRUE, TRUE, 0);
813 box = abox (line_box, "Pattern", 0);
814 GtkListStore * store = gtk_list_store_new (1, GDK_TYPE_PIXBUF);
815 GtkTreeIter iter;
816 for (i=0; i<NDOTS; i++)
817 {
818 gtk_list_store_append (store, & iter);
819 gtk_list_store_set (store, & iter, 0, gdk_pixbuf_new_from_file (dots[i], NULL), -1);
820 }
821 lstyle = gtk_combo_box_new_with_model (GTK_TREE_MODEL(store));
822 g_object_unref (G_OBJECT(store));
823 GtkCellRenderer * renderer;
824 renderer = gtk_cell_renderer_pixbuf_new();
825 gtk_cell_layout_pack_start( GTK_CELL_LAYOUT(lstyle), renderer, FALSE );
826 gtk_cell_layout_set_attributes( GTK_CELL_LAYOUT(lstyle), renderer, "pixbuf", 0, NULL );
827 combo_set_active (lstyle, mpattern);
828 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, box, lstyle, TRUE, TRUE, 10);
829 gtk_widget_set_size_request (lstyle, 100, 35);
830 g_signal_connect (G_OBJECT (lstyle), "changed", G_CALLBACK(set_measure_style), measure_pointer);
831
832 box = abox (line_box, "Factor", 0);
833 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, box,
834 create_hscale(1.0, 10.0, 1.0, (double)mfactor, GTK_POS_RIGHT, 0, 100, G_CALLBACK(set_measure_factor), G_CALLBACK(scroll_set_measure_factor), measure_pointer),
835 TRUE, TRUE, 0);
836
837 box = abox (line_box, "Width", 0);
838 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, box,
839 create_hscale(1.0, 10.0, 1.0, mwidth, GTK_POS_RIGHT, 0, 100, G_CALLBACK(set_measure_width), G_CALLBACK(scroll_set_measure_width), measure_pointer),
840 TRUE, TRUE, 0);
841 }
842 return tbox;
843}
integer(kind=c_int) function chemistry()
Definition chemistry.F90:22
color colorp[64]
double scale(double axe)
find appropriate major tick spacing based on axis length
Definition curve.c:204
void label(cairo_t *cr, double val, int axe, int p, project *this_proj)
draw axis label
Definition labels.c:56
ColRGBA col
Definition d_measures.c:77
int * shift
Definition d_measures.c:72
float val
Definition dlp_init.c:117
Global variable declarations Global convenience function declarations Global data structure defin...
int combo_get_active(GtkWidget *combo)
retrieve the active item's position
Definition gtk-misc.c:909
GtkWidget * font_button(gchar *font, int dimx, int dimy, GCallback handler, gpointer data)
create a font selection button
Definition gtk-misc.c:1811
project * proj
void combo_set_active(GtkWidget *combo, int pos)
set the active item's position
Definition gtk-misc.c:932
GdkRGBA colrgba_togtkrgba(ColRGBA col)
convert ColRGBA color to GdkRGBA color
Definition gtk-misc.c:1695
#define BSEP
Definition global.h:247
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_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
ColRGBA get_button_color(GtkColorChooser *colob)
get the ColRGBA color from a GtkColorChooser button
Definition gtk-misc.c:2371
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
GtkWidget * color_button(ColRGBA col, gboolean alpha, int dimx, int dimy, GCallback handler, gpointer data)
create a color selection button
Definition gtk-misc.c:1789
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
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
gchar * dots[NDOTS]
Definition gui.c:105
#define NDOTS
project * get_project_by_id(int p)
get project pointer using id number
Definition project.c:120
void update(glwin *view)
update the rendering of the OpenGL window
Definition glview.c:450
Variable declarations related to the OpenGL window Function declarations related to the OpenGL wind...
render
Definition glview.h:191
labels
Definition glview.h:223
struct box box
box layout data structure
Definition glwin.h:349
@ LABEL
Definition glwin.h:98
@ MAXIS
Definition glwin.h:94
@ MEASU
Definition glwin.h:99
Function declarations for the creation of the OpenGL window.
Messaging function declarations.
position
Definition m_proj.c:48
int tmp_mfactor[2]
tint * pref_pointer
int tmp_mpattern[2]
gboolean tmp_mtilt[2]
screen_label * tmp_label[5]
gboolean preferences
int tmp_acl_format[2]
double tmp_mwidth[2]
Preference variable declarations.
Definition glwin.h:351
Definition glwin.h:965
Definition glwin.h:365
Definition global.h:106
int b
Definition tab-1.c:95
int c
Definition tab-1.c:95
int a
Definition tab-1.c:95
gchar * lpos[3]
Definition w_advance.c:137
G_MODULE_EXPORT void set_label_shift(GtkRange *range, gpointer data)
change label(s) shift - range callback
Definition w_labels.c:379
G_MODULE_EXPORT void set_labels_font(GtkFontButton *fontb, gpointer data)
change label(s) font
Definition w_labels.c:250
G_MODULE_EXPORT gboolean scroll_set_measure_factor(GtkRange *range, GtkScrollType scroll, gdouble value, gpointer data)
change measure scall factor - scroll callback
Definition w_labels.c:483
G_MODULE_EXPORT void set_labels_format(GtkComboBox *box, gpointer data)
change label(s) format
Definition w_labels.c:111
G_MODULE_EXPORT gboolean scroll_set_label_shift(GtkRange *range, GtkScrollType scroll, gdouble value, gpointer data)
change label(s) shift - scroll callback
Definition w_labels.c:365
void mesure_factor_has_changed(gpointer data, double value)
change measure scale factor
Definition w_labels.c:457
GtkWidget * lstyle
Definition w_labels.c:556
GtkWidget ** color_title
Definition w_labels.c:76
G_MODULE_EXPORT void set_labels_position(GtkComboBox *box, gpointer data)
change label(s) position
Definition w_labels.c:311
G_MODULE_EXPORT gboolean scroll_set_measure_width(GtkRange *range, GtkScrollType scroll, gdouble value, gpointer data)
change measure width - scroll callback
Definition w_labels.c:536
GtkWidget * line_box
Definition w_labels.c:555
G_MODULE_EXPORT void set_measure_width(GtkRange *range, gpointer data)
change measure width - range callback
Definition w_labels.c:550
GtkWidget * atom_color_box
Definition w_labels.c:75
G_MODULE_EXPORT void use_atom_default_colors(GtkToggleButton *but, gpointer data)
use default atom colors - toggle callback GTK3
Definition w_labels.c:214
void init_labels_colors(image *img, int sp, int id)
initialize atomic labels colors
Definition w_labels.c:181
#define LABEL_FORMATS
Definition w_labels.c:71
G_MODULE_EXPORT void set_label_color(GtkColorChooser *colob, gpointer data)
change label(s) color
Definition w_labels.c:286
void measure_width_has_changed(gpointer data, double value)
change measure width
Definition w_labels.c:510
G_MODULE_EXPORT void enable_lines(GtkToggleButton *but, gpointer data)
toggle enable measure lines callback GTK3
Definition w_labels.c:577
GtkWidget * tilt
Definition w_labels.c:77
G_MODULE_EXPORT void set_labels_scale(GtkToggleButton *but, gpointer data)
change label(s) scale - toggle callback GTK3
Definition w_labels.c:403
G_MODULE_EXPORT void set_measure_factor(GtkRange *range, gpointer data)
change measure scall factor - range callback
Definition w_labels.c:497
G_MODULE_EXPORT void set_measure_style(GtkComboBox *box, gpointer data)
change measure style
Definition w_labels.c:87
void label_shift_has_changed(gpointer data, double value)
change label(s) shift
Definition w_labels.c:337
G_MODULE_EXPORT void set_labels_render(GtkComboBox *box, gpointer data)
change label(s) rendering mode
Definition w_labels.c:140
G_MODULE_EXPORT void set_labels_tilt(GtkComboBox *box, gpointer data)
change label(s) tilt
Definition w_labels.c:431
gchar * lab_formats[LABEL_FORMATS]
Definition w_labels.c:73
GtkWidget * labels_tab(glwin *view, int lid)
create atomic label(s) tab for the atom(s) / clone(s) window
Definition w_labels.c:624
GtkWidget * hbox
Definition workspace.c:71
GtkWidget * img
Definition workspace.c:70
GtkWidget * vbox
Definition workspace.c:72