aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2020-08-14 16:48:03 +0200
committerThomas White <taw@physics.org>2020-08-14 16:48:03 +0200
commit3df62e76acbd0c7455c786eb07499c228cbe8457 (patch)
tree5d2b3e140e42f51c5f7f82044e7902aabb606b03 /src
parent1323191a533b420bb9119960f41bfcf0175a18ad (diff)
Hook up (almost all) indexing parameters
Diffstat (limited to 'src')
-rw-r--r--src/crystfelindexingopts.c388
-rw-r--r--src/crystfelindexingopts.h64
-rw-r--r--src/gui_index.c64
-rw-r--r--src/gui_project.c118
-rw-r--r--src/gui_project.h21
5 files changed, 598 insertions, 57 deletions
diff --git a/src/crystfelindexingopts.c b/src/crystfelindexingopts.c
index 6d13c8d3..67770146 100644
--- a/src/crystfelindexingopts.c
+++ b/src/crystfelindexingopts.c
@@ -36,6 +36,10 @@
#include <assert.h>
#include <gtk/gtk.h>
#include <glib-object.h>
+#include <errno.h>
+#include <math.h>
+
+#include <integration.h>
#include "crystfelindexingopts.h"
@@ -68,8 +72,8 @@ static void add_method(GtkListStore *store, const char *name)
}
-static void add_tol(GtkGrid *grid, const char *spec_t,
- const char *unit_t, gint left, gint top)
+static GtkWidget *add_tol(GtkGrid *grid, const char *spec_t,
+ const char *unit_t, gint left, gint top)
{
GtkWidget *spec;
GtkWidget *entry;
@@ -86,6 +90,8 @@ static void add_tol(GtkGrid *grid, const char *spec_t,
unit = gtk_label_new(unit_t);
g_object_set(G_OBJECT(unit), "margin-right", 12, NULL);
gtk_grid_attach(grid, unit, left+2, top, 1, 1);
+
+ return entry;
}
@@ -98,12 +104,12 @@ static GtkWidget *make_tolerances(CrystFELIndexingOpts *io)
gtk_grid_set_column_spacing(GTK_GRID(grid), 4);
gtk_container_set_border_width(GTK_CONTAINER(grid), 6);
- add_tol(GTK_GRID(grid), "a", "%", 0, 0);
- add_tol(GTK_GRID(grid), "b", "%", 4, 0);
- add_tol(GTK_GRID(grid), "c", "%", 8, 0);
- add_tol(GTK_GRID(grid), "α", "°", 0, 1);
- add_tol(GTK_GRID(grid), "β", "°", 4, 1);
- add_tol(GTK_GRID(grid), "ɣ", "°", 8, 1);
+ io->tols[0] = add_tol(GTK_GRID(grid), "a", "%", 0, 0);
+ io->tols[1] = add_tol(GTK_GRID(grid), "b", "%", 4, 0);
+ io->tols[2] = add_tol(GTK_GRID(grid), "c", "%", 8, 0);
+ io->tols[3] = add_tol(GTK_GRID(grid), "α", "°", 0, 1);
+ io->tols[4] = add_tol(GTK_GRID(grid), "β", "°", 4, 1);
+ io->tols[5] = add_tol(GTK_GRID(grid), "ɣ", "°", 8, 1);
return grid;
}
@@ -170,9 +176,6 @@ static GtkWidget *indexing_parameters(CrystFELIndexingOpts *io)
GtkWidget *box;
GtkWidget *hbox;
GtkWidget *label;
- GtkWidget *entry;
- GtkWidget *check;
- GtkWidget *filechooser;
GtkWidget *expander;
GtkWidget *frame;
GtkWidget *indexing_methods;
@@ -185,17 +188,19 @@ static GtkWidget *indexing_parameters(CrystFELIndexingOpts *io)
hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8);
gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(hbox),
FALSE, FALSE, 0);
- check = gtk_check_button_new_with_label("Use unit cell");
- gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(check),
+ io->use_cell = gtk_check_button_new_with_label("Use unit cell");
+ gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(io->use_cell),
FALSE, FALSE, 0);
- filechooser = gtk_file_chooser_button_new("Unit cell file",
- GTK_FILE_CHOOSER_ACTION_OPEN);
- gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(filechooser),
+ io->cell_chooser = gtk_file_chooser_button_new("Unit cell file",
+ GTK_FILE_CHOOSER_ACTION_OPEN);
+ gtk_file_chooser_set_local_only(GTK_FILE_CHOOSER(io->cell_chooser),
+ TRUE);
+ gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(io->cell_chooser),
FALSE, FALSE, 0);
/* Indexing method selector */
- check = gtk_check_button_new_with_label("Automatically choose the indexing methods");
- gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(check),
+ io->auto_indm = gtk_check_button_new_with_label("Automatically choose the indexing methods");
+ gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(io->auto_indm),
FALSE, FALSE, 0);
expander = gtk_expander_new("Select indexing methods and prior information");
frame = gtk_frame_new(NULL);
@@ -210,28 +215,28 @@ static GtkWidget *indexing_parameters(CrystFELIndexingOpts *io)
gtk_container_set_border_width(GTK_CONTAINER(frame), 6);
/* --multi */
- check = gtk_check_button_new_with_label("Attempt to find multiple lattices per frame");
- gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(check),
+ io->multi = gtk_check_button_new_with_label("Attempt to find multiple lattices per frame");
+ gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(io->multi),
FALSE, FALSE, 0);
/* --no-refine (NB inverse) */
- check = gtk_check_button_new_with_label("Refine the indexing solution");
- gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(check),
+ io->refine = gtk_check_button_new_with_label("Refine the indexing solution");
+ gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(io->refine),
FALSE, FALSE, 0);
/* --no-retry (NB inverse) */
- check = gtk_check_button_new_with_label("Retry indexing if unsuccessful");
- gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(check),
+ io->retry = gtk_check_button_new_with_label("Retry indexing if unsuccessful");
+ gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(io->retry),
FALSE, FALSE, 0);
/* --no-check-peaks (NB inverse) */
- check = gtk_check_button_new_with_label("Check indexing solutions match peaks");
- gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(check),
+ io->check_peaks = gtk_check_button_new_with_label("Check indexing solutions match peaks");
+ gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(io->check_peaks),
FALSE, FALSE, 0);
/* --no-check-cell (NB inverse) and --tolerance */
- check = gtk_check_button_new_with_label("Check indexing solutions against reference cell");
- gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(check),
+ io->check_cell = gtk_check_button_new_with_label("Check indexing solutions against reference cell");
+ gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(io->check_cell),
FALSE, FALSE, 0);
expander = gtk_expander_new("Unit cell tolerances");
gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(expander),
@@ -243,12 +248,12 @@ static GtkWidget *indexing_parameters(CrystFELIndexingOpts *io)
hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8);
gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(hbox),
FALSE, FALSE, 0);
- check = gtk_check_button_new_with_label("Skip frames with fewer than");
- gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(check),
+ io->enable_hitfind = gtk_check_button_new_with_label("Skip frames with fewer than");
+ gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(io->enable_hitfind),
FALSE, FALSE, 0);
- entry = gtk_entry_new();
- gtk_entry_set_width_chars(GTK_ENTRY(entry), 4);
- gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(entry),
+ io->ignore_fewer_peaks = gtk_entry_new();
+ gtk_entry_set_width_chars(GTK_ENTRY(io->ignore_fewer_peaks), 4);
+ gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(io->ignore_fewer_peaks),
FALSE, FALSE, 0);
label = gtk_label_new("peaks");
gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(label),
@@ -261,10 +266,7 @@ static GtkWidget *indexing_parameters(CrystFELIndexingOpts *io)
static GtkWidget *integration_parameters(CrystFELIndexingOpts *io)
{
GtkWidget *box;
- GtkWidget *combo;
- GtkWidget *check;
GtkWidget *label;
- GtkWidget *entry;
GtkWidget *hbox;
box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 8);
@@ -277,36 +279,36 @@ static GtkWidget *integration_parameters(CrystFELIndexingOpts *io)
label = gtk_label_new("Integration method:");
gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(label),
FALSE, FALSE, 0);
- combo = gtk_combo_box_text_new();
- gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(combo),
+ io->integration_combo = gtk_combo_box_text_new();
+ gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(io->integration_combo),
FALSE, FALSE, 0);
- gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(combo), "none",
+ gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(io->integration_combo), "none",
"No integration (only spot prediction)");
- gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(combo), "rings",
+ gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(io->integration_combo), "rings",
"Ring summation");
- gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(combo), "prof2d",
+ gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(io->integration_combo), "prof2d",
"Two dimensional profile fitting");
/* -cen */
- check = gtk_check_button_new_with_label("Center integration boxes on observed reflections");
- gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(check),
+ io->centering = gtk_check_button_new_with_label("Center integration boxes on observed reflections");
+ gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(io->centering),
FALSE, FALSE, 0);
/* --overpredict */
- check = gtk_check_button_new_with_label("Over-predict reflections (for post-refinement)");
- gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(check),
+ io->overpredict = gtk_check_button_new_with_label("Over-predict reflections (for post-refinement)");
+ gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(io->overpredict),
FALSE, FALSE, 0);
/* --push-res */
hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8);
gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(hbox),
FALSE, FALSE, 0);
- check = gtk_check_button_new_with_label("Limit prediction to");
- gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(check),
+ io->limit_res = gtk_check_button_new_with_label("Limit prediction to");
+ gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(io->limit_res),
FALSE, FALSE, 0);
- entry = gtk_entry_new();
- gtk_entry_set_width_chars(GTK_ENTRY(entry), 4);
- gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(entry),
+ io->push_res = gtk_entry_new();
+ gtk_entry_set_width_chars(GTK_ENTRY(io->push_res), 4);
+ gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(io->push_res),
FALSE, FALSE, 0);
label = gtk_label_new("nm-1 above apparent resolution limit");
gtk_label_set_markup(GTK_LABEL(label),
@@ -338,3 +340,289 @@ GtkWidget *crystfel_indexing_opts_new()
gtk_widget_show_all(GTK_WIDGET(io));
return GTK_WIDGET(io);
}
+
+
+char *crystfel_indexing_opts_get_cell_file(CrystFELIndexingOpts *opts)
+{
+ if ( gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(opts->use_cell)) ) {
+ return gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(opts->cell_chooser));
+ } else {
+ return NULL;
+ }
+}
+
+
+char *crystfel_indexing_opts_get_indexing_method_string(CrystFELIndexingOpts *opts)
+{
+ return strdup("dirax"); /* FIXME! */
+}
+
+
+int crystfel_indexing_opts_get_multi_lattice(CrystFELIndexingOpts *opts)
+{
+ return gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(opts->multi));
+}
+
+
+int crystfel_indexing_opts_get_refine(CrystFELIndexingOpts *opts)
+{
+ return gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(opts->refine));
+}
+
+
+int crystfel_indexing_opts_get_retry(CrystFELIndexingOpts *opts)
+{
+ return gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(opts->retry));
+}
+
+
+int crystfel_indexing_opts_get_peak_check(CrystFELIndexingOpts *opts)
+{
+ return gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(opts->check_peaks));
+}
+
+
+int crystfel_indexing_opts_get_cell_check(CrystFELIndexingOpts *opts)
+{
+ return gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(opts->check_cell));
+}
+
+
+void crystfel_indexing_opts_get_tolerances(CrystFELIndexingOpts *opts,
+ float *tols)
+{
+ int i;
+ for ( i=0; i<3; i++ ) {
+ float tol;
+ char *rval;
+ const gchar *text = gtk_entry_get_text(GTK_ENTRY(opts->tols[i]));
+ errno = 0;
+ tol = strtod(text, &rval);
+ if ( *rval != '\0' ) {
+ printf("Invalid tolerance '%s'\n", text);
+ } else {
+ tols[i] = tol / 100.0;
+ }
+ }
+ for ( i=3; i<6; i++ ) {
+ float tol;
+ char *rval;
+ const gchar *text = gtk_entry_get_text(GTK_ENTRY(opts->tols[i]));
+ errno = 0;
+ tol = strtod(text, &rval);
+ if ( *rval != '\0' ) {
+ printf("Invalid tolerance '%s'\n", text);
+ } else {
+ tols[i] = deg2rad(tol);
+ }
+ }
+}
+
+
+int crystfel_indexing_opts_get_min_peaks(CrystFELIndexingOpts *opts)
+{
+ if ( gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(opts->enable_hitfind)) ) {
+ const gchar *text;
+ int fewer_peaks;
+ char *rval;
+ text = gtk_entry_get_text(GTK_ENTRY(opts->ignore_fewer_peaks));
+ errno = 0;
+ fewer_peaks = strtod(text, &rval);
+ if ( *rval != '\0' ) {
+ printf("Invalid value for minimum number of peaks (%s)\n",
+ rval);
+ return 0;
+ }
+ /* Subtract one because the dialog box says to skip
+ * frames with "FEWER THAN" this number */
+ return fewer_peaks - 1;
+ } else {
+ return 0;
+ }
+}
+
+
+char *crystfel_indexing_opts_get_integration_method_string(CrystFELIndexingOpts *opts)
+{
+ const gchar *id;
+ char method[64];
+
+ id = gtk_combo_box_get_active_id(GTK_COMBO_BOX(opts->integration_combo));
+ if ( id == NULL ) return strdup("none");
+
+ strcpy(method, id);
+ if ( gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(opts->centering)) ) {
+ strcat(method, "-cen");
+ }
+
+ return strdup(method);
+}
+
+
+int crystfel_indexing_opts_get_overpredict(CrystFELIndexingOpts *opts)
+{
+ return gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(opts->overpredict));
+}
+
+
+float crystfel_indexing_opts_get_push_res(CrystFELIndexingOpts *opts)
+{
+ if ( gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(opts->limit_res)) ) {
+ return INFINITY;
+ } else {
+ const gchar *text;
+ float push_res;
+ char *rval;
+ text = gtk_entry_get_text(GTK_ENTRY(opts->ignore_fewer_peaks));
+ errno = 0;
+ push_res = strtof(text, &rval);
+ if ( *rval != '\0' ) {
+ printf("Invalid value for push-res (%s)\n",
+ rval);
+ return INFINITY;
+ }
+ return push_res;
+ }
+}
+
+
+void crystfel_indexing_opts_set_cell_file(CrystFELIndexingOpts *opts,
+ const char *cell_file)
+{
+ if ( cell_file != NULL ) {
+ gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(opts->cell_chooser),
+ cell_file);
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(opts->use_cell),
+ TRUE);
+ } else {
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(opts->use_cell),
+ FALSE);
+ }
+}
+
+
+static const char *integration_method_id(IntegrationMethod meth)
+{
+ switch ( meth ) {
+ case INTEGRATION_NONE : return "none";
+ case INTEGRATION_RINGS : return "rings";
+ case INTEGRATION_PROF2D : return "prof2d";
+ default : return "none";
+ }
+}
+
+
+void crystfel_indexing_opts_set_indexing_method_string(CrystFELIndexingOpts *opts,
+ const char *indm_str)
+{
+ /* FIXME */
+}
+
+
+void crystfel_indexing_opts_set_multi_lattice(CrystFELIndexingOpts *opts,
+ int multi)
+{
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(opts->multi),
+ multi);
+}
+
+
+void crystfel_indexing_opts_set_refine(CrystFELIndexingOpts *opts,
+ int refine)
+{
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(opts->refine),
+ refine);
+}
+
+
+void crystfel_indexing_opts_set_retry(CrystFELIndexingOpts *opts,
+ int retry)
+{
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(opts->retry),
+ retry);
+}
+
+
+void crystfel_indexing_opts_set_peak_check(CrystFELIndexingOpts *opts,
+ int peak_check)
+
+{
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(opts->check_peaks),
+ peak_check);
+}
+
+
+void crystfel_indexing_opts_set_cell_check(CrystFELIndexingOpts *opts,
+ int cell_check)
+{
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(opts->check_cell),
+ cell_check);
+}
+
+
+void crystfel_indexing_opts_set_tolerances(CrystFELIndexingOpts *opts,
+ float *tols)
+{
+ int i;
+ for ( i=0; i<3; i++ ) {
+ char tmp[64];
+ snprintf(tmp, 63, "%f", tols[i]*100.0);
+ gtk_entry_set_text(GTK_ENTRY(opts->tols[i]), tmp);
+ }
+ for ( i=3; i<6; i++ ) {
+ char tmp[64];
+ snprintf(tmp, 63, "%f", rad2deg(tols[i]));
+ gtk_entry_set_text(GTK_ENTRY(opts->tols[i]), tmp);
+ }
+}
+
+
+void crystfel_indexing_opts_set_min_peaks(CrystFELIndexingOpts *opts,
+ int min_peaks)
+{
+ char tmp[64];
+
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(opts->enable_hitfind),
+ (min_peaks > 0));
+
+ /* Plus one because dialog says skip when "fewer than" X peaks */
+ snprintf(tmp, 63, "%i", min_peaks+1);
+ gtk_entry_set_text(GTK_ENTRY(opts->ignore_fewer_peaks), tmp);
+}
+
+
+void crystfel_indexing_opts_set_integration_method_string(CrystFELIndexingOpts *opts,
+ const char *integr_str)
+{
+ IntegrationMethod meth;
+ int err;
+
+ meth = integration_method(integr_str, &err);
+ if ( !err ) {
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(opts->centering),
+ meth & INTEGRATION_CENTER);
+ gtk_combo_box_set_active_id(GTK_COMBO_BOX(opts->integration_combo),
+ integration_method_id(meth & INTEGRATION_METHOD_MASK));
+ }
+}
+
+
+void crystfel_indexing_opts_set_overpredict(CrystFELIndexingOpts *opts,
+ int overpredict)
+{
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(opts->overpredict),
+ overpredict);
+}
+
+
+void crystfel_indexing_opts_set_push_res(CrystFELIndexingOpts *opts,
+ float push_res)
+{
+ char tmp[64];
+
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(opts->limit_res),
+ !isinf(push_res));
+
+ snprintf(tmp, 63, "%f", push_res);
+ gtk_entry_set_text(GTK_ENTRY(opts->push_res), tmp);
+}
diff --git a/src/crystfelindexingopts.h b/src/crystfelindexingopts.h
index 2af709e0..7f7a251a 100644
--- a/src/crystfelindexingopts.h
+++ b/src/crystfelindexingopts.h
@@ -51,16 +51,32 @@
struct _crystfelindexingopts
{
- GtkNotebook parent_instance;
+ GtkNotebook parent_instance;
/*< private >*/
- int dummy;
+ GtkWidget *use_cell;
+ GtkWidget *cell_chooser;
+ GtkWidget *auto_indm;
+ /* FIXME: indexing algo choice */
+ GtkWidget *multi;
+ GtkWidget *refine;
+ GtkWidget *retry;
+ GtkWidget *check_peaks;
+ GtkWidget *check_cell;
+ GtkWidget *tols[6];
+ GtkWidget *enable_hitfind;
+ GtkWidget *ignore_fewer_peaks;
+
+ GtkWidget *integration_combo;
+ GtkWidget *centering;
+ GtkWidget *overpredict;
+ GtkWidget *limit_res;
+ GtkWidget *push_res;
};
struct _crystfelindexingoptsclass
{
GtkNotebookClass parent_class;
- int dummy;
};
typedef struct _crystfelindexingopts CrystFELIndexingOpts;
@@ -69,4 +85,46 @@ typedef struct _crystfelindexingoptsclass CrystFELIndexingOptsClass;
extern GType crystfel_indexing_opts_get_type(void);
extern GtkWidget *crystfel_indexing_opts_new(void);
+extern char *crystfel_indexing_opts_get_cell_file(CrystFELIndexingOpts *opts);
+extern char *crystfel_indexing_opts_get_indexing_method_string(CrystFELIndexingOpts *opts);
+extern int crystfel_indexing_opts_get_multi_lattice(CrystFELIndexingOpts *opts);
+extern int crystfel_indexing_opts_get_refine(CrystFELIndexingOpts *opts);
+extern int crystfel_indexing_opts_get_retry(CrystFELIndexingOpts *opts);
+extern int crystfel_indexing_opts_get_peak_check(CrystFELIndexingOpts *opts);
+extern int crystfel_indexing_opts_get_cell_check(CrystFELIndexingOpts *opts);
+extern void crystfel_indexing_opts_get_tolerances(CrystFELIndexingOpts *opts,
+ float *tols);
+extern int crystfel_indexing_opts_get_min_peaks(CrystFELIndexingOpts *opts);
+
+extern char *crystfel_indexing_opts_get_integration_method_string(CrystFELIndexingOpts *opts);
+extern int crystfel_indexing_opts_get_overpredict(CrystFELIndexingOpts *opts);
+extern float crystfel_indexing_opts_get_push_res(CrystFELIndexingOpts *opts);
+
+
+extern void crystfel_indexing_opts_set_cell_file(CrystFELIndexingOpts *opts,
+ const char *cell_file);
+extern void crystfel_indexing_opts_set_indexing_method_string(CrystFELIndexingOpts *opts,
+ const char *indm_str);
+extern void crystfel_indexing_opts_set_multi_lattice(CrystFELIndexingOpts *opts,
+ int multi);
+extern void crystfel_indexing_opts_set_refine(CrystFELIndexingOpts *opts,
+ int refine);
+extern void crystfel_indexing_opts_set_retry(CrystFELIndexingOpts *opts,
+ int retry);
+extern void crystfel_indexing_opts_set_peak_check(CrystFELIndexingOpts *opts,
+ int peak_check);
+extern void crystfel_indexing_opts_set_cell_check(CrystFELIndexingOpts *opts,
+ int cell_check);
+extern void crystfel_indexing_opts_set_tolerances(CrystFELIndexingOpts *opts,
+ float *tols);
+extern void crystfel_indexing_opts_set_min_peaks(CrystFELIndexingOpts *opts,
+ int min_peaks);
+
+extern void crystfel_indexing_opts_set_integration_method_string(CrystFELIndexingOpts *opts,
+ const char *integr_str);
+extern void crystfel_indexing_opts_set_overpredict(CrystFELIndexingOpts *opts,
+ int overpredict);
+extern void crystfel_indexing_opts_set_push_res(CrystFELIndexingOpts *opts,
+ float push_res);
+
#endif /* CRYSTFELINDEXINGOPTS_H */
diff --git a/src/gui_index.c b/src/gui_index.c
index fff453ba..edc54a3b 100644
--- a/src/gui_index.c
+++ b/src/gui_index.c
@@ -72,6 +72,7 @@ static void index_all_response_sig(GtkWidget *dialog, gint resp,
}
gtk_widget_destroy(dialog);
+ proj->indexing_opts = NULL;
}
@@ -110,6 +111,8 @@ gint index_all_sig(GtkWidget *widget, struct crystfelproject *proj)
GtkWidget *vbox;
GtkWidget *indexing_opts;
+ if ( proj->indexing_opts != NULL ) return FALSE;
+
dialog = gtk_dialog_new_with_buttons("Index all frames",
GTK_WINDOW(proj->window),
GTK_DIALOG_DESTROY_WITH_PARENT,
@@ -141,14 +144,63 @@ gint index_all_sig(GtkWidget *widget, struct crystfelproject *proj)
}
+static void set_indexing_opts(struct crystfelproject *proj,
+ CrystFELIndexingOpts *opts)
+{
+ /* Indexing */
+ crystfel_indexing_opts_set_cell_file(opts, proj->indexing_params.cell_file);
+ crystfel_indexing_opts_set_indexing_method_string(opts, proj->indexing_params.indexing_methods);
+ crystfel_indexing_opts_set_multi_lattice(opts, proj->indexing_params.multi);
+ crystfel_indexing_opts_set_refine(opts, !proj->indexing_params.no_refine);
+ crystfel_indexing_opts_set_retry(opts, !proj->indexing_params.no_retry);
+ crystfel_indexing_opts_set_peak_check(opts, !proj->indexing_params.no_peak_check);
+ crystfel_indexing_opts_set_cell_check(opts, !proj->indexing_params.no_cell_check);
+ crystfel_indexing_opts_set_tolerances(opts, proj->indexing_params.tols);
+ crystfel_indexing_opts_set_min_peaks(opts, proj->indexing_params.min_peaks);
+
+ /* Integration */
+ crystfel_indexing_opts_set_integration_method_string(opts, proj->indexing_params.integration_method);
+ crystfel_indexing_opts_set_overpredict(opts, proj->indexing_params.overpredict);
+ crystfel_indexing_opts_set_push_res(opts, proj->indexing_params.push_res);
+}
+
+
+static void get_indexing_opts(struct crystfelproject *proj,
+ CrystFELIndexingOpts *opts)
+{
+ /* Indexing */
+ proj->indexing_params.cell_file = crystfel_indexing_opts_get_cell_file(opts);
+ proj->indexing_params.indexing_methods = crystfel_indexing_opts_get_indexing_method_string(opts);
+ proj->indexing_params.multi = crystfel_indexing_opts_get_multi_lattice(opts);
+ proj->indexing_params.no_refine = !crystfel_indexing_opts_get_refine(opts);
+ proj->indexing_params.no_retry = !crystfel_indexing_opts_get_retry(opts);
+ proj->indexing_params.no_peak_check = !crystfel_indexing_opts_get_peak_check(opts);
+ proj->indexing_params.no_cell_check = !crystfel_indexing_opts_get_cell_check(opts);
+ proj->indexing_params.min_peaks = crystfel_indexing_opts_get_min_peaks(opts);
+
+ /* Integration */
+ proj->indexing_params.integration_method = crystfel_indexing_opts_get_integration_method_string(opts);
+ proj->indexing_params.overpredict = crystfel_indexing_opts_get_overpredict(opts);
+ proj->indexing_params.push_res = crystfel_indexing_opts_get_push_res(opts);
+}
+
+
+static void run_indexing_once(struct crystfelproject *proj)
+{
+}
+
+
static void index_one_response_sig(GtkWidget *dialog, gint resp,
struct crystfelproject *proj)
{
if ( resp == GTK_RESPONSE_OK ) {
- STATUS("OK!\n");
+ get_indexing_opts(proj,
+ CRYSTFEL_INDEXING_OPTS(proj->indexing_opts));
+ run_indexing_once(proj);
}
gtk_widget_destroy(dialog);
+ proj->indexing_opts = NULL;
}
@@ -157,7 +209,8 @@ gint index_one_sig(GtkWidget *widget, struct crystfelproject *proj)
GtkWidget *dialog;
GtkWidget *content_area;
GtkWidget *vbox;
- GtkWidget *indexing_opts;
+
+ if ( proj->indexing_opts != NULL ) return FALSE;
dialog = gtk_dialog_new_with_buttons("Index one frame",
GTK_WINDOW(proj->window),
@@ -174,9 +227,12 @@ gint index_one_sig(GtkWidget *widget, struct crystfelproject *proj)
gtk_container_add(GTK_CONTAINER(content_area), vbox);
gtk_container_set_border_width(GTK_CONTAINER(content_area), 8);
- indexing_opts = crystfel_indexing_opts_new();
- gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(indexing_opts),
+ proj->indexing_opts = crystfel_indexing_opts_new();
+ gtk_box_pack_start(GTK_BOX(vbox),
+ GTK_WIDGET(proj->indexing_opts),
FALSE, FALSE, 8.0);
+ set_indexing_opts(proj,
+ CRYSTFEL_INDEXING_OPTS(proj->indexing_opts));
gtk_dialog_set_default_response(GTK_DIALOG(dialog),
GTK_RESPONSE_OK);
diff --git a/src/gui_project.c b/src/gui_project.c
index c8868486..c10d9a99 100644
--- a/src/gui_project.c
+++ b/src/gui_project.c
@@ -128,6 +128,24 @@ int match_filename(const char *fn, enum match_type_id mt)
}
+static void parse_tols(const char *text, float *tols)
+{
+ int r;
+
+ r = sscanf(text, "%f,%f,%f,%f,%f,%f",
+ &tols[0], &tols[1], &tols[2],
+ &tols[3], &tols[4], &tols[5]);
+
+ if ( r != 6 ) {
+ STATUS("Invalid tolerances '%s'\n", text);
+ } else {
+ int i;
+ for ( i=0; i<3; i++ ) tols[i] /= 100.0;
+ for ( i=3; i<6; i++ ) tols[i] = deg2rad(tols[i]);
+ }
+}
+
+
static void handle_var(const char *key, const char *val,
struct crystfelproject *proj)
{
@@ -199,6 +217,54 @@ static void handle_var(const char *key, const char *val,
proj->peak_search_params.revalidate = parse_int(val);
}
+ if ( strcmp(key, "indexing.cell_file") == 0 ) {
+ proj->indexing_params.cell_file = strdup(val);
+ }
+
+ if ( strcmp(key, "indexing.methods") == 0 ) {
+ proj->indexing_params.indexing_methods = strdup(val);
+ }
+
+ if ( strcmp(key, "indexing.multi_lattice") == 0 ) {
+ proj->indexing_params.multi = parse_int(val);
+ }
+
+ if ( strcmp(key, "indexing.no_refine") == 0 ) {
+ proj->indexing_params.no_refine = parse_int(val);
+ }
+
+ if ( strcmp(key, "indexing.no_retry") == 0 ) {
+ proj->indexing_params.no_retry = parse_int(val);
+ }
+
+ if ( strcmp(key, "indexing.no_peak_check") == 0 ) {
+ proj->indexing_params.no_peak_check = parse_int(val);
+ }
+
+ if ( strcmp(key, "indexing.no_cell_check") == 0 ) {
+ proj->indexing_params.no_cell_check = parse_int(val);
+ }
+
+ if ( strcmp(key, "indexing.cell_tolerance") == 0 ) {
+ parse_tols(val, proj->indexing_params.tols);
+ }
+
+ if ( strcmp(key, "indexing.min_peaks") == 0 ) {
+ proj->indexing_params.min_peaks = parse_int(val);
+ }
+
+ if ( strcmp(key, "integration.method") == 0 ) {
+ proj->indexing_params.integration_method = strdup(val);
+ }
+
+ if ( strcmp(key, "integration.overpredict") == 0 ) {
+ proj->indexing_params.overpredict = parse_int(val);
+ }
+
+ if ( strcmp(key, "integration.push_res") == 0 ) {
+ proj->indexing_params.push_res = parse_float(val);
+ }
+
if ( strcmp(key, "show_peaks") == 0 ) {
proj->show_peaks = parse_int(val);
}
@@ -386,6 +452,37 @@ int save_project(struct crystfelproject *proj)
fprintf(fh, "peak_search_params.revalidate %i\n",
proj->peak_search_params.revalidate);
+ fprintf(fh, "indexing.cell_file %s\n",
+ proj->indexing_params.cell_file);
+ fprintf(fh, "indexing.methods %s\n",
+ proj->indexing_params.indexing_methods);
+ fprintf(fh, "indexing.multi_lattice %i\n",
+ proj->indexing_params.multi);
+ fprintf(fh, "indexing.no_refine %i\n",
+ proj->indexing_params.no_refine);
+ fprintf(fh, "indexing.no_retry %i\n",
+ proj->indexing_params.no_retry);
+ fprintf(fh, "indexing.no_peak_check %i\n",
+ proj->indexing_params.no_peak_check);
+ fprintf(fh, "indexing.no_cell_check %i\n",
+ proj->indexing_params.no_cell_check);
+ fprintf(fh, "indexing.cell_tolerance %f,%f,%f,%f,%f,%f\n",
+ proj->indexing_params.tols[0]*100.0,
+ proj->indexing_params.tols[1]*100.0,
+ proj->indexing_params.tols[2]*100.0,
+ rad2deg(proj->indexing_params.tols[3]),
+ rad2deg(proj->indexing_params.tols[4]),
+ rad2deg(proj->indexing_params.tols[5]));
+ fprintf(fh, "indexing.min_peaks %i\n",
+ proj->indexing_params.min_peaks);
+
+ fprintf(fh, "integration.method %s\n",
+ proj->indexing_params.integration_method);
+ fprintf(fh, "integration.overpredict %i\n",
+ proj->indexing_params.overpredict);
+ fprintf(fh, "integration.push_res %f\n",
+ proj->indexing_params.push_res);
+
fprintf(fh, "show_peaks %i\n", proj->show_peaks);
fprintf(fh, "show_refls %i\n", proj->show_refls);
fprintf(fh, "backend %s\n", proj->backend->name);
@@ -424,10 +521,12 @@ void default_project(struct crystfelproject *proj)
proj->stream = NULL;
proj->dtempl = NULL;
proj->cur_image = NULL;
+ proj->indexing_opts = NULL;
/* Default parameter values */
proj->show_peaks = 0;
proj->show_refls = 0;
+
proj->peak_search_params.method = PEAK_ZAEF;
proj->peak_search_params.threshold = 800.0;
proj->peak_search_params.min_sq_gradient = 100000;
@@ -446,5 +545,24 @@ void default_project(struct crystfelproject *proj)
proj->peak_search_params.pk_out = 5.0;
proj->peak_search_params.half_pixel_shift = 1;
proj->peak_search_params.revalidate = 1;
+
+ proj->indexing_params.cell_file = NULL;
+ proj->indexing_params.indexing_methods = NULL;
+ proj->indexing_params.multi = 1;
+ proj->indexing_params.no_refine = 0;
+ proj->indexing_params.no_retry = 0;
+ proj->indexing_params.no_peak_check = 0;
+ proj->indexing_params.no_cell_check = 0;
+ proj->indexing_params.tols[0] = 5.0;
+ proj->indexing_params.tols[1] = 5.0;
+ proj->indexing_params.tols[2] = 5.0;
+ proj->indexing_params.tols[3] = deg2rad(1.5);
+ proj->indexing_params.tols[4] = deg2rad(1.5);
+ proj->indexing_params.tols[5] = deg2rad(1.5);
+ proj->indexing_params.min_peaks = 0;
+ proj->indexing_params.integration_method = strdup("rings");
+ proj->indexing_params.overpredict = 0;
+ proj->indexing_params.push_res = INFINITY;
+
proj->backend = backend_local;
}
diff --git a/src/gui_project.h b/src/gui_project.h
index bd4904fd..313a748a 100644
--- a/src/gui_project.h
+++ b/src/gui_project.h
@@ -64,6 +64,25 @@ struct peak_params {
int revalidate;
};
+struct index_params {
+
+ /* Indexing */
+ char *cell_file;
+ char *indexing_methods;
+ int multi;
+ int no_refine;
+ int no_retry;
+ int no_peak_check;
+ int no_cell_check;
+ float tols[6];
+ int min_peaks;
+
+ /* Integration */
+ char *integration_method;
+ int overpredict;
+ float push_res;
+};
+
struct crystfelproject {
GtkWidget *window;
@@ -98,6 +117,8 @@ struct crystfelproject {
struct peak_params peak_search_params;
int show_refls;
+ struct index_params indexing_params;
+ GtkWidget *indexing_opts;
GtkWidget *type_combo;
GtkWidget *peak_vbox; /* Box for peak search parameter widgets */