atomes 1.3.1
atomes: an atomic scale modeling tool box
Loading...
Searching...
No Matches
update_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-2026 by CNRS and University of Strasbourg */
15
22
23/*
24* This file: 'update_p.c'
25*
26* Contains:
27*
28
29 - The functions to update a project
30 - The functions to activate a project
31
32*
33* List of functions:
34
35 int update_project ();
36
37 void prep_calc_actions ();
38 void active_project_changed (int id);
39 void opengl_project_changed (int id);
40 void update_analysis_availability (project * this_proj);
41
42*/
43
44#include "global.h"
45#include "bind.h"
46#include "interface.h"
47#include "callbacks.h"
48#include "project.h"
49#include "workspace.h"
50
51extern GtkWidget * work_menu (int p, int c);
52extern GtkTreeStore * tool_model;
53
60{
61 int i;
62 gchar * str;
63 // Depends on the number of calculations available
64 for (i=0; i<NCALCS-1; i++)
65 {
66 str = g_strdup_printf ("analyze.%d", i);
67 if (! active_project || ! active_project -> analysis)
68 {
69 remove_action (str);
70 }
71 else
72 {
73 if (i < ANG)
74 {
75 if (active_project -> analysis[i])
76 {
77 if (active_project -> analysis[i] -> avail_ok)
78 {
80 }
81 else
82 {
83 remove_action (str);
84 }
85 }
86 else
87 {
88 remove_action (str);
89 }
90 }
91 else
92 {
93 if (active_project -> analysis[i+1])
94 {
95 if (active_project -> analysis[i+1] -> avail_ok)
96 {
98 }
99 else
100 {
101 remove_action (str);
102 }
103 }
104 else
105 {
106 remove_action (str);
107 }
108 }
109 }
110 g_free (str);
111 }
112}
113
122{
123 if (this_proj -> natomes && this_proj -> analysis)
124 {
125 if (this_proj -> cell.has_a_box)
126 {
127 if (this_proj -> analysis[GDR]) this_proj -> analysis[GDR] -> avail_ok = TRUE;
128 if (this_proj -> analysis[SKD]) this_proj -> analysis[SKD] -> avail_ok = TRUE;
129 if (this_proj -> analysis[SQD] && this_proj -> analysis[GDR]) this_proj -> analysis[SQD] -> avail_ok = this_proj -> analysis[GDR] -> calc_ok;
130 if (this_proj -> analysis[GDK] && this_proj -> analysis[SKD]) this_proj -> analysis[GDK] -> avail_ok = this_proj -> analysis[SKD] -> calc_ok;
131 if (this_proj -> steps > 1 && this_proj -> analysis[SKT]) this_proj -> analysis[SKT] -> avail_ok = TRUE;
132 }
133 else
134 {
135 if (this_proj -> analysis[GDR]) this_proj -> analysis[GDR] -> avail_ok = FALSE;
136 if (this_proj -> analysis[SQD]) this_proj -> analysis[SQD] -> avail_ok = FALSE;
137 if (this_proj -> analysis[SKD]) this_proj -> analysis[SKD] -> avail_ok = FALSE;
138 if (this_proj -> analysis[GDK]) this_proj -> analysis[GDK] -> avail_ok = FALSE;
139 }
140 if (this_proj -> analysis[BND]) this_proj -> analysis[BND] -> avail_ok = TRUE;
141 if (this_proj -> analysis[ANG]) this_proj -> analysis[ANG] -> avail_ok = TRUE;
142 if (this_proj -> analysis[RIN]) this_proj -> analysis[RIN] -> avail_ok = TRUE;
143 if (this_proj -> analysis[CHA]) this_proj -> analysis[CHA] -> avail_ok = TRUE;
144 if (this_proj -> analysis[SPH]) this_proj -> analysis[SPH] -> avail_ok = TRUE;
145 if (this_proj -> steps > 1 && this_proj -> analysis[MSD]) this_proj -> analysis[MSD] -> avail_ok = TRUE;
146 }
147 else if (this_proj -> analysis)
148 {
149 int i;
150 for (i=0; i<NCALCS; i++)
151 {
152 if (this_proj -> analysis[i]) this_proj -> analysis[i] -> avail_ok = FALSE;
153 }
154 }
155}
156
163{
164#ifdef DEBUG
165 g_debug ("UPDATE_PROJECT: to update");
166#endif
167 int i, j;
168 if (! active_project -> newproj && active_project -> natomes)
169 {
170 i = alloc_data_ (& active_project -> natomes,
171 & active_project -> nspec,
172 & active_project -> steps);
173 if (i == 1)
174 {
175 to_read_pos ();
176 int * lot = allocint (active_project -> natomes);
177 for (j=0; j<active_project -> natomes; j++) lot[j] = active_project -> atoms[0][j].sp;
178 read_data_ (lot, active_chem -> nsps);
179 g_free (lot);
180 read_chem_ (active_chem -> chem_prop[CHEM_M], active_chem -> chem_prop[CHEM_R],
181 active_chem -> chem_prop[CHEM_N], active_chem -> chem_prop[CHEM_X]);
182 j = 0;
183 prep_spec_ (active_chem -> chem_prop[CHEM_Z], active_chem -> nsps, & j);
184 }
185 else
186 {
187 return 0;
188 }
189 if (active_project -> run)
190 {
191 j = (active_cell -> npt) ? active_project -> steps : 1;
192 for (i=0; i<j; i++)
193 {
194 lattice_ (& j, & i,
195 active_cell -> box[i].vect,
196 active_cell -> box[i].param[0],
197 active_cell -> box[i].param[1],
198 & active_cell -> ltype,
199 & active_cell -> frac,
200 & active_cell -> pbc);
201
202 }
203 cutoffsend ();
204 }
205 }
207#ifdef DEBUG
208 g_debug ("UPDATE_PROJECT: updated");
209#endif
210 return 1;
211}
212
221{
222 char * errp = NULL;
224 {
225 if (id != inactep && inactep < nprojects && ! atomes_logo) clean_view ();
226 gtk_tree_store_clear (tool_model);
227 }
228 activep = id;
231 active_coord = active_project -> coord;
232 active_cell = & active_project -> cell;
233 active_box = NULL;
234 active_glwin = NULL;
235 active_image = NULL;
236 if (active_project -> modelgl != NULL)
237 {
238 active_glwin = active_project -> modelgl;
239 if (active_glwin -> anim != NULL)
240 {
241 active_image = active_glwin -> anim -> last -> img;
242 }
243 }
244
245 if (active_cell -> box)
246 {
247 if (active_project -> steps == 1 || ! active_cell -> npt || ! active_image)
248 {
249 active_box = & active_cell -> box[0];
250 }
251 else if (active_cell -> npt)
252 {
254 }
255 }
256 if (update_project() == 0)
257 {
258 errp = g_strdup_printf (_("Impossible to update project: %s\n"), active_project -> name);
259 show_error (errp, 0, MainWindow);
260 g_free (errp);
261 }
262 else
263 {
265 {
266 if (active_project -> analysis)
267 {
269 g_action_map_add_action (G_ACTION_MAP(AtomesApp), G_ACTION(edition_actions[0]));
270 if (active_cell -> npt)
271 {
273 }
274 else
275 {
276 g_action_map_add_action (G_ACTION_MAP(AtomesApp), G_ACTION(edition_actions[1]));
277 }
278 g_action_map_add_action (G_ACTION_MAP(AtomesApp), G_ACTION(edition_actions[2]));
280 correct_this_window_title (curvetoolbox, g_strdup_printf (_("Toolboxes - %s"), prepare_for_title(active_project -> name)));
281 correct_this_window_title (MainWindow, g_strdup_printf ("%s - %s", PACKAGE, prepare_for_title (active_project -> name)));
282 }
283 }
285 }
287}
288
297{
298 activev = id;
300}
gchar * action_name[5]
Definition atom_edit.c:60
Binding to the Fortran90 subroutines.
void read_chem_(double *, double *, double *, double *)
void read_data_(int *, int *)
void prep_spec_(double *, int *, int *)
void lattice_(int *, int *, double[3][3], double[3], double[3], int *, int *, int *)
int alloc_data_(int *, int *, int *)
void to_read_pos()
send atomic coordinates to Fortran90
Definition callbacks.c:960
Callback declarations for main window.
void fill_tool_model()
fill the tool window tree model
Definition tools.c:91
integer(kind=c_int) function chemistry()
Definition chemistry.F90:22
#define PACKAGE
Definition config.h:46
gchar * param[2]
int atoms[NUM_STYLES][2]
int activep
Definition global.c:162
GSimpleAction * edition_actions[3]
Definition global.c:204
int inactep
Definition global.c:165
int activew
Definition global.c:166
GtkApplication * AtomesApp
Definition global.c:206
int nprojects
Definition global.c:161
int activev
Definition global.c:163
GtkWidget * MainWindow
Definition global.c:207
gboolean atomes_render_image
Definition global.c:196
int * allocint(int val)
allocate an int * pointer
Definition global.c:301
GtkWidget * atomes_logo
Definition global.c:214
GtkWidget * curvetoolbox
Definition global.c:211
Global variable declarations Global convenience function declarations Global data structure defin...
#define SKT
Definition global.h:347
glwin * active_glwin
Definition project.c:53
#define SQD
Definition global.h:338
void add_analysis_action(int act)
add action to the main window action map
Definition gui.c:538
coord_info * active_coord
Definition project.c:49
cell_info * active_cell
Definition project.c:50
atomes_action edition_acts[]
Definition gui.c:108
#define RIN
Definition global.h:343
#define CHEM_N
Definition global.h:319
chemical_data * active_chem
Definition project.c:48
#define SPH
Definition global.h:345
#define CHEM_R
Definition global.h:318
box_info * active_box
Definition project.c:51
#define ANG
Definition global.h:342
#define CHA
Definition global.h:344
project * opengl_project
Definition project.c:54
#define CHEM_M
Definition global.h:317
#define SKD
Definition global.h:339
#define BND
Definition global.h:341
gchar * prepare_for_title(gchar *init)
prepare a string for a window title, getting rid of all markup
Definition tools.c:71
void cutoffsend()
send cutoffs to Fortran90
Definition bdcall.c:293
#define CHEM_X
Definition global.h:320
#define CHEM_Z
Definition global.h:316
#define GDK
Definition global.h:340
project * active_project
Definition project.c:47
#define NCALCS
#define MSD
Definition global.h:346
void remove_action(gchar *action_name)
add action from the main window action map
Definition gui.c:554
#define GDR
Definition global.h:337
image * active_image
Definition project.c:52
project * get_project_by_id(int p)
get project pointer using id number
Definition project.c:120
int step
Definition ogl_draw.c:76
void clean_view()
clean the main window
Definition gui.c:288
void show_error(char *error, int val, GtkWidget *win)
show error message
Definition interface.c:299
Messaging function declarations.
Function declarations for reading atomes project file Function declarations for saving atomes proje...
Definition glwin.h:350
GtkTreeStore * tool_model
Definition tools.c:60
void update_analysis_availability(project *this_proj)
update analysis availability for a target projet
Definition update_p.c:121
void opengl_project_changed(int id)
change the OpenGL project
Definition update_p.c:296
void active_project_changed(int id)
change the active project
Definition update_p.c:220
void prep_calc_actions()
prepare analysis widgets
Definition update_p.c:59
GtkWidget * work_menu(int p, int c)
create the workspace popup menu
Definition work_menu.c:216
int update_project()
update project: send data to Fortran90, and update calculation interactors
Definition update_p.c:162
GtkWidget * img
Definition workspace.c:70
void correct_this_window_title(GtkWidget *win, gchar *str)
use new title for GtkWindow, providing it exists
Definition workspace.c:324
Function declarations for workspace managment.