diff options
author | Thomas White <taw@physics.org> | 2020-07-06 14:24:34 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2020-07-29 18:53:45 +0200 |
commit | ce12bf3b6739a7a149f2cbed62951240dd536cab (patch) | |
tree | 1b762078d8760a54f1d7467ceff03daf8c2e6803 | |
parent | 4e64ee724415f5e2e0acf2846c77bbf293368364 (diff) |
Show reflections in GUI
-rw-r--r-- | src/crystfel_gui.c | 12 | ||||
-rw-r--r-- | src/crystfelimageview.c | 57 | ||||
-rw-r--r-- | src/crystfelimageview.h | 4 | ||||
-rw-r--r-- | src/gui_project.c | 6 | ||||
-rw-r--r-- | src/gui_project.h | 2 |
5 files changed, 80 insertions, 1 deletions
diff --git a/src/crystfel_gui.c b/src/crystfel_gui.c index 8ab8a7fb..f60555f8 100644 --- a/src/crystfel_gui.c +++ b/src/crystfel_gui.c @@ -609,6 +609,15 @@ static gint show_peaks_sig(GtkWidget *w, struct crystfelproject *proj) } +static gint show_refls_sig(GtkWidget *w, struct crystfelproject *proj) +{ + proj->show_refls = gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(w)); + crystfel_image_view_set_show_reflections(CRYSTFEL_IMAGE_VIEW(proj->imageview), + proj->show_refls); + return FALSE; +} + + static void add_menu_bar(struct crystfelproject *proj, GtkWidget *vbox) { GError *error = NULL; @@ -620,6 +629,7 @@ static void add_menu_bar(struct crystfelproject *proj, GtkWidget *vbox) "</menu>" "<menu name=\"view\" action=\"ViewAction\" >" " <menuitem name=\"peaks\" action=\"PeaksAction\" />" + " <menuitem name=\"refls\" action=\"ReflsAction\" />" "</menu>" "<menu name=\"tools\" action=\"ToolsAction\" >" "</menu>" @@ -649,6 +659,8 @@ static void add_menu_bar(struct crystfelproject *proj, GtkWidget *vbox) GtkToggleActionEntry toggles[] = { { "PeaksAction", NULL, "Peak detection results", NULL, NULL, G_CALLBACK(show_peaks_sig), FALSE }, + { "ReflsAction", NULL, "Calculated reflection positions", NULL, NULL, + G_CALLBACK(show_refls_sig), FALSE }, }; proj->action_group = gtk_action_group_new("cellwindow"); diff --git a/src/crystfelimageview.c b/src/crystfelimageview.c index 8334cb2e..4e2f47b1 100644 --- a/src/crystfelimageview.c +++ b/src/crystfelimageview.c @@ -408,6 +408,44 @@ static void draw_peaks(cairo_t *cr, CrystFELImageView *iv, } +static void draw_refls(cairo_t *cr, CrystFELImageView *iv, + RefList *list) +{ + const Reflection *refl; + RefListIterator *iter; + double bs, lw; + + if ( list == NULL ) return; + + bs = 5.0; + lw = 1.0; + cairo_device_to_user_distance(cr, &bs, &lw); + bs = fabs(bs); + lw = fabs(lw); + + for ( refl = first_refl_const(list, &iter); + refl != NULL; + refl = next_refl_const(refl, iter) ) + { + struct detgeom_panel *p; + double fs, ss; + int pn; + double x, y; + + get_detector_pos(refl, &fs, &ss); + pn = get_panel_number(refl); + + p = &iv->image->detgeom->panels[pn]; + x = p->pixel_pitch*(p->cnx + p->fsx*fs + p->ssx*ss); + y = p->pixel_pitch*(p->cny + p->fsy*fs + p->ssy*ss); + + cairo_arc(cr, x, y, bs, 0, 2*M_PI); + cairo_set_source_rgb(cr, 0.0, 1.0, 0.0); + cairo_stroke(cr); + } +} + + static gint draw_sig(GtkWidget *window, cairo_t *cr, CrystFELImageView *iv) { cairo_matrix_t m; @@ -440,6 +478,14 @@ static gint draw_sig(GtkWidget *window, cairo_t *cr, CrystFELImageView *iv) draw_peaks(cr, iv, iv->image->features); } + if ( iv->show_refls ) { + int i; + for ( i=0; i<iv->image->n_crystals; i++ ) { + Crystal *cry = iv->image->crystals[i]; + draw_refls(cr, iv, crystal_get_reflections(cry)); + } + } + cairo_restore(cr); return FALSE; @@ -452,7 +498,8 @@ static void scroll_adjust_sig(GtkAdjustment *adj, CrystFELImageView *iv) } -static void crystfel_image_view_set_property(GObject *obj, guint id, const GValue *val, +static void crystfel_image_view_set_property(GObject *obj, guint id, + const GValue *val, GParamSpec *spec) { CrystFELImageView *iv = CRYSTFEL_IMAGE_VIEW(obj); @@ -829,3 +876,11 @@ void crystfel_image_view_set_show_peaks(CrystFELImageView *iv, iv->show_peaks = show_peaks; rerender_image(iv); } + + +void crystfel_image_view_set_show_reflections(CrystFELImageView *iv, + int show_refls) +{ + iv->show_refls = show_refls; + rerender_image(iv); +} diff --git a/src/crystfelimageview.h b/src/crystfelimageview.h index 90c406b7..ff07f4b3 100644 --- a/src/crystfelimageview.h +++ b/src/crystfelimageview.h @@ -87,6 +87,7 @@ struct _crystfelimageview double brightness; int show_peaks; + int show_refls; }; struct _crystfelimageviewclass @@ -111,4 +112,7 @@ extern void crystfel_image_view_set_brightness(CrystFELImageView *iv, extern void crystfel_image_view_set_show_peaks(CrystFELImageView *iv, int show_peaks); +extern void crystfel_image_view_set_show_reflections(CrystFELImageView *iv, + int show_refls); + #endif /* CRYSTFELIMAGEVIEW_H */ diff --git a/src/gui_project.c b/src/gui_project.c index 1b022d2a..ca550795 100644 --- a/src/gui_project.c +++ b/src/gui_project.c @@ -203,6 +203,10 @@ static void handle_var(const char *key, const char *val, proj->show_peaks = parse_int(val); } + if ( strcmp(key, "show_refls") == 0 ) { + proj->show_refls = parse_int(val); + } + if ( strcmp(key, "backend") == 0 ) { proj->backend = parse_backend(val); } @@ -383,6 +387,7 @@ int save_project(struct crystfelproject *proj) proj->peak_search_params.revalidate); fprintf(fh, "show_peaks %i\n", proj->show_peaks); + fprintf(fh, "show_refls %i\n", proj->show_refls); fprintf(fh, "backend %s\n", proj->backend->name); fprintf(fh, "-----\n"); @@ -423,6 +428,7 @@ void default_project(struct crystfelproject *proj) /* Default parameter values */ proj->show_peaks = 0; + proj->show_refls = 0; proj->peak_search_params.method = PEAK_ZAEF; proj->peak_search_params.threshold = 800.0; proj->peak_search_params.min_sq_gradient = 100000; diff --git a/src/gui_project.h b/src/gui_project.h index aad71e2e..33f1271b 100644 --- a/src/gui_project.h +++ b/src/gui_project.h @@ -97,6 +97,8 @@ struct crystfelproject { int show_peaks; struct peak_params peak_search_params; + int show_refls; + GtkWidget *type_combo; GtkWidget *peak_vbox; /* Box for peak search parameter widgets */ GtkWidget *peak_params; /* Peak search parameter widgets */ |