aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/detector.c56
-rw-r--r--src/detector.h3
-rw-r--r--src/displaywindow.c40
-rw-r--r--src/displaywindow.h5
4 files changed, 93 insertions, 11 deletions
diff --git a/src/detector.c b/src/detector.c
index 633af6df..e4f15aff 100644
--- a/src/detector.c
+++ b/src/detector.c
@@ -515,3 +515,59 @@ struct detector *simple_geometry(const struct image *image)
return geom;
}
+
+
+static void check_extents(struct panel p, double *min_x, double *min_y,
+ double *max_x, double *max_y, double fs, double ss)
+{
+ double xs, ys, rx, ry;
+
+ xs = fs*p.fsx + ss*p.ssx;
+ ys = fs*p.fsy + ss*p.ssy;
+
+ rx = xs + p.cx;
+ ry = ys + p.cy;
+
+ if ( rx > *max_x ) *max_x = rx;
+ if ( ry > *max_y ) *max_y = ry;
+ if ( rx < *min_x ) *min_x = rx;
+ if ( ry < *min_y ) *min_y = ry;
+}
+
+
+void get_pixel_extents(struct detector *det,
+ double *min_x, double *min_y,
+ double *max_x, double *max_y)
+{
+ int i;
+
+ *min_x = 0.0;
+ *max_x = 0.0;
+ *min_y = 0.0;
+ *max_y = 0.0;
+
+ /* To determine the maximum extents of the detector, put all four
+ * corners of each panel through the transformations and watch for the
+ * biggest */
+
+ for ( i=0; i<det->n_panels; i++ ) {
+
+ check_extents(det->panels[i], min_x, min_y, max_x, max_y,
+ 0.0,
+ 0.0);
+
+ check_extents(det->panels[i], min_x, min_y, max_x, max_y,
+ 0.0,
+ det->panels[i].max_ss-det->panels[i].min_ss+1);
+
+ check_extents(det->panels[i], min_x, min_y, max_x, max_y,
+ det->panels[i].max_fs-det->panels[i].min_fs+1,
+ 0.0);
+
+ check_extents(det->panels[i], min_x, min_y, max_x, max_y,
+ det->panels[i].max_fs-det->panels[i].min_fs+1,
+ det->panels[i].max_ss-det->panels[i].min_ss+1);
+
+
+ }
+}
diff --git a/src/detector.h b/src/detector.h
index f5ae25ca..703c79ae 100644
--- a/src/detector.h
+++ b/src/detector.h
@@ -61,5 +61,8 @@ extern struct detector *get_detector_geometry(const char *filename);
extern void free_detector_geometry(struct detector *det);
extern struct detector *simple_geometry(const struct image *image);
+extern void get_pixel_extents(struct detector *det,
+ double *min_x, double *min_y,
+ double *max_x, double *max_y);
#endif /* DETECTOR_H */
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);
diff --git a/src/displaywindow.h b/src/displaywindow.h
index fb7192cf..e0c6600e 100644
--- a/src/displaywindow.h
+++ b/src/displaywindow.h
@@ -64,6 +64,11 @@ typedef struct {
int width;
int height; /* Size of the drawing area */
+ double min_x;
+ double min_y;
+ double max_x;
+ double max_y;
+
int binning;
double boostint;
int cmfilter; /* Use CM subtraction */