X-Git-Url: https://git.octo.it/?p=rrdtool.git;a=blobdiff_plain;f=src%2Frrd_graph.c;h=367d3524f1e7c662d5c20d191da9685475e00987;hp=3be36d066da81bdc388f551812314579860ba45e;hb=bac209eb1d120c27acc1ede8fa7dfef81f3eaaf1;hpb=963ea81c470181470ba8f3260c43d171fc403902 diff --git a/src/rrd_graph.c b/src/rrd_graph.c index 3be36d0..367d352 100644 --- a/src/rrd_graph.c +++ b/src/rrd_graph.c @@ -1,5 +1,5 @@ /**************************************************************************** - * RRDtool 1.2.x Copyright Tobias Oetiker, 1997 - 2005 + * RRDtool 1.2rc3 Copyright by Tobi Oetiker, 1997-2005 **************************************************************************** * rrd__graph.c produce graphs from data in rrdfiles ****************************************************************************/ @@ -9,7 +9,7 @@ #include "rrd_tool.h" -#ifdef WIN32 +#if defined(WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__) #include #include #endif @@ -27,9 +27,6 @@ /* some constant definitions */ -#ifdef WIN32 -char rrd_win_default_font[80]; -#endif #ifndef RRD_DEFAULT_FONT /* there is special code later to pick Cour.ttf when running on windows */ @@ -183,7 +180,9 @@ enum gf_en gf_conv(char *string){ conv_if(DEF,GF_DEF) conv_if(CDEF,GF_CDEF) conv_if(VDEF,GF_VDEF) +#ifdef WITH_PIECHART conv_if(PART,GF_PART) +#endif conv_if(XPORT,GF_XPORT) conv_if(SHIFT,GF_SHIFT) @@ -1355,7 +1354,9 @@ print_calc(image_desc_t *im, char ***prdata) case GF_DEF: case GF_CDEF: case GF_VDEF: +#ifdef WITH_PIECHART case GF_PART: +#endif case GF_SHIFT: case GF_XPORT: break; @@ -1801,15 +1802,15 @@ vertical_grid( } /* paint the labels below the graph */ - for(ti = find_first_time(im->start, + for(ti = find_first_time(im->start - im->xlab_user.precis/2, im->xlab_user.labtm, im->xlab_user.labst); - ti <= im->end; + ti <= im->end - im->xlab_user.precis/2; 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 (tilab < im->start || tilab > im->end) continue; #if HAVE_STRFTIME localtime_r(&tilab, &tm); @@ -1958,6 +1959,14 @@ grid_paint(image_desc_t *im) im->tabwidth,"M", 0)*1.2; boxV = boxH; + /* make sure transparent colors show up all the same */ + node = gfx_new_area(im->canvas, + X0,Y0-boxV, + X0,Y0, + X0+boxH,Y0, + im->graph_col[GRC_CANVAS]); + gfx_add_point ( node, X0+boxH, Y0-boxV ); + node = gfx_new_area(im->canvas, X0,Y0-boxV, X0,Y0, @@ -1966,7 +1975,7 @@ grid_paint(image_desc_t *im) gfx_add_point ( node, X0+boxH, Y0-boxV ); node = gfx_new_line(im->canvas, X0,Y0-boxV, X0,Y0, - 1,0x000000FF); + 1,im->graph_col[GRC_FONT]); gfx_add_point(node,X0+boxH,Y0); gfx_add_point(node,X0+boxH,Y0-boxV); gfx_close_path(node); @@ -2006,6 +2015,7 @@ int lazy_check(image_desc_t *im){ return size; } +#ifdef WITH_PIECHART void pie_part(image_desc_t *im, gfx_color_t color, double PieCenterX, double PieCenterY, double Radius, @@ -2052,8 +2062,16 @@ pie_part(image_desc_t *im, gfx_color_t color, } } +#endif + int -graph_size_location(image_desc_t *im, int elements, int piechart ) +graph_size_location(image_desc_t *im, int elements + +#ifdef WITH_PIECHART +, int piechart +#endif + + ) { /* The actual size of the image to draw is determined from ** several sources. The size given on the command line is @@ -2125,11 +2143,13 @@ graph_size_location(image_desc_t *im, int elements, int piechart ) } } +#ifdef WITH_PIECHART if (piechart) { im->piesize=im->xsizeysize?im->xsize:im->ysize; Xpie=im->piesize; Ypie=im->piesize; } +#endif /* Now calculate the total size. Insert some spacing where desired. im->xorigin and im->yorigin need to correspond @@ -2217,6 +2237,7 @@ graph_size_location(image_desc_t *im, int elements, int piechart ) } #endif +#ifdef WITH_PIECHART /* The pie is placed in the upper right hand corner, ** just below the title (if any) and with sufficient ** padding. @@ -2228,6 +2249,7 @@ graph_size_location(image_desc_t *im, int elements, int piechart ) im->pie_x = im->ximg/2; im->pie_y = im->yorigin-Ypie/2; } +#endif return 0; } @@ -2238,8 +2260,10 @@ graph_paint(image_desc_t *im, char ***calcpr) { int i,ii; int lazy = lazy_check(im); +#ifdef WITH_PIECHART int piechart = 0; double PieStart=0.0; +#endif FILE *fo; gfx_node_t *node; @@ -2258,7 +2282,8 @@ graph_paint(image_desc_t *im, char ***calcpr) /* evaluate VDEF and CDEF operations ... */ if(data_calc(im)==-1) return -1; - + +#ifdef WITH_PIECHART /* check if we need to draw a piechart */ for(i=0;igdes_c;i++){ if (im->gdes[i].gf == GF_PART) { @@ -2266,6 +2291,7 @@ graph_paint(image_desc_t *im, char ***calcpr) break; } } +#endif /* calculate and PRINT and GPRINT definitions. We have to do it at * this point because it will affect the length of the legends @@ -2274,10 +2300,16 @@ graph_paint(image_desc_t *im, char ***calcpr) */ i=print_calc(im,calcpr); if(i<0) return -1; - if(((i==0)&&(piechart==0)) || lazy) return 0; + if(((i==0) +#ifdef WITH_PIECHART +&&(piechart==0) +#endif +) || lazy) return 0; +#ifdef WITH_PIECHART /* If there's only the pie chart to draw, signal this */ if (i==0) piechart=2; +#endif /* get actual drawing data and find min and max values*/ if(data_proc(im)==-1) @@ -2300,7 +2332,11 @@ graph_paint(image_desc_t *im, char ***calcpr) *** Calculating sizes and locations became a bit confusing *** *** so I moved this into a separate function. *** **************************************************************/ - if(graph_size_location(im,i,piechart)==-1) + if(graph_size_location(im,i +#ifdef WITH_PIECHART +,piechart +#endif +)==-1) return -1; /* the actual graph is created by going through the individual @@ -2314,7 +2350,9 @@ graph_paint(image_desc_t *im, char ***calcpr) gfx_add_point(node,0, im->yimg); +#ifdef WITH_PIECHART if (piechart != 2) { +#endif node=gfx_new_area ( im->canvas, im->xorigin, im->yorigin, im->xorigin + im->xsize, im->yorigin, @@ -2327,11 +2365,15 @@ graph_paint(image_desc_t *im, char ***calcpr) areazero = im->minval; if (im->maxval < 0.0) areazero = im->maxval; - } +#ifdef WITH_PIECHART + } +#endif +#ifdef WITH_PIECHART if (piechart) { pie_part(im,im->graph_col[GRC_CANVAS],im->pie_x,im->pie_y,im->piesize*0.5,0,2*M_PI); } +#endif for(i=0;igdes_c;i++){ switch(im->gdes[i].gf){ @@ -2460,6 +2502,7 @@ graph_paint(image_desc_t *im, char ***calcpr) } lastgdes = &(im->gdes[i]); break; +#ifdef WITH_PIECHART case GF_PART: if(isnan(im->gdes[i].yrule)) /* fetch variable */ im->gdes[i].yrule = im->gdes[im->gdes[i].vidx].vf.val; @@ -2472,12 +2515,16 @@ graph_paint(image_desc_t *im, char ***calcpr) PieStart += im->gdes[i].yrule; } break; +#endif + } /* switch */ } +#ifdef WITH_PIECHART if (piechart==2) { im->draw_x_grid=0; im->draw_y_grid=0; } +#endif if( !(im->extra_flags & ONLY_GRAPH) ) axis_paint(im); @@ -2520,7 +2567,7 @@ graph_paint(image_desc_t *im, char ***calcpr) if (strcmp(im->graphfile,"-")==0) { fo = im->graphhandle ? im->graphhandle : stdout; -#ifdef WIN32 +#if defined(WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__) /* Change translation mode for stdout to BINARY */ _setmode( _fileno( fo ), O_BINARY ); #endif @@ -2719,19 +2766,34 @@ rrd_graph_init(image_desc_t *im) for(i=0;igraph_col[i]=graph_col[i]; -#ifdef WIN32 + +#if defined(WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__) { char *windir; + char rrd_win_default_font[1000]; windir = getenv("windir"); /* %windir% is something like D:\windows or C:\winnt */ if (windir != NULL) { - strcpy(rrd_win_default_font,windir); + strncpy(rrd_win_default_font,windir,999); + rrd_win_default_font[999] = '\0'; strcat(rrd_win_default_font,"\\fonts\\cour.ttf"); - for(i=0;itext_prop[i].size = text_prop[i].size; strcpy(im->text_prop[i].font,text_prop[i].font); @@ -2861,6 +2923,7 @@ rrd_graph_options(int argc, char *argv[],image_desc_t *im) &im->xlab_user.precis, &stroff) == 7 && stroff != 0){ strncpy(im->xlab_form, optarg+stroff, sizeof(im->xlab_form) - 1); + im->xlab_form[sizeof(im->xlab_form)-1] = '\0'; if((int)(im->xlab_user.gridtm = tmt_conv(scan_gtm)) == -1){ rrd_set_error("unknown keyword %s",scan_gtm); return;