From ecc033af6344fb2c5d1770628cd438057fd80ddd Mon Sep 17 00:00:00 2001 From: Thomas White Date: Wed, 10 Feb 2021 17:18:46 +0100 Subject: GUI: Sketch out data export window --- src/crystfel_gui.c | 3 +- src/gui_export.c | 188 +++++++++++++++++++++++++++++++++++++++++++++++++++++ src/gui_export.h | 39 +++++++++++ src/gui_project.c | 3 + src/gui_project.h | 3 + 5 files changed, 235 insertions(+), 1 deletion(-) create mode 100644 src/gui_export.c create mode 100644 src/gui_export.h (limited to 'src') diff --git a/src/crystfel_gui.c b/src/crystfel_gui.c index 09011830..e4151b43 100644 --- a/src/crystfel_gui.c +++ b/src/crystfel_gui.c @@ -49,6 +49,7 @@ #include "gui_index.h" #include "gui_merge.h" #include "gui_fom.h" +#include "gui_export.h" #include "gui_project.h" #include "version.h" @@ -862,7 +863,7 @@ static void add_task_buttons(GtkWidget *vbox, struct crystfelproject *proj) add_button(vbox, "Figures of merit", "trophy-gold", G_CALLBACK(fom_sig), proj); add_button(vbox, "Export data", "document-send", - G_CALLBACK(NULL), proj); + G_CALLBACK(export_sig), proj); } diff --git a/src/gui_export.c b/src/gui_export.c new file mode 100644 index 00000000..ef79d809 --- /dev/null +++ b/src/gui_export.c @@ -0,0 +1,188 @@ +/* + * gui_export.c + * + * Export data from CrystFEL GUI + * + * Copyright © 2021 Deutsches Elektronen-Synchrotron DESY, + * a research centre of the Helmholtz Association. + * + * Authors: + * 2021 Thomas White + * + * This file is part of CrystFEL. + * + * CrystFEL is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * CrystFEL is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with CrystFEL. If not, see . + * + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "gui_project.h" +#include "crystfel_gui.h" +#include "gtk-util-routines.h" + + +struct export_window +{ + struct crystfelproject *proj; + GtkWidget *cell_chooser; + GtkWidget *limit_res; + GtkWidget *min_res; + GtkWidget *max_res; + GtkWidget *dataset; + GtkWidget *format; +}; + + +static void export_response_sig(GtkWidget *dialog, gint resp, + struct export_window *f) +{ + if ( resp != GTK_RESPONSE_APPLY ) { + gtk_widget_destroy(dialog); + return; + } +} + + +static void cell_file_clear_sig(GtkButton *buton, + struct export_window *win) +{ + gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(win->cell_chooser), + "(none)"); +} + + +gint export_sig(GtkWidget *widget, struct crystfelproject *proj) +{ + GtkWidget *dialog; + GtkWidget *content_area; + GtkWidget *vbox; + GtkWidget *hbox; + GtkWidget *label; + GtkWidget *button; + char tmp[64]; + struct export_window *win; + + win = malloc(sizeof(struct export_window)); + if ( win == NULL ) return 0; + + win->proj = proj; + + dialog = gtk_dialog_new_with_buttons("Export data", + GTK_WINDOW(proj->window), + GTK_DIALOG_DESTROY_WITH_PARENT, + "Close", GTK_RESPONSE_CLOSE, + "Export", GTK_RESPONSE_OK, + NULL); + + g_signal_connect(G_OBJECT(dialog), "response", + G_CALLBACK(export_response_sig), + win); + + vbox = gtk_vbox_new(FALSE, 0.0); + content_area = gtk_dialog_get_content_area(GTK_DIALOG(dialog)); + gtk_container_add(GTK_CONTAINER(content_area), vbox); + gtk_container_set_border_width(GTK_CONTAINER(vbox), 4); + gtk_container_set_border_width(GTK_CONTAINER(content_area), 8); + + hbox = gtk_hbox_new(FALSE, 0.0); + gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(hbox), + FALSE, FALSE, 4.0); + label = gtk_label_new("Results to export:"); + gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(label), + FALSE, FALSE, 4.0); + win->dataset = gtk_combo_box_text_new(); + gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(win->dataset), + FALSE, FALSE, 4.0); + + hbox = gtk_hbox_new(FALSE, 0.0); + gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(hbox), + FALSE, FALSE, 4.0); + label = gtk_label_new("Format"); + gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(label), + FALSE, FALSE, 4.0); + win->format = gtk_combo_box_text_new(); + gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(win->format), + FALSE, FALSE, 4.0); + gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(win->format), "mtz", + "MTZ, plain"); + gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(win->format), "mtz-bij", + "MTZ, Bijvoet pairs together"); + gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(win->format), "xscale", + "XSCALE"); + + hbox = gtk_hbox_new(FALSE, 0.0); + gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(hbox), + FALSE, FALSE, 4.0); + win->limit_res = gtk_check_button_new_with_label("Restrict resolution range:"); + gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(win->limit_res), + FALSE, FALSE, 4.0); + win->min_res = gtk_entry_new(); + gtk_entry_set_width_chars(GTK_ENTRY(win->min_res), 4); + snprintf(tmp, 64, "%.2f", proj->export_res_min); + gtk_entry_set_text(GTK_ENTRY(win->min_res), tmp); + gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(win->min_res), + FALSE, FALSE, 4.0); + label = gtk_label_new("to"); + gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(label), + FALSE, FALSE, 4.0); + win->max_res = gtk_entry_new(); + gtk_entry_set_width_chars(GTK_ENTRY(win->max_res), 4); + snprintf(tmp, 64, "%.2f", proj->export_res_max); + gtk_entry_set_text(GTK_ENTRY(win->max_res), tmp); + gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(win->max_res), + FALSE, FALSE, 4.0); + label = gtk_label_new("Å"); + gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(label), + FALSE, FALSE, 4.0); + + hbox = gtk_hbox_new(FALSE, 0.0); + gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(hbox), + FALSE, FALSE, 4.0); + label = gtk_label_new("Unit cell file:"); + gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(label), + FALSE, FALSE, 4.0); + win->cell_chooser = gtk_file_chooser_button_new("Unit cell file", + GTK_FILE_CHOOSER_ACTION_OPEN); + gtk_file_chooser_set_local_only(GTK_FILE_CHOOSER(win->cell_chooser), + TRUE); + gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(win->cell_chooser), + proj->fom_cell_filename); + gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(win->cell_chooser), + FALSE, FALSE, 4.0); + button = gtk_button_new_from_icon_name("edit-clear", + GTK_ICON_SIZE_BUTTON); + g_signal_connect(G_OBJECT(button), "clicked", + G_CALLBACK(cell_file_clear_sig), win); + gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(button), + FALSE, FALSE, 4.0); + + gtk_dialog_set_default_response(GTK_DIALOG(dialog), + GTK_RESPONSE_CLOSE); + gtk_widget_show_all(dialog); + + return FALSE; +} diff --git a/src/gui_export.h b/src/gui_export.h new file mode 100644 index 00000000..481d5d5b --- /dev/null +++ b/src/gui_export.h @@ -0,0 +1,39 @@ +/* + * gui_export.h + * + * Export data from CrystFEL GUI + * + * Copyright © 2021 Deutsches Elektronen-Synchrotron DESY, + * a research centre of the Helmholtz Association. + * + * Authors: + * 2021 Thomas White + * + * This file is part of CrystFEL. + * + * CrystFEL is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * CrystFEL is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with CrystFEL. If not, see . + * + */ + +#ifndef GUI_EXPORT_H +#define GUI_EXPORT_H + +#include + +#include "gui_project.h" + +extern gint export_sig(GtkWidget *widget, + struct crystfelproject *proj); + +#endif diff --git a/src/gui_project.c b/src/gui_project.c index 6c9c5e5f..153fb55f 100644 --- a/src/gui_project.c +++ b/src/gui_project.c @@ -1072,6 +1072,9 @@ void default_project(struct crystfelproject *proj) proj->fom_min_snr = -INFINITY; proj->fom_min_meas = 1; proj->fom_cell_filename = NULL; + + proj->export_res_min = INFINITY; + proj->export_res_max = 0.0; } diff --git a/src/gui_project.h b/src/gui_project.h index b0431c04..4d2e75c3 100644 --- a/src/gui_project.h +++ b/src/gui_project.h @@ -274,6 +274,9 @@ struct crystfelproject { double fom_min_snr; int fom_min_meas; char *fom_cell_filename; + + double export_res_min; + double export_res_max; }; extern enum match_type_id decode_matchtype(const char *type_id); -- cgit v1.2.3