aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2011-02-27 22:07:35 +0100
committerThomas White <taw@physics.org>2012-02-22 15:27:15 +0100
commit06cce661882a8b3608304533afc9336a9b380240 (patch)
treeddaec95b534df6bec143546b81de60d2c0baea89
parent58db0aef18fe71d501d7712c7718e4e55324ee87 (diff)
hdfsee: Show resolution rings
-rw-r--r--src/displaywindow.c49
1 files changed, 44 insertions, 5 deletions
diff --git a/src/displaywindow.c b/src/displaywindow.c
index ae90b8f6..5b657ef5 100644
--- a/src/displaywindow.c
+++ b/src/displaywindow.c
@@ -130,6 +130,37 @@ static gint displaywindow_closed(GtkWidget *window, DisplayWindow *dw)
}
+static double ring_radius(struct image *image, double d)
+{
+ double theta, r, r_px;
+
+ theta = asin(image->lambda / (2.0*d));
+ r = image->det->panels[0].clen * tan(2.0*theta);
+ r_px = r * image->det->panels[0].res;
+
+ return r_px;
+}
+
+
+static void show_ring(cairo_t *cr, DisplayWindow *dw,
+ double d, const char *label)
+{
+ cairo_identity_matrix(cr);
+ cairo_translate(cr, -dw->min_x/dw->binning, dw->max_y/dw->binning);
+ cairo_arc(cr, 0.0, 0.0, ring_radius(dw->image, d)/dw->binning,
+ 0.0, 2.0*M_PI);
+ cairo_set_source_rgb(cr, 1.0, 0.0, 0.0);
+ cairo_set_line_width(cr, 1.0);
+ cairo_stroke(cr);
+ cairo_rotate(cr, -M_PI/4.0);
+ cairo_translate(cr, 0.0,
+ ring_radius(dw->image, d)/dw->binning-5.0);
+ cairo_set_font_size(cr, 20.0);
+ cairo_show_text(cr, label);
+ cairo_fill(cr);
+}
+
+
static gboolean displaywindow_expose(GtkWidget *da, GdkEventExpose *event,
DisplayWindow *dw)
{
@@ -154,11 +185,6 @@ static gboolean displaywindow_expose(GtkWidget *da, GdkEventExpose *event,
cairo_transform(cr, &m);
cairo_get_matrix(cr, &basic_m);
- /* Mark the beam */
- cairo_arc(cr, 0.0, 0.0, 5.0/dw->binning, 0.0, 2.0*M_PI);
- cairo_set_source_rgb(cr, 1.0, 0.0, 0.0);
- cairo_fill(cr);
-
if ( dw->pixbufs != NULL ) {
int i;
@@ -198,6 +224,19 @@ static gboolean displaywindow_expose(GtkWidget *da, GdkEventExpose *event,
cairo_fill(cr);
}
+ /* Mark the beam */
+ cairo_set_matrix(cr, &basic_m);
+ cairo_arc(cr, 0.0, 0.0, 5.0/dw->binning, 0.0, 2.0*M_PI);
+ cairo_set_source_rgb(cr, 1.0, 0.0, 0.0);
+ cairo_fill(cr);
+
+ /* Draw resolution circles */
+ show_ring(cr, dw, 5.0e-10, "5A");
+ show_ring(cr, dw, 4.0e-10, "4A");
+ show_ring(cr, dw, 3.0e-10, "3A");
+ show_ring(cr, dw, 2.0e-10, "2A");
+ show_ring(cr, dw, 1.0e-10, "1A");
+
if ( dw->image->features == NULL ) {
cairo_destroy(cr);
return FALSE;