aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2021-02-25 13:22:40 +0100
committerThomas White <taw@physics.org>2021-02-25 13:23:13 +0100
commit92513549075ae4acd101a291d033418ee30607a4 (patch)
treeed00a55d648ba0e0713fb986643d0381632cd22f /src
parent0c9809f34b8346c1cde01b63362f3af165758170 (diff)
GUI: Implement optional dumping of old results
Diffstat (limited to 'src')
-rw-r--r--src/gtk-util-routines.c11
-rw-r--r--src/gtk-util-routines.h1
-rw-r--r--src/gui_import.c59
-rw-r--r--src/gui_project.c26
-rw-r--r--src/gui_project.h1
5 files changed, 84 insertions, 14 deletions
diff --git a/src/gtk-util-routines.c b/src/gtk-util-routines.c
index f709921d..a5e04457 100644
--- a/src/gtk-util-routines.c
+++ b/src/gtk-util-routines.c
@@ -94,6 +94,17 @@ int i_maybe_disable(GtkWidget *toggle, GtkWidget *widget)
}
+int i_maybe_disable_and_deselect(GtkWidget *toggle, GtkWidget *widget)
+{
+ int active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toggle));
+ gtk_widget_set_sensitive(GTK_WIDGET(widget), active);
+ if ( !active ) {
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), FALSE);
+ }
+ return FALSE;
+}
+
+
void set_active(GtkWidget *tb, int active)
{
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(tb), active);
diff --git a/src/gtk-util-routines.h b/src/gtk-util-routines.h
index eb25dfc8..a6722f5a 100644
--- a/src/gtk-util-routines.h
+++ b/src/gtk-util-routines.h
@@ -36,6 +36,7 @@ extern int get_bool(GtkWidget *widget);
extern unsigned int get_uint(GtkWidget *entry);
extern float get_float(GtkWidget *entry);
extern int i_maybe_disable(GtkWidget *toggle, GtkWidget *widget);
+extern int i_maybe_disable_and_deselect(GtkWidget *toggle, GtkWidget *widget);
extern void set_active(GtkWidget *tb, int active);
extern void redraw_widget(GtkWidget *wid);
diff --git a/src/gui_import.c b/src/gui_import.c
index 8d5256c4..48289b72 100644
--- a/src/gui_import.c
+++ b/src/gui_import.c
@@ -46,6 +46,7 @@
#include "crystfelimageview.h"
#include "gui_project.h"
#include "crystfel_gui.h"
+#include "gtk-util-routines.h"
#include "version.h"
@@ -159,6 +160,7 @@ struct finddata_ctx
GtkWidget *stream_chooser;
GtkWidget *dump;
+ GtkWidget *dump_results;
};
enum import_mode
@@ -387,6 +389,9 @@ static void finddata_response_sig(GtkWidget *dialog, gint resp,
crystfel_image_view_set_image(CRYSTFEL_IMAGE_VIEW(proj->imageview),
NULL);
+ if ( gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ctx->dump_results)) ) {
+ clear_indexing_results(proj);
+ }
}
switch ( import_mode(ctx) ) {
@@ -444,19 +449,6 @@ gint import_sig(GtkWidget *widget, struct crystfelproject *proj)
gtk_container_add(GTK_CONTAINER(content_area), vbox);
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, 8.0);
- label = gtk_label_new("Geometry file:");
- gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
- gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(label), FALSE, FALSE, 2.0);
- ctx->geom_file = gtk_file_chooser_button_new("Select geometry file",
- GTK_FILE_CHOOSER_ACTION_OPEN);
- if ( proj->geom_filename != NULL ) {
- gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(ctx->geom_file),
- proj->geom_filename);
- }
- gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(ctx->geom_file), TRUE, TRUE, 2.0);
-
/* Select individual files */
hbox = gtk_hbox_new(FALSE, 0.0);
gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(hbox), FALSE, FALSE, 8.0);
@@ -545,11 +537,50 @@ gint import_sig(GtkWidget *widget, struct crystfelproject *proj)
gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(ctx->stream_chooser),
TRUE, TRUE, 2.0);
+ /* Stuff at bottom */
+ gtk_box_pack_start(GTK_BOX(vbox),
+ gtk_separator_new(GTK_ORIENTATION_HORIZONTAL),
+ FALSE, FALSE, 4.0);
+
+ /* Geometry file */
+ hbox = gtk_hbox_new(FALSE, 0.0);
+ gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(hbox), FALSE, FALSE, 8.0);
+
+ ctx->geom_file = gtk_file_chooser_button_new("Select geometry file",
+ GTK_FILE_CHOOSER_ACTION_OPEN);
+ if ( proj->geom_filename != NULL ) {
+ gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(ctx->geom_file),
+ proj->geom_filename);
+ }
+ if ( proj->dtempl == NULL ) {
+ label = gtk_label_new("Geometry file:");
+ gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
+ gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(label),
+ FALSE, FALSE, 4.0);
+ } else {
+ GtkWidget *check;
+ check = gtk_check_button_new_with_label("Replace geometry file:");
+ gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(check),
+ FALSE, FALSE, 4.0);
+ g_signal_connect(G_OBJECT(check), "toggled",
+ G_CALLBACK(i_maybe_disable), ctx->geom_file);
+ gtk_widget_set_sensitive(ctx->geom_file, FALSE);
+ }
+ gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(ctx->geom_file), TRUE, TRUE, 2.0);
+
/* Replace data toggle */
hbox = gtk_hbox_new(FALSE, 0.0);
gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(hbox), FALSE, FALSE, 8.0);
ctx->dump = gtk_check_button_new_with_label("Replace all the current data");
- gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(ctx->dump), FALSE, FALSE, 4.0);
+ gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(ctx->dump),
+ FALSE, FALSE, 4.0);
+ ctx->dump_results = gtk_check_button_new_with_label("Forget about indexing results");
+ gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(ctx->dump_results),
+ FALSE, FALSE, 4.0);
+ g_signal_connect(G_OBJECT(ctx->dump), "toggled",
+ G_CALLBACK(i_maybe_disable_and_deselect),
+ ctx->dump_results);
+ gtk_widget_set_sensitive(ctx->dump_results, FALSE);
g_signal_connect(dialog, "response",
G_CALLBACK(finddata_response_sig), ctx);
diff --git a/src/gui_project.c b/src/gui_project.c
index 29d4ceb3..3c4a5c52 100644
--- a/src/gui_project.c
+++ b/src/gui_project.c
@@ -566,6 +566,32 @@ void clear_project_files(struct crystfelproject *proj)
}
+void clear_indexing_results(struct crystfelproject *proj)
+{
+ int i;
+ for ( i=0; i<proj->n_results; i++ ) {
+ int j;
+ free(proj->results[i].name);
+ for ( j=0; j<proj->results[i].n_streams; j++ ) {
+ free(proj->results[i].streams[j]);
+ stream_index_free(proj->results[i].indices[j]);
+ }
+ free(proj->results[i].streams);
+ free(proj->results[i].indices);
+ }
+ free(proj->results);
+ proj->results = NULL;
+ proj->n_results = 0;
+
+ /* Reset the widget, as well */
+ gtk_combo_box_text_remove_all(GTK_COMBO_BOX_TEXT(proj->results_combo));
+ gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(proj->results_combo),
+ "crystfel-gui-internal",
+ "Calculations within GUI");
+ gtk_combo_box_set_active(GTK_COMBO_BOX(proj->results_combo), 0);
+}
+
+
void add_file_to_project(struct crystfelproject *proj,
const char *filename, const char *event)
{
diff --git a/src/gui_project.h b/src/gui_project.h
index 2289ffff..e08e20a7 100644
--- a/src/gui_project.h
+++ b/src/gui_project.h
@@ -339,6 +339,7 @@ extern void add_file_to_project(struct crystfelproject *proj,
const char *event);
extern void clear_project_files(struct crystfelproject *proj);
+extern void clear_indexing_results(struct crystfelproject *proj);
extern int add_indexing_result(struct crystfelproject *proj,
char *name,