From 7f2c2fb5a158b313804775ba431f0131914db1b6 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Wed, 24 Aug 2022 16:27:41 +0200 Subject: GUI: Add options for detector-shift and peakogram-stream Fixes: https://gitlab.desy.de/thomas.white/crystfel/-/issues/63 --- src/crystfel_gui.c | 88 +++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 80 insertions(+), 8 deletions(-) (limited to 'src/crystfel_gui.c') diff --git a/src/crystfel_gui.c b/src/crystfel_gui.c index 2881728b..a82f305e 100644 --- a/src/crystfel_gui.c +++ b/src/crystfel_gui.c @@ -434,19 +434,84 @@ static gint save_sig(GtkWidget *widget, struct crystfelproject *proj) } -static gint rescan_sig(GtkWidget *widget, struct crystfelproject *proj) +static struct gui_indexing_result *current_result(struct crystfelproject *proj) { const char *results_name; + struct gui_indexing_result *res; results_name = gtk_combo_box_get_active_id(GTK_COMBO_BOX(proj->results_combo)); - if ( strcmp(results_name, "crystfel-gui-internal") != 0 ) { - struct gui_indexing_result *res; - res = find_indexing_result_by_name(proj, results_name); - if ( res != NULL ) { - update_result_index(res); - } else { - ERROR("Couldn't find result '%s'\n", results_name); + if ( strcmp(results_name, "crystfel-gui-internal") == 0 ) return NULL; + + res = find_indexing_result_by_name(proj, results_name); + if ( res == NULL ) { + ERROR("Couldn't find result '%s'\n", results_name); + } + + return res; +} + + +static gint rescan_sig(GtkWidget *widget, struct crystfelproject *proj) +{ + struct gui_indexing_result *res = current_result(proj); + if ( res != NULL ) { + update_result_index(res); + } + return FALSE; +} + + +static gint detector_shift_sig(GtkWidget *widget, struct crystfelproject *proj) +{ + struct gui_indexing_result *res = current_result(proj); + if ( res != NULL ) { + GError *error = NULL; + const gchar *args[64]; + GSubprocess *sp; + int i; + args[0] = "detector-shift"; + args[1] = "--"; + for ( i=0; in_streams, 60); i++ ) { + args[2+i] = res->streams[i]; } + args[2+res->n_streams] = NULL; + + sp = g_subprocess_newv(args, G_SUBPROCESS_FLAGS_NONE, &error); + if ( sp == NULL ) { + ERROR("Failed to invoke detector-shift: %s\n", + error->message); + g_error_free(error); + } + } else { + ERROR("Select indexing result first!\n"); + } + return FALSE; +} + + +static gint peakogram_sig(GtkWidget *widget, struct crystfelproject *proj) +{ + struct gui_indexing_result *res = current_result(proj); + if ( res != NULL ) { + GError *error = NULL; + const gchar *args[128]; + GSubprocess *sp; + int i; + args[0] = "peakogram-stream"; + for ( i=0; in_streams, 60); i++ ) { + args[1+2*i] = "-i"; + args[2+2*i] = res->streams[i]; + } + args[1+2*res->n_streams] = NULL; + + sp = g_subprocess_newv(args, G_SUBPROCESS_FLAGS_NONE, &error); + if ( sp == NULL ) { + ERROR("Failed to invoke peakogram-stream: %s\n", + error->message); + g_error_free(error); + } + } else { + ERROR("Select indexing result first!\n"); } return FALSE; } @@ -745,6 +810,9 @@ static void add_menu_bar(struct crystfelproject *proj, GtkWidget *vbox) " " " " " " + " " + " " + " " "" "" " " @@ -768,6 +836,10 @@ static void add_menu_bar(struct crystfelproject *proj, GtkWidget *vbox) G_CALLBACK(rescan_sig) }, { "JumpFrameAction", NULL, "Jump to frame", NULL, NULL, G_CALLBACK(goto_frame_sig) }, + { "DetectorShiftAction", NULL, "Check detector shift", NULL, NULL, + G_CALLBACK(detector_shift_sig) }, + { "PeakogramAction", NULL, "Check detector saturation (peakogram)", NULL, NULL, + G_CALLBACK(peakogram_sig) }, { "HelpAction", NULL, "_Help", NULL, NULL, NULL }, { "AboutAction", GTK_STOCK_ABOUT, "_About", NULL, NULL, -- cgit v1.2.3