gvrender_end_edge(gvc);
}
+static void init_gvc_from_graph(GVC_t * gvc, graph_t * g)
+{
+ double xf, yf;
+ char *p;
+ int i;
+
+ /* margins */
+ gvc->graph_sets_margin = FALSE;
+ if ((p = agget(g, "margin"))) {
+ i = sscanf(p, "%lf,%lf", &xf, &yf);
+ if (i > 0) {
+ gvc->margin.x = gvc->margin.y = xf * POINTS_PER_INCH;
+ if (i > 1)
+ gvc->margin.y = yf * POINTS_PER_INCH;
+ gvc->graph_sets_margin = TRUE;
+ }
+ }
+
+ /* pagesize */
+ gvc->graph_sets_pageSize = FALSE;
+ P2PF(GD_drawing(g)->page, gvc->pageSize);
+ if ((GD_drawing(g)->page.x > 0) && (GD_drawing(g)->page.y > 0)) {
+ gvc->graph_sets_pageSize = TRUE;
+ }
+
+ /* bounding box */
+ B2BF(GD_bb(g),gvc->bb);
+
+ /* rotation */
+ gvc->rotation = GD_drawing(g)->landscape ? 90 : 0;
+
+ /* clusters have peripheries */
+ G_peripheries = agfindattr(g, "peripheries");
+
+ /* default font */
+ gvc->defaultfontname = late_nnstring(g->proto->n,
+ N_fontname, DEFAULT_FONTNAME);
+ gvc->defaultfontsize = late_double(g->proto->n,
+ N_fontsize, DEFAULT_FONTSIZE, MIN_FONTSIZE);
+
+ /* default line style */
+ gvc->defaultlinestyle = defaultlinestyle;
+
+ gvc->graphname = g->name;
+ gvc->lib = Lib;
+}
+
+
static void init_job_margin(GVC_t *gvc)
{
gvrender_job_t *job = gvc->job;
}
}
+static void init_job_dpi(GVC_t *gvc, graph_t *g)
+{
+ gvrender_job_t *job = gvc->job;
+
+ job->dpi = GD_drawing(g)->dpi;
+ if (job->dpi == 0) {
+ /* set default margins depending on format */
+ switch (job->output_lang) {
+ case GVRENDER_PLUGIN:
+ job->dpi = job->render_features->default_dpi;
+ break;
+ case POSTSCRIPT:
+ job->dpi = POINTS_PER_INCH;
+ break;
+ default:
+ job->dpi = DEFAULT_DPI;
+ break;
+ }
+ }
+}
+
static void init_job_viewport(GVC_t * gvc, graph_t * g)
{
gvrender_job_t * job = gvc->job;
pointf UR, size;
char *str;
double X, Y, Z, x, y;
- int dpi;
assert((GD_bb(g).LL.x == 0) && (GD_bb(g).LL.y == 0));
Z = MIN(size.x/UR.x, size.y/UR.y);
}
- dpi = GD_drawing(g)->dpi;
- if (dpi == 0) {
- if (job->render_engine)
- dpi = job->render_features->default_dpi;
- else {
- /* WARNING - nasty hack to avoid modifying old codegens */
- codegen_t *cg = job->codegen;
- if (cg == &PS_CodeGen)
- dpi = POINTS_PER_INCH;
- else
- dpi = DEFAULT_DPI;
- }
- }
- job->dpi = dpi;
-
/* default focus, in graph units = center of bb */
x = UR.x / 2.;
y = UR.y / 2.;
/* rotate and scale bb to give default device width and height */
if (GD_drawing(g)->landscape)
UR = exch_xyf(UR);
- X = Z * (UR.x + 2 * job->margin.x) * dpi / POINTS_PER_INCH;
- Y = Z * (UR.y + 2 * job->margin.y) * dpi / POINTS_PER_INCH;
+ X = Z * (UR.x + 2 * job->margin.x) * job->dpi / POINTS_PER_INCH;
+ Y = Z * (UR.y + 2 * job->margin.y) * job->dpi / POINTS_PER_INCH;
/* user can override */
if ((str = agget(g, "viewport")))
job->rotation = gvc->rotation;
}
-static void init_gvc_from_graph(GVC_t * gvc, graph_t * g)
-{
- double xf, yf;
- char *p;
- int i;
-
- /* margins */
- gvc->graph_sets_margin = FALSE;
- if ((p = agget(g, "margin"))) {
- i = sscanf(p, "%lf,%lf", &xf, &yf);
- if (i > 0) {
- gvc->margin.x = gvc->margin.y = xf * POINTS_PER_INCH;
- if (i > 1)
- gvc->margin.y = yf * POINTS_PER_INCH;
- gvc->graph_sets_margin = TRUE;
- }
- }
-
- /* pagesize */
- gvc->graph_sets_pageSize = FALSE;
- P2PF(GD_drawing(g)->page, gvc->pageSize);
- if ((GD_drawing(g)->page.x > 0) && (GD_drawing(g)->page.y > 0)) {
- gvc->graph_sets_pageSize = TRUE;
- }
-
- /* bounding box */
- B2BF(GD_bb(g),gvc->bb);
-
- /* rotation */
- gvc->rotation = GD_drawing(g)->landscape ? 90 : 0;
-
- /* clusters have peripheries */
- G_peripheries = agfindattr(g, "peripheries");
-
- /* default font */
- gvc->defaultfontname = late_nnstring(g->proto->n, N_fontname, DEFAULT_FONTNAME);
- gvc->defaultfontsize = late_double(g->proto->n, N_fontsize, DEFAULT_FONTSIZE,
- MIN_FONTSIZE);
-
- /* default line style */
- gvc->defaultlinestyle = defaultlinestyle;
-
- gvc->graphname = g->name;
- gvc->lib = Lib;
-}
-
-
/* emit_init
* - called just once per output device
* (where emit_graph can be called many times for refresh callbacks)
init_layering(gvc, g);
init_job_flags(gvc->job, g);
init_job_margin(gvc);
+ init_job_dpi(gvc, g);
init_job_viewport(gvc, g);
init_job_pagination(gvc, g);
gvrender_begin_job(gvc);