aboutsummaryrefslogtreecommitdiff
path: root/src/displaywindow.c
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/displaywindow.c
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/displaywindow.c')
-rw-r--r--src/displaywindow.c60
1 files changed, 60 insertions, 0 deletions
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) },