atomes 1.1.14
atomes: an atomic scale modeling tool box
Loading...
Searching...
No Matches
m_quality.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: 'm_quality.c'
24*
25* Contains:
26*
27
28 - The functions to create the 'OengGL -> Quality' submenu
29
30*
31* List of functions:
32
33 void set_quality (int q, glwin * view);
34
35 G_MODULE_EXPORT void set_quality_spin (GtkSpinButton * res, gpointer data);
36 G_MODULE_EXPORT void window_quality (GtkWidget * widg, gpointer data);
37 G_MODULE_EXPORT void to_window_quality (GSimpleAction * action, GVariant * parameter, gpointer data);
38
39 GtkWidget * menu_quality (glwin * view, int id);
40
41 GMenu * menu_quality (glwin * view, int popm);
42
43*/
44
45#include "global.h"
46#include "interface.h"
47#include "project.h"
48#include "glwindow.h"
49#include "glview.h"
50
59void set_quality (int q, glwin * view)
60{
61 view -> anim -> last -> img -> quality = q;
63 view -> create_shaders[MDBOX] = TRUE;
64 view -> create_shaders[MAXIS] = TRUE;
65 update (view);
66#ifdef GTK3
67 gtk_range_set_value (GTK_RANGE(view -> ogl_quality), view -> anim -> last -> img -> quality);
68#endif
69}
70
79G_MODULE_EXPORT void set_quality_spin (GtkSpinButton * res, gpointer data)
80{
81 glwin * view = (glwin *)data;
82 set_quality (gtk_spin_button_get_value_as_int(res), view);
83 update_entry_int (GTK_ENTRY(res), view -> anim -> last -> img -> quality);
84}
85
94G_MODULE_EXPORT void window_quality (GtkWidget * widg, gpointer data)
95{
96 glwin * view = (glwin *)data;
97 GtkWidget * win = dialogmodal ("Render Quality", GTK_WINDOW(view -> win));
98 GtkWidget * vbox = dialog_get_content_area (win);
99 GtkWidget * hbox = create_hbox (0);
100 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, TRUE, TRUE, 10);
101 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, gtk_label_new ("Quality [2-1000]: "), TRUE, TRUE, 0);
102 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox,
103 spin_button (G_CALLBACK(set_quality_spin), view -> anim -> last -> img -> quality, 2.0, 1000.0, 1.0, 0, 100, data),
104 FALSE, FALSE, 10);
105 add_gtk_close_event (win, G_CALLBACK(destroy_this_window), NULL);
107 run_this_gtk_dialog (win, G_CALLBACK(run_destroy_dialog), NULL);
108#ifdef GTK3
109 // GTK3 Menu Action To Check
110 gtk_range_set_value (GTK_RANGE(view -> ogl_quality), view -> anim -> last -> img -> quality);
111#else
112 update_menu_bar (view);
113#endif
114}
115
116#ifdef GTK3
125GtkWidget * menu_quality (glwin * view, int id)
126{
127 GtkWidget * menuq = gtk_menu_new ();
128 GtkWidget * fixed = gtk_fixed_new ();
129 if (id == 0)
130 {
131 view -> ogl_quality = create_hscale (2.0, 1000.0, 1.0, view -> anim -> last -> img -> quality, GTK_POS_RIGHT, 0, 100, NULL, NULL, NULL);
132 gtk_fixed_put (GTK_FIXED(fixed), view -> ogl_quality, 0, 0);
133 }
134 else
135 {
136 GtkWidget * qscale = create_hscale (2.0, 1000.0, 1.0, view -> anim -> last -> img -> quality, GTK_POS_RIGHT, 0, 100, NULL, NULL, NULL);
137 gtk_fixed_put (GTK_FIXED(fixed), qscale, 0, 0);
138 }
139 GtkWidget * qs = create_menu_item_from_widget (fixed, FALSE, FALSE, FALSE);
140 g_signal_connect (G_OBJECT (qs), "activate", G_CALLBACK(window_quality), view);
141 gtk_menu_shell_append ((GtkMenuShell *)menuq, qs);
142 return menuq;
143}
144#else
154G_MODULE_EXPORT void to_window_quality (GSimpleAction * action, GVariant * parameter, gpointer data)
155{
156 window_quality (NULL, data);
157}
158
167GMenu * menu_quality (glwin * view, int popm)
168{
169 GMenu * menu = g_menu_new ();
170 gchar * str = g_strdup_printf ("Quality: %d", view -> anim -> last -> img -> quality);
171 append_opengl_item (view, menu, str, "quality", popm, popm, NULL, IMG_NONE, NULL, FALSE, G_CALLBACK(to_window_quality), (gpointer)view, FALSE, FALSE, FALSE, TRUE);
172 g_free (str);
173 return menu;
174}
175#endif
void init_default_shaders(glwin *view)
re-initialize the default OpenGL shaders
Global variable declarations Global convenience function declarations Global data structure defin...
void run_this_gtk_dialog(GtkWidget *dial, GCallback handler, gpointer data)
run a GTK (3 and 4) basic GtkDialog
Definition gtk-misc.c:472
@ IMG_NONE
Definition global.h:232
GtkWidget * create_menu_item_from_widget(GtkWidget *widg, gboolean check, gboolean radio, gboolean status)
GtkWidget * dialogmodal(gchar *str, GtkWindow *parent)
Create a new dialog modal window.
Definition gtk-misc.c:490
void update_entry_int(GtkEntry *entry, int intval)
update the content of a GtkEntry as int
Definition gtk-misc.c:594
G_MODULE_EXPORT gboolean destroy_this_window(GtkWidget *win, GdkEvent *event, gpointer data)
destroy a GtkWindow
Definition gtk-misc.c:2320
void add_gtk_close_event(GtkWidget *widg, GCallback handler, gpointer data)
add a close event signal and callback to a GtkWidget
Definition gtk-misc.c:2363
GtkWidget * spin_button(GCallback handler, double value, double start, double end, double step, int digits, int dim, gpointer data)
create a spin button
Definition gtk-misc.c:1752
GtkWidget * dialog_get_content_area(GtkWidget *widg)
prepare GtkWidget to insert content in a GtkDialog window
Definition gtk-misc.c:805
void add_box_child_start(int orientation, GtkWidget *widg, GtkWidget *child, gboolean expand, gboolean fill, int padding)
Add a GtkWidget in a GtkBox at the initial position.
Definition gtk-misc.c:279
GtkWidget * create_hbox(int spacing)
create a GtkBox with horizontal orientation
Definition gtk-misc.c:793
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:2078
GtkWidget * create_hscale(float min, float max, float delta, float val, int pos, int round, int size, GCallback handler, GCallback scroll_handler, gpointer data)
create an horizontal scale GtkWidget
Definition gtk-misc.c:724
void show_the_widgets(GtkWidget *widg)
show GtkWidget
Definition gtk-misc.c:169
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
@ MAXIS
Definition glwin.h:94
@ MDBOX
Definition glwin.h:93
Function declarations for the creation of the OpenGL window.
void append_opengl_item(glwin *view, GMenu *menu, const gchar *name, gchar *key, int mpop, int item_id, gchar *accel, int image_format, gpointer icon, gboolean custom, GCallback handler, gpointer data, gboolean check, gboolean status, gboolean radio, gboolean sensitive)
Messaging function declarations.
void set_quality(int q, glwin *view)
set OpenGL quality
Definition m_quality.c:59
GMenu * menu_quality(glwin *view, int popm)
create the 'OpenGL -> Quality' menu item - GTK4
Definition m_quality.c:167
G_MODULE_EXPORT void to_window_quality(GSimpleAction *action, GVariant *parameter, gpointer data)
quality callback GTK4
Definition m_quality.c:154
G_MODULE_EXPORT void set_quality_spin(GtkSpinButton *res, gpointer data)
set quality spin button callback
Definition m_quality.c:79
G_MODULE_EXPORT void window_quality(GtkWidget *widg, gpointer data)
adjust OpenGL quality - creating the dialog
Definition m_quality.c:94
Function declarations for reading atomes project file Function declarations for saving atomes proje...
Definition glwin.h:875
GtkWidget * res[2]
Definition w_encode.c:212
GtkWidget * hbox
Definition workspace.c:71
GtkWidget * img
Definition workspace.c:70
GtkWidget * vbox
Definition workspace.c:72