atomes 1.2.1
atomes: an atomic scale modeling tool box
Loading...
Searching...
No Matches
init_p.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: 'init_p.c'
24*
25* Contains:
26*
27
28 - The functions to initialize an atomes project
29
30*
31* List of functions:
32
33 void init_curves_and_calc (project * this_proj);
34 void apply_default_parameters_to_project (project * this_proj);
35 void init_project (gboolean alloc_box);
36
37*/
38
39#include "global.h"
40#include "bind.h"
41#include "callbacks.h"
42#include "interface.h"
43#include "preferences.h"
44#include "project.h"
45#include "curve.h"
46#include "glview.h"
47#include "glwindow.h"
48
49extern void init_camera (project * this_proj, int get_depth);
50extern void setup_default_image (project * this_proj, image * img);
51extern void clean_atom_style (project * this_proj);
53extern void init_shaders (glwin * view);
54extern G_MODULE_EXPORT void box_advanced (GtkWidget * widg, gpointer data);
55extern G_MODULE_EXPORT void axis_advanced (GtkWidget * widg, gpointer data);
56extern G_MODULE_EXPORT void representation_advanced (GtkWidget * widg, gpointer data);
57extern G_MODULE_EXPORT void opengl_advanced (GtkWidget * widg, gpointer data);
58extern void update_gradient_widgets (gradient_edition * gradient_win, background * back);
59extern G_MODULE_EXPORT void gradient_advanced (GtkWidget * widg, gpointer data);
60
68void init_curves_and_calc (project * this_proj)
69{
70 int i;
71 for (i=0; i<NGRAPHS; i++)
72 {
73 this_proj -> runok[i] = FALSE;
74 this_proj -> initok[i] = FALSE;
75 this_proj -> visok[i] = FALSE;
76 }
77}
78
87{
88 int i, j;
89 // Calc parameters
90 if (this_proj -> chemistry)
91 {
92 this_proj -> chemistry -> grtotcutoff = default_totcut;
93 }
94 for (i=0; i<6; i++) this_proj -> num_delta[i] = default_num_delta[i];
95 this_proj -> num_delta[SP] = default_num_delta[6];
96 this_proj -> num_delta[MS] = default_num_delta[7];
97 this_proj -> delta[MS] = default_delta_t[0];
98 for (i=0; i<5; i++)
99 {
100 this_proj -> rsparam[i][0] = default_rsparam[1];
101 this_proj -> rsparam[i][1] = default_rsparam[2];
102 for (j=2; j<5; j++) this_proj -> rsparam[i][j] = default_rsparam[j+2];
103 }
104 this_proj -> rsearch[0] = default_rsparam[0];
105 this_proj -> rsearch[1] = default_rsparam[3];
106 this_proj -> csparam[0] = default_csparam[0];
107 for (i=1; i<4; i++) this_proj -> csparam[i]= default_csparam[i+2];
108 this_proj -> csparam[5] = default_csparam[1];
109 this_proj -> csearch = default_csparam[2];
110 if (this_proj -> modelgl)
111 {
112 image * img = this_proj -> modelgl -> anim -> last -> img;
113 if (img)
114 {
115 preferences = FALSE;
116 setup_default_image (this_proj, img);
117 preferences = TRUE;
118 init_camera (this_proj, FALSE);
120 clean_atom_style (this_proj);
121 init_shaders (this_proj -> modelgl);
122 update (this_proj -> modelgl);
123 if (this_proj -> modelgl -> box_win)
124 {
125 if (this_proj -> modelgl -> box_win -> win) this_proj -> modelgl -> box_win -> win = destroy_this_widget (this_proj -> modelgl -> box_win -> win);
126 g_free (this_proj -> modelgl -> box_win);
127 this_proj -> modelgl -> box_win = NULL;
128 box_advanced (NULL, this_proj -> modelgl);
129 }
130 if (this_proj -> modelgl -> axis_win)
131 {
132 if (this_proj -> modelgl -> axis_win -> win) this_proj -> modelgl -> axis_win -> win = destroy_this_widget (this_proj -> modelgl -> axis_win -> win);
133 g_free (this_proj -> modelgl -> axis_win);
134 this_proj -> modelgl -> axis_win = NULL;
135 axis_advanced (NULL, this_proj -> modelgl);
136 }
137 if (this_proj -> modelgl -> rep_win)
138 {
139 if (this_proj -> modelgl -> rep_win -> win) this_proj -> modelgl -> rep_win -> win = destroy_this_widget (this_proj -> modelgl -> rep_win -> win);
140 g_free (this_proj -> modelgl -> rep_win);
141 this_proj -> modelgl -> rep_win = NULL;
142 representation_advanced (NULL, this_proj -> modelgl);
143 }
144 if (this_proj -> modelgl -> opengl_win)
145 {
146 if (this_proj -> modelgl -> opengl_win -> win) this_proj -> modelgl -> opengl_win -> win = destroy_this_widget (this_proj -> modelgl -> opengl_win -> win);
147 g_free (this_proj -> modelgl -> opengl_win);
148 this_proj -> modelgl -> opengl_win = NULL;
149 opengl_advanced (NULL, this_proj -> modelgl);
150 }
151 if (this_proj -> modelgl -> gradient_win) update_gradient_widgets (this_proj -> modelgl -> gradient_win, img -> back);
152 }
153 }
154}
155
163void init_project (gboolean alloc_box)
164{
165 project * new_proj = g_malloc0 (sizeof*proj);
166 nprojects ++;
167 activep = nprojects - 1;
168 new_proj -> id = activep;
169 new_proj -> name = g_strdup_printf("%s%2d", "Project N°", activep);
170 new_proj -> delta[RI] = new_proj -> delta[CH] = 1.0;
171 new_proj -> min[RI] = new_proj -> min[CH] = 1;
172 new_proj -> delta[SP] = 2.0;
174 new_proj -> tfile = -1;
175 new_proj -> newproj = TRUE;
176 new_proj -> steps = 1;
177 new_proj -> xcor = 1;
178 new_proj -> tunit = (int)default_delta_t[1];
179
180 new_proj -> sk_advanced[0] = 1.0;
181 new_proj -> sk_advanced[1] = 15.0;
182
183 new_proj -> coord = g_malloc0 (sizeof*new_proj -> coord);
184 if (alloc_box) new_proj -> cell.box = g_malloc0(sizeof*new_proj -> cell.box);
185
187 init_curves_and_calc (new_proj);
188 new_proj -> numwid = -1;
189 if (nprojects == 1)
190 {
191 workzone.first = g_malloc0 (sizeof*workzone.first);
192 workzone.first = new_proj;
193 workzone.last = g_malloc0 (sizeof*workzone.last);
194 }
195 else
196 {
197 new_proj -> prev = workzone.last;
198 workzone.last -> next = new_proj;
199 }
200 workzone.last = new_proj;
201 active_project_changed (new_proj -> id);
203 new_proj -> newproj = FALSE;
204}
Binding to the Fortran90 subroutines.
Callback declarations for main window.
integer(kind=c_int) function chemistry()
Definition chemistry.F90:22
Variable declarations for the curve widget Functions for interactions with the curve widget.
int activep
Definition global.c:159
int nprojects
Definition global.c:158
Global variable declarations Global convenience function declarations Global data structure defin...
workspace workzone
Definition project.c:46
project * proj
void remove_edition_actions()
remove all edition actions
Definition gui.c:422
#define NGRAPHS
#define RI
Definition global.h:330
#define MS
Definition global.h:333
GtkWidget * destroy_this_widget(GtkWidget *widg)
destroy a GtkWidget
Definition gtk-misc.c:2169
#define min(a, b)
Definition global.h:81
#define SP
Definition global.h:332
#define CH
Definition global.h:331
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...
Function declarations for the creation of the OpenGL window.
void setup_default_image(project *this_proj, image *img)
setup default image parameters
Definition glview.c:1344
G_MODULE_EXPORT void opengl_advanced(GtkWidget *widg, gpointer data)
create OpenGL rendering advanced window
Definition w_advance.c:1670
void init_curves_and_calc(project *this_proj)
for a project reset analysis, curves, data to not performed
Definition init_p.c:68
void apply_default_parameters_to_project(project *this_proj)
apply new default parameters to project
Definition init_p.c:86
void init_shaders(glwin *view)
initialize all the OpenGL shaders
G_MODULE_EXPORT void gradient_advanced(GtkWidget *widg, gpointer data)
Background configuration window.
Definition w_colors.c:434
void clean_atom_style(project *this_proj)
clean all atom(s) possible alternative rendering styles
Definition m_style.c:74
G_MODULE_EXPORT void axis_advanced(GtkWidget *widg, gpointer data)
create the axis advanced parameters window
Definition w_axis.c:786
void init_camera(project *this_proj, int get_depth)
initialize the OpenGL camera settings
Definition glview.c:1170
void update_gradient_widgets(gradient_edition *gradient_win, background *back)
update the widgets of the gradient window
Definition w_colors.c:84
G_MODULE_EXPORT void box_advanced(GtkWidget *widg, gpointer data)
create the box edition window
Definition w_box.c:338
void setup_default_species_parameters_for_image(project *this_proj, image *img)
setup default chemical species related parameters for image
Definition glview.c:1218
G_MODULE_EXPORT void representation_advanced(GtkWidget *widg, gpointer data)
open advanced representation dialog
Definition m_rep.c:424
void init_project(gboolean alloc_box)
initialize a new project
Definition init_p.c:163
Messaging function declarations.
void prep_calc_actions()
prepare analysis widgets
Definition update_p.c:58
int * default_csparam
int * default_num_delta
int * default_rsparam
double default_totcut
double * default_delta_t
gboolean preferences
Preference variable declarations.
Function declarations for reading atomes project file Function declarations for saving atomes proje...
void active_project_changed(int id)
change the active project
Definition update_p.c:175
Definition glwin.h:965
Definition glwin.h:365
project * last
Definition global.h:1050
project * first
Definition global.h:1049
atom_search * csearch
Definition w_search.c:2729
GtkWidget * img
Definition workspace.c:70