From a7057533b2d8dbccb2e29d7215a054e368d0b749 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Thu, 5 Mar 2020 15:38:41 +0100 Subject: Show the peaks in the image view --- src/crystfel_gui.c | 12 +++++++++- src/crystfelimageview.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++- src/crystfelimageview.h | 6 ++++- 3 files changed, 76 insertions(+), 3 deletions(-) diff --git a/src/crystfel_gui.c b/src/crystfel_gui.c index eb3fa842..aba46e9a 100644 --- a/src/crystfel_gui.c +++ b/src/crystfel_gui.c @@ -149,7 +149,7 @@ static void update_peaks(struct crystfelproject *proj) proj->peak_search_params.use_saturated); crystfel_image_view_set_peaks(CRYSTFEL_IMAGE_VIEW(proj->imageview), - image->features); + image->features, 0); } @@ -557,6 +557,7 @@ static gint first_frame_sig(GtkWidget *widget, struct crystfelproject *proj) { proj->cur_frame = 0; update_imageview(proj); + update_peaks(proj); return FALSE; } @@ -566,6 +567,7 @@ static gint prev_frame_sig(GtkWidget *widget, struct crystfelproject *proj) if ( proj->cur_frame == 0 ) return FALSE; proj->cur_frame--; update_imageview(proj); + update_peaks(proj); return FALSE; } @@ -575,6 +577,7 @@ static gint next_frame_sig(GtkWidget *widget, struct crystfelproject *proj) if ( proj->cur_frame == proj->n_frames - 1 ) return FALSE; proj->cur_frame++; update_imageview(proj); + update_peaks(proj); return FALSE; } @@ -583,6 +586,7 @@ static gint last_frame_sig(GtkWidget *widget, struct crystfelproject *proj) { proj->cur_frame = proj->n_frames - 1; update_imageview(proj); + update_peaks(proj); return FALSE; } @@ -765,6 +769,12 @@ int main(int argc, char *argv[]) proj.events = NULL; proj.peak_params = NULL; proj.peak_search_params.threshold = 800.0; + proj.peak_search_params.min_sq_gradient = 100000; + proj.peak_search_params.min_snr = 5.0; + proj.peak_search_params.pk_inn = 3.0; + proj.peak_search_params.pk_mid = 4.0; + proj.peak_search_params.pk_out = 5.0; + proj.peak_search_params.use_saturated = 1; proj.window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(proj.window), "CrystFEL"); diff --git a/src/crystfelimageview.c b/src/crystfelimageview.c index 3b56dbca..33feb46a 100644 --- a/src/crystfelimageview.c +++ b/src/crystfelimageview.c @@ -230,8 +230,40 @@ static void draw_panel_rectangle(cairo_t *cr, CrystFELImageView *iv, int i) } +static void draw_peaks(cairo_t *cr, CrystFELImageView *iv, + ImageFeatureList *pks) +{ + int i, n_pks; + double bs, lw; + + bs = 5.0; + lw = 1.0; + cairo_device_to_user_distance(cr, &bs, &lw); + bs = fabs(bs); + lw = fabs(lw); + + n_pks = image_feature_count(pks); + for ( i=0; iimage->detgeom->panels[f->pn]; + x = p->pixel_pitch*(p->cnx + p->fsx*f->fs + p->ssx*f->ss); + y = p->pixel_pitch*(p->cny + p->fsy*f->fs + p->ssy*f->ss); + cairo_rectangle(cr, x-bs, y-bs, 2*bs, 2*bs); + cairo_set_line_width(cr, lw); + cairo_set_source_rgb(cr, 1.0, 0.0, 0.0); + cairo_stroke(cr); + } +} + + static gint draw_sig(GtkWidget *window, cairo_t *cr, CrystFELImageView *iv) { + int i; + cairo_save(cr); /* Overall background (light grey) */ @@ -253,6 +285,12 @@ static gint draw_sig(GtkWidget *window, cairo_t *cr, CrystFELImageView *iv) } } + for ( i=0; inum_peaklists; i++ ){ + if ( iv->peaklists[i] != NULL ) { + draw_peaks(cr, iv , iv->peaklists[i]); + } + } + cairo_restore(cr); return FALSE; } @@ -395,6 +433,8 @@ GtkWidget *crystfel_image_view_new() iv->filename = NULL; iv->event = NULL; iv->image = NULL; + iv->num_peaklists = 0; + iv->peaklists = NULL; g_signal_connect(G_OBJECT(iv), "destroy", G_CALLBACK(destroy_sig), iv); @@ -543,6 +583,25 @@ struct image *crystfel_image_view_get_image_struct(CrystFELImageView *iv) void crystfel_image_view_set_peaks(CrystFELImageView *iv, - ImageFeatureList *peaks) + ImageFeatureList *peaks, + int list_num) { + int i; + if ( list_num >= iv->num_peaklists ) { + ImageFeatureList **n_fl; + n_fl = realloc(iv->peaklists, + (list_num+1)*sizeof(ImageFeatureList*)); + if ( n_fl == NULL ) return; + for ( i=iv->num_peaklists; ipeaklists = n_fl; + iv->num_peaklists = list_num+1; + } + if ( iv->peaklists[list_num] != NULL ) { + image_feature_list_free(iv->peaklists[list_num]); + } + iv->peaklists[list_num] = image_feature_list_copy(peaks); + + redraw(iv); } diff --git a/src/crystfelimageview.h b/src/crystfelimageview.h index 3e2c35e2..62faf044 100644 --- a/src/crystfelimageview.h +++ b/src/crystfelimageview.h @@ -86,6 +86,9 @@ struct _crystfelimageview char *event; struct image *image; GdkPixbuf **pixbufs; + + int num_peaklists; + ImageFeatureList **peaklists; }; struct _crystfelimageviewclass @@ -109,6 +112,7 @@ extern int crystfel_image_view_set_image(CrystFELImageView *iv, extern struct image *crystfel_image_view_get_image_struct(CrystFELImageView *iv); extern void crystfel_image_view_set_peaks(CrystFELImageView *iv, - ImageFeatureList *peaks); + ImageFeatureList *peaks, + int list_num); #endif /* CRYSTFELIMAGEVIEW_H */ -- cgit v1.2.3