aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2020-08-20 11:17:49 +0200
committerThomas White <taw@physics.org>2020-08-20 11:17:49 +0200
commit2ffe338d663cfc1c2cdb42a63a1e50f769a508c0 (patch)
tree495d0fdc27511bd1bf0b3a4467801cc24c692a0e /src
parentd9e011c9e3f877ed95482fd54a549c065ff9b8be (diff)
GUI: Implement automatic indexing method selection
Diffstat (limited to 'src')
-rw-r--r--src/crystfelindexingopts.c14
-rw-r--r--src/gui_index.c28
2 files changed, 34 insertions, 8 deletions
diff --git a/src/crystfelindexingopts.c b/src/crystfelindexingopts.c
index 23866786..5f29a97c 100644
--- a/src/crystfelindexingopts.c
+++ b/src/crystfelindexingopts.c
@@ -428,6 +428,8 @@ char *crystfel_indexing_opts_get_cell_file(CrystFELIndexingOpts *opts)
}
+/* NULL means "automatic".
+ * "none" means "no indexing" */
char *crystfel_indexing_opts_get_indexing_method_string(CrystFELIndexingOpts *opts)
{
GtkTreePath *path;
@@ -435,6 +437,10 @@ char *crystfel_indexing_opts_get_indexing_method_string(CrystFELIndexingOpts *op
char indm_str[1024];
int first = 1;
+ if ( gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(opts->auto_indm)) ) {
+ return NULL;
+ }
+
path = gtk_tree_path_new_from_string("0");
gtk_tree_model_get_iter(GTK_TREE_MODEL(opts->indm_store),
&iter, path);
@@ -470,6 +476,9 @@ char *crystfel_indexing_opts_get_indexing_method_string(CrystFELIndexingOpts *op
} while ( gtk_tree_model_iter_next(GTK_TREE_MODEL(opts->indm_store),
&iter) );
+ if ( indm_str[0] == '\0' ) {
+ strcpy(indm_str, "none");
+ }
return strdup(indm_str);
}
@@ -658,10 +667,7 @@ void crystfel_indexing_opts_set_indexing_method_string(CrystFELIndexingOpts *opt
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(opts->auto_indm),
(indm_str == NULL));
- if ( indm_str == NULL ) {
- unset_all_methods(opts);
- return;
- }
+ if ( indm_str == NULL ) return;
methods = parse_indexing_methods(indm_str, &n);
if ( methods == NULL ) {
diff --git a/src/gui_index.c b/src/gui_index.c
index 8215ba8a..86ecab35 100644
--- a/src/gui_index.c
+++ b/src/gui_index.c
@@ -208,8 +208,13 @@ static void run_indexing_once(struct crystfelproject *proj)
IndexingPrivate *ipriv;
UnitCell *cell;
IntegrationMethod int_method;
+ char *methods;
int i;
int err;
+ TakeTwoOptions *taketwoopts;
+ XGandalfOptions *xgandalf_opts;
+ PinkIndexerOptions *pinkIndexer_opts;
+ FelixOptions *felix_opts;
if ( proj->indexing_params.cell_file != NULL ) {
cell = load_cell_from_file(proj->indexing_params.cell_file);
@@ -217,12 +222,27 @@ static void run_indexing_once(struct crystfelproject *proj)
cell = NULL;
}
- ipriv = setup_indexing(proj->indexing_params.indexing_methods,
- cell,
- proj->dtempl,
+ if ( proj->indexing_params.indexing_methods == NULL ) {
+ methods = detect_indexing_methods(cell);
+ STATUS("Auto-detected indexng methods: %s\n",
+ methods);
+ } else {
+ methods = strdup(proj->indexing_params.indexing_methods);
+ }
+
+ /* Get default options for the indexing methods.
+ * The GUI current does not allow them to be changed */
+ default_method_options(&taketwoopts,
+ &xgandalf_opts,
+ &pinkIndexer_opts,
+ &felix_opts);
+
+ ipriv = setup_indexing(methods, cell, proj->dtempl,
proj->indexing_params.tols,
indexing_flags(&proj->indexing_params),
- NULL, NULL, NULL, NULL);
+ taketwoopts, xgandalf_opts,
+ pinkIndexer_opts, felix_opts);
+ free(methods);
index_pattern(proj->cur_image, ipriv);