From c25120f4b71da8b82476c8a14b1617c8f7b72d57 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Thu, 2 Dec 2010 22:56:28 +0100 Subject: Fix Cairo conditionals --- configure | 18 ------- src/Makefile.am | 2 + src/Makefile.in | 21 +++++--- src/cubeit.c | 1 + src/render.c | 163 +++++++++++++++++++++++++++++--------------------------- src/render.h | 9 ++-- 6 files changed, 107 insertions(+), 107 deletions(-) diff --git a/configure b/configure index cb26682f..538262e7 100755 --- a/configure +++ b/configure @@ -600,8 +600,6 @@ HAVE_CAIRO_FALSE HAVE_CAIRO_TRUE Cairo_LIBS Cairo_CFLAGS -HAVE_LIBPNG_FALSE -HAVE_LIBPNG_TRUE libPNG_LIBS libPNG_CFLAGS HAVE_GTK_FALSE @@ -4972,14 +4970,6 @@ else $as_echo "no" >&6; } fi - if test x$havelibpng = xtrue; then - HAVE_LIBPNG_TRUE= - HAVE_LIBPNG_FALSE='#' -else - HAVE_LIBPNG_TRUE='#' - HAVE_LIBPNG_FALSE= -fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use TIFF" >&5 @@ -5258,10 +5248,6 @@ if test -z "${HAVE_GTK_TRUE}" && test -z "${HAVE_GTK_FALSE}"; then as_fn_error "conditional \"HAVE_GTK\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi -if test -z "${HAVE_LIBPNG_TRUE}" && test -z "${HAVE_LIBPNG_FALSE}"; then - as_fn_error "conditional \"HAVE_LIBPNG\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi if test -z "${HAVE_CAIRO_TRUE}" && test -z "${HAVE_CAIRO_FALSE}"; then as_fn_error "conditional \"HAVE_CAIRO\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 @@ -6710,10 +6696,6 @@ if test -z "${HAVE_GTK_TRUE}" && test -z "${HAVE_GTK_FALSE}"; then as_fn_error "conditional \"HAVE_GTK\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi -if test -z "${HAVE_LIBPNG_TRUE}" && test -z "${HAVE_LIBPNG_FALSE}"; then - as_fn_error "conditional \"HAVE_LIBPNG\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi if test -z "${HAVE_CAIRO_TRUE}" && test -z "${HAVE_CAIRO_FALSE}"; then as_fn_error "conditional \"HAVE_CAIRO\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 diff --git a/src/Makefile.am b/src/Makefile.am index 98508dd0..75ef8063 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -67,9 +67,11 @@ facetron_SOURCES = facetron.c cell.c hdf5-file.c utils.c detector.c peaks.c \ beam-parameters.c symmetry.c post-refinement.c hrs-scaling.c facetron_LDADD = @LIBS@ +if HAVE_CAIRO cubeit_SOURCES = cubeit.c cell.c hdf5-file.c utils.c detector.c render.c \ filters.c image.c symmetry.c stream.c thread-pool.c cubeit_LDADD = @LIBS@ +endif reintegrate_SOURCES = reintegrate.c cell.c hdf5-file.c utils.c detector.c \ peaks.c image.c stream.c \ diff --git a/src/Makefile.in b/src/Makefile.in index d7833b13..11b0eabf 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -70,10 +70,15 @@ am_compare_hkl_OBJECTS = compare_hkl.$(OBJEXT) sfac.$(OBJEXT) \ statistics.$(OBJEXT) symmetry.$(OBJEXT) compare_hkl_OBJECTS = $(am_compare_hkl_OBJECTS) compare_hkl_DEPENDENCIES = -am_cubeit_OBJECTS = cubeit.$(OBJEXT) cell.$(OBJEXT) \ - hdf5-file.$(OBJEXT) utils.$(OBJEXT) detector.$(OBJEXT) \ - render.$(OBJEXT) filters.$(OBJEXT) image.$(OBJEXT) \ - symmetry.$(OBJEXT) stream.$(OBJEXT) thread-pool.$(OBJEXT) +am__cubeit_SOURCES_DIST = cubeit.c cell.c hdf5-file.c utils.c \ + detector.c render.c filters.c image.c symmetry.c stream.c \ + thread-pool.c +@HAVE_CAIRO_TRUE@am_cubeit_OBJECTS = cubeit.$(OBJEXT) cell.$(OBJEXT) \ +@HAVE_CAIRO_TRUE@ hdf5-file.$(OBJEXT) utils.$(OBJEXT) \ +@HAVE_CAIRO_TRUE@ detector.$(OBJEXT) render.$(OBJEXT) \ +@HAVE_CAIRO_TRUE@ filters.$(OBJEXT) image.$(OBJEXT) \ +@HAVE_CAIRO_TRUE@ symmetry.$(OBJEXT) stream.$(OBJEXT) \ +@HAVE_CAIRO_TRUE@ thread-pool.$(OBJEXT) cubeit_OBJECTS = $(am_cubeit_OBJECTS) cubeit_DEPENDENCIES = am_estimate_background_OBJECTS = estimate_background.$(OBJEXT) \ @@ -180,7 +185,7 @@ SOURCES = $(calibrate_detector_SOURCES) $(check_hkl_SOURCES) \ $(process_hkl_SOURCES) $(reintegrate_SOURCES) \ $(render_hkl_SOURCES) DIST_SOURCES = $(calibrate_detector_SOURCES) $(check_hkl_SOURCES) \ - $(compare_hkl_SOURCES) $(cubeit_SOURCES) \ + $(compare_hkl_SOURCES) $(am__cubeit_SOURCES_DIST) \ $(estimate_background_SOURCES) $(facetron_SOURCES) \ $(get_hkl_SOURCES) $(am__hdfsee_SOURCES_DIST) \ $(am__indexamajig_SOURCES_DIST) \ @@ -333,10 +338,10 @@ facetron_SOURCES = facetron.c cell.c hdf5-file.c utils.c detector.c peaks.c \ beam-parameters.c symmetry.c post-refinement.c hrs-scaling.c facetron_LDADD = @LIBS@ -cubeit_SOURCES = cubeit.c cell.c hdf5-file.c utils.c detector.c render.c \ - filters.c image.c symmetry.c stream.c thread-pool.c +@HAVE_CAIRO_TRUE@cubeit_SOURCES = cubeit.c cell.c hdf5-file.c utils.c detector.c render.c \ +@HAVE_CAIRO_TRUE@ filters.c image.c symmetry.c stream.c thread-pool.c -cubeit_LDADD = @LIBS@ +@HAVE_CAIRO_TRUE@cubeit_LDADD = @LIBS@ reintegrate_SOURCES = reintegrate.c cell.c hdf5-file.c utils.c detector.c \ peaks.c image.c stream.c \ index.c dirax.c templates.c geometry.c symmetry.c \ diff --git a/src/cubeit.c b/src/cubeit.c index 4b32e11b..c5766d6f 100644 --- a/src/cubeit.c +++ b/src/cubeit.c @@ -25,6 +25,7 @@ #include #include #include +#include #include "utils.h" #include "hdf5-file.h" diff --git a/src/render.c b/src/render.c index 2cc6a63b..98fb693d 100644 --- a/src/render.c +++ b/src/render.c @@ -13,8 +13,12 @@ #include #endif -#include + +#ifdef HAVE_GTK #include +#endif + +#include #include #include #include @@ -27,81 +31,6 @@ #include "utils.h" -static void *render_bin(float *in, int inw, int inh, int binning, float *maxp) -{ - float *data; - int x, y; - int w, h; - float max; - - w = inw / binning; - h = inh / binning; /* Some pixels might get discarded */ - - data = malloc(w*h*sizeof(float)); - max = 0.0; - - for ( x=0; x max ) max = data[x+w*y]; - - } - } - - *maxp = max; - return data; -} - - -float *render_get_image_binned(DisplayWindow *dw, int binning, float *max) -{ - struct image *image; - float *data; - - if ( (dw->image == NULL) || (dw->image_dirty) ) { - - image = malloc(sizeof(struct image)); - if ( image == NULL ) return NULL; - image->features = NULL; - image->data = NULL; - - /* We don't care about the photon energy here */ - hdf5_read(dw->hdfile, image, 1, 0.0); - dw->image_dirty = 0; - if ( dw->cmfilter ) filter_cm(image); - if ( dw->noisefilter ) filter_noise(image, NULL); - - /* Deal with the old image, if existing */ - if ( dw->image != NULL ) { - image->features = dw->image->features; - if ( dw->image->data != NULL ) free(dw->image->data); - free(dw->image); - } - - dw->image = image; - - } - - data = render_bin(dw->image->data, hdfile_get_width(dw->hdfile), - hdfile_get_height(dw->hdfile), binning, max); - - return data; -} - - static void render_rgb(float val, float max, float *rp, float *gp, float *bp) { int s; @@ -201,6 +130,84 @@ void render_scale(float val, float max, int scale, } +#ifdef HAVE_GTK + + +static void *render_bin(float *in, int inw, int inh, int binning, float *maxp) +{ + float *data; + int x, y; + int w, h; + float max; + + w = inw / binning; + h = inh / binning; /* Some pixels might get discarded */ + + data = malloc(w*h*sizeof(float)); + max = 0.0; + + for ( x=0; x max ) max = data[x+w*y]; + + } + } + + *maxp = max; + return data; +} + + +float *render_get_image_binned(DisplayWindow *dw, int binning, float *max) +{ + struct image *image; + float *data; + + if ( (dw->image == NULL) || (dw->image_dirty) ) { + + image = malloc(sizeof(struct image)); + if ( image == NULL ) return NULL; + image->features = NULL; + image->data = NULL; + + /* We don't care about the photon energy here */ + hdf5_read(dw->hdfile, image, 1, 0.0); + dw->image_dirty = 0; + if ( dw->cmfilter ) filter_cm(image); + if ( dw->noisefilter ) filter_noise(image, NULL); + + /* Deal with the old image, if existing */ + if ( dw->image != NULL ) { + image->features = dw->image->features; + if ( dw->image->data != NULL ) free(dw->image->data); + free(dw->image); + } + + dw->image = image; + + } + + data = render_bin(dw->image->data, hdfile_get_width(dw->hdfile), + hdfile_get_height(dw->hdfile), binning, max); + + return data; +} + + /* NB This function is shared between render_get_image() and * render_get_colour_scale() */ static void render_free_data(guchar *data, gpointer p) @@ -250,7 +257,6 @@ static void show_marked_features(struct image *image, guchar *data, } -#ifdef HAVE_GTK /* Return a pixbuf containing a rendered version of the image after binning. * This pixbuf might be scaled later - hopefully mostly in a downward * direction. */ @@ -345,7 +351,6 @@ GdkPixbuf *render_get_colour_scale(size_t w, size_t h, int scale) return gdk_pixbuf_new_from_data(data, GDK_COLORSPACE_RGB, FALSE, 8, w, h, w*3, render_free_data, NULL); } -#endif /* HAVE_GTK */ int render_png(DisplayWindow *dw, const char *filename) @@ -566,3 +571,5 @@ int render_tiff_int16(DisplayWindow *dw, const char *filename) #endif return 0; } + +#endif /* HAVE_GTK */ diff --git a/src/render.h b/src/render.h index 902ec278..ae9fb637 100644 --- a/src/render.h +++ b/src/render.h @@ -20,7 +20,7 @@ #include -#include "displaywindow.h" + #include "image.h" enum { @@ -32,18 +32,21 @@ enum { extern void render_scale(float val, float max, int scale, float *rp, float *gp, float *bp); + #ifdef HAVE_GTK #include +#include "displaywindow.h" extern GdkPixbuf *render_get_image(DisplayWindow *dw); extern GdkPixbuf *render_get_colour_scale(size_t w, size_t h, int scale); -#endif /* HAVE_GTK */ - extern int render_png(DisplayWindow *dw, const char *filename); extern int render_tiff_fp(DisplayWindow *dw, const char *filename); extern int render_tiff_int16(DisplayWindow *dw, const char *filename); +#endif /* HAVE_GTK */ + + #endif /* RENDER_H */ -- cgit v1.2.3