Graphviz 13.1.2~dev.20250722.1051
Loading...
Searching...
No Matches
gvrender_core_pov.c
Go to the documentation of this file.
1/**********************************************************
2* Copyright (c) 2011 Andy Jeutter *
3* AKA HallerHarry at gmx.de *
4* All rights reserved. *
5**********************************************************/
6
7/*************************************************************************
8 * This program and the accompanying materials
9 * are made available under the terms of the Eclipse Public License v1.0
10 * which accompanies this distribution, and is available at
11 * https://www.eclipse.org/legal/epl-v10.html
12 *
13 * Contributors: Details at https://graphviz.org
14 *************************************************************************/
15
16#define _GNU_SOURCE
17#include "config.h"
18#include <assert.h>
19#include <math.h>
20#include <stdarg.h>
21#include <stdlib.h>
22#include <string.h>
23#include <ctype.h>
24#include <errno.h>
25#include <util/agxbuf.h>
26#include <util/prisize_t.h>
27
28#include <common/macros.h>
29#include <common/const.h>
30
31#include <gvc/gvplugin_render.h>
32#include <gvc/gvplugin_device.h>
33#include <gvc/gvio.h>
34#include <gvc/gvcint.h>
35
36#define POV_VERSION \
37 "#version 3.6;\n"
38
39#define POV_GLOBALS \
40 "global_settings { assumed_gamma 1.0 }\n"
41
42#define POV_DEFAULT \
43 "#default { finish { ambient 0.1 diffuse 0.9 } }\n"
44
45#define POV_INCLUDE \
46 "#include \"colors.inc\"\n"\
47 "#include \"textures.inc\"\n"\
48 "#include \"shapes.inc\"\n"
49
50#define POV_LIGHT \
51 "light_source { <1500,3000,-2500> color White }\n"
52
53#define POV_CAMERA \
54 "camera { location <%.3f , %.3f , -500.000>\n"\
55 " look_at <%.3f , %.3f , 0.000>\n"\
56 " right x * image_width / image_height\n"\
57 " angle %.3f\n"\
58 "}\n"
59
60#define POV_SKY_AND_GND \
61 "//sky\n"\
62 "plane { <0, 1, 0>, 1 hollow\n"\
63 " texture {\n"\
64 " pigment { bozo turbulence 0.95\n"\
65 " color_map {\n"\
66 " [0.00 rgb <0.05, 0.20, 0.50>]\n"\
67 " [0.50 rgb <0.05, 0.20, 0.50>]\n"\
68 " [0.75 rgb <1.00, 1.00, 1.00>]\n"\
69 " [0.75 rgb <0.25, 0.25, 0.25>]\n"\
70 " [1.00 rgb <0.50, 0.50, 0.50>]\n"\
71 " }\n"\
72 " scale <1.00, 1.00, 1.50> * 2.50\n"\
73 " translate <0.00, 0.00, 0.00>\n"\
74 " }\n"\
75 " finish { ambient 1 diffuse 0 }\n"\
76 " }\n"\
77 " scale 10000\n"\
78 "}\n"\
79 "//mist\n"\
80 "fog { fog_type 2\n"\
81 " distance 50\n"\
82 " color rgb <1.00, 1.00, 1.00> * 0.75\n"\
83 " fog_offset 0.10\n"\
84 " fog_alt 1.50\n"\
85 " turbulence 1.75\n"\
86 "}\n"\
87 "//gnd\n"\
88 "plane { <0.00, 1.00, 0.00>, 0\n"\
89 " texture {\n"\
90 " pigment{ color rgb <0.25, 0.45, 0.00> }\n"\
91 " normal { bumps 0.75 scale 0.01 }\n"\
92 " finish { phong 0.10 }\n"\
93 " }\n"\
94 "}\n"
95
96#define POV_BOX \
97 "box { <%.3f, %.3f, %.3f>, <%.3f, %.3f, %.3f>\n"
98
99#define POV_SCALE1 \
100 "scale %.3f\n"
101
102#define POV_SCALE3 \
103 "scale "POV_VECTOR3"\n"
104
105#define POV_ROTATE \
106 "rotate "POV_VECTOR3"\n"
107
108#define POV_TRANSLATE \
109 "translate<%9.3f, %9.3f, %d.000>\n"
110
111#define END \
112 "}\n"
113
114#define POV_TORUS \
115 "torus { %.3f, %.3f\n"
116
117#define POV_SPHERE_SWEEP \
118 "sphere_sweep {\n"\
119 " %s\n"\
120 " %" PRISIZE_T ",\n"
121
122#define POV_SPHERE \
123 "sphere {"POV_VECTOR3", 1.0\n" // center, radius
124
125#define POV_TEXT \
126 "text {\n"\
127 " ttf \"%s\",\n"\
128 " \"%s\", %.3f, %.3f\n"
129
130#define POV_DECLARE \
131 "#declare %s = %s;\n"
132
133#define POV_OBJECT \
134 "object { %s }\n"
135
136#define POV_VERBATIM \
137 "%s\n"
138
139#define POV_DEBUG \
140 "#debug %s\n"
141
142#define POV_POLYGON \
143 "polygon { %" PRISIZE_T ",\n"
144
145#define POV_VECTOR3 \
146 "<%9.3f, %9.3f, %9.3f>"
147
148#define POV_PIGMENT_COLOR \
149 "pigment { color %s }\n"
150
151#define POV_COLOR_NAME \
152 "%s transmit %.3f"
153
154#define POV_COLOR_RGB \
155 "rgb"POV_VECTOR3" transmit %.3f"
156
157//colors are taken from /usr/share/povray-3.6/include/colors.inc
158//list must be LANG_C sorted (all lower case)
159#define POV_COLORS \
160"aquamarine",\
161"bakerschoc",\
162"black",\
163"blue",\
164"blueviolet",\
165"brass",\
166"brightgold",\
167"bronze",\
168"bronze2",\
169"brown",\
170"cadetblue",\
171"clear",\
172"coolcopper",\
173"copper",\
174"coral",\
175"cornflowerblue",\
176"cyan",\
177"darkbrown",\
178"darkgreen",\
179"darkolivegreen",\
180"darkorchid",\
181"darkpurple",\
182"darkslateblue",\
183"darkslategray",\
184"darkslategrey",\
185"darktan",\
186"darkturquoise",\
187"darkwood",\
188"dkgreencopper",\
189"dustyrose",\
190"feldspar",\
191"firebrick",\
192"flesh",\
193"forestgreen",\
194"gold",\
195"goldenrod",\
196"gray05",\
197"gray10",\
198"gray15",\
199"gray20",\
200"gray25",\
201"gray30",\
202"gray35",\
203"gray40",\
204"gray45",\
205"gray50",\
206"gray55",\
207"gray60",\
208"gray65",\
209"gray70",\
210"gray75",\
211"gray80",\
212"gray85",\
213"gray90",\
214"gray95",\
215"green",\
216"greencopper",\
217"greenyellow",\
218"huntersgreen",\
219"indianred",\
220"khaki",\
221"lightblue",\
222"light_purple",\
223"lightsteelblue",\
224"lightwood",\
225"limegreen",\
226"magenta",\
227"mandarinorange",\
228"maroon",\
229"mediumaquamarine",\
230"mediumblue",\
231"mediumforestgreen",\
232"mediumgoldenrod",\
233"mediumorchid",\
234"mediumseagreen",\
235"mediumslateblue",\
236"mediumspringgreen",\
237"mediumturquoise",\
238"mediumvioletred",\
239"mediumwood",\
240"med_purple",\
241"mica",\
242"midnightblue",\
243"navy",\
244"navyblue",\
245"neonblue",\
246"neonpink",\
247"newmidnightblue",\
248"newtan",\
249"oldgold",\
250"orange",\
251"orangered",\
252"orchid",\
253"palegreen",\
254"pink",\
255"plum",\
256"quartz",\
257"red",\
258"richblue",\
259"salmon",\
260"scarlet",\
261"seagreen",\
262"semiSweetChoc",\
263"sienna",\
264"silver",\
265"skyblue",\
266"slateblue",\
267"spicypink",\
268"springgreen",\
269"steelblue",\
270"summersky",\
271"tan",\
272"thistle",\
273"turquoise",\
274"verydarkbrown",\
275"very_light_purple",\
276"violet",\
277"violetred",\
278"wheat",\
279"white",\
280"yellow",\
281"yellowgreen"
282
283#define GV_OBJ_EXT(type, obj, name) \
284 do { \
285 char debug_str[256]; \
286 gvprintf(job, POV_DECLARE, type, obj); \
287 gvprintf(job, POV_OBJECT, type); \
288 gvprintf(job, POV_DECLARE, "Min", "min_extent("type")"); \
289 gvprintf(job, POV_DECLARE, "Max", "max_extent("type")"); \
290 snprintf(debug_str, 256, \
291 "concat(\"Dim = \" , vstr(3, Max - Min, \", \", 0, 3)," \
292 " \" "type": %s\", \"\\n\")", name); \
293 gvprintf(job, POV_DEBUG, debug_str); \
294 } while (0)
295
296#define DPI 72.0
297#define RENDERER_COLOR_TYPE RGBA_BYTE
298enum { FORMAT_POV, };
299
300//TODO: check why this dot file does not work (90 rotated)
301// /usr/share/graphviz/graphs/directed/NaN.gv
302//TODO: add Texttures
303//TODO: check how we can receive attributes from dot file
304// if we can't receive attributes set defaults in pov include file
305// - put #include "graph-scheme-fancy.inc" in pov file
306// - run povray with +L`pwd`
307// - put e.g. #declare mycolor = Gold; in graph-scheme-fancy.inc
308// - use textures and color: pigment { color mycolor transmit 0.000 }
309//TODO: idea, put the whole graph in a declare= and then
310// print it with something along the line:
311// object{ graph translate{page->translation, ...} rotate{page->rotation, ...} }
312
313static char *pov_knowncolors[] = { POV_COLORS };
314
315static int layerz = 0;
316static int z = 0;
317
318static char *pov_color_as_str(GVJ_t * job, gvcolor_t color, float transparency)
319{
320 agxbuf c = {0};
321 switch (color.type) {
322 case COLOR_STRING:
323#ifdef DEBUG
324 gvprintf(job, "// type = %d, color = %s\n", color.type, color.u.string);
325#else
326 (void)job;
327#endif
328 if (!strcmp(color.u.string, "red"))
329 agxbprint(&c, POV_COLOR_NAME, "Red", transparency);
330 else if (!strcmp(color.u.string, "green"))
331 agxbprint(&c, POV_COLOR_NAME, "Green", transparency);
332 else if (!strcmp(color.u.string, "blue"))
333 agxbprint(&c, POV_COLOR_NAME, "Blue", transparency);
334 else
335 agxbprint(&c, POV_COLOR_NAME, color.u.string, transparency);
336 break;
338#ifdef DEBUG
339 gvprintf(job, "// type = %d, color = %d, %d, %d\n",
340 color.type, color.u.rgba[0], color.u.rgba[1],
341 color.u.rgba[2]);
342#endif
344 color.u.rgba[0] / 256.0, color.u.rgba[1] / 256.0,
345 color.u.rgba[2] / 256.0, transparency);
346 break;
347 default:
348 fprintf(stderr,
349 "oops, internal error: unhandled color type=%d %s\n",
350 color.type, color.u.string);
351 assert(0); //oops, wrong type set in gvrender_features_t?
352 }
353 agxbuf pov = {0};
355 agxbfree(&c);
356 return agxbdisown(&pov);
357}
358
359static void pov_comment(GVJ_t * job, char *str)
360{
361 gvprintf(job, "//*** comment: %s\n", str);
362}
363
364static void pov_begin_job(GVJ_t * job)
365{
366 gvputs(job, POV_VERSION);
367 gvputs(job, POV_GLOBALS);
368 gvputs(job, POV_DEFAULT);
369 gvputs(job, POV_INCLUDE);
370 gvprintf(job, POV_DECLARE, "black", "Black");
371 gvprintf(job, POV_DECLARE, "white", "White");
372}
373
374static void pov_begin_graph(GVJ_t * job)
375{
376 gvprintf(job, "//*** begin_graph %s\n", agnameof(job->obj->u.g));
377#ifdef DEBUG
378 gvprintf(job, "// graph_index = %d, pages = %d, layer = %d/%d\n",
379 job->graph_index, job->numPages, job->layerNum,
380 job->numLayers);
381 gvprintf(job, "// pagesArraySize.x,y = %d,%d\n", job->pagesArraySize.x,
382 job->pagesArraySize.y);
383 gvprintf(job, "// pagesArrayFirst.x,y = %d,%d\n",
385 gvprintf(job, "// pagesArrayElem.x,y = %d,%d\n", job->pagesArrayElem.x,
386 job->pagesArrayElem.y);
387 gvprintf(job, "// bb.LL,UR = %.3f,%.3f, %.3f,%.3f\n", job->bb.LL.x,
388 job->bb.LL.y, job->bb.UR.x, job->bb.UR.y);
389 gvprintf(job, "// pageBox in graph LL,UR = %.3f,%.3f, %.3f,%.3f\n",
390 job->pageBox.LL.x, job->pageBox.LL.y, job->pageBox.UR.x,
391 job->pageBox.UR.y);
392 gvprintf(job, "// pageSize.x,y = %.3f,%.3f\n", job->pageSize.x,
393 job->pageSize.y);
394 gvprintf(job, "// focus.x,y = %.3f,%.3f\n", job->focus.x, job->focus.y);
395 gvprintf(job, "// zoom = %.3f, rotation = %d\n", job->zoom, job->rotation);
396 gvprintf(job, "// view port.x,y = %.3f,%.3f\n", job->view.x,
397 job->view.y);
398 gvprintf(job, "// canvasBox LL,UR = %.3f,%.3f, %.3f,%.3f\n",
399 job->canvasBox.LL.x, job->canvasBox.LL.y, job->canvasBox.UR.x,
400 job->canvasBox.UR.y);
401 gvprintf(job, "// pageBoundingBox LL,UR = %d,%d, %d,%d\n",
404 gvprintf(job, "// boundingBox (all pages) LL,UR = %d,%d, %d,%d\n",
405 job->boundingBox.LL.x, job->boundingBox.LL.y,
406 job->boundingBox.UR.x, job->boundingBox.UR.y);
407 gvprintf(job, "// scale.x,y = %.3f,%.3f\n", job->scale.x, job->scale.y);
408 gvprintf(job, "// translation.x,y = %.3f,%.3f\n", job->translation.x,
409 job->translation.y);
410 gvprintf(job, "// devscale.x,y = %.3f,%.3f\n", job->devscale.x,
411 job->devscale.y);
412 gvprintf(job, "// verbose = %d\n", job->common->verbose);
413 gvprintf(job, "// cmd = %s\n", job->common->cmdname);
414 gvprintf(job, "// info = %s, %s, %s\n", job->common->info[0],
415 job->common->info[1], job->common->info[2]);
416#endif
417
418 //setup scene
419 double x = job->view.x / 2.0 * job->scale.x;
420 double y = job->view.y / 2.0 * job->scale.y;
421 double d = 500;
422 double px = atan(x / d) * 180.0 / M_PI * 2.0;
423 double py = atan(y / d) * 180.0 / M_PI * 2.0;
424 gvprintf(job, POV_CAMERA, x, y, x, y, fmax(px, py) * 1.2);
426 gvputs(job, POV_LIGHT);
427}
428
429static void pov_end_graph(GVJ_t * job)
430{
431 gvputs(job, "//*** end_graph\n");
432}
433
434static void pov_begin_layer(GVJ_t * job, char *layername, int layerNum, int numLayers)
435{
436 gvprintf(job, "//*** begin_layer: %s, %d/%d\n", layername, layerNum,
437 numLayers);
438 layerz = layerNum * -10;
439}
440
441static void pov_end_layer(GVJ_t * job)
442{
443 gvputs(job, "//*** end_layer\n");
444}
445
446static void pov_begin_page(GVJ_t * job)
447{
448 gvputs(job, "//*** begin_page\n");
449}
450
451static void pov_end_page(GVJ_t * job)
452{
453 gvputs(job, "//*** end_page\n");
454}
455
456static void pov_begin_cluster(GVJ_t * job)
457{
458 gvputs(job, "//*** begin_cluster\n");
459 layerz -= 2;
460}
461
462static void pov_end_cluster(GVJ_t * job)
463{
464 gvputs(job, "//*** end_cluster\n");
465}
466
467static void pov_begin_node(GVJ_t * job)
468{
469 gvprintf(job, "//*** begin_node: %s\n", agnameof(job->obj->u.n));
470}
471
472static void pov_end_node(GVJ_t * job)
473{
474 gvputs(job, "//*** end_node\n");
475}
476
477static void pov_begin_edge(GVJ_t * job)
478{
479 gvputs(job, "//*** begin_edge\n");
480 layerz -= 5;
481#ifdef DEBUG
482 gvprintf(job, "// layerz = %d.000\n", layerz);
483#endif
484}
485
486static void pov_end_edge(GVJ_t * job)
487{
488 gvputs(job, "//*** end_edge\n");
489 layerz += 5;
490#ifdef DEBUG
491 gvprintf(job, "// layerz = %d.000\n", layerz);
492#endif
493}
494
495static void pov_textspan(GVJ_t * job, pointf c, textspan_t * span)
496{
497 gvprintf(job, "//*** textspan: %s, fontsize = %.3f, fontname = %s\n",
498 span->str, span->font->size, span->font->name);
499 z = layerz - 9;
500
501#ifdef DEBUG
502 if (span->font->postscript_alias)
503 gvputs(job, "// Warning: postscript_alias not handled!\n");
504#endif
505
506 //handle text justification
507 switch (span->just) {
508 case 'l': //left justified
509 break;
510 case 'r': //right justified
511 c.x = c.x - span->size.x;
512 break;
513 default:
514 case 'n': //centered
515 c.x = c.x - span->size.x / 2.0;
516 break;
517 }
518
519 double x = (c.x + job->translation.x) * job->scale.x;
520 double y = (c.y + job->translation.y) * job->scale.y;
521
522 char *p = pov_color_as_str(job, job->obj->pencolor, 0.0);
523
524 //pov bundled fonts: timrom.ttf, cyrvetic.ttf
525 agxbuf pov = {0};
526 agxbprint(&pov, POV_TEXT " no_shadow\n",
527 span->font->name, span->str, 0.25, 0.0); // font, text, depth (0.5 ... 2.0), offset
528 agxbprint(&pov, " " POV_SCALE1, span->font->size * job->scale.x);
529 agxbprint(&pov, " " POV_ROTATE, 0.0, 0.0, (float)job->rotation);
530 agxbprint(&pov, " " POV_TRANSLATE, x, y, z);
531 agxbprint(&pov, " %s" END, p);
532
533#ifdef DEBUG
534 GV_OBJ_EXT("Text", agxbuse(&pov), span->str);
535 gvprintf(job, "sphere{<0, 0, 0>, 2\ntranslate<%f, %f, %d>\n"
536 "pigment{color Red}\nno_shadow\n}\n", x, y, z - 1);
537#else
538 gvputs(job, agxbuse(&pov));
539#endif
540
541 agxbfree(&pov);
542 free(p);
543}
544
545static void pov_ellipse(GVJ_t * job, pointf * A, int filled)
546{
547 gvputs(job, "//*** ellipse\n");
548 z = layerz - 6;
549
550 // A[0] center, A[1] corner of ellipse
551 const double cx = (A[0].x + job->translation.x) * job->scale.x;
552 const double cy = (A[0].y + job->translation.y) * job->scale.y;
553 const double rx = (A[1].x - A[0].x) * job->scale.x;
554 const double ry = (A[1].y - A[0].y) * job->scale.y;
555 const double w = job->obj->penwidth / (rx + ry) / 2.0 * 5;
556
557 //draw rim (torus)
558 char *p = pov_color_as_str(job, job->obj->pencolor, 0.0);
559
560 agxbuf pov = {0};
561 agxbprint(&pov, POV_TORUS, 1.0, w); // radius, size of ring
562 agxbprint(&pov, " " POV_SCALE3, rx, (rx + ry) / 4.0, ry);
563 agxbprint(&pov, " " POV_ROTATE, 90.0, 0.0, (float)job->rotation);
564 agxbprint(&pov, " " POV_TRANSLATE, cx, cy, z);
565 agxbprint(&pov, " %s" END, p);
566
567#ifdef DEBUG
568 GV_OBJ_EXT("Torus", agxbuse(&pov), "");
569 gvprintf(job, "sphere{<0, 0, 0>, 2\ntranslate<%f, %f, %d>\n"
570 "pigment{color Green}\nno_shadow\n}\n", cx, cy, z - 1);
571#else
572 gvputs(job, agxbuse(&pov));
573#endif
574
575 free(p);
576
577 //backgroud of ellipse if filled
578 if (filled) {
579 p = pov_color_as_str(job, job->obj->fillcolor, 0.0);
580
581 gvprintf(job, POV_SPHERE, 0.0, 0.0, 0.0);
582 gvprintf(job, " " POV_SCALE3, rx, ry, 1.0);
583 gvprintf(job, " " POV_ROTATE, 0.0, 0.0, (float)job->rotation);
584 gvprintf(job, " " POV_TRANSLATE, cx, cy, z);
585 gvprintf(job, " %s" END, p);
586
587 free(p);
588 }
589 agxbfree(&pov);
590}
591
592static void pov_bezier(GVJ_t *job, pointf *A, size_t n, int filled) {
593 (void)filled;
594
595 gvputs(job, "//*** bezier\n");
596 z = layerz - 4;
597
598 char *p = pov_color_as_str(job, job->obj->fillcolor, 0.0);
599
600 agxbuf pov = {0};
601 agxbprint(&pov, POV_SPHERE_SWEEP, "b_spline", n + 2);
602
603 for (size_t i = 0; i < n; i++) {
604 agxbprint(&pov, " " POV_VECTOR3 ", %.3f\n", A[i].x + job->translation.x,
605 A[i].y + job->translation.y, 0.0, job->obj->penwidth); // z coordinate, thickness
606
607 //TODO: we currently just use the start and end points of the curve as
608 //control points but we should use center of nodes
609 if (i == 0 || i + 1 == n) {
610 agxbprint(&pov, " " POV_VECTOR3 ", %.3f\n", A[i].x + job->translation.x,
611 A[i].y + job->translation.y, 0.0, job->obj->penwidth); // z coordinate, thickness
612 }
613#ifdef DEBUG
614 gvprintf(job, "sphere{<0, 0, 0>, 2\ntranslate<%f, %f, %d>\n"
615 "pigment{color Yellow}\nno_shadow\n}\n",
616 (A[i].x + job->translation.x) * job->scale.x,
617 (A[i].y + job->translation.y) * job->scale.y, z - 2);
618#endif
619 }
620 // catenate pov & end str
621 gvprintf(job, "%s tolerance 0.01\n", agxbuse(&pov));
622 gvprintf(job, " " POV_SCALE3, job->scale.x, job->scale.y, 1.0);
623 gvprintf(job, " " POV_ROTATE, 0.0, 0.0, (float)job->rotation);
624 gvprintf(job, " " POV_TRANSLATE, 0.0, 0.0, z - 2);
625 gvprintf(job, " %s" END, p);
626
627 free(p);
628 agxbfree(&pov);
629}
630
631static void pov_polygon(GVJ_t *job, pointf *A, size_t n, int filled) {
632 gvputs(job, "//*** polygon\n");
633 z = layerz - 2;
634
635 char *p = pov_color_as_str(job, job->obj->pencolor, 0.0);
636
637 gvprintf(job, POV_SPHERE_SWEEP, "linear_spline", n + 1);
638
639 for (size_t i = 0; i < n; i++) {
640 gvprintf(job, " " POV_VECTOR3 ", %.3f\n", A[i].x + job->translation.x,
641 A[i].y + job->translation.y, 0.0, job->obj->penwidth); // z coordinate, thickness
642 }
643
644 //close polygon, add starting point as final point^
645 gvprintf(job, " " POV_VECTOR3 ", %.3f\n", A[0].x + job->translation.x,
646 A[0].y + job->translation.y, 0.0, job->obj->penwidth); // z coordinate, thickness
647
648 gvputs(job, " tolerance 0.1\n");
649 gvprintf(job, " " POV_SCALE3, job->scale.x, job->scale.y, 1.0);
650 gvprintf(job, " " POV_ROTATE, 0.0, 0.0, (float)job->rotation);
651 gvprintf(job, " " POV_TRANSLATE, 0.0, 0.0, z - 2);
652 gvprintf(job, " %s" END, p);
653
654 free(p);
655
656 //create fill background
657 if (filled) {
658 p = pov_color_as_str(job, job->obj->fillcolor, 0.25);
659
660 gvprintf(job, POV_POLYGON, n);
661
662 for (size_t i = 0; i < n; i++) {
663 //create on z = 0 plane, then translate to real z pos
664 gvprintf(job, "\n " POV_VECTOR3,
665 A[i].x + job->translation.x,
666 A[i].y + job->translation.y, 0.0);
667 }
668 gvputs(job, "\n ");
669 gvprintf(job, " " POV_SCALE3, job->scale.x, job->scale.y, 1.0);
670 gvprintf(job, " " POV_ROTATE, 0.0, 0.0, (float)job->rotation);
671 gvprintf(job, " " POV_TRANSLATE, 0.0, 0.0, z - 2);
672 gvprintf(job, " %s" END, p);
673
674 free(p);
675 }
676}
677
678static void pov_polyline(GVJ_t *job, pointf *A, size_t n) {
679 gvputs(job, "//*** polyline\n");
680 z = layerz - 6;
681
682 char *p = pov_color_as_str(job, job->obj->pencolor, 0.0);
683
684 gvprintf(job, POV_SPHERE_SWEEP, "linear_spline", n);
685
686 for (size_t i = 0; i < n; i++) {
687 gvprintf(job, " " POV_VECTOR3 ", %.3f\n", A[i].x + job->translation.x,
688 A[i].y + job->translation.y, 0.0, job->obj->penwidth); // z coordinate, thickness
689 }
690
691 gvputs(job, " tolerance 0.01\n");
692 gvprintf(job, " " POV_SCALE3, job->scale.x, job->scale.y, 1.0);
693 gvprintf(job, " " POV_ROTATE, 0.0, 0.0, (float)job->rotation);
694 gvprintf(job, " " POV_TRANSLATE, 0.0, 0.0, z);
695 gvprintf(job, " %s" END, p);
696
697 free(p);
698}
699
702 0, /* pov_end_job */
711 0, /* pov_begin_nodes */
712 0, /* pov_end_nodes */
713 0, /* pov_begin_edges */
714 0, /* pov_end_edges */
719 0, /* pov_begin_anchor */
720 0, /* pov_end_anchor */
721 0, /* pov_begin_label */
722 0, /* pov_end_label */
724 0, /* pov_resolve_color */
730 0, /* pov_library_shape */
731};
732
734 /* flags */
744 4.0, /* default pad - graph units */
745 pov_knowncolors, /* knowncolors */
746 sizeof(pov_knowncolors) / sizeof(char *), /* strings in knowncolors */
747 RENDERER_COLOR_TYPE /* set renderer color type */
748};
749
751 GVDEVICE_DOES_TRUECOLOR, /* flags */
752 {0.0, 0.0}, /* default margin - points */
753 {0.0, 0.0}, /* default page width, height - points */
754 {DPI, DPI}, /* default dpi */
755};
756
761
763 {FORMAT_POV, "pov:pov", 1, NULL, &device_features_pov},
764 {0, NULL, 0, NULL, NULL}
765};
766
static void agxbfree(agxbuf *xb)
free any malloced resources
Definition agxbuf.h:78
static int agxbprint(agxbuf *xb, const char *fmt,...)
Printf-style output to an agxbuf.
Definition agxbuf.h:234
static WUR char * agxbuse(agxbuf *xb)
Definition agxbuf.h:307
static char * agxbdisown(agxbuf *xb)
Definition agxbuf.h:327
#define M_PI
Definition arith.h:41
@ COLOR_STRING
Definition color.h:27
#define A(n, t)
Definition expr.h:76
void free(void *)
node NULL
Definition grammar.y:180
char * agnameof(void *)
returns a string descriptor for the object.
Definition id.c:143
#define GVRENDER_DOES_MAP_ELLIPSE
Definition gvcjob.h:101
#define GVRENDER_DOES_Z
Definition gvcjob.h:105
#define GVRENDER_NO_WHITE_BG
Definition gvcjob.h:106
#define GVDEVICE_DOES_LAYERS
Definition gvcjob.h:88
#define GVDEVICE_DOES_TRUECOLOR
Definition gvcjob.h:90
#define GVRENDER_DOES_MAP_BSPLINE
Definition gvcjob.h:102
#define GVRENDER_DOES_TRANSFORM
Definition gvcjob.h:95
#define GVRENDER_DOES_MAP_POLYGON
Definition gvcjob.h:100
#define GVRENDER_DOES_MAP_RECTANGLE
Definition gvcjob.h:98
#define GVRENDER_DOES_MAP_CIRCLE
Definition gvcjob.h:99
static void color(Agraph_t *g)
Definition gvcolor.c:129
int gvputs(GVJ_t *job, const char *s)
Definition gvdevice.c:266
void gvprintf(GVJ_t *job, const char *format,...)
Definition gvdevice.c:402
gvdevice_features_t device_features_pov
static void pov_textspan(GVJ_t *job, pointf c, textspan_t *span)
gvplugin_installed_t gvrender_pov_types[]
static int z
@ FORMAT_POV
#define POV_CAMERA
static void pov_begin_job(GVJ_t *job)
#define POV_COLORS
static void pov_end_node(GVJ_t *job)
#define END
#define POV_SPHERE
static void pov_end_graph(GVJ_t *job)
static void pov_begin_cluster(GVJ_t *job)
static void pov_bezier(GVJ_t *job, pointf *A, size_t n, int filled)
#define POV_COLOR_NAME
#define POV_SKY_AND_GND
static void pov_begin_page(GVJ_t *job)
#define POV_VERSION
gvrender_features_t render_features_pov
#define POV_COLOR_RGB
static void pov_polyline(GVJ_t *job, pointf *A, size_t n)
#define POV_ROTATE
#define POV_TRANSLATE
#define POV_TEXT
#define GV_OBJ_EXT(type, obj, name)
static void pov_begin_graph(GVJ_t *job)
static void pov_begin_layer(GVJ_t *job, char *layername, int layerNum, int numLayers)
static void pov_comment(GVJ_t *job, char *str)
static void pov_end_edge(GVJ_t *job)
static void pov_end_page(GVJ_t *job)
#define POV_PIGMENT_COLOR
static char * pov_knowncolors[]
static void pov_end_layer(GVJ_t *job)
static void pov_polygon(GVJ_t *job, pointf *A, size_t n, int filled)
#define POV_SCALE1
#define POV_LIGHT
#define POV_SCALE3
static void pov_ellipse(GVJ_t *job, pointf *A, int filled)
#define POV_TORUS
gvplugin_installed_t gvdevice_pov_types[]
static char * pov_color_as_str(GVJ_t *job, gvcolor_t color, float transparency)
#define DPI
static void pov_begin_edge(GVJ_t *job)
#define POV_INCLUDE
#define POV_DECLARE
#define POV_VECTOR3
#define POV_SPHERE_SWEEP
#define POV_POLYGON
static void pov_begin_node(GVJ_t *job)
#define POV_GLOBALS
#define POV_DEFAULT
#define RENDERER_COLOR_TYPE
static int layerz
static void pov_end_cluster(GVJ_t *job)
gvrender_engine_t pov_engine
textitem scanner parser str
Definition htmlparse.y:224
char * cmdname
Definition gvcommon.h:21
char ** info
Definition gvcommon.h:20
int verbose
Definition gvcommon.h:22
int rotation
Definition gvcjob.h:319
pointf pageSize
Definition gvcjob.h:315
point pagesArraySize
Definition gvcjob.h:304
obj_state_t * obj
Definition gvcjob.h:269
boxf bb
Definition gvcjob.h:311
point pagesArrayElem
Definition gvcjob.h:308
pointf view
Definition gvcjob.h:321
pointf devscale
Definition gvcjob.h:334
pointf focus
Definition gvcjob.h:316
GVCOMMON_t * common
Definition gvcjob.h:267
point pagesArrayFirst
Definition gvcjob.h:305
box pageBoundingBox
Definition gvcjob.h:329
double zoom
Definition gvcjob.h:318
box boundingBox
Definition gvcjob.h:330
pointf scale
Definition gvcjob.h:332
boxf canvasBox
Definition gvcjob.h:322
int layerNum
Definition gvcjob.h:302
int numLayers
Definition gvcjob.h:301
int numPages
Definition gvcjob.h:309
boxf pageBox
Definition gvcjob.h:314
int graph_index
Definition gvcjob.h:272
pointf translation
Definition gvcjob.h:333
union agxbuf::@129 u
point LL
Definition geom.h:39
point UR
Definition geom.h:39
pointf UR
Definition geom.h:41
pointf LL
Definition geom.h:41
ingroup plugin_api
Definition gvplugin.h:35
graph_t * g
Definition gvcjob.h:186
gvcolor_t fillcolor
Definition gvcjob.h:194
node_t * n
Definition gvcjob.h:188
gvcolor_t pencolor
Definition gvcjob.h:194
union obj_state_s::@97 u
double penwidth
Definition gvcjob.h:199
int y
Definition geom.h:27
int x
Definition geom.h:27
double x
Definition geom.h:29
double y
Definition geom.h:29
char * name
Definition textspan.h:54
PostscriptAlias * postscript_alias
Definition textspan.h:56
double size
Definition textspan.h:57
char * str
Definition textspan.h:65
char just
'l' 'n' 'r'
Definition textspan.h:71
pointf size
Definition textspan.h:70
textfont_t * font
Definition textspan.h:66