diff options
author | Thomas White <taw@physics.org> | 2020-10-29 17:30:13 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2020-10-29 17:30:13 +0100 |
commit | 4e35c922741bee4312957a42d2d0cc16d4c7ad78 (patch) | |
tree | 4f2ffcc87a32178d94053334895cee8519a7a965 | |
parent | 4029011f2097165537b5425f20012d57fdf7ef9c (diff) |
Set all options in CrystFELMergeOpts
-rw-r--r-- | src/crystfelmergeopts.c | 161 | ||||
-rw-r--r-- | src/crystfelmergeopts.h | 44 | ||||
-rw-r--r-- | src/crystfelsymmetryselector.c | 4 | ||||
-rw-r--r-- | src/gui_merge.c | 22 |
4 files changed, 219 insertions, 12 deletions
diff --git a/src/crystfelmergeopts.c b/src/crystfelmergeopts.c index 5153888f..0162ed21 100644 --- a/src/crystfelmergeopts.c +++ b/src/crystfelmergeopts.c @@ -157,8 +157,8 @@ static GtkWidget *merge_parameters(CrystFELMergeOpts *mo) hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8); gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(hbox), FALSE, FALSE, 0); - label = gtk_label_new("Detector saturation value:"); - gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(label), + mo->use_max_adu = gtk_check_button_new_with_label("Detector saturation cutoff:"); + gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(mo->use_max_adu), FALSE, FALSE, 0); mo->max_adu = gtk_entry_new(); gtk_entry_set_width_chars(GTK_ENTRY(mo->max_adu), 4); @@ -249,10 +249,153 @@ GtkWidget *crystfel_merge_opts_new() } -//int crystfel_merge_opts_get_multi_lattice(CrystFELMergeOpts *opts) -//{ -// return gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(opts->multi)); -//} +static int set_if(GtkWidget *combo, const char *a, const char *new_id) +{ + if ( strcmp(a, new_id) == 0 ) { + gtk_combo_box_set_active_id(GTK_COMBO_BOX(combo), + new_id); + return 1; + } + + return 0; +} + + +static void set_int(GtkWidget *entry, int val) +{ + char tmp[64]; + snprintf(tmp, 63, "%i", val); + gtk_entry_set_text(GTK_ENTRY(entry), tmp); +} + + +static void set_float(GtkWidget *entry, float val) +{ + char tmp[64]; + snprintf(tmp, 63, "%f", val); + gtk_entry_set_text(GTK_ENTRY(entry), tmp); +} + + +void crystfel_merge_opts_set_model(CrystFELMergeOpts *opts, + const char *model) +{ + int done = 0; + done += set_if(opts->model_combo, model, "process_hkl"); + done += set_if(opts->model_combo, model, "unity"); + done += set_if(opts->model_combo, model, "xsphere"); + done += set_if(opts->model_combo, model, "offset"); + done += set_if(opts->model_combo, model, "ggpm"); + + if ( done == 0 ) { + ERROR("Unrecognised model '%s'\n", model); + } +} + + +void crystfel_merge_opts_set_polarisation(CrystFELMergeOpts *opts, + const char *polar) +{ + int done = 0; + done += set_if(opts->polarisation, polar, "horiz"); + done += set_if(opts->polarisation, polar, "vert"); + done += set_if(opts->polarisation, polar, "none"); + done += set_if(opts->polarisation, polar, "horiz50"); + + if ( done == 0 ) { + ERROR("Unrecognised polarisation '%s'\n", polar); + } +} + + +void crystfel_merge_opts_set_symmetry(CrystFELMergeOpts *opts, + const char *sym) +{ + crystfel_symmetry_selector_set_group_symbol(CRYSTFEL_SYMMETRY_SELECTOR(opts->symmetry), + sym); +} + + +void crystfel_merge_opts_set_scale(CrystFELMergeOpts *opts, + int scale) +{ + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(opts->scale), + scale); +} + + +void crystfel_merge_opts_set_bscale(CrystFELMergeOpts *opts, + int bscale) +{ + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(opts->bscale), + bscale); +} + + +void crystfel_merge_opts_set_postref(CrystFELMergeOpts *opts, + int postref) +{ + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(opts->postref), + postref); +} + + +void crystfel_merge_opts_set_niter(CrystFELMergeOpts *opts, + int niter) +{ + set_int(opts->niter, niter); +} + + +void crystfel_merge_opts_set_deltacchalf(CrystFELMergeOpts *opts, + int deltacchalf) +{ + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(opts->deltacchalf), + deltacchalf); +} + + +void crystfel_merge_opts_set_min_measurements(CrystFELMergeOpts *opts, + int min_measurements) +{ + set_int(opts->min_measurements, min_measurements); +} + + +void crystfel_merge_opts_set_max_adu(CrystFELMergeOpts *opts, + float max_adu) +{ + set_float(opts->max_adu, max_adu); +} + + +void crystfel_merge_opts_set_custom_split(CrystFELMergeOpts *opts, + const char *custom_split_file) +{ + if ( custom_split_file != NULL ) { + gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(opts->custom_split_file), + custom_split_file); + } + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(opts->custom_split), + (custom_split_file != NULL)); +} + + +void crystfel_merge_opts_set_twin_sym(CrystFELMergeOpts *opts, + const char *twin_sym) +{ + crystfel_symmetry_selector_set_group_symbol(CRYSTFEL_SYMMETRY_SELECTOR(opts->detwin_sym), + twin_sym); +} + + +void crystfel_merge_opts_set_min_res(CrystFELMergeOpts *opts, + float min_res) +{ + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(opts->min_res), + !isinf(min_res)); + set_float(opts->min_res_val, min_res); +} float crystfel_merge_opts_get_push_res(CrystFELMergeOpts *opts) @@ -279,11 +422,7 @@ float crystfel_merge_opts_get_push_res(CrystFELMergeOpts *opts) void crystfel_merge_opts_set_push_res(CrystFELMergeOpts *mo, float push_res) { - char tmp[64]; - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mo->limit_res), !isinf(push_res)); - - snprintf(tmp, 63, "%f", push_res); - gtk_entry_set_text(GTK_ENTRY(mo->push_res), tmp); + set_float(mo->push_res, push_res); } diff --git a/src/crystfelmergeopts.h b/src/crystfelmergeopts.h index aa2ed164..4346a71e 100644 --- a/src/crystfelmergeopts.h +++ b/src/crystfelmergeopts.h @@ -63,6 +63,7 @@ struct _crystfelmergeopts GtkWidget *polarisation; GtkWidget *deltacchalf; GtkWidget *min_measurements; + GtkWidget *use_max_adu; GtkWidget *max_adu; GtkWidget *custom_split; GtkWidget *custom_split_file; @@ -85,6 +86,49 @@ typedef struct _crystfelmergeoptsclass CrystFELMergeOptsClass; extern GType crystfel_merge_opts_get_type(void); extern GtkWidget *crystfel_merge_opts_new(void); +extern void crystfel_merge_opts_set_model(CrystFELMergeOpts *opts, + const char *model); +extern void crystfel_merge_opts_set_symmetry(CrystFELMergeOpts *opts, + const char *sym); +extern void crystfel_merge_opts_set_scale(CrystFELMergeOpts *opts, + int scale); +extern void crystfel_merge_opts_set_bscale(CrystFELMergeOpts *opts, + int bscale); +extern void crystfel_merge_opts_set_postref(CrystFELMergeOpts *opts, + int postref); +extern void crystfel_merge_opts_set_niter(CrystFELMergeOpts *opts, + int niter); +extern void crystfel_merge_opts_set_polarisation(CrystFELMergeOpts *opts, + const char *polar); +extern void crystfel_merge_opts_set_deltacchalf(CrystFELMergeOpts *opts, + int deltacchalf); +extern void crystfel_merge_opts_set_min_measurements(CrystFELMergeOpts *opts, + int min_measurements); +extern void crystfel_merge_opts_set_max_adu(CrystFELMergeOpts *opts, + float max_adu); +extern void crystfel_merge_opts_set_custom_split(CrystFELMergeOpts *opts, + const char *custom_split_file); +extern void crystfel_merge_opts_set_twin_sym(CrystFELMergeOpts *opts, + const char *twin_sym); +extern void crystfel_merge_opts_set_min_res(CrystFELMergeOpts *opts, + float min_res); +extern void crystfel_merge_opts_set_push_res(CrystFELMergeOpts *opts, + float push_res); + +extern float crystfel_merge_opts_get_push_res(CrystFELMergeOpts *opts); +extern const char *crystfel_merge_opts_get_model(CrystFELMergeOpts *opts); +extern const char *crystfel_merge_opts_get_symmetry(CrystFELMergeOpts *opts); +extern int crystfel_merge_opts_get_scale(CrystFELMergeOpts *opts); +extern int crystfel_merge_opts_get_bscale(CrystFELMergeOpts *opts); +extern int crystfel_merge_opts_get_postref(CrystFELMergeOpts *opts); +extern int crystfel_merge_opts_get_niter(CrystFELMergeOpts *opts); +extern const char *crystfel_merge_opts_get_polarisation(CrystFELMergeOpts *opts); +extern int crystfel_merge_opts_get_deltacchalf(CrystFELMergeOpts *opts); +extern int crystfel_merge_opts_get_min_measurements(CrystFELMergeOpts *opts); +extern float crystfel_merge_opts_get_max_adu(CrystFELMergeOpts *opts); +extern const char *crystfel_merge_opts_get_custom_split(CrystFELMergeOpts *opts); +extern const char *crystfel_merge_opts_get_twin_sym(CrystFELMergeOpts *opts); +extern float crystfel_merge_opts_get_min_res(CrystFELMergeOpts *opts); extern float crystfel_merge_opts_get_push_res(CrystFELMergeOpts *opts); #endif /* CRYSTFELMERGEOPTS_H */ diff --git a/src/crystfelsymmetryselector.c b/src/crystfelsymmetryselector.c index e8b1d0d6..219e4da6 100644 --- a/src/crystfelsymmetryselector.c +++ b/src/crystfelsymmetryselector.c @@ -81,6 +81,8 @@ char *crystfel_symmetry_selector_get_group_symbol(CrystFELSymmetrySelector *sel) int crystfel_symmetry_selector_set_group_symbol(CrystFELSymmetrySelector *sel, const char *pg_symbol) { - gtk_entry_set_text(GTK_ENTRY(sel->entry), pg_symbol); + if ( pg_symbol != NULL ) { + gtk_entry_set_text(GTK_ENTRY(sel->entry), pg_symbol); + } return 0; } diff --git a/src/gui_merge.c b/src/gui_merge.c index b3320ac0..a320c331 100644 --- a/src/gui_merge.c +++ b/src/gui_merge.c @@ -68,6 +68,26 @@ static void merging_response_sig(GtkWidget *dialog, gint resp, } +static void set_merging_opts(struct merging_params *opts, + CrystFELMergeOpts *mo) +{ + crystfel_merge_opts_set_model(mo, opts->model); + crystfel_merge_opts_set_symmetry(mo, opts->symmetry); + crystfel_merge_opts_set_scale(mo, opts->scale); + crystfel_merge_opts_set_bscale(mo, opts->bscale); + crystfel_merge_opts_set_postref(mo, opts->postref); + crystfel_merge_opts_set_niter(mo, opts->niter); + crystfel_merge_opts_set_polarisation(mo, opts->polarisation); + crystfel_merge_opts_set_deltacchalf(mo, opts->deltacchalf); + crystfel_merge_opts_set_min_measurements(mo, opts->min_measurements); + crystfel_merge_opts_set_max_adu(mo, opts->max_adu); + crystfel_merge_opts_set_custom_split(mo, opts->custom_split); + crystfel_merge_opts_set_twin_sym(mo, opts->twin_sym); + crystfel_merge_opts_set_min_res(mo, opts->min_res); + crystfel_merge_opts_set_push_res(mo, opts->push_res); +} + + static GtkWidget *make_merging_job_opts(struct crystfelproject *proj, struct new_merging_job_params *njp) { @@ -229,6 +249,8 @@ gint merge_sig(GtkWidget *widget, struct crystfelproject *proj) gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(notebook), FALSE, FALSE, 8.0); + set_merging_opts(&proj->merging_params, CRYSTFEL_MERGE_OPTS(notebook)); + job_page = make_merging_job_opts(proj, njp); gtk_notebook_prepend_page(GTK_NOTEBOOK(notebook), job_page, |