aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortaw27 <taw27@bf6ca9ba-c028-0410-8290-897cf20841d1>2007-10-21 18:00:52 +0000
committertaw27 <taw27@bf6ca9ba-c028-0410-8290-897cf20841d1>2007-10-21 18:00:52 +0000
commit32e59363873d27c79e63fdd72076b87806f4caa1 (patch)
treea49e15c18555fe2a19ad9ef37e85cd3c2ef95dd9 /src
parent13a940f8a878b0a31b1fed38e2c71f483f1c7710 (diff)
Allow the tilt axis to be redefined
git-svn-id: svn://cook.msm.cam.ac.uk:745/diff-tomo/dtr@165 bf6ca9ba-c028-0410-8290-897cf20841d1
Diffstat (limited to 'src')
-rw-r--r--src/control.c1
-rw-r--r--src/displaywindow.c60
-rw-r--r--src/displaywindow.h4
-rw-r--r--src/mapping.c42
-rw-r--r--src/mapping.h1
-rw-r--r--src/reflections.c8
6 files changed, 103 insertions, 13 deletions
diff --git a/src/control.c b/src/control.c
index e581b06..6efae0f 100644
--- a/src/control.c
+++ b/src/control.c
@@ -28,6 +28,7 @@ ControlContext *control_ctx_new() {
ctx->cell = NULL;
ctx->dirax = NULL;
ctx->images = image_list_new();
+ ctx->reflectionlist = NULL;
return ctx;
diff --git a/src/displaywindow.c b/src/displaywindow.c
index e9aaa7d..5a5f25a 100644
--- a/src/displaywindow.c
+++ b/src/displaywindow.c
@@ -33,6 +33,7 @@
#include "dirax.h"
#include "reproject.h"
#include "cache.h"
+#include "mapping.h"
static void displaywindow_gl_set_ortho(DisplayWindow *dw, GLfloat w, GLfloat h) {
@@ -907,6 +908,64 @@ static gint displaywindow_savecache(GtkWidget *widget, DisplayWindow *dw) {
}
+static gint displaywindow_setaxis_response(GtkWidget *widget, gint response, DisplayWindow *dw) {
+
+ if ( response == GTK_RESPONSE_OK ) {
+
+ const char *offset;
+ float off;
+
+ offset = gtk_entry_get_text(GTK_ENTRY(dw->tiltaxis_entry));
+ sscanf(offset, "%f", &off);
+
+ mapping_adjust_axis(dw->ctx, off);
+
+ }
+
+ gtk_widget_destroy(widget);
+
+ return 0;
+
+}
+
+static gint displaywindow_setaxis(GtkWidget *widget, DisplayWindow *dw) {
+
+ GtkWidget *vbox;
+ GtkWidget *hbox;
+ GtkWidget *table;
+ GtkWidget *label;
+
+ dw->tiltaxis_window = gtk_dialog_new_with_buttons("Set Tilt Axis Position", GTK_WINDOW(dw->window),
+ GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_CANCEL, GTK_RESPONSE_CLOSE, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL);
+
+ vbox = gtk_vbox_new(FALSE, 0);
+ hbox = gtk_hbox_new(TRUE, 0);
+ gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dw->tiltaxis_window)->vbox), GTK_WIDGET(hbox), FALSE, FALSE, 7);
+ gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(vbox), FALSE, FALSE, 5);
+
+ table = gtk_table_new(1, 3, FALSE);
+ gtk_table_set_row_spacings(GTK_TABLE(table), 5);
+ gtk_table_set_col_spacings(GTK_TABLE(table), 5);
+ gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(table), FALSE, FALSE, 0);
+
+ label = gtk_label_new("Tilt Axis Offset:");
+ gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
+ gtk_table_attach_defaults(GTK_TABLE(table), GTK_WIDGET(label), 1, 2, 1, 2);
+ label = gtk_label_new("degrees");
+ gtk_table_attach_defaults(GTK_TABLE(table), GTK_WIDGET(label), 3, 4, 1, 2);
+
+ dw->tiltaxis_entry = gtk_entry_new();
+ gtk_table_attach_defaults(GTK_TABLE(table), GTK_WIDGET(dw->tiltaxis_entry), 2, 3, 1, 2);
+ gtk_entry_set_alignment(GTK_ENTRY(dw->tiltaxis_entry), 1);
+
+ g_signal_connect(G_OBJECT(dw->tiltaxis_window), "response", G_CALLBACK(displaywindow_setaxis_response), dw);
+
+ gtk_widget_show_all(dw->tiltaxis_window);
+ gtk_widget_grab_focus(GTK_WIDGET(dw->tiltaxis_entry));
+
+ return 0;
+
+}
static void displaywindow_addmenubar(DisplayWindow *dw) {
GtkActionEntry entries[] = {
@@ -921,6 +980,7 @@ static void displaywindow_addmenubar(DisplayWindow *dw) {
{ "StopDirAxAction", GTK_STOCK_CLOSE, "Stop DirAx", NULL, NULL, G_CALLBACK(displaywindow_dirax_stop) },
{ "ReprojectAction", NULL, "_Reproject Diffraction Patterns", NULL, NULL, G_CALLBACK(displaywindow_reproject) },
{ "SaveCacheAction", NULL, "Save Reflections to _Cache", NULL, NULL, G_CALLBACK(displaywindow_savecache) },
+ { "SetAxisAction", NULL, "Set Tilt Axis Position", NULL, NULL, G_CALLBACK(displaywindow_setaxis) },
{ "HelpAction", NULL, "_Help", NULL, NULL, NULL },
{ "AboutAction", GTK_STOCK_ABOUT, "_About DTR...", NULL, NULL, G_CALLBACK(displaywindow_about) },
diff --git a/src/displaywindow.h b/src/displaywindow.h
index 6857dc9..420767e 100644
--- a/src/displaywindow.h
+++ b/src/displaywindow.h
@@ -69,6 +69,10 @@ typedef struct dw_struct {
float x_start;
float y_start;
+ /* Tilt axis adjustment window */
+ GtkWidget *tiltaxis_window;
+ GtkWidget *tiltaxis_entry;
+
} DisplayWindow;
extern DisplayWindow *displaywindow_open(ControlContext *ctx);
diff --git a/src/mapping.c b/src/mapping.c
index a4ecd96..8c82c14 100644
--- a/src/mapping.c
+++ b/src/mapping.c
@@ -18,6 +18,7 @@
#include "control.h"
#include "itrans.h"
#include "image.h"
+#include "displaywindow.h"
static int mapping_map_to_space(ImageFeature *refl, double *ddx, double *ddy, double *ddz, double *twotheta) {
@@ -90,19 +91,14 @@ static int mapping_map_to_space(ImageFeature *refl, double *ddx, double *ddy, do
}
-ReflectionList *mapping_create(ControlContext *ctx) {
+static void mapping_map_features(ControlContext *ctx) {
int i;
-
- /* Pass all images through itrans */
- printf("MP: Analysing images..."); fflush(stdout);
- for ( i=0; i<ctx->images->n_images; i++ ) {
- ctx->images->images[i].features = itrans_process_image(&ctx->images->images[i], ctx->psmode);
- }
- printf("done.\n");
-
+
/* Create reflection list for measured reflections */
+ if ( ctx->reflectionlist ) reflectionlist_free(ctx->reflectionlist);
ctx->reflectionlist = reflectionlist_new();
+
printf("MP: Mapping to 3D..."); fflush(stdout);
for ( i=0; i<ctx->images->n_images; i++ ) {
@@ -121,8 +117,36 @@ ReflectionList *mapping_create(ControlContext *ctx) {
}
printf("done.\n");
+
+}
+
+ReflectionList *mapping_create(ControlContext *ctx) {
+
+ int i;
+
+ /* Find all the features */
+ printf("MP: Analysing images..."); fflush(stdout);
+ for ( i=0; i<ctx->images->n_images; i++ ) {
+ ctx->images->images[i].features = itrans_process_image(&ctx->images->images[i], ctx->psmode);
+ }
+ printf("done.\n");
+
+ mapping_map_features(ctx);
return ctx->reflectionlist;
}
+void mapping_adjust_axis(ControlContext *ctx, double offset) {
+
+ int i;
+
+ for ( i=0; i<ctx->images->n_images; i++ ) {
+ ctx->images->images[i].omega += offset;
+ }
+
+ mapping_map_features(ctx);
+ if ( ctx->dw ) displaywindow_update(ctx->dw);
+
+}
+
diff --git a/src/mapping.h b/src/mapping.h
index 601ad46..ca4a087 100644
--- a/src/mapping.h
+++ b/src/mapping.h
@@ -20,6 +20,7 @@
#include "control.h"
extern ReflectionList *mapping_create(ControlContext *ctx);
+extern void mapping_adjust_axis(ControlContext *ctx, double offset);
#endif /* MAPPING_H */
diff --git a/src/reflections.c b/src/reflections.c
index 7fcec2f..3e37a14 100644
--- a/src/reflections.c
+++ b/src/reflections.c
@@ -45,7 +45,7 @@ void reflectionlist_clear_markers(ReflectionList *reflectionlist) {
Reflection *prev = NULL;
int del = 0;
- do {
+ while ( reflection ) {
Reflection *next = reflection->next;
if ( (reflection->type == REFLECTION_MARKER) || (reflection->type == REFLECTION_GENERATED)
@@ -64,7 +64,7 @@ void reflectionlist_clear_markers(ReflectionList *reflectionlist) {
reflection = next;
- } while ( reflection );
+ };
reflectionlist->n_reflections -= del;
reflectionlist->last_reflection = prev;
@@ -73,11 +73,11 @@ void reflectionlist_clear_markers(ReflectionList *reflectionlist) {
void reflectionlist_clear(ReflectionList *reflectionlist) {
Reflection *reflection = reflectionlist->reflections;
- do {
+ while ( reflection ) {
Reflection *next = reflection->next;
free(reflection);
reflection = next;
- } while ( reflection );
+ };
reflectionlist_init(reflectionlist);