Graphviz 13.0.0~dev.20241220.2304
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
298typedef enum { FORMAT_POV, } format_type;
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,
396 (float)job->rotation);
397 gvprintf(job, "// view port.x,y = %.3f,%.3f\n", job->view.x,
398 job->view.y);
399 gvprintf(job, "// canvasBox LL,UR = %.3f,%.3f, %.3f,%.3f\n",
400 job->canvasBox.LL.x, job->canvasBox.LL.y, job->canvasBox.UR.x,
401 job->canvasBox.UR.y);
402 gvprintf(job, "// pageBoundingBox LL,UR = %d,%d, %d,%d\n",
405 gvprintf(job, "// boundingBox (all pages) LL,UR = %d,%d, %d,%d\n",
406 job->boundingBox.LL.x, job->boundingBox.LL.y,
407 job->boundingBox.UR.x, job->boundingBox.UR.y);
408 gvprintf(job, "// scale.x,y = %.3f,%.3f\n", job->scale.x, job->scale.y);
409 gvprintf(job, "// translation.x,y = %.3f,%.3f\n", job->translation.x,
410 job->translation.y);
411 gvprintf(job, "// devscale.x,y = %.3f,%.3f\n", job->devscale.x,
412 job->devscale.y);
413 gvprintf(job, "// verbose = %d\n", job->common->verbose);
414 gvprintf(job, "// cmd = %s\n", job->common->cmdname);
415 gvprintf(job, "// info = %s, %s, %s\n", job->common->info[0],
416 job->common->info[1], job->common->info[2]);
417#endif
418
419 //setup scene
420 double x = job->view.x / 2.0 * job->scale.x;
421 double y = job->view.y / 2.0 * job->scale.y;
422 double d = 500;
423 double px = atan(x / d) * 180.0 / M_PI * 2.0;
424 double py = atan(y / d) * 180.0 / M_PI * 2.0;
425 gvprintf(job, POV_CAMERA, x, y, x, y, fmax(px, py) * 1.2);
427 gvputs(job, POV_LIGHT);
428}
429
430static void pov_end_graph(GVJ_t * job)
431{
432 gvputs(job, "//*** end_graph\n");
433}
434
435static void pov_begin_layer(GVJ_t * job, char *layername, int layerNum, int numLayers)
436{
437 gvprintf(job, "//*** begin_layer: %s, %d/%d\n", layername, layerNum,
438 numLayers);
439 layerz = layerNum * -10;
440}
441
442static void pov_end_layer(GVJ_t * job)
443{
444 gvputs(job, "//*** end_layer\n");
445}
446
447static void pov_begin_page(GVJ_t * job)
448{
449 gvputs(job, "//*** begin_page\n");
450}
451
452static void pov_end_page(GVJ_t * job)
453{
454 gvputs(job, "//*** end_page\n");
455}
456
457static void pov_begin_cluster(GVJ_t * job)
458{
459 gvputs(job, "//*** begin_cluster\n");
460 layerz -= 2;
461}
462
463static void pov_end_cluster(GVJ_t * job)
464{
465 gvputs(job, "//*** end_cluster\n");
466}
467
468static void pov_begin_node(GVJ_t * job)
469{
470 gvprintf(job, "//*** begin_node: %s\n", agnameof(job->obj->u.n));
471}
472
473static void pov_end_node(GVJ_t * job)
474{
475 gvputs(job, "//*** end_node\n");
476}
477
478static void pov_begin_edge(GVJ_t * job)
479{
480 gvputs(job, "//*** begin_edge\n");
481 layerz -= 5;
482#ifdef DEBUG
483 gvprintf(job, "// layerz = %d.000\n", layerz);
484#endif
485}
486
487static void pov_end_edge(GVJ_t * job)
488{
489 gvputs(job, "//*** end_edge\n");
490 layerz += 5;
491#ifdef DEBUG
492 gvprintf(job, "// layerz = %d.000\n", layerz);
493#endif
494}
495
496static void pov_textspan(GVJ_t * job, pointf c, textspan_t * span)
497{
498 gvprintf(job, "//*** textspan: %s, fontsize = %.3f, fontname = %s\n",
499 span->str, span->font->size, span->font->name);
500 z = layerz - 9;
501
502#ifdef DEBUG
503 if (span->font->postscript_alias)
504 gvputs(job, "// Warning: postscript_alias not handled!\n");
505#endif
506
507 //handle text justification
508 switch (span->just) {
509 case 'l': //left justified
510 break;
511 case 'r': //right justified
512 c.x = c.x - span->size.x;
513 break;
514 default:
515 case 'n': //centered
516 c.x = c.x - span->size.x / 2.0;
517 break;
518 }
519
520 double x = (c.x + job->translation.x) * job->scale.x;
521 double y = (c.y + job->translation.y) * job->scale.y;
522
523 char *p = pov_color_as_str(job, job->obj->pencolor, 0.0);
524
525 //pov bundled fonts: timrom.ttf, cyrvetic.ttf
526 agxbuf pov = {0};
527 agxbprint(&pov, POV_TEXT " no_shadow\n",
528 span->font->name, span->str, 0.25, 0.0); // font, text, depth (0.5 ... 2.0), offset
529 agxbprint(&pov, " " POV_SCALE1, span->font->size * job->scale.x);
530 agxbprint(&pov, " " POV_ROTATE, 0.0, 0.0, (float)job->rotation);
531 agxbprint(&pov, " " POV_TRANSLATE, x, y, z);
532 agxbprint(&pov, " %s" END, p);
533
534#ifdef DEBUG
535 GV_OBJ_EXT("Text", agxbuse(&pov), span->str);
536 gvprintf(job, "sphere{<0, 0, 0>, 2\ntranslate<%f, %f, %d>\n"
537 "pigment{color Red}\nno_shadow\n}\n", x, y, z - 1);
538#else
539 gvputs(job, agxbuse(&pov));
540#endif
541
542 agxbfree(&pov);
543 free(p);
544}
545
546static void pov_ellipse(GVJ_t * job, pointf * A, int filled)
547{
548 gvputs(job, "//*** ellipse\n");
549 z = layerz - 6;
550
551 // A[0] center, A[1] corner of ellipse
552 const double cx = (A[0].x + job->translation.x) * job->scale.x;
553 const double cy = (A[0].y + job->translation.y) * job->scale.y;
554 const double rx = (A[1].x - A[0].x) * job->scale.x;
555 const double ry = (A[1].y - A[0].y) * job->scale.y;
556 const double w = job->obj->penwidth / (rx + ry) / 2.0 * 5;
557
558 //draw rim (torus)
559 char *p = pov_color_as_str(job, job->obj->pencolor, 0.0);
560
561 agxbuf pov = {0};
562 agxbprint(&pov, POV_TORUS, 1.0, w); // radius, size of ring
563 agxbprint(&pov, " " POV_SCALE3, rx, (rx + ry) / 4.0, ry);
564 agxbprint(&pov, " " POV_ROTATE, 90.0, 0.0, (float)job->rotation);
565 agxbprint(&pov, " " POV_TRANSLATE, cx, cy, z);
566 agxbprint(&pov, " %s" END, p);
567
568#ifdef DEBUG
569 GV_OBJ_EXT("Torus", agxbuse(&pov), "");
570 gvprintf(job, "sphere{<0, 0, 0>, 2\ntranslate<%f, %f, %d>\n"
571 "pigment{color Green}\nno_shadow\n}\n", cx, cy, z - 1);
572#else
573 gvputs(job, agxbuse(&pov));
574#endif
575
576 free(p);
577
578 //backgroud of ellipse if filled
579 if (filled) {
580 p = pov_color_as_str(job, job->obj->fillcolor, 0.0);
581
582 gvprintf(job, POV_SPHERE, 0.0, 0.0, 0.0);
583 gvprintf(job, " " POV_SCALE3, rx, ry, 1.0);
584 gvprintf(job, " " POV_ROTATE, 0.0, 0.0, (float)job->rotation);
585 gvprintf(job, " " POV_TRANSLATE, cx, cy, z);
586 gvprintf(job, " %s" END, p);
587
588 free(p);
589 }
590 agxbfree(&pov);
591}
592
593static void pov_bezier(GVJ_t *job, pointf *A, size_t n, int filled) {
594 (void)filled;
595
596 gvputs(job, "//*** bezier\n");
597 z = layerz - 4;
598
599 char *p = pov_color_as_str(job, job->obj->fillcolor, 0.0);
600
601 agxbuf pov = {0};
602 agxbprint(&pov, POV_SPHERE_SWEEP, "b_spline", n + 2);
603
604 for (size_t i = 0; i < n; i++) {
605 agxbprint(&pov, " " POV_VECTOR3 ", %.3f\n", A[i].x + job->translation.x,
606 A[i].y + job->translation.y, 0.0, job->obj->penwidth); // z coordinate, thickness
607
608 //TODO: we currently just use the start and end points of the curve as
609 //control points but we should use center of nodes
610 if (i == 0 || i + 1 == n) {
611 agxbprint(&pov, " " POV_VECTOR3 ", %.3f\n", A[i].x + job->translation.x,
612 A[i].y + job->translation.y, 0.0, job->obj->penwidth); // z coordinate, thickness
613 }
614#ifdef DEBUG
615 gvprintf(job, "sphere{<0, 0, 0>, 2\ntranslate<%f, %f, %d>\n"
616 "pigment{color Yellow}\nno_shadow\n}\n",
617 (A[i].x + job->translation.x) * job->scale.x,
618 (A[i].y + job->translation.y) * job->scale.y, z - 2);
619#endif
620 }
621 // catenate pov & end str
622 gvprintf(job, "%s tolerance 0.01\n", agxbuse(&pov));
623 gvprintf(job, " " POV_SCALE3, job->scale.x, job->scale.y, 1.0);
624 gvprintf(job, " " POV_ROTATE, 0.0, 0.0, (float)job->rotation);
625 gvprintf(job, " " POV_TRANSLATE, 0.0, 0.0, z - 2);
626 gvprintf(job, " %s" END, p);
627
628 free(p);
629 agxbfree(&pov);
630}
631
632static void pov_polygon(GVJ_t *job, pointf *A, size_t n, int filled) {
633 gvputs(job, "//*** polygon\n");
634 z = layerz - 2;
635
636 char *p = pov_color_as_str(job, job->obj->pencolor, 0.0);
637
638 gvprintf(job, POV_SPHERE_SWEEP, "linear_spline", n + 1);
639
640 for (size_t i = 0; i < n; i++) {
641 gvprintf(job, " " POV_VECTOR3 ", %.3f\n", A[i].x + job->translation.x,
642 A[i].y + job->translation.y, 0.0, job->obj->penwidth); // z coordinate, thickness
643 }
644
645 //close polygon, add starting point as final point^
646 gvprintf(job, " " POV_VECTOR3 ", %.3f\n", A[0].x + job->translation.x,
647 A[0].y + job->translation.y, 0.0, job->obj->penwidth); // z coordinate, thickness
648
649 gvputs(job, " tolerance 0.1\n");
650 gvprintf(job, " " POV_SCALE3, job->scale.x, job->scale.y, 1.0);
651 gvprintf(job, " " POV_ROTATE, 0.0, 0.0, (float)job->rotation);
652 gvprintf(job, " " POV_TRANSLATE, 0.0, 0.0, z - 2);
653 gvprintf(job, " %s" END, p);
654
655 free(p);
656
657 //create fill background
658 if (filled) {
659 p = pov_color_as_str(job, job->obj->fillcolor, 0.25);
660
661 gvprintf(job, POV_POLYGON, n);
662
663 for (size_t i = 0; i < n; i++) {
664 //create on z = 0 plane, then translate to real z pos
665 gvprintf(job, "\n " POV_VECTOR3,
666 A[i].x + job->translation.x,
667 A[i].y + job->translation.y, 0.0);
668 }
669 gvputs(job, "\n ");
670 gvprintf(job, " " POV_SCALE3, job->scale.x, job->scale.y, 1.0);
671 gvprintf(job, " " POV_ROTATE, 0.0, 0.0, (float)job->rotation);
672 gvprintf(job, " " POV_TRANSLATE, 0.0, 0.0, z - 2);
673 gvprintf(job, " %s" END, p);
674
675 free(p);
676 }
677}
678
679static void pov_polyline(GVJ_t *job, pointf *A, size_t n) {
680 gvputs(job, "//*** polyline\n");
681 z = layerz - 6;
682
683 char *p = pov_color_as_str(job, job->obj->pencolor, 0.0);
684
685 gvprintf(job, POV_SPHERE_SWEEP, "linear_spline", n);
686
687 for (size_t i = 0; i < n; i++) {
688 gvprintf(job, " " POV_VECTOR3 ", %.3f\n", A[i].x + job->translation.x,
689 A[i].y + job->translation.y, 0.0, job->obj->penwidth); // z coordinate, thickness
690 }
691
692 gvputs(job, " tolerance 0.01\n");
693 gvprintf(job, " " POV_SCALE3, job->scale.x, job->scale.y, 1.0);
694 gvprintf(job, " " POV_ROTATE, 0.0, 0.0, (float)job->rotation);
695 gvprintf(job, " " POV_TRANSLATE, 0.0, 0.0, z);
696 gvprintf(job, " %s" END, p);
697
698 free(p);
699}
700
703 0, /* pov_end_job */
712 0, /* pov_begin_nodes */
713 0, /* pov_end_nodes */
714 0, /* pov_begin_edges */
715 0, /* pov_end_edges */
720 0, /* pov_begin_anchor */
721 0, /* pov_end_anchor */
722 0, /* pov_begin_label */
723 0, /* pov_end_label */
725 0, /* pov_resolve_color */
731 0, /* pov_library_shape */
732};
733
735 /* flags */
745 4.0, /* default pad - graph units */
746 pov_knowncolors, /* knowncolors */
747 sizeof(pov_knowncolors) / sizeof(char *), /* strings in knowncolors */
748 RENDERER_COLOR_TYPE /* set renderer color type */
749};
750
752 GVDEVICE_DOES_TRUECOLOR, /* flags */
753 {0.0, 0.0}, /* default margin - points */
754 {0.0, 0.0}, /* default page width, height - points */
755 {DPI, DPI}, /* default dpi */
756};
757
762
764 {FORMAT_POV, "pov:pov", 1, NULL, &device_features_pov},
765 {0, NULL, 0, NULL, NULL}
766};
767
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:163
char * agnameof(void *)
returns a string descriptor for the object.
Definition id.c:158
#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:264
void gvprintf(GVJ_t *job, const char *format,...)
Definition gvdevice.c:395
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
#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
@ FORMAT_POV
#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::@121 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
union obj_state_s::@89 u
node_t * n
Definition gvcjob.h:188
gvcolor_t pencolor
Definition gvcjob.h:194
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