Graphviz 12.0.1~dev.20240715.2254
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 <cgraph/agxbuf.h>
20#include <cgraph/prisize_t.h>
21#include <math.h>
22#include <stdarg.h>
23#include <stdlib.h>
24#include <string.h>
25#include <ctype.h>
26#include <errno.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//#define DEBUG
301
302//TODO: check why this dot file does not work (90 rotated)
303// /usr/share/graphviz/graphs/directed/NaN.gv
304//TODO: add Texttures
305//TODO: check how we can receive attributes from dot file
306// if we can't receive attributes set defaults in pov include file
307// - put #include "graph-scheme-fancy.inc" in pov file
308// - run povray with +L`pwd`
309// - put e.g. #declare mycolor = Gold; in graph-scheme-fancy.inc
310// - use textures and color: pigment { color mycolor transmit 0.000 }
311//TODO: idea, put the whole graph in a declare= and then
312// print it with something along the line:
313// object{ graph translate{page->translation, ...} rotate{page->rotation, ...} }
314
315static char *pov_knowncolors[] = { POV_COLORS };
316
317static int layerz = 0;
318static int z = 0;
319
320static char *pov_color_as_str(GVJ_t * job, gvcolor_t color, float transparency)
321{
322 agxbuf c = {0};
323 switch (color.type) {
324 case COLOR_STRING:
325#ifdef DEBUG
326 gvprintf(job, "// type = %d, color = %s\n", color.type, color.u.string);
327#else
328 (void)job;
329#endif
330 if (!strcmp(color.u.string, "red"))
331 agxbprint(&c, POV_COLOR_NAME, "Red", transparency);
332 else if (!strcmp(color.u.string, "green"))
333 agxbprint(&c, POV_COLOR_NAME, "Green", transparency);
334 else if (!strcmp(color.u.string, "blue"))
335 agxbprint(&c, POV_COLOR_NAME, "Blue", transparency);
336 else
337 agxbprint(&c, POV_COLOR_NAME, color.u.string, transparency);
338 break;
340#ifdef DEBUG
341 gvprintf(job, "// type = %d, color = %d, %d, %d\n",
342 color.type, color.u.rgba[0], color.u.rgba[1],
343 color.u.rgba[2]);
344#endif
346 color.u.rgba[0] / 256.0, color.u.rgba[1] / 256.0,
347 color.u.rgba[2] / 256.0, transparency);
348 break;
349 default:
350 fprintf(stderr,
351 "oops, internal error: unhandled color type=%d %s\n",
352 color.type, color.u.string);
353 assert(0); //oops, wrong type set in gvrender_features_t?
354 }
355 agxbuf pov = {0};
357 agxbfree(&c);
358 return agxbdisown(&pov);
359}
360
361static void pov_comment(GVJ_t * job, char *str)
362{
363 gvprintf(job, "//*** comment: %s\n", str);
364}
365
366static void pov_begin_job(GVJ_t * job)
367{
368 gvputs(job, POV_VERSION);
369 gvputs(job, POV_GLOBALS);
370 gvputs(job, POV_DEFAULT);
371 gvputs(job, POV_INCLUDE);
372 gvprintf(job, POV_DECLARE, "black", "Black");
373 gvprintf(job, POV_DECLARE, "white", "White");
374}
375
376static void pov_begin_graph(GVJ_t * job)
377{
378 gvprintf(job, "//*** begin_graph %s\n", agnameof(job->obj->u.g));
379#ifdef DEBUG
380 gvprintf(job, "// graph_index = %d, pages = %d, layer = %d/%d\n",
381 job->graph_index, job->numPages, job->layerNum,
382 job->numLayers);
383 gvprintf(job, "// pagesArraySize.x,y = %d,%d\n", job->pagesArraySize.x,
384 job->pagesArraySize.y);
385 gvprintf(job, "// pagesArrayFirst.x,y = %d,%d\n",
387 gvprintf(job, "// pagesArrayElem.x,y = %d,%d\n", job->pagesArrayElem.x,
388 job->pagesArrayElem.y);
389 gvprintf(job, "// bb.LL,UR = %.3f,%.3f, %.3f,%.3f\n", job->bb.LL.x,
390 job->bb.LL.y, job->bb.UR.x, job->bb.UR.y);
391 gvprintf(job, "// pageBox in graph LL,UR = %.3f,%.3f, %.3f,%.3f\n",
392 job->pageBox.LL.x, job->pageBox.LL.y, job->pageBox.UR.x,
393 job->pageBox.UR.y);
394 gvprintf(job, "// pageSize.x,y = %.3f,%.3f\n", job->pageSize.x,
395 job->pageSize.y);
396 gvprintf(job, "// focus.x,y = %.3f,%.3f\n", job->focus.x, job->focus.y);
397 gvprintf(job, "// zoom = %.3f, rotation = %d\n", job->zoom,
398 (float)job->rotation);
399 gvprintf(job, "// view port.x,y = %.3f,%.3f\n", job->view.x,
400 job->view.y);
401 gvprintf(job, "// canvasBox LL,UR = %.3f,%.3f, %.3f,%.3f\n",
402 job->canvasBox.LL.x, job->canvasBox.LL.y, job->canvasBox.UR.x,
403 job->canvasBox.UR.y);
404 gvprintf(job, "// pageBoundingBox LL,UR = %d,%d, %d,%d\n",
407 gvprintf(job, "// boundingBox (all pages) LL,UR = %d,%d, %d,%d\n",
408 job->boundingBox.LL.x, job->boundingBox.LL.y,
409 job->boundingBox.UR.x, job->boundingBox.UR.y);
410 gvprintf(job, "// scale.x,y = %.3f,%.3f\n", job->scale.x, job->scale.y);
411 gvprintf(job, "// translation.x,y = %.3f,%.3f\n", job->translation.x,
412 job->translation.y);
413 gvprintf(job, "// devscale.x,y = %.3f,%.3f\n", job->devscale.x,
414 job->devscale.y);
415 gvprintf(job, "// verbose = %d\n", job->common->verbose);
416 gvprintf(job, "// cmd = %s\n", job->common->cmdname);
417 gvprintf(job, "// info = %s, %s, %s\n", job->common->info[0],
418 job->common->info[1], job->common->info[2]);
419#endif
420
421 //setup scene
422 double x = job->view.x / 2.0 * job->scale.x;
423 double y = job->view.y / 2.0 * job->scale.y;
424 double d = 500;
425 double px = atan(x / d) * 180.0 / M_PI * 2.0;
426 double py = atan(y / d) * 180.0 / M_PI * 2.0;
427 gvprintf(job, POV_CAMERA, x, y, x, y, fmax(px, py) * 1.2);
429 gvputs(job, POV_LIGHT);
430}
431
432static void pov_end_graph(GVJ_t * job)
433{
434 gvputs(job, "//*** end_graph\n");
435}
436
437static void pov_begin_layer(GVJ_t * job, char *layername, int layerNum, int numLayers)
438{
439 gvprintf(job, "//*** begin_layer: %s, %d/%d\n", layername, layerNum,
440 numLayers);
441 layerz = layerNum * -10;
442}
443
444static void pov_end_layer(GVJ_t * job)
445{
446 gvputs(job, "//*** end_layer\n");
447}
448
449static void pov_begin_page(GVJ_t * job)
450{
451 gvputs(job, "//*** begin_page\n");
452}
453
454static void pov_end_page(GVJ_t * job)
455{
456 gvputs(job, "//*** end_page\n");
457}
458
459static void pov_begin_cluster(GVJ_t * job)
460{
461 gvputs(job, "//*** begin_cluster\n");
462 layerz -= 2;
463}
464
465static void pov_end_cluster(GVJ_t * job)
466{
467 gvputs(job, "//*** end_cluster\n");
468}
469
470static void pov_begin_node(GVJ_t * job)
471{
472 gvprintf(job, "//*** begin_node: %s\n", agnameof(job->obj->u.n));
473}
474
475static void pov_end_node(GVJ_t * job)
476{
477 gvputs(job, "//*** end_node\n");
478}
479
480static void pov_begin_edge(GVJ_t * job)
481{
482 gvputs(job, "//*** begin_edge\n");
483 layerz -= 5;
484#ifdef DEBUG
485 gvprintf(job, "// layerz = %d.000\n", layerz);
486#endif
487}
488
489static void pov_end_edge(GVJ_t * job)
490{
491 gvputs(job, "//*** end_edge\n");
492 layerz += 5;
493#ifdef DEBUG
494 gvprintf(job, "// layerz = %d.000\n", layerz);
495#endif
496}
497
498static void pov_textspan(GVJ_t * job, pointf c, textspan_t * span)
499{
500 gvprintf(job, "//*** textspan: %s, fontsize = %.3f, fontname = %s\n",
501 span->str, span->font->size, span->font->name);
502 z = layerz - 9;
503
504#ifdef DEBUG
505 if (span->font->postscript_alias)
506 gvputs(job, "// Warning: postscript_alias not handled!\n");
507#endif
508
509 //handle text justification
510 switch (span->just) {
511 case 'l': //left justified
512 break;
513 case 'r': //right justified
514 c.x = c.x - span->size.x;
515 break;
516 default:
517 case 'n': //centered
518 c.x = c.x - span->size.x / 2.0;
519 break;
520 }
521
522 double x = (c.x + job->translation.x) * job->scale.x;
523 double y = (c.y + job->translation.y) * job->scale.y;
524
525 char *p = pov_color_as_str(job, job->obj->pencolor, 0.0);
526
527 //pov bundled fonts: timrom.ttf, cyrvetic.ttf
528 agxbuf pov = {0};
529 agxbprint(&pov, POV_TEXT " no_shadow\n",
530 span->font->name, span->str, 0.25, 0.0); // font, text, depth (0.5 ... 2.0), offset
531 agxbprint(&pov, " " POV_SCALE1, span->font->size * job->scale.x);
532 agxbprint(&pov, " " POV_ROTATE, 0.0, 0.0, (float)job->rotation);
533 agxbprint(&pov, " " POV_TRANSLATE, x, y, z);
534 agxbprint(&pov, " %s" END, p);
535
536#ifdef DEBUG
537 GV_OBJ_EXT("Text", agxbuse(&pov), span->str);
538 gvprintf(job, "sphere{<0, 0, 0>, 2\ntranslate<%f, %f, %d>\n"
539 "pigment{color Red}\nno_shadow\n}\n", x, y, z - 1);
540#else
541 gvputs(job, agxbuse(&pov));
542#endif
543
544 agxbfree(&pov);
545 free(p);
546}
547
548static void pov_ellipse(GVJ_t * job, pointf * A, int filled)
549{
550 gvputs(job, "//*** ellipse\n");
551 z = layerz - 6;
552
553 // A[0] center, A[1] corner of ellipse
554 float cx = (A[0].x + job->translation.x) * job->scale.x;
555 float cy = (A[0].y + job->translation.y) * job->scale.y;
556 float rx = (A[1].x - A[0].x) * job->scale.x;
557 float ry = (A[1].y - A[0].y) * job->scale.y;
558 float w = job->obj->penwidth / (rx + ry) / 2.0 * 5;
559
560 //draw rim (torus)
561 char *p = pov_color_as_str(job, job->obj->pencolor, 0.0);
562
563 agxbuf pov = {0};
564 agxbprint(&pov, POV_TORUS, 1.0, w); // radius, size of ring
565 agxbprint(&pov, " " POV_SCALE3, rx, (rx + ry) / 4.0, ry);
566 agxbprint(&pov, " " POV_ROTATE, 90.0, 0.0, (float)job->rotation);
567 agxbprint(&pov, " " POV_TRANSLATE, cx, cy, z);
568 agxbprint(&pov, " %s" END, p);
569
570#ifdef DEBUG
571 GV_OBJ_EXT("Torus", agxbuse(&pov), "");
572 gvprintf(job, "sphere{<0, 0, 0>, 2\ntranslate<%f, %f, %d>\n"
573 "pigment{color Green}\nno_shadow\n}\n", cx, cy, z - 1);
574#else
575 gvputs(job, agxbuse(&pov));
576#endif
577
578 free(p);
579
580 //backgroud of ellipse if filled
581 if (filled) {
582 p = pov_color_as_str(job, job->obj->fillcolor, 0.0);
583
584 gvprintf(job, POV_SPHERE, 0.0, 0.0, 0.0);
585 gvprintf(job, " " POV_SCALE3, rx, ry, 1.0);
586 gvprintf(job, " " POV_ROTATE, 0.0, 0.0, (float)job->rotation);
587 gvprintf(job, " " POV_TRANSLATE, cx, cy, z);
588 gvprintf(job, " %s" END, p);
589
590 free(p);
591 }
592 agxbfree(&pov);
593}
594
595static void pov_bezier(GVJ_t *job, pointf *A, size_t n, int filled) {
596 (void)filled;
597
598 gvputs(job, "//*** bezier\n");
599 z = layerz - 4;
600
601 char *p = pov_color_as_str(job, job->obj->fillcolor, 0.0);
602
603 agxbuf pov = {0};
604 agxbprint(&pov, POV_SPHERE_SWEEP, "b_spline", n + 2);
605
606 for (size_t i = 0; i < n; i++) {
607 agxbprint(&pov, " " POV_VECTOR3 ", %.3f\n", A[i].x + job->translation.x,
608 A[i].y + job->translation.y, 0.0, job->obj->penwidth); // z coordinate, thickness
609
610 //TODO: we currently just use the start and end points of the curve as
611 //control points but we should use center of nodes
612 if (i == 0 || i + 1 == n) {
613 agxbprint(&pov, " " POV_VECTOR3 ", %.3f\n", A[i].x + job->translation.x,
614 A[i].y + job->translation.y, 0.0, job->obj->penwidth); // z coordinate, thickness
615 }
616#ifdef DEBUG
617 gvprintf(job, "sphere{<0, 0, 0>, 2\ntranslate<%f, %f, %d>\n"
618 "pigment{color Yellow}\nno_shadow\n}\n",
619 (A[i].x + job->translation.x) * job->scale.x,
620 (A[i].y + job->translation.y) * job->scale.y, z - 2);
621#endif
622 }
623 // catenate pov & end str
624 gvprintf(job, "%s tolerance 0.01\n", agxbuse(&pov));
625 gvprintf(job, " " POV_SCALE3, job->scale.x, job->scale.y, 1.0);
626 gvprintf(job, " " POV_ROTATE, 0.0, 0.0, (float)job->rotation);
627 gvprintf(job, " " POV_TRANSLATE, 0.0, 0.0, z - 2);
628 gvprintf(job, " %s" END, p);
629
630 free(p);
631 agxbfree(&pov);
632}
633
634static void pov_polygon(GVJ_t *job, pointf *A, size_t n, int filled) {
635 gvputs(job, "//*** polygon\n");
636 z = layerz - 2;
637
638 char *p = pov_color_as_str(job, job->obj->pencolor, 0.0);
639
640 gvprintf(job, POV_SPHERE_SWEEP, "linear_spline", n + 1);
641
642 for (size_t i = 0; i < n; i++) {
643 gvprintf(job, " " POV_VECTOR3 ", %.3f\n", A[i].x + job->translation.x,
644 A[i].y + job->translation.y, 0.0, job->obj->penwidth); // z coordinate, thickness
645 }
646
647 //close polygon, add starting point as final point^
648 gvprintf(job, " " POV_VECTOR3 ", %.3f\n", A[0].x + job->translation.x,
649 A[0].y + job->translation.y, 0.0, job->obj->penwidth); // z coordinate, thickness
650
651 gvputs(job, " tolerance 0.1\n");
652 gvprintf(job, " " POV_SCALE3, job->scale.x, job->scale.y, 1.0);
653 gvprintf(job, " " POV_ROTATE, 0.0, 0.0, (float)job->rotation);
654 gvprintf(job, " " POV_TRANSLATE, 0.0, 0.0, z - 2);
655 gvprintf(job, " %s" END, p);
656
657 free(p);
658
659 //create fill background
660 if (filled) {
661 p = pov_color_as_str(job, job->obj->fillcolor, 0.25);
662
663 gvprintf(job, POV_POLYGON, n);
664
665 for (size_t i = 0; i < n; i++) {
666 //create on z = 0 plane, then translate to real z pos
667 gvprintf(job, "\n " POV_VECTOR3,
668 A[i].x + job->translation.x,
669 A[i].y + job->translation.y, 0.0);
670 }
671 gvputs(job, "\n ");
672 gvprintf(job, " " POV_SCALE3, job->scale.x, job->scale.y, 1.0);
673 gvprintf(job, " " POV_ROTATE, 0.0, 0.0, (float)job->rotation);
674 gvprintf(job, " " POV_TRANSLATE, 0.0, 0.0, z - 2);
675 gvprintf(job, " %s" END, p);
676
677 free(p);
678 }
679}
680
681static void pov_polyline(GVJ_t *job, pointf *A, size_t n) {
682 gvputs(job, "//*** polyline\n");
683 z = layerz - 6;
684
685 char *p = pov_color_as_str(job, job->obj->pencolor, 0.0);
686
687 gvprintf(job, POV_SPHERE_SWEEP, "linear_spline", n);
688
689 for (size_t i = 0; i < n; i++) {
690 gvprintf(job, " " POV_VECTOR3 ", %.3f\n", A[i].x + job->translation.x,
691 A[i].y + job->translation.y, 0.0, job->obj->penwidth); // z coordinate, thickness
692 }
693
694 gvputs(job, " tolerance 0.01\n");
695 gvprintf(job, " " POV_SCALE3, job->scale.x, job->scale.y, 1.0);
696 gvprintf(job, " " POV_ROTATE, 0.0, 0.0, (float)job->rotation);
697 gvprintf(job, " " POV_TRANSLATE, 0.0, 0.0, z);
698 gvprintf(job, " %s" END, p);
699
700 free(p);
701}
702
705 0, /* pov_end_job */
714 0, /* pov_begin_nodes */
715 0, /* pov_end_nodes */
716 0, /* pov_begin_edges */
717 0, /* pov_end_edges */
722 0, /* pov_begin_anchor */
723 0, /* pov_end_anchor */
724 0, /* pov_begin_label */
725 0, /* pov_end_label */
727 0, /* pov_resolve_color */
733 0, /* pov_library_shape */
734};
735
737 /* flags */
747 4.0, /* default pad - graph units */
748 pov_knowncolors, /* knowncolors */
749 sizeof(pov_knowncolors) / sizeof(char *), /* strings in knowncolors */
750 RENDERER_COLOR_TYPE /* set renderer color type */
751};
752
754 GVDEVICE_DOES_TRUECOLOR, /* flags */
755 {0.0, 0.0}, /* default margin - points */
756 {0.0, 0.0}, /* default page width, height - points */
757 {DPI, DPI}, /* default dpi */
758};
759
764
766 {FORMAT_POV, "pov:pov", 1, NULL, &device_features_pov},
767 {0, NULL, 0, NULL, NULL}
768};
769
static void agxbfree(agxbuf *xb)
free any malloced resources
Definition agxbuf.h:77
static int agxbprint(agxbuf *xb, const char *fmt,...)
Printf-style output to an agxbuf.
Definition agxbuf.h:213
static char * agxbuse(agxbuf *xb)
Definition agxbuf.h:286
static char * agxbdisown(agxbuf *xb)
Definition agxbuf.h:299
#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:149
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:128
int gvputs(GVJ_t *job, const char *s)
Definition gvdevice.c:263
void gvprintf(GVJ_t *job, const char *format,...)
Definition gvdevice.c:394
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
agxbuf * str
Definition htmlparse.c:97
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::@59 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
union obj_state_s::@92 u
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
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