aboutsummaryrefslogtreecommitdiff
path: root/src/intensities.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/intensities.c')
-rw-r--r--src/intensities.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/intensities.c b/src/intensities.c
index 96c7ad1..8c02592 100644
--- a/src/intensities.c
+++ b/src/intensities.c
@@ -17,6 +17,7 @@
#include "reflections.h"
#include "image.h"
#include "reproject.h"
+#include "displaywindow.h"
/* Extract integrated reflection intensities by estimating the spike function
* based on the observed intensity and the calculated excitation error from
@@ -107,3 +108,51 @@ void intensities_extract(ControlContext *ctx) {
}
+static int intensities_do_save(ReflectionList *integrated, const char *filename) {
+
+ FILE *fh;
+ Reflection *reflection;
+
+ fh = fopen(filename, "w");
+ reflection = integrated->reflections;
+ while ( reflection ) {
+ fprintf(fh, "%3i %3i %3i %12.8f\n", reflection->h, reflection->k, reflection->l, reflection->intensity);
+ reflection = reflection->next;
+ }
+ fclose(fh);
+
+ return 0;
+
+}
+
+static gint intensities_save_response(GtkWidget *widget, gint response, ControlContext *ctx) {
+
+ if ( response == GTK_RESPONSE_ACCEPT ) {
+ char *filename;
+ filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(widget));
+ if ( intensities_do_save(ctx->integrated, filename) ) {
+ displaywindow_error("Failed to save cache file.", ctx->dw);
+ }
+ g_free(filename);
+ }
+
+ gtk_widget_destroy(widget);
+
+ return 0;
+
+}
+
+void intensities_save(ControlContext *ctx) {
+
+ GtkWidget *save;
+
+ save = gtk_file_chooser_dialog_new("Save Reflections to File", GTK_WINDOW(ctx->dw->window),
+ GTK_FILE_CHOOSER_ACTION_SAVE,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
+ NULL);
+ g_signal_connect(G_OBJECT(save), "response", G_CALLBACK(intensities_save_response), ctx);
+ gtk_widget_show_all(save);
+
+}
+