X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Foutput%2Fcharts%2Fcartesian.c;h=ffa6e3c5323c5002d90b7c6868e67a88ef94c936;hb=41df2767aa78e928e50c59f05db2051f687355d4;hp=75c49aa88c9d4fc84ec56d9439ae8560f3e2a09b;hpb=43b1296aafe7582e7dbe6c2b6a8b478d7d9b0fcf;p=pspp diff --git a/src/output/charts/cartesian.c b/src/output/charts/cartesian.c index 75c49aa88c..ffa6e3c532 100644 --- a/src/output/charts/cartesian.c +++ b/src/output/charts/cartesian.c @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 2004 Free Software Foundation, Inc. + Copyright (C) 2004, 2009 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -17,17 +17,16 @@ #include +#include + #include #include #include - +#include #include -#include #include - - struct dataset { int n_data; @@ -46,24 +45,15 @@ static const struct dataset dataset[DATASETS] = /* Plot a data point */ void -chart_datum(struct chart *ch, int dataset UNUSED, double x, double y) +chart_datum (plPlotter *lp, const struct chart_geometry *geom, + int dataset UNUSED, double x, double y) { - if ( ! ch ) - return ; - - { - const double x_pos = - (x - ch->x_min) * ch->abscissa_scale + ch->data_left ; + double x_pos = (x - geom->x_min) * geom->abscissa_scale + geom->data_left; + double y_pos = (y - geom->y_min) * geom->ordinate_scale + geom->data_bottom; - const double y_pos = - (y - ch->y_min) * ch->ordinate_scale + ch->data_bottom ; - - pl_savestate_r(ch->lp); - - pl_fmarker_r(ch->lp, x_pos, y_pos, 6, 15); - - pl_restorestate_r(ch->lp); - } + pl_savestate_r (lp); + pl_fmarker_r (lp, x_pos, y_pos, 6, 15); + pl_restorestate_r (lp); } /* Draw a line with slope SLOPE and intercept INTERCEPT. @@ -72,20 +62,17 @@ chart_datum(struct chart *ch, int dataset UNUSED, double x, double y) y axis otherwise the x axis */ void -chart_line(struct chart *ch, double slope, double intercept, +chart_line(plPlotter *lp, const struct chart_geometry *geom, + double slope, double intercept, double limit1, double limit2, enum CHART_DIM lim_dim) { double x1, y1; - double x2, y2 ; - - if ( ! ch ) - return ; - + double x2, y2; if ( lim_dim == CHART_DIM_Y ) { - x1 = ( limit1 - intercept ) / slope ; - x2 = ( limit2 - intercept ) / slope ; + x1 = ( limit1 - intercept ) / slope; + x2 = ( limit2 - intercept ) / slope; y1 = limit1; y2 = limit2; } @@ -97,15 +84,12 @@ chart_line(struct chart *ch, double slope, double intercept, y2 = slope * x2 + intercept; } - y1 = (y1 - ch->y_min) * ch->ordinate_scale + ch->data_bottom ; - y2 = (y2 - ch->y_min) * ch->ordinate_scale + ch->data_bottom ; - x1 = (x1 - ch->x_min) * ch->abscissa_scale + ch->data_left ; - x2 = (x2 - ch->x_min) * ch->abscissa_scale + ch->data_left ; - - pl_savestate_r(ch->lp); - - pl_fline_r(ch->lp, x1, y1, x2, y2); - - pl_restorestate_r(ch->lp); + y1 = (y1 - geom->y_min) * geom->ordinate_scale + geom->data_bottom; + y2 = (y2 - geom->y_min) * geom->ordinate_scale + geom->data_bottom; + x1 = (x1 - geom->x_min) * geom->abscissa_scale + geom->data_left; + x2 = (x2 - geom->x_min) * geom->abscissa_scale + geom->data_left; + pl_savestate_r (lp); + pl_fline_r (lp, x1, y1, x2, y2); + pl_restorestate_r (lp); }