X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fplot-chart.c;h=a866f4f371c5e7d1a04cd66f0aa4a74c07a48832;hb=64f58bbdab17e4a09b725e713f4f82f567f44076;hp=795e3113a8da141d428c8a832194557ef47cf8fd;hpb=2c4c4a789e9c23478bce195d2ed98bab6064dfc1;p=pspp-builds.git diff --git a/src/plot-chart.c b/src/plot-chart.c index 795e3113..a866f4f3 100644 --- a/src/plot-chart.c +++ b/src/plot-chart.c @@ -14,8 +14,8 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. */ #include #include @@ -52,24 +52,23 @@ struct chart * chart_create(void) { struct chart *chart; - struct outp_driver *d; + d = outp_drivers (NULL); + if (d == NULL) + return NULL; + chart = xmalloc(sizeof(struct chart) ); - - for (d = outp_drivers (NULL); d; d = outp_drivers (d)) + d->class->initialise_chart(d, chart); + if (!chart->lp) { - assert(d->class->initialise_chart); - d->class->initialise_chart(d, chart); - break; /* KLUDGE!! */ + free (chart); + return NULL; } - if ( ! chart->lp ) - return 0; - if (pl_openpl_r (chart->lp) < 0) /* open Plotter */ - return 0; - + return NULL; + pl_fspace_r (chart->lp, 0.0, 0.0, 1000.0, 1000.0); /* set coordinate system */ pl_flinewidth_r (chart->lp, 0.25); /* set line thickness */ pl_pencolorname_r (chart->lp, "black"); @@ -77,8 +76,6 @@ chart_create(void) pl_erase_r (chart->lp); /* erase graphics display */ pl_filltype_r(chart->lp,0); - - pl_savestate_r(chart->lp); /* Set default chartetry */ @@ -94,7 +91,6 @@ chart_create(void) chart->font_size = 0; strcpy(chart->fill_colour,"red"); - /* Get default font size */ if ( !chart->font_size) chart->font_size = pl_fontsize_r(chart->lp, -1); @@ -105,11 +101,8 @@ chart_create(void) chart->data_right, chart->data_top); return chart; - } - - /* Draw a tick mark at position If label is non zero, then print it at the tick mark */ @@ -166,7 +159,8 @@ chart_write_title(struct chart *chart, const char *title, ...) va_list ap; char buf[100]; - assert(chart); + if ( ! chart ) + return ; pl_savestate_r(chart->lp); pl_ffontsize_r(chart->lp,chart->font_size * 1.5); @@ -187,8 +181,10 @@ void chart_submit(struct chart *chart) { struct som_entity s; + struct outp_driver *d; - assert(chart); + if ( ! chart ) + return ; pl_restorestate_r(chart->lp); @@ -206,8 +202,9 @@ chart_submit(struct chart *chart) pl_deleteplparams(chart->pl_params); + d = outp_drivers (NULL); + d->class->finalise_chart(d, chart); free(chart); - } @@ -249,8 +246,8 @@ chart_write_yscale(struct chart *ch, double smin, double smax, int ticks) chart_rounded_tick( (smax - smin) / (double) ticks); - assert (ch) ; - + if ( !ch ) + return; ch->y_max = ceil ( smax / tick_interval ) * tick_interval ; ch->y_min = floor ( smin / tick_interval ) * tick_interval ;