From 0fe03275068c0e55d01a7cc2308fa12fdee569cf Mon Sep 17 00:00:00 2001 From: alex Date: Sat, 6 Apr 2002 12:25:29 +0000 Subject: [PATCH] Removed references to GIF Changed y0 and such into Y0 and so git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk/program@116 a5681a0c-68f1-0310-ab6d-d61299d08faa --- NT-BUILD-TIPS.txt | 2 +- bindings/perl-shared/Makefile.PL | 2 +- bindings/perl-shared/RRDs.pm | 4 +- bindings/perl-shared/ntmake.pl | 2 +- bindings/perl-shared/t/base.t | 18 +-- doc/Makefile.am | 2 +- doc/cdeftutorial.pod | 4 +- doc/rrdgraph-old.pod | 31 +++-- doc/rrdgraph_graph.src | 4 +- doc/rrdtutorial.es.pod | 44 +++---- examples/cgi-demo.cgi | 4 +- examples/cgi-demo.cgi.in | 4 +- examples/piped-demo.pl | 10 +- examples/piped-demo.pl.in | 8 +- examples/shared-demo.pl | 22 ++-- examples/shared-demo.pl.in | 20 ++-- src/rrd_cgi.c | 2 + src/rrd_gfx.c | 36 +++--- src/rrd_gfx.h | 14 +-- src/rrd_graph.c | 193 ++++++++++++++++--------------- src/rrd_graph.h | 7 +- src/rrd_tool.h | 2 - 22 files changed, 218 insertions(+), 217 deletions(-) diff --git a/NT-BUILD-TIPS.txt b/NT-BUILD-TIPS.txt index 0354f50..d163d3f 100644 --- a/NT-BUILD-TIPS.txt +++ b/NT-BUILD-TIPS.txt @@ -58,7 +58,7 @@ Is a library missing? But it does not stop with an error... 4. nmake test (You must have Visual C++ on the machine!) -After these steps it generates the test files (gifs and rrds), +After these steps it generates the test files (svgs and rrds), and they seem to be good. The real problem in the shared perl modul is the following: diff --git a/bindings/perl-shared/Makefile.PL b/bindings/perl-shared/Makefile.PL index b7732be..76a8154 100644 --- a/bindings/perl-shared/Makefile.PL +++ b/bindings/perl-shared/Makefile.PL @@ -15,5 +15,5 @@ WriteMakefile( # Perl will figure out which one is valid 'depend' => {'RRDs.c' => "../../src/.libs/librrd_private.a"}, 'dynamic_lib' => {'OTHERLDFLAGS' => "$librrd -lm"}, - 'realclean' => {FILES => 't/demo?.rrd t/demo?.gif' } + 'realclean' => {FILES => 't/demo?.rrd t/demo?.png' } ); diff --git a/bindings/perl-shared/RRDs.pm b/bindings/perl-shared/RRDs.pm index 7ed87c2..2cd3370 100644 --- a/bindings/perl-shared/RRDs.pm +++ b/bindings/perl-shared/RRDs.pm @@ -75,10 +75,10 @@ B returns a single INTEGER representing the last update time. $lastupdate = RRDs::last ... B returns an pointer to an ARRAY containing the x-size and y-size of the -created gif and results of the PRINT arguments. +created image and results of the PRINT arguments. ($averages,$xsize,$ysize) = RRDs::graph ... - print "Gifsize: ${xsize}x${ysize}\n"; + print "Imagesize: ${xsize}x${ysize}\n"; print "Averages: ", (join ", ", @$averages); B returns a pointer to a hash. The keys of the hash diff --git a/bindings/perl-shared/ntmake.pl b/bindings/perl-shared/ntmake.pl index ff01a41..dbde9bf 100644 --- a/bindings/perl-shared/ntmake.pl +++ b/bindings/perl-shared/ntmake.pl @@ -12,7 +12,7 @@ WriteMakefile( 'INC' => '-I../../src/ -I../../libraries/freetype-2.0.5/include -I ../../libraries/libart_lgpl-2.3.7 -I ../../libraries/zlib-1.1.4 -I ../../libraries/libpng-1.2.0', # change this path to refer to your libc.lib 'MYEXTLIB' => 'c:/vc98/lib/libc.lib ../../src/release/rrd.lib ../../libraries/libart_lgpl-2.3.7/release/libart.lib ../../libraries/zlib-1.1.4/release/zlib.lib ../../libraries/libpng-1.2.0\release\png.lib ../../libraries/freetype-2.0.5/release/freetype.lib', - 'realclean' => {FILES => 't/demo?.rrd t/demo?.gif' }, + 'realclean' => {FILES => 't/demo?.rrd t/demo?.png' }, ($] ge '5.005') ? ( 'AUTHOR' => 'Tobias Oetiker (oetiker@ee.ethz.ch)', 'ABSTRACT' => 'Round Robin Database Tool', diff --git a/bindings/perl-shared/t/base.t b/bindings/perl-shared/t/base.t index 0477f45..8154a11 100755 --- a/bindings/perl-shared/t/base.t +++ b/bindings/perl-shared/t/base.t @@ -30,8 +30,8 @@ my $RUNS = 500; my $GRUNS = 4; my $RRD1 = "demo1.rrd"; my $RRD2 = "demo2.rrd"; -my $GIF1 = "demo1.gif"; -my $GIF2 = "demo2.gif"; +my $PNG1 = "demo1.png"; +my $PNG2 = "demo2.png"; my $time = 30*int(time/30); my $START = $time-$RUNS*$STEP; @@ -107,14 +107,14 @@ if ($ERROR = RRDs::error) { die "$0: unable to update `$RRD2': $ERROR\n"; } -print "* Creating $GRUNS graphs: $GIF1 & $GIF2\n\n"; +print "* Creating $GRUNS graphs: $PNG1 & $PNG2\n\n"; my $now = $time; for (my $i=0;$i<$GRUNS;$i++) { - my @rrd_gifs = ($RRD1, $GIF1, $RRD2, $GIF2); - while (@rrd_gifs) { - my $RRD = shift(@rrd_gifs); - my $GIF = shift(@rrd_gifs); - my ($graphret,$xs,$ys) = RRDs::graph $GIF, "--title", 'Test GRAPH', + my @rrd_pngs = ($RRD1, $PNG1, $RRD2, $PNG2); + while (@rrd_pngs) { + my $RRD = shift(@rrd_pngs); + my $PNG = shift(@rrd_pngs); + my ($graphret,$xs,$ys) = RRDs::graph $PNG, "--title", 'Test GRAPH', "--vertical-label", 'Dummy Units', "--start", (-$RUNS*$STEP), "DEF:alpha=$RRD:a:AVERAGE", "DEF:beta=$RRD:b:AVERAGE", @@ -143,7 +143,7 @@ for (my $i=0;$i<$GRUNS;$i++) { if ($ERROR = RRDs::error) { print "ERROR: $ERROR\n"; } else { - print "GIF Size: ${xs}x${ys}\n"; + print "Image Size: ${xs}x${ys}\n"; print "Graph Return:\n",(join "\n", @$graphret),"\n\n"; } } diff --git a/doc/Makefile.am b/doc/Makefile.am index ba22f05..824fad9 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -58,7 +58,7 @@ RRDp.pm: ln -s ../bindings/perl-piped/RRDp.pm . index.html: - rm index.html; ln -s rrdtool.html index.html + rm -f index.html; ln -s rrdtool.html index.html link: RRDp.pm RRDs.pm index.html diff --git a/doc/cdeftutorial.pod b/doc/cdeftutorial.pod index 19070ae..fe58063 100644 --- a/doc/cdeftutorial.pod +++ b/doc/cdeftutorial.pod @@ -725,7 +725,7 @@ If you do so, you won't be able to use these next GPRINTs: =head2 Degrees Celcius vs. Degrees Fahrenheit - rrdtool graph demo.gif --title="Demo Graph" \ + rrdtool graph demo.png --title="Demo Graph" \ DEF:cel=demo.rrd:exhaust:AVERAGE \ CDEF:far=cel,32,-,0.55555,* \ LINE2:cel#00a000:"D. Celsius" \ @@ -750,7 +750,7 @@ enough for this purpose and it saves a calculation. =head2 Changing unknown into zero - rrdtool graph demo.gif --title="Demo Graph" \ + rrdtool graph demo.png --title="Demo Graph" \ DEF:idat1=interface1.rrd:ds0:AVERAGE \ DEF:idat2=interface2.rrd:ds0:AVERAGE \ DEF:odat1=interface1.rrd:ds1:AVERAGE \ diff --git a/doc/rrdgraph-old.pod b/doc/rrdgraph-old.pod index 8e8038e..b464c42 100644 --- a/doc/rrdgraph-old.pod +++ b/doc/rrdgraph-old.pod @@ -20,7 +20,7 @@ S<[B<-w>|B<--width> I]> S<[B<-h>|B<--height> I]> S<[B<-i>|B<--interlaced>]> S<[B<-f>|B<--imginfo> I]> -S<[B<-a>|B<--imgformat> B|B]> +S<[B<-a>|B<--imgformat> B|B]> S<[B<-z>|B<--lazy>]> S<[B<-o>|B<--logarithmic>]> S<[B<-u>|B<--upper-limit> I]> @@ -54,14 +54,11 @@ from generating graphs, it can also extract numerical reports. =item I The name of the graph to generate. Since B outputs -GIFs and PNGs, it's recommended that the filename end in either -F<.gif> or F<.png>. B does not enforce this, however. +SVGs and PNGs, it's recommended that the filename end in either +F<.svg> or F<.png>. B does not enforce this, however. If the I is set to '-' the image file will be written to standard out. All other output will get suppressed. -PNG output is recommended, since it takes up to 40% less disk space -and 20-30% less time to generate than a GIF file. - If no graph functions are called, the graph will not be created. =item B<-s>|B<--start> I (default end-1day) @@ -170,20 +167,20 @@ specify the units used. =item B<-w>|B<--width> I (default 400 pixel) Width of the drawing area within the graph. This affects the size of the -gif. +image. =item B<-h>|B<--height> I (default 100 pixel) Width of the drawing area within the graph. This affects the size of the -gif. +image. =item B<-i>|B<--interlaced> (default: false) -If you set this option, then the resulting GIF will be interlaced. +If you set this option, then the resulting image will be interlaced. Most web browsers display these incrementally as they load. If -you do not use this option, the GIFs default to being progressive +you do not use this option, the image defaults to being progressive scanned. The only effect of this option is to control the format -of the GIF on disk. It makes no changes to the layout or contents +of the image on disk. It makes no changes to the layout or contents of the graph. =item B<-f>|B<--imginfo> I @@ -197,13 +194,13 @@ would look like this: --imginfo 'Demo' -=item B<-a>|B<--imgformat> B|B (default: GIF) +=item B<-a>|B<--imgformat> B|B (default: PNG) Allows you to produce PNG output from rrdtool. =item B<-z>|B<--lazy> (default: false) -Only generate the graph, if the current gif is out of date or not +Only generate the graph, if the current image is out of date or not existent. =item B<-u>|B<--upper-limit> I (default autoconfigure) @@ -521,11 +518,11 @@ before placing the next row of legends. =head1 NOTE on Return Values Whenever rrd_graph gets called, it prints a line telling the size of -the gif it has just created to STDOUT. This line looks like this: XSIZExYSIZE. +the image it has just created to STDOUT. This line looks like this: XSIZExYSIZE. =head1 EXAMPLE 1 - rrdtool graph demo.gif --title="Demo Graph" \ + rrdtool graph demo.png --title="Demo Graph" \ DEF:cel=demo.rrd:exhaust:AVERAGE \ "CDEF:far=cel,1.8,*,32,+"" \ LINE2:cel#00a000:"D. Celsius" \ @@ -538,7 +535,7 @@ I<*UNKNOWN*> values to 0. This technique is useful if you are aggregating interface data where the start dates of the data sets doesn't match. - rrdtool graph demo.gif --title="Demo Graph" \ + rrdtool graph demo.png --title="Demo Graph" \ DEF:idat1=interface1.rrd:ds0:AVERAGE \ DEF:idat2=interface2.rrd:ds0:AVERAGE \ DEF:odat1=interface1.rrd:ds1:AVERAGE \ @@ -602,7 +599,7 @@ If the specialized function B exist for aberrant behavior detection, they can be used to generate the graph of a time series with confidence bands and failures. - rrdtool graph example.gif \ + rrdtool graph example.png \ DEF:obs=monitor.rrd:ifOutOctets:AVERAGE \ DEF:pred=monitor.rrd:ifOutOctets:HWPREDICT \ DEF:dev=monitor.rrd:ifOutOctets:DEVPREDICT \ diff --git a/doc/rrdgraph_graph.src b/doc/rrdgraph_graph.src index 732e03b..0209b05 100644 --- a/doc/rrdgraph_graph.src +++ b/doc/rrdgraph_graph.src @@ -131,12 +131,12 @@ BIB<:>IB<:>I I This is the same as B but now it is printed inside the graph. -See L for more information. +See L for more information. BIB<:>I This is the same as B but now it is printed inside the graph. -See L for more information. +See L for more information. BI diff --git a/doc/rrdtutorial.es.pod b/doc/rrdtutorial.es.pod index c1f38b3..0c249eb 100644 --- a/doc/rrdtutorial.es.pod +++ b/doc/rrdtutorial.es.pod @@ -76,7 +76,7 @@ probable es que empieces a usar RRDtool para guardar y procesar datos conseguidos a través de SNMP, y que los datos sean el número de bytes (o bits) transferidos desde y hacia una red u ordenador. RRDtool te permite crear una base de datos, guardar los -datos en ellas, recuperarlos y crear gráficos en formato GIF o PNG, +datos en ellas, recuperarlos y crear gráficos en formato SVG o PNG, para mostrarlos en un navegador web. Esas imágenes dependen de los datos que hayas guardado y pueden, por ejemplo, ser un sumario del promedio de uso de la red, o los picos de tráfico que ocurrieron. @@ -332,12 +332,12 @@ Lo que representa exactamente esta salida lo vamos m Prueba este comando: - rrdtool graph speed.gif \ + rrdtool graph speed.png \ --start 920804400 --end 920808000 \ DEF:myspeed=test.rrd:speed:AVERAGE \ LINE2:myspeed#FF0000 -Este comando crea speed.gif, un gráfico de los datos desde las +Este comando crea speed.png, un gráfico de los datos desde las 12:00 hasta las 13:00. Contiene una definición de la variable myspeed y define el color como rojo. Notarás que el gráfico no comienza exactamente a las 12:00 sino a las 12:05, y es porque no tenemos datos @@ -360,10 +360,10 @@ FFFFFF; el negro es la ausencia de todos los colores: 000000. violeta #FF00FF (mezcla de rojo y azul) gris #555555 (un tercio de cada uno de los colores) -El archivo GIF que acabas de crear puede +El archivo PNG que acabas de crear puede verse con tu visor de archivos de imagen favorito. Los navegadores lo mostrarán usando la URL -``file://el/camino/de/directorios/hasta/speed.gif'' +``file://el/camino/de/directorios/hasta/speed.png'' =head2 Gráficos con un poco de matemática @@ -384,9 +384,9 @@ Donde nos equivocamos fue en que debimos medir en metros. As Vamos a corregirlo. Podríamos recrear la base de datos con los valores correctos, pero hay una forma mejor: ¡haciendo los cálculos -mientras creamos el archivo gif! +mientras creamos el archivo png! - rrdtool graph speed2.gif \ + rrdtool graph speed2.png \ --start 920804400 --end 920808000 \ --vertical-label m/s \ DEF:myspeed=test.rrd:speed:AVERAGE \ @@ -395,7 +395,7 @@ mientras creamos el archivo gif! Cuando veas esta imagen, notarás que la ``m'' ha desaparecido, y ahora tienes los resultados correctos. Además hemos añadido una -etiqueta a la imagen. Apartando esto, el archivo GIF es el mismo. +etiqueta a la imagen. Apartando esto, el archivo PNG es el mismo. Las operaciones están en la sección del CDEF y están escritas en Notación Polaca Inversa (Reverse Polish Notation o @@ -418,9 +418,9 @@ Como en nuestra base de datos cometimos un error guardando los valores en kilómetros, debemos compensar por ello, multiplicando por 100, por lo que al aplicar esta corrección nos queda valor * 3600. -Ahora vamos a crear este gif, agreándole un poco más de magia... +Ahora vamos a crear este png, agreándole un poco más de magia... - rrdtool graph speed3.gif \ + rrdtool graph speed3.png \ --start 920804400 --end 920808000 \ --vertical-label km/h \ DEF:myspeed=test.rrd:speed:AVERAGE \ @@ -449,9 +449,9 @@ Para calcular la parte de velocidad "excesiva": =head2 Magia gráfica Me gusta creer que virtualmente no hay limites para lo que RRDtool puede -hacer con los datos. No voy a explicarlo en detalle, pero mira este GIF: +hacer con los datos. No voy a explicarlo en detalle, pero mira este PNG: - rrdtool graph speed4.gif \ + rrdtool graph speed4.png \ --start 920804400 --end 920808000 \ --vertical-label km/h \ DEF:myspeed=test.rrd:speed:AVERAGE \ @@ -464,21 +464,21 @@ hacer con los datos. No voy a explicarlo en detalle, pero mira este GIF: AREA:fast#550000:"Too fast" \ STACK:over#FF0000:"Over speed" -Vamos a crear una página HTML simple para ver los tres archivos GIF: +Vamos a crear una página HTML simple para ver los tres archivos PNG: Velocidad - Speed in meters per second + Speed in meters per second
- Speed in kilometers per hour + Speed in kilometers per hour
- Traveled too fast? + Traveled too fast? Guárdalo como ``speed.html'' o algo parecido, y examínalo con un navegador. Ahora, todo lo que tienes que hacer es medir los datos regularmente y actualizar la base de datos. Cuando quieras verlos, vuelve a crear -los archivos GIF y asegúrate que se carguen de nuevo en tu navegador +los archivos PNG y asegúrate que se carguen de nuevo en tu navegador (Nota: presionar el botón de "refrescar" puede no ser suficiente; en particular, Netscape tiene un problema al respecto, por lo que necesitaras darle al botón mientras presionas la tecla de mayúsculas. @@ -705,7 +705,7 @@ buscar exactamente como hacerlo funcionar en tu sistema operativo. Luego, tras recoger datos por un día, crea una imagen, usando: - rrdtool graph myrouter-day.gif --start -86400 \ + rrdtool graph myrouter-day.png --start -86400 \ DEF:inoctets=myrouter.rrd:input:AVERAGE \ DEF:outoctets=myrouter.rrd:output:AVERAGE \ AREA:inoctets#00FF00:"In traffic" \ @@ -874,7 +874,7 @@ Vamos a probarlos todos: 978303300:2400:6:600:2400 \ 978303600:2700:4:600:2700 \ 978303900:3000:2:1200:3000 - rrdtool graph all1.gif -s 978300600 -e 978304200 -h 400 \ + rrdtool graph all1.png -s 978300600 -e 978304200 -h 400 \ DEF:linea=all.rrd:a:AVERAGE LINE3:linea#FF0000:"Line A" \ DEF:lineb=all.rrd:b:AVERAGE LINE3:lineb#00FF00:"Line B" \ DEF:linec=all.rrd:c:AVERAGE LINE3:linec#0000FF:"Line C" \ @@ -922,7 +922,7 @@ terminando a las 00:10 (las U significan desconocido). - Línea C: u u 2 2 2 0 -2 -6 2 0 2 u - Línea D: u 1 2 3 4 5 6 7 8 9 10 u -Si tu archivo GIF muestra todo esto, has +Si tu archivo PNG muestra todo esto, has entrado los datos correctamente, tu programa RRDtool está funcionando bien, el visor de gráficos no te engaña y hemos entrado en el 2000 sin problemas :) Puedes probar el mismo ejemplo cuatro veces, una por cada línea. @@ -1131,7 +1131,7 @@ tiempo entre 920805000 y 920805900. rrdtool update seconds2.rrd \ 920805000:000 920805300:300 920805603:603 920805900:900 - rrdtool graph seconds1.gif \ + rrdtool graph seconds1.png \ --start 920804700 --end 920806200 \ --height 200 \ --upper-limit 1.05 --lower-limit 0.95 --rigid \ @@ -1139,7 +1139,7 @@ tiempo entre 920805000 y 920805900. CDEF:unknown=seconds,UN \ LINE2:seconds#0000FF \ AREA:unknown#FF0000 - rrdtool graph seconds2.gif \ + rrdtool graph seconds2.png \ --start 920804700 --end 920806200 \ --height 200 \ --upper-limit 1.05 --lower-limit 0.95 --rigid \ diff --git a/examples/cgi-demo.cgi b/examples/cgi-demo.cgi index 5ab4f49..268742e 100755 --- a/examples/cgi-demo.cgi +++ b/examples/cgi-demo.cgi @@ -11,7 +11,7 @@ the shared-demo.pl.

This is NOT traffic

-

" @@ -22,7 +22,7 @@ the shared-demo.pl.

- shared-demo.pl.

This is NOT traffic

-

" @@ -22,7 +22,7 @@ the shared-demo.pl.

- ' arives */ +static char* scanargs(char *aLine, long *argc, char ***args) { char *getP, *putP; diff --git a/src/rrd_gfx.c b/src/rrd_gfx.c index bd84706..e5653b5 100644 --- a/src/rrd_gfx.c +++ b/src/rrd_gfx.c @@ -64,15 +64,15 @@ gfx_canvas_t *gfx_new_canvas (void) { /* create a new line */ gfx_node_t *gfx_new_line(gfx_canvas_t *canvas, - double x0, double y0, - double x1, double y1, + double X0, double Y0, + double X1, double Y1, double width, gfx_color_t color){ - return gfx_new_dashed_line(canvas, x0, y0, x1, y1, width, color, 0, 0); + return gfx_new_dashed_line(canvas, X0, Y0, X1, Y1, width, color, 0, 0); } gfx_node_t *gfx_new_dashed_line(gfx_canvas_t *canvas, - double x0, double y0, - double x1, double y1, + double X0, double Y0, + double X1, double Y1, double width, gfx_color_t color, double dash_on, double dash_off){ @@ -82,8 +82,8 @@ gfx_node_t *gfx_new_dashed_line(gfx_canvas_t *canvas, if (node == NULL) return NULL; vec = art_new(ArtVpath, 3); if (vec == NULL) return NULL; - vec[0].code = ART_MOVETO_OPEN; vec[0].x=x0+LINEOFFSET; vec[0].y=y0+LINEOFFSET; - vec[1].code = ART_LINETO; vec[1].x=x1+LINEOFFSET; vec[1].y=y1+LINEOFFSET; + vec[0].code = ART_MOVETO_OPEN; vec[0].x=X0+LINEOFFSET; vec[0].y=Y0+LINEOFFSET; + vec[1].code = ART_LINETO; vec[1].x=X1+LINEOFFSET; vec[1].y=Y1+LINEOFFSET; vec[2].code = ART_END; node->points = 3; @@ -98,9 +98,9 @@ gfx_node_t *gfx_new_dashed_line(gfx_canvas_t *canvas, /* create a new area */ gfx_node_t *gfx_new_area (gfx_canvas_t *canvas, - double x0, double y0, - double x1, double y1, - double x2, double y2, + double X0, double Y0, + double X1, double Y1, + double X2, double Y2, gfx_color_t color) { gfx_node_t *node; @@ -109,10 +109,10 @@ gfx_node_t *gfx_new_area (gfx_canvas_t *canvas, if (node == NULL) return NULL; vec = art_new(ArtVpath, 5); if (vec == NULL) return NULL; - vec[0].code = ART_MOVETO; vec[0].x=x0; vec[0].y=y0; - vec[1].code = ART_LINETO; vec[1].x=x1; vec[1].y=y1; - vec[2].code = ART_LINETO; vec[2].x=x2; vec[2].y=y2; - vec[3].code = ART_LINETO; vec[3].x=x0; vec[3].y=y0; + vec[0].code = ART_MOVETO; vec[0].x=X0; vec[0].y=Y0; + vec[1].code = ART_LINETO; vec[1].x=X1; vec[1].y=Y1; + vec[2].code = ART_LINETO; vec[2].x=X2; vec[2].y=Y2; + vec[3].code = ART_LINETO; vec[3].x=X0; vec[3].y=Y0; vec[4].code = ART_END; node->points = 5; @@ -128,8 +128,8 @@ int gfx_add_point (gfx_node_t *node, double x, double y){ if (node == NULL) return 1; if (node->type == GFX_AREA) { - double x0 = node->path[0].x; - double y0 = node->path[0].y; + double X0 = node->path[0].x; + double Y0 = node->path[0].y; node->points -= 2; art_vpath_add_point (&(node->path), &(node->points), @@ -140,7 +140,7 @@ int gfx_add_point (gfx_node_t *node, &(node->points), &(node->points_max), ART_LINETO, - x0,y0); + X0,Y0); art_vpath_add_point (&(node->path), &(node->points), &(node->points_max), @@ -384,12 +384,14 @@ int gfx_render_png (gfx_canvas_t *canvas, case GFX_H_RIGHT: pen_x -= text_width; break; case GFX_H_CENTER: pen_x -= text_width / 2.0; break; case GFX_H_LEFT: break; + case GFX_H_NULL: break; } switch(node->valign){ case GFX_V_TOP: pen_y += text_height; break; case GFX_V_CENTER: pen_y += text_height / 2.0; break; case GFX_V_BOTTOM: break; + case GFX_V_NULL: break; } glyph_index=0; diff --git a/src/rrd_gfx.h b/src/rrd_gfx.h index ed107cb..d2cb97d 100644 --- a/src/rrd_gfx.h +++ b/src/rrd_gfx.h @@ -50,21 +50,21 @@ gfx_canvas_t *gfx_new_canvas (void); /* create a new line */ gfx_node_t *gfx_new_line (gfx_canvas_t *canvas, - double x0, double y0, - double x1, double y1, + double X0, double Y0, + double X1, double Y1, double width, gfx_color_t color); gfx_node_t *gfx_new_dashed_line (gfx_canvas_t *canvas, - double x0, double y0, - double x1, double y1, + double X0, double Y0, + double X1, double Y1, double width, gfx_color_t color, double dash_on, double dash_off); /* create a new area */ gfx_node_t *gfx_new_area (gfx_canvas_t *canvas, - double x0, double y0, - double x1, double y1, - double x2, double y2, + double X0, double Y0, + double X1, double Y1, + double X2, double Y2, gfx_color_t color); /* add a point to a line or to an area */ diff --git a/src/rrd_graph.c b/src/rrd_graph.c index bfce36f..5f5ab27 100644 --- a/src/rrd_graph.c +++ b/src/rrd_graph.c @@ -12,7 +12,6 @@ #ifdef WIN32 #include #include -#define RRD_DEFAULT_FONT "c:/winnt/fonts/COUR.TTF" #endif #include "rrd_graph.h" @@ -1220,7 +1219,6 @@ print_calc(image_desc_t *im, char ***prdata) } } break; - case GF_COMMENT: case GF_LINE: case GF_AREA: case GF_TICK: @@ -1229,6 +1227,7 @@ print_calc(image_desc_t *im, char ***prdata) case GF_VRULE: graphelement = 1; break; + case GF_COMMENT: case GF_DEF: case GF_CDEF: case GF_VDEF: @@ -1250,7 +1249,7 @@ leg_place(image_desc_t *im) int border = im->text_prop[TEXT_PROP_LEGEND].size*2.0; int fill=0, fill_last; int leg_c = 0; - int leg_x = border, leg_y = im->ygif; + int leg_x = border, leg_y = im->yimg; int leg_cc; int glue = 0; int i,ii, mark = 0; @@ -1311,7 +1310,7 @@ leg_place(image_desc_t *im) if (i == im->gdes_c -1 ) prt_fctn ='l'; /* is it time to place the legends ? */ - if (fill > im->xgif - 2*border){ + if (fill > im->ximg - 2*border){ if (leg_c > 1) { /* go back one */ i--; @@ -1329,12 +1328,12 @@ leg_place(image_desc_t *im) if (prt_fctn != '\0'){ leg_x = border; if (leg_c >= 2 && prt_fctn == 'j') { - glue = (im->xgif - fill - 2* border) / (leg_c-1); + glue = (im->ximg - fill - 2* border) / (leg_c-1); } else { glue = 0; } - if (prt_fctn =='c') leg_x = (im->xgif - fill) / 2.0; - if (prt_fctn =='r') leg_x = im->xgif - fill - border; + if (prt_fctn =='c') leg_x = (im->ximg - fill) / 2.0; + if (prt_fctn =='r') leg_x = im->ximg - fill - border; for(ii=mark;ii<=i;ii++){ if(im->gdes[ii].legend[0]=='\0') @@ -1360,7 +1359,7 @@ leg_place(image_desc_t *im) mark = ii; } } - im->ygif = leg_y; + im->yimg = leg_y; free(legspace); } return 0; @@ -1384,7 +1383,7 @@ horizontal_grid(image_desc_t *im) double gridstep; double scaledstep; char graph_label[100]; - double x0,x1,y0; + double X0,X1,Y0; int labfact,gridind; int decimals, fractionals; char labfmt[64]; @@ -1455,16 +1454,16 @@ horizontal_grid(image_desc_t *im) labfact = im->ylabfact; } - x0=im->xorigin; - x1=im->xorigin+im->xsize; + X0=im->xorigin; + X1=im->xorigin+im->xsize; sgrid = (int)( im->minval / gridstep - 1); egrid = (int)( im->maxval / gridstep + 1); scaledstep = gridstep/im->magfact; for (i = sgrid; i <= egrid; i++){ - y0=ytr(im,gridstep*i); - if ( y0 >= im->yorigin-im->ysize - && y0 <= im->yorigin){ + Y0=ytr(im,gridstep*i); + if ( Y0 >= im->yorigin-im->ysize + && Y0 <= im->yorigin){ if(i % labfact == 0){ if (i==0 || im->symbol == ' ') { if(scaledstep < 1){ @@ -1486,21 +1485,21 @@ horizontal_grid(image_desc_t *im) } gfx_new_text ( im->canvas, - x0-im->text_prop[TEXT_PROP_AXIS].size/1.5, y0, + X0-im->text_prop[TEXT_PROP_AXIS].size/1.5, Y0, im->graph_col[GRC_FONT], im->text_prop[TEXT_PROP_AXIS].font, im->text_prop[TEXT_PROP_AXIS].size, im->tabwidth, 0.0, GFX_H_RIGHT, GFX_V_CENTER, graph_label ); gfx_new_line ( im->canvas, - x0-2,y0, - x1+2,y0, + X0-2,Y0, + X1+2,Y0, MGRIDWIDTH, im->graph_col[GRC_MGRID] ); } else { gfx_new_line ( im->canvas, - x0-1,y0, - x1+1,y0, + X0-1,Y0, + X1+1,Y0, GRIDWIDTH, im->graph_col[GRC_GRID] ); } @@ -1517,7 +1516,7 @@ horizontal_log_grid(image_desc_t *im) int ii,i; int minoridx=0, majoridx=0; char graph_label[100]; - double x0,x1,y0; + double X0,X1,Y0; double value, pixperstep, minstep; /* find grid spaceing */ @@ -1540,8 +1539,8 @@ horizontal_log_grid(image_desc_t *im) if(pixperstep > 2 * im->text_prop[TEXT_PROP_LEGEND].size){majoridx = i;} } - x0=im->xorigin; - x1=im->xorigin+im->xsize; + X0=im->xorigin; + X1=im->xorigin+im->xsize; /* paint minor grid */ for (value = pow((double)10, log10(im->minval) - fmod(log10(im->minval),log10(yloglab[minoridx][0]))); @@ -1550,11 +1549,11 @@ horizontal_log_grid(image_desc_t *im) if (value < im->minval) continue; i=0; while(yloglab[minoridx][++i] > 0){ - y0 = ytr(im,value * yloglab[minoridx][i]); - if (y0 <= im->yorigin - im->ysize) break; + Y0 = ytr(im,value * yloglab[minoridx][i]); + if (Y0 <= im->yorigin - im->ysize) break; gfx_new_line ( im->canvas, - x0-1,y0, - x1+1,y0, + X0-1,Y0, + X1+1,Y0, GRIDWIDTH, im->graph_col[GRC_GRID] ); } } @@ -1567,16 +1566,16 @@ horizontal_log_grid(image_desc_t *im) if (value < im->minval) continue; i=0; while(yloglab[majoridx][++i] > 0){ - y0 = ytr(im,value * yloglab[majoridx][i]); - if (y0 <= im->yorigin - im->ysize) break; + Y0 = ytr(im,value * yloglab[majoridx][i]); + if (Y0 <= im->yorigin - im->ysize) break; gfx_new_line ( im->canvas, - x0-2,y0, - x1+2,y0, + X0-2,Y0, + X1+2,Y0, MGRIDWIDTH, im->graph_col[GRC_MGRID] ); sprintf(graph_label,"%3.0e",value * yloglab[majoridx][i]); gfx_new_text ( im->canvas, - x0-im->text_prop[TEXT_PROP_AXIS].size/1.5, y0, + X0-im->text_prop[TEXT_PROP_AXIS].size/1.5, Y0, im->graph_col[GRC_FONT], im->text_prop[TEXT_PROP_AXIS].font, im->text_prop[TEXT_PROP_AXIS].size, @@ -1596,7 +1595,7 @@ vertical_grid( time_t ti, tilab; long factor; char graph_label[100]; - double x0,y0,y1; /* points for filled graph and more*/ + double X0,Y0,Y1; /* points for filled graph and more*/ /* the type of time grid is determined by finding @@ -1619,8 +1618,8 @@ vertical_grid( } /* y coords are the same for every line ... */ - y0 = im->yorigin; - y1 = im->yorigin-im->ysize; + Y0 = im->yorigin; + Y1 = im->yorigin-im->ysize; /* paint the minor grid */ @@ -1632,8 +1631,8 @@ vertical_grid( ){ /* are we inside the graph ? */ if (ti < im->start || ti > im->end) continue; - x0 = xtr(im,ti); - gfx_new_line(im->canvas,x0,y0+1, x0,y1-1,GRIDWIDTH, im->graph_col[GRC_GRID]); + X0 = xtr(im,ti); + gfx_new_line(im->canvas,X0,Y0+1, X0,Y1-1,GRIDWIDTH, im->graph_col[GRC_GRID]); } @@ -1646,8 +1645,8 @@ vertical_grid( ){ /* are we inside the graph ? */ if (ti < im->start || ti > im->end) continue; - x0 = xtr(im,ti); - gfx_new_line(im->canvas,x0,y0+2, x0,y1-2,MGRIDWIDTH, im->graph_col[GRC_MGRID]); + X0 = xtr(im,ti); + gfx_new_line(im->canvas,X0,Y0+2, X0,Y1-2,MGRIDWIDTH, im->graph_col[GRC_MGRID]); } /* paint the labels below the graph */ @@ -1667,7 +1666,7 @@ vertical_grid( # error "your libc has no strftime I guess we'll abort the exercise here." #endif gfx_new_text ( im->canvas, - xtr(im,tilab), y0+im->text_prop[TEXT_PROP_AXIS].size/1.5, + xtr(im,tilab), Y0+im->text_prop[TEXT_PROP_AXIS].size/1.5, im->graph_col[GRC_FONT], im->text_prop[TEXT_PROP_AXIS].font, im->text_prop[TEXT_PROP_AXIS].size, @@ -1706,7 +1705,7 @@ axis_paint( gfx_new_area ( im->canvas, im->xorigin+im->xsize+3, im->yorigin-3, im->xorigin+im->xsize+3, im->yorigin+4, - im->xorigin+im->xsize+8, im->yorigin+0.5, // LINEOFFSET + im->xorigin+im->xsize+8, im->yorigin+0.5, /* LINEOFFSET */ im->graph_col[GRC_ARROW]); @@ -1718,26 +1717,26 @@ grid_paint(image_desc_t *im) { long i; int res=0; - double x0,y0; /* points for filled graph and more*/ + double X0,Y0; /* points for filled graph and more*/ gfx_node_t *node; /* draw 3d border */ - node = gfx_new_area (im->canvas, 0,im->ygif, - 2,im->ygif-2, + node = gfx_new_area (im->canvas, 0,im->yimg, + 2,im->yimg-2, 2,2,im->graph_col[GRC_SHADEA]); - gfx_add_point( node , im->xgif - 2, 2 ); - gfx_add_point( node , im->xgif, 0 ); + gfx_add_point( node , im->ximg - 2, 2 ); + gfx_add_point( node , im->ximg, 0 ); gfx_add_point( node , 0,0 ); -/* gfx_add_point( node , 0,im->ygif ); */ +/* gfx_add_point( node , 0,im->yimg ); */ - node = gfx_new_area (im->canvas, 2,im->ygif-2, - im->xgif-2,im->ygif-2, - im->xgif - 2, 2, + node = gfx_new_area (im->canvas, 2,im->yimg-2, + im->ximg-2,im->yimg-2, + im->ximg - 2, 2, im->graph_col[GRC_SHADEB]); - gfx_add_point( node , im->xgif,0); - gfx_add_point( node , im->xgif,im->ygif); - gfx_add_point( node , 0,im->ygif); -/* gfx_add_point( node , 0,im->ygif ); */ + gfx_add_point( node , im->ximg,0); + gfx_add_point( node , im->ximg,im->yimg); + gfx_add_point( node , 0,im->yimg); +/* gfx_add_point( node , 0,im->yimg ); */ if (im->draw_x_grid == 1 ) @@ -1753,7 +1752,7 @@ grid_paint(image_desc_t *im) /* dont draw horizontal grid if there is no min and max val */ if (! res ) { char *nodata = "No Data found"; - gfx_new_text(im->canvas,im->xgif/2, (2*im->yorigin-im->ysize) / 2, + gfx_new_text(im->canvas,im->ximg/2, (2*im->yorigin-im->ysize) / 2, im->graph_col[GRC_FONT], im->text_prop[TEXT_PROP_AXIS].font, im->text_prop[TEXT_PROP_AXIS].size, @@ -1792,7 +1791,7 @@ grid_paint(image_desc_t *im) /* graph title */ gfx_new_text( im->canvas, - im->xgif/2, im->text_prop[TEXT_PROP_TITLE].size, + im->ximg/2, im->text_prop[TEXT_PROP_TITLE].size, im->graph_col[GRC_FONT], im->text_prop[TEXT_PROP_TITLE].font, im->text_prop[TEXT_PROP_TITLE].size, im->tabwidth, 0.0, @@ -1806,8 +1805,8 @@ grid_paint(image_desc_t *im) continue; /* im->gdes[i].leg_y is the bottom of the legend */ - x0 = im->gdes[i].leg_x; - y0 = im->gdes[i].leg_y; + X0 = im->gdes[i].leg_x; + Y0 = im->gdes[i].leg_y; /* Box needed? */ if ( im->gdes[i].gf != GF_GPRINT && im->gdes[i].gf != GF_COMMENT) { @@ -1820,20 +1819,20 @@ grid_paint(image_desc_t *im) boxV = boxH; node = gfx_new_area(im->canvas, - x0,y0-boxV, - x0,y0, - x0+boxH,y0, + X0,Y0-boxV, + X0,Y0, + X0+boxH,Y0, im->gdes[i].col); - gfx_add_point ( node, x0+boxH, y0-boxV ); + gfx_add_point ( node, X0+boxH, Y0-boxV ); node = gfx_new_line(im->canvas, - x0,y0-boxV, x0,y0, + X0,Y0-boxV, X0,Y0, 1,0x000000FF); - gfx_add_point(node,x0+boxH,y0); - gfx_add_point(node,x0+boxH,y0-boxV); + gfx_add_point(node,X0+boxH,Y0); + gfx_add_point(node,X0+boxH,Y0-boxV); gfx_close_path(node); - x0 += boxH / 1.25 * 2; + X0 += boxH / 1.25 * 2; } - gfx_new_text ( im->canvas, x0, y0, + gfx_new_text ( im->canvas, X0, Y0, im->graph_col[GRC_FONT], im->text_prop[TEXT_PROP_AXIS].font, im->text_prop[TEXT_PROP_AXIS].size, @@ -1851,21 +1850,21 @@ grid_paint(image_desc_t *im) int lazy_check(image_desc_t *im){ FILE *fd = NULL; int size = 1; - struct stat gifstat; + struct stat imgstat; if (im->lazy == 0) return 0; /* no lazy option */ - if (stat(im->graphfile,&gifstat) != 0) + if (stat(im->graphfile,&imgstat) != 0) return 0; /* can't stat */ /* one pixel in the existing graph is more then what we would change here ... */ - if (time(NULL) - gifstat.st_mtime > + if (time(NULL) - imgstat.st_mtime > (im->end - im->start) / im->xsize) return 0; if ((fd = fopen(im->graphfile,"rb")) == NULL) return 0; /* the file does not exist */ switch (im->canvas->imgformat) { case IF_PNG: - size = PngSize(fd,&(im->xgif),&(im->ygif)); + size = PngSize(fd,&(im->ximg),&(im->yimg)); break; default: size = 1; @@ -1949,7 +1948,9 @@ graph_size_location(image_desc_t *im, int elements, int piechart ) Xmain =0, Ymain =0, Xpie =0, Ypie =0, Xxlabel =0, Yxlabel =0, +#if 0 Xlegend =0, Ylegend =0, +#endif Xspacing =10, Yspacing =10; if (im->ylegend[0] != '\0') { @@ -2000,13 +2001,13 @@ graph_size_location(image_desc_t *im, int elements, int piechart ) ** forget about it at all; the legend will have to fit in the ** size already allocated. */ - im->xgif = Xylabel + Xmain + Xpie + Xspacing; - if (Xmain) im->xgif += Xspacing; - if (Xpie) im->xgif += Xspacing; + im->ximg = Xylabel + Xmain + Xpie + Xspacing; + if (Xmain) im->ximg += Xspacing; + if (Xpie) im->ximg += Xspacing; im->xorigin = Xspacing + Xylabel; - if (Xtitle > im->xgif) im->xgif = Xtitle; + if (Xtitle > im->ximg) im->ximg = Xtitle; if (Xvertical) { - im->xgif += Xvertical; + im->ximg += Xvertical; im->xorigin += Xvertical; } xtr(im,0); @@ -2021,33 +2022,33 @@ graph_size_location(image_desc_t *im, int elements, int piechart ) */ /* reserve space for main and/or pie */ - im->ygif = Ymain + Yxlabel; - if (im->ygif < Ypie) im->ygif = Ypie; - im->yorigin = im->ygif - Yxlabel; + im->yimg = Ymain + Yxlabel; + if (im->yimg < Ypie) im->yimg = Ypie; + im->yorigin = im->yimg - Yxlabel; /* reserve space for the title *or* some padding above the graph */ if (Ytitle) { - im->ygif += Ytitle; + im->yimg += Ytitle; im->yorigin += Ytitle; } else { - im->ygif += Yspacing; + im->yimg += Yspacing; im->yorigin += Yspacing; } /* reserve space for padding below the graph */ - im->ygif += Yspacing; + im->yimg += Yspacing; ytr(im,DNAN); /* Determine where to place the legends onto the image. - ** Adjust im->ygif to match the space requirements. + ** Adjust im->yimg to match the space requirements. */ if(leg_place(im)==-1) return -1; /* last of three steps: check total height of image */ - if (im->ygif < Yvertical) im->ygif = Yvertical; + if (im->yimg < Yvertical) im->yimg = Yvertical; #if 0 - if (Xlegend > im->xgif) { - im->xgif = Xlegend; + if (Xlegend > im->ximg) { + im->ximg = Xlegend; /* reposition Pie */ #endif @@ -2056,10 +2057,10 @@ graph_size_location(image_desc_t *im, int elements, int piechart ) ** padding. */ if (elements) { - im->pie_x = im->xgif - Xspacing - Xpie/2; + im->pie_x = im->ximg - Xspacing - Xpie/2; im->pie_y = im->yorigin-Ymain+Ypie/2; } else { - im->pie_x = im->xgif/2; + im->pie_x = im->ximg/2; im->pie_y = im->yorigin-Ypie/2; } @@ -2135,11 +2136,11 @@ graph_paint(image_desc_t *im, char ***calcpr) node=gfx_new_area ( im->canvas, 0, 0, - im->xgif, 0, - im->xgif, im->ygif, + im->ximg, 0, + im->ximg, im->yimg, im->graph_col[GRC_BACK]); - gfx_add_point(node,0, im->ygif); + gfx_add_point(node,0, im->yimg); if (piechart != 2) { node=gfx_new_area ( im->canvas, @@ -2347,7 +2348,7 @@ graph_paint(image_desc_t *im, char ***calcpr) return (-1); } } - gfx_render (im->canvas,im->xgif,im->ygif,0x0,fo); + gfx_render (im->canvas,im->ximg,im->yimg,0x0,fo); if (strcmp(im->graphfile,"-") != 0) fclose(fo); return 0; @@ -2455,8 +2456,8 @@ rrd_graph(int argc, char **argv, char ***prdata, int *xsize, int *ysize) ** Also, if needed, print a line with information about the image. */ - *xsize=im.xgif; - *ysize=im.ygif; + *xsize=im.ximg; + *ysize=im.yimg; if (im.imginfo) { char *filename; if (!(*prdata)) { @@ -2477,7 +2478,7 @@ rrd_graph(int argc, char **argv, char ***prdata, int *xsize, int *ysize) filename--; } - sprintf((*prdata)[0],im.imginfo,filename,(long)(im.canvas->zoom*im.xgif),(long)(im.canvas->zoom*im.ygif)); + sprintf((*prdata)[0],im.imginfo,filename,(long)(im.canvas->zoom*im.ximg),(long)(im.canvas->zoom*im.yimg)); } im_free(&im); return 0; @@ -2489,8 +2490,8 @@ rrd_graph_init(image_desc_t *im) int i; im->xlab_user.minsec = -1; - im->xgif=0; - im->ygif=0; + im->ximg=0; + im->yimg=0; im->xsize = 400; im->ysize = 100; im->step = 0; diff --git a/src/rrd_graph.h b/src/rrd_graph.h index 3abb154..de73a72 100644 --- a/src/rrd_graph.h +++ b/src/rrd_graph.h @@ -136,15 +136,16 @@ typedef struct image_desc_t { values outside */ char* imginfo; /* construct an