aboutsummaryrefslogtreecommitdiff
path: root/src/reproject.c
diff options
context:
space:
mode:
authortaw27 <taw27@bf6ca9ba-c028-0410-8290-897cf20841d1>2007-10-24 19:20:49 +0000
committertaw27 <taw27@bf6ca9ba-c028-0410-8290-897cf20841d1>2007-10-24 19:20:49 +0000
commitd889de524b665bb82caa232b925044a36054464f (patch)
treea215ac6ea4c8807eb380877765dbf57469a7c13a /src/reproject.c
parentb538363541f327e9702b4c46162775608e7ed031 (diff)
Preparation for relrod projection refinement
Add the option to perform a fine centering of patterns git-svn-id: svn://cook.msm.cam.ac.uk:745/diff-tomo/dtr@174 bf6ca9ba-c028-0410-8290-897cf20841d1
Diffstat (limited to 'src/reproject.c')
-rw-r--r--src/reproject.c53
1 files changed, 32 insertions, 21 deletions
diff --git a/src/reproject.c b/src/reproject.c
index 2c84326..b13dd66 100644
--- a/src/reproject.c
+++ b/src/reproject.c
@@ -85,6 +85,7 @@ ImageFeatureList *reproject_get_reflections(ImageRecord *image, ReflectionList *
double theta;
double x, y;
double rx, ry, rz;
+ double xtest, ytest;
/* Determine the intersection point */
xi = xl + s*nx; yi = yl + s*ny; zi = zl + s*nz;
@@ -153,12 +154,10 @@ ImageFeatureList *reproject_get_reflections(ImageRecord *image, ReflectionList *
return NULL;
}
- /* Adjust centre */
- x += image->x_centre;
- y += image->y_centre;
-
/* Sanity check */
- if ( (x>=0) && (x<image->width) && (y>=0) && (y<image->height) ) {
+ xtest = x + image->x_centre;
+ ytest = y + image->y_centre;
+ if ( (xtest>=0) && (xtest<image->width) && (ytest>=0) && (ytest<image->height) ) {
/* Record the reflection */
image_add_feature(flist, x, y, image, reflection->intensity);
@@ -178,10 +177,32 @@ ImageFeatureList *reproject_get_reflections(ImageRecord *image, ReflectionList *
}
-static gint reproject_clicked(GtkWidget *widget, GdkEventButton *event, ControlContext *ctx) {
+static void reproject_mark_peaks(ControlContext *ctx) {
ImageFeatureList *flist;
size_t j;
+ double xc, yc;
+
+ xc = ctx->images->images[ctx->reproject_cur_image].x_centre;
+ yc = ctx->images->images[ctx->reproject_cur_image].y_centre;
+
+ /* Draw the reprojected peaks */
+ flist = reproject_get_reflections(&ctx->images->images[ctx->reproject_cur_image], ctx->cell_lattice, ctx);
+ for ( j=0; j<flist->n_features; j++ ) {
+ imagedisplay_add_mark(ctx->reproject_id, xc+flist->features[j].x, yc+flist->features[j].y, IMAGEDISPLAY_MARK_CIRCLE_1);
+ }
+ image_feature_list_free(flist);
+
+ /* Now draw the original measured peaks */
+ flist = ctx->images->images[ctx->reproject_cur_image].features;
+ for ( j=0; j<flist->n_features; j++ ) {
+ imagedisplay_add_mark(ctx->reproject_id, xc+flist->features[j].x, yc+flist->features[j].y, IMAGEDISPLAY_MARK_CIRCLE_2);
+ }
+
+}
+
+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;
@@ -189,11 +210,7 @@ static gint reproject_clicked(GtkWidget *widget, GdkEventButton *event, ControlC
imagedisplay_clear_circles(ctx->reproject_id);
reflectionlist_clear_markers(ctx->reflectionlist);
- flist = reproject_get_reflections(&ctx->images->images[ctx->reproject_cur_image], ctx->cell_lattice, ctx);
- for ( j=0; j<flist->n_features; j++ ) {
- imagedisplay_mark_circle(ctx->reproject_id, flist->features[j].x, flist->features[j].y);
- }
- image_feature_list_free(flist);
+ reproject_mark_peaks(ctx);
imagedisplay_put_data(ctx->reproject_id, ctx->images->images[ctx->reproject_cur_image]);
@@ -208,9 +225,6 @@ static gint reproject_closed(GtkWidget *widget, ControlContext *ctx) {
void reproject_open(ControlContext *ctx) {
- size_t j;
- ImageFeatureList *flist;
-
if ( ctx->reproject_id ) {
displaywindow_error("Reprojection window is already open.", ctx->dw);
return;
@@ -231,16 +245,13 @@ void reproject_open(ControlContext *ctx) {
ctx->cell_lattice = reflection_list_from_cell(ctx->cell);
ctx->reproject_cur_image = 0;
- ctx->reproject_id = imagedisplay_open_with_message(ctx->images->images[ctx->reproject_cur_image], "Current Image", "Click to change image",
+ ctx->reproject_id = imagedisplay_open_with_message(ctx->images->images[ctx->reproject_cur_image],
+ "Reprojected Diffraction Pattern", "Click to change image",
IMAGEDISPLAY_SHOW_CENTRE | IMAGEDISPLAY_SHOW_TILT_AXIS, G_CALLBACK(reproject_clicked), ctx);
- g_signal_connect(GTK_OBJECT(ctx->reproject_id->drawingarea), "destroy", G_CALLBACK(reproject_closed), ctx);
+ reproject_mark_peaks(ctx);
- flist = reproject_get_reflections(&ctx->images->images[ctx->reproject_cur_image], ctx->cell_lattice, ctx);
- for ( j=0; j<flist->n_features; j++ ) {
- imagedisplay_mark_circle(ctx->reproject_id, flist->features[j].x, flist->features[j].y);
- }
- image_feature_list_free(flist);
+ g_signal_connect(GTK_OBJECT(ctx->reproject_id->drawingarea), "destroy", G_CALLBACK(reproject_closed), ctx);
}