aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2011-07-08 17:56:15 +0200
committerThomas White <taw@physics.org>2012-02-22 15:27:32 +0100
commitf2473f3f3c29b6d4b1193393c77ca4d21921be4e (patch)
tree7ddf1d229ca8672df4410cc6ff89eeb6a0461433
parent06238f6deee66dc1a90920f335cab5af88e6693c (diff)
Add scaling report skeleton
-rw-r--r--Makefile.am6
-rw-r--r--Makefile.in36
-rwxr-xr-xconfigure15
-rw-r--r--configure.ac2
-rw-r--r--src/partialator.c5
-rw-r--r--src/scaling-report.c69
-rw-r--r--src/scaling-report.h34
7 files changed, 153 insertions, 14 deletions
diff --git a/Makefile.am b/Makefile.am
index 489a5dd2..a2fdb3c0 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -121,6 +121,10 @@ src_partialator_SOURCES = src/partialator.c src/cell.c src/hdf5-file.c \
src/symmetry.c src/post-refinement.c \
src/hrs-scaling.c src/reflist.c
+if HAVE_CAIRO
+src_partialator_SOURCES += src/scaling-report.c
+endif
+
if BUILD_CUBEIT
src_cubeit_SOURCES = src/cubeit.c src/cell.c src/hdf5-file.c src/utils.c \
src/detector.c src/render.c src/filters.c src/image.c \
@@ -158,7 +162,7 @@ EXTRA_DIST += src/cell.h src/hdf5-file.h src/image.h src/utils.h \
src/symmetry.h src/povray.h src/index-priv.h src/geometry.h \
src/render_hkl.h src/stream.h src/thread-pool.h \
src/beam-parameters.h src/post-refinement.h src/hrs-scaling.h \
- src/reflist.h
+ src/reflist.h src/scaling-report.h
crystfeldir = $(datadir)/crystfel
crystfel_DATA = data/diffraction.cl data/defs.h data/hdfsee.ui
diff --git a/Makefile.in b/Makefile.in
index 2ca908cd..df5dd25d 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -55,6 +55,7 @@ TESTS = tests/list_check$(EXEEXT) tests/first_merge_check \
@HAVE_OPENCL_TRUE@am__append_4 = tests/gpu_sim_check
@HAVE_OPENCL_TRUE@am__append_5 = tests/gpu_sim_check
@HAVE_OPENCL_TRUE@am__append_6 = src/diffraction-gpu.c src/cl-utils.c
+@HAVE_CAIRO_TRUE@am__append_7 = src/scaling-report.c
subdir = .
DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in $(srcdir)/config.h.in \
@@ -191,6 +192,13 @@ am_src_partial_sim_OBJECTS = src/partial_sim.$(OBJEXT) \
src_partial_sim_OBJECTS = $(am_src_partial_sim_OBJECTS)
src_partial_sim_LDADD = $(LDADD)
src_partial_sim_DEPENDENCIES = $(top_builddir)/lib/libgnu.a
+am__src_partialator_SOURCES_DIST = src/partialator.c src/cell.c \
+ src/hdf5-file.c src/utils.c src/detector.c src/peaks.c \
+ src/image.c src/geometry.c src/reflist-utils.c src/stream.c \
+ src/thread-pool.c src/beam-parameters.c src/symmetry.c \
+ src/post-refinement.c src/hrs-scaling.c src/reflist.c \
+ src/scaling-report.c
+@HAVE_CAIRO_TRUE@am__objects_2 = src/scaling-report.$(OBJEXT)
am_src_partialator_OBJECTS = src/partialator.$(OBJEXT) \
src/cell.$(OBJEXT) src/hdf5-file.$(OBJEXT) src/utils.$(OBJEXT) \
src/detector.$(OBJEXT) src/peaks.$(OBJEXT) src/image.$(OBJEXT) \
@@ -198,7 +206,7 @@ am_src_partialator_OBJECTS = src/partialator.$(OBJEXT) \
src/stream.$(OBJEXT) src/thread-pool.$(OBJEXT) \
src/beam-parameters.$(OBJEXT) src/symmetry.$(OBJEXT) \
src/post-refinement.$(OBJEXT) src/hrs-scaling.$(OBJEXT) \
- src/reflist.$(OBJEXT)
+ src/reflist.$(OBJEXT) $(am__objects_2)
src_partialator_OBJECTS = $(am_src_partialator_OBJECTS)
src_partialator_LDADD = $(LDADD)
src_partialator_DEPENDENCIES = $(top_builddir)/lib/libgnu.a
@@ -334,9 +342,10 @@ DIST_SOURCES = $(contrib_alter_stream_SOURCES) \
$(src_compare_hkl_SOURCES) $(am__src_cubeit_SOURCES_DIST) \
$(src_get_hkl_SOURCES) $(am__src_hdfsee_SOURCES_DIST) \
$(am__src_indexamajig_SOURCES_DIST) $(src_partial_sim_SOURCES) \
- $(src_partialator_SOURCES) $(am__src_pattern_sim_SOURCES_DIST) \
- $(src_powder_plot_SOURCES) $(src_process_hkl_SOURCES) \
- $(src_render_hkl_SOURCES) $(src_sum_stack_SOURCES) \
+ $(am__src_partialator_SOURCES_DIST) \
+ $(am__src_pattern_sim_SOURCES_DIST) $(src_powder_plot_SOURCES) \
+ $(src_process_hkl_SOURCES) $(src_render_hkl_SOURCES) \
+ $(src_sum_stack_SOURCES) \
$(am__tests_gpu_sim_check_SOURCES_DIST) \
$(tests_integration_check_SOURCES) $(tests_list_check_SOURCES) \
$(tests_pr_gradient_check_SOURCES)
@@ -633,8 +642,8 @@ EXTRA_DIST = configure m4/gnulib-cache.m4 tests/first_merge_check \
src/symmetry.h src/povray.h src/index-priv.h src/geometry.h \
src/render_hkl.h src/stream.h src/thread-pool.h \
src/beam-parameters.h src/post-refinement.h src/hrs-scaling.h \
- src/reflist.h $(crystfel_DATA) doc/twin-calculator.pdf \
- doc/examples/lcls-dec.geom \
+ src/reflist.h src/scaling-report.h $(crystfel_DATA) \
+ doc/twin-calculator.pdf doc/examples/lcls-dec.geom \
doc/examples/lcls-june-r0013-r0128.geom \
doc/examples/lcls-xpp-estimate.geom doc/examples/simple.geom \
doc/examples/lcls-dec.beam doc/examples/lcls-june.beam \
@@ -718,12 +727,11 @@ src_calibrate_detector_SOURCES = src/calibrate_detector.c src/utils.c \
src/symmetry.c src/peaks.c
src_partialator_SOURCES = src/partialator.c src/cell.c src/hdf5-file.c \
- src/utils.c src/detector.c src/peaks.c src/image.c \
- src/geometry.c src/reflist-utils.c src/stream.c \
- src/thread-pool.c src/beam-parameters.c \
- src/symmetry.c src/post-refinement.c \
- src/hrs-scaling.c src/reflist.c
-
+ src/utils.c src/detector.c src/peaks.c src/image.c \
+ src/geometry.c src/reflist-utils.c src/stream.c \
+ src/thread-pool.c src/beam-parameters.c src/symmetry.c \
+ src/post-refinement.c src/hrs-scaling.c src/reflist.c \
+ $(am__append_7)
@BUILD_CUBEIT_TRUE@src_cubeit_SOURCES = src/cubeit.c src/cell.c src/hdf5-file.c src/utils.c \
@BUILD_CUBEIT_TRUE@ src/detector.c src/render.c src/filters.c src/image.c \
@BUILD_CUBEIT_TRUE@ src/symmetry.c src/stream.c src/thread-pool.c \
@@ -974,6 +982,8 @@ src/post-refinement.$(OBJEXT): src/$(am__dirstamp) \
src/$(DEPDIR)/$(am__dirstamp)
src/hrs-scaling.$(OBJEXT): src/$(am__dirstamp) \
src/$(DEPDIR)/$(am__dirstamp)
+src/scaling-report.$(OBJEXT): src/$(am__dirstamp) \
+ src/$(DEPDIR)/$(am__dirstamp)
src/partialator$(EXEEXT): $(src_partialator_OBJECTS) $(src_partialator_DEPENDENCIES) src/$(am__dirstamp)
@rm -f src/partialator$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(src_partialator_OBJECTS) $(src_partialator_LDADD) $(LIBS)
@@ -1068,6 +1078,7 @@ mostlyclean-compile:
-rm -f src/reflist.$(OBJEXT)
-rm -f src/render.$(OBJEXT)
-rm -f src/render_hkl.$(OBJEXT)
+ -rm -f src/scaling-report.$(OBJEXT)
-rm -f src/statistics.$(OBJEXT)
-rm -f src/stream.$(OBJEXT)
-rm -f src/sum_stack.$(OBJEXT)
@@ -1117,6 +1128,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/reflist.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/render.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/render_hkl.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/scaling-report.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/statistics.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/stream.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/sum_stack.Po@am__quote@
diff --git a/configure b/configure
index d5f96eb3..e47de008 100755
--- a/configure
+++ b/configure
@@ -616,6 +616,8 @@ HTML_DIR
GTKDOC_MKPDF
GTKDOC_REBASE
GTKDOC_CHECK
+HAVE_CAIRO_FALSE
+HAVE_CAIRO_TRUE
BUILD_CUBEIT_FALSE
BUILD_CUBEIT_TRUE
BUILD_HDFSEE_FALSE
@@ -7565,6 +7567,15 @@ else
fi
+ if test x$have_cairo = xtrue; then
+ HAVE_CAIRO_TRUE=
+ HAVE_CAIRO_FALSE='#'
+else
+ HAVE_CAIRO_TRUE='#'
+ HAVE_CAIRO_FALSE=
+fi
+
+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler flag to ignore unused libraries" >&5
@@ -8028,6 +8039,10 @@ if test -z "${BUILD_CUBEIT_TRUE}" && test -z "${BUILD_CUBEIT_FALSE}"; then
as_fn_error $? "conditional \"BUILD_CUBEIT\" 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
+fi
if test -z "${ENABLE_GTK_DOC_TRUE}" && test -z "${ENABLE_GTK_DOC_FALSE}"; then
as_fn_error $? "conditional \"ENABLE_GTK_DOC\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
diff --git a/configure.ac b/configure.ac
index eaac7a4b..d390602a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -239,6 +239,8 @@ AM_CONDITIONAL([BUILD_HDFSEE], test x$have_gdk_pixbuf = xtrue \
AM_CONDITIONAL([BUILD_CUBEIT], test x$have_cairo = xtrue \
-a x$have_libpng = xtrue)
+AM_CONDITIONAL([HAVE_CAIRO], test x$have_cairo = xtrue)
+
gl_IGNORE_UNUSED_LIBRARIES
diff --git a/src/partialator.c b/src/partialator.c
index b3d40b02..97c10a7b 100644
--- a/src/partialator.c
+++ b/src/partialator.c
@@ -36,6 +36,7 @@
#include "hrs-scaling.h"
#include "reflist.h"
#include "reflist-utils.h"
+#include "scaling-report.h"
static void show_help(const char *s)
@@ -357,7 +358,6 @@ int main(int argc, char *argv[])
ERROR("Failed to open input file '%s'\n", infile);
return 1;
}
- free(infile);
/* Sanitise output filename */
if ( outfile == NULL ) {
@@ -544,6 +544,8 @@ int main(int argc, char *argv[])
/* Output results */
write_reflist(outfile, full, images[0].indexed_cell);
+ scaling_report("scaling-report.pdf", images, n_usable_patterns, infile);
+
/* Clean up */
for ( i=0; i<n_usable_patterns; i++ ) {
reflist_free(images[i].reflections);
@@ -561,6 +563,7 @@ int main(int argc, char *argv[])
free(images[i].filename);
}
free(images);
+ free(infile);
return 0;
}
diff --git a/src/scaling-report.c b/src/scaling-report.c
new file mode 100644
index 00000000..de0e396e
--- /dev/null
+++ b/src/scaling-report.c
@@ -0,0 +1,69 @@
+/*
+ * scaling-report.c
+ *
+ * Write a nice PDF of scaling parameters
+ *
+ * (c) 2011 Thomas White <taw@physics.org>
+ *
+ * Part of CrystFEL - crystallography with a FEL
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <cairo.h>
+#include <cairo-pdf.h>
+#include <pango/pangocairo.h>
+
+#include "image.h"
+
+
+static void write_title(cairo_t *cr, const char *filename, double w, double h)
+{
+ char text[1024];
+ PangoLayout *layout;
+ PangoFontDescription *fontdesc;
+ int width, height;
+
+ snprintf(text, 1023, "Scaling report: %s", filename);
+
+ layout = pango_cairo_create_layout(cr);
+ pango_layout_set_text(layout, text, -1);
+ fontdesc = pango_font_description_from_string("Sans 14 Bold");
+ pango_layout_set_font_description(layout, fontdesc);
+
+ pango_cairo_update_layout(cr, layout);
+ pango_layout_get_size(layout, &width, &height);
+
+ cairo_move_to(cr, 0.5-width/PANGO_SCALE, 10.0);
+
+ cairo_set_source_rgb(cr, 0.0, 0.0, 0.0);
+ pango_cairo_show_layout(cr, layout);
+}
+
+
+void scaling_report(const char *filename, const struct image *images, int n,
+ const char *stream_filename)
+{
+ cairo_surface_t *surface;
+ cairo_t *cr;
+ const double w = 842.0;
+ const double h = 595.0;
+
+ surface = cairo_pdf_surface_create(filename, w, h);
+
+ if ( cairo_surface_status(surface) != CAIRO_STATUS_SUCCESS ) {
+ fprintf(stderr, "Couldn't create Cairo surface\n");
+ cairo_surface_destroy(surface);
+ return;
+ }
+
+ cr = cairo_create(surface);
+
+ write_title(cr, stream_filename, w, h);
+
+ cairo_surface_finish(surface);
+ cairo_destroy(cr);
+}
diff --git a/src/scaling-report.h b/src/scaling-report.h
new file mode 100644
index 00000000..3186c5f7
--- /dev/null
+++ b/src/scaling-report.h
@@ -0,0 +1,34 @@
+/*
+ * scaling-report.h
+ *
+ * Write a nice PDF of scaling parameters
+ *
+ * (c) 2011 Thomas White <taw@physics.org>
+ *
+ * Part of CrystFEL - crystallography with a FEL
+ *
+ */
+
+#ifndef SCALING_REPORT_H
+#define SCALING_REPORT_H
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+
+#include "utils.h"
+
+#ifdef HAVE_CAIRO
+extern void scaling_report(const char *filename, const struct image *images,
+ int n, const char *stream_filename);
+#else
+static inline void scaling_report(const char *filename,
+ const struct image *images, int n,
+ const char *stream_filename)
+{
+ ERROR("Not writing scaling report - no Cairo support.\n");
+}
+#endif
+
+#endif /* SCALING_REPORT_H */