atomes 1.1.15
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-2024 by CNRS and University of Strasbourg */
15
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
41*/
42
43#include "global.h"
44#include "bind.h"
45#include "interface.h"
46#include "callbacks.h"
47#include "project.h"
48#include "workspace.h"
49
50extern GtkWidget * work_menu (int p, int c);
51extern GtkTreeStore * tool_model;
52
59{
60 int i;
61 // Depends on the number of calculations available
62 for (i=0; i<G_N_ELEMENTS(analyze_actions); i++)
63 {
64 if (i < AN)
65 {
66 if (active_project -> runok[i])
67 {
69 }
70 else
71 {
73 }
74 }
75 else
76 {
77 if (active_project -> runok[i+1])
78 {
80 }
81 else
82 {
84 }
85 }
86 }
87}
88
95{
96#ifdef DEBUG
97 g_debug ("UPDATE_PROJECT: to update");
98#endif
99 int i, j;
100 if (! active_project -> newproj && active_project -> natomes)
101 {
102 i = alloc_data_ (& active_project -> natomes,
103 & active_project -> nspec,
104 & active_project -> steps);
105 if (i == 1)
106 {
107 to_read_pos ();
108 int * lot = allocint (active_project -> natomes);
109 for (j=0; j<active_project -> natomes; j++) lot[j] = active_project -> atoms[0][j].sp;
110 read_data_ (lot, active_chem -> nsps);
111 g_free (lot);
112 read_chem_ (active_chem -> chem_prop[CHEM_M], active_chem -> chem_prop[CHEM_R],
113 active_chem -> chem_prop[CHEM_N], active_chem -> chem_prop[CHEM_X]);
114 j = 0;
115 prep_spec_ (active_chem -> chem_prop[CHEM_Z], active_chem -> nsps, & j);
116 }
117 else
118 {
119 return 0;
120 }
121 if (active_project -> run)
122 {
123 active_project -> dmtx = FALSE;
124 j = (active_cell -> npt) ? active_project -> steps : 1;
125 for (i=0; i<j; i++)
126 {
127 lattice_ (& j, & i,
128 active_cell -> box[i].vect,
129 active_cell -> box[i].param[0],
130 active_cell -> box[i].param[1],
131 & active_cell -> ltype,
132 & active_cell -> frac,
133 & active_cell -> pbc);
134
135 }
136 cutoffsend ();
137 }
138 }
139 if (active_project -> numwid > 0)
140 {
141 if (active_cell -> has_a_box)
142 {
143 active_project -> runok[GR] = TRUE;
144 active_project -> runok[SK] = TRUE;
145 }
146 else
147 {
148 active_project -> runok[GR] = FALSE;
149 active_project -> runok[SQ] = FALSE;
150 active_project -> runok[SK] = FALSE;
151 active_project -> runok[GK] = FALSE;
152 }
153 if (active_project -> natomes)
154 {
155 active_project -> runok[BD] = TRUE;
156 active_project -> runok[RI] = TRUE;
157 active_project -> runok[CH] = TRUE;
158 active_project -> runok[SP] = TRUE;
159 if (active_project -> steps > 1) active_project -> runok[MS] = TRUE;
160 }
161 }
162#ifdef DEBUG
163 g_debug ("UPDATE_PROJECT: updated");
164#endif
165 return 1;
166}
167
176{
177 char * errp = NULL;
178 if (id != inactep && inactep < nprojects && ! atomes_logo) clean_view ();
179 gtk_tree_store_clear (tool_model);
180 activep = id;
183 active_coord = active_project -> coord;
184 active_cell = & active_project -> cell;
185 active_box = NULL;
186 active_glwin = NULL;
187 active_image = NULL;
188 if (active_project -> modelgl != NULL)
189 {
190 active_glwin = active_project -> modelgl;
191 if (active_glwin -> anim != NULL)
192 {
193 active_image = active_glwin -> anim -> last -> img;
194 }
195 }
196
197 if (active_cell -> box)
198 {
199 if (active_project -> steps == 1 || ! active_cell -> npt || ! active_image)
200 {
201 active_box = & active_cell -> box[0];
202 }
203 else if (active_cell -> npt)
204 {
206 }
207 }
208 if (update_project() == 0)
209 {
210 errp = g_strdup_printf ("Impossible to update project: %s\n", active_project -> name);
211 show_error (errp, 0, MainWindow);
212 g_free (errp);
213 }
214 else
215 {
216 if (active_project -> numwid > 0)
217 {
220 if (active_cell -> npt)
221 {
223 }
224 else
225 {
227 }
230 correct_this_window_title (curvetoolbox, g_strdup_printf ("Toolboxes - %s", prepare_for_title(active_project -> name)));
231 correct_this_window_title (MainWindow, g_strdup_printf ("%s - %s", PACKAGE, prepare_for_title (active_project -> name)));
232 }
234 }
236}
237
246{
247 activev = id;
249}
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:831
Callback declarations for main window.
void fill_tool_model()
fill the tool window tree model
Definition tools.c:87
integer(kind=c_int) function chemistry()
Definition chemistry.F90:22
gchar * param[2]
int atoms[NUM_STYLES][2]
int activep
Definition global.c:159
GSimpleAction * edition_actions[3]
Definition global.c:197
int inactep
Definition global.c:162
int activew
Definition global.c:163
int nprojects
Definition global.c:158
int activev
Definition global.c:160
GtkWidget * MainWindow
Definition global.c:201
int * allocint(int val)
allocate an int * pointer
Definition global.c:314
GtkWidget * atomes_logo
Definition global.c:208
GSimpleAction * analyze_actions[9]
Definition global.c:198
GtkWidget * curvetoolbox
Definition global.c:205
Global variable declarations Global convenience function declarations Global data structure defin...
glwin * active_glwin
Definition project.c:53
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 CHEM_N
Definition global.h:300
chemical_data * active_chem
Definition project.c:48
atomes_action analyze_acts[]
Definition gui.c:112
#define GR
Definition global.h:322
#define SQ
Definition global.h:323
#define CHEM_R
Definition global.h:299
#define RI
Definition global.h:328
box_info * active_box
Definition project.c:51
#define BD
Definition global.h:326
project * opengl_project
Definition project.c:54
#define AN
Definition global.h:327
void add_action(GSimpleAction *action)
add action to the main window action map
Definition gui.c:400
#define CHEM_M
Definition global.h:298
#define MS
Definition global.h:331
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:243
#define CHEM_X
Definition global.h:301
#define CHEM_Z
Definition global.h:297
#define SK
Definition global.h:324
#define GK
Definition global.h:325
#define SP
Definition global.h:330
project * active_project
Definition project.c:47
void remove_action(gchar *action_name)
add action from the main window action map
Definition gui.c:412
#define CH
Definition global.h:329
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:70
void clean_view()
clean the main window
Definition gui.c:286
void show_error(char *error, int val, GtkWidget *win)
show error message
Definition interface.c:293
Messaging function declarations.
Function declarations for reading atomes project file Function declarations for saving atomes proje...
int c
Definition tab-1.c:95
GtkTreeStore * tool_model
Definition tools.c:60
void opengl_project_changed(int id)
change the OpenGL project
Definition update_p.c:245
void active_project_changed(int id)
change the active project
Definition update_p.c:175
void prep_calc_actions()
prepare analysis widgets
Definition update_p.c:58
GtkWidget * work_menu(int p, int c)
create the workspace popup menu
Definition work_menu.c:202
int update_project()
update project: send data to Fortran90, and update calculation interactors
Definition update_p.c:94
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:337
Function declarations for workspace managment.