aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/displaywindow.c19
-rw-r--r--src/intensities.c49
-rw-r--r--src/intensities.h1
3 files changed, 68 insertions, 1 deletions
diff --git a/src/displaywindow.c b/src/displaywindow.c
index ea03a22..215d5e2 100644
--- a/src/displaywindow.c
+++ b/src/displaywindow.c
@@ -1149,8 +1149,21 @@ static gint displaywindow_refinestack(GtkWidget *widget, DisplayWindow *dw) {
}
static gint displaywindow_extract(GtkWidget *widget, DisplayWindow *dw) {
+
+ GtkWidget *d;
+
intensities_extract(dw->ctx);
+ dw->mode = DW_MEASURED;
displaywindow_update(dw);
+
+ d = gtk_ui_manager_get_widget(dw->ui, "/ui/displaywindow/file/savehkl");
+ gtk_widget_set_sensitive(d, TRUE);
+
+ return 0;
+}
+
+static gint displaywindow_savehkl(GtkWidget *widget, DisplayWindow *dw) {
+ intensities_save(dw->ctx);
return 0;
}
@@ -1159,7 +1172,8 @@ static void displaywindow_addmenubar(DisplayWindow *dw) {
GtkActionEntry entries[] = {
{ "FileAction", NULL, "_File", NULL, NULL, NULL },
- { "SaveCacheAction", GTK_STOCK_SAVE, "Save Image Analysis to _Cache", NULL, NULL, G_CALLBACK(displaywindow_savecache) },
+ { "SaveCacheAction", "filesave", "Save Image Analysis to _Cache", NULL, NULL, G_CALLBACK(displaywindow_savecache) },
+ { "SaveHKLAction", GTK_STOCK_SAVE, "Save Reflections", NULL, NULL, G_CALLBACK(displaywindow_savehkl) },
{ "CloseAction", GTK_STOCK_QUIT, "_Quit", NULL, NULL, G_CALLBACK(displaywindow_close) },
{ "ViewAction", NULL, "_View", NULL, NULL, NULL },
@@ -1318,6 +1332,7 @@ DisplayWindow *displaywindow_open(ControlContext *ctx) {
GdkGLConfig *glconfig;
DisplayWindow *dw;
GtkWidget *notebook;
+ GtkWidget *d;
dw = malloc(sizeof(DisplayWindow));
@@ -1384,6 +1399,8 @@ DisplayWindow *displaywindow_open(ControlContext *ctx) {
displaywindow_enable_cell_functions(dw, FALSE);
displaywindow_update_dirax(ctx, dw);
+ d = gtk_ui_manager_get_widget(dw->ui, "/ui/displaywindow/file/savehkl");
+ gtk_widget_set_sensitive(d, FALSE);
gtk_window_set_default_size(GTK_WINDOW(dw->window), 840, 800);
gtk_widget_show_all(dw->window);
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);
+
+}
+
diff --git a/src/intensities.h b/src/intensities.h
index 88d385b..8ebea64 100644
--- a/src/intensities.h
+++ b/src/intensities.h
@@ -19,6 +19,7 @@
#include "control.h"
extern void intensities_extract(ControlContext *ctx);
+extern void intensities_save(ControlContext *ctx);
#endif /* INTENSITIES_H */