atomes 1.1.16
atomes: an atomic scale modeling tool box
Loading...
Searching...
No Matches
cell_extra.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: 'cell_extra.c'
24*
25* Contains:
26*
27
28 - The functions to create the 'add cell(s)' tab in the cell edition window
29
30*
31* List of functions:
32
33 G_MODULE_EXPORT void add_cell (GtkSpinButton * res, gpointer data);
34
35 GtkWidget * add_extra_cell_tab (glwin * view);
36
37*/
38
39#include "cell_edit.h"
40
49G_MODULE_EXPORT void add_cell (GtkSpinButton * res, gpointer data)
50{
51 tint * dat = (tint *)data;
52 int i;
53 project * this_proj = get_project_by_id (dat -> a);
54 image * last = this_proj -> modelgl -> anim -> last -> img;
55 i = max(last -> extra_cell[0], last -> extra_cell[1]);
56 i = max(i, last -> extra_cell[2]);
57 last -> p_depth /= (i+1);
58 last -> extra_cell[dat -> b] = gtk_spin_button_get_value_as_int(res) - 1;
59 i = max(last -> extra_cell[0], last -> extra_cell[1]);
60 i = max(i, last -> extra_cell[2]);
61 last -> p_depth *= (i+1);
62 double fact = last -> p_depth*2.0 / last -> gfar;
63 last -> gfar = last -> p_depth*2.0;
64 last -> gnear *= fact;
65 last -> zoom *= fact;
66 init_default_shaders (this_proj -> modelgl);
67 this_proj -> modelgl -> create_shaders[MDBOX] = TRUE;
68 this_proj -> modelgl -> create_shaders[MAXIS] = TRUE;
69 if (this_proj -> modelgl -> n_shaders[SLABS][0]) this_proj -> modelgl -> create_shaders[SLABS] = TRUE;
70 update (this_proj -> modelgl);
71 sens_superbut (this_proj);
72}
73
81GtkWidget * add_extra_cell_tab (glwin * view)
82{
83 GtkWidget * layout = create_layout (350, 150);
84 GtkWidget * hbox = create_hbox (50);
85 GtkWidget * vbox = create_vbox (BSEP);
86 layout_add_widget (layout, hbox, 50, 50);
87 int i;
88 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, vbox, FALSE, FALSE, 0);
89 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, markup_label("\tAdd extra cell(s):", -1, -1, 0.0, 0.5), FALSE, FALSE, 10);
90 GtkWidget * hhbox;
91 gchar * str;
92 for (i=0; i<3; i++)
93 {
94 hhbox = create_hbox (0);
95 view -> cell_win -> ax_cell[i] = spin_button (G_CALLBACK(add_cell), view -> anim -> last -> img -> extra_cell[i]+1, 1, 1000, 1, 0, 100, & view -> colorp[i][0]);
96 str = g_strdup_printf ("%s x ", box_prop[0][i]);
97 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hhbox, markup_label(str, -1, -1, 0.0, 0.5), FALSE, FALSE, 40);
98 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hhbox, view -> cell_win -> ax_cell[i], FALSE, FALSE, 0);
99 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hhbox, FALSE, FALSE, 5);
100 }
102 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, vbox, FALSE, FALSE, 50);
103 view -> cell_win -> superbut = create_button ("Create super-cell", IMG_NONE, NULL, 100, -1, GTK_RELIEF_NORMAL, G_CALLBACK(super_cell_but), view);
105 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, view -> cell_win -> superbut, FALSE, FALSE, 90);
107 return layout;
108}
Function declarations for the cell edition window.
void sens_superbut(project *this_proj)
adjust 'Create super-cell' button sensitivity
Definition cell_super.c:141
G_MODULE_EXPORT void super_cell_but(GtkButton *but, gpointer data)
create super cell callback
Definition cell_super.c:338
G_MODULE_EXPORT void add_cell(GtkSpinButton *res, gpointer data)
add cell callback
Definition cell_extra.c:49
GtkWidget * add_extra_cell_tab(glwin *view)
create the add cell(s) tab
Definition cell_extra.c:81
color colorp[64]
PangoLayout * layout
Definition curve.c:79
void init_default_shaders(glwin *view)
re-initialize the default OpenGL shaders
char * box_prop[2][3]
Definition edit_menu.c:73
@ IMG_NONE
Definition global.h:260
project * proj
#define BSEP
Definition global.h:245
void layout_add_widget(GtkWidget *layout, GtkWidget *child, int x_pos, int y_pos)
Add a GtkWidget in a GtkLayout.
Definition gtk-misc.c:846
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:1772
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:1863
GtkWidget * markup_label(gchar *text, int dimx, int dimy, float ax, float ay)
Definition gtk-misc.c:1585
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
GtkWidget * create_hbox(int spacing)
create a GtkBox with horizontal orientation
Definition gtk-misc.c:813
GtkWidget * create_layout(int x, int y)
create a GtkLayout / GtkFixed widget
Definition gtk-misc.c:880
GtkWidget * create_vbox(int spacing)
create a GtkBox with vertical orientation
Definition gtk-misc.c:801
void show_the_widgets(GtkWidget *widg)
show GtkWidget
Definition gtk-misc.c:173
project * get_project_by_id(int p)
get project pointer using id number
Definition project.c:120
#define max(a, b)
Definition global.h:80
void update(glwin *view)
update the rendering of the OpenGL window
Definition glview.c:439
void zoom(glwin *view, int delta)
zoom in or zoom out in the OpenGL window
Definition glview.c:1006
@ SLABS
Definition glwin.h:101
@ MAXIS
Definition glwin.h:94
@ MDBOX
Definition glwin.h:93
Definition glwin.h:875
Definition glwin.h:277
Definition global.h:104
int b
Definition tab-1.c:95
int a
Definition tab-1.c:95
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