Added a "plot svg" command that, when used in conjuction with the

Cairo graphics package (magic -d XR), will map the display onto
an SVG surface and save it to a file using the Cairo SVG backend.
Due to the simplicity of the mapping, there are no options to this
plot command;  it just creates a file that is a (scalable!)
replica of the layout window.
This commit is contained in:
Tim Edwards
2019-03-12 13:29:24 -04:00
parent c08ddd355f
commit 1f3a512909
2 changed files with 65 additions and 1 deletions
+39
View File
@@ -22,6 +22,7 @@
#include <X11/keysym.h>
#include <cairo/cairo-xlib.h>
#include <cairo/cairo-svg.h>
#include "tcltk/tclmagic.h"
#include "utils/main.h"
@@ -342,9 +343,47 @@ GrTCairoFlush ()
}
/*
*---------------------------------------------------------
* Generate SVG graphics output
*---------------------------------------------------------
*/
void
GrTCairoPlotSVG (char *filename, MagWindow *mw)
{
int screenw, screenh;
cairo_surface_t *wind_surface;
cairo_t *wind_context;
TCairoData *tcairodata = (TCairoData *)mw->w_grdata2;
if (tcairodata == NULL)
{
TxError("Must be running in mode \"-d XR\" (CAIRO) to get SVG output.\n");
return;
}
screenw = mw->w_screenArea.r_xtop - mw->w_screenArea.r_xbot;
screenh = mw->w_screenArea.r_ytop - mw->w_screenArea.r_ybot;
wind_surface = tcairodata->surface;
wind_context = tcairodata->context;
tcairodata->surface = (cairo_surface_t *)cairo_svg_surface_create(filename,
(double)screenw, (double)screenh);
tcairodata->context = cairo_create(tcairodata->surface);
WindRedisplay(mw);
WindUpdate();
cairo_surface_destroy(tcairodata->surface);
cairo_destroy(tcairodata->context);
tcairodata->surface = wind_surface;
tcairodata->context = wind_context;
WindRedisplay(mw);
WindUpdate();
return;
}
/*
*---------------------------------------------------------
* Set the Cairo projection matrix for a window