91extern GtkWidget *
p_box;
99extern G_MODULE_EXPORT
void markup_action_renderer (GtkCellRendererCombo * cell, GtkCellEditable * editable, gchar * path_string, gpointer data);
130 gboolean a_match, b_match;
131 for (i=0; i<nat; i++)
133 if (fpar[i] == -1 || ffc[i] == -1) has_x ++;
135 if (has_x == nat)
return FALSE;
141 j = (i == 0) ? 1 : 0;
142 if (ffc[0] == fpar[i] && ffc[1] == fpar[j])
return TRUE;
143 if (ffc[0] == fpar[i] && has_x)
return TRUE;
144 if (ffc[1] == fpar[i] && has_x)
return TRUE;
149 if (ffc[1] != fpar[1] && fpar[1] != -1 && ffc[1] != -1)
return FALSE;
150 for (i=0; i<3; i=i+2)
153 if (ffc[0] == fpar[i] && ffc[2] == fpar[j])
return TRUE;
154 if (ffc[i] == fpar[i] && (ffc[j] == -1 || fpar[j] == -1))
return TRUE;
155 if (ffc[j] == fpar[i] && (ffc[i] == -1 || fpar[j] == -1))
return TRUE;
160 a_match = b_match = TRUE;
163 if (ffc[i] != fpar[i] && ffc[i] != -1 && fpar[i] != -1)
174 if (ffc[i] != fpar[j] && ffc[i] != -1 && fpar[j] != -1)
183 if (ffc[0] != fpar[0] && ffc[0] != -1 && fpar[0] != -1)
187 else if (ffc[3] != fpar[3] && ffc[3] != -1 && fpar[3] != -1)
193 if ((ffc[1] == fpar[1] || ffc[1] == -1 || fpar[1] == -1) && (ffc[2] == fpar[2] || ffc[2] == -1 || fpar[2] == -1))
197 else if ((ffc[1] == fpar[2] || ffc[1] == -1 || fpar[2] == -1) && (ffc[2] == fpar[1] || ffc[2] == -1 || fpar[1] == -1))
203 if (! a_match && ! b_match)
return FALSE;
262 char * vbdq[4] = {
"k/2",
"r<sub>0</sub>",
"k'/3",
"k''/4"};
263 char * vanq[4] = {
"k/2",
"θ<sub>0</sub>",
"k'/3",
"k''/4"};
264 char * vdwij[2] = {
"Ɛ<sub>i</sub>",
"r0<sub>i</sub>/2.0"};
268 if (newp && (key == 0 || key == 5))
270 vars = (
char **)vbdq;
280 vars = (
char **)vanq;
290 if (newp && (
tmp_field -> type <= CHARMMSI || tmp_field -> type >
COMPASS) && ! calc)
292 vars = (
char **)vdwij;
310 return g_strdup_printf (
"%s pot. (%s)",
fnames[
activef][(sid > 7) ? 10 : sid+2][key],
336 str = g_strdup_printf (
"%s-%s", str, (k < 0) ?
"X" :
ff_atoms[k][2]);
340 str = g_strdup_printf (
"%s", (k < 0) ?
"X" :
ff_atoms[k][2]);
348 if (sid == 8 && calc)
377 new_m ->
id = old_m -> id;
378 new_m -> obj = old_m -> obj;
379 new_m -> oid = old_m -> oid;
380 new_m -> type = old_m -> type;
381 new_m -> use = old_m -> use;
402 if (mbp ->
id == map ->
id && mbp -> obj == map -> obj)
405 if (mbp -> next && mbp -> prev)
407 mbp -> prev -> next = map;
408 map -> prev = mbp -> prev;
409 map -> next = mbp -> next;
410 mbp -> next -> prev = map;
412 else if (mbp -> next)
414 mbp -> next -> prev = map;
415 map -> next = mbp -> next;
417 else if (mbp -> prev)
419 mbp -> prev -> next = map;
420 map -> prev = mbp -> prev;
423 else if (! mbp -> next)
426 map -> prev = mbp -> next;
447 GtkTreeIter prop_level, struct_level;
451 gchar * stra, * strb, * strc, * strd, * stre;
454 g = (i==8) ? i+1 : i;
462 str = g_strdup_printf (
"<b>%s(s)</b> <sup>(2,3)</sup>",
felemts[8+g]);
466 str = g_strdup_printf (
"<b>%s(s)</b> <sup>(2)</sup>",
felemts[8+g]);
473 str = g_strdup_printf (
"<b>%s(s)</b> <sup>(3)</sup>",
felemts[8+g]);
477 str = g_strdup_printf (
"<b>%s(s)</b>",
felemts[8+g]);
482 str = g_strdup_printf (
"<b>%s(s)</b> <sup>(3)</sup>",
felemts[8+i]);
486 str = g_strdup_printf (
"<b>%s(s)</b> <sup>(4)</sup>",
felemts[8+i]);
490 str = g_strdup_printf (
"<b>%s(s)</b>",
felemts[8+i]);
492 gtk_tree_store_append (store, & prop_level, NULL);
493 gtk_tree_store_set (store, & prop_level, 0, -(i+1),
536 stra = g_strdup_printf (
"%s - ""%s""", stra, upat -> name);
537 if (
tmp_match -> obj > 0 && i < 8) strb = g_strdup_printf (
"%s-%d", strb,
tmp_fprop -> aid[j]+1);
542 stra = g_strdup_printf (
"""%s""", upat -> name);
543 if (
tmp_match -> obj > 0 && i < 8) strb = g_strdup_printf (
"%d",
tmp_fprop -> aid[j]+1);
555 strd = g_strdup_printf (
"Select ...");
568 str = g_strdup_printf (
"%s", strb);
573 str = g_strdup_printf (
"%s <sup>(*)</sup>", stra);
575 gtk_tree_store_append (store, & struct_level, & prop_level);
580 gtk_tree_store_set (store, & struct_level, 0, i,
608 GtkTreeStore * store;
610 store = gtk_tree_store_new (1, G_TYPE_STRING);
611 gtk_tree_store_append (store, & iter, NULL);
612 gtk_tree_store_set (store, & iter, 0,
"Select ...", -1);
621 gtk_tree_store_append (store, & iter, NULL);
622 gtk_tree_store_set (store, & iter, 0, str, -1);
628 return gtk_tree_model_filter_new(GTK_TREE_MODEL (store), NULL);
643 gboolean done = FALSE;
654 if (i ==
up.
a && ((i < 8 && other_match ->
id ==
up.
b) || (i == 8 &&
other_match -> obj ==
up.
b)))
659 if (g_strcmp0 (str, the_name) == 0)
689G_MODULE_EXPORT
void changed_update_renderer (GtkCellRendererCombo * combo, gchar * path_string, GtkTreeIter * iter, gpointer data)
694 g_object_get (combo,
"model", & cmodel, NULL);
695 gtk_tree_model_get_value ((GtkTreeModel *)cmodel, iter, 0, &
val);
696 if (gtk_tree_model_get_iter_from_string ((GtkTreeModel *)
update_model, iter, path_string))
698 gchar * str = g_strdup_printf (
"%s", (
char *)g_value_get_string (&
val));
719 GtkTreeModel * tmodel = gtk_tree_view_get_model (GTK_TREE_VIEW(tree));
720 GtkTreeIter update_iter;
722 if (gtk_tree_model_get_iter (tmodel, & update_iter,
path))
724 gtk_tree_model_get (tmodel, & update_iter, 0, &
up.
a, 1, &
up.
b, -1);
725 gtk_tree_model_filter_refilter ((GtkTreeModelFilter *)
prop_to_up);
742void ff_button_event (
double event_x,
double event_y, guint event_button, guint event_type, guint32 event_time, gpointer data)
757void ff_button_event (GdkEvent * event,
double event_x,
double event_y, guint event_button, guint event_type, guint32 event_time, gpointer data)
760 if (event_type == GDK_BUTTON_PRESS)
763 GtkTreeViewColumn * column;
767 gtk_tree_view_convert_widget_to_bin_window_coords (GTK_TREE_VIEW(
update_tree), event_x, event_y, & e_x, & e_y);
768 gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW(
update_tree), e_x, e_y, &
path, & column, & i, & j);
770 gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW(
update_tree), event_x, event_y, &
path, & column, & i, & j);
791G_MODULE_EXPORT
void on_ff_button_pressed (GtkGesture * gesture,
int n_press,
double x,
double y, gpointer data)
793 ff_button_event (
x,
y, gtk_gesture_single_get_current_button ((GtkGestureSingle * )gesture), GDK_BUTTON_PRESS, gtk_event_controller_get_current_event_time((GtkEventController *)gesture), data);
807G_MODULE_EXPORT
void on_ff_button_released (GtkGesture * gesture,
int n_press,
double x,
double y, gpointer data)
809 ff_button_event (
x,
y, gtk_gesture_single_get_current_button ((GtkGestureSingle * )gesture), GDK_BUTTON_RELEASE, gtk_event_controller_get_current_event_time((GtkEventController *)gesture), data);
823 GdkEventButton * bevent = (GdkEventButton *)event;
824 ff_button_event (event, bevent ->
x, bevent ->
y, bevent -> button, bevent -> type, bevent -> time, data);
838G_MODULE_EXPORT
void on_toggle_update (GtkCellRendererToggle * cell_renderer, gchar * string_path, gpointer data)
842 GtkTreePath *
path = gtk_tree_path_new_from_string (string_path);
844 gtk_tree_model_get (GTK_TREE_MODEL(
update_model), & iter, 7, & i, -1);
846 gtk_tree_model_get (GTK_TREE_MODEL(
update_model), & iter, 5, & str, -1);
874static gboolean update_rend (GtkTreeModel *
model, GtkTreeIter * iter, gpointer data)
879 if (gtk_tree_model_get_iter_first(
model, & upiter))
881 GtkTreePath *
path = gtk_tree_model_get_path(
model, iter);
882 str = gtk_tree_path_to_string(
path);
883 gtk_tree_path_free(
path);
884 if (g_strcmp0 (str,
"0") == 0)
return TRUE;
888 if (p > vis.
a && p < vis.
a+vis.
b+1)
return TRUE;
907 i = GPOINTER_TO_INT(data);
908 gtk_tree_model_get (mod, iter, 0, & j, -1);
910 gtk_cell_renderer_set_visible (renderer, (i == 2) ? ! k : k);
911 if ((j < 0 && i == 2) || (j>-1 && i != 7))
914 gtk_tree_model_get (mod, iter, i, & str, -1);
915 g_object_set (renderer,
"markup", str, NULL, NULL);
929 gchar * up_title[
NUCOL]={
" ",
" ",
"Property",
"Atoms",
"Species",
"parameters (1)",
"Actual parameters (1)",
"Update ?"};
930 GType up_type[
NUCOL] = {G_TYPE_INT, G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN};
934 for (i=0; i<
NUCOL; i++)
942 str = g_strdup_printf (
"%s", up_title[i]);
949 gtk_tree_model_filter_set_visible_func ((GtkTreeModelFilter *)
prop_to_up, (GtkTreeModelFilterVisibleFunc)G_CALLBACK(update_rend), GTK_TREE_VIEW(
update_tree), NULL);
955 else if (i ==
NUCOL-1)
969 gtk_tree_view_column_set_alignment (
update_col[i], 0.5);
974 for (i=0; i<9; i++)
tmp_res[i] = NULL;
977 GtkTreeSelection * update_select = gtk_tree_view_get_selection (GTK_TREE_VIEW(
update_tree));
978 gtk_tree_selection_set_mode (update_select, GTK_SELECTION_SINGLE);
980 add_widget_gesture_and_key_action (
update_tree,
"ff-button-pressed", G_CALLBACK(on_ff_button_pressed), NULL,
981 "ff-button-released", G_CALLBACK(on_ff_button_released), NULL,
982 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
1002 for (i=0; i<
NUCOL; i++)
1007 GtkWidget * scrollsets =
create_scroll (NULL, -1, -1, GTK_SHADOW_ETCHED_IN);
1008 gtk_widget_set_size_request (scrollsets, 800, 400);
1014 gchar * funits[5] ={
"Ev",
"kcal mol<sup>-1</sup>",
"kJ mol<sup>-1</sup>",
"K B<sup>-1</sup>",
"DL_POLY internal units"};
1015 gchar * str = g_strdup_printf (
"\t<b>(*)</b> Each force field element can be tuned separately, if not this <b>default</b> parameters will be used.\n"
1016 "\t<b>(1)</b> %s energy unit: %s, if required conversion to FIELD file energy unit will be performed upon selection.\n"
1017 "\t<b>(2)</b> Restraint parameters are duplicates of the non-restraint parameters.\n",
1022 str = g_strdup_printf (
"%s\t<b>(%d)</b> Urey-Bradley terms provided by the %s force field are ignored.\n", str, i,
field_acro[
tmp_field -> type]);
1027 str = g_strdup_printf (
"%s\t<b>(%d)</b> In %s, 12-6 non-bonded interactions are evaluated using:", str, i,
field_acro[
tmp_field -> type]);
1037 str = g_strdup_printf (
"%s\n<i><b>A</b></i> and <i><b>B</b></i> are calculated using Ɛ<sub>i/j</sub> and r0<sub>i/j</sub> provided by the force field parameters.",
get_this_vdw_string());
1040 str = g_strdup_printf (
"%s\nScaled 1-4 exclusion parameters, provided by the %s force field, are ignored.", str,
field_acro[
tmp_field -> type]);
1045 str = g_strdup_printf (
"%s\n<i><b>A</b></i> and <i><b>B</b></i> are calculated using A<sub>i/j</sub> and B<sub>i/j</sub> provided by the force field parameters.",
get_this_vdw_string());
1120 if (tmpat ->
id !=
tmp_fat ->
id)
1122 if (tmpat -> afid < 0)
1162 for (j=0; j<body -> na[i]; j++)
1164 k = body -> ma[i][j];
1165 l = body ->
a[i][j];
1185 gboolean update_vdw = FALSE;
1186 if (response_id == GTK_RESPONSE_APPLY)
1209 for (l=0; l<
ff_data -> npar; l++)
1223 else if (i/2 == 0 &&
tmp_fprop -> key == 1)
1310 gboolean update_this = FALSE;
1319 if ((i != 4 && i != 5) ||
tmp_field -> type < CFF91 || tmp_field -> type >
COMPASS)
1422 i = gtk_combo_box_get_active (box);
1436 for (j=0; j<
ff_data -> npar; j++)
1445 if (((prop ->
a - 7)/2 == 1 &&
tmp_fprop -> key == 1) || ((prop ->
a - 7)/2 == 1 &&
tmp_fprop -> key == 3))
1450 else if ((prop ->
a - 7)/2 == 0 &&
tmp_fprop -> key == 1)
1477 if (prop ->
a == 15)
1482 i = (prop ->
b) ? 0 : 1;
1495 eij = sqrt(
val[0]*vbl[0]);
1496 rij = (
val[1] + vbl[1]);
1497 vcl[0] = eij * pow((
double) rij, 12.0);
1498 vcl[1] = 2.0 * eij * pow((
double) rij, 6.0);
1507 vcl[0] = sqrt(
val[0]*vbl[0]);
1508 vcl[1] = sqrt(
val[1]*vbl[1]);
1533 int h, i, j, k, l, m, n;
1539 i = (f == 15) ? 2 : 1;
1555 if (g_strcmp0 (str_vdw[0], str_vdw[1]) == 0)
1570 str = g_strdup_printf (
"Atom (1 and 2) <b>%s</b>", str_vdw[j]);
1574 str = g_strdup_printf (
"Atom (%d) <b>%s</b>", j+1, str_vdw[j]);
1580 for (j=0; j<2; j++) g_free (str_vdw[j]);
1623 else if (f == 15 &&
ff_data -> atoms_z[k][0] == spec_z[j])
1634 if (g_strcmp0 (
ff_data -> info[k],
" ") != 0) str = g_strdup_printf (
"%s : %s", str,
ff_data -> info[k]);
1655 GList * cell_list = gtk_cell_layout_get_cells(GTK_CELL_LAYOUT(
ff_p_combo[j]));
1656 if (cell_list && cell_list -> data)
1658 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(
ff_p_combo[j]), cell_list -> data,
"markup", 0, NULL);
1662 gtk_combo_box_set_active (GTK_COMBO_BOX(
ff_p_combo[j]), n);
integer(kind=c_int) function chemistry()
void label(cairo_t *cr, double val, int axe, int p, project *this_proj)
draw axis label
field_struct * get_active_struct(int s, int a, int b)
retrieve field structural property
field_atom * get_active_atom(int a, int b)
retrieve field atom
field_nth_body * get_active_body(int a, int b)
retrieve field nth body interaction
field_prop * get_active_prop(struct field_prop *pr, int a)
the field molecule structural property id to retrieve
gchar * get_this_prop_string(int sid, int oid, int type, int calc)
get property name
field_object_match * tmp_res[9]
char * fvars_bond[2][FBONDS][FBONDS_P]
G_MODULE_EXPORT void on_toggle_update(GtkCellRendererToggle *cell_renderer, gchar *string_path, gpointer data)
on select field parameter toggle callback
void check_this_fprop(int fsid, int fpid, int ssid, int *fat, int *fsp)
check if the database offers parameters for a field property
void field_set_markup_and_visible(GtkTreeViewColumn *col, GtkCellRenderer *renderer, GtkTreeModel *mod, GtkTreeIter *iter, gpointer data)
field parameter set renderer markup and visibility in the parameter database selection tree model
G_MODULE_EXPORT void markup_action_renderer(GtkCellRendererCombo *cell, GtkCellEditable *editable, gchar *path_string, gpointer data)
add pango markup to a combo box inserted in the cell of a tree view
field_object_match * duplicate_match(field_object_match *old_m)
create a copy of a field match
GtkTreeViewColumn * update_col[NUCOL]
void update_result_list(int sid, field_object_match *new_match)
update avialable parameter list
gchar * felemts[MAXDATA+1]
field_object_match * up_match[9]
dint get_visible(gboolean result, gchar *the_name)
get cell renderer visibility poitner
GtkTreeStore * update_model
char * fvars_inversion[2][FINVERS][FINVERS_P]
G_MODULE_EXPORT void run_check_atom_for_updates(GtkDialog *dialog, gint response_id, gpointer data)
check for parameters in the database to be used in the force field - running the dialog
char * fvars_dihedral[2][FDIHEDRAL][FDIHEDRAL_P]
gchar * get_this_vdw_string()
get VdW formalism description string
char * fvars_angle[2][FANGLES][FANGLES_P]
int get_num_vdw_max()
Get the number of field shell interactions.
void fill_update_model(GtkTreeStore *store)
fill the parameters database tree store
int this_body_has_atom(field_nth_body *body, char *name)
check if non bonded potential has this field atom
gboolean is_this_object_a_match(int fsid, int nat, int *ffc, int *fpar)
check if object matches parameters from the database
void win_update_tree(GtkWidget *vbx)
update the parameters database tree model
GtkCellRenderer * update_renderer[NUCOL]
GtkWidget * create_field_prop_combo(int f, int is_moy)
create field parameter selection combo box
GtkWidget * param_prop_param_box(int pid)
prepare field parameter edition widgets
GtkWidget * field_key_combo
field_data * get_ff_data(int i, int j)
retrieve field property from database
void get_update_tree_data(GtkWidget *tree, gpointer data, GtkTreePath *path)
update force field parameters database tree model data
char * fvars_vdw[2][FVDW][FVDW_P]
void check_atom_for_updates()
check for parameters in the database to be used in the force field - creating the dialog
G_MODULE_EXPORT void changed_update_renderer(GtkCellRendererCombo *combo, gchar *path_string, GtkTreeIter *iter, gpointer data)
change combo box in tree model callback
gchar * get_this_prop_param(int sid, int key, int calc, int newp, float *val)
prepare field property parameters description string
field_object_match * tmp_match
GtkTreeModel * prop_to_up
G_MODULE_EXPORT gboolean on_ff_button_event(GtkWidget *widget, GdkEvent *event, gpointer data)
mouse button event on the DL-POLY force field parameters database window
field_object_match * other_match
GtkWidget * ff_p_combo[2]
GtkTreeModel * global_render_tree()
create the field property combo box model that contains the list of available parameters
void ff_button_event(GdkEvent *event, double event_x, double event_y, guint event_button, guint event_type, guint32 event_time, gpointer data)
handle mouse button event on the DL-POLY force field parameters database window GTK3
G_MODULE_EXPORT void changed_field_prop_combo(GtkComboBox *box, gpointer data)
change the field parameter selection
gchar * get_body_element_name(field_nth_body *body, int aid, int nbd)
get field body potential element name
void look_up_this_field_object(int fsid, int fpid, int ssid, int nat, int *fsp, int *fat)
look up in database for this field property
GtkWidget * create_update_tree()
create the parameters database tree model
field_nth_body * tmp_fbody
float internal_to_other[5]
gchar * fnames[2][16][21]
int struct_id(int f)
number of atoms in a structural element
gchar * parameters_info(int obj, int key, gchar **words, float *data)
prepare classical force field parameter description string
field_molecule * tmp_fmol
GtkWidget * field_assistant
classical_field * tmp_field
Variable declarations for the creation of the DL_POLY input file(s)
field_data * ff_angles[2]
char * field_acro[N_FIELDS]
float * duplicate_float(int num, float *old_val)
copy a list of float
field_object_match * field_objects_id[6]
field_object_match * tmp_obj_id
int * allocint(int val)
allocate an int * pointer
float * allocfloat(int val)
allocate a float * pointer
double string_to_double(gpointer string)
convert string to double
Global variable declarations Global convenience function declarations Global data structure defin...
GtkWidget * dialog_cancel_apply(gchar *title, GtkWidget *parent, gboolean resiz)
create a dialog modal offering a choice to apply something or not
void run_this_gtk_dialog(GtkWidget *dial, GCallback handler, gpointer data)
run a GTK (3 and 4) basic GtkDialog
GtkWidget * create_scroll(GtkWidget *box, int dimx, int dimy, int shadow)
create a scroll window
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
void combo_text_append(GtkWidget *combo, gchar *text)
append text in GtkComboBox widget
GtkWidget * destroy_this_widget(GtkWidget *widg)
destroy a GtkWidget
void add_container_child(int type, GtkWidget *widg, GtkWidget *child)
Add a GtkWidget into another GtkWidget.
GtkWidget * create_vbox(int spacing)
create a GtkBox with vertical orientation
#define MAXDATA
Number of tabs for the description of the classical force field.
void show_the_widgets(GtkWidget *widg)
show GtkWidget
void update(glwin *view)
update the rendering of the OpenGL window
Variable declarations related to the OpenGL window Function declarations related to the OpenGL wind...
Function declarations for the creation of the OpenGL window.
gchar * exact_name(gchar *name)
short cut to print string without spaces
Messaging function declarations.