aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2024-01-10 16:49:41 +0100
committerThomas White <taw@physics.org>2024-01-10 17:10:34 +0100
commit2058e8e032575c6b267271522778c9beb3d8b0aa (patch)
tree4eac3fd9d33530d8c9412758d3c41a64a101b75e /src
parent8ad1eddff0b3f020581e1852448752145656d16d (diff)
GUI: Skeleton task for detector alignment
Diffstat (limited to 'src')
-rw-r--r--src/crystfel_gui.c3
-rw-r--r--src/gui_align.c123
-rw-r--r--src/gui_align.h38
3 files changed, 164 insertions, 0 deletions
diff --git a/src/crystfel_gui.c b/src/crystfel_gui.c
index a51ec016..b3d3bc3f 100644
--- a/src/crystfel_gui.c
+++ b/src/crystfel_gui.c
@@ -56,6 +56,7 @@
#include "gui_merge.h"
#include "gui_fom.h"
#include "gui_export.h"
+#include "gui_align.h"
#include "gui_ambi.h"
#include "gui_project.h"
#include "version.h"
@@ -902,6 +903,8 @@ static void add_task_buttons(GtkWidget *vbox, struct crystfelproject *proj)
G_CALLBACK(index_all_sig), proj);
add_button(vbox, "Determine unit cell", "crystfel-unitcell",
G_CALLBACK(cell_explorer_sig), proj);
+ add_button(vbox, "Refine detector geometry", "crystfel-geometry",
+ G_CALLBACK(align_sig), proj);
add_button(vbox, "Indexing ambiguity", "crystfel-ambiguity",
G_CALLBACK(ambi_sig), proj);
add_button(vbox, "Merge", "crystfel-merge",
diff --git a/src/gui_align.c b/src/gui_align.c
new file mode 100644
index 00000000..5c559878
--- /dev/null
+++ b/src/gui_align.c
@@ -0,0 +1,123 @@
+/*
+ * gui_align.c
+ *
+ * Align detector via CrystFEL GUI
+ *
+ * Copyright © 2024 Deutsches Elektronen-Synchrotron DESY,
+ * a research centre of the Helmholtz Association.
+ *
+ * Authors:
+ * 2024 Thomas White <taw@physics.org>
+ *
+ * This file is part of CrystFEL.
+ *
+ * CrystFEL is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * CrystFEL is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with CrystFEL. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <string.h>
+#include <gtk/gtk.h>
+#include <assert.h>
+
+#include "version.h"
+#include "gui_project.h"
+#include "crystfel_gui.h"
+#include "gtk-util-routines.h"
+
+
+struct align_window
+{
+ struct crystfelproject *proj;
+ GtkWidget *window;
+ GtkWidget *out_of_plane;
+ GtkWidget *level;
+};
+
+
+static int run_align(struct align_window *win)
+{
+ STATUS("Mock detector alignment!\n");
+ return 0;
+}
+
+
+static void align_response_sig(GtkWidget *dialog, gint resp,
+ struct align_window *win)
+{
+ int r = 0;
+
+ if ( resp == GTK_RESPONSE_ACCEPT ) {
+ r = run_align(win);
+ }
+
+ if ( !r ) gtk_widget_destroy(dialog);
+}
+
+
+gint align_sig(GtkWidget *widget, struct crystfelproject *proj)
+{
+ GtkWidget *vbox;
+ GtkWidget *hbox;
+ GtkWidget *label;
+ GtkWidget *content_area;
+ struct align_window *win;
+
+ win = malloc(sizeof(struct align_window));
+ if ( win == NULL ) return 0;
+
+ win->proj = proj;
+
+ win->window = gtk_dialog_new_with_buttons("Align detector",
+ GTK_WINDOW(proj->window),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ "Cancel", GTK_RESPONSE_CANCEL,
+ "Run", GTK_RESPONSE_OK,
+ NULL);
+
+ vbox = gtk_vbox_new(FALSE, 0.0);
+ content_area = gtk_dialog_get_content_area(GTK_DIALOG(win->window));
+ gtk_box_pack_start(GTK_BOX(content_area), GTK_WIDGET(vbox), TRUE, TRUE, 0.0);
+ gtk_container_set_border_width(GTK_CONTAINER(content_area), 8);
+
+ hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8);
+ gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(hbox),
+ FALSE, FALSE, 0.0);
+ label = gtk_label_new("Refinement level:");
+ gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(label),
+ FALSE, FALSE, 16.0);
+ win->level = gtk_spin_button_new_with_range(0.0, 9.0, 1.0);
+ gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(win->level),
+ FALSE, FALSE, 4.0);
+ gtk_widget_set_tooltip_text(win->level, "--level");
+
+ win->out_of_plane = gtk_check_button_new_with_label("Refine out-of-plane positions and tilts");
+ gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(win->out_of_plane),
+ FALSE, FALSE, 4.0);
+ gtk_widget_set_tooltip_text(win->out_of_plane, "--out-of-plane");
+
+ g_signal_connect(G_OBJECT(win->window), "response",
+ G_CALLBACK(align_response_sig), win);
+
+ gtk_dialog_set_default_response(GTK_DIALOG(win->window),
+ GTK_RESPONSE_CLOSE);
+ gtk_widget_show_all(win->window);
+
+ return FALSE;
+}
diff --git a/src/gui_align.h b/src/gui_align.h
new file mode 100644
index 00000000..50250e6a
--- /dev/null
+++ b/src/gui_align.h
@@ -0,0 +1,38 @@
+/*
+ * gui_align.h
+ *
+ * Align detector via CrystFEL GUI
+ *
+ * Copyright © 2024 Deutsches Elektronen-Synchrotron DESY,
+ * a research centre of the Helmholtz Association.
+ *
+ * Authors:
+ * 2024 Thomas White <taw@physics.org>
+ *
+ * This file is part of CrystFEL.
+ *
+ * CrystFEL is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * CrystFEL is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with CrystFEL. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef GUI_ALIGN_H
+#define GUI_ALIGN_H
+
+#include <gtk/gtk.h>
+
+#include "gui_project.h"
+
+extern gint align_sig(GtkWidget *widget, struct crystfelproject *proj);
+
+#endif