aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/control.c2
-rw-r--r--src/refine.c9
-rw-r--r--src/reflections.c23
-rw-r--r--src/reflections.h1
-rw-r--r--src/reproject.c33
-rw-r--r--src/reproject.h1
6 files changed, 55 insertions, 14 deletions
diff --git a/src/control.c b/src/control.c
index f5b5b12..0346e7a 100644
--- a/src/control.c
+++ b/src/control.c
@@ -30,6 +30,8 @@ ControlContext *control_ctx_new() {
ctx->images = image_list_new();
ctx->reflectionlist = NULL;
ctx->refine_window = NULL;
+ ctx->cell_lattice = NULL;
+ ctx->reproject_id = NULL;
return ctx;
diff --git a/src/refine.c b/src/refine.c
index c996691..01c4bcb 100644
--- a/src/refine.c
+++ b/src/refine.c
@@ -64,12 +64,11 @@ typedef enum {
} RefinementIndex;
/* Use the IPR algorithm to make "cell" fit the given image */
-static void refine_fit_image(Basis *cell, ImageRecord *image) {
+static void refine_fit_image(Basis *cell, ImageRecord *image, ReflectionList *cell_lattice) {
ImageFeatureList *rflist;
ImageFeatureList *flist;
int i;
- ReflectionList *cell_lattice;
Basis cd; /* Cell delta */
int n_a = 0;
int n_b = 0;
@@ -79,7 +78,6 @@ static void refine_fit_image(Basis *cell, ImageRecord *image) {
cd.b.x = 0.0; cd.b.y = 0.0; cd.b.z = 0.0;
cd.c.x = 0.0; cd.c.y = 0.0; cd.c.z = 0.0;
- cell_lattice = reflection_list_from_cell(cell);
rflist = reproject_get_reflections(image, cell_lattice);
flist = image->features;
reproject_partner_features(rflist, image);
@@ -226,8 +224,9 @@ static gint refine_graph(GtkWidget *step_button, ControlContext *ctx) {
static gint refine_step(GtkWidget *step_button, ControlContext *ctx) {
- if ( ctx->reproject_id ) {
- refine_fit_image(ctx->cell, &ctx->images->images[ctx->reproject_cur_image]);
+ if ( (ctx->reproject_id) && (ctx->cell_lattice) ) {
+ refine_fit_image(ctx->cell, &ctx->images->images[ctx->reproject_cur_image], ctx->cell_lattice);
+ reproject_lattice_changed(ctx);
} else {
displaywindow_error("Please first open the reprojection window and select the image to fit", ctx->dw);
}
diff --git a/src/reflections.c b/src/reflections.c
index 9f3f1c8..3060bfd 100644
--- a/src/reflections.c
+++ b/src/reflections.c
@@ -223,7 +223,6 @@ ReflectionList *reflection_list_from_cell(Basis *basis) {
signed int h, k, l;
int max_order_a, max_order_b, max_order_c;
-
max_res = 20e9;
ordered = reflectionlist_new();
@@ -261,3 +260,25 @@ ReflectionList *reflection_list_from_cell(Basis *basis) {
}
+void reflection_list_from_new_cell(ReflectionList *ordered, Basis *basis) {
+
+ Reflection *ref;
+
+ ref = ordered->reflections;
+
+ while ( ref ) {
+
+ signed int h, k, l;
+
+ h = ref->h; k = ref->k; l = ref->l;
+
+ ref->x = h*basis->a.x + k*basis->b.x + l*basis->c.x;
+ ref->y = h*basis->a.y + k*basis->b.y + l*basis->c.y;
+ ref->z = h*basis->a.z + k*basis->b.z + l*basis->c.z;
+
+ ref = ref->next;
+
+ }
+
+}
+
diff --git a/src/reflections.h b/src/reflections.h
index 7f287a1..9158d27 100644
--- a/src/reflections.h
+++ b/src/reflections.h
@@ -70,6 +70,7 @@ extern Reflection *reflectionlist_find_nearest_type(ReflectionList *reflectionli
#include "basis.h"
extern ReflectionList *reflection_list_from_cell(Basis *basis);
+extern void reflection_list_from_new_cell(ReflectionList *ordered, Basis *basis);
#endif /* REFLECTION_H */
diff --git a/src/reproject.c b/src/reproject.c
index c41f173..c0dfc73 100644
--- a/src/reproject.c
+++ b/src/reproject.c
@@ -259,24 +259,41 @@ static void reproject_mark_peaks(ControlContext *ctx) {
image_feature_list_free(rflist);
}
-
-static gint reproject_clicked(GtkWidget *widget, GdkEventButton *event, ControlContext *ctx) {
-
-
- ctx->reproject_cur_image++;
- if ( ctx->reproject_cur_image == ctx->images->n_images ) ctx->reproject_cur_image = 0;
+static void reproject_update(ControlContext *ctx) {
+
imagedisplay_clear_marks(ctx->reproject_id);
- reflectionlist_clear_markers(ctx->reflectionlist);
+ //reflectionlist_clear_markers(ctx->reflectionlist);
reproject_mark_peaks(ctx);
imagedisplay_put_data(ctx->reproject_id, ctx->images->images[ctx->reproject_cur_image]);
+}
+
+static gint reproject_clicked(GtkWidget *widget, GdkEventButton *event, ControlContext *ctx) {
+
+ ctx->reproject_cur_image++;
+ if ( ctx->reproject_cur_image == ctx->images->n_images ) ctx->reproject_cur_image = 0;
+
+ reproject_update(ctx);
+
return 0;
}
+void reproject_lattice_changed(ControlContext *ctx) {
+
+ if ( ctx->cell_lattice ) {
+ reflection_list_from_new_cell(ctx->cell_lattice, ctx->cell);
+ } else {
+ ctx->cell_lattice = reflection_list_from_cell(ctx->cell);
+ }
+
+ if ( ctx->reproject_id ) reproject_update(ctx);
+
+}
+
static gint reproject_closed(GtkWidget *widget, ControlContext *ctx) {
ctx->reproject_id = NULL;
return 0;
@@ -301,8 +318,8 @@ void reproject_open(ControlContext *ctx) {
return;
}
- ctx->cell_lattice = reflection_list_from_cell(ctx->cell);
ctx->reproject_cur_image = 0;
+ reproject_lattice_changed(ctx);
ctx->reproject_id = imagedisplay_open_with_message(ctx->images->images[ctx->reproject_cur_image],
"Reprojected Diffraction Pattern", "Click to change image",
diff --git a/src/reproject.h b/src/reproject.h
index a0dfd5f..9964048 100644
--- a/src/reproject.h
+++ b/src/reproject.h
@@ -22,6 +22,7 @@
extern ImageFeatureList *reproject_get_reflections(ImageRecord *image, ReflectionList *reflectionlist);
extern void reproject_partner_features(ImageFeatureList *flist, ImageRecord *image);
extern void reproject_open(ControlContext *ctx);
+extern void reproject_lattice_changed(ControlContext *ctx);
#endif /* REPROJECT_H */