static int N_pages;
/* static point Pages; */
-static double Scale;
-static pointf Offset;
static int Rot;
-static box PB;
static int onetime = TRUE;
+static int Dpi;
+static pointf CompScale;
+static int Rot;
+
+static point Viewport;
+static pointf GraphFocus;
+static double Zoom;
+
static node_t *Curnode;
typedef struct context_t {
{
point rv;
- if (Rot == 0) {
- rv.x = PB.LL.x / Scale + p.x + Offset.x;
- rv.y = PB.UR.y / Scale - 1 - p.y - Offset.y;
+ if (Rot) {
+ rv.x = ROUND(-(p.y - GraphFocus.y) * CompScale.x + Viewport.x / 2.);
+ rv.y = ROUND((p.x - GraphFocus.x) * CompScale.y + Viewport.y / 2.);
} else {
- rv.x = PB.UR.x / Scale - 1 - p.y - Offset.x;
- rv.y = PB.UR.y / Scale - 1 - p.x - Offset.y;
+ rv.x = ROUND((p.x - GraphFocus.x) * CompScale.x + Viewport.x / 2.);
+ rv.y = ROUND((p.y - GraphFocus.y) * CompScale.y + Viewport.y / 2.);
}
return rv;
}
svg_fputs("<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.0//EN\"\n");
svg_fputs
(" \"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd\"");
-#if 1
/* This is to work around a bug in the SVG 1.0 DTD */
- if ((agfindattr(g, "href")
- || agfindattr(g->proto->n, "href")
- || agfindattr(g->proto->e, "href")
- || agfindattr(g, "URL")
- || agfindattr(g->proto->n, "URL")
- || agfindattr(g->proto->e, "URL"))) {
- svg_fputs
- (" [\n <!ATTLIST svg xmlns:xlink CDATA #FIXED \"http://www.w3.org/1999/xlink\">\n]");
- }
-#endif
+ svg_fputs
+ (" [\n <!ATTLIST svg xmlns:xlink CDATA #FIXED \"http://www.w3.org/1999/xlink\">\n]");
svg_fputs(">\n<!-- Generated by ");
svg_fputs(xml_string(info[0]));
svg_fputs(" version ");
svg_fputs(xml_string(info[2]));
svg_fputs(")\n For user: ");
svg_fputs(xml_string(user));
- svg_fputs(" Title: ");
- svg_fputs(xml_string(g->name));
- svg_printf(" Pages: %d -->\n", N_pages);
+ svg_fputs(" -->\n");
}
static void svg_begin_graph(GVC_t * gvc, graph_t * g, box bb, point pb)
{
- double dpi = GD_drawing(g)->dpi;
+ Dpi = gvc->job->dpi;
+ Viewport.x = gvc->job->width;
+ Viewport.y = gvc->job->height;
+ Zoom = gvc->job->zoom;
+ GraphFocus = gvc->job->focus;
+ CompScale = gvc->job->compscale;
- PB.LL.x = PB.LL.y = 0;
- PB.UR.x = (bb.UR.x - bb.LL.x + 2 * GD_drawing(g)->margin.x) * SCALE;
- PB.UR.y = (bb.UR.y - bb.LL.y + 2 * GD_drawing(g)->margin.y) * SCALE;
- Offset.x = GD_drawing(g)->margin.x * SCALE;
- Offset.y = GD_drawing(g)->margin.y * SCALE;
if (onetime) {
-#if 0
- fprintf(stderr, "LL %d %d UR %d %d\n", PB.LL.x, PB.LL.y, PB.UR.x,
- PB.UR.y);
-#endif
init_svg();
onetime = FALSE;
}
- if (dpi < 1.0)
+ svg_fputs("<!-- Title: ");
+ svg_fputs(xml_string(g->name));
+ svg_printf(" Pages: %d -->\n", N_pages);
+ if (Dpi == POINTS_PER_INCH)
svg_printf("<svg width=\"%dpt\" height=\"%dpt\"\n",
- PB.UR.x - PB.LL.x + 2, PB.UR.y - PB.LL.y + 2);
+ Viewport.x, Viewport.y);
else
svg_printf("<svg width=\"%dpx\" height=\"%dpx\"\n",
- ROUND(dpi / POINTS_PER_INCH) * (PB.UR.x - PB.LL.x + 2),
- ROUND(dpi / POINTS_PER_INCH) * (PB.UR.y - PB.LL.y + 2));
+ Dpi * Viewport.x / POINTS_PER_INCH,
+ Dpi * Viewport.y / POINTS_PER_INCH);
/* establish absolute units in points */
- svg_printf(" viewBox = \"%d %d %d %d\"\n", PB.LL.x - 1, PB.LL.y - 1,
- PB.UR.x + 1, PB.UR.y + 1);
+ svg_printf(" viewBox = \"%d %d %d %d\"\n", 0, 0, Viewport.x, Viewport.y);
/* namespace of svg */
svg_fputs(" xmlns=\"http://www.w3.org/2000/svg\"");
- /* namespace of xlink if needed */
- if ((agfindattr(g, "href")
- || agfindattr(g->proto->n, "href")
- || agfindattr(g->proto->e, "href")
- || agfindattr(g, "URL")
- || agfindattr(g->proto->n, "URL")
- || agfindattr(g->proto->e, "URL"))) {
- svg_fputs(" xmlns:xlink=\"http://www.w3.org/1999/xlink\"");
- }
+ /* namespace of xlink */
+ svg_fputs(" xmlns:xlink=\"http://www.w3.org/1999/xlink\"");
svg_fputs(">\n");
}
svg_begin_page(graph_t * g, point page, double scale, int rot,
point offset)
{
-/* int page_number; */
- /* point sz; */
-
- Scale = scale;
Rot = rot;
-/* page_number = page.x + page.y * Pages.x + 1; */
- /* sz = sub_points(PB.UR,PB.LL); */
/* its really just a page of the graph, but its still a graph,
* and it is the entire graph if we're not currently paging */
if (Rot) {
svg_printf(" transform=\"rotate(-90 %d %d)\"", mp.x, mp.y);
}
+ svg_printf(" x=\"%d\" y=\"%d\"", mp.x, mp.y);
svg_font(cp);
- svg_printf(" x=\"%d\" y=\"%d", mp.x, mp.y);
#if 0
/* adobe svg doesn't like the dx propert */
if (line->xshow) {
svg_fputs(line->xshow);
}
#endif
- svg_fputs("\">");
+ svg_fputs(">");
svg_fputs(string);
svg_fputs("</text>\n");
}