aboutsummaryrefslogtreecommitdiff
path: root/src
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 /src
parent06238f6deee66dc1a90920f335cab5af88e6693c (diff)
Add scaling report skeleton
Diffstat (limited to 'src')
-rw-r--r--src/partialator.c5
-rw-r--r--src/scaling-report.c69
-rw-r--r--src/scaling-report.h34
3 files changed, 107 insertions, 1 deletions
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 */