90 "CPMD trajectory - NPT",
92 "VASP trajectory - NPT",
93 "Protein Data Bank file",
94 "Protein Data Bank file",
95 "Crystallographic information (crystal build)",
96 "Crystallographic information (symmetry positions)",
97 "DL-POLY HISTORY file",
98 "ISAACS Project File"};
101 "pdb",
"ent",
"cif",
"cif",
"hist",
"ipf"};
105extern G_MODULE_EXPORT
void on_edit_activate (GtkWidget * widg, gpointer data);
106extern gchar *
substitute_string (gchar * init, gchar * o_motif, gchar * n_motif);
107extern const gchar *
dfi[2];
122 g_application_quit (G_APPLICATION(
AtomesApp));
136 gboolean close = FALSE;
137 j = GPOINTER_TO_INT (data);
153 g_debug (
"CLOSING:: %d", i);
174int open_save (FILE *
fp,
int i,
int pid,
int aid,
int npi, gchar * pfile)
189 err = g_strdup_printf (
"Impossible to open project file: \n%s\nError code: %d\n", pfile, j);
198 g_debug (
"pid= %d, pfile= %s", pid, pfile);
213 err = g_strdup_printf (
"Impossible to save project file:\n%s\nError code: %d\n", pfile, j);
246 if (fread (& i,
sizeof(
int), 1,
fp) != 1)
return 1;
247 ver = g_malloc0 (i*
sizeof*ver);
248 if (fread (ver,
sizeof(
char), i,
fp) != i)
return 1;
251 if (fread (& i,
sizeof(
int), 1,
fp) != 1)
return 1;
256 ver = g_strdup_printf (
"%%\n%% Workspace file v-%1d.0\n%%\n", i);
258 if (fwrite (& i,
sizeof(
int), 1,
fp) != 1)
return 1;
259 if (fwrite (ver,
sizeof(
char), i,
fp) != i)
return 1;
263 if (fwrite (& i,
sizeof(
int), 1,
fp) != 1)
return 1;
277 if (m != 0)
return m;
282 if (m != 0)
return m;
303 FILE *
fp = fopen (data,
dfi[0]);
326 GListModel * projlist;
327 GtkFileChooser * chooser = GTK_FILE_CHOOSER((GtkFileChooserNative *)info);
340 GSList * projlist = NULL;
341 GtkFileChooser * chooser = GTK_FILE_CHOOSER((GtkWidget *)info);
346 const gchar * mess[2]={
"reading",
"saving "};
347 if (response_id == GTK_RESPONSE_ACCEPT)
381 g_slist_free (projlist);
384 for (i=0; i<g_list_model_get_n_items (projlist); i++)
386 GObject * obj = g_list_model_get_item (projlist, i);
389 g_object_unref (projlist);
401 err = g_strdup_printf (
"Error %s workspace file\n%s\nError code: %d\n",
428 GtkFileChooserNative * info;
432 GtkFileChooser * chooser;
434 const gchar * str[4]={
"Open Project File(s)",
"Save Project File",
"Open Workspace",
"Save Workspace"};
435 const gchar *
res[2]={
"Open",
"Save"};
436 const gchar * file_name[2]={
"Project file (*.apf)",
"Workspace file (*.awf)"};
437 const gchar * file_ext[2]={
"*.apf",
"*.awf"};
438 GtkFileChooserAction act[2]={GTK_FILE_CHOOSER_ACTION_OPEN, GTK_FILE_CHOOSER_ACTION_SAVE};
441 i = GPOINTER_TO_INT (data);
443 if (i == 1 || i == 3)
472 else if (i == 1 && ! this_proj -> natomes)
491 if (g_strcmp0(this_proj ->
projfile,
"(null)") == 0) this_proj ->
projfile = NULL;
525 tmp_str = g_strdup_printf (
"%s - New project", str[i]);
529 tmp_str = g_strdup_printf (
"%s - %s", str[i],
prepare_for_title(this_proj -> name));
533 tmp_str = g_strdup_printf (
"%s", str[i]);
539 chooser = GTK_FILE_CHOOSER (info);
542 gtk_file_chooser_set_do_overwrite_confirmation (chooser, TRUE);
544 if (i == 1 || i == 3) gtk_file_chooser_set_create_folders (chooser, TRUE);
550 gtk_file_chooser_set_select_multiple (chooser, TRUE);
560 gtk_file_chooser_set_current_name (chooser,
projfile);
572 gtk_file_chooser_set_current_name (chooser, g_strdup_printf (
"%s",
workspacefile));
580 filter1 = gtk_file_filter_new();
581 gtk_file_filter_set_name (GTK_FILE_FILTER(
filter1), file_name[i/2]);
582 gtk_file_filter_add_pattern (GTK_FILE_FILTER(
filter1), file_ext[i/2]);
583 gtk_file_chooser_add_filter (chooser,
filter1);
584 filter2 = gtk_file_filter_new();
585 gtk_file_filter_set_name (GTK_FILE_FILTER(
filter2),
"All files (*)");
586 gtk_file_filter_add_pattern (GTK_FILE_FILTER(
filter2),
"*");
587 gtk_file_chooser_add_filter (chooser,
filter2);
716G_MODULE_EXPORT
void run_on_isaacs_port (GtkNativeDialog * info, gint response_id, gpointer data)
718 GtkFileChooser * chooser = GTK_FILE_CHOOSER((GtkFileChooserNative *)info);
731 GtkFileChooser * chooser = GTK_FILE_CHOOSER((GtkWidget *)info);
733 if (response_id == GTK_RESPONSE_ACCEPT)
780 GtkFileChooserNative * info;
784 GtkFileChooser * chooser;
785 GtkFileFilter *
filter[2];
786 const gchar * file_ext[2]={
"*.ipf",
"*"};
787 const gchar * file_type[2]={
"IPF file (*.ipf)",
"All files (*)"};
788 const gchar * str[2]={
"Import ISAACS Project File",
"Export ISAACS Project File"};
789 const gchar *
res[2]={
"Open",
"Save"};
790 GtkFileChooserAction act[2]={GTK_FILE_CHOOSER_ACTION_OPEN, GTK_FILE_CHOOSER_ACTION_SAVE};
792 i = GPOINTER_TO_INT (data);
801 chooser = GTK_FILE_CHOOSER (info);
803 gtk_file_chooser_set_do_overwrite_confirmation (chooser, TRUE);
805 if (i) gtk_file_chooser_set_create_folders (chooser, TRUE);
808 filter[j] = gtk_file_filter_new();
809 gtk_file_filter_set_name (GTK_FILE_FILTER(
filter[j]), file_type[j]);
810 gtk_file_filter_add_pattern (GTK_FILE_FILTER(
filter[j]), file_ext[j]);
811 gtk_file_chooser_add_filter (chooser,
filter[j]);
817 run_this_gtk_native_dialog ((GtkNativeDialog *)info, G_CALLBACK(
run_on_isaacs_port), NULL);
834 double *
x, *
y, *
z;
841 lat[0] = lat[1] = lat[2] = 0.0;
846 for (j=0; j<3; j++) lat[i] -=
active_box -> vect[j][i]/2.0;
908 gchar * str = g_strdup_printf (
"Label of atomic spec. N° %d:", sid+1);
909 gtk_label_set_text (GTK_LABEL(
sa_lab[0]), str);
919 str = g_strdup_printf (
"Number of atom(s) for spec. N° %d:", sid+1);
921 gtk_label_set_text (GTK_LABEL(
sa_lab[1]), str);
945 i = GPOINTER_TO_INT(data);
1010 str = g_strdup_printf (
"N°%d", i+1);
1011 gtk_combo_box_text_append_text ((GtkComboBoxText *)combo, str);
1014 gtk_combo_box_set_active (GTK_COMBO_BOX(combo), 0);
1015 g_signal_connect (G_OBJECT (combo),
"changed", G_CALLBACK(
changed_spec_combo), NULL);
1041 i = GPOINTER_TO_INT(data);
1043 gboolean
up = FALSE;
1102 int id = GPOINTER_TO_INT(data);
1103 switch (response_id)
1105 case GTK_RESPONSE_APPLY:
1132 gchar * rlabel[2]={
"Total number of atom(s):",
"Number of chemical species:"};
1134 read_this = gtk_dialog_add_button (GTK_DIALOG (dialog),
"Apply", GTK_RESPONSE_APPLY);
1193G_MODULE_EXPORT
void run_read_npt_data (GtkNativeDialog * info, gint response_id, gpointer data)
1195 GtkFileChooser * chooser = GTK_FILE_CHOOSER((GtkFileChooserNative *)info);
1208 GtkFileChooser * chooser = GTK_FILE_CHOOSER((GtkWidget *)info);
1210 if (response_id == GTK_RESPONSE_ACCEPT)
1233 GtkFileFilter *
filter[2];
1235 GtkFileChooserNative * info;
1241 GTK_FILE_CHOOSER_ACTION_OPEN,
1243 GtkFileChooser * chooser = GTK_FILE_CHOOSER(info);
1244 filter[0] = gtk_file_filter_new();
1245 gtk_file_filter_set_name (GTK_FILE_FILTER(
filter[0]),
"DAT files (*.dat)");
1246 gtk_file_filter_add_pattern (GTK_FILE_FILTER(
filter[0]),
"*.dat");
1247 gtk_file_chooser_add_filter (chooser,
filter[0]);
1248 filter[1] = gtk_file_filter_new();
1249 gtk_file_filter_set_name (GTK_FILE_FILTER(
filter[1]),
"All files (*)");
1250 gtk_file_filter_add_pattern (GTK_FILE_FILTER(
filter[1]),
"*");
1251 gtk_file_chooser_add_filter (chooser,
filter[1]);
1254 run_this_gtk_native_dialog ((GtkNativeDialog *)info, G_CALLBACK(
run_read_npt_data), NULL);
1270 struct timespec sta_time;
1271 struct timespec sto_time;
1274 clock_gettime (CLOCK_MONOTONIC, & sta_time);
1340 clock_gettime (CLOCK_MONOTONIC, & sto_time);
1388 if (
id > 6 &&
id < 9)
1390 clock_gettime (CLOCK_MONOTONIC, & sta_time);
1393 show_error (
"Error while parsing the chemical information\n"
1394 "please check carefully the coordinates file", 0,
MainWindow);
1397 clock_gettime (CLOCK_MONOTONIC, & sto_time);
1419 clock_gettime (CLOCK_MONOTONIC, &
start_time);
1422 clock_gettime (CLOCK_MONOTONIC, &
stop_time);
1436 if (format != 1 && format != 4 && format != 6 && format != 9 && format != 10 && format != 11)
on_edit_activate (NULL, GINT_TO_POINTER(4));
1445 if ((format == 9 || format == 10) &&
active_cell -> has_a_box)
1448 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)
active_glwin -> ogl_rep[0], TRUE);
1450 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)
active_glwin -> ogl_clones[0], TRUE);
1460 gchar * file_name = g_strdup_printf (
"%s",
active_project -> coordfile);
1461 gchar * proj_name = g_strdup_printf (
"%s - symmetry position(s)",
active_project -> name);
1485G_MODULE_EXPORT
void run_on_coord_port (GtkNativeDialog * info, gint response_id, gpointer data)
1487 GtkFileChooser * chooser = GTK_FILE_CHOOSER((GtkFileChooserNative *)info);
1500 GtkFileChooser * chooser = GTK_FILE_CHOOSER((GtkWidget *)info);
1503 GtkFileFilter * tmp;
1506 i = GPOINTER_TO_INT(data);
1508 switch (response_id)
1510 case GTK_RESPONSE_ACCEPT:
1511 tmp = gtk_file_chooser_get_filter (chooser);
1519 while (tmp !=
filter[j]) j++;
1527 j =
iask (
"Please select the file format of the atomic coordinates",
"Select format :", 2,
MainWindow);
1535 format =
iask (
"Please select the format of the atomic coordinates",
"Select format :", 1,
MainWindow);
1541 active_cell -> frac = (format < 2) ? 0 : format - 1;
1542 car_to_au = (format == 1) ? 1 : 0;
1575 tmp_str = g_strdup_printf (
"Impossible to export the atomic coordinates\nError code: %d", k);
1608 GtkFileChooserNative * info;
1612 GtkFileChooser * chooser;
1615 const gchar * str[2]={
"Import atomic coordinates",
"Export atomic coordinates"};
1616 const gchar *
res[2]={
"Open",
"Save"};
1617 char * out_files[2] = {
"XYZ file",
1619 char * out_ext[2]={
"xyz",
"c3d"};
1620 GtkFileChooserAction act[2]={GTK_FILE_CHOOSER_ACTION_OPEN, GTK_FILE_CHOOSER_ACTION_SAVE};
1622 i = GPOINTER_TO_INT (data);
1640 chooser = GTK_FILE_CHOOSER(info);
1641 if (i) gtk_file_chooser_set_create_folders (chooser, TRUE);
1643 gtk_file_chooser_set_do_overwrite_confirmation (chooser, TRUE);
1645 for (j=0; j<num_files[i]; j++)
1647 filter[j] = gtk_file_filter_new();
1654 tmp_str = g_strdup_printf (
"%s (*.%s)", out_files[j], out_ext[j]);
1656 gtk_file_filter_set_name (GTK_FILE_FILTER(
filter[j]), tmp_str);
1664 tmp_str = g_strdup_printf (
"*.%s", out_ext[j]);
1666 gtk_file_filter_add_pattern (GTK_FILE_FILTER(
filter[j]), tmp_str);
1667 gtk_file_chooser_add_filter (chooser,
filter[j]);
1672 filter[j] = gtk_file_filter_new();
1673 gtk_file_filter_set_name (GTK_FILE_FILTER(
filter[j]),
"All files (*)");
1674 gtk_file_filter_add_pattern (GTK_FILE_FILTER(
filter[j]),
"*");
1675 gtk_file_chooser_add_filter (chooser,
filter[j]);
1680 gtk_file_chooser_set_current_name (chooser,
"coord.xyz");
1683 run_this_gtk_native_dialog ((GtkNativeDialog *)info, G_CALLBACK(
run_on_coord_port), GINT_TO_POINTER(i));
1696 tmp_str = g_strdup_printf (
"Project <b>%s</b> is empty ... nothing to be saved\n",
Function declarations for the mode edition window.
Binding to the Fortran90 subroutines.
void send_label_(int *, int *, char *)
void read_pos_(double *, double *, double *)
void prep_pos_(int *, int *)
int write_xyz_(char *, int *, int *, int *)
void lattice_(int *, int *, double[3][3], double[3], double[3], int *, int *, int *)
int write_c3d_(char *, int *, int *, int *)
int read_pdb_(char *, int *)
int open_coordinate_file(int id)
try to open coordinate file, type is based of id
int open_coord_file(gchar *filename, int fti)
open atomic coordinates file
int to_read_trj_or_vas(int ff)
reading CPMD/VASP trajectory - prepare the dialog
void initcwidgets()
initializing curve values
void quit_gtk()
Leave the application.
G_MODULE_EXPORT void on_edit_activate(GtkWidget *widg, gpointer data)
create an edition dialog - prepare the dialog
G_MODULE_EXPORT void run_read_npt_data(GtkDialog *info, gint response_id, gpointer data)
read NPT data associated with atomic coordinates: run the dialog GTK3 callback
G_MODULE_EXPORT void changed_spec_combo(GtkComboBox *box, gpointer data)
reading CPMD/VASP trajectory, change the active species
int read_npt_data()
read NPT data associated with atomic coordinates: setup the dialog
int open_save_workspace(FILE *fp, int act)
open or save the active workspace
gchar * substitute_string(gchar *init, gchar *o_motif, gchar *n_motif)
substitute all patterns in string
G_MODULE_EXPORT void run_on_open_save_active(GtkDialog *info, gint response_id, gpointer data)
open or save an atomes file - running the dialog
double get_z_from_periodic_table(gchar *lab)
get Z from atom label
G_MODULE_EXPORT void on_close_workspace(GtkWidget *widg, gpointer data)
close the active workspace
G_MODULE_EXPORT void on_open_save_activate(GtkWidget *widg, gpointer data)
open or save an atomes file - prepare the dialog
G_MODULE_EXPORT void run_on_coord_port(GtkDialog *info, gint response_id, gpointer data)
export or import atomic coordinates: run dialog
G_MODULE_EXPORT void run_on_isaacs_port(GtkDialog *info, gint response_id, gpointer data)
open or write ISAACS XML file - running the dialog
void apply_project(gboolean showtools)
get project ready for calculation and initialize the OpenGL window
int prep_chem_data()
prepare chemical data to read CPMD/VASP file
G_MODULE_EXPORT void on_isaacs_port(GtkWidget *widg, gpointer data)
open or write ISAACS XML file - prepare the dialog
void open_this_coordinate_file(int format, gchar *proj_name)
open coordinate file format, if successful add to workspace
int open_history_file(gchar *filename)
void run_project()
send project data to Fortran90
int open_save(FILE *fp, int i, int pid, int aid, int npi, gchar *pfile)
open or save project file
G_MODULE_EXPORT void run_to_read_trj_or_vas(GtkDialog *dialog, gint response_id, gpointer data)
reading CPMD/VASP trajectory: run the dialog
void cell_data_from_pdb_(float *a, float *b, float *c, float *alp, float *bet, float *gam)
update cell parameters from the data in the PDB file
GtkFileFilter * filter[NCFORMATS+1]
char * coord_files_ext[NCFORMATS+1]
int open_cif_file(gchar *filename)
G_MODULE_EXPORT void update_sa(GtkEntry *res, gpointer data)
reading CPMD/VASP trajectory, set the number of chemical species
G_MODULE_EXPORT void on_coord_port(GtkWidget *widg, gpointer data)
export or import atomic coordinates: prepare dialog
G_MODULE_EXPORT void on_save_as_activate(GtkWidget *widg, gpointer data)
open or save, choosing a file name
void update_sa_info(int sid)
reading CPMD/VASP trajectory, update chemical species info
void prepare_sp_box()
eading CPMD/VASP trajectory, prepare the species combo box
char * coord_files[NCFORMATS+1]
G_MODULE_EXPORT void update_at_sp(GtkEntry *res, gpointer data)
reading CPMD/VASP trajectory, changing number of atomes or species
void open_this_isaacs_xml_file(gchar *profile, int ptoc, gboolean visible)
open an ISAACS XML file
void open_this_proj(gpointer data, gpointer user_data)
Open many projects, one at a time.
void to_read_pos()
send atomic coordinates to Fortran90
int open_cell_file(int format, gchar *filename)
open the file that contains the cell parameters
void check_read_sa()
reading CPMD/VASP trajectory, testing parameters to active the read capabilty
Callback declarations for main window.
void shift_it(vec3_t shift, int refresh, int proj)
shift atomic coordinates
Function declarations for the cell edition window.
void update_insert_combos()
update some GtkComboBox in the workspace if a project is removed
void to_close_this_project(int to_activate, project *this_proj)
to close this project
G_MODULE_EXPORT void on_close_activate(GtkWidget *widg, gpointer cdata)
signal to close a project
void label(cairo_t *cr, double val, int axe, int p, project *this_proj)
draw axis label
struct timespec start_time
GtkApplication * AtomesApp
double * allocdouble(int val)
allocate a double * pointer
gchar * calculation_time(gboolean modelv, double ctime)
get calculation time, human readable
int * allocint(int val)
allocate an int * pointer
double get_calc_time(struct timespec start, struct timespec stop)
get calculation time in s
struct timespec stop_time
gboolean cif_use_symmetry_positions
double string_to_double(gpointer string)
convert string to double
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
void file_chooser_set_current_folder(GtkFileChooser *chooser)
set current folder in a GtkFilechooser
GtkWidget * create_entry(GCallback handler, int dim, int cdim, gboolean key_release, gpointer data)
Create a GtkEntry.
#define ATOM_LIMIT
atom number limit to compute fragment(s) and molecule(s) analysis automatically
GtkWidget * dialogmodal(gchar *str, GtkWindow *parent)
Create a new dialog modal window.
gchar * file_chooser_get_file_name(GtkFileChooser *chooser)
get a file name from a GtkFileChooser (single file selected)
const gchar * entry_get_text(GtkEntry *entry)
get the text in a GtkEntry
chemical_data * active_chem
void update_entry_int(GtkEntry *entry, int intval)
update the content of a GtkEntry as int
gboolean file_chooser_set_file_name(GtkFileChooser *chooser, gchar *filename)
set file name in a GtkFilechooser
GtkWidget * create_combo()
create a GtkCombox widget, note deprecated in GTK4
GtkWidget * dialog_get_content_area(GtkWidget *widg)
prepare GtkWidget to insert content in a GtkDialog window
GtkWidget * markup_label(gchar *text, int dimx, int dimy, float ax, float ay)
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.
void widget_set_sensitive(GtkWidget *widg, gboolean sensitive)
Set sensitivity for a GtkWidget, ensuring it is a GtkWidget.
void destroy_this_dialog(GtkDialog *dialog)
destroy a GtkDialog
GtkWidget * create_hbox(int spacing)
create a GtkBox with horizontal orientation
GtkWidget * destroy_this_widget(GtkWidget *widg)
destroy a GtkWidget
void update_entry_text(GtkEntry *entry, gchar *text)
update the content of a GtkEntry as string
gchar * prepare_for_title(gchar *init)
prepare a string for a window title, getting rid of all markup
GtkWidget * create_vbox(int spacing)
create a GtkBox with vertical orientation
GtkWidget * create_file_chooser(const gchar *title, GtkWindow *parent, GtkFileChooserAction act, const gchar *act_name)
create a GtkFileChooser, utility to select file(s)
GSList * file_chooser_get_file_names(GtkFileChooser *chooser)
create a file list from files selected using a GtkFileChooser
void initcutoffs(chemical_data *chem, int species)
initialize bond cutoffs
void destroy_this_native_dialog(GtkNativeDialog *dialog)
destroy a GtkNativeDialog
void show_the_widgets(GtkWidget *widg)
show GtkWidget
project * get_project_by_id(int p)
get project pointer using id number
Variable declarations related to the OpenGL window Function declarations related to the OpenGL wind...
G_MODULE_EXPORT void show_hide_clones(GSimpleAction *action, GVariant *state, gpointer data)
show/hide clones menu item callback
void prep_model(int p)
prepare, or display, the OpenGL model window
Function declarations for the creation of the OpenGL window.
void init_project(gboolean alloc_box)
initialize a new project
int iask(char *question, char *lab, int id, GtkWidget *win)
enter an integer value - prepare the dialog
void show_warning(char *warning, GtkWidget *win)
show warning
void show_info(char *information, int val, GtkWidget *win)
add / show information message to widget
void show_error(char *error, int val, GtkWidget *win)
show error message
gboolean ask_yes_no(gchar *title, gchar *text, int type, GtkWidget *widg)
ask yes or no for something: prepare dialog
Messaging function declarations.
void prep_calc_actions()
prepare analysis widgets
integer(kind=c_int) function lattice(totl, lid, vectors, vmod, angles, lat, cfrac, apbc)
G_MODULE_EXPORT void set_rep(GtkWidget *widg, gpointer data)
change representation callback - GTK3
int open_project(FILE *fp, int npi)
open atomes project file
Function declarations for reading atomes project file Function declarations for saving atomes proje...
int save_project(FILE *fp, project *this_proj, int wid)
save project to file
void active_project_changed(int id)
change the active project
int write_xml(const char *filetosave)
write XML file
gchar * open_xml(const char *filetoread)
Open ISAACS XML file.
Functions declaration to read atomic coordinates.
void add_project_to_workspace()
add project(s) to the workspace tree
Function declarations for workspace managment.