aboutsummaryrefslogtreecommitdiff
path: root/src/displaywindow.c
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2011-02-27 21:34:20 +0100
committerThomas White <taw@physics.org>2012-02-22 15:27:15 +0100
commit58db0aef18fe71d501d7712c7718e4e55324ee87 (patch)
treec12a7f3f3adf0cd53ef3fb77399ead0742b1849b /src/displaywindow.c
parent7dd5cd690e3c61df638aaacad5d23617f72ff0da (diff)
hdfsee: Fit window to detector geometry
Diffstat (limited to 'src/displaywindow.c')
-rw-r--r--src/displaywindow.c40
1 files changed, 29 insertions, 11 deletions
diff --git a/src/displaywindow.c b/src/displaywindow.c
index 1c60add6..ae90b8f6 100644
--- a/src/displaywindow.c
+++ b/src/displaywindow.c
@@ -49,12 +49,31 @@ static void displaywindow_update(DisplayWindow *dw)
gint width;
GdkGeometry geom;
- if ( dw->image != NULL ) {
- dw->width = dw->image->width/dw->binning;
- dw->height = dw->image->height/dw->binning;
- } else {
+ if ( dw->image == NULL ) {
dw->width = 320;
dw->height = 320;
+ } else {
+
+ double min_x, min_y, max_x, max_y;
+
+ get_pixel_extents(dw->image->det,
+ &min_x, &min_y, &max_x, &max_y);
+
+ if ( min_x > 0.0 ) min_x = 0.0;
+ if ( max_x < 0.0 ) max_x = 0.0;
+ if ( min_y > 0.0 ) min_y = 0.0;
+ if ( max_y < 0.0 ) max_y = 0.0;
+ dw->min_x = min_x;
+ dw->max_x = max_x;
+ dw->min_y = min_y;
+ dw->max_y = max_y;
+
+ dw->width = (max_x - min_x) / dw->binning;
+ dw->height = (max_y - min_y) / dw->binning;
+
+ /* Add a thin border */
+ dw->width += 2.0;
+ dw->height += 2.0;
}
width = dw->width;
@@ -130,11 +149,16 @@ static gboolean displaywindow_expose(GtkWidget *da, GdkEventExpose *event,
/* Set up basic coordinate system
* - origin in the centre, y upwards. */
cairo_identity_matrix(cr);
- cairo_translate(cr, dw->width/2.0, dw->height/2.0);
cairo_matrix_init(&m, 1.0, 0.0, 0.0, -1.0, 0.0, 0.0);
+ cairo_translate(cr, -dw->min_x/dw->binning, dw->max_y/dw->binning);
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;
@@ -166,12 +190,6 @@ static gboolean displaywindow_expose(GtkWidget *da, GdkEventExpose *event,
}
- cairo_identity_matrix(cr);
- cairo_translate(cr, dw->width/2.0, dw->height/2.0);
- 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->show_col_scale) && (dw->col_scale != NULL) ) {
cairo_identity_matrix(cr);
cairo_translate(cr, dw->width, 0.0);