From d889de524b665bb82caa232b925044a36054464f Mon Sep 17 00:00:00 2001 From: taw27 Date: Wed, 24 Oct 2007 19:20:49 +0000 Subject: 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 --- src/reproject.c | 53 ++++++++++++++++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 21 deletions(-) (limited to 'src/reproject.c') 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) && (xwidth) && (y>=0) && (yheight) ) { + xtest = x + image->x_centre; + ytest = y + image->y_centre; + if ( (xtest>=0) && (xtestwidth) && (ytest>=0) && (ytestheight) ) { /* 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; jn_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; jn_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; jn_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; jn_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); } -- cgit v1.2.3