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)
781 GtkFileChooserNative * info;
785 GtkFileChooser * chooser;
786 GtkFileFilter *
filter[2];
787 const gchar * file_ext[2]={
"*.ipf",
"*"};
788 const gchar * file_type[2]={
"IPF file (*.ipf)",
"All files (*)"};
789 const gchar * str[2]={
"Import ISAACS Project File",
"Export ISAACS Project File"};
790 const gchar *
res[2]={
"Open",
"Save"};
791 GtkFileChooserAction act[2]={GTK_FILE_CHOOSER_ACTION_OPEN, GTK_FILE_CHOOSER_ACTION_SAVE};
793 i = GPOINTER_TO_INT (data);
802 chooser = GTK_FILE_CHOOSER (info);
804 gtk_file_chooser_set_do_overwrite_confirmation (chooser, TRUE);
806 if (i) gtk_file_chooser_set_create_folders (chooser, TRUE);
809 filter[j] = gtk_file_filter_new();
810 gtk_file_filter_set_name (GTK_FILE_FILTER(
filter[j]), file_type[j]);
811 gtk_file_filter_add_pattern (GTK_FILE_FILTER(
filter[j]), file_ext[j]);
812 gtk_file_chooser_add_filter (chooser,
filter[j]);
818 run_this_gtk_native_dialog ((GtkNativeDialog *)info, G_CALLBACK(
run_on_isaacs_port), NULL);
835 double *
x, *
y, *
z;
842 lat[0] = lat[1] = lat[2] = 0.0;
847 for (j=0; j<3; j++) lat[i] -=
active_box -> vect[j][i]/2.0;
909 gchar * str = g_strdup_printf (
"Label of atomic spec. N° %d:", sid+1);
910 gtk_label_set_text (GTK_LABEL(
sa_lab[0]), str);
920 str = g_strdup_printf (
"Number of atom(s) for spec. N° %d:", sid+1);
922 gtk_label_set_text (GTK_LABEL(
sa_lab[1]), str);
946 i = GPOINTER_TO_INT(data);
1011 str = g_strdup_printf (
"N°%d", i+1);
1012 gtk_combo_box_text_append_text ((GtkComboBoxText *)combo, str);
1015 gtk_combo_box_set_active (GTK_COMBO_BOX(combo), 0);
1016 g_signal_connect (G_OBJECT (combo),
"changed", G_CALLBACK(
changed_spec_combo), NULL);
1042 i = GPOINTER_TO_INT(data);
1044 gboolean
up = FALSE;
1103 int id = GPOINTER_TO_INT(data);
1104 switch (response_id)
1106 case GTK_RESPONSE_APPLY:
1133 gchar * rlabel[2]={
"Total number of atom(s):",
"Number of chemical species:"};
1135 read_this = gtk_dialog_add_button (GTK_DIALOG (dialog),
"Apply", GTK_RESPONSE_APPLY);
1194G_MODULE_EXPORT
void run_read_npt_data (GtkNativeDialog * info, gint response_id, gpointer data)
1196 GtkFileChooser * chooser = GTK_FILE_CHOOSER((GtkFileChooserNative *)info);
1209 GtkFileChooser * chooser = GTK_FILE_CHOOSER((GtkWidget *)info);
1211 if (response_id == GTK_RESPONSE_ACCEPT)
1234 GtkFileFilter *
filter[2];
1236 GtkFileChooserNative * info;
1242 GTK_FILE_CHOOSER_ACTION_OPEN,
1244 GtkFileChooser * chooser = GTK_FILE_CHOOSER(info);
1245 filter[0] = gtk_file_filter_new();
1246 gtk_file_filter_set_name (GTK_FILE_FILTER(
filter[0]),
"DAT files (*.dat)");
1247 gtk_file_filter_add_pattern (GTK_FILE_FILTER(
filter[0]),
"*.dat");
1248 gtk_file_chooser_add_filter (chooser,
filter[0]);
1249 filter[1] = gtk_file_filter_new();
1250 gtk_file_filter_set_name (GTK_FILE_FILTER(
filter[1]),
"All files (*)");
1251 gtk_file_filter_add_pattern (GTK_FILE_FILTER(
filter[1]),
"*");
1252 gtk_file_chooser_add_filter (chooser,
filter[1]);
1255 run_this_gtk_native_dialog ((GtkNativeDialog *)info, G_CALLBACK(
run_read_npt_data), NULL);
1271 struct timespec sta_time;
1272 struct timespec sto_time;
1275 clock_gettime (CLOCK_MONOTONIC, & sta_time);
1341 clock_gettime (CLOCK_MONOTONIC, & sto_time);
1389 if (
id > 6 &&
id < 9)
1391 clock_gettime (CLOCK_MONOTONIC, & sta_time);
1394 show_error (
"Error while parsing the chemical information\n"
1395 "please check carefully the coordinates file", 0,
MainWindow);
1398 clock_gettime (CLOCK_MONOTONIC, & sto_time);
1420 clock_gettime (CLOCK_MONOTONIC, &
start_time);
1423 clock_gettime (CLOCK_MONOTONIC, &
stop_time);
1437 if (format != 1 && format != 4 && format != 6 && format != 9 && format != 10 && format != 11)
on_edit_activate (NULL, GINT_TO_POINTER(4));
1446 if ((format == 9 || format == 10) &&
active_cell -> has_a_box)
1449 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)
active_glwin -> ogl_rep[0], TRUE);
1451 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)
active_glwin -> ogl_clones[0], TRUE);
1461 gchar * file_name = g_strdup_printf (
"%s",
active_project -> coordfile);
1462 gchar * proj_name = g_strdup_printf (
"%s - symmetry position(s)",
active_project -> name);
1486G_MODULE_EXPORT
void run_on_coord_port (GtkNativeDialog * info, gint response_id, gpointer data)
1488 GtkFileChooser * chooser = GTK_FILE_CHOOSER((GtkFileChooserNative *)info);
1501 GtkFileChooser * chooser = GTK_FILE_CHOOSER((GtkWidget *)info);
1504 GtkFileFilter * tmp;
1507 i = GPOINTER_TO_INT(data);
1509 switch (response_id)
1511 case GTK_RESPONSE_ACCEPT:
1512 tmp = gtk_file_chooser_get_filter (chooser);
1520 while (tmp !=
filter[j]) j++;
1525 j =
iask (
"Please select the file format of the atomic coordinates",
"Select format :", 2,
MainWindow);
1533 format =
iask (
"Please select the format of the atomic coordinates",
"Select format :", 1,
MainWindow);
1539 active_cell -> frac = (format < 2) ? 0 : format - 1;
1540 car_to_au = (format == 1) ? 1 : 0;
1573 tmp_str = g_strdup_printf (
"Impossible to export the atomic coordinates\nError code: %d", k);
1606 GtkFileChooserNative * info;
1610 GtkFileChooser * chooser;
1613 const gchar * str[2]={
"Import atomic coordinates",
"Export atomic coordinates"};
1614 const gchar *
res[2]={
"Open",
"Save"};
1615 char * out_files[2] = {
"XYZ file",
1617 char * out_ext[2]={
"xyz",
"c3d"};
1618 GtkFileChooserAction act[2]={GTK_FILE_CHOOSER_ACTION_OPEN, GTK_FILE_CHOOSER_ACTION_SAVE};
1620 i = GPOINTER_TO_INT (data);
1638 chooser = GTK_FILE_CHOOSER(info);
1639 if (i) gtk_file_chooser_set_create_folders (chooser, TRUE);
1641 gtk_file_chooser_set_do_overwrite_confirmation (chooser, TRUE);
1643 for (j=0; j<num_files[i]; j++)
1645 filter[j] = gtk_file_filter_new();
1652 tmp_str = g_strdup_printf (
"%s (*.%s)", out_files[j], out_ext[j]);
1654 gtk_file_filter_set_name (GTK_FILE_FILTER(
filter[j]), tmp_str);
1662 tmp_str = g_strdup_printf (
"*.%s", out_ext[j]);
1664 gtk_file_filter_add_pattern (GTK_FILE_FILTER(
filter[j]), tmp_str);
1665 gtk_file_chooser_add_filter (chooser,
filter[j]);
1670 filter[j] = gtk_file_filter_new();
1671 gtk_file_filter_set_name (GTK_FILE_FILTER(
filter[j]),
"All files (*)");
1672 gtk_file_filter_add_pattern (GTK_FILE_FILTER(
filter[j]),
"*");
1673 gtk_file_chooser_add_filter (chooser,
filter[j]);
1678 gtk_file_chooser_set_current_name (chooser,
"coord.xyz");
1681 run_this_gtk_native_dialog ((GtkNativeDialog *)info, G_CALLBACK(
run_on_coord_port), GINT_TO_POINTER(i));
1694 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
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.