From d252a95b51aac07904ec27dde793826894ba8ad9 Mon Sep 17 00:00:00 2001 From: oetiker Date: Sat, 23 Mar 2002 08:53:31 +0000 Subject: [PATCH 01/16] Move CDEF start pointers if start of cdef is a step ahead of the start of the data -- Ashok Mandala git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk/program@100 a5681a0c-68f1-0310-ab6d-d61299d08faa --- src/rrd_graph.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/rrd_graph.c b/src/rrd_graph.c index 04cdc54..166d562 100644 --- a/src/rrd_graph.c +++ b/src/rrd_graph.c @@ -816,6 +816,17 @@ printf("DEBUG: value from vdef is %f\n",im->gdes[ptr].vf.val); } /* if OP_VARIABLE */ } /* loop through all rpi */ + /* move the data pointers to the correct period */ + for(rpi=0;im->gdes[gdi].rpnp[rpi].op != OP_END;rpi++){ + if(im->gdes[gdi].rpnp[rpi].op == OP_VARIABLE){ + long ptr = im->gdes[gdi].rpnp[rpi].ptr; + if(im->gdes[gdi].start > im->gdes[ptr].start) { + im->gdes[gdi].rpnp[rpi].data += im->gdes[gdi].rpnp[rpi].ds_cnt; + } + } + } + + if(steparray == NULL){ rrd_set_error("rpn expressions without DEF" " or CDEF variables are not supported"); -- 2.11.0 From 77377ff6ac43512ee216af115a3e62c57a2484a3 Mon Sep 17 00:00:00 2001 From: oetiker Date: Sat, 23 Mar 2002 09:01:43 +0000 Subject: [PATCH 02/16] remove all traces of GIF and make PNG the default git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk/program@101 a5681a0c-68f1-0310-ab6d-d61299d08faa --- src/Makefile.am | 1 - src/rrd_graph.c | 8 +------- src/rrd_graph.h | 2 +- src/rrd_tool.c | 2 +- 4 files changed, 3 insertions(+), 10 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 18d16a0..1ed0fdc 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -42,7 +42,6 @@ INCLUDES = $(CGI_INCLUDES) $(FREETYPE_INCLUDES) $(ART_INCLUDES) \ RRD_C_FILES = \ getopt.c \ getopt1.c \ - gifsize.c \ parsetime.c \ hash_32.c \ rrd_hw.c \ diff --git a/src/rrd_graph.c b/src/rrd_graph.c index 166d562..2e9e009 100644 --- a/src/rrd_graph.c +++ b/src/rrd_graph.c @@ -181,7 +181,6 @@ enum gf_en gf_conv(char *string){ enum if_en if_conv(char *string){ - conv_if(GIF,IF_GIF) conv_if(PNG,IF_PNG) return (-1); @@ -1849,9 +1848,6 @@ int lazy_check(image_desc_t *im){ if ((fd = fopen(im->graphfile,"rb")) == NULL) return 0; /* the file does not exist */ switch (im->imgformat) { - case IF_GIF: - size = GifSize(fd,&(im->xgif),&(im->ygif)); - break; case IF_PNG: size = PngSize(fd,&(im->xgif),&(im->ygif)); break; @@ -2271,8 +2267,6 @@ graph_paint(image_desc_t *im, char ***calcpr) } } switch (im->imgformat) { - case IF_GIF: - break; case IF_PNG: gfx_render_png (canvas,im->xgif,im->ygif,im->zoom,0x0,fo); break; @@ -2444,7 +2438,7 @@ rrd_graph_init(image_desc_t *im) im->gdes_c = 0; im->gdes = NULL; im->zoom = 1.0; - im->imgformat = IF_GIF; /* we default to GIF output */ + im->imgformat = IF_PNG; /* we default to PNG output */ for(i=0;igraph_col[i]=graph_col[i]; diff --git a/src/rrd_graph.h b/src/rrd_graph.h index b86859c..9df2144 100644 --- a/src/rrd_graph.h +++ b/src/rrd_graph.h @@ -25,7 +25,7 @@ enum gf_en {GF_PRINT=0,GF_GPRINT,GF_COMMENT,GF_HRULE,GF_VRULE,GF_LINE, GF_DEF, GF_CDEF, GF_VDEF, GF_PART}; -enum if_en {IF_GIF=0,IF_PNG=1}; +enum if_en {IF_PNG=0}; enum vdef_op_en { VDEF_MAXIMUM /* like the MAX in (G)PRINT */ diff --git a/src/rrd_tool.c b/src/rrd_tool.c index b1e0309..72fdddb 100644 --- a/src/rrd_tool.c +++ b/src/rrd_tool.c @@ -81,7 +81,7 @@ void PrintUsage(char *cmd) "\t\t[--units-exponent value]\n" "\t\t[--step seconds]\n" "\t\t[-f|--imginfo printfstr]\n" - "\t\t[-a|--imgformat GIF|PNG]\n" + "\t\t[-a|--imgformat PNG]\n" "\t\t[-c|--color COLORTAG#rrggbb[aa]] [-t|--title string]\n" "\t\t[DEF:vname=rrd:ds-name:CF]\n" "\t\t[CDEF:vname=rpn-expression]\n" -- 2.11.0 From 35e66dd1f1a4c2d6934e74a137f047bc0c6a9c38 Mon Sep 17 00:00:00 2001 From: oetiker Date: Sat, 23 Mar 2002 09:05:32 +0000 Subject: [PATCH 03/16] removed reference to GIF git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk/program@102 a5681a0c-68f1-0310-ab6d-d61299d08faa --- doc/rrdcgi.pod | 12 ++++++------ doc/rrdgraph.src | 4 +--- doc/rrdtutorial.pod | 48 ++++++++++++++++++++++++------------------------ 3 files changed, 31 insertions(+), 33 deletions(-) diff --git a/doc/rrdcgi.pod b/doc/rrdcgi.pod index c48b059..d55095c 100644 --- a/doc/rrdcgi.pod +++ b/doc/rrdcgi.pod @@ -127,7 +127,7 @@ be used: Note that %s stands for the filename part of the graph generated, all -directories given in the GIF file argument will get dropped. +directories given in the PNG file argument will get dropped. =item RRD::PRINT I @@ -147,7 +147,7 @@ The example below creates a web pages with a single RRD graph.

RRDCGI Example Page

- @@ -172,7 +172,7 @@ you want to use a source for your graph.

Graph

- .gif --lazy + .png --lazy --title "Temperatures for " DEF:cel=.rrd:exhaust:AVERAGE LINE2:cel#00a000:"D. Celsius"> @@ -192,8 +192,8 @@ cgi-bins are seperate directories

RRDCGI test Page

' + /.../web/pngs/testhvt.png + --imginfo '' --lazy --start -1d --end now DEF:http_src=/.../rrds/test.rrd:http_src:AVERAGE AREA:http_src#00ff00:http_src @@ -203,7 +203,7 @@ cgi-bins are seperate directories Note 1: Replace /.../ with the relevant directories -Note 2: The SRC=/.../gifs should be paths from the view of the +Note 2: The SRC=/.../pngs should be paths from the view of the webserver/browser =head1 AUTHOR diff --git a/doc/rrdgraph.src b/doc/rrdgraph.src index 2f45c19..06e0761 100644 --- a/doc/rrdgraph.src +++ b/doc/rrdgraph.src @@ -307,9 +307,7 @@ not be all that difficult to add. B<[-i|--interlaced]> -The default is to generate a non-interlaced GIF image. It is recommended -to generate PNG graphics as they take up to 40% less disk space and -20-30% less time to generate. +If images are interlaced they become visible on browsers more quickly. B<[-g|--no-legend]> diff --git a/doc/rrdtutorial.pod b/doc/rrdtutorial.pod index ff61216..a63c74a 100644 --- a/doc/rrdtutorial.pod +++ b/doc/rrdtutorial.pod @@ -67,7 +67,7 @@ the like. Most likely you will start to use the RRDtool to store and process data collected via SNMP. The data will most likely be bytes (or bits) transfered from and to a network or a computer. RRDtool lets you create a database, store data in it, retrieve that data -and create graphs in GIF format for display on a web browser. Those GIF +and create graphs in PNG format for display on a web browser. Those PNG images are dependent on the data you collected and could be, for instance, an overview of the average network usage, or the peaks that occurred. It can also be used to display tidal waves, solar radiation, power @@ -312,12 +312,12 @@ What this output represents will become clear in the rest of the tutorial. Try the following command: - rrdtool graph speed.gif \ + rrdtool graph speed.png \ --start 920804400 --end 920808000 \ DEF:myspeed=test.rrd:speed:AVERAGE \ LINE2:myspeed#FF0000 -This will create speed.gif which starts at 12:00 and ends at 13:00. +This will create speed.png which starts at 12:00 and ends at 13:00. There is a definition of variable myspeed, it is the data from RRA "speed" out of database "test.rrd". The line drawn is 2 pixels high, and comes from variable myspeed. The color is red. @@ -341,9 +341,9 @@ The "color" black is all colors off: 000000 magenta #FF00FF (mixed red with blue) gray #555555 (one third of all components) -The GIF you just created can be displayed using your favorite image -viewer. Web browsers will display the GIF via the URL -"file://the/path/to/speed.gif" +The PNG you just created can be displayed using your favorite image +viewer. Web browsers will display the PNG via the URL +"file://the/path/to/speed.png" =head2 Graphics with some math @@ -362,18 +362,18 @@ have been (12357000-12345000)/300 = 12000/300 = 40. Let's correct that. We could recreate our database and store the correct data but there is a better way: do some calculations while creating the -gif file ! +png file ! - rrdtool graph speed2.gif \ + rrdtool graph speed2.png \ --start 920804400 --end 920808000 \ --vertical-label m/s \ DEF:myspeed=test.rrd:speed:AVERAGE \ CDEF:realspeed=myspeed,1000,\* \ LINE2:realspeed#FF0000 -After viewing this GIF, you notice the "m" has disappeared. This it what +After viewing this PNG, you notice the "m" has disappeared. This it what the correct result would be. Also, a label has been added to the image. -Apart from the things mentioned above, the GIF should be the same. +Apart from the things mentioned above, the PNG should be the same. The calculations are in the CDEF part and are in Reverse Polish Notation ("RPN"). What it says is: "take the data source myspeed and the number @@ -393,9 +393,9 @@ In our example database we made a mistake and we need to compensate for this by multiplying with 1000. Applying that correction: -*- value * 3.6 *1000 == value * 3600 -Now let's create this GIF, and add some more magic ... +Now let's create this PNG, and add some more magic ... - rrdtool graph speed3.gif \ + rrdtool graph speed3.png \ --start 920804400 --end 920808000 \ --vertical-label km/h \ DEF:myspeed=test.rrd:speed:AVERAGE \ @@ -424,9 +424,9 @@ For the other speed: I like to believe there are virtually no limits to how RRDtool graph can manipulate data. I will not explain how it works, but look at the -following GIF: +following PNG: - rrdtool graph speed4.gif \ + rrdtool graph speed4.png \ --start 920804400 --end 920808000 \ --vertical-label km/h \ DEF:myspeed=test.rrd:speed:AVERAGE \ @@ -439,20 +439,20 @@ following GIF: AREA:fast#550000:"Too fast" \ STACK:over#FF0000:"Over speed" -Let's create a quick and dirty HTML page to view three GIFs: +Let's create a quick and dirty HTML page to view three PNGs: Speed - 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? Name the file "speed.html" or similar, and view it. Now, all you have to do is measure the values regularly and update the -database. When you want to view the data, recreate the GIFs and make +database. When you want to view the data, recreate the PNGs and make sure to refresh them in your browser. (Note: just clicking reload may not be enough; Netscape in particular has a problem doing so and you'll need to click reload while pressing the shift key). @@ -670,7 +670,7 @@ to do exactly on your OS to make it work. Then, after collecting data for a day, try to create an image using: - 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" \ @@ -832,7 +832,7 @@ Let's try them all: 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" \ @@ -875,7 +875,7 @@ at 00:10 the next day (where U means unknown/unplotted): - Line C: u u 2 2 2 0 -2 -6 2 0 2 u - Line D: u 1 2 3 4 5 6 7 8 9 10 u -If your GIF shows all this, you know you have typed the data correct, +If your PNG shows all this, you know you have typed the data correct, the RRDtool executable is working properly, your viewer doesn't fool you and you successfully entered the year 2000 :) You could try the same example four times, each time with only one of @@ -1068,7 +1068,7 @@ to 920805900 as this goes very well with the example numbers. 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 \ @@ -1076,7 +1076,7 @@ to 920805900 as this goes very well with the example numbers. 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 \ -- 2.11.0 From 3c8cee9e032f175c987c538a49e6dc0440789e02 Mon Sep 17 00:00:00 2001 From: alex Date: Sat, 23 Mar 2002 19:59:39 +0000 Subject: [PATCH 04/16] Changes in rrd_graph; see NEWS git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk/program@103 a5681a0c-68f1-0310-ab6d-d61299d08faa --- src/rrd_graph.c | 418 +++++++++++++++++++++++++++++++++----------------------- src/rrd_graph.h | 4 +- 2 files changed, 251 insertions(+), 171 deletions(-) diff --git a/src/rrd_graph.c b/src/rrd_graph.c index 2e9e009..7908ad4 100644 --- a/src/rrd_graph.c +++ b/src/rrd_graph.c @@ -1221,7 +1221,6 @@ print_calc(image_desc_t *im, char ***prdata) case GF_LINE: case GF_AREA: case GF_TICK: - case GF_PART: case GF_STACK: case GF_HRULE: case GF_VRULE: @@ -1230,6 +1229,7 @@ print_calc(image_desc_t *im, char ***prdata) case GF_DEF: case GF_CDEF: case GF_VDEF: + case GF_PART: break; } } @@ -1280,7 +1280,7 @@ leg_place(image_desc_t *im) leg_cc--; im->gdes[i].legend[leg_cc]='\0'; } - if (leg_cc != 0 ){ + if (leg_cc != 0 ){ legspace[i]=(prt_fctn=='g' ? 0 : interleg); if (fill > 0){ @@ -1355,7 +1355,7 @@ leg_place(image_desc_t *im) mark = ii; } } - im->ygif = leg_y+6; + im->ygif = leg_y; free(legspace); } return 0; @@ -1654,6 +1654,8 @@ vertical_grid( ti = find_next_time(ti,im->xlab_user.labtm,im->xlab_user.labst) ){ tilab= ti + im->xlab_user.precis/2; /* correct time for the label */ + /* are we inside the graph ? */ + if (ti < im->start || ti > im->end) continue; #if HAVE_STRFTIME strftime(graph_label,99,im->xlab_user.stst,localtime(&tilab)); @@ -1716,11 +1718,9 @@ grid_paint( ) { long i; - int boxH=8, boxV=8; int res=0; double x0,x1,x2,x3,y0,y1,y2,y3; /* points for filled graph and more*/ gfx_node_t *node; - /* draw 3d border */ node = gfx_new_area (canvas, 0,im->ygif, @@ -1764,68 +1764,85 @@ grid_paint( } /* yaxis description */ - gfx_new_text( canvas, - 7, (im->yorigin - im->ysize/2), - im->graph_col[GRC_FONT], - im->text_prop[TEXT_PROP_AXIS].font, - im->text_prop[TEXT_PROP_AXIS].size, im->tabwidth, 270.0, - GFX_H_CENTER, GFX_V_CENTER, - im->ylegend); + #if 0 + gfx_new_text( canvas, + 7, (im->yorigin - im->ysize/2), + im->graph_col[GRC_FONT], + im->text_prop[TEXT_PROP_AXIS].font, + im->text_prop[TEXT_PROP_AXIS].size, im->tabwidth, 270.0, + GFX_H_CENTER, GFX_V_CENTER, + im->ylegend); + #else + /* horrible hack until we can actually print vertically */ + { + int n; + int l=strlen(im->ylegend); + char s[2]; + for (n=0;nylegend);n++) { + s[0]=im->ylegend[n]; + s[1]='\0'; + gfx_new_text(canvas,7,im->text_prop[TEXT_PROP_AXIS].size*(l-n), + im->graph_col[GRC_FONT], + im->text_prop[TEXT_PROP_AXIS].font, + im->text_prop[TEXT_PROP_AXIS].size, im->tabwidth, 270.0, + GFX_H_CENTER, GFX_V_CENTER, + s); + } + } + #endif /* graph title */ gfx_new_text( canvas, - im->xgif/2, im->text_prop[TEXT_PROP_TITLE].size*1.5, + im->xgif/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, GFX_H_CENTER, GFX_V_CENTER, im->title); - /* graph labels */ - if( !(im->extra_flags & NOLEGEND) ) { + /* graph labels */ + if( !(im->extra_flags & NOLEGEND) ) { for(i=0;igdes_c;i++){ - if(im->gdes[i].legend[0] =='\0') - continue; + if(im->gdes[i].legend[0] =='\0') + continue; - if(im->gdes[i].gf != GF_GPRINT && im->gdes[i].gf != GF_COMMENT){ - x0 = im->gdes[i].leg_x; - y0 = im->gdes[i].leg_y+1.0; - x1 = x0; - x2 = x0+boxH; - x3 = x0+boxH; - y1 = y0+boxV; - y2 = y0+boxV; - y3 = y0; - node = gfx_new_area(canvas, x0,y0,x1,y1,x2,y2 ,im->gdes[i].col); - gfx_add_point ( node, x3, y3 ); -/* gfx_add_point ( node, x0, y0 ); */ - node = gfx_new_line(canvas, x0,y0,x1,y1 ,GRIDWIDTH, im->graph_col[GRC_FRAME]); - gfx_add_point ( node, x2, y2 ); - gfx_add_point ( node, x3, y3 ); - gfx_add_point ( node, x0, y0 ); - - gfx_new_text ( canvas, x0+boxH+6, (y0+y2) / 2.0, - 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_LEFT, GFX_V_CENTER, - im->gdes[i].legend ); - - } else { - x0 = im->gdes[i].leg_x; - y0 = im->gdes[i].leg_y; - - gfx_new_text ( canvas, x0, (y0+y2) / 2.0, - 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_LEFT, GFX_V_BOTTOM, - im->gdes[i].legend ); - - } - } - } -} + /* im->gdes[i].leg_y is the bottom of the legend */ + 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) { + int boxH, boxV; + + boxH = gfx_get_text_width(0, + im->text_prop[TEXT_PROP_AXIS].font, + im->text_prop[TEXT_PROP_AXIS].size, + im->tabwidth,"M") * 1.25; + boxV = boxH; + + node = gfx_new_area(canvas, + x0,y0-boxV, + x0,y0, + x0+boxH,y0, + im->gdes[i].col); + gfx_add_point ( node, x0+boxH, y0-boxV ); + node = gfx_new_line(canvas, + 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,y0-boxV); + x0 += boxH / 1.25 * 2; + } + gfx_new_text ( canvas, x0, 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_LEFT, GFX_V_BOTTOM, + im->gdes[i].legend ); + } + } + } /***************************************************** @@ -1902,6 +1919,147 @@ pie_part(gfx_canvas_t *canvas, gfx_color_t color, } } +int +graph_size_location(image_desc_t *im, int elements, int piechart ) +{ + /* The actual size of the image to draw is determined from + ** several sources. The size given on the command line is + ** the graph area but we need more as we have to draw labels + ** and other things outside the graph area + */ + + /* +-+-------------------------------------------+ + ** |l|.................title.....................| + ** |e+--+-------------------------------+--------+ + ** |b| b| | | + ** |a| a| | pie | + ** |l| l| main graph area | chart | + ** |.| .| | area | + ** |t| y| | | + ** |r+--+-------------------------------+--------+ + ** |e| | x-axis labels | | + ** |v+--+-------------------------------+--------+ + ** | |..............legends......................| + ** +-+-------------------------------------------+ + */ + int Xvertical=0, Yvertical=0, + Xtitle =0, Ytitle =0, + Xylabel =0, Yylabel =0, + Xmain =0, Ymain =0, + Xpie =0, Ypie =0, + Xxlabel =0, Yxlabel =0, + Xlegend =0, Ylegend =0, + Xspacing =10, Yspacing =10; + + if (im->ylegend[0] != '\0') { + Xvertical = im->text_prop[TEXT_PROP_LEGEND].size *2; + Yvertical = im->text_prop[TEXT_PROP_LEGEND].size * (strlen(im->ylegend)+1); + } + + if (im->title[0] != '\0') { + /* The title is placed "inbetween" two text lines so it + ** automatically has some vertical spacing. The horizontal + ** spacing is added here, on each side. + */ + Xtitle = gfx_get_text_width(0, + im->text_prop[TEXT_PROP_TITLE].font, + im->text_prop[TEXT_PROP_TITLE].size, + im->tabwidth, + im->title) + 2*Xspacing; + Ytitle = im->text_prop[TEXT_PROP_TITLE].size*2; + } + + if (elements) { + Xmain=im->xsize; + Ymain=im->ysize; + if (im->draw_x_grid) { + Xxlabel=Xmain; + Yxlabel=im->text_prop[TEXT_PROP_LEGEND].size *2; + } + if (im->draw_y_grid) { + Xylabel=im->text_prop[TEXT_PROP_LEGEND].size *6; + Yylabel=Ymain; + } + } + + if (piechart) { + im->piesize=im->xsizeysize?im->xsize:im->ysize; + Xpie=im->piesize; + Ypie=im->piesize; + } + + /* Now calculate the total size. Insert some spacing where + desired. im->xorigin and im->yorigin need to correspond + with the lower left corner of the main graph area or, if + this one is not set, the imaginary box surrounding the + pie chart area. */ + + /* The legend width cannot yet be determined, as a result we + ** have problems adjusting the image to it. For now, we just + ** 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->xorigin = Xspacing + Xylabel; + if (Xtitle > im->xgif) im->xgif = Xtitle; + if (Xvertical) { + im->xgif += Xvertical; + im->xorigin += Xvertical; + } + xtr(im,0); + + /* The vertical size is interesting... we need to compare + ** the sum of {Ytitle, Ymain, Yxlabel, Ylegend} with Yvertical + ** however we need to know {Ytitle+Ymain+Yxlabel} in order to + ** start even thinking about Ylegend. + ** + ** Do it in three portions: First calculate the inner part, + ** then do the legend, then adjust the total height of the img. + */ + + /* reserve space for main and/or pie */ + im->ygif = Ymain + Yxlabel; + if (im->ygif < Ypie) im->ygif = Ypie; + im->yorigin = im->ygif - Yxlabel; + /* reserve space for the title *or* some padding above the graph */ + if (Ytitle) { + im->ygif += Ytitle; + im->yorigin += Ytitle; + } else { + im->ygif += Yspacing; + im->yorigin += Yspacing; + } + /* reserve space for padding below the graph */ + im->ygif += Yspacing; + ytr(im,DNAN); + + /* Determine where to place the legends onto the image. + ** Adjust im->ygif 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 0 + if (Xlegend > im->xgif) { + im->xgif = Xlegend; + /* reposition Pie */ +#endif + + /* The pie is placed in the upper right hand corner, + ** just below the title (if any) and with sufficient + ** padding. + */ + im->pie_x = im->xgif - Xspacing - Xpie/2; + im->pie_y = im->yorigin-Ymain+Ypie/2; + + return 0; +} + /* draw that picture thing ... */ int graph_paint(image_desc_t *im, char ***calcpr) @@ -1909,7 +2067,7 @@ graph_paint(image_desc_t *im, char ***calcpr) int i,ii; int lazy = lazy_check(im); int piechart = 0; - double PieStart=0.0, PieSize=0.0, PieCenterX=0.0, PieCenterY=0.0; + double PieStart=0.0; FILE *fo; gfx_canvas_t *canvas; gfx_node_t *node; @@ -1930,6 +2088,14 @@ graph_paint(image_desc_t *im, char ***calcpr) if(data_calc(im)==-1) return -1; + /* check if we need to draw a piechart */ + for(i=0;igdes_c;i++){ + if (im->gdes[i].gf == GF_PART) { + piechart=1; + break; + } + } + /* calculate and PRINT and GPRINT definitions. We have to do it at * this point because it will affect the length of the legends * if there are no graph elements we stop here ... @@ -1937,7 +2103,10 @@ graph_paint(image_desc_t *im, char ***calcpr) */ i=print_calc(im,calcpr); if(i<0) return -1; - if(i==0 || lazy) return 0; + if(((i==0)&&(piechart==0)) || lazy) return 0; + + /* If there's only the pie chart to draw, signal this */ + if (i==0) piechart=2; /* get actual drawing data and find min and max values*/ if(data_proc(im)==-1) @@ -1948,57 +2117,16 @@ graph_paint(image_desc_t *im, char ***calcpr) if(!im->rigid && ! im->logarithmic) expand_range(im); /* make sure the upper and lower limit are sensible values */ - - /* init xtr and ytr */ - /* determine the actual size of the gif to draw. The size given - on the cmdline is the graph area. But we need more as we have - draw labels and other things outside the graph area */ - - - im->xorigin = 10 + 9 * im->text_prop[TEXT_PROP_LEGEND].size; - - xtr(im,0); - - im->yorigin = 10 + im->ysize; - - ytr(im,DNAN); - - if(im->title[0] != '\0') - im->yorigin += im->text_prop[TEXT_PROP_TITLE].size*3+4; - - im->xgif= 20 +im->xsize + im->xorigin; - im->ygif= im->yorigin+2* im->text_prop[TEXT_PROP_LEGEND].size; - - /* check if we need to draw a piechart */ - for(i=0;igdes_c;i++){ - if (im->gdes[i].gf == GF_PART) { - piechart=1; - break; - } - } - if (piechart) { - /* allocate enough space for the piechart itself (PieSize), 20% - ** more for the background and an additional 50 pixels spacing. - */ - if (im->xsize < im->ysize) - PieSize = im->xsize; - else - PieSize = im->ysize; - im->xgif += PieSize*1.2 + 50; - - PieCenterX = im->xorigin + im->xsize + 50 + PieSize*0.6; - PieCenterY = im->yorigin - PieSize*0.5; - } - - /* determine where to place the legends onto the graphics. - and set im->ygif to match space requirements for text */ - if(leg_place(im)==-1) +/************************************************************** + *** Calculating sizes and locations became a bit confusing *** + *** so I moved this into a separate function. *** + **************************************************************/ + if(graph_size_location(im,i,piechart)==-1) return -1; canvas=gfx_new_canvas(); - /* the actual graph is created by going through the individual graph elements and then drawing them */ @@ -2010,82 +2138,27 @@ graph_paint(image_desc_t *im, char ***calcpr) gfx_add_point(node,0, im->ygif); - node=gfx_new_area ( canvas, + if (piechart != 2) { + node=gfx_new_area ( canvas, im->xorigin, im->yorigin, im->xorigin + im->xsize, im->yorigin, im->xorigin + im->xsize, im->yorigin-im->ysize, im->graph_col[GRC_CANVAS]); - gfx_add_point(node,im->xorigin, im->yorigin - im->ysize); - -#if 0 -/****************************************************************** - ** Just to play around. If you see this, I forgot to remove it ** - ******************************************************************/ - im->ygif+=100; - node=gfx_new_area(canvas, - 0, im->ygif-100, - im->xgif, im->ygif-100, - im->xgif, im->ygif, - im->graph_col[GRC_CANVAS]); - gfx_add_point(node,0,im->ygif); - - /* Four areas: - ** top left: current way, solid color - ** top right: proper way, solid color - ** bottom left: current way, alpha=0x80, partially overlapping - ** bottom right: proper way, alpha=0x80, partially overlapping - */ - { - double x,y,x1,y1,x2,y2,x3,y3,x4,y4; - - x=(im->xgif-40)/6; - y= (100-40)/6; - x1= 20; y1=im->ygif-100+20; - x2=3*x+20; y2=im->ygif-100+20; - x3= x+20; y3=im->ygif-100+20+2*y; - x4=4*x+20; y4=im->ygif-100+20+2*y; + gfx_add_point(node,im->xorigin, im->yorigin - im->ysize); - node=gfx_new_area(canvas, - x1,y1, - x1+3*x,y1, - x1+3*x,y1+3*y, - 0xFF0000FF); - gfx_add_point(node,x1,y1+3*y); - node=gfx_new_area(canvas, - x2,y2, - x2,y2+3*y, - x2+3*x,y2+3*y, - 0xFFFF00FF); - gfx_add_point(node,x2+3*x,y2); - node=gfx_new_area(canvas, - x3,y3, - x3+2*x,y3, - x3+2*x,y3+3*y, - 0x00FF007F); - gfx_add_point(node,x3,y3+3*y); - node=gfx_new_area(canvas, - x4,y4, - x4,y4+3*y, - x4+2*x,y4+3*y, - 0x0000FF7F); - gfx_add_point(node,x4+2*x,y4); + if (im->minval > 0.0) + areazero = im->minval; + if (im->maxval < 0.0) + areazero = im->maxval; + + axis_paint(im,canvas); } - -#endif if (piechart) { - pie_part(canvas,im->graph_col[GRC_CANVAS],PieCenterX,PieCenterY,PieSize*0.6,0,2*M_PI); + pie_part(canvas,im->graph_col[GRC_CANVAS],im->pie_x,im->pie_y,im->piesize*0.5,0,2*M_PI); } - if (im->minval > 0.0) - areazero = im->minval; - if (im->maxval < 0.0) - areazero = im->maxval; - - axis_paint(im,canvas); - - for(i=0;igdes_c;i++){ switch(im->gdes[i].gf){ case GF_CDEF: @@ -2211,7 +2284,7 @@ graph_paint(image_desc_t *im, char ***calcpr) if (finite(im->gdes[i].yrule)) { /* even the fetched var can be NaN */ pie_part(canvas,im->gdes[i].col, - PieCenterX,PieCenterY,PieSize/2, + im->pie_x,im->pie_y,im->piesize*0.4, M_PI*2.0*PieStart/100.0, M_PI*2.0*(PieStart+im->gdes[i].yrule)/100.0); PieStart += im->gdes[i].yrule; @@ -2219,6 +2292,11 @@ graph_paint(image_desc_t *im, char ***calcpr) break; } /* switch */ } + if (piechart==2) { + im->draw_x_grid=0; + im->draw_y_grid=0; + } + /* grid_paint also does the text */ grid_paint(im,canvas); /* the RULES are the last thing to paint ... */ diff --git a/src/rrd_graph.h b/src/rrd_graph.h index 9df2144..d222f9a 100644 --- a/src/rrd_graph.h +++ b/src/rrd_graph.h @@ -118,7 +118,7 @@ typedef struct image_desc_t { /* configuration of graph */ char graphfile[MAXPATH]; /* filename for graphic */ - long xsize,ysize; /* graph area size in pixels */ + long xsize,ysize,piesize; /* graph area size in pixels */ double zoom; /* zoom for graph */ gfx_color_t graph_col[__GRC_END__]; /* real colors for the graph */ text_prop_t text_prop[TEXT_PROP_LAST]; /* text properties */ @@ -147,6 +147,7 @@ typedef struct image_desc_t { /* status information */ long xorigin,yorigin;/* where is (0,0) of the graph */ + long pie_x,pie_y; /* where is the centerpoint */ long xgif,ygif; /* total size of the gif */ int interlaced; /* will the graph be interlaced? */ double magfact; /* numerical magnitude*/ @@ -207,3 +208,4 @@ int bad_format(char *); int vdef_parse(struct graph_desc_t *,char *); int vdef_calc(image_desc_t *, int); int vdef_percent_compar(const void *,const void *); +int graph_size_location(image_desc_t *, int, int); -- 2.11.0 From fc04186840774d769fbc2ffcc683cdc1019c089b Mon Sep 17 00:00:00 2001 From: alex Date: Sat, 23 Mar 2002 20:01:13 +0000 Subject: [PATCH 05/16] Modified rrd_graph git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk/program@104 a5681a0c-68f1-0310-ab6d-d61299d08faa --- NEWS | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 403f700..40c69d9 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,13 @@ RRDTOOL NEWS In this file I am noting the Major changes to rrdtool for details check the cvs ChangeLog +2002/03/23 Alex van den Bogaerdt + Several visible changes made to rrd_graph + * Pie chart support workable + * Elements that are not used do not take up space on the img + * Hack for the missing rotated text (see --vertical-label) + * Tiny boxes in front of labels now scale with the text + 2002/01/15 Tobias Oetiker The BIG graph update * Replace libgd with libart @@ -42,7 +49,7 @@ for details check the cvs ChangeLog 2001/03/07 Tobias Oetiker Integrated complete rewrite of rrdgraph documentation by Alex van den Bogaerdt - . This also contains info on his planned + . This also contains info on his planned changes to the rrdgraph module 2001/03/02 Tobias Oetiker -- 2.11.0 From d0e33e637bdd017595931609cb06fa7a396441b5 Mon Sep 17 00:00:00 2001 From: alex Date: Sat, 23 Mar 2002 20:41:48 +0000 Subject: [PATCH 06/16] Better positioning of the pie when it is alone on the canvas git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk/program@105 a5681a0c-68f1-0310-ab6d-d61299d08faa --- src/rrd_graph.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/rrd_graph.c b/src/rrd_graph.c index 7908ad4..8b9e679 100644 --- a/src/rrd_graph.c +++ b/src/rrd_graph.c @@ -2054,8 +2054,13 @@ graph_size_location(image_desc_t *im, int elements, int piechart ) ** just below the title (if any) and with sufficient ** padding. */ - im->pie_x = im->xgif - Xspacing - Xpie/2; - im->pie_y = im->yorigin-Ymain+Ypie/2; + if (elements) { + im->pie_x = im->xgif - Xspacing - Xpie/2; + im->pie_y = im->yorigin-Ymain+Ypie/2; + } else { + im->pie_x = im->xgif/2; + im->pie_y = im->yorigin-Ypie/2; + } return 0; } -- 2.11.0 From bd715d227c39077d697017e111919e9406833972 Mon Sep 17 00:00:00 2001 From: oetiker Date: Tue, 26 Mar 2002 07:02:28 +0000 Subject: [PATCH 07/16] added SVG support -- Peter Speck git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk/program@106 a5681a0c-68f1-0310-ab6d-d61299d08faa --- doc/rrdgraph.src | 6 +- src/rrd_gfx.c | 402 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/rrd_gfx.h | 6 + src/rrd_graph.h | 2 +- 4 files changed, 412 insertions(+), 4 deletions(-) diff --git a/doc/rrdgraph.src b/doc/rrdgraph.src index 06e0761..9dc4050 100644 --- a/doc/rrdgraph.src +++ b/doc/rrdgraph.src @@ -61,7 +61,7 @@ statements (after all, most of them do define graph elements...). =item filename The name and path of the graph to generate. It is recommended to -end this in C<.png> or C<.gif> but B does not enforce this. +end this in C<.png> or C<.svg> but B does not enforce this. I can be 'C<->' to send the image to C. In that case, no other output is generated. @@ -300,9 +300,9 @@ for the graph legend. Use Times for the title: C<--font TITLE:13:/usr/lib/fonts/times.ttf> -B<[-a|--imgformat C]> +B<[-a|--imgformat C|C]> -At present only PNG is supported, but C, C or even C should +At present only C and C are supported, but C, or even C should not be all that difficult to add. B<[-i|--interlaced]> diff --git a/src/rrd_gfx.c b/src/rrd_gfx.c index 405291b..e36910d 100644 --- a/src/rrd_gfx.c +++ b/src/rrd_gfx.c @@ -37,6 +37,7 @@ gfx_node_t *gfx_new_node( gfx_canvas_t *canvas,enum gfx_en type){ node->text = NULL; node->x = 0.0; node->y = 0.0; /* position */ + node->angle = 0; node->halign = GFX_H_NULL; /* text alignement */ node->valign = GFX_V_NULL; /* text alignement */ node->tabwidth = 0.0; @@ -173,6 +174,7 @@ gfx_node_t *gfx_new_text (gfx_canvas_t *canvas, node->filename = strdup(font); node->x = x; node->y = y; + node->angle = angle; node->color = color; node->tabwidth = tabwidth; node->halign = h_align; @@ -467,3 +469,403 @@ static int gfx_save_png (art_u8 *buffer, FILE *fp, long width, long height, lon png_destroy_write_struct(&png_ptr, &info_ptr); return 1; } + + +static int svg_indent = 0; +static int svg_single_line = 0; +static void svg_print_indent(FILE *fp) +{ + int i; + for (i = svg_indent - svg_single_line; i > 0; i--) { + putc(' ', fp); + putc(' ', fp); + } +} + +static void svg_start_tag(FILE *fp, const char *name) + { + svg_print_indent(fp); + putc('<', fp); + fputs(name, fp); + svg_indent++; + } + + static void svg_close_tag_single_line(FILE *fp) + { + svg_single_line++; + putc('>', fp); + } + + static void svg_close_tag(FILE *fp) + { + putc('>', fp); + if (!svg_single_line) + putc('\n', fp); + } + + static void svg_end_tag(FILE *fp, const char *name) + { + /* name is NULL if closing empty-node tag */ + svg_indent--; + if (svg_single_line) + svg_single_line--; + else if (name) + svg_print_indent(fp); + if (name != NULL) { + fputs("': fputs(">", fp); break; + case '"': fputs(""", fp); break; + default: putc(ch, fp); + } + } + } + + static void svg_write_number(FILE *fp, double d) + { + /* omit decimals if integer to reduce filesize */ + char buf[60], *p; + snprintf(buf, sizeof(buf), "%.2f", d); + p = buf; /* doesn't trust snprintf return value */ + while (*p) + p++; + while (--p > buf) { + char ch = *p; + if (ch == '0') { + *p = '\0'; /* zap trailing zeros */ + continue; + } + if (ch == '.') + *p = '\0'; /* zap trailing dot */ + break; + } + fputs(buf, fp); + } + + static int svg_color_is_black(int c) + { + /* gfx_color_t is RRGGBBAA, svg can use #RRGGBB like html */ + c = (int)((c >> 8) & 0xFFFFFF); + return !c; + } + + static void svg_write_color(FILE *fp, int c) + { + /* gfx_color_t is RRGGBBAA, svg can use #RRGGBB like html */ + c = (int)((c >> 8) & 0xFFFFFF); + if ((c & 0x0F0F0F) == ((c >> 4) & 0x0F0F0F)) { + /* css2 short form, #rgb is #rrggbb, not #r0g0b0 */ + fprintf(fp, "#%03X", + ( ((c >> 8) & 0xF00) + | ((c >> 4) & 0x0F0) + | ( c & 0x00F))); + } else { + fprintf(fp, "#%06X", c); + } + } + + static int svg_is_int_step(double a, double b) + { + double diff = fabs(a - b); + return floor(diff) == diff; + } + + static int svg_path_straight_segment(FILE *fp, + double lastA, double currentA, double currentB, + gfx_node_t *node, + int segment_idx, int isx, char absChar, char relChar) + { + if (!svg_is_int_step(lastA, currentA)) { + putc(absChar, fp); + svg_write_number(fp, currentA); + return 0; + } + if (segment_idx < node->points - 1) { + ArtVpath *vec = node->path + segment_idx + 1; + if (vec->code == ART_LINETO) { + double nextA = (isx ? vec->x : vec->y) - LINEOFFSET; + double nextB = (isx ? vec->y : vec->x) - LINEOFFSET; + if (nextB == currentB + && ((currentA >= lastA) == (nextA >= currentA)) + && svg_is_int_step(currentA, nextA)) { + return 1; /* skip to next as it is a straight line */ + } + } + } + putc(relChar, fp); + svg_write_number(fp, currentA - lastA); + return 0; + } + + static void svg_path(FILE *fp, gfx_node_t *node, int multi) + { + int i; + double lastX = 0, lastY = 0; + /* for straight lines tags take less space than + tags because of the efficient packing + in the 'd' attribute */ + svg_start_tag(fp, "path"); + if (!multi) { + fputs(" stroke-width=\"", fp); + svg_write_number(fp, node->size); + fputs("\" stroke=\"", fp); + svg_write_color(fp, node->color); + fputs("\" fill=\"none\"", fp); + } + fputs(" d=\"", fp); + /* specification of the 'd' attribute: */ + /* http://www.w3.org/TR/SVG/paths.html#PathDataGeneralInformation */ + for (i = 0; i < node->points; i++) { + ArtVpath *vec = node->path + i; + double x = vec->x - LINEOFFSET; + double y = vec->y - LINEOFFSET; + switch (vec->code) { + case ART_MOVETO_OPEN: /* fall-through */ + case ART_MOVETO: + putc('M', fp); + svg_write_number(fp, x); + putc(',', fp); + svg_write_number(fp, y); + break; + case ART_LINETO: + /* try optimize filesize by using minimal lineto commands */ + /* without introducing rounding errors. */ + if (x == lastX) { + if (svg_path_straight_segment(fp, lastY, y, x, node, i, 0, 'V', 'v')) + continue; + } else if (y == lastY) { + if (svg_path_straight_segment(fp, lastX, x, y, node, i, 1, 'H', 'h')) + continue; + } else { + putc('L', fp); + svg_write_number(fp, x); + putc(',', fp); + svg_write_number(fp, y); + } + break; + case ART_CURVETO: break; /* unsupported */ + case ART_END: break; /* nop */ + } + lastX = x; + lastY = y; + } + fputs("\"", fp); + svg_close_tag_empty_node(fp); + } + + static void svg_multi_path(FILE *fp, gfx_node_t **nodeR) + { + /* optimize for multiple paths with the same color, penwidth, etc. */ + int num = 1; + gfx_node_t *node = *nodeR; + gfx_node_t *next = node->next; + while (next) { + if (next->type != node->type + || next->size != node->size + || next->color != node->color) + break; + next = next->next; + num++; + } + if (num == 1) { + svg_path(fp, node, 0); + return; + } + svg_start_tag(fp, "g"); + fputs(" stroke-width=\"", fp); + svg_write_number(fp, node->size); + fputs("\" stroke=\"", fp); + svg_write_color(fp, node->color); + fputs("\" fill=\"none\"", fp); + svg_close_tag(fp); + while (num && node) { + svg_path(fp, node, 1); + if (!--num) + break; + node = node->next; + *nodeR = node; + } + svg_end_tag(fp, "g"); + } + + static void svg_area(FILE *fp, gfx_node_t *node) + { + int i; + double startX = 0, startY = 0; + svg_start_tag(fp, "polygon"); + fputs(" fill=\"", fp); + svg_write_color(fp, node->color); + fputs("\" points=\"", fp); + for (i = 0; i < node->points; i++) { + ArtVpath *vec = node->path + i; + double x = vec->x - LINEOFFSET; + double y = vec->y - LINEOFFSET; + switch (vec->code) { + case ART_MOVETO_OPEN: /* fall-through */ + case ART_MOVETO: + svg_write_number(fp, x); + putc(',', fp); + svg_write_number(fp, y); + startX = x; + startY = y; + break; + case ART_LINETO: + if (i == node->points - 2 + && node->path[i + 1].code == ART_END + && fabs(x - startX) < 0.001 && fabs(y - startY) < 0.001) { + break; /* poly area always closed, no need for last point */ + } + putc(' ', fp); + svg_write_number(fp, x); + putc(',', fp); + svg_write_number(fp, y); + break; + case ART_CURVETO: break; /* unsupported */ + case ART_END: break; /* nop */ + } + } + fputs("\"", fp); + svg_close_tag_empty_node(fp); + } + + static void svg_text(FILE *fp, gfx_node_t *node) + { + double x = node->x - LINEOFFSET; + double y = node->y - LINEOFFSET; + if (node->angle != 0) { + svg_start_tag(fp, "g"); + fputs(" transform=\"translate(", fp); + svg_write_number(fp, x); + fputs(",", fp); + svg_write_number(fp, y); + fputs(") rotate(", fp); + svg_write_number(fp, node->angle); + fputs(")\"", fp); + x = y = 0; + svg_close_tag(fp); + } + switch (node->valign) { + case GFX_V_TOP: y += node->size; break; + case GFX_V_CENTER: y += node->size / 2; break; + case GFX_V_BOTTOM: break; + case GFX_V_NULL: break; + } + svg_start_tag(fp, "text"); + fputs(" x=\"", fp); + svg_write_number(fp, x); + fputs("\" y=\"", fp); + svg_write_number(fp, y); + fputs("\" font-size=\"", fp); + svg_write_number(fp, node->size); + fputs("\"", fp); + if (!svg_color_is_black(node->color)) { + fputs(" fill=\"", fp); + svg_write_color(fp, node->color); + fputs("\"", fp); + } + switch (node->halign) { + case GFX_H_RIGHT: fputs(" text-anchor=\"end\"", fp); break; + case GFX_H_CENTER: fputs(" text-anchor=\"middle\"", fp); break; + case GFX_H_LEFT: break; + case GFX_H_NULL: break; + } + svg_close_tag_single_line(fp); + /* support for node->tabwidth missing */ + svg_write_text(fp, node->text); + svg_end_tag(fp, "text"); + if (node->angle != 0) + svg_end_tag(fp, "g"); + } + + int gfx_render_svg (gfx_canvas_t *canvas, + art_u32 width, art_u32 height, + double zoom, + gfx_color_t background, FILE *fp){ + gfx_node_t *node = canvas->firstnode; + fputs( + "\n" + "\n" + "\n", fp); + svg_start_tag(fp, "svg"); + fputs(" width=\"", fp); + svg_write_number(fp, width * zoom); + fputs("\" height=\"", fp); + svg_write_number(fp, height * zoom); + fputs("\" x=\"0\" y=\"0\" viewBox=\"", fp); + svg_write_number(fp, -LINEOFFSET); + fputs(" ", fp); + svg_write_number(fp, -LINEOFFSET); + fputs(" ", fp); + svg_write_number(fp, width - LINEOFFSET); + fputs(" ", fp); + svg_write_number(fp, height - LINEOFFSET); + fputs("\" preserveAspectRatio=\"xMidYMid\"", fp); + fputs(" font-family=\"Helvetica\"", fp); /* default font */ + svg_close_tag(fp); + svg_start_tag(fp, "rect"); + fprintf(fp, " x=\"0\" y=\"0\" width=\"%d\" height=\"%d\"", width, height); + fputs(" style=\"fill:", fp); + svg_write_color(fp, background); + fputs("\"", fp); + svg_close_tag_empty_node(fp); + while (node) { + switch (node->type) { + case GFX_LINE: + svg_multi_path(fp, &node); + break; + case GFX_AREA: + svg_area(fp, node); + break; + case GFX_TEXT: + svg_text(fp, node); + } + node = node->next; + } + svg_end_tag(fp, "svg"); + return 0; + } diff --git a/src/rrd_gfx.h b/src/rrd_gfx.h index 808b7c4..504f425 100644 --- a/src/rrd_gfx.h +++ b/src/rrd_gfx.h @@ -25,6 +25,7 @@ typedef struct gfx_node_t { char *filename; /* font or image filename */ char *text; double x,y; /* position */ + double angle; enum gfx_h_align_en halign; /* text alignement */ enum gfx_v_align_en valign; /* text alignement */ double tabwidth; @@ -86,5 +87,10 @@ int gfx_destroy (gfx_canvas_t *canvas); #endif +/* turn graph into an svg image */ +int gfx_render_svg (gfx_canvas_t *canvas, + art_u32 width, art_u32 height, + double zoom, + gfx_color_t background, FILE *fo); diff --git a/src/rrd_graph.h b/src/rrd_graph.h index d222f9a..8fb96d6 100644 --- a/src/rrd_graph.h +++ b/src/rrd_graph.h @@ -25,7 +25,7 @@ enum gf_en {GF_PRINT=0,GF_GPRINT,GF_COMMENT,GF_HRULE,GF_VRULE,GF_LINE, GF_DEF, GF_CDEF, GF_VDEF, GF_PART}; -enum if_en {IF_PNG=0}; +enum if_en {IF_PNG=0,IF_SVG}; enum vdef_op_en { VDEF_MAXIMUM /* like the MAX in (G)PRINT */ -- 2.11.0 From d1a93c1958f2d14459be92ab3290b902cae06047 Mon Sep 17 00:00:00 2001 From: jake Date: Thu, 28 Mar 2002 17:33:49 +0000 Subject: [PATCH 08/16] Added comment suggesting use of -I flag with aclocal. git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk/program@107 a5681a0c-68f1-0310-ab6d-d61299d08faa --- MakeMakefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/MakeMakefile b/MakeMakefile index 2047f1d..d8032d0 100755 --- a/MakeMakefile +++ b/MakeMakefile @@ -43,6 +43,9 @@ libtoolize --copy --force cp ltmain.sh config # wget ftp://sources.redhat.com/pub/automake/automake-1.5.tar.gz +# If autoconf generates undefined MACRO errors, it may be unable +# to find libtool.m4. Add the -I flag to aclocal to specify the +# directory location of this file. aclocal autoheader --warnings=all automake --foreign --add-missing --force-missing --copy -- 2.11.0 From a6f454695dcd606a8b95bab0f654272832b0d968 Mon Sep 17 00:00:00 2001 From: oetiker Date: Mon, 1 Apr 2002 18:31:22 +0000 Subject: [PATCH 09/16] "!" takes a higher preference than "||" this means rrd_update N:: would segfault -- Oliver Cook git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk/program@108 a5681a0c-68f1-0310-ab6d-d61299d08faa --- src/rrd_diff.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/rrd_diff.c b/src/rrd_diff.c index 0e04de6..3f80a15 100644 --- a/src/rrd_diff.c +++ b/src/rrd_diff.c @@ -7,6 +7,10 @@ ***************************************************************************** * $Id$ * $Log$ + * Revision 1.3 2002/04/01 18:31:22 oetiker + * "!" takes a higher preference than "||" this means rrd_update N:: would + * segfault -- Oliver Cook + * * Revision 1.2 2002/02/01 20:34:49 oetiker * fixed version number and date/time * @@ -35,13 +39,13 @@ rrd_diff(char *a, char *b) char res[LAST_DS_LEN+1], *a1, *b1, *r1, *fix; int c,x,m; - while (!isdigit((int)*a) || *a==0) + while (!(isdigit((int)*a) || *a==0)) a++; fix=a; while (isdigit((int)*fix)) fix++; *fix = 0; /* maybe there is some non digit data in the string */ - while (!isdigit((int)*b) || *b==0) + while (!(isdigit((int)*b) || *b==0)) b++; fix=b; while (isdigit((int)*fix)) -- 2.11.0 From 692778b1e53984e5e9450881c0b434bf8d864df6 Mon Sep 17 00:00:00 2001 From: oetiker Date: Mon, 1 Apr 2002 18:32:17 +0000 Subject: [PATCH 10/16] merged svg update git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk/program@109 a5681a0c-68f1-0310-ab6d-d61299d08faa --- NEWS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/NEWS b/NEWS index 40c69d9..b8347f2 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,9 @@ RRDTOOL NEWS In this file I am noting the Major changes to rrdtool for details check the cvs ChangeLog +2002/03/26 Peter Speck + Contribution of an svg output routine for the new gfx graphing part + 2002/03/23 Alex van den Bogaerdt Several visible changes made to rrd_graph * Pie chart support workable -- 2.11.0 From d1d774b37f93718829addf71d7af43b295eba587 Mon Sep 17 00:00:00 2001 From: oetiker Date: Tue, 2 Apr 2002 19:37:54 +0000 Subject: [PATCH 11/16] rrd restore should not burn down existing files -- Paul Vixie git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk/program@110 a5681a0c-68f1-0310-ab6d-d61299d08faa --- src/rrd_restore.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/rrd_restore.c b/src/rrd_restore.c index 207986d..fa5e412 100644 --- a/src/rrd_restore.c +++ b/src/rrd_restore.c @@ -406,9 +406,12 @@ rrd_write(char *file_name, rrd_t *rrd) if (strcmp("-",file_name)==0){ *rrd_file= *stdout; } else { - if ((rrd_file = fopen(file_name,"wb")) == NULL ) { + int fd = open(file_name,O_RDWR|O_CREAT|O_EXCL); + if (fd == -1 || (rrd_file = fdopen(fd,"wb")) == NULL) { rrd_set_error("creating '%s': %s",file_name,strerror(errno)); rrd_free(rrd); + if (fd != -1) + close(fd); return(-1); } } -- 2.11.0 From bac27f0cc0680c2b0e60c0621240074561838303 Mon Sep 17 00:00:00 2001 From: oetiker Date: Tue, 2 Apr 2002 21:31:08 +0000 Subject: [PATCH 12/16] aded missing fcntl.h git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk/program@111 a5681a0c-68f1-0310-ab6d-d61299d08faa --- src/rrd_restore.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/rrd_restore.c b/src/rrd_restore.c index fa5e412..770e22f 100644 --- a/src/rrd_restore.c +++ b/src/rrd_restore.c @@ -6,6 +6,7 @@ #include "rrd_tool.h" #include "rrd_rpncalc.h" +#include /* Prototypes */ -- 2.11.0 From b02391185d69f22b09557b1caf725ad7eff5eb6e Mon Sep 17 00:00:00 2001 From: oetiker Date: Tue, 2 Apr 2002 21:32:15 +0000 Subject: [PATCH 13/16] added call to tzset to activate TZ settings -- Paul A Vixie git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk/program@112 a5681a0c-68f1-0310-ab6d-d61299d08faa --- bindings/perl-shared/RRDs.xs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bindings/perl-shared/RRDs.xs b/bindings/perl-shared/RRDs.xs index d8eef7e..d567d07 100644 --- a/bindings/perl-shared/RRDs.xs +++ b/bindings/perl-shared/RRDs.xs @@ -5,6 +5,7 @@ extern "C" { #include "EXTERN.h" #include "perl.h" #include "XSUB.h" +#include #ifdef __cplusplus } @@ -138,6 +139,7 @@ rrd_graph(...) } optind=0; opterr=0; rrd_clear_error(); + tzset(); rrd_graph(items+1,argv,&calcpr,&xsize,&ysize); for (i=0; i < items; i++) { free(argv[i+1]); -- 2.11.0 From 37b2687fdcdd310be0aa5d622426e04820f92d3c Mon Sep 17 00:00:00 2001 From: oetiker Date: Wed, 3 Apr 2002 05:32:31 +0000 Subject: [PATCH 14/16] i suck. sorry. add ,0666 to the open(). -- Paul Vixie git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk/program@113 a5681a0c-68f1-0310-ab6d-d61299d08faa --- src/rrd_restore.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rrd_restore.c b/src/rrd_restore.c index 770e22f..e24cc8e 100644 --- a/src/rrd_restore.c +++ b/src/rrd_restore.c @@ -407,7 +407,7 @@ rrd_write(char *file_name, rrd_t *rrd) if (strcmp("-",file_name)==0){ *rrd_file= *stdout; } else { - int fd = open(file_name,O_RDWR|O_CREAT|O_EXCL); + int fd = open(file_name,O_RDWR|O_CREAT|O_EXCL,0666); if (fd == -1 || (rrd_file = fdopen(fd,"wb")) == NULL) { rrd_set_error("creating '%s': %s",file_name,strerror(errno)); rrd_free(rrd); -- 2.11.0 From badb4b5a280242c6991970d25c4069bc12e77f10 Mon Sep 17 00:00:00 2001 From: oetiker Date: Wed, 3 Apr 2002 14:52:15 +0000 Subject: [PATCH 15/16] As gfx_canvas_t now has excatly the same lifespan as image_desc_t, I've made 'gfx_canvas_t canvas' a member of image_desc_t and dropped it as a separate parameter in all function calls. imgformat, interlaced and zoom are moved to gfx_canvas_t. I have dropped my old fontlib-enum as imgformat contains that information. The gfx_render_xxx switch is moved to rrd_gfx so rrd_graph is (almost) only bothered with image formats in cmd line parsing. gfx_close_path is added. gfx_new_dashed_line is added with 2 new arguments: length of a dash and length between dashes. gfx_new_line is still there for plain lines. Having dash-length == 0 creates normal line. rrd_graph.c is not updated for dashed lines. It's not decided how one should specify which and how lines are dashed. An extension of the color specification? svg is updated for dashes and opacity, but libart code is not. I've fixed indent in SVG, all lines had a space before func decl. etc. Misc small fixes, e.g. sscanf of gfx_color_t, position of x-axis arrow. --- Peter Speck git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk/program@114 a5681a0c-68f1-0310-ab6d-d61299d08faa --- src/rrd_gfx.c | 282 ++++++++++++++++++++++++++++++++++---------------------- src/rrd_gfx.h | 28 +++++- src/rrd_graph.c | 163 +++++++++++++++----------------- src/rrd_graph.h | 21 ++--- 4 files changed, 282 insertions(+), 212 deletions(-) diff --git a/src/rrd_gfx.c b/src/rrd_gfx.c index e36910d..7ca6450 100644 --- a/src/rrd_gfx.c +++ b/src/rrd_gfx.c @@ -32,6 +32,7 @@ gfx_node_t *gfx_new_node( gfx_canvas_t *canvas,enum gfx_en type){ node->path = NULL; /* path */ node->points = 0; node->points_max =0; + node->closed_path = 0; node->svp = NULL; /* svp */ node->filename = NULL; /* font or image filename */ node->text = NULL; @@ -56,6 +57,9 @@ gfx_canvas_t *gfx_new_canvas (void) { gfx_canvas_t *canvas = art_new(gfx_canvas_t,1); canvas->firstnode = NULL; canvas->lastnode = NULL; + canvas->imgformat = IF_PNG; /* we default to PNG output */ + canvas->interlaced = 0; + canvas->zoom = 1.0; return canvas; } @@ -64,6 +68,14 @@ gfx_node_t *gfx_new_line(gfx_canvas_t *canvas, 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); +} + +gfx_node_t *gfx_new_dashed_line(gfx_canvas_t *canvas, + double x0, double y0, + double x1, double y1, + double width, gfx_color_t color, + double dash_on, double dash_off){ gfx_node_t *node; ArtVpath *vec; @@ -79,6 +91,8 @@ gfx_node_t *gfx_new_line(gfx_canvas_t *canvas, node->points_max = 3; node->color = color; node->size = width; + node->dash_on = dash_on; + node->dash_off = dash_off; node->path = vec; return node; } @@ -153,7 +167,9 @@ int gfx_add_point (gfx_node_t *node, return 0; } - +void gfx_close_path (gfx_node_t *node) { + node->closed_path = 1; +} /* create a text node */ gfx_node_t *gfx_new_text (gfx_canvas_t *canvas, @@ -182,7 +198,32 @@ gfx_node_t *gfx_new_text (gfx_canvas_t *canvas, return node; } -double gfx_get_text_width ( double start, char* font, double size, +int gfx_render(gfx_canvas_t *canvas, + art_u32 width, art_u32 height, + gfx_color_t background, FILE *fp){ + switch (canvas->imgformat) { + case IF_PNG: + return gfx_render_png (canvas, width, height, background, fp); + case IF_SVG: + return gfx_render_svg (canvas, width, height, background, fp); + default: + return -1; + } +} + +double gfx_get_text_width ( gfx_canvas_t *canvas, + double start, char* font, double size, + double tabwidth, char* text){ + switch (canvas->imgformat) { + case IF_PNG: + return gfx_get_text_width_libart (canvas, start, font, size, tabwidth, text); + default: + return size * strlen(text); + } +} + +double gfx_get_text_width_libart ( gfx_canvas_t *canvas, + double start, char* font, double size, double tabwidth, char* text){ FT_GlyphSlot slot; @@ -237,7 +278,6 @@ static int gfx_save_png (art_u8 *buffer, FILE *fp, /* render grafics into png image */ int gfx_render_png (gfx_canvas_t *canvas, art_u32 width, art_u32 height, - double zoom, gfx_color_t background, FILE *fp){ @@ -245,8 +285,8 @@ int gfx_render_png (gfx_canvas_t *canvas, gfx_node_t *node = canvas->firstnode; art_u8 red = background >> 24, green = (background >> 16) & 0xff; art_u8 blue = (background >> 8) & 0xff, alpha = ( background & 0xff ); - unsigned long pys_width = width * zoom; - unsigned long pys_height = height * zoom; + unsigned long pys_width = width * canvas->zoom; + unsigned long pys_height = height * canvas->zoom; const int bytes_per_pixel = 3; unsigned long rowstride = pys_width*bytes_per_pixel; /* bytes per pixel */ art_u8 *buffer = art_new (art_u8, rowstride*pys_height); @@ -259,12 +299,17 @@ int gfx_render_png (gfx_canvas_t *canvas, ArtVpath *vec; double dst[6]; ArtSVP *svp; - art_affine_scale(dst,zoom,zoom); + if (node->closed_path) { + /* libart uses end==start for closed as indicator of closed path */ + gfx_add_point(node, node->path[0].x, node->path[0].y); + node->closed_path = 0; + } + art_affine_scale(dst,canvas->zoom,canvas->zoom); vec = art_vpath_affine_transform(node->path,dst); if(node->type == GFX_LINE){ svp = art_svp_vpath_stroke ( vec, ART_PATH_STROKE_JOIN_ROUND, ART_PATH_STROKE_CAP_ROUND, - node->size*zoom,1,1); + node->size*canvas->zoom,1,1); } else { svp = art_svp_from_vpath ( vec ); } @@ -303,11 +348,11 @@ int gfx_render_png (gfx_canvas_t *canvas, error = FT_Set_Char_Size(face, /* handle to face object */ (long)(node->size*64), (long)(node->size*64), - (long)(100*zoom), - (long)(100*zoom)); + (long)(100*canvas->zoom), + (long)(100*canvas->zoom)); if ( error ) break; - pen_x = node->x * zoom; - pen_y = node->y * zoom; + pen_x = node->x * canvas->zoom; + pen_y = node->y * canvas->zoom; slot = face->glyph; for(text=(unsigned char *)node->text;*text;text++) { @@ -471,8 +516,14 @@ static int gfx_save_png (art_u8 *buffer, FILE *fp, long width, long height, lon } +/* ------- SVG ------- + SVG reference: + http://www.w3.org/TR/SVG/ +*/ static int svg_indent = 0; static int svg_single_line = 0; +static const char *svg_default_font = "Helvetica"; + static void svg_print_indent(FILE *fp) { int i; @@ -483,28 +534,28 @@ static void svg_print_indent(FILE *fp) } static void svg_start_tag(FILE *fp, const char *name) - { +{ svg_print_indent(fp); putc('<', fp); fputs(name, fp); svg_indent++; - } +} - static void svg_close_tag_single_line(FILE *fp) - { +static void svg_close_tag_single_line(FILE *fp) +{ svg_single_line++; putc('>', fp); - } +} - static void svg_close_tag(FILE *fp) - { +static void svg_close_tag(FILE *fp) +{ putc('>', fp); if (!svg_single_line) putc('\n', fp); - } +} - static void svg_end_tag(FILE *fp, const char *name) - { +static void svg_end_tag(FILE *fp, const char *name) +{ /* name is NULL if closing empty-node tag */ svg_indent--; if (svg_single_line) @@ -518,15 +569,15 @@ static void svg_start_tag(FILE *fp, const char *name) putc('/', fp); } svg_close_tag(fp); - } +} - static void svg_close_tag_empty_node(FILE *fp) - { +static void svg_close_tag_empty_node(FILE *fp) +{ svg_end_tag(fp, NULL); - } +} - static void svg_write_text(FILE *fp, const char *p) - { +static void svg_write_text(FILE *fp, const char *p) +{ char ch; const char *start, *last; if (!p) @@ -554,10 +605,10 @@ static void svg_start_tag(FILE *fp, const char *name) default: putc(ch, fp); } } - } +} - static void svg_write_number(FILE *fp, double d) - { +static void svg_write_number(FILE *fp, double d) +{ /* omit decimals if integer to reduce filesize */ char buf[60], *p; snprintf(buf, sizeof(buf), "%.2f", d); @@ -575,41 +626,64 @@ static void svg_start_tag(FILE *fp, const char *name) break; } fputs(buf, fp); - } +} - static int svg_color_is_black(int c) - { - /* gfx_color_t is RRGGBBAA, svg can use #RRGGBB like html */ - c = (int)((c >> 8) & 0xFFFFFF); - return !c; - } +static int svg_color_is_black(int c) +{ + /* gfx_color_t is RRGGBBAA */ + return c == 0x000000FF; +} - static void svg_write_color(FILE *fp, int c) - { - /* gfx_color_t is RRGGBBAA, svg can use #RRGGBB like html */ - c = (int)((c >> 8) & 0xFFFFFF); - if ((c & 0x0F0F0F) == ((c >> 4) & 0x0F0F0F)) { +static void svg_write_color(FILE *fp, gfx_color_t c, const char *attr) +{ + /* gfx_color_t is RRGGBBAA, svg can use #RRGGBB and #RGB like html */ + gfx_color_t rrggbb = (int)((c >> 8) & 0xFFFFFF); + gfx_color_t opacity = c & 0xFF; + fprintf(fp, " %s=\"", attr); + if ((rrggbb & 0x0F0F0F) == ((rrggbb >> 4) & 0x0F0F0F)) { /* css2 short form, #rgb is #rrggbb, not #r0g0b0 */ - fprintf(fp, "#%03X", - ( ((c >> 8) & 0xF00) - | ((c >> 4) & 0x0F0) - | ( c & 0x00F))); + fprintf(fp, "#%03lX", + ( ((rrggbb >> 8) & 0xF00) + | ((rrggbb >> 4) & 0x0F0) + | ( rrggbb & 0x00F))); } else { - fprintf(fp, "#%06X", c); + fprintf(fp, "#%06lX", rrggbb); } + fputs("\"", fp); + if (opacity != 0xFF) { + fprintf(fp, " stroke-opacity=\""); + svg_write_number(fp, opacity / 255.0); + fputs("\"", fp); } +} - static int svg_is_int_step(double a, double b) - { +static void svg_common_path_attributes(FILE *fp, gfx_node_t *node) +{ + fputs(" stroke-width=\"", fp); + svg_write_number(fp, node->size); + fputs("\"", fp); + svg_write_color(fp, node->color, "stroke"); + fputs(" fill=\"none\"", fp); + if (node->dash_on != 0 && node->dash_off != 0) { + fputs(" stroke-dasharray=\"", fp); + svg_write_number(fp, node->dash_on); + fputs(",", fp); + svg_write_number(fp, node->dash_off); + fputs("\"", fp); + } +} + +static int svg_is_int_step(double a, double b) +{ double diff = fabs(a - b); return floor(diff) == diff; - } +} - static int svg_path_straight_segment(FILE *fp, +static int svg_path_straight_segment(FILE *fp, double lastA, double currentA, double currentB, gfx_node_t *node, int segment_idx, int isx, char absChar, char relChar) - { +{ if (!svg_is_int_step(lastA, currentA)) { putc(absChar, fp); svg_write_number(fp, currentA); @@ -630,23 +704,18 @@ static void svg_start_tag(FILE *fp, const char *name) putc(relChar, fp); svg_write_number(fp, currentA - lastA); return 0; - } +} - static void svg_path(FILE *fp, gfx_node_t *node, int multi) - { +static void svg_path(FILE *fp, gfx_node_t *node, int multi) +{ int i; double lastX = 0, lastY = 0; /* for straight lines tags take less space than tags because of the efficient packing in the 'd' attribute */ svg_start_tag(fp, "path"); - if (!multi) { - fputs(" stroke-width=\"", fp); - svg_write_number(fp, node->size); - fputs("\" stroke=\"", fp); - svg_write_color(fp, node->color); - fputs("\" fill=\"none\"", fp); - } + if (!multi) + svg_common_path_attributes(fp, node); fputs(" d=\"", fp); /* specification of the 'd' attribute: */ /* http://www.w3.org/TR/SVG/paths.html#PathDataGeneralInformation */ @@ -684,12 +753,14 @@ static void svg_start_tag(FILE *fp, const char *name) lastX = x; lastY = y; } + if (node->closed_path) + fputs(" Z", fp); fputs("\"", fp); svg_close_tag_empty_node(fp); - } +} - static void svg_multi_path(FILE *fp, gfx_node_t **nodeR) - { +static void svg_multi_path(FILE *fp, gfx_node_t **nodeR) +{ /* optimize for multiple paths with the same color, penwidth, etc. */ int num = 1; gfx_node_t *node = *nodeR; @@ -697,7 +768,9 @@ static void svg_start_tag(FILE *fp, const char *name) while (next) { if (next->type != node->type || next->size != node->size - || next->color != node->color) + || next->color != node->color + || next->dash_on != node->dash_on + || next->dash_off != node->dash_off) break; next = next->next; num++; @@ -707,11 +780,7 @@ static void svg_start_tag(FILE *fp, const char *name) return; } svg_start_tag(fp, "g"); - fputs(" stroke-width=\"", fp); - svg_write_number(fp, node->size); - fputs("\" stroke=\"", fp); - svg_write_color(fp, node->color); - fputs("\" fill=\"none\"", fp); + svg_common_path_attributes(fp, node); svg_close_tag(fp); while (num && node) { svg_path(fp, node, 1); @@ -721,16 +790,16 @@ static void svg_start_tag(FILE *fp, const char *name) *nodeR = node; } svg_end_tag(fp, "g"); - } +} - static void svg_area(FILE *fp, gfx_node_t *node) - { +static void svg_area(FILE *fp, gfx_node_t *node) +{ int i; double startX = 0, startY = 0; svg_start_tag(fp, "polygon"); - fputs(" fill=\"", fp); - svg_write_color(fp, node->color); - fputs("\" points=\"", fp); + fputs(" ", fp); + svg_write_color(fp, node->color, "fill"); + fputs(" points=\"", fp); for (i = 0; i < node->points; i++) { ArtVpath *vec = node->path + i; double x = vec->x - LINEOFFSET; @@ -761,10 +830,10 @@ static void svg_start_tag(FILE *fp, const char *name) } fputs("\"", fp); svg_close_tag_empty_node(fp); - } +} - static void svg_text(FILE *fp, gfx_node_t *node) - { +static void svg_text(FILE *fp, gfx_node_t *node) +{ double x = node->x - LINEOFFSET; double y = node->y - LINEOFFSET; if (node->angle != 0) { @@ -790,14 +859,13 @@ static void svg_start_tag(FILE *fp, const char *name) svg_write_number(fp, x); fputs("\" y=\"", fp); svg_write_number(fp, y); + if (strcmp(node->filename, svg_default_font)) + fprintf(fp, " font-family=\"%s\"", node->filename); fputs("\" font-size=\"", fp); svg_write_number(fp, node->size); fputs("\"", fp); - if (!svg_color_is_black(node->color)) { - fputs(" fill=\"", fp); - svg_write_color(fp, node->color); - fputs("\"", fp); - } + if (!svg_color_is_black(node->color)) + svg_write_color(fp, node->color, "fill"); switch (node->halign) { case GFX_H_RIGHT: fputs(" text-anchor=\"end\"", fp); break; case GFX_H_CENTER: fputs(" text-anchor=\"middle\"", fp); break; @@ -810,32 +878,31 @@ static void svg_start_tag(FILE *fp, const char *name) svg_end_tag(fp, "text"); if (node->angle != 0) svg_end_tag(fp, "g"); - } +} - int gfx_render_svg (gfx_canvas_t *canvas, +int gfx_render_svg (gfx_canvas_t *canvas, art_u32 width, art_u32 height, - double zoom, gfx_color_t background, FILE *fp){ gfx_node_t *node = canvas->firstnode; fputs( - "\n" - "\n" - "\n", fp); +"\n" +"\n" +"\n", fp); svg_start_tag(fp, "svg"); fputs(" width=\"", fp); - svg_write_number(fp, width * zoom); + svg_write_number(fp, width * canvas->zoom); fputs("\" height=\"", fp); - svg_write_number(fp, height * zoom); + svg_write_number(fp, height * canvas->zoom); fputs("\" x=\"0\" y=\"0\" viewBox=\"", fp); svg_write_number(fp, -LINEOFFSET); fputs(" ", fp); @@ -845,13 +912,12 @@ static void svg_start_tag(FILE *fp, const char *name) fputs(" ", fp); svg_write_number(fp, height - LINEOFFSET); fputs("\" preserveAspectRatio=\"xMidYMid\"", fp); - fputs(" font-family=\"Helvetica\"", fp); /* default font */ + fprintf(fp, " font-family=\"%s\"", svg_default_font); /* default font */ + fputs(" stroke-linecap=\"round\" stroke-linejoin=\"round\"", fp); svg_close_tag(fp); svg_start_tag(fp, "rect"); fprintf(fp, " x=\"0\" y=\"0\" width=\"%d\" height=\"%d\"", width, height); - fputs(" style=\"fill:", fp); - svg_write_color(fp, background); - fputs("\"", fp); + svg_write_color(fp, background, "fill"); svg_close_tag_empty_node(fp); while (node) { switch (node->type) { @@ -868,4 +934,4 @@ static void svg_start_tag(FILE *fp, const char *name) } svg_end_tag(fp, "svg"); return 0; - } +} diff --git a/src/rrd_gfx.h b/src/rrd_gfx.h index 504f425..ed107cb 100644 --- a/src/rrd_gfx.h +++ b/src/rrd_gfx.h @@ -9,6 +9,7 @@ #define LIBART_COMPILATION #include +enum gfx_if_en {IF_PNG=0,IF_SVG}; enum gfx_en { GFX_LINE=0,GFX_AREA,GFX_TEXT }; enum gfx_h_align_en { GFX_H_NULL=0, GFX_H_LEFT, GFX_H_RIGHT, GFX_H_CENTER }; enum gfx_v_align_en { GFX_V_NULL=0, GFX_V_TOP, GFX_V_BOTTOM, GFX_V_CENTER }; @@ -18,14 +19,16 @@ typedef struct gfx_node_t { enum gfx_en type; /* type of graph element */ gfx_color_t color; /* color of element 0xRRGGBBAA alpha 0xff is solid*/ double size; /* font size, line width */ + double dash_on, dash_off; /* dash line fragments lengths */ ArtVpath *path; /* path */ + int closed_path; int points; int points_max; ArtSVP *svp; /* svp */ char *filename; /* font or image filename */ char *text; double x,y; /* position */ - double angle; + double angle; /* text angle */ enum gfx_h_align_en halign; /* text alignement */ enum gfx_v_align_en valign; /* text alignement */ double tabwidth; @@ -37,6 +40,9 @@ typedef struct gfx_canvas_t { struct gfx_node_t *firstnode; struct gfx_node_t *lastnode; + enum gfx_if_en imgformat; /* image format */ + int interlaced; /* will the graph be interlaced? */ + double zoom; /* zoom for graph */ } gfx_canvas_t; @@ -48,6 +54,12 @@ gfx_node_t *gfx_new_line (gfx_canvas_t *canvas, 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 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, @@ -58,6 +70,9 @@ gfx_node_t *gfx_new_area (gfx_canvas_t *canvas, /* add a point to a line or to an area */ int gfx_add_point (gfx_node_t *node, double x, double y); +/* close current path so it ends at the same point as it started */ +void gfx_close_path (gfx_node_t *node); + /* create a text node */ gfx_node_t *gfx_new_text (gfx_canvas_t *canvas, @@ -69,7 +84,8 @@ gfx_node_t *gfx_new_text (gfx_canvas_t *canvas, char* text); /* measure width of a text string */ -double gfx_get_text_width ( double start, char* font, double size, +double gfx_get_text_width ( gfx_canvas_t *canvas, + double start, char* font, double size, double tabwidth, char* text); @@ -77,9 +93,14 @@ double gfx_get_text_width ( double start, char* font, double size, /* turn graph into a png image */ int gfx_render_png (gfx_canvas_t *canvas, art_u32 width, art_u32 height, - double zoom, gfx_color_t background, FILE *fo); +double gfx_get_text_width_libart ( gfx_canvas_t *canvas, + double start, char* font, double size, + double tabwidth, char* text); +int gfx_render (gfx_canvas_t *canvas, + art_u32 width, art_u32 height, + gfx_color_t background, FILE *fo); /* free memory used by nodes this will also remove memory required for node chain and associated material */ @@ -90,7 +111,6 @@ int gfx_destroy (gfx_canvas_t *canvas); /* turn graph into an svg image */ int gfx_render_svg (gfx_canvas_t *canvas, art_u32 width, art_u32 height, - double zoom, gfx_color_t background, FILE *fo); diff --git a/src/rrd_graph.c b/src/rrd_graph.c index 8b9e679..537a03f 100644 --- a/src/rrd_graph.c +++ b/src/rrd_graph.c @@ -179,9 +179,10 @@ enum gf_en gf_conv(char *string){ return (-1); } -enum if_en if_conv(char *string){ +enum gfx_if_en if_conv(char *string){ conv_if(PNG,IF_PNG) + conv_if(SVG,IF_SVG) return (-1); } @@ -247,6 +248,7 @@ im_free(image_desc_t *im) free (im->gdes[i].rpnp); } free(im->gdes); + gfx_destroy(im->canvas); return 0; } @@ -1291,7 +1293,8 @@ leg_place(image_desc_t *im) im->gdes[i].gf != GF_COMMENT) { fill += box; } - fill += gfx_get_text_width(fill+border,im->text_prop[TEXT_PROP_LEGEND].font, + fill += gfx_get_text_width(im->canvas, fill+border, + im->text_prop[TEXT_PROP_LEGEND].font, im->text_prop[TEXT_PROP_LEGEND].size, im->tabwidth, im->gdes[i].legend); @@ -1338,7 +1341,8 @@ leg_place(image_desc_t *im) im->gdes[ii].leg_x = leg_x; im->gdes[ii].leg_y = leg_y; leg_x += - gfx_get_text_width(leg_x,im->text_prop[TEXT_PROP_LEGEND].font, + gfx_get_text_width(im->canvas, leg_x, + im->text_prop[TEXT_PROP_LEGEND].font, im->text_prop[TEXT_PROP_LEGEND].size, im->tabwidth, im->gdes[ii].legend) @@ -1370,7 +1374,7 @@ leg_place(image_desc_t *im) int -horizontal_grid(gfx_canvas_t *canvas, image_desc_t *im) +horizontal_grid(image_desc_t *im) { double range; double scaledrange; @@ -1379,7 +1383,7 @@ horizontal_grid(gfx_canvas_t *canvas, image_desc_t *im) double gridstep; double scaledstep; char graph_label[100]; - double x0,x1,y0,y1; + double x0,x1,y0; int labfact,gridind; int decimals, fractionals; char labfmt[64]; @@ -1480,20 +1484,20 @@ horizontal_grid(gfx_canvas_t *canvas, image_desc_t *im) } } - gfx_new_text ( canvas, + gfx_new_text ( im->canvas, 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 ( canvas, + gfx_new_line ( im->canvas, x0-2,y0, x1+2,y0, MGRIDWIDTH, im->graph_col[GRC_MGRID] ); } else { - gfx_new_line ( canvas, + gfx_new_line ( im->canvas, x0-1,y0, x1+1,y0, GRIDWIDTH, im->graph_col[GRC_GRID] ); @@ -1506,13 +1510,13 @@ horizontal_grid(gfx_canvas_t *canvas, image_desc_t *im) /* logaritmic horizontal grid */ int -horizontal_log_grid(gfx_canvas_t *canvas, image_desc_t *im) +horizontal_log_grid(image_desc_t *im) { double pixpex; int ii,i; int minoridx=0, majoridx=0; char graph_label[100]; - double x0,x1,y0,y1; + double x0,x1,y0; double value, pixperstep, minstep; /* find grid spaceing */ @@ -1547,7 +1551,7 @@ horizontal_log_grid(gfx_canvas_t *canvas, image_desc_t *im) while(yloglab[minoridx][++i] > 0){ y0 = ytr(im,value * yloglab[minoridx][i]); if (y0 <= im->yorigin - im->ysize) break; - gfx_new_line ( canvas, + gfx_new_line ( im->canvas, x0-1,y0, x1+1,y0, GRIDWIDTH, im->graph_col[GRC_GRID] ); @@ -1564,13 +1568,13 @@ horizontal_log_grid(gfx_canvas_t *canvas, image_desc_t *im) while(yloglab[majoridx][++i] > 0){ y0 = ytr(im,value * yloglab[majoridx][i]); if (y0 <= im->yorigin - im->ysize) break; - gfx_new_line ( canvas, + gfx_new_line ( im->canvas, x0-2,y0, x1+2,y0, MGRIDWIDTH, im->graph_col[GRC_MGRID] ); sprintf(graph_label,"%3.0e",value * yloglab[majoridx][i]); - gfx_new_text ( canvas, + gfx_new_text ( im->canvas, x0-im->text_prop[TEXT_PROP_AXIS].size/1.5, y0, im->graph_col[GRC_FONT], im->text_prop[TEXT_PROP_AXIS].font, @@ -1585,7 +1589,6 @@ horizontal_log_grid(gfx_canvas_t *canvas, image_desc_t *im) void vertical_grid( - gfx_canvas_t *canvas, image_desc_t *im ) { int xlab_sel; /* which sort of label and grid ? */ @@ -1629,7 +1632,7 @@ vertical_grid( /* are we inside the graph ? */ if (ti < im->start || ti > im->end) continue; x0 = xtr(im,ti); - gfx_new_line(canvas,x0,y0+1, x0,y1-1,GRIDWIDTH, im->graph_col[GRC_GRID]); + gfx_new_line(im->canvas,x0,y0+1, x0,y1-1,GRIDWIDTH, im->graph_col[GRC_GRID]); } @@ -1643,7 +1646,7 @@ vertical_grid( /* are we inside the graph ? */ if (ti < im->start || ti > im->end) continue; x0 = xtr(im,ti); - gfx_new_line(canvas,x0,y0+2, x0,y1-2,MGRIDWIDTH, im->graph_col[GRC_MGRID]); + gfx_new_line(im->canvas,x0,y0+2, x0,y1-2,MGRIDWIDTH, im->graph_col[GRC_MGRID]); } /* paint the labels below the graph */ @@ -1662,7 +1665,7 @@ vertical_grid( #else # error "your libc has no strftime I guess we'll abort the exercise here." #endif - gfx_new_text ( canvas, + gfx_new_text ( im->canvas, 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, @@ -1677,33 +1680,32 @@ vertical_grid( void axis_paint( - image_desc_t *im, - gfx_canvas_t *canvas + image_desc_t *im ) { /* draw x and y axis */ - gfx_new_line ( canvas, im->xorigin+im->xsize,im->yorigin, + gfx_new_line ( im->canvas, im->xorigin+im->xsize,im->yorigin, im->xorigin+im->xsize,im->yorigin-im->ysize, GRIDWIDTH, im->graph_col[GRC_GRID]); - gfx_new_line ( canvas, im->xorigin,im->yorigin-im->ysize, + gfx_new_line ( im->canvas, im->xorigin,im->yorigin-im->ysize, im->xorigin+im->xsize,im->yorigin-im->ysize, GRIDWIDTH, im->graph_col[GRC_GRID]); - gfx_new_line ( canvas, im->xorigin-4,im->yorigin, + gfx_new_line ( im->canvas, im->xorigin-4,im->yorigin, im->xorigin+im->xsize+4,im->yorigin, MGRIDWIDTH, im->graph_col[GRC_GRID]); - gfx_new_line ( canvas, im->xorigin,im->yorigin+4, + gfx_new_line ( im->canvas, im->xorigin,im->yorigin+4, im->xorigin,im->yorigin-im->ysize-4, MGRIDWIDTH, im->graph_col[GRC_GRID]); /* arrow for X axis direction */ - gfx_new_area ( canvas, - im->xorigin+im->xsize+4, im->yorigin-3, - im->xorigin+im->xsize+4, im->yorigin+3, - im->xorigin+im->xsize+9, im->yorigin, + 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->graph_col[GRC_ARROW]); @@ -1711,19 +1713,15 @@ axis_paint( } void -grid_paint( - image_desc_t *im, - gfx_canvas_t *canvas - - ) +grid_paint(image_desc_t *im) { long i; int res=0; - double x0,x1,x2,x3,y0,y1,y2,y3; /* 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 (canvas, 0,im->ygif, + node = gfx_new_area (im->canvas, 0,im->ygif, 2,im->ygif-2, 2,2,im->graph_col[GRC_SHADEA]); gfx_add_point( node , im->xgif - 2, 2 ); @@ -1731,7 +1729,7 @@ grid_paint( gfx_add_point( node , 0,0 ); /* gfx_add_point( node , 0,im->ygif ); */ - node = gfx_new_area (canvas, 2,im->ygif-2, + node = gfx_new_area (im->canvas, 2,im->ygif-2, im->xgif-2,im->ygif-2, im->xgif - 2, 2, im->graph_col[GRC_SHADEB]); @@ -1742,19 +1740,19 @@ grid_paint( if (im->draw_x_grid == 1 ) - vertical_grid(canvas, im); + vertical_grid(im); if (im->draw_y_grid == 1){ if(im->logarithmic){ - res = horizontal_log_grid(canvas,im); + res = horizontal_log_grid(im); } else { - res = horizontal_grid(canvas,im); + res = horizontal_grid(im); } /* dont draw horizontal grid if there is no min and max val */ if (! res ) { char *nodata = "No Data found"; - gfx_new_text(canvas,im->xgif/2, (2*im->yorigin-im->ysize) / 2, + gfx_new_text(im->canvas,im->xgif/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, @@ -1764,15 +1762,15 @@ grid_paint( } /* yaxis description */ - #if 0 - gfx_new_text( canvas, + if (im->canvas->imgformat != IF_PNG) { + gfx_new_text( im->canvas, 7, (im->yorigin - im->ysize/2), im->graph_col[GRC_FONT], im->text_prop[TEXT_PROP_AXIS].font, im->text_prop[TEXT_PROP_AXIS].size, im->tabwidth, 270.0, GFX_H_CENTER, GFX_V_CENTER, im->ylegend); - #else + } else { /* horrible hack until we can actually print vertically */ { int n; @@ -1781,7 +1779,7 @@ grid_paint( for (n=0;nylegend);n++) { s[0]=im->ylegend[n]; s[1]='\0'; - gfx_new_text(canvas,7,im->text_prop[TEXT_PROP_AXIS].size*(l-n), + gfx_new_text(im->canvas,7,im->text_prop[TEXT_PROP_AXIS].size*(l-n), im->graph_col[GRC_FONT], im->text_prop[TEXT_PROP_AXIS].font, im->text_prop[TEXT_PROP_AXIS].size, im->tabwidth, 270.0, @@ -1789,10 +1787,10 @@ grid_paint( s); } } - #endif + } /* graph title */ - gfx_new_text( canvas, + gfx_new_text( im->canvas, im->xgif/2, im->text_prop[TEXT_PROP_TITLE].size, im->graph_col[GRC_FONT], im->text_prop[TEXT_PROP_TITLE].font, @@ -1814,27 +1812,27 @@ grid_paint( && im->gdes[i].gf != GF_COMMENT) { int boxH, boxV; - boxH = gfx_get_text_width(0, + boxH = gfx_get_text_width(im->canvas, 0, im->text_prop[TEXT_PROP_AXIS].font, im->text_prop[TEXT_PROP_AXIS].size, im->tabwidth,"M") * 1.25; boxV = boxH; - node = gfx_new_area(canvas, + node = gfx_new_area(im->canvas, x0,y0-boxV, x0,y0, x0+boxH,y0, im->gdes[i].col); gfx_add_point ( node, x0+boxH, y0-boxV ); - node = gfx_new_line(canvas, + node = gfx_new_line(im->canvas, 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,y0-boxV); + gfx_close_path(node); x0 += boxH / 1.25 * 2; } - gfx_new_text ( 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, @@ -1864,17 +1862,19 @@ int lazy_check(image_desc_t *im){ return 0; if ((fd = fopen(im->graphfile,"rb")) == NULL) return 0; /* the file does not exist */ - switch (im->imgformat) { + switch (im->canvas->imgformat) { case IF_PNG: size = PngSize(fd,&(im->xgif),&(im->ygif)); break; + default: + size = 1; } fclose(fd); return size; } void -pie_part(gfx_canvas_t *canvas, gfx_color_t color, +pie_part(image_desc_t *im, gfx_color_t color, double PieCenterX, double PieCenterY, double Radius, double startangle, double endangle) { @@ -1904,7 +1904,7 @@ pie_part(gfx_canvas_t *canvas, gfx_color_t color, Radius *= 0.8; } - node=gfx_new_area(canvas, + node=gfx_new_area(im->canvas, PieCenterX+sin(startangle)*Radius, PieCenterY-cos(startangle)*Radius, PieCenterX, @@ -1961,7 +1961,7 @@ graph_size_location(image_desc_t *im, int elements, int piechart ) ** automatically has some vertical spacing. The horizontal ** spacing is added here, on each side. */ - Xtitle = gfx_get_text_width(0, + Xtitle = gfx_get_text_width(im->canvas, 0, im->text_prop[TEXT_PROP_TITLE].font, im->text_prop[TEXT_PROP_TITLE].size, im->tabwidth, @@ -2074,7 +2074,6 @@ graph_paint(image_desc_t *im, char ***calcpr) int piechart = 0; double PieStart=0.0; FILE *fo; - gfx_canvas_t *canvas; gfx_node_t *node; double areazero = 0.0; @@ -2130,12 +2129,10 @@ graph_paint(image_desc_t *im, char ***calcpr) if(graph_size_location(im,i,piechart)==-1) return -1; - canvas=gfx_new_canvas(); - /* the actual graph is created by going through the individual graph elements and then drawing them */ - node=gfx_new_area ( canvas, + node=gfx_new_area ( im->canvas, 0, 0, im->xgif, 0, im->xgif, im->ygif, @@ -2144,7 +2141,7 @@ graph_paint(image_desc_t *im, char ***calcpr) gfx_add_point(node,0, im->ygif); if (piechart != 2) { - node=gfx_new_area ( canvas, + node=gfx_new_area ( im->canvas, im->xorigin, im->yorigin, im->xorigin + im->xsize, im->yorigin, im->xorigin + im->xsize, im->yorigin-im->ysize, @@ -2157,11 +2154,11 @@ graph_paint(image_desc_t *im, char ***calcpr) if (im->maxval < 0.0) areazero = im->maxval; - axis_paint(im,canvas); + axis_paint(im); } if (piechart) { - pie_part(canvas,im->graph_col[GRC_CANVAS],im->pie_x,im->pie_y,im->piesize*0.5,0,2*M_PI); + pie_part(im,im->graph_col[GRC_CANVAS],im->pie_x,im->pie_y,im->piesize*0.5,0,2*M_PI); } for(i=0;igdes_c;i++){ @@ -2182,7 +2179,7 @@ graph_paint(image_desc_t *im, char ***calcpr) im->gdes[i].p_data[ii] > 0.0) { /* generate a tick */ - gfx_new_line(canvas, im -> xorigin + ii, + gfx_new_line(im->canvas, im -> xorigin + ii, im -> yorigin - (im -> gdes[i].yrule * im -> ysize), im -> xorigin + ii, im -> yorigin, @@ -2215,7 +2212,7 @@ graph_paint(image_desc_t *im, char ***calcpr) if ( ! isnan(im->gdes[i].p_data[ii-1]) && ! isnan(im->gdes[i].p_data[ii])){ if (node == NULL){ - node = gfx_new_line(canvas, + node = gfx_new_line(im->canvas, ii-1+im->xorigin,ytr(im,im->gdes[i].p_data[ii-1]), ii+im->xorigin,ytr(im,im->gdes[i].p_data[ii]), im->gdes[i].linewidth, @@ -2242,7 +2239,7 @@ graph_paint(image_desc_t *im, char ***calcpr) ybase = ytr(im,areazero); } area_start = ii-1; - node = gfx_new_area(canvas, + node = gfx_new_area(im->canvas, ii-1+im->xorigin,ybase, ii-1+im->xorigin,ytr(im,im->gdes[i].p_data[ii-1]), ii+im->xorigin,ytr(im,im->gdes[i].p_data[ii]), @@ -2288,7 +2285,7 @@ graph_paint(image_desc_t *im, char ***calcpr) im->gdes[i].yrule = im->gdes[im->gdes[i].vidx].vf.val; if (finite(im->gdes[i].yrule)) { /* even the fetched var can be NaN */ - pie_part(canvas,im->gdes[i].col, + pie_part(im,im->gdes[i].col, im->pie_x,im->pie_y,im->piesize*0.4, M_PI*2.0*PieStart/100.0, M_PI*2.0*(PieStart+im->gdes[i].yrule)/100.0); @@ -2302,7 +2299,7 @@ graph_paint(image_desc_t *im, char ***calcpr) im->draw_y_grid=0; } /* grid_paint also does the text */ - grid_paint(im,canvas); + grid_paint(im); /* the RULES are the last thing to paint ... */ for(i=0;igdes_c;i++){ @@ -2314,7 +2311,7 @@ graph_paint(image_desc_t *im, char ***calcpr) }; if(im->gdes[i].yrule >= im->minval && im->gdes[i].yrule <= im->maxval) - gfx_new_line(canvas, + gfx_new_line(im->canvas, im->xorigin,ytr(im,im->gdes[i].yrule), im->xorigin+im->xsize,ytr(im,im->gdes[i].yrule), 1.0,im->gdes[i].col); @@ -2325,7 +2322,7 @@ graph_paint(image_desc_t *im, char ***calcpr) }; if(im->gdes[i].xrule >= im->start && im->gdes[i].xrule <= im->end) - gfx_new_line(canvas, + gfx_new_line(im->canvas, xtr(im,im->gdes[i].xrule),im->yorigin, xtr(im,im->gdes[i].xrule),im->yorigin-im->ysize, 1.0,im->gdes[i].col); @@ -2349,15 +2346,9 @@ graph_paint(image_desc_t *im, char ***calcpr) return (-1); } } - switch (im->imgformat) { - case IF_PNG: - gfx_render_png (canvas,im->xgif,im->ygif,im->zoom,0x0,fo); - break; - } + gfx_render (im->canvas,im->xgif,im->ygif,0x0,fo); if (strcmp(im->graphfile,"-") != 0) fclose(fo); - - gfx_destroy(canvas); return 0; } @@ -2485,7 +2476,7 @@ rrd_graph(int argc, char **argv, char ***prdata, int *xsize, int *ysize) filename--; } - sprintf((*prdata)[0],im.imginfo,filename,(long)(im.zoom*im.xgif),(long)(im.zoom*im.ygif)); + sprintf((*prdata)[0],im.imginfo,filename,(long)(im.canvas->zoom*im.xgif),(long)(im.canvas->zoom*im.ygif)); } im_free(&im); return 0; @@ -2506,7 +2497,6 @@ rrd_graph_init(image_desc_t *im) im->title[0] = '\0'; im->minval = DNAN; im->maxval = DNAN; - im->interlaced = 0; im->unitsexponent= 9999; im->extra_flags= 0; im->rigid = 0; @@ -2520,8 +2510,7 @@ rrd_graph_init(image_desc_t *im) im->prt_c = 0; im->gdes_c = 0; im->gdes = NULL; - im->zoom = 1.0; - im->imgformat = IF_PNG; /* we default to PNG output */ + im->canvas = gfx_new_canvas(); for(i=0;igraph_col[i]=graph_col[i]; @@ -2709,7 +2698,7 @@ rrd_graph_options(int argc, char *argv[],image_desc_t *im) im->ysize = long_tmp; break; case 'i': - im->interlaced = 1; + im->canvas->interlaced = 1; break; case 'r': im->rigid = 1; @@ -2718,7 +2707,7 @@ rrd_graph_options(int argc, char *argv[],image_desc_t *im) im->imginfo = optarg; break; case 'a': - if((im->imgformat = if_conv(optarg)) == -1) { + if((im->canvas->imgformat = if_conv(optarg)) == -1) { rrd_set_error("unsupported graphics format '%s'",optarg); return; } @@ -2733,7 +2722,7 @@ rrd_graph_options(int argc, char *argv[],image_desc_t *im) break; case 'c': if(sscanf(optarg, - "%10[A-Z]#%8x", + "%10[A-Z]#%8lx", col_nam,&color) == 2){ int ci; if((ci=grc_conv(col_nam)) != -1){ @@ -2743,7 +2732,7 @@ rrd_graph_options(int argc, char *argv[],image_desc_t *im) } } else { rrd_set_error("invalid color def format"); - return -1; + return; } break; case 'n':{ @@ -2788,8 +2777,8 @@ rrd_graph_options(int argc, char *argv[],image_desc_t *im) break; } case 'm': - im->zoom= atof(optarg); - if (im->zoom <= 0.0) { + im->canvas->zoom = atof(optarg); + if (im->canvas->zoom <= 0.0) { rrd_set_error("zoom factor must be > 0"); return; } @@ -3100,12 +3089,12 @@ rrd_graph_color(image_desc_t *im, char *var, char *err, int optional) switch (n) { case 7: - sscanf(color,"#%6x%n",&col,&n); + sscanf(color,"#%6lx%n",&col,&n); col = (col << 8) + 0xff /* shift left by 8 */; if (n!=7) rrd_set_error("Color problem in %s",err); break; case 9: - sscanf(color,"#%8x%n",&col,&n); + sscanf(color,"#%8lx%n",&col,&n); if (n==9) break; default: rrd_set_error("Color problem in %s",err); diff --git a/src/rrd_graph.h b/src/rrd_graph.h index 8fb96d6..3abb154 100644 --- a/src/rrd_graph.h +++ b/src/rrd_graph.h @@ -25,8 +25,6 @@ enum gf_en {GF_PRINT=0,GF_GPRINT,GF_COMMENT,GF_HRULE,GF_VRULE,GF_LINE, GF_DEF, GF_CDEF, GF_VDEF, GF_PART}; -enum if_en {IF_PNG=0,IF_SVG}; - enum vdef_op_en { VDEF_MAXIMUM /* like the MAX in (G)PRINT */ ,VDEF_MINIMUM /* like the MIN in (G)PRINT */ @@ -119,7 +117,6 @@ typedef struct image_desc_t { char graphfile[MAXPATH]; /* filename for graphic */ long xsize,ysize,piesize; /* graph area size in pixels */ - double zoom; /* zoom for graph */ gfx_color_t graph_col[__GRC_END__]; /* real colors for the graph */ text_prop_t text_prop[TEXT_PROP_LAST]; /* text properties */ char ylegend[200]; /* legend along the yaxis */ @@ -142,14 +139,12 @@ typedef struct image_desc_t { int lazy; /* only update the gif if there is reasonable probablility that the existing one is out of date */ int logarithmic; /* scale the yaxis logarithmic */ - enum if_en imgformat; /* image format */ /* status information */ long xorigin,yorigin;/* where is (0,0) of the graph */ long pie_x,pie_y; /* where is the centerpoint */ long xgif,ygif; /* total size of the gif */ - int interlaced; /* will the graph be interlaced? */ double magfact; /* numerical magnitude*/ long base; /* 1000 or 1024 depending on what we graph */ char symbol; /* magnitude symbol for y-axis */ @@ -160,14 +155,14 @@ typedef struct image_desc_t { long prt_c; /* number of print elements */ long gdes_c; /* number of graphics elements */ graph_desc_t *gdes; /* points to an array of graph elements */ - + gfx_canvas_t *canvas; /* graphics library */ } image_desc_t; /* Prototypes */ int xtr(image_desc_t *,time_t); int ytr(image_desc_t *, double); enum gf_en gf_conv(char *); -enum if_en if_conv(char *); +enum gfx_if_en if_conv(char *); enum tmt_en tmt_conv(char *); enum grc_en grc_conv(char *); enum grc_en text_prop_conv(char *); @@ -186,14 +181,14 @@ time_t find_first_time( time_t, enum tmt_en, long); time_t find_next_time( time_t, enum tmt_en, long); int print_calc(image_desc_t *, char ***); int leg_place(image_desc_t *); -int horizontal_grid(gfx_canvas_t *,image_desc_t *); -int horizontal_log_grid(gfx_canvas_t *, image_desc_t *); -void vertical_grid(gfx_canvas_t *, image_desc_t *); -void axis_paint( image_desc_t *, gfx_canvas_t *); -void grid_paint( image_desc_t *, gfx_canvas_t *); +int horizontal_grid(image_desc_t *); +int horizontal_log_grid(image_desc_t *); +void vertical_grid(image_desc_t *); +void axis_paint(image_desc_t *); +void grid_paint(image_desc_t *); int lazy_check(image_desc_t *); int graph_paint(image_desc_t *, char ***); -void pie_part(gfx_canvas_t *, gfx_color_t, double, double, double, double, double); +void pie_part(image_desc_t *, gfx_color_t, double, double, double, double, double); int gdes_alloc(image_desc_t *); int scan_for_col(char *, int, char *); int rrd_graph(int, char **, char ***, int *, int *); -- 2.11.0 From 3a4825306f808c36fb2c529f27c5457a0715dfaf Mon Sep 17 00:00:00 2001 From: jake Date: Fri, 5 Apr 2002 23:51:21 +0000 Subject: [PATCH 16/16] Updated/added MVSC++ 6.0 project files for compilation of rrd.lib and rrdtool.exe on Win32. Changes for RRDs compilation on Win32. Moved src/ntconfig.h to confignt/config.h. git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk/program@115 a5681a0c-68f1-0310-ab6d-d61299d08faa --- NT-BUILD-TIPS.txt | 30 +++ bindings/perl-shared/RRDs.xs | 10 +- bindings/perl-shared/ntmake.pl | 24 ++- src/ntconfig.h => confignt/config.h | 2 + libraries/freetype-2.0.5/freetype.dsp | 322 +++++++++++++++++++++++++++++++++ libraries/libart_lgpl-2.3.7/libart.dsp | 249 +++++++++++++++++++++++++ libraries/libpng-1.2.0/png.dsp | 183 +++++++++++++++++++ libraries/zlib-1.1.4/zlib.dsp | 149 +++++++++++++++ src/rrd.dsp | 32 +++- src/rrd_gfx.c | 3 +- src/rrd_graph.c | 1 + src/rrd_tool.h | 2 +- src/rrdtool.dsp | 10 +- src/rrdtool.dsw | 38 +++- 14 files changed, 1017 insertions(+), 38 deletions(-) rename src/ntconfig.h => confignt/config.h (90%) create mode 100644 libraries/freetype-2.0.5/freetype.dsp create mode 100644 libraries/libart_lgpl-2.3.7/libart.dsp create mode 100644 libraries/libpng-1.2.0/png.dsp create mode 100644 libraries/zlib-1.1.4/zlib.dsp diff --git a/NT-BUILD-TIPS.txt b/NT-BUILD-TIPS.txt index 882ee95..0354f50 100644 --- a/NT-BUILD-TIPS.txt +++ b/NT-BUILD-TIPS.txt @@ -1,3 +1,33 @@ +Compiling RRDtool 1.1.x on Win32 (WinXP/Win2K with Visual C++): +--------------------------------------------------------------- +4/1/02 Jake Brutlag (jakeb@corp.webtv.net) + +These notes share some insight I gained compiling 1.1.x with +MS Visual C++ 6.0 (using project files). This information may or +may not be accurate at the time you are reading this. + +(1) freetype and rrdtool cannot use precompiled headers (which are +enabled by default for MSVC++ projects). MSVC++ 6.0 does not +support precompiled headers if #include directives contain MACROS. +(2) Compile Release build with Default optimization, not the +Maximize Speed optimization. I encountered some strange errors +(related to argument processing for complex commands like graph-- +perhaps the getopt stuff is too blame) with Maximize Speed. +(3) libart relies upon config.h (ostensibly generated by the +configure script-- but of course not on Win32 platforms). ..\..\confignt +(which contains a static Win32 version of config.h) should be on +the include path. +(4) Fonts are located in the %windir%\fonts, so the default font +is c:\winnt\fonts\cour.ttf. + +Currently, to compile rrd.lib and rrdtool.exe using +the MSVC++ project files, first start MSVC++ 6.0. Open the rrdtool +workspace (rrdtool.dsw in the src directory). The active project/ +configuration should be rrdtool-Win32 Release. Select Rebuild All +from the Build menu. The static link library (rrd.lib) will +be generated in src\release directory and executable will be generated +in the src\toolrelease directory. + Compiling RRDtool on NT ... work in progress --------------------------------------------------------------- by Tamas Kovacshazy (khazy@mit.bme.hu) diff --git a/bindings/perl-shared/RRDs.xs b/bindings/perl-shared/RRDs.xs index d567d07..17b3d85 100644 --- a/bindings/perl-shared/RRDs.xs +++ b/bindings/perl-shared/RRDs.xs @@ -11,10 +11,10 @@ extern "C" { } #endif -#include "../src/rrd_tool.h" +#include "../../src/rrd_tool.h" /* perl 5.004 compatibility */ -#if PERLPATCHLEVEL < 5 +#if PERLPATCHLEVEL < 5 #define PL_sv_undef sv_undef #endif @@ -39,12 +39,14 @@ extern "C" { \ if (rrd_test_error()) XSRETURN_UNDEF; - +/* + * should not be needed if libc is linked (see ntmake.pl) #ifdef WIN32 #define free free #define malloc malloc #define realloc realloc -#endif /*WIN32*/ +#endif +*/ MODULE = RRDs PACKAGE = RRDs PREFIX = rrd_ diff --git a/bindings/perl-shared/ntmake.pl b/bindings/perl-shared/ntmake.pl index b510d76..ff01a41 100644 --- a/bindings/perl-shared/ntmake.pl +++ b/bindings/perl-shared/ntmake.pl @@ -1,14 +1,22 @@ use ExtUtils::MakeMaker; +use Config; # See lib/ExtUtils/MakeMaker.pm for details of how to influence # the contents of the Makefile that is written. +# This file is current set to compile with ActiveState 5xx builds +# (perl 5.005_03). Hopefully this lowest common denominator +# approach will work with newer ActiveState builds (i.e. 6xx). WriteMakefile( 'NAME' => 'RRDs', - 'VERSION_FROM' => 'RRDs.pm', - #'DEFINE' => '-D_DEBUG -DWIN32 -D_CONSOLE', - 'OPTIMIZE' => '-O2', - 'INC' => '-I../src/ -I../gd1.3', - #'LIBS' => ['-L../src/debug -lrrd.lib -L../gd1.3/debug -lgd.lib'], - #'LIBC' => 'libc.lib', - 'MYEXTLIB' => '../src/release/rrd.lib ../gd1.3/release/gd.lib ..\zlib-1.1.3\Release\zlib.lib ..\libpng-1.0.3\Release\png.lib', - 'realclean' => {FILES => 't/demo?.rrd t/demo?.gif' } + 'VERSION_FROM' => 'RRDs.pm', + 'DEFINE' => "-DPERLPATCHLEVEL=$Config{PATCHLEVEL}", + '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' }, + ($] ge '5.005') ? ( + 'AUTHOR' => 'Tobias Oetiker (oetiker@ee.ethz.ch)', + 'ABSTRACT' => 'Round Robin Database Tool', + ) : () + + ); diff --git a/src/ntconfig.h b/confignt/config.h similarity index 90% rename from src/ntconfig.h rename to confignt/config.h index 78fde7a..261f0e6 100644 --- a/src/ntconfig.h +++ b/confignt/config.h @@ -9,3 +9,5 @@ #define HAVE_MATH_H 1 #define rrd_realloc(a,b) realloc((a), (b)) + +#define snprintf _snprintf diff --git a/libraries/freetype-2.0.5/freetype.dsp b/libraries/freetype-2.0.5/freetype.dsp new file mode 100644 index 0000000..50ad9f7 --- /dev/null +++ b/libraries/freetype-2.0.5/freetype.dsp @@ -0,0 +1,322 @@ +# Microsoft Developer Studio Project File - Name="freetype" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Static Library" 0x0104 + +CFG=freetype - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "freetype.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "freetype.mak" CFG="freetype - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "freetype - Win32 Release" (based on "Win32 (x86) Static Library") +!MESSAGE "freetype - Win32 Debug" (based on "Win32 (x86) Static Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "freetype - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c +# ADD CPP /nologo /W3 /GX /I "include" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /FD /c +# SUBTRACT CPP /O /YX +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /i "include" /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo + +!ELSEIF "$(CFG)" == "freetype - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c +# ADD CPP /nologo /ML /W3 /Gm /GX /ZI /Od /I "include" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FD /GZ /c +# SUBTRACT CPP /YX +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo + +!ENDIF + +# Begin Target + +# Name "freetype - Win32 Release" +# Name "freetype - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\ahangles.c +# End Source File +# Begin Source File + +SOURCE=.\ahglobal.c +# End Source File +# Begin Source File + +SOURCE=.\ahglyph.c +# End Source File +# Begin Source File + +SOURCE=.\ahhint.c +# End Source File +# Begin Source File + +SOURCE=.\ahmodule.c +# End Source File +# Begin Source File + +SOURCE=.\cff.c +# End Source File +# Begin Source File + +SOURCE=.\cidgload.c +# End Source File +# Begin Source File + +SOURCE=.\cidload.c +# End Source File +# Begin Source File + +SOURCE=.\cidobjs.c +# End Source File +# Begin Source File + +SOURCE=.\cidparse.c +# End Source File +# Begin Source File + +SOURCE=.\cidriver.c +# End Source File +# Begin Source File + +SOURCE=.\ftcalc.c +# End Source File +# Begin Source File + +SOURCE=.\ftcchunk.c +# End Source File +# Begin Source File + +SOURCE=.\ftcglyph.c +# End Source File +# Begin Source File + +SOURCE=.\ftcimage.c +# End Source File +# Begin Source File + +SOURCE=.\ftcmanag.c +# End Source File +# Begin Source File + +SOURCE=.\ftcsbits.c +# End Source File +# Begin Source File + +SOURCE=.\ftextend.c +# End Source File +# Begin Source File + +SOURCE=.\ftglyph.c +# End Source File +# Begin Source File + +SOURCE=.\ftgrays.c +# End Source File +# Begin Source File + +SOURCE=.\ftinit.c +# End Source File +# Begin Source File + +SOURCE=.\ftlist.c +# End Source File +# Begin Source File + +SOURCE=.\ftlru.c +# End Source File +# Begin Source File + +SOURCE=.\ftnames.c +# End Source File +# Begin Source File + +SOURCE=.\ftobjs.c +# End Source File +# Begin Source File + +SOURCE=.\ftoutln.c +# End Source File +# Begin Source File + +SOURCE=.\ftraster.c +# End Source File +# Begin Source File + +SOURCE=.\ftrend1.c +# End Source File +# Begin Source File + +SOURCE=.\ftsmooth.c +# End Source File +# Begin Source File + +SOURCE=.\ftstream.c +# End Source File +# Begin Source File + +SOURCE=.\ftsystem.c +# End Source File +# Begin Source File + +SOURCE=.\fttrigon.c +# End Source File +# Begin Source File + +SOURCE=.\pcfdriver.c +# End Source File +# Begin Source File + +SOURCE=.\pcfread.c +# End Source File +# Begin Source File + +SOURCE=.\pcfutil.c +# End Source File +# Begin Source File + +SOURCE=.\psauxmod.c +# End Source File +# Begin Source File + +SOURCE=.\psmodule.c +# End Source File +# Begin Source File + +SOURCE=.\psobjs.c +# End Source File +# Begin Source File + +SOURCE=.\sfdriver.c +# End Source File +# Begin Source File + +SOURCE=.\sfobjs.c +# End Source File +# Begin Source File + +SOURCE=.\t1afm.c +# End Source File +# Begin Source File + +SOURCE=.\t1decode.c +# End Source File +# Begin Source File + +SOURCE=.\t1driver.c +# End Source File +# Begin Source File + +SOURCE=.\t1gload.c +# End Source File +# Begin Source File + +SOURCE=.\t1load.c +# End Source File +# Begin Source File + +SOURCE=.\t1objs.c +# End Source File +# Begin Source File + +SOURCE=.\t1parse.c +# End Source File +# Begin Source File + +SOURCE=.\ttcmap.c +# End Source File +# Begin Source File + +SOURCE=.\ttdriver.c +# End Source File +# Begin Source File + +SOURCE=.\ttgload.c +# End Source File +# Begin Source File + +SOURCE=.\ttinterp.c +# End Source File +# Begin Source File + +SOURCE=.\ttload.c +# End Source File +# Begin Source File + +SOURCE=.\ttobjs.c +# End Source File +# Begin Source File + +SOURCE=.\ttpload.c +# End Source File +# Begin Source File + +SOURCE=.\ttpost.c +# End Source File +# Begin Source File + +SOURCE=.\ttsbit.c +# End Source File +# Begin Source File + +SOURCE=.\winfnt.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# End Target +# End Project diff --git a/libraries/libart_lgpl-2.3.7/libart.dsp b/libraries/libart_lgpl-2.3.7/libart.dsp new file mode 100644 index 0000000..2ba7fb3 --- /dev/null +++ b/libraries/libart_lgpl-2.3.7/libart.dsp @@ -0,0 +1,249 @@ +# Microsoft Developer Studio Project File - Name="libart" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Static Library" 0x0104 + +CFG=libart - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "libart.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "libart.mak" CFG="libart - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "libart - Win32 Release" (based on "Win32 (x86) Static Library") +!MESSAGE "libart - Win32 Debug" (based on "Win32 (x86) Static Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "libart - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c +# ADD CPP /nologo /W3 /GX /I "..\..\confignt" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "LIBART_COMPILATION" /YX /FD /c +# SUBTRACT CPP /O +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo + +!ELSEIF "$(CFG)" == "libart - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c +# ADD CPP /nologo /ML /W3 /Gm /GX /ZI /Od /I "..\..\confignt" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "LIBART_COMPILATION" /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo + +!ENDIF + +# Begin Target + +# Name "libart - Win32 Release" +# Name "libart - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\art_affine.c +# End Source File +# Begin Source File + +SOURCE=.\art_alphagamma.c +# End Source File +# Begin Source File + +SOURCE=.\art_bpath.c +# End Source File +# Begin Source File + +SOURCE=.\art_gray_svp.c +# End Source File +# Begin Source File + +SOURCE=.\art_misc.c +# End Source File +# Begin Source File + +SOURCE=.\art_pixbuf.c +# End Source File +# Begin Source File + +SOURCE=.\art_rect.c +# End Source File +# Begin Source File + +SOURCE=.\art_rect_svp.c +# End Source File +# Begin Source File + +SOURCE=.\art_rect_uta.c +# End Source File +# Begin Source File + +SOURCE=.\art_render.c +# End Source File +# Begin Source File + +SOURCE=.\art_render_gradient.c +# End Source File +# Begin Source File + +SOURCE=.\art_render_svp.c +# End Source File +# Begin Source File + +SOURCE=.\art_rgb.c +# End Source File +# Begin Source File + +SOURCE=.\art_rgb_a_affine.c +# End Source File +# Begin Source File + +SOURCE=.\art_rgb_affine.c +# End Source File +# Begin Source File + +SOURCE=.\art_rgb_affine_private.c +# End Source File +# Begin Source File + +SOURCE=.\art_rgb_bitmap_affine.c +# End Source File +# Begin Source File + +SOURCE=.\art_rgb_pixbuf_affine.c +# End Source File +# Begin Source File + +SOURCE=.\art_rgb_rgba_affine.c +# End Source File +# Begin Source File + +SOURCE=.\art_rgb_svp.c +# End Source File +# Begin Source File + +SOURCE=.\art_rgba.c +# End Source File +# Begin Source File + +SOURCE=.\art_svp.c +# End Source File +# Begin Source File + +SOURCE=.\art_svp_intersect.c +# End Source File +# Begin Source File + +SOURCE=.\art_svp_ops.c +# End Source File +# Begin Source File + +SOURCE=.\art_svp_point.c +# End Source File +# Begin Source File + +SOURCE=.\art_svp_render_aa.c +# End Source File +# Begin Source File + +SOURCE=.\art_svp_vpath.c +# End Source File +# Begin Source File + +SOURCE=.\art_svp_vpath_stroke.c +# End Source File +# Begin Source File + +SOURCE=.\art_svp_wind.c +# End Source File +# Begin Source File + +SOURCE=.\art_uta.c +# End Source File +# Begin Source File + +SOURCE=.\art_uta_ops.c +# End Source File +# Begin Source File + +SOURCE=.\art_uta_rect.c +# End Source File +# Begin Source File + +SOURCE=.\art_uta_svp.c +# End Source File +# Begin Source File + +SOURCE=.\art_uta_vpath.c +# End Source File +# Begin Source File + +SOURCE=.\art_vpath.c +# End Source File +# Begin Source File + +SOURCE=.\art_vpath_bpath.c +# End Source File +# Begin Source File + +SOURCE=.\art_vpath_dash.c +# End Source File +# Begin Source File + +SOURCE=.\art_vpath_svp.c +# End Source File +# Begin Source File + +SOURCE=".\libart-features.c" +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# End Target +# End Project diff --git a/libraries/libpng-1.2.0/png.dsp b/libraries/libpng-1.2.0/png.dsp new file mode 100644 index 0000000..7a8ebd5 --- /dev/null +++ b/libraries/libpng-1.2.0/png.dsp @@ -0,0 +1,183 @@ +# Microsoft Developer Studio Project File - Name="png" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Static Library" 0x0104 + +CFG=png - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "png.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "png.mak" CFG="png - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "png - Win32 Release" (based on "Win32 (x86) Static Library") +!MESSAGE "png - Win32 Debug" (based on "Win32 (x86) Static Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "png - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c +# ADD CPP /nologo /W3 /GX /I "..\zlib-1.1.3" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c +# SUBTRACT CPP /O +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo + +!ELSEIF "$(CFG)" == "png - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c +# ADD CPP /nologo /ML /W3 /Gm /GX /ZI /Od /I "..\zlib-1.1.3" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo + +!ENDIF + +# Begin Target + +# Name "png - Win32 Release" +# Name "png - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\png.c +# ADD CPP /I "..\zlib-1.1.4" +# SUBTRACT CPP /I "..\zlib-1.1.3" +# End Source File +# Begin Source File + +SOURCE=.\pngerror.c +# ADD CPP /I "..\zlib-1.1.4" +# SUBTRACT CPP /I "..\zlib-1.1.3" +# End Source File +# Begin Source File + +SOURCE=.\pngget.c +# ADD CPP /I "..\zlib-1.1.4" +# SUBTRACT CPP /I "..\zlib-1.1.3" +# End Source File +# Begin Source File + +SOURCE=.\pngmem.c +# ADD CPP /I "..\zlib-1.1.4" +# SUBTRACT CPP /I "..\zlib-1.1.3" +# End Source File +# Begin Source File + +SOURCE=.\pngpread.c +# ADD CPP /I "..\zlib-1.1.4" +# SUBTRACT CPP /I "..\zlib-1.1.3" +# End Source File +# Begin Source File + +SOURCE=.\pngread.c +# ADD CPP /I "..\zlib-1.1.4" +# SUBTRACT CPP /I "..\zlib-1.1.3" +# End Source File +# Begin Source File + +SOURCE=.\pngrio.c +# ADD CPP /I "..\zlib-1.1.4" +# SUBTRACT CPP /I "..\zlib-1.1.3" +# End Source File +# Begin Source File + +SOURCE=.\pngrtran.c +# ADD CPP /I "..\zlib-1.1.4" +# SUBTRACT CPP /I "..\zlib-1.1.3" +# End Source File +# Begin Source File + +SOURCE=.\pngrutil.c +# ADD CPP /I "..\zlib-1.1.4" +# SUBTRACT CPP /I "..\zlib-1.1.3" +# End Source File +# Begin Source File + +SOURCE=.\pngset.c +# ADD CPP /I "..\zlib-1.1.4" +# SUBTRACT CPP /I "..\zlib-1.1.3" +# End Source File +# Begin Source File + +SOURCE=.\pngtrans.c +# ADD CPP /I "..\zlib-1.1.4" +# SUBTRACT CPP /I "..\zlib-1.1.3" +# End Source File +# Begin Source File + +SOURCE=.\pngwio.c +# ADD CPP /I "..\zlib-1.1.4" +# SUBTRACT CPP /I "..\zlib-1.1.3" +# End Source File +# Begin Source File + +SOURCE=.\pngwrite.c +# ADD CPP /I "..\zlib-1.1.4" +# SUBTRACT CPP /I "..\zlib-1.1.3" +# End Source File +# Begin Source File + +SOURCE=.\pngwtran.c +# ADD CPP /I "..\zlib-1.1.4" +# SUBTRACT CPP /I "..\zlib-1.1.3" +# End Source File +# Begin Source File + +SOURCE=.\pngwutil.c +# ADD CPP /I "..\zlib-1.1.4" +# SUBTRACT CPP /I "..\zlib-1.1.3" +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# End Target +# End Project diff --git a/libraries/zlib-1.1.4/zlib.dsp b/libraries/zlib-1.1.4/zlib.dsp new file mode 100644 index 0000000..c443829 --- /dev/null +++ b/libraries/zlib-1.1.4/zlib.dsp @@ -0,0 +1,149 @@ +# Microsoft Developer Studio Project File - Name="zlib" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Static Library" 0x0104 + +CFG=zlib - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "zlib.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "zlib.mak" CFG="zlib - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "zlib - Win32 Release" (based on "Win32 (x86) Static Library") +!MESSAGE "zlib - Win32 Debug" (based on "Win32 (x86) Static Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "zlib - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c +# ADD CPP /nologo /W3 /GX /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c +# SUBTRACT CPP /O +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo + +!ELSEIF "$(CFG)" == "zlib - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c +# ADD CPP /nologo /ML /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo + +!ENDIF + +# Begin Target + +# Name "zlib - Win32 Release" +# Name "zlib - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\adler32.c +# End Source File +# Begin Source File + +SOURCE=.\compress.c +# End Source File +# Begin Source File + +SOURCE=.\crc32.c +# End Source File +# Begin Source File + +SOURCE=.\deflate.c +# End Source File +# Begin Source File + +SOURCE=.\gzio.c +# End Source File +# Begin Source File + +SOURCE=.\infblock.c +# End Source File +# Begin Source File + +SOURCE=.\infcodes.c +# End Source File +# Begin Source File + +SOURCE=.\inffast.c +# End Source File +# Begin Source File + +SOURCE=.\inflate.c +# End Source File +# Begin Source File + +SOURCE=.\inftrees.c +# End Source File +# Begin Source File + +SOURCE=.\infutil.c +# End Source File +# Begin Source File + +SOURCE=.\trees.c +# End Source File +# Begin Source File + +SOURCE=.\uncompr.c +# End Source File +# Begin Source File + +SOURCE=.\zutil.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# End Target +# End Project diff --git a/src/rrd.dsp b/src/rrd.dsp index c6bfe1c..afb073d 100644 --- a/src/rrd.dsp +++ b/src/rrd.dsp @@ -41,8 +41,8 @@ RSC=rc.exe # PROP Intermediate_Dir "release" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MT /W3 /GX /O2 /I "." /I "..\gd1.3" /I "..\libpng-1.0.3" /I "..\zlib-1.1.3" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_CTYPE_DISABLE_MACROS" /FD /c -# SUBTRACT CPP /X /YX +# ADD CPP /nologo /W3 /GX /I "..\libraries\libpng-1.2.0" /I "..\libraries\zlib-1.1.4" /I "..\libraries\libart_lgpl-2.3.7" /I "..\libraries\freetype-2.0.5\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_CTYPE_DISABLE_MACROS" /FD /c +# SUBTRACT CPP /O /X /YX # ADD BASE RSC /l 0x100c # ADD RSC /l 0x100c BSC32=bscmake.exe @@ -65,7 +65,7 @@ LIB32=link.exe -lib # PROP Intermediate_Dir "debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "." /I "..\gd1.3" /I "..\libpng-1.0.3" /I "..\zlib-1.1.3" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "_CTYPE_DISABLE_MACROS" /FR /FD /c +# ADD CPP /nologo /ML /W3 /Gm /GX /ZI /Od /I "..\libraries\libpng-1.2.0" /I "..\libraries\zlib-1.1.4" /I "..\libraries\libart_lgpl-2.3.7" /I "..\libraries\freetype-2.0.5\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "_CTYPE_DISABLE_MACROS" /FR /FD /c # SUBTRACT CPP /X /YX # ADD BASE RSC /l 0x100c # ADD RSC /l 0x100c @@ -84,10 +84,6 @@ LIB32=link.exe -lib # Name "rrd - Win32 Debug" # Begin Source File -SOURCE=.\gdpng.c -# End Source File -# Begin Source File - SOURCE=.\getopt.c # End Source File # Begin Source File @@ -96,7 +92,7 @@ SOURCE=.\getopt1.c # End Source File # Begin Source File -SOURCE=.\gifsize.c +SOURCE=.\hash_32.c # End Source File # Begin Source File @@ -132,10 +128,26 @@ SOURCE=.\rrd_format.c # End Source File # Begin Source File +SOURCE=.\rrd_gfx.c +# End Source File +# Begin Source File + SOURCE=.\rrd_graph.c # End Source File # Begin Source File +SOURCE=.\rrd_graph_helper.c +# End Source File +# Begin Source File + +SOURCE=.\rrd_hw.c +# End Source File +# Begin Source File + +SOURCE=.\rrd_info.c +# End Source File +# Begin Source File + SOURCE=.\rrd_last.c # End Source File # Begin Source File @@ -152,6 +164,10 @@ SOURCE=.\rrd_restore.c # End Source File # Begin Source File +SOURCE=.\rrd_rpncalc.c +# End Source File +# Begin Source File + SOURCE=.\rrd_tune.c # End Source File # Begin Source File diff --git a/src/rrd_gfx.c b/src/rrd_gfx.c index 7ca6450..bd84706 100644 --- a/src/rrd_gfx.c +++ b/src/rrd_gfx.c @@ -11,11 +11,10 @@ #else # define DPRINT(x) #endif - +#include "rrd_tool.h" #include #include #include FT_FREETYPE_H -#include #include "rrd_gfx.h" diff --git a/src/rrd_graph.c b/src/rrd_graph.c index 537a03f..bfce36f 100644 --- a/src/rrd_graph.c +++ b/src/rrd_graph.c @@ -12,6 +12,7 @@ #ifdef WIN32 #include #include +#define RRD_DEFAULT_FONT "c:/winnt/fonts/COUR.TTF" #endif #include "rrd_graph.h" diff --git a/src/rrd_tool.h b/src/rrd_tool.h index 426cef8..76bd7a7 100644 --- a/src/rrd_tool.h +++ b/src/rrd_tool.h @@ -12,7 +12,7 @@ extern "C" { #define _RRD_TOOL_H #ifdef WIN32 -# include "ntconfig.h" +#include "../confignt/config.h" #else #ifdef HAVE_CONFIG_H #include diff --git a/src/rrdtool.dsp b/src/rrdtool.dsp index ad9d877..d3bb360 100644 --- a/src/rrdtool.dsp +++ b/src/rrdtool.dsp @@ -42,8 +42,8 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /MT /W3 /GX /O2 /I "." /I "..\gd1.3" /I "..\libpng-1.0.3" /I "..\zlib-1.1.3" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_CTYPE_DISABLE_MACROS" /FD /c -# SUBTRACT CPP /YX +# ADD CPP /nologo /W3 /GX /I "..\libraries\libpng-1.2.0" /I "..\libraries\zlib-1.1.4" /I "..\libraries\libart_lgpl-2.3.7" /I "..\libraries\freetype-2.0.5\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_CTYPE_DISABLE_MACROS" /FD /c +# SUBTRACT CPP /O /YX # ADD BASE RSC /l 0x100c /d "NDEBUG" # ADD RSC /l 0x100c /d "NDEBUG" BSC32=bscmake.exe @@ -51,7 +51,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ..\gd1.3\release\gd.lib release\rrd.lib /nologo /subsystem:console /incremental:yes /debug /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ..\libraries\libpng-1.2.0\release\png.lib ..\libraries\zlib-1.1.4\release\zlib.lib ..\libraries\libart_lgpl-2.3.7\release\libart.lib ..\libraries\freetype-2.0.5\release\freetype.lib /nologo /subsystem:console /incremental:yes /debug /machine:I386 !ELSEIF "$(CFG)" == "rrdtool - Win32 Debug" @@ -67,7 +67,7 @@ LINK32=link.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "." /I "..\gd1.3" /I "..\libpng-1.0.3" /I "..\zlib-1.1.3" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "_CTYPE_DISABLE_MACROS" /FR /FD /c +# ADD CPP /nologo /ML /W3 /Gm /GX /ZI /Od /I "..\libraries\libpng-1.2.0" /I "..\libraries\zlib-1.1.4" /I "..\libraries\libart_lgpl-2.3.7" /I "..\libraries\freetype-2.0.5\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "_CTYPE_DISABLE_MACROS" /FR /FD /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x100c /d "_DEBUG" # ADD RSC /l 0x100c /d "_DEBUG" @@ -76,7 +76,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo /o"rrdtool.bsc" LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ..\gd1.3\debug\gd.lib debug\rrd.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ..\libraries\libpng-1.2.0\Debug\png.lib ..\libraries\zlib-1.1.4\Debug\zlib.lib ..\libraries\libart_lgpl-2.3.7\Debug\libart.lib ..\libraries\freetype-2.0.5\Debug\freetype.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF diff --git a/src/rrdtool.dsw b/src/rrdtool.dsw index c1f7755..a8ad5a6 100644 --- a/src/rrdtool.dsw +++ b/src/rrdtool.dsw @@ -3,7 +3,7 @@ Microsoft Developer Studio Workspace File, Format Version 6.00 ############################################################################### -Project: "cgilib"="..\cgilib-0.4\cgilib.dsp" - Package Owner=<4> +Project: "cgilib"="..\libraries\cgilib-0.4\cgilib.dsp" - Package Owner=<4> Package=<5> {{{ @@ -15,7 +15,19 @@ Package=<4> ############################################################################### -Project: "gd"="..\gd1.3\gd.dsp" - Package Owner=<4> +Project: "freetype"="..\libraries\freetype-2.0.5\freetype.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "libart"="..\libraries\libart_lgpl-2.3.7\libart.dsp" - Package Owner=<4> Package=<5> {{{ @@ -23,14 +35,11 @@ Package=<5> Package=<4> {{{ - Begin Project Dependency - Project_Dep_Name png - End Project Dependency }}} ############################################################################### -Project: "png"="..\libpng-1.0.3\png.dsp" - Package Owner=<4> +Project: "png"="..\libraries\libpng-1.2.0\png.dsp" - Package Owner=<4> Package=<5> {{{ @@ -53,9 +62,6 @@ Package=<5> Package=<4> {{{ - Begin Project Dependency - Project_Dep_Name gd - End Project Dependency }}} ############################################################################### @@ -89,11 +95,23 @@ Package=<4> Begin Project Dependency Project_Dep_Name rrd End Project Dependency + Begin Project Dependency + Project_Dep_Name freetype + End Project Dependency + Begin Project Dependency + Project_Dep_Name libart + End Project Dependency + Begin Project Dependency + Project_Dep_Name png + End Project Dependency + Begin Project Dependency + Project_Dep_Name zlib + End Project Dependency }}} ############################################################################### -Project: "zlib"="..\zlib-1.1.3\zlib.dsp" - Package Owner=<4> +Project: "zlib"="..\libraries\zlib-1.1.4\zlib.dsp" - Package Owner=<4> Package=<5> {{{ -- 2.11.0