aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2011-02-22 00:04:47 -0800
committerThomas White <taw@physics.org>2012-02-22 15:27:15 +0100
commit1a443ce35e96fb39ca0a152a38e35adb7e655ca2 (patch)
tree697faa252fec1bae61d11cafc81e9f7a585d62fa
parent03276838678866c187f368958f00cbc22573bce3 (diff)
Get rid of show_marked_features() in render.c, and use Cairo in displaywindow instead
-rw-r--r--src/displaywindow.c41
-rw-r--r--src/render.c44
2 files changed, 39 insertions, 46 deletions
diff --git a/src/displaywindow.c b/src/displaywindow.c
index 03dabe94..4120e3b4 100644
--- a/src/displaywindow.c
+++ b/src/displaywindow.c
@@ -107,6 +107,7 @@ static gboolean displaywindow_expose(GtkWidget *da, GdkEventExpose *event,
DisplayWindow *dw)
{
cairo_t *cr;
+ int i;
cr = gdk_cairo_create(da->window);
@@ -116,8 +117,6 @@ static gboolean displaywindow_expose(GtkWidget *da, GdkEventExpose *event,
cairo_set_source_rgb(cr, 0.0, 0.0, 1.0);
cairo_fill(cr);
- cairo_destroy(cr);
-
if ( dw->pixbuf != NULL ) {
gdk_draw_pixbuf(da->window,
da->style->bg_gc[GTK_WIDGET_STATE(da)],
@@ -134,6 +133,44 @@ static gboolean displaywindow_expose(GtkWidget *da, GdkEventExpose *event,
GDK_RGB_DITHER_NONE, 0, 0);
}
+ if ( dw->image->features == NULL ) return FALSE;
+
+ for ( i=0; i<image_feature_count(dw->image->features); i++ ) {
+
+ double x, y;
+ struct imagefeature *f;
+
+ f = image_get_feature(dw->image->features, i);
+ if ( f == NULL ) continue;
+
+ x = f->x / (double)dw->binning;
+ y = dw->height - f->y / (double)dw->binning;
+
+ cairo_new_path(cr);
+ cairo_arc(cr, x, y, 7.0/dw->binning, 0.0, 2.0*M_PI);
+ switch ( dw->scale ) {
+
+ case SCALE_COLOUR :
+ cairo_set_source_rgb(cr, 1.0, 1.0, 0.0);
+ break;
+
+ case SCALE_MONO :
+ cairo_set_source_rgb(cr, 1.0, 1.0, 1.0);
+ break;
+
+ case SCALE_INVMONO:
+ cairo_set_source_rgb(cr, 0.0, 0.0, 0.0);
+ break;
+
+ }
+
+ cairo_set_line_width(cr, 0.75);
+ cairo_stroke(cr);
+
+ }
+
+ cairo_destroy(cr);
+
return FALSE;
}
diff --git a/src/render.c b/src/render.c
index 10dd9f10..231225f2 100644
--- a/src/render.c
+++ b/src/render.c
@@ -193,48 +193,6 @@ static void render_free_data(guchar *data, gpointer p)
}
-/* FIXME: This doesn't belong here at all */
-static void show_marked_features(struct image *image, guchar *data,
- int w, int h, int binning)
-{
- int i;
- float r = 10.0/binning;
-
- if ( image->features == NULL ) return;
-
- for ( i=0; i<image_feature_count(image->features); i++ ) {
-
- struct imagefeature *f;
- float x, y;
- double th;
-
- f = image_get_feature(image->features, i);
- if ( f == NULL ) continue;
-
- x = f->x / (float)binning;
- y = f->y / (float)binning;
-
- for ( th=0; th<2*M_PI; th+=M_PI/40.0 ) {
-
- int nx, ny;
-
- nx = x + r*cos(th);
- ny = y + r*sin(th);
-
- if ( nx < 0 ) continue;
- if ( ny < 0 ) continue;
- if ( nx >= w ) continue;
- if ( ny >= h ) continue;
-
- data[3*( nx+w*(h-1-ny) )+0] = 128;
- data[3*( nx+w*(h-1-ny) )+1] = 128;
- data[3*( nx+w*(h-1-ny) )+2] = 30;
-
- }
- }
-}
-
-
/* Return a pixbuf containing a rendered version of the image after binning.
* This pixbuf might be scaled later - hopefully mostly in a downward
* direction. */
@@ -287,8 +245,6 @@ GdkPixbuf *render_get_image(struct image *image, int binning, int scale,
}
}
- show_marked_features(image, data, w, h, binning);
-
/* Finished with this */
free(hdr);