diff options
-rw-r--r-- | src/crystfel_gui.c | 88 |
1 files changed, 80 insertions, 8 deletions
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; i<MIN(res->n_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; i<MIN(res->n_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) " <menuitem name=\"rescanonchange\" action=\"RescanOnChangeAction\" />" " <menuitem name=\"rescan\" action=\"RescanAction\" />" " <menuitem name=\"jumpframe\" action=\"JumpFrameAction\" />" + " <separator />" + " <menuitem name=\"detectorshift\" action=\"DetectorShiftAction\" />" + " <menuitem name=\"peakogram\" action=\"PeakogramAction\" />" "</menu>" "<menu name=\"help\" action=\"HelpAction\">" " <menuitem name=\"about\" action=\"AboutAction\" />" @@ -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, |