atomes 1.1.15
atomes: an atomic scale modeling tool box
Loading...
Searching...
No Matches
w_box.c
Go to the documentation of this file.
1/* This file is part of the 'atomes' software
2
3'atomes' is free software: you can redistribute it and/or modify it under the terms
4of the GNU Affero General Public License as published by the Free Software Foundation,
5either version 3 of the License, or (at your option) any later version.
6
7'atomes' is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
8without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9See the GNU General Public License for more details.
10
11You should have received a copy of the GNU Affero General Public License along with 'atomes'.
12If not, see <https://www.gnu.org/licenses/>
13
14Copyright (C) 2022-2024 by CNRS and University of Strasbourg */
15
22/*
23* This file: 'w_box.c'
24*
25* Contains:
26*
27
28 - The functions to create the box properties window
29
30*
31* List of functions:
32
33 G_MODULE_EXPORT void set_box_combo_style (GtkWidget * widg, gpointer data);
34 G_MODULE_EXPORT void set_show_box_toggle (GtkCheckButton * but, gpointer data);
35 G_MODULE_EXPORT void set_show_box_toggle (GtkToggleButton * but, gpointer data);
36 G_MODULE_EXPORT void set_color_box (GtkColorChooser * colob, gpointer data);
37 G_MODULE_EXPORT void box_advanced (GSimpleAction * action, GVariant * parameter, gpointer data);
38 G_MODULE_EXPORT void box_advanced (GtkWidget * widg, gpointer data);
39
40*/
41
42#include "global.h"
43#include "interface.h"
44#include "glview.h"
45#include "glwindow.h"
46
47#define BOX_STYLES 2
48
49extern G_MODULE_EXPORT void update_bond_parameter (GtkEntry * res, gpointer data);
50extern GtkWidget * styles;
51extern GtkWidget * width_box;
52extern GtkWidget * radius_box;
53
54gchar * box_style[BOX_STYLES] = {"Wireframe", "Cylinders"};
55GtkWidget * box_data;
56
65G_MODULE_EXPORT void set_box_combo_style (GtkWidget * widg, gpointer data)
66{
67 int i = gtk_combo_box_get_active (GTK_COMBO_BOX(widg));
68#ifdef GTK4
69 opengl_project -> modelgl -> anim -> last -> img -> box_axis[0] = (i < 0) ? (NONE) : (i == 0) ? WIREFRAME : CYLINDERS;
70 opengl_project -> modelgl -> create_shaders[MDBOX] = TRUE;
71 update (opengl_project -> modelgl);
72#endif
73 if (i == 1)
74 {
77#ifdef GTK4
78
79#else
80 // GTK3 Menu Action To Check
81 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)opengl_project -> modelgl -> ogl_box_axis[0][2], TRUE);
82#endif
83 }
84 else if (i == 0)
85 {
88#ifdef GTK3
89 // GTK3 Menu Action To Check
90 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)opengl_project -> modelgl -> ogl_box_axis[0][1], TRUE);
91#endif
92 }
93}
94
95#ifdef GTK4
104G_MODULE_EXPORT void set_show_box_toggle (GtkCheckButton * but, gpointer data)
105#else
114G_MODULE_EXPORT void set_show_box_toggle (GtkToggleButton * but, gpointer data)
115#endif
116{
117 gboolean val;
118#ifdef GTK4
119 val = gtk_check_button_get_active (but);
120#else
121 val = gtk_toggle_button_get_active (but);
122#endif
123 if (val)
124 {
125#ifdef GTK3
126 // GTK3 Menu Action To Check
127 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)opengl_project -> modelgl -> ogl_box_axis[0][0], TRUE);
128#endif
129 gtk_combo_box_set_active (GTK_COMBO_BOX(styles), WIREFRAME-1);
130 }
131 else
132 {
133#ifdef GTK3
134 // GTK3 Menu Action To Check
135 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)opengl_project -> modelgl -> ogl_box_axis[0][0], FALSE);
136#endif
137 gtk_combo_box_set_active (GTK_COMBO_BOX(styles), NONE);
138 }
140}
141
150G_MODULE_EXPORT void set_color_box (GtkColorChooser * colob, gpointer data)
151{
152 opengl_project -> modelgl -> anim -> last -> img -> box_color = get_button_color (colob);
153 opengl_project -> modelgl -> create_shaders[MDBOX] = TRUE;
154 update (opengl_project -> modelgl);
155}
156
157#ifdef GTK4
167G_MODULE_EXPORT void box_advanced (GSimpleAction * action, GVariant * parameter, gpointer data)
168#else
177G_MODULE_EXPORT void box_advanced (GtkWidget * widg, gpointer data)
178#endif
179{
180 int i;
181
182 glwin * view = (glwin *)data;
184 GtkWidget * win = dialogmodal ("Advanced box settings", GTK_WINDOW(view -> win));
185 GtkWidget * vbox = dialog_get_content_area (win);
186 GtkWidget * box;
187
188 gboolean ac;
189 if (view -> anim -> last -> img -> box_axis[BOX] != NONE)
190 {
191 ac = TRUE;
192 }
193 else
194 {
195 ac = FALSE;
196 }
197 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, check_button ("Show / hide box", 100, 40, ac, G_CALLBACK(set_show_box_toggle), (gpointer)data),
198 FALSE, FALSE, 0);
200 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, box_data, TRUE, TRUE, 10);
202
203 GtkWidget * pos_box = create_vbox (BSEP);
204 add_box_child_start (GTK_ORIENTATION_VERTICAL, box_data, pos_box, TRUE, TRUE, 0);
205
206 box = abox (box_data, "Style: ", 0);
207 styles = create_combo ();
208 for (i=0; i<BOX_STYLES; i++)
209 {
211 }
212 if (view -> anim -> last -> img -> box_axis[BOX] == NONE) i = NONE;
213 if (view -> anim -> last -> img -> box_axis[BOX] == WIREFRAME) i = 0;
214 if (view -> anim -> last -> img -> box_axis[BOX] == CYLINDERS) i = 1;
215 gtk_combo_box_set_active (GTK_COMBO_BOX(styles), i);
216 gtk_widget_set_size_request (styles, 100, -1);
217 g_signal_connect (G_OBJECT (styles), "changed", G_CALLBACK(set_box_combo_style), data);
218 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, box, styles, TRUE, TRUE, 0);
219 width_box = abox (box_data, "Line width [pts]: ", 0);
220 GtkWidget * width = create_entry (G_CALLBACK(update_bond_parameter), 100, 10, FALSE, (gpointer)GINT_TO_POINTER(-3));
221 update_entry_double (GTK_ENTRY(width), view -> anim -> last -> img -> box_axis_line[BOX]);
222 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, width_box, width, FALSE, FALSE, 10);
223 radius_box = abox (box_data, "Cylinder radius [Å]: ", 0);
224 GtkWidget * radius = create_entry (G_CALLBACK(update_bond_parameter), 100, 10, FALSE, (gpointer)GINT_TO_POINTER(-3));
225 update_entry_double (GTK_ENTRY(radius), view -> anim -> last -> img -> box_axis_rad[BOX]);
226 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, radius_box, radius, FALSE, FALSE, 10);
227
228 // Colors
229 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, abox (box_data, "Color:", 0),
230 color_button(view -> anim -> last -> img -> box_color, TRUE, 100, -1, G_CALLBACK(set_color_box), NULL),
231 FALSE, FALSE, 10);
232
233 g_signal_connect (G_OBJECT(win), "response", G_CALLBACK(run_destroy_dialog), NULL);
234 show_the_widgets (win);
235 if (view -> anim -> last -> img -> box_axis[BOX] == CYLINDERS)
236 {
238 }
239 else
240 {
242 }
243 dialog_id ++;
244 Event_loop[dialog_id] = g_main_loop_new (NULL, FALSE);
245 g_main_loop_run (Event_loop[dialog_id]);
246#ifdef GTK4
247 update_menu_bar (view);
248#endif
249}
float val
Definition dlp_init.c:117
int dialog_id
Definition global.c:167
GMainLoop * Event_loop[5]
Definition global.c:178
Global variable declarations Global convenience function declarations Global data structure defin...
GtkWidget * create_entry(GCallback handler, int dim, int cdim, gboolean key_release, gpointer data)
Create a GtkEntry.
Definition gtk-misc.c:1314
void update_entry_double(GtkEntry *entry, double doubleval)
update the content of a GtkEntry as double
Definition gtk-misc.c:633
GtkWidget * dialogmodal(gchar *str, GtkWindow *parent)
Create a new dialog modal window.
Definition gtk-misc.c:510
gboolean is_the_widget_visible(GtkWidget *widg)
test if a GtkWidget exist, then return if it is visible or not
Definition gtk-misc.c:714
project * proj
#define BSEP
Definition global.h:245
void opengl_project_changed(int id)
change the OpenGL project
Definition update_p.c:245
GtkWidget * check_button(gchar *text, int dimx, int dimy, gboolean state, GCallback handler, gpointer data)
create a check button
Definition gtk-misc.c:1799
GtkWidget * create_combo()
create a GtkCombox widget, note deprecated in GTK4
Definition gtk-misc.c:923
GtkWidget * dialog_get_content_area(GtkWidget *widg)
prepare GtkWidget to insert content in a GtkDialog window
Definition gtk-misc.c:825
project * opengl_project
Definition project.c:54
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:299
ColRGBA get_button_color(GtkColorChooser *colob)
get the ColRGBA color from a GtkColorChooser button
Definition gtk-misc.c:2236
void widget_set_sensitive(GtkWidget *widg, gboolean sensitive)
Set sensitivity for a GtkWidget, ensuring it is a GtkWidget.
Definition gtk-misc.c:206
void combo_text_append(GtkWidget *combo, gchar *text)
append text in GtkComboBox widget
Definition gtk-misc.c:900
G_MODULE_EXPORT void run_destroy_dialog(GtkDialog *dialog, gint response_id, gpointer data)
to destroy a GtkDialog when the dialog emit the closing signal
Definition gtk-misc.c:2102
GtkWidget * color_button(ColRGBA col, gboolean alpha, int dimx, int dimy, GCallback handler, gpointer data)
create a color selection button
Definition gtk-misc.c:1728
void hide_the_widgets(GtkWidget *widg)
hide GtkWidget
Definition gtk-misc.c:189
GtkWidget * create_vbox(int spacing)
create a GtkBox with vertical orientation
Definition gtk-misc.c:801
GtkWidget * abox(GtkWidget *box, char *lab, int vspace)
box creating routine, to help design faster elements for the GUI
Definition gtk-misc.c:1912
void show_the_widgets(GtkWidget *widg)
show GtkWidget
Definition gtk-misc.c:173
void update(glwin *view)
update the rendering of the OpenGL window
Definition glview.c:439
Variable declarations related to the OpenGL window Function declarations related to the OpenGL wind...
action
Definition glview.h:189
styles
Definition glview.h:171
@ CYLINDERS
Definition glview.h:177
@ WIREFRAME
Definition glview.h:174
@ NONE
Definition glview.h:172
#define BOX
Definition glwin.h:54
@ MDBOX
Definition glwin.h:93
Function declarations for the creation of the OpenGL window.
Messaging function declarations.
Definition glwin.h:875
#define BOX_STYLES
Definition w_box.c:47
G_MODULE_EXPORT void set_show_box_toggle(GtkToggleButton *but, gpointer data)
toggle show / hide box callback GTK3
Definition w_box.c:114
G_MODULE_EXPORT void set_box_combo_style(GtkWidget *widg, gpointer data)
set box style callback
Definition w_box.c:65
G_MODULE_EXPORT void update_bond_parameter(GtkEntry *res, gpointer data)
update bond parameter callback
Definition w_bonds.c:59
GtkWidget * styles
Definition w_axis.c:85
GtkWidget * width_box
Definition w_axis.c:86
GtkWidget * radius_box
Definition w_axis.c:87
G_MODULE_EXPORT void set_color_box(GtkColorChooser *colob, gpointer data)
set box color callback
Definition w_box.c:150
gchar * box_style[BOX_STYLES]
Definition w_box.c:54
G_MODULE_EXPORT void box_advanced(GtkWidget *widg, gpointer data)
create the box edition window callback GTK3
Definition w_box.c:177
GtkWidget * box_data
Definition w_box.c:55
GtkWidget * res[2]
Definition w_encode.c:212
GtkWidget * img
Definition workspace.c:70
GtkWidget * vbox
Definition workspace.c:72