From ecb9dc67c50139e29a23a2406e11efd70f123dea Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Fri, 8 Nov 2013 16:18:58 -0800 Subject: [PATCH] Add SVG export. This is cheesy for now, (using a hard-coded output filename). --- acre-x.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/acre-x.c b/acre-x.c index 80b86de..e62c596 100644 --- a/acre-x.c +++ b/acre-x.c @@ -24,6 +24,8 @@ #include #include + +#include #include #include "acre.h" @@ -117,6 +119,24 @@ draw (Display *dpy, Window window, Visual *visual, acre_t *acre, cairo_surface_destroy (surface); } +static void +draw_svg (acre_t *acre, int width, int height, double x_min, double x_max) +{ + cairo_t *cr; + cairo_surface_t *surface; + + surface = cairo_svg_surface_create ("acre-fips.svg", width, height); + + cr = cairo_create (surface); + + acre_set_x_axis_range (acre, x_min, x_max); + acre_draw (acre, cr, width, height); + + cairo_destroy (cr); + + cairo_surface_destroy (surface); +} + static void handle_events(Display *dpy, Window window, Visual *visual, @@ -131,6 +151,7 @@ handle_events(Display *dpy, Window window, Visual *visual, KeyCode equal_code = XKeysymToKeycode (dpy, XStringToKeysym("equal")); KeyCode minus_code = XKeysymToKeycode (dpy, XStringToKeysym("minus")); KeyCode home_code = XKeysymToKeycode (dpy, XStringToKeysym("Home")); + KeyCode svg_code = XKeysymToKeycode (dpy, XStringToKeysym("S")); KeyCode keycode; bool need_redraw = false; double x_min, x_max, shift; @@ -183,6 +204,11 @@ handle_events(Display *dpy, Window window, Visual *visual, { acre_get_x_axis_data_range (acre, &x_min, &x_max); } + else if (keycode == svg_code) + { + need_redraw = false; + draw_svg (acre, width, height, x_min, x_max); + } else { need_redraw = false; -- 2.43.0