From 77dc491d3b0c1429801ec839e7afab0fbef6a7fc Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Wed, 29 Jul 2009 21:19:41 -0700 Subject: [PATCH] output: Use Cairo and Pango to draw charts, instead of libplot. This paves the way for adding support for charts to the PSPPIRE GUI, since Cairo can render to a window in GTK+ whereas libplot cannot. I am aware of the following regressions versus the state before this commit: 1. Alignment of text in charts on the baseline is not properly implemented. This makes the labels in pie charts look funny. 2. Chart titles are drawn in the same font size as other chart text. 3. Building without Cairo and Pango is broken. 4. The postscript output driver (as opposed to the cairo output driver in PostScript output mode) no longer supports charts. I plan to fix #1, #2, and #3. #4 is fixable too, but I don't know whether it is worth it; I might prefer to delete the postscript output driver altogether. --- INSTALL | 20 +- NEWS | 9 +- THANKS | 2 - acinclude.m4 | 36 +-- configure.ac | 49 ++-- doc/configuring.texi | 169 ++++++++--- lib/automake.mk | 2 +- src/output/ascii.c | 34 +-- src/output/automake.mk | 3 - src/output/cairo.c | 31 +- src/output/chart-provider.h | 16 +- src/output/chart.c | 142 ++++----- src/output/chart.h | 9 +- src/output/charts/box-whisker.c | 119 ++++---- src/output/charts/cartesian.c | 15 +- src/output/charts/cartesian.h | 5 +- src/output/charts/libplot-dummy.c | 232 --------------- src/output/charts/libplot-dummy.h | 465 ------------------------------ src/output/charts/np-plot.c | 32 +- src/output/charts/piechart.c | 112 +++---- src/output/charts/plot-chart.c | 174 ++++++++--- src/output/charts/plot-chart.h | 26 +- src/output/charts/plot-hist.c | 68 ++--- src/output/html.c | 24 +- src/output/postscript.c | 76 +---- src/ui/automake.mk | 2 +- src/ui/gui/automake.mk | 1 + 27 files changed, 596 insertions(+), 1277 deletions(-) delete mode 100644 src/output/charts/libplot-dummy.c delete mode 100644 src/output/charts/libplot-dummy.h diff --git a/INSTALL b/INSTALL index d3a469cf..686109e4 100644 --- a/INSTALL +++ b/INSTALL @@ -33,12 +33,13 @@ The following packages are required to install PSPP: If you don't have a version already, you can install GNU libiconv (http://www.gnu.org/software/libiconv/). -The following package is required to enable PSPP's graphing features. -If you cannot arrange to install it, you must run `configure' with ---without-libplot. +The following packages are required to enable PSPP's graphing +features. If you cannot arrange to install them, you must run +`configure' with --without-cairo. - * libplot, from GNU plotutils - (http://www.gnu.org/software/plotutils/). + * Cairo (http://cairographics.org/), version 1.5 or later. + + * Pango (http://www.pango.org/), version 1.22 or later. The following packages are required to enable PSPPIRE, the graphical user interface for PSPP. If you cannot install them or do not wish to @@ -209,14 +210,17 @@ suffix on their names by giving `configure' the option Optional Features ================= -`--without-libplot' - Don't compile in support for charts (using libplot). This is - useful if your system doesn't have the libplot library. +`--without-cairo' + Don't compile in support for charts (using Cairo and Pango). This + is useful if your system lacks these libraries. `--without-gui' Don't build the PSPPIRE gui. Use this option if you only want to build the command line version of PSPP. + Cairo and Pango required to build the GUI, so --without-cairo + implies --without-gui. + `--with-gui-tools' Build the gui developer tools. There is no reason to use this option unless you're involved with the development of PSPP diff --git a/NEWS b/NEWS index df10031e..7f6c2a0e 100644 --- a/NEWS +++ b/NEWS @@ -1,10 +1,17 @@ PSPP NEWS -- history of user-visible changes. -Time-stamp: <2009-05-24 22:25:04 blp> +Time-stamp: <2009-07-29 20:52:41 blp> Copyright (C) 1996-9, 2000, 2008, 2009 Free Software Foundation, Inc. See the end for copying conditions. Please send PSPP bug reports to bug-gnu-pspp@gnu.org. +Changes from 0.7.2 to 0.7.3: + + * Charts are now produced with Cairo and Pango, instead of libplot. + Without them, the new graphing features will not work. If you do + not have Cairo and Pango installed, you must run `configure' with + --without-cairo. + Changes from 0.7.1 to 0.7.2: * Updated Perl module interface. diff --git a/THANKS b/THANKS index 5af73108..b5bd839e 100644 --- a/THANKS +++ b/THANKS @@ -12,5 +12,3 @@ Thanks to... * François Pinard for advice on proceeding with development. * Jim Van Zandt for Debian packaging and suggestions. - - * The authors of libplot and libgsl for providing those libraries. diff --git a/acinclude.m4 b/acinclude.m4 index 75fcb0d0..6141edd2 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -1,4 +1,4 @@ -dnl Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc. +dnl Copyright (C) 2005, 2006, 2007, 2009 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -36,40 +36,6 @@ AC_DEFUN([PSPP_PERL], fi ]) -dnl Check that libplot is available. -AC_DEFUN([PSPP_LIBPLOT], -[ - AC_ARG_WITH( - libplot, - [AS_HELP_STRING([--without-libplot], - [don't compile in support of charts (using libplot)])]) - - if test x"$with_libplot" != x"no" ; then - # Check whether we can link against libplot without any extra libraries. - AC_CHECK_LIB(plot, pl_newpl_r, [LIBPLOT_LIBS="-lplot"]) - - # Check whether we can link against libplot if we also link X. - if test x"$LIBPLOT_LIBS" = x""; then - AC_PATH_XTRA - extra_libs="-lXaw -lXmu -lXt $X_PRE_LIBS -lXext -lX11 $X_EXTRA_LIBS -lm" - AC_CHECK_LIB(plot, pl_newpl_r, - [LIBPLOT_LIBS="-lplot $extra_libs" - LDFLAGS="$LDFLAGS $X_LIBS"],, - [$extra_libs]) - fi - - # Still can't link? - if test x"$LIBPLOT_LIBS" = x""; then - PSPP_REQUIRED_PREREQ([libplot (or use --without-libplot)]) - fi - - # Set up to make everything work. - LIBS="$LIBPLOT_LIBS $LIBS" - AC_DEFINE(HAVE_LIBPLOT, 1, - [Define to 1 if you have the `libplot' library (-lplot).]) - fi -]) - dnl PSPP_CHECK_CC_OPTION([OPTION], [ACTION-IF-ACCEPTED], [ACTION-IF-REJECTED]) dnl Check whether the given C compiler OPTION is accepted. dnl If so, execute ACTION-IF-ACCEPTED, otherwise ACTION-IF-REJECTED. diff --git a/configure.ac b/configure.ac index 3405c039..77519330 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ dnl Process this file with autoconf to produce a configure script. dnl Initialize. AC_PREREQ(2.60) -AC_INIT([pspp],[0.7.2],[bug-gnu-pspp@gnu.org]) +AC_INIT([pspp],[0.7.3],[bug-gnu-pspp@gnu.org]) AC_CONFIG_HEADERS([config.h]) AM_INIT_AUTOMAKE @@ -36,36 +36,39 @@ AM_GNU_GETTEXT_VERSION([0.17]) dnl Checks for libraries. AC_SYS_LARGEFILE AC_SEARCH_LIBS([sin], [m]) -PSPP_LIBPLOT PSPP_LC_PAPER AC_ARG_VAR([PSPP_LDFLAGS], [linker flags to be used for linking the pspp binary only]) AC_ARG_VAR([PSPPIRE_LDFLAGS], [linker flags to be used for linking the psppire binary only]) +# Support for Cairo and Pango. +AC_ARG_WITH([cairo], + [AS_HELP_STRING( + [--without-cairo], + [Don't build support for charts (using Cairo and Pango); + implies --without-gui])], + [], [with_cairo=yes]) +AM_CONDITIONAL([HAVE_CAIRO], [test "$with_cairo" != no]) +if test "$with_cairo" != no; then + PKG_CHECK_MODULES([CAIRO], [cairo >= 1.5 pango >= 1.22 pangocairo], + [CPPFLAGS="$CPPFLAGS $CAIRO_CFLAGS" + AC_DEFINE([HAVE_CAIRO], 1, + [Define to 1 if Cairo and Pango are available.])], + [PSPP_REQUIRED_PREREQ([cairo 1.5 or later and pango 1.22 or later (or use --without-cairo)])]) +fi -AC_ARG_WITH( - gui, - [AS_HELP_STRING([--without-gui], [don't build the PSPPIRE gui])]) - -required_gtk_version=2.12 - -if test x"$with_gui" != x"no" ; then - PKG_CHECK_MODULES(GTK, gtk+-2.0 >= $required_gtk_version,, - [PSPP_REQUIRED_PREREQ([gtk+ 2.0 v$required_gtk_version or later (or use --without-gui)])]) +# Support for GUI. +AC_ARG_WITH([gui], + [AS_HELP_STRING([--without-gui], + [Don't build the PSPPIRE GUI (using GTK+)])], + [], [with_gui=yes]) +AM_CONDITIONAL([HAVE_GUI], + [test "$with_cairo" != no && test "$with_gui" != "no"]) +if test "$with_cairo" != no && test "$with_gui" != "no"; then + PKG_CHECK_MODULES([GTK], [gtk+-2.0 >= 2.12], [], + [PSPP_REQUIRED_PREREQ([gtk+ 2.0 version 2.12 or later (or use --without-gui)])]) fi -AM_CONDITIONAL(WITHGUI, test x"$with_gui" != x"no") - - -PKG_CHECK_MODULES([CAIRO], [cairo >= 1.5 pango pangocairo], - [HAVE_CAIRO=yes - CPPFLAGS="$CPPFLAGS $CAIRO_CFLAGS" - LIBS="$LIBPLOT_LIBS $LIBS" - AC_DEFINE([HAVE_CAIRO], 1, - [Define to 1 if Cairo and Pango are available.])], - [HAVE_CAIRO=no - PSPP_OPTIONAL_PREREQ([cairo 1.5 or later])]) -AM_CONDITIONAL([HAVE_CAIRO], [test $HAVE_CAIRO = yes]) dnl Checks needed for psql reader diff --git a/doc/configuring.texi b/doc/configuring.texi index 164d9ab1..a1007d92 100644 --- a/doc/configuring.texi +++ b/doc/configuring.texi @@ -11,9 +11,10 @@ This chapter describe how to configure PSPP for your system. * Configuration files:: How configuration files are read. * Environment variables:: All about environment variables. * Output devices:: Describing your terminal(s) and printer(s). -* PostScript driver class:: Configuration of PostScript devices. +* Cairo driver class:: Configuration of Cairo devices. * ASCII driver class:: Configuration of character-code devices. * HTML driver class:: Configuration for HTML output. +* PostScript driver class:: Configuration of PostScript devices. * Miscellaneous configuring:: Even more configuration variables. @end menu @@ -324,7 +325,7 @@ A unique identifier, used to determine whether to enable the driver. @item class name One of the predefined driver classes supported by PSPP. The -currently supported driver classes include `postscript' and `ascii'. +currently supported driver classes include `cairo' and `ascii'. @item device type(s) Zero or more of the following keywords, delimited by spaces: @@ -540,26 +541,27 @@ interpreted; only the lower 8 bits are used. Tokens, outside of quoted strings, are delimited by white space or equals signs. -@node PostScript driver class -@section The PostScript driver class +@node Cairo driver class +@section The Cairo driver class -The @code{postscript} driver class is used to produce output that is -acceptable to PostScript printers and other interpreters. +The @code{cairo} driver class can produce output in PDF, PostScript, +and SVG formats. It has full support for international character +sets. + +The Cairo driver is only available if your copy of PSPP was built with +the Cairo library. The available options are listed below. @table @code @item output-file=@var{file-name} -File to which output should be sent. This can be an ordinary file name -(i.e., @code{"pspp.ps"}), a pipe (i.e., @code{"|lpr"}), or -stdout (@code{"-"}). Default: @code{"pspp.ps"}. +File to which output should be sent. Default: @code{"pspp.pdf"}. -@item headers=@var{boolean} +@item output-type=@var{output-type} -Controls whether the standard headers showing the time and date and -title and subtitle are printed at the top of each page. Default: -@code{on}. +Type of output to write to the output file, one of @code{pdf}, +@code{ps}, or @code{svg}. Default: @code{pdf}. @item paper-size=@var{paper-size} @@ -578,6 +580,12 @@ assumed. Either @code{portrait} or @code{landscape}. Default: @code{portrait}. +@item headers=@var{boolean} + +Controls whether the standard headers showing the time and date and +title and subtitle are printed at the top of each page. Default: +@code{on}. + @item left-margin=@var{dimension} @itemx right-margin=@var{dimension} @itemx top-margin=@var{dimension} @@ -587,29 +595,17 @@ Sets the margins around the page. The headers, if enabled, are not included in the margins; they are in addition to the margins. For a description of dimensions, see @ref{Dimensions}. Default: @code{0.5in}. -@item prop-font=@var{afm-file}[,@var{font-file}[,@var{encoding-file}]] -@itemx emph-font=@var{afm-file}[,@var{font-file}[,@var{encoding-file}]] -@itemx fixed-font=@var{afm-file}[,@var{font-file}[,@var{encoding-file}]] +@item prop-font=@var{font-name} +@itemx emph-font=@var{font-name} +@itemx fixed-font=@var{font-name} Sets the font used for proportional, emphasized, or fixed-pitch text. -The only required value is @var{afm-file}, the AFM file for the font. - -If specified, @var{font-file} will be downloaded to the printer at the -beginning of the print job. The font file may be in PFA or PFB format. - -The font is reencoded as specified in @var{encoding-file}, if specified. -Each line in @var{encoding-file} should consist of a PostScript -character name and a decimal encoding value (between 0 and 255), -separated by white space. Blank lines and comments introduced by -@samp{#} are also allowed. +Most systems support CSS-like font names such as ``serif'' and +``monospace'', but a wide range of system-specific font are likely to +be supported as well. -The files specified on these options are located as follows. If -the file name begins with @samp{/}, then it is taken as an absolute -path. Otherwise, PSPP searches its configuration path for the specified -name prefixed by @code{psfonts/} (@pxref{File locations}). - -Default: proportional font @code{Times-Roman.afm}, emphasis font -@code{Times-Italic.afm}, fixed-pitch font @code{Courier.afm}. +Default: proportional font @code{serif}, emphasis font @code{serif +italic}, fixed-pitch font @code{monospace}. @item font-size=@var{font-size} @@ -653,14 +649,11 @@ a single @samp{#}, which is replaced by the chart number. Default: @file{"pspp-#.png"}. @item chart-type=@var{type}. -Type of charts to output. Available types typically include @samp{X}, -@samp{png}, @samp{gif}, @samp{svg}, @samp{ps}, @samp{cgm}, @samp{fig}, -@samp{pcl}, @samp{hpgl}, @samp{regis}, @samp{tek}, and @samp{meta}. +Type of charts to output, either @samp{png} or @samp{none}. Default: @samp{png}. -You may specify @samp{none} to disable chart output. Charts are also -disabled if your installation of PSPP was compiled without -@code{libplot}. +Charts are always disabled if your installation of PSPP was compiled +without the @code{cairo} library. @item paginate=@var{boolean} @@ -812,6 +805,104 @@ format. The name should contain a single @samp{#}, which is replaced by the chart number. Default: @file{"pspp-#.png"}. @end table +@node PostScript driver class +@section The PostScript driver class + +The @code{postscript} driver class is used to produce output that is +acceptable to PostScript printers and other interpreters. +The PostScript driver class does not support charts. + +The PostScript driver class is deprecated. It is likely to be removed +in a future version of PSPP. We suggest that you use the Cairo driver +class instead, which can output PostScript as well and has better font +support, including support for international character sets, and does +support charts. + +The available options are listed below. + +@table @code +@item output-file=@var{file-name} + +File to which output should be sent. This can be an ordinary file name +(i.e., @code{"pspp.ps"}), a pipe (i.e., @code{"|lpr"}), or +stdout (@code{"-"}). Default: @code{"pspp.ps"}. + +@item headers=@var{boolean} + +Controls whether the standard headers showing the time and date and +title and subtitle are printed at the top of each page. Default: +@code{on}. + +@item paper-size=@var{paper-size} + +Paper size. You may specify a name (e.g.@: @code{a4}, @code{letter}) +or measurements (e.g.@: @code{210x297}, @code{8.5x11in}). + +The default paper size is taken from the @env{PAPERSIZE} environment +variable or the file indicated by the @env{PAPERCONF} environment +variable, if either variable is set. If not, and your system supports +the @code{LC_PAPER} locale category, then the default paper size is +taken from the locale. Otherwise, if @file{/etc/papersize} exists, +the default paper size is read from it. As a last resort, A4 paper is +assumed. + +@item orientation=@var{orientation} + +Either @code{portrait} or @code{landscape}. Default: @code{portrait}. + +@item left-margin=@var{dimension} +@itemx right-margin=@var{dimension} +@itemx top-margin=@var{dimension} +@itemx bottom-margin=@var{dimension} + +Sets the margins around the page. The headers, if enabled, are not +included in the margins; they are in addition to the margins. For a +description of dimensions, see @ref{Dimensions}. Default: @code{0.5in}. + +@item prop-font=@var{afm-file}[,@var{font-file}[,@var{encoding-file}]] +@itemx emph-font=@var{afm-file}[,@var{font-file}[,@var{encoding-file}]] +@itemx fixed-font=@var{afm-file}[,@var{font-file}[,@var{encoding-file}]] + +Sets the font used for proportional, emphasized, or fixed-pitch text. +The only required value is @var{afm-file}, the AFM file for the font. + +If specified, @var{font-file} will be downloaded to the printer at the +beginning of the print job. The font file may be in PFA or PFB format. + +The font is reencoded as specified in @var{encoding-file}, if specified. +Each line in @var{encoding-file} should consist of a PostScript +character name and a decimal encoding value (between 0 and 255), +separated by white space. Blank lines and comments introduced by +@samp{#} are also allowed. + +The files specified on these options are located as follows. If +the file name begins with @samp{/}, then it is taken as an absolute +path. Otherwise, PSPP searches its configuration path for the specified +name prefixed by @code{psfonts/} (@pxref{File locations}). + +Default: proportional font @code{Times-Roman.afm}, emphasis font +@code{Times-Italic.afm}, fixed-pitch font @code{Courier.afm}. + +@item font-size=@var{font-size} + +Sets the size of the default fonts, in thousandths of a point. Default: +10000 (10 point). + +@item line-gutter=@var{dimension} + +Sets the width of white space on either side of lines that border text +or graphics objects. @xref{Dimensions}. Default: @code{1pt}. + +@item line-spacing=@var{dimension} + +Sets the spacing between the lines in a double line in a table. +Default: @code{1pt}. + +@item line-width=@var{dimension} + +Sets the width of the lines used in tables. Default: @code{0.5pt}. +@end table + @node Miscellaneous configuring @section Miscellaneous configuration diff --git a/lib/automake.mk b/lib/automake.mk index 6b20c674..9bde4afc 100644 --- a/lib/automake.mk +++ b/lib/automake.mk @@ -2,7 +2,7 @@ include $(top_srcdir)/lib/linreg/automake.mk -if WITHGUI +if HAVE_GUI include $(top_srcdir)/lib/gtk-contrib/automake.mk endif diff --git a/src/output/ascii.c b/src/output/ascii.c index 15af515f..b224b3eb 100644 --- a/src/output/ascii.c +++ b/src/output/ascii.c @@ -45,7 +45,7 @@ output-file="pspp.list" append=no|yes If output-file exists, append to it? chart-files="pspp-#.png" Name used for charts. - chart-type=png Format of charts (use "none" to disable). + chart-type=png|none paginate=on|off Formfeeds are desired? tab-width=8 Width of a tab; 0 to not use tabs. @@ -109,7 +109,7 @@ struct ascii_driver_ext bool squeeze_blank_lines; /* Squeeze multiple blank lines into one? */ enum emphasis_style emphasis; /* How to emphasize text. */ int tab_width; /* Width of a tab; 0 not to use tabs. */ - const char *chart_type; /* Type of charts to output; NULL for none. */ + bool enable_charts; /* Enable charts? */ const char *chart_file_name; /* Name of files used for charts. */ bool auto_width; /* Use viewwidth as page width? */ @@ -160,7 +160,7 @@ ascii_open_driver (const char *name, int types, struct substring options) x->emphasis = EMPH_BOLD; x->tab_width = 8; x->chart_file_name = pool_strdup (x->pool, "pspp-#.png"); - x->chart_type = pool_strdup (x->pool, "png"); + x->enable_charts = true; x->auto_width = false; x->auto_length = false; x->page_length = 66; @@ -485,10 +485,16 @@ handle_option (void *this_, const char *key, error (0, 0, _("`chart-files' value must contain `#'")); break; case 2: - if (value[0] != '\0') - x->chart_type = pool_strdup (x->pool, value); + if (!strcmp (value, "png")) + x->enable_charts = true; + else if (!strcmp (value, "none")) + x->enable_charts = false; else - x->chart_type = NULL; + { + error (0, 0, + _("ascii: `png' or `none' expected for `chart-type'")); + return false; + } break; case 3: x->init = pool_strdup (x->pool, value); @@ -867,24 +873,12 @@ static void ascii_output_chart (struct outp_driver *this, const struct chart *chart) { struct ascii_driver_ext *x = this->ext; - struct chart_geometry geom; struct outp_text t; char *file_name; - plPlotter *lp; char *text; - if (x->chart_type == NULL) - return; - - /* Draw chart in separate file. */ - if (!chart_create_file (x->chart_type, x->chart_file_name, x->chart_cnt, - NULL, &file_name, &lp)) - return; - x->chart_cnt++; - chart_geometry_init (lp, &geom, 1000.0, 1000.0); - chart_draw (chart, lp, &geom); - chart_geometry_free (lp); - pl_deletepl_r (lp); + /* Draw chart into separate file */ + file_name = chart_draw_png (chart, x->chart_file_name, x->chart_cnt++); /* Mention chart in output. First advance current position. */ diff --git a/src/output/automake.mk b/src/output/automake.mk index 71b88bb9..1edc5bf7 100644 --- a/src/output/automake.mk +++ b/src/output/automake.mk @@ -12,9 +12,6 @@ src_output_liboutput_la_SOURCES = \ src/output/charts/box-whisker.h \ src/output/charts/cartesian.c \ src/output/charts/cartesian.h \ - src/output/charts/libplot-dummy.c \ - src/output/charts/libplot-dummy.h \ - src/output/charts/libplot.h \ src/output/charts/np-plot.c \ src/output/charts/np-plot.h \ src/output/charts/piechart.c \ diff --git a/src/output/cairo.c b/src/output/cairo.c index 93842328..b8fc486e 100644 --- a/src/output/cairo.c +++ b/src/output/cairo.c @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include @@ -57,9 +57,9 @@ top-margin=0.5in bottom-margin=0.5in - prop-font=Times-Roman - emph-font=Times-Italic - fixed-font=Courier + prop-font=serif + emph-font=serif italic + fixed-font=monospace font-size=10000 line-gutter=1pt @@ -502,6 +502,27 @@ xr_close_page (struct outp_driver *this) struct xr_driver_ext *x = this->ext; cairo_show_page (x->cairo); } + +static void +xr_output_chart (struct outp_driver *this, const struct chart *chart) +{ + struct xr_driver_ext *x = this->ext; + struct chart_geometry geom; + + outp_eject_page (this); + outp_open_page (this); + + cairo_save (x->cairo); + cairo_translate (x->cairo, 0.0, xr_to_pt (this->length)); + cairo_scale (x->cairo, 1.0, -1.0); + chart_geometry_init (x->cairo, &geom, + xr_to_pt (this->width), xr_to_pt (this->length)); + chart_draw (chart, x->cairo, &geom); + chart_geometry_free (x->cairo); + cairo_restore (x->cairo); + + outp_close_page (this); +} /* Draws a line from (x0,y0) to (x1,y1). */ static void @@ -880,7 +901,7 @@ const struct outp_class cairo_class = xr_close_page, NULL, - NULL, + xr_output_chart, NULL, diff --git a/src/output/chart-provider.h b/src/output/chart-provider.h index fbec5d25..fa632861 100644 --- a/src/output/chart-provider.h +++ b/src/output/chart-provider.h @@ -17,6 +17,7 @@ #ifndef OUTPUT_CHART_PROVIDER_H #define OUTPUT_CHART_PROVIDER_H 1 +#include #include #include #include @@ -45,7 +46,7 @@ struct chart_geometry int legend_left ; int legend_right ; - /* Default font size for the plot (if zero, then use plotter default) */ + /* Default font size for the plot. */ int font_size; struct chart_colour fill_colour; @@ -61,7 +62,7 @@ struct chart_geometry struct chart_class { - void (*draw) (const struct chart *, plPlotter *, struct chart_geometry *); + void (*draw) (const struct chart *, cairo_t *, struct chart_geometry *); void (*destroy) (struct chart *); }; @@ -72,14 +73,13 @@ struct chart }; void chart_init (struct chart *, const struct chart_class *); -bool chart_create_file (const char *type, const char *file_name_tmpl, - int number, plPlotterParams *, - char **file_namep, plPlotter **lpp); -void chart_geometry_init (plPlotter *, struct chart_geometry *, +void chart_geometry_init (cairo_t *, struct chart_geometry *, double width, double length); -void chart_geometry_free (plPlotter *); +void chart_geometry_free (cairo_t *); -void chart_draw (const struct chart *, plPlotter *, struct chart_geometry *); +void chart_draw (const struct chart *, cairo_t *, struct chart_geometry *); +char *chart_draw_png (const struct chart *, const char *file_name_template, + int number); #endif /* output/chart-provider.h */ diff --git a/src/output/chart.c b/src/output/chart.c index fb561a26..ab2e57c1 100644 --- a/src/output/chart.c +++ b/src/output/chart.c @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -48,25 +49,9 @@ chart_init (struct chart *chart, const struct chart_class *class) } void -chart_geometry_init (plPlotter *lp, struct chart_geometry *geom, +chart_geometry_init (cairo_t *cr, struct chart_geometry *geom, double width, double length) { - /* Start output page. */ - pl_openpl_r (lp); - - /* Set coordinate system. */ - pl_fspace_r (lp, 0.0, 0.0, width, length); - - /* Set line thickness. */ - pl_flinewidth_r (lp, 0.25); - pl_pencolor_r (lp, 0, 0, 0); - - /* Erase graphics display. */ - pl_erase_r (lp); - - pl_filltype_r (lp, 0); - pl_savestate_r(lp); - /* Set default chartetry. */ geom->data_top = 0.900 * length; geom->data_right = 0.800 * width; @@ -77,36 +62,83 @@ chart_geometry_init (plPlotter *lp, struct chart_geometry *geom, geom->title_bottom = 0.920 * length; geom->legend_left = 0.810 * width; geom->legend_right = width; - geom->font_size = 0; + geom->font_size = 10; geom->fill_colour.red = 255; geom->fill_colour.green = 0; geom->fill_colour.blue = 0; - /* Get default font size */ - if (!geom->font_size) - geom->font_size = pl_fontsize_r (lp, -1); + cairo_set_line_width (cr, 1.0); - /* Draw the data area */ - pl_box_r (lp, - geom->data_left, geom->data_bottom, - geom->data_right, geom->data_top); + cairo_rectangle (cr, geom->data_left, geom->data_bottom, + geom->data_right - geom->data_left, + geom->data_top - geom->data_bottom); + cairo_stroke (cr); } void -chart_geometry_free (plPlotter *lp) +chart_geometry_free (cairo_t *cr UNUSED) { - if (pl_closepl_r (lp) < 0) - fprintf (stderr, "Couldn't close Plotter\n"); } void -chart_draw (const struct chart *chart, plPlotter *lp, +chart_draw (const struct chart *chart, cairo_t *cr, struct chart_geometry *geom) { - chart->class->draw (chart, lp, geom); + chart->class->draw (chart, cr, geom); +} + +char * +chart_draw_png (const struct chart *chart, const char *file_name_template, + int number) +{ + const int width = 640; + const int length = 480; + + struct chart_geometry geom; + cairo_surface_t *surface; + cairo_status_t status; + const char *number_pos; + char *file_name; + cairo_t *cr; + + number_pos = strchr (file_name_template, '#'); + if (number_pos != NULL) + file_name = xasprintf ("%.*s%d%s", (int) (number_pos - file_name_template), + file_name_template, number, number_pos + 1); + else + file_name = xstrdup (file_name_template); + + surface = cairo_image_surface_create (CAIRO_FORMAT_RGB24, width, length); + cr = cairo_create (surface); + + cairo_translate (cr, 0.0, length); + cairo_scale (cr, 1.0, -1.0); + + cairo_save (cr); + cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); + cairo_rectangle (cr, 0, 0, width, length); + cairo_fill (cr); + cairo_restore (cr); + + cairo_set_source_rgb (cr, 0.0, 0.0, 0.0); + + chart_geometry_init (cr, &geom, width, length); + chart_draw (chart, cr, &geom); + chart_geometry_free (cr); + + status = cairo_surface_write_to_png (surface, file_name); + if (status != CAIRO_STATUS_SUCCESS) + error (0, 0, _("writing output file \"%s\": %s"), + file_name, cairo_status_to_string (status)); + + cairo_destroy (cr); + cairo_surface_destroy (surface); + + return file_name; } + struct chart * chart_ref (const struct chart *chart_) { @@ -129,7 +161,7 @@ chart_unref (struct chart *chart) void chart_submit (struct chart *chart) { -#ifdef HAVE_LIBPLOT +#ifdef HAVE_CAIRO struct outp_driver *d; for (d = outp_drivers (NULL); d; d = outp_drivers (d)) @@ -139,51 +171,3 @@ chart_submit (struct chart *chart) chart_unref (chart); } - -bool -chart_create_file (const char *type, const char *file_name_tmpl, int number, - plPlotterParams *params, char **file_namep, plPlotter **lpp) -{ - char *file_name = NULL; - FILE *fp = NULL; - int number_pos; - plPlotter *lp; - - number_pos = strchr (file_name_tmpl, '#') - file_name_tmpl; - file_name = xasprintf ("%.*s%d%s", number_pos, file_name_tmpl, - number, file_name_tmpl + number_pos + 1); - - fp = fopen (file_name, "wb"); - if (fp == NULL) - { - error (0, errno, _("creating \"%s\""), file_name); - goto error; - } - - if (params != NULL) - lp = pl_newpl_r (type, 0, fp, stderr, params); - else - { - params = pl_newplparams (); - lp = pl_newpl_r (type, 0, fp, stderr, params); - pl_deleteplparams (params); - } - if (lp == NULL) - goto error; - - *file_namep = file_name; - *lpp = lp; - return true; - -error: - if (fp != NULL) - { - fclose (fp); - if (file_name != NULL) - unlink (file_name); - } - free (file_name); - *file_namep = NULL; - *lpp = NULL; - return false; -} diff --git a/src/output/chart.h b/src/output/chart.h index b05b5ba4..d6b9b3d4 100644 --- a/src/output/chart.h +++ b/src/output/chart.h @@ -17,14 +17,7 @@ #ifndef OUTPUT_CHART_H #define OUTPUT_CHART_H 1 -/* requires but doesn't #include it. */ -#include - -#ifdef HAVE_CHARTS -#include -#else -#include -#endif +#include struct chart; diff --git a/src/output/charts/box-whisker.c b/src/output/charts/box-whisker.c index d799d743..ea1b4624 100644 --- a/src/output/charts/box-whisker.c +++ b/src/output/charts/box-whisker.c @@ -21,6 +21,7 @@ #include #include +#include #include #include @@ -86,26 +87,20 @@ boxplot_get_chart (struct boxplot *boxplot) * at CENTRELINE */ static void -draw_case (plPlotter *lp, const struct chart_geometry *geom, double centreline, +draw_case (cairo_t *cr, const struct chart_geometry *geom, double centreline, const struct outlier *outlier) { + double y = geom->data_bottom + (outlier->value - geom->y_min) * geom->ordinate_scale; + chart_draw_marker (cr, centreline, y, + outlier->extreme ? MARKER_ASTERISK : MARKER_CIRCLE, + 20); -#define MARKER_CIRCLE 4 -#define MARKER_STAR 3 - - pl_fmarker_r(lp, - centreline, - geom->data_bottom + (outlier->value - geom->y_min) * geom->ordinate_scale, - outlier->extreme ? MARKER_STAR : MARKER_CIRCLE, - 20); - - pl_moverel_r(lp, 10,0); - - pl_alabel_r(lp, 'l', 'c', ds_cstr (&outlier->label)); + cairo_move_to (cr, centreline + 10, y); + chart_label (cr, 'l', 'c', ds_cstr (&outlier->label)); } static void -boxplot_draw_box (plPlotter *lp, const struct chart_geometry *geom, +boxplot_draw_box (cairo_t *cr, const struct chart_geometry *geom, double box_centre, double box_width, const struct box_whisker *bw, @@ -138,75 +133,68 @@ boxplot_draw_box (plPlotter *lp, const struct chart_geometry *geom, top_whisker = geom->data_bottom + (whisker[1] - geom->y_min) * geom->ordinate_scale; - pl_savestate_r(lp); - /* Draw the box */ - pl_savestate_r (lp); - pl_fillcolor_r (lp, - geom->fill_colour.red * 257, - geom->fill_colour.green * 257, - geom->fill_colour.blue * 257); - pl_filltype_r (lp,1); - pl_fbox_r (lp, - box_left, - box_bottom, - box_right, - box_top); - - pl_restorestate_r (lp); + cairo_rectangle (cr, + box_left, + box_bottom, + box_right - box_left, + box_top - box_bottom); + cairo_save (cr); + cairo_set_source_rgb (cr, + geom->fill_colour.red / 255.0, + geom->fill_colour.green / 255.0, + geom->fill_colour.blue / 255.0); + cairo_fill (cr); + cairo_restore (cr); + cairo_stroke (cr); /* Draw the median */ - pl_savestate_r (lp); - pl_linewidth_r (lp, 5); - pl_fline_r (lp, - box_left, - geom->data_bottom + (hinge[1] - geom->y_min) * geom->ordinate_scale, - box_right, - geom->data_bottom + (hinge[1] - geom->y_min) * geom->ordinate_scale); - pl_restorestate_r (lp); + cairo_save (cr); + cairo_set_line_width (cr, cairo_get_line_width (cr) * 5); + cairo_move_to (cr, + box_left, + geom->data_bottom + (hinge[1] - geom->y_min) * geom->ordinate_scale); + cairo_line_to (cr, + box_right, + geom->data_bottom + (hinge[1] - geom->y_min) * geom->ordinate_scale); + cairo_stroke (cr); + cairo_restore (cr); /* Draw the bottom whisker */ - pl_fline_r (lp, - box_left, - bottom_whisker, - box_right, - bottom_whisker); + cairo_move_to (cr, box_left, bottom_whisker); + cairo_line_to (cr, box_right, bottom_whisker); + cairo_stroke (cr); /* Draw top whisker */ - pl_fline_r (lp, - box_left, - top_whisker, - box_right, - top_whisker); - + cairo_move_to (cr, box_left, top_whisker); + cairo_line_to (cr, box_right, top_whisker); + cairo_stroke (cr); /* Draw centre line. (bottom half) */ - pl_fline_r (lp, - box_centre, bottom_whisker, - box_centre, box_bottom); + cairo_move_to (cr, box_centre, bottom_whisker); + cairo_line_to (cr, box_centre, box_bottom); + cairo_stroke (cr); /* (top half) */ - pl_fline_r (lp, - box_centre, top_whisker, - box_centre, box_top); + cairo_move_to (cr, box_centre, top_whisker); + cairo_line_to (cr, box_centre, box_top); + cairo_stroke (cr); outliers = box_whisker_outliers (bw); for (ll = ll_head (outliers); ll != ll_null (outliers); ll = ll_next (ll)) { const struct outlier *outlier = ll_data (ll, struct outlier, ll); - draw_case (lp, geom, box_centre, outlier); + draw_case (cr, geom, box_centre, outlier); } /* Draw tick mark on x axis */ - draw_tick(lp, geom, TICK_ABSCISSA, box_centre - geom->data_left, "%s", name); - - pl_restorestate_r(lp); + draw_tick(cr, geom, TICK_ABSCISSA, box_centre - geom->data_left, "%s", name); } static void -boxplot_draw_yscale (plPlotter *lp, struct chart_geometry *geom, +boxplot_draw_yscale (cairo_t *cr, struct chart_geometry *geom, double y_max, double y_min) { double y_tick; @@ -224,31 +212,28 @@ boxplot_draw_yscale (plPlotter *lp, struct chart_geometry *geom, geom->ordinate_scale = (fabs (geom->data_top - geom->data_bottom) / fabs (geom->y_max - geom->y_min)); - /* Move to data bottom-left */ - pl_move_r (lp, geom->data_left, geom->data_bottom); - for (d = geom->y_min; d <= geom->y_max; d += y_tick) - draw_tick (lp, geom, TICK_ORDINATE, + draw_tick (cr, geom, TICK_ORDINATE, (d - geom->y_min) * geom->ordinate_scale, "%g", d); } static void -boxplot_chart_draw (const struct chart *chart, plPlotter *lp, +boxplot_chart_draw (const struct chart *chart, cairo_t *cr, struct chart_geometry *geom) { const struct boxplot *boxplot = (struct boxplot *) chart; double box_width; size_t i; - boxplot_draw_yscale (lp, geom, boxplot->y_max, boxplot->y_min); - chart_write_title (lp, geom, "%s", boxplot->title); + boxplot_draw_yscale (cr, geom, boxplot->y_max, boxplot->y_min); + chart_write_title (cr, geom, "%s", boxplot->title); box_width = (geom->data_right - geom->data_left) / boxplot->n_boxes / 2.0; for (i = 0; i < boxplot->n_boxes; i++) { const struct box *box = &boxplot->boxes[i]; const double box_centre = (i * 2 + 1) * box_width + geom->data_left; - boxplot_draw_box (lp, geom, box_centre, box_width, box->bw, box->label); + boxplot_draw_box (cr, geom, box_centre, box_width, box->bw, box->label); } } diff --git a/src/output/charts/cartesian.c b/src/output/charts/cartesian.c index ffa6e3c5..74840c30 100644 --- a/src/output/charts/cartesian.c +++ b/src/output/charts/cartesian.c @@ -19,6 +19,7 @@ #include +#include #include #include @@ -45,15 +46,13 @@ static const struct dataset dataset[DATASETS] = /* Plot a data point */ void -chart_datum (plPlotter *lp, const struct chart_geometry *geom, +chart_datum (cairo_t *cr, const struct chart_geometry *geom, int dataset UNUSED, double x, double y) { 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; - pl_savestate_r (lp); - pl_fmarker_r (lp, x_pos, y_pos, 6, 15); - pl_restorestate_r (lp); + chart_draw_marker (cr, x_pos, y_pos, MARKER_SQUARE, 15); } /* Draw a line with slope SLOPE and intercept INTERCEPT. @@ -62,7 +61,7 @@ chart_datum (plPlotter *lp, const struct chart_geometry *geom, y axis otherwise the x axis */ void -chart_line(plPlotter *lp, const struct chart_geometry *geom, +chart_line(cairo_t *cr, const struct chart_geometry *geom, double slope, double intercept, double limit1, double limit2, enum CHART_DIM lim_dim) { @@ -89,7 +88,7 @@ chart_line(plPlotter *lp, const struct chart_geometry *geom, 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); + cairo_move_to (cr, x1, y1); + cairo_line_to (cr, x2, y2); + cairo_stroke (cr); } diff --git a/src/output/charts/cartesian.h b/src/output/charts/cartesian.h index 22e914df..feda1b6f 100644 --- a/src/output/charts/cartesian.h +++ b/src/output/charts/cartesian.h @@ -19,6 +19,7 @@ #ifndef CARTESIAN_H #define CARTESIAN_H +#include #include #include @@ -31,7 +32,7 @@ enum CHART_DIM struct chart_geometry; /* Plot a data point */ -void chart_datum(plPlotter *, const struct chart_geometry *, +void chart_datum(cairo_t *, const struct chart_geometry *, int dataset UNUSED, double x, double y); /* Draw a line with slope SLOPE and intercept INTERCEPT. @@ -39,7 +40,7 @@ void chart_datum(plPlotter *, const struct chart_geometry *, If lim_dim is CHART_DIM_Y then the limit{1,2} are on the y axis otherwise the x axis */ -void chart_line(plPlotter *, const struct chart_geometry *, +void chart_line(cairo_t *, const struct chart_geometry *, double slope, double intercept, double limit1, double limit2, enum CHART_DIM lim_dim); diff --git a/src/output/charts/libplot-dummy.c b/src/output/charts/libplot-dummy.c deleted file mode 100644 index 6fe123ab..00000000 --- a/src/output/charts/libplot-dummy.c +++ /dev/null @@ -1,232 +0,0 @@ -#include - -#ifndef HAVE_LIBPLOT -#include -#include -#include - -plPlotter * pl_newpl_r (const char *type UNUSED, FILE *infile UNUSED, FILE *outfile UNUSED, FILE *errfile UNUSED, const plPlotterParams *plotter_params UNUSED) { abort (); } -int pl_deletepl_r (plPlotter *plotter UNUSED) { abort (); } - -plPlotterParams * pl_newplparams (void UNUSED) { abort (); } -int pl_deleteplparams (plPlotterParams *plotter_params UNUSED) { abort (); } -plPlotterParams * pl_copyplparams (const plPlotterParams *plotter_params UNUSED) { abort (); } - -int pl_setplparam (plPlotterParams *plotter_params UNUSED, const char *parameter UNUSED, void *value UNUSED) { abort (); } - -int pl_arc_r (plPlotter *plotter UNUSED, int xc UNUSED, int yc UNUSED, int x0 UNUSED, int y0 UNUSED, int x1 UNUSED, int y1 UNUSED) { abort (); } -int pl_box_r (plPlotter *plotter UNUSED, int x0 UNUSED, int y0 UNUSED, int x1 UNUSED, int y1 UNUSED) { abort (); } -int pl_circle_r (plPlotter *plotter UNUSED, int x UNUSED, int y UNUSED, int r UNUSED) { abort (); } -int pl_closepl_r (plPlotter *plotter UNUSED) { abort (); } -int pl_cont_r (plPlotter *plotter UNUSED, int x UNUSED, int y UNUSED) { abort (); } -int pl_erase_r (plPlotter *plotter UNUSED) { abort (); } -int pl_label_r (plPlotter *plotter UNUSED, const char *s UNUSED) { abort (); } -int pl_line_r (plPlotter *plotter UNUSED, int x0 UNUSED, int y0 UNUSED, int x1 UNUSED, int y1 UNUSED) { abort (); } -int pl_linemod_r (plPlotter *plotter UNUSED, const char *s UNUSED) { abort (); } -int pl_move_r (plPlotter *plotter UNUSED, int x UNUSED, int y UNUSED) { abort (); } -int pl_openpl_r (plPlotter *plotter UNUSED) { abort (); } -int pl_point_r (plPlotter *plotter UNUSED, int x UNUSED, int y UNUSED) { abort (); } -int pl_space_r (plPlotter *plotter UNUSED, int x0 UNUSED, int y0 UNUSED, int x1 UNUSED, int y1 UNUSED) { abort (); } - -FILE* pl_outfile_r (plPlotter *plotter UNUSED, FILE* outfile UNUSED) { abort (); }/* OBSOLETE */ -int pl_alabel_r (plPlotter *plotter UNUSED, int x_justify UNUSED, int y_justify UNUSED, const char *s UNUSED) { abort (); } -int pl_arcrel_r (plPlotter *plotter UNUSED, int dxc UNUSED, int dyc UNUSED, int dx0 UNUSED, int dy0 UNUSED, int dx1 UNUSED, int dy1 UNUSED) { abort (); } -int pl_bezier2_r (plPlotter *plotter UNUSED, int x0 UNUSED, int y0 UNUSED, int x1 UNUSED, int y1 UNUSED, int x2 UNUSED, int y2 UNUSED) { abort (); } -int pl_bezier2rel_r (plPlotter *plotter UNUSED, int dx0 UNUSED, int dy0 UNUSED, int dx1 UNUSED, int dy1 UNUSED, int dx2 UNUSED, int dy2 UNUSED) { abort (); } -int pl_bezier3_r (plPlotter *plotter UNUSED, int x0 UNUSED, int y0 UNUSED, int x1 UNUSED, int y1 UNUSED, int x2 UNUSED, int y2 UNUSED, int x3 UNUSED, int y3 UNUSED) { abort (); } -int pl_bezier3rel_r (plPlotter *plotter UNUSED, int dx0 UNUSED, int dy0 UNUSED, int dx1 UNUSED, int dy1 UNUSED, int dx2 UNUSED, int dy2 UNUSED, int dx3 UNUSED, int dy3 UNUSED) { abort (); } -int pl_bgcolor_r (plPlotter *plotter UNUSED, int red UNUSED, int green UNUSED, int blue UNUSED) { abort (); } -int pl_bgcolorname_r (plPlotter *plotter UNUSED, const char *name UNUSED) { abort (); } -int pl_boxrel_r (plPlotter *plotter UNUSED, int dx0 UNUSED, int dy0 UNUSED, int dx1 UNUSED, int dy1 UNUSED) { abort (); } -int pl_capmod_r (plPlotter *plotter UNUSED, const char *s UNUSED) { abort (); } -int pl_circlerel_r (plPlotter *plotter UNUSED, int dx UNUSED, int dy UNUSED, int r UNUSED) { abort (); } -int pl_closepath_r (plPlotter *plotter UNUSED) { abort (); } -int pl_color_r (plPlotter *plotter UNUSED, int red UNUSED, int green UNUSED, int blue UNUSED) { abort (); } -int pl_colorname_r (plPlotter *plotter UNUSED, const char *name UNUSED) { abort (); } -int pl_contrel_r (plPlotter *plotter UNUSED, int x UNUSED, int y UNUSED) { abort (); } -int pl_ellarc_r (plPlotter *plotter UNUSED, int xc UNUSED, int yc UNUSED, int x0 UNUSED, int y0 UNUSED, int x1 UNUSED, int y1 UNUSED) { abort (); } -int pl_ellarcrel_r (plPlotter *plotter UNUSED, int dxc UNUSED, int dyc UNUSED, int dx0 UNUSED, int dy0 UNUSED, int dx1 UNUSED, int dy1 UNUSED) { abort (); } -int pl_ellipse_r (plPlotter *plotter UNUSED, int x UNUSED, int y UNUSED, int rx UNUSED, int ry UNUSED, int angle UNUSED) { abort (); } -int pl_ellipserel_r (plPlotter *plotter UNUSED, int dx UNUSED, int dy UNUSED, int rx UNUSED, int ry UNUSED, int angle UNUSED) { abort (); } -int pl_endpath_r (plPlotter *plotter UNUSED) { abort (); } -int pl_endsubpath_r (plPlotter *plotter UNUSED) { abort (); } -int pl_fillcolor_r (plPlotter *plotter UNUSED, int red UNUSED, int green UNUSED, int blue UNUSED) { abort (); } -int pl_fillcolorname_r (plPlotter *plotter UNUSED, const char *name UNUSED) { abort (); } -int pl_fillmod_r (plPlotter *plotter UNUSED, const char *s UNUSED) { abort (); } -int pl_filltype_r (plPlotter *plotter UNUSED, int level UNUSED) { abort (); } -int pl_flushpl_r (plPlotter *plotter UNUSED) { abort (); } -int pl_fontname_r (plPlotter *plotter UNUSED, const char *s UNUSED) { abort (); } -int pl_fontsize_r (plPlotter *plotter UNUSED, int size UNUSED) { abort (); } -int pl_havecap_r (plPlotter *plotter UNUSED, const char *s UNUSED) { abort (); } -int pl_joinmod_r (plPlotter *plotter UNUSED, const char *s UNUSED) { abort (); } -int pl_labelwidth_r (plPlotter *plotter UNUSED, const char *s UNUSED) { abort (); } -int pl_linedash_r (plPlotter *plotter UNUSED, int n UNUSED, const int *dashes UNUSED, int offset UNUSED) { abort (); } -int pl_linerel_r (plPlotter *plotter UNUSED, int dx0 UNUSED, int dy0 UNUSED, int dx1 UNUSED, int dy1 UNUSED) { abort (); } -int pl_linewidth_r (plPlotter *plotter UNUSED, int size UNUSED) { abort (); } -int pl_marker_r (plPlotter *plotter UNUSED, int x UNUSED, int y UNUSED, int type UNUSED, int size UNUSED) { abort (); } -int pl_markerrel_r (plPlotter *plotter UNUSED, int dx UNUSED, int dy UNUSED, int type UNUSED, int size UNUSED) { abort (); } -int pl_moverel_r (plPlotter *plotter UNUSED, int x UNUSED, int y UNUSED) { abort (); } -int pl_orientation_r (plPlotter *plotter UNUSED, int direction UNUSED) { abort (); } -int pl_pencolor_r (plPlotter *plotter UNUSED, int red UNUSED, int green UNUSED, int blue UNUSED) { abort (); } -int pl_pencolorname_r (plPlotter *plotter UNUSED, const char *name UNUSED) { abort (); } -int pl_pentype_r (plPlotter *plotter UNUSED, int level UNUSED) { abort (); } -int pl_pointrel_r (plPlotter *plotter UNUSED, int dx UNUSED, int dy UNUSED) { abort (); } -int pl_restorestate_r (plPlotter *plotter UNUSED) { abort (); } -int pl_savestate_r (plPlotter *plotter UNUSED) { abort (); } -int pl_space2_r (plPlotter *plotter UNUSED, int x0 UNUSED, int y0 UNUSED, int x1 UNUSED, int y1 UNUSED, int x2 UNUSED, int y2 UNUSED) { abort (); } -int pl_textangle_r (plPlotter *plotter UNUSED, int angle UNUSED) { abort (); } - -double pl_ffontname_r (plPlotter *plotter UNUSED, const char *s UNUSED) { abort (); } -double pl_ffontsize_r (plPlotter *plotter UNUSED, double size UNUSED) { abort (); } -double pl_flabelwidth_r (plPlotter *plotter UNUSED, const char *s UNUSED) { abort (); } -double pl_ftextangle_r (plPlotter *plotter UNUSED, double angle UNUSED) { abort (); } -int pl_farc_r (plPlotter *plotter UNUSED, double xc UNUSED, double yc UNUSED, double x0 UNUSED, double y0 UNUSED, double x1 UNUSED, double y1 UNUSED) { abort (); } -int pl_farcrel_r (plPlotter *plotter UNUSED, double dxc UNUSED, double dyc UNUSED, double dx0 UNUSED, double dy0 UNUSED, double dx1 UNUSED, double dy1 UNUSED) { abort (); } -int pl_fbezier2_r (plPlotter *plotter UNUSED, double x0 UNUSED, double y0 UNUSED, double x1 UNUSED, double y1 UNUSED, double x2 UNUSED, double y2 UNUSED) { abort (); } -int pl_fbezier2rel_r (plPlotter *plotter UNUSED, double dx0 UNUSED, double dy0 UNUSED, double dx1 UNUSED, double dy1 UNUSED, double dx2 UNUSED, double dy2 UNUSED) { abort (); } -int pl_fbezier3_r (plPlotter *plotter UNUSED, double x0 UNUSED, double y0 UNUSED, double x1 UNUSED, double y1 UNUSED, double x2 UNUSED, double y2 UNUSED, double x3 UNUSED, double y3 UNUSED) { abort (); } -int pl_fbezier3rel_r (plPlotter *plotter UNUSED, double dx0 UNUSED, double dy0 UNUSED, double dx1 UNUSED, double dy1 UNUSED, double dx2 UNUSED, double dy2 UNUSED, double dx3 UNUSED, double dy3 UNUSED) { abort (); } -int pl_fbox_r (plPlotter *plotter UNUSED, double x0 UNUSED, double y0 UNUSED, double x1 UNUSED, double y1 UNUSED) { abort (); } -int pl_fboxrel_r (plPlotter *plotter UNUSED, double dx0 UNUSED, double dy0 UNUSED, double dx1 UNUSED, double dy1 UNUSED) { abort (); } -int pl_fcircle_r (plPlotter *plotter UNUSED, double x UNUSED, double y UNUSED, double r UNUSED) { abort (); } -int pl_fcirclerel_r (plPlotter *plotter UNUSED, double dx UNUSED, double dy UNUSED, double r UNUSED) { abort (); } -int pl_fcont_r (plPlotter *plotter UNUSED, double x UNUSED, double y UNUSED) { abort (); } -int pl_fcontrel_r (plPlotter *plotter UNUSED, double dx UNUSED, double dy UNUSED) { abort (); } -int pl_fellarc_r (plPlotter *plotter UNUSED, double xc UNUSED, double yc UNUSED, double x0 UNUSED, double y0 UNUSED, double x1 UNUSED, double y1 UNUSED) { abort (); } -int pl_fellarcrel_r (plPlotter *plotter UNUSED, double dxc UNUSED, double dyc UNUSED, double dx0 UNUSED, double dy0 UNUSED, double dx1 UNUSED, double dy1 UNUSED) { abort (); } -int pl_fellipse_r (plPlotter *plotter UNUSED, double x UNUSED, double y UNUSED, double rx UNUSED, double ry UNUSED, double angle UNUSED) { abort (); } -int pl_fellipserel_r (plPlotter *plotter UNUSED, double dx UNUSED, double dy UNUSED, double rx UNUSED, double ry UNUSED, double angle UNUSED) { abort (); } -int pl_flinedash_r (plPlotter *plotter UNUSED, int n UNUSED, const double *dashes UNUSED, double offset UNUSED) { abort (); } -int pl_fline_r (plPlotter *plotter UNUSED, double x0 UNUSED, double y0 UNUSED, double x1 UNUSED, double y1 UNUSED) { abort (); } -int pl_flinerel_r (plPlotter *plotter UNUSED, double dx0 UNUSED, double dy0 UNUSED, double dx1 UNUSED, double dy1 UNUSED) { abort (); } -int pl_flinewidth_r (plPlotter *plotter UNUSED, double size UNUSED) { abort (); } -int pl_fmarker_r (plPlotter *plotter UNUSED, double x UNUSED, double y UNUSED, int type UNUSED, double size UNUSED) { abort (); } -int pl_fmarkerrel_r (plPlotter *plotter UNUSED, double dx UNUSED, double dy UNUSED, int type UNUSED, double size UNUSED) { abort (); } -int pl_fmove_r (plPlotter *plotter UNUSED, double x UNUSED, double y UNUSED) { abort (); } -int pl_fmoverel_r (plPlotter *plotter UNUSED, double dx UNUSED, double dy UNUSED) { abort (); } -int pl_fpoint_r (plPlotter *plotter UNUSED, double x UNUSED, double y UNUSED) { abort (); } -int pl_fpointrel_r (plPlotter *plotter UNUSED, double dx UNUSED, double dy UNUSED) { abort (); } -int pl_fspace_r (plPlotter *plotter UNUSED, double x0 UNUSED, double y0 UNUSED, double x1 UNUSED, double y1 UNUSED) { abort (); } -int pl_fspace2_r (plPlotter *plotter UNUSED, double x0 UNUSED, double y0 UNUSED, double x1 UNUSED, double y1 UNUSED, double x2 UNUSED, double y2 UNUSED) { abort (); } - -int pl_fconcat_r (plPlotter *plotter UNUSED, double m0 UNUSED, double m1 UNUSED, double m2 UNUSED, double m3 UNUSED, double m4 UNUSED, double m5 UNUSED) { abort (); } -int pl_fmiterlimit_r (plPlotter *plotter UNUSED, double limit UNUSED) { abort (); } -int pl_frotate_r (plPlotter *plotter UNUSED, double theta UNUSED) { abort (); } -int pl_fscale_r (plPlotter *plotter UNUSED, double x UNUSED, double y UNUSED) { abort (); } -int pl_fsetmatrix_r (plPlotter *plotter UNUSED, double m0 UNUSED, double m1 UNUSED, double m2 UNUSED, double m3 UNUSED, double m4 UNUSED, double m5 UNUSED) { abort (); } -int pl_ftranslate_r (plPlotter *plotter UNUSED, double x UNUSED, double y UNUSED) { abort (); } - -int pl_newpl (const char *type UNUSED, FILE *infile UNUSED, FILE *outfile UNUSED, FILE *errfile UNUSED) { abort (); } -int pl_selectpl (int handle UNUSED) { abort (); } -int pl_deletepl (int handle UNUSED) { abort (); } - -int pl_parampl (const char *parameter UNUSED, void *value UNUSED) { abort (); } - -int pl_arc (int xc UNUSED, int yc UNUSED, int x0 UNUSED, int y0 UNUSED, int x1 UNUSED, int y1 UNUSED) { abort (); } -int pl_box (int x0 UNUSED, int y0 UNUSED, int x1 UNUSED, int y1 UNUSED) { abort (); } -int pl_circle (int x UNUSED, int y UNUSED, int r UNUSED) { abort (); } -int pl_closepl (void UNUSED) { abort (); } -int pl_cont (int x UNUSED, int y UNUSED) { abort (); } -int pl_erase (void UNUSED) { abort (); } -int pl_label (const char *s UNUSED) { abort (); } -int pl_line (int x0 UNUSED, int y0 UNUSED, int x1 UNUSED, int y1 UNUSED) { abort (); } -int pl_linemod (const char *s UNUSED) { abort (); } -int pl_move (int x UNUSED, int y UNUSED) { abort (); } -int pl_openpl (void UNUSED) { abort (); } -int pl_point (int x UNUSED, int y UNUSED) { abort (); } -int pl_space (int x0 UNUSED, int y0 UNUSED, int x1 UNUSED, int y1 UNUSED) { abort (); } - -FILE* pl_outfile (FILE* outfile UNUSED) { abort (); }/* OBSOLETE */ -int pl_alabel (int x_justify UNUSED, int y_justify UNUSED, const char *s UNUSED) { abort (); } -int pl_arcrel (int dxc UNUSED, int dyc UNUSED, int dx0 UNUSED, int dy0 UNUSED, int dx1 UNUSED, int dy1 UNUSED) { abort (); } -int pl_bezier2 (int x0 UNUSED, int y0 UNUSED, int x1 UNUSED, int y1 UNUSED, int x2 UNUSED, int y2 UNUSED) { abort (); } -int pl_bezier2rel (int dx0 UNUSED, int dy0 UNUSED, int dx1 UNUSED, int dy1 UNUSED, int dx2 UNUSED, int dy2 UNUSED) { abort (); } -int pl_bezier3 (int x0 UNUSED, int y0 UNUSED, int x1 UNUSED, int y1 UNUSED, int x2 UNUSED, int y2 UNUSED, int x3 UNUSED, int y3 UNUSED) { abort (); } -int pl_bezier3rel (int dx0 UNUSED, int dy0 UNUSED, int dx1 UNUSED, int dy1 UNUSED, int dx2 UNUSED, int dy2 UNUSED, int dx3 UNUSED, int dy3 UNUSED) { abort (); } -int pl_bgcolor (int red UNUSED, int green UNUSED, int blue UNUSED) { abort (); } -int pl_bgcolorname (const char *name UNUSED) { abort (); } -int pl_boxrel (int dx0 UNUSED, int dy0 UNUSED, int dx1 UNUSED, int dy1 UNUSED) { abort (); } -int pl_capmod (const char *s UNUSED) { abort (); } -int pl_circlerel (int dx UNUSED, int dy UNUSED, int r UNUSED) { abort (); } -int pl_closepath (void UNUSED) { abort (); } -int pl_color (int red UNUSED, int green UNUSED, int blue UNUSED) { abort (); } -int pl_colorname (const char *name UNUSED) { abort (); } -int pl_contrel (int x UNUSED, int y UNUSED) { abort (); } -int pl_ellarc (int xc UNUSED, int yc UNUSED, int x0 UNUSED, int y0 UNUSED, int x1 UNUSED, int y1 UNUSED) { abort (); } -int pl_ellarcrel (int dxc UNUSED, int dyc UNUSED, int dx0 UNUSED, int dy0 UNUSED, int dx1 UNUSED, int dy1 UNUSED) { abort (); } -int pl_ellipse (int x UNUSED, int y UNUSED, int rx UNUSED, int ry UNUSED, int angle UNUSED) { abort (); } -int pl_ellipserel (int dx UNUSED, int dy UNUSED, int rx UNUSED, int ry UNUSED, int angle UNUSED) { abort (); } -int pl_endpath (void UNUSED) { abort (); } -int pl_endsubpath (void UNUSED) { abort (); } -int pl_fillcolor (int red UNUSED, int green UNUSED, int blue UNUSED) { abort (); } -int pl_fillcolorname (const char *name UNUSED) { abort (); } -int pl_fillmod (const char *s UNUSED) { abort (); } -int pl_filltype (int level UNUSED) { abort (); } -int pl_flushpl (void UNUSED) { abort (); } -int pl_fontname (const char *s UNUSED) { abort (); } -int pl_fontsize (int size UNUSED) { abort (); } -int pl_havecap (const char *s UNUSED) { abort (); } -int pl_joinmod (const char *s UNUSED) { abort (); } -int pl_labelwidth (const char *s UNUSED) { abort (); } -int pl_linedash (int n UNUSED, const int *dashes UNUSED, int offset UNUSED) { abort (); } -int pl_linerel (int dx0 UNUSED, int dy0 UNUSED, int dx1 UNUSED, int dy1 UNUSED) { abort (); } -int pl_linewidth (int size UNUSED) { abort (); } -int pl_marker (int x UNUSED, int y UNUSED, int type UNUSED, int size UNUSED) { abort (); } -int pl_markerrel (int dx UNUSED, int dy UNUSED, int type UNUSED, int size UNUSED) { abort (); } -int pl_moverel (int x UNUSED, int y UNUSED) { abort (); } -int pl_orientation (int direction UNUSED) { abort (); } -int pl_pencolor (int red UNUSED, int green UNUSED, int blue UNUSED) { abort (); } -int pl_pencolorname (const char *name UNUSED) { abort (); } -int pl_pentype (int level UNUSED) { abort (); } -int pl_pointrel (int dx UNUSED, int dy UNUSED) { abort (); } -int pl_restorestate (void UNUSED) { abort (); } -int pl_savestate (void UNUSED) { abort (); } -int pl_space2 (int x0 UNUSED, int y0 UNUSED, int x1 UNUSED, int y1 UNUSED, int x2 UNUSED, int y2 UNUSED) { abort (); } -int pl_textangle (int angle UNUSED) { abort (); } - -double pl_ffontname (const char *s UNUSED) { abort (); } -double pl_ffontsize (double size UNUSED) { abort (); } -double pl_flabelwidth (const char *s UNUSED) { abort (); } -double pl_ftextangle (double angle UNUSED) { abort (); } -int pl_farc (double xc UNUSED, double yc UNUSED, double x0 UNUSED, double y0 UNUSED, double x1 UNUSED, double y1 UNUSED) { abort (); } -int pl_farcrel (double dxc UNUSED, double dyc UNUSED, double dx0 UNUSED, double dy0 UNUSED, double dx1 UNUSED, double dy1 UNUSED) { abort (); } -int pl_fbezier2 (double x0 UNUSED, double y0 UNUSED, double x1 UNUSED, double y1 UNUSED, double x2 UNUSED, double y2 UNUSED) { abort (); } -int pl_fbezier2rel (double dx0 UNUSED, double dy0 UNUSED, double dx1 UNUSED, double dy1 UNUSED, double dx2 UNUSED, double dy2 UNUSED) { abort (); } -int pl_fbezier3 (double x0 UNUSED, double y0 UNUSED, double x1 UNUSED, double y1 UNUSED, double x2 UNUSED, double y2 UNUSED, double x3 UNUSED, double y3 UNUSED) { abort (); } -int pl_fbezier3rel (double dx0 UNUSED, double dy0 UNUSED, double dx1 UNUSED, double dy1 UNUSED, double dx2 UNUSED, double dy2 UNUSED, double dx3 UNUSED, double dy3 UNUSED) { abort (); } -int pl_fbox (double x0 UNUSED, double y0 UNUSED, double x1 UNUSED, double y1 UNUSED) { abort (); } -int pl_fboxrel (double dx0 UNUSED, double dy0 UNUSED, double dx1 UNUSED, double dy1 UNUSED) { abort (); } -int pl_fcircle (double x UNUSED, double y UNUSED, double r UNUSED) { abort (); } -int pl_fcirclerel (double dx UNUSED, double dy UNUSED, double r UNUSED) { abort (); } -int pl_fcont (double x UNUSED, double y UNUSED) { abort (); } -int pl_fcontrel (double dx UNUSED, double dy UNUSED) { abort (); } -int pl_fellarc (double xc UNUSED, double yc UNUSED, double x0 UNUSED, double y0 UNUSED, double x1 UNUSED, double y1 UNUSED) { abort (); } -int pl_fellarcrel (double dxc UNUSED, double dyc UNUSED, double dx0 UNUSED, double dy0 UNUSED, double dx1 UNUSED, double dy1 UNUSED) { abort (); } -int pl_fellipse (double x UNUSED, double y UNUSED, double rx UNUSED, double ry UNUSED, double angle UNUSED) { abort (); } -int pl_fellipserel (double dx UNUSED, double dy UNUSED, double rx UNUSED, double ry UNUSED, double angle UNUSED) { abort (); } -int pl_flinedash (int n UNUSED, const double *dashes UNUSED, double offset UNUSED) { abort (); } -int pl_fline (double x0 UNUSED, double y0 UNUSED, double x1 UNUSED, double y1 UNUSED) { abort (); } -int pl_flinerel (double dx0 UNUSED, double dy0 UNUSED, double dx1 UNUSED, double dy1 UNUSED) { abort (); } -int pl_flinewidth (double size UNUSED) { abort (); } -int pl_fmarker (double x UNUSED, double y UNUSED, int type UNUSED, double size UNUSED) { abort (); } -int pl_fmarkerrel (double dx UNUSED, double dy UNUSED, int type UNUSED, double size UNUSED) { abort (); } -int pl_fmove (double x UNUSED, double y UNUSED) { abort (); } -int pl_fmoverel (double dx UNUSED, double dy UNUSED) { abort (); } -int pl_fpoint (double x UNUSED, double y UNUSED) { abort (); } -int pl_fpointrel (double dx UNUSED, double dy UNUSED) { abort (); } -int pl_fspace (double x0 UNUSED, double y0 UNUSED, double x1 UNUSED, double y1 UNUSED) { abort (); } -int pl_fspace2 (double x0 UNUSED, double y0 UNUSED, double x1 UNUSED, double y1 UNUSED, double x2 UNUSED, double y2 UNUSED) { abort (); } - -int pl_fconcat (double m0 UNUSED, double m1 UNUSED, double m2 UNUSED, double m3 UNUSED, double m4 UNUSED, double m5 UNUSED) { abort (); } -int pl_fmiterlimit (double limit UNUSED) { abort (); } -int pl_frotate (double theta UNUSED) { abort (); } -int pl_fscale (double x UNUSED, double y UNUSED) { abort (); } -int pl_fsetmatrix (double m0 UNUSED, double m1 UNUSED, double m2 UNUSED, double m3 UNUSED, double m4 UNUSED, double m5 UNUSED) { abort (); } -int pl_ftranslate (double x UNUSED, double y UNUSED) { abort (); } - - -void *_pl_get_hershey_font_info (plPlotter *plotter UNUSED) { abort (); } -void *_pl_get_ps_font_info (plPlotter *plotter UNUSED) { abort (); } -void *_pl_get_pcl_font_info (plPlotter *plotter UNUSED) { abort (); } -void *_pl_get_stick_font_info (plPlotter *plotter UNUSED) { abort (); } -#endif /* !HAVE_LIBPLOT */ diff --git a/src/output/charts/libplot-dummy.h b/src/output/charts/libplot-dummy.h deleted file mode 100644 index 1278113c..00000000 --- a/src/output/charts/libplot-dummy.h +++ /dev/null @@ -1,465 +0,0 @@ -/* This file is part of the GNU plotutils package. Copyright (C) 1995, - 1996, 1997, 1998, 1999, 2000, 2005, 2009, Free Software Foundation, Inc. - - This file has been modified for use with GNU PSPP. - - The GNU plotutils package is free software. You may redistribute it - and/or modify it under the terms of the GNU General Public License as - published by the Free Software foundation; either version 2, or (at your - option) any later version. - - The GNU plotutils package is distributed in the hope that it will be - useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License along - with the GNU plotutils package; see the file COPYING. If not, write to - the Free Software Foundation, Inc., 51 Franklin St., Fifth Floor, - Boston, MA 02110-1301, USA. */ - -/* This is "plot.h", the public header file for GNU libplot, a shared - library for 2-dimensional vector graphics. It declares both the new C - binding, which is thread-safe, and the old C binding, which is not. */ - -/* stdio.h must be included before this file is included. */ - -#ifndef _PLOT_H_ -#define _PLOT_H_ 1 - -/***********************************************************************/ - -/* The functions in the C binding deal with `plPlotter' and - `plPlotterParams' objects. They are the same as the `Plotter' and - `PlotterParams' objects of the C++ binding. Internally, they are called - `plPlotterStruct' and `plPlotterParamsStruct'. In the context of this - header file, they are opaque. */ -typedef struct plPlotterStruct plPlotter; -typedef struct plPlotterParamsStruct plPlotterParams; - -/* Support C++. This file could be #included by a C++ compiler rather than - a C compiler, in which case it needs to know that libplot functions have - C linkage, not C++ linkage. This is accomplished by wrapping all - function declarations in __BEGIN_DECLS ... __END_DECLS. */ -#ifdef ___BEGIN_DECLS -#undef ___BEGIN_DECLS -#endif -#ifdef ___END_DECLS -#undef ___END_DECLS -#endif -#ifdef __cplusplus -# define ___BEGIN_DECLS extern "C" { -# define ___END_DECLS } -#else -# define ___BEGIN_DECLS /* empty */ -# define ___END_DECLS /* empty */ -#endif - -___BEGIN_DECLS - -/* THE C API */ - -/* Constructor/destructor for the plPlotter type. Parameter values are - specified at creation time via a plPlotterParams instance. There is no - copy constructor. */ -plPlotter * pl_newpl_r (const char *type, FILE *infile, FILE *outfile, FILE *errfile, const plPlotterParams *plotter_params); -int pl_deletepl_r (plPlotter *plotter); - -/* Constructor/destructor/copy constructor for the plPlotterParams type, - any instance of which stores parameters that are used when creating a - plPlotter. */ -plPlotterParams * pl_newplparams (void); -int pl_deleteplparams (plPlotterParams *plotter_params); -plPlotterParams * pl_copyplparams (const plPlotterParams *plotter_params); - -/* A function for setting a single Plotter parameter in a plPlotterParams - instance. */ -int pl_setplparam (plPlotterParams *plotter_params, const char *parameter, void *value); - -/* THE PLOTTER METHODS */ - -/* 13 functions in traditional (pre-GNU) libplot */ -int pl_arc_r (plPlotter *plotter, int xc, int yc, int x0, int y0, int x1, int y1); -int pl_box_r (plPlotter *plotter, int x0, int y0, int x1, int y1); -int pl_circle_r (plPlotter *plotter, int x, int y, int r); -int pl_closepl_r (plPlotter *plotter); -int pl_cont_r (plPlotter *plotter, int x, int y); -int pl_erase_r (plPlotter *plotter); -int pl_label_r (plPlotter *plotter, const char *s); -int pl_line_r (plPlotter *plotter, int x0, int y0, int x1, int y1); -int pl_linemod_r (plPlotter *plotter, const char *s); -int pl_move_r (plPlotter *plotter, int x, int y); -int pl_openpl_r (plPlotter *plotter); -int pl_point_r (plPlotter *plotter, int x, int y); -int pl_space_r (plPlotter *plotter, int x0, int y0, int x1, int y1); - -/* 46 additional functions in GNU libplot, plus 1 obsolete function - [pl_outfile_r]. */ -FILE* pl_outfile_r (plPlotter *plotter, FILE* outfile);/* OBSOLETE */ -int pl_alabel_r (plPlotter *plotter, int x_justify, int y_justify, const char *s); -int pl_arcrel_r (plPlotter *plotter, int dxc, int dyc, int dx0, int dy0, int dx1, int dy1); -int pl_bezier2_r (plPlotter *plotter, int x0, int y0, int x1, int y1, int x2, int y2); -int pl_bezier2rel_r (plPlotter *plotter, int dx0, int dy0, int dx1, int dy1, int dx2, int dy2); -int pl_bezier3_r (plPlotter *plotter, int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3); -int pl_bezier3rel_r (plPlotter *plotter, int dx0, int dy0, int dx1, int dy1, int dx2, int dy2, int dx3, int dy3); -int pl_bgcolor_r (plPlotter *plotter, int red, int green, int blue); -int pl_bgcolorname_r (plPlotter *plotter, const char *name); -int pl_boxrel_r (plPlotter *plotter, int dx0, int dy0, int dx1, int dy1); -int pl_capmod_r (plPlotter *plotter, const char *s); -int pl_circlerel_r (plPlotter *plotter, int dx, int dy, int r); -int pl_closepath_r (plPlotter *plotter); -int pl_color_r (plPlotter *plotter, int red, int green, int blue); -int pl_colorname_r (plPlotter *plotter, const char *name); -int pl_contrel_r (plPlotter *plotter, int x, int y); -int pl_ellarc_r (plPlotter *plotter, int xc, int yc, int x0, int y0, int x1, int y1); -int pl_ellarcrel_r (plPlotter *plotter, int dxc, int dyc, int dx0, int dy0, int dx1, int dy1); -int pl_ellipse_r (plPlotter *plotter, int x, int y, int rx, int ry, int angle); -int pl_ellipserel_r (plPlotter *plotter, int dx, int dy, int rx, int ry, int angle); -int pl_endpath_r (plPlotter *plotter); -int pl_endsubpath_r (plPlotter *plotter); -int pl_fillcolor_r (plPlotter *plotter, int red, int green, int blue); -int pl_fillcolorname_r (plPlotter *plotter, const char *name); -int pl_fillmod_r (plPlotter *plotter, const char *s); -int pl_filltype_r (plPlotter *plotter, int level); -int pl_flushpl_r (plPlotter *plotter); -int pl_fontname_r (plPlotter *plotter, const char *s); -int pl_fontsize_r (plPlotter *plotter, int size); -int pl_havecap_r (plPlotter *plotter, const char *s); -int pl_joinmod_r (plPlotter *plotter, const char *s); -int pl_labelwidth_r (plPlotter *plotter, const char *s); -int pl_linedash_r (plPlotter *plotter, int n, const int *dashes, int offset); -int pl_linerel_r (plPlotter *plotter, int dx0, int dy0, int dx1, int dy1); -int pl_linewidth_r (plPlotter *plotter, int size); -int pl_marker_r (plPlotter *plotter, int x, int y, int type, int size); -int pl_markerrel_r (plPlotter *plotter, int dx, int dy, int type, int size); -int pl_moverel_r (plPlotter *plotter, int x, int y); -int pl_orientation_r (plPlotter *plotter, int direction); -int pl_pencolor_r (plPlotter *plotter, int red, int green, int blue); -int pl_pencolorname_r (plPlotter *plotter, const char *name); -int pl_pentype_r (plPlotter *plotter, int level); -int pl_pointrel_r (plPlotter *plotter, int dx, int dy); -int pl_restorestate_r (plPlotter *plotter); -int pl_savestate_r (plPlotter *plotter); -int pl_space2_r (plPlotter *plotter, int x0, int y0, int x1, int y1, int x2, int y2); -int pl_textangle_r (plPlotter *plotter, int angle); - -/* 32 floating point counterparts to some of the above (all GNU additions) */ -double pl_ffontname_r (plPlotter *plotter, const char *s); -double pl_ffontsize_r (plPlotter *plotter, double size); -double pl_flabelwidth_r (plPlotter *plotter, const char *s); -double pl_ftextangle_r (plPlotter *plotter, double angle); -int pl_farc_r (plPlotter *plotter, double xc, double yc, double x0, double y0, double x1, double y1); -int pl_farcrel_r (plPlotter *plotter, double dxc, double dyc, double dx0, double dy0, double dx1, double dy1); -int pl_fbezier2_r (plPlotter *plotter, double x0, double y0, double x1, double y1, double x2, double y2); -int pl_fbezier2rel_r (plPlotter *plotter, double dx0, double dy0, double dx1, double dy1, double dx2, double dy2); -int pl_fbezier3_r (plPlotter *plotter, double x0, double y0, double x1, double y1, double x2, double y2, double x3, double y3); -int pl_fbezier3rel_r (plPlotter *plotter, double dx0, double dy0, double dx1, double dy1, double dx2, double dy2, double dx3, double dy3); -int pl_fbox_r (plPlotter *plotter, double x0, double y0, double x1, double y1); -int pl_fboxrel_r (plPlotter *plotter, double dx0, double dy0, double dx1, double dy1); -int pl_fcircle_r (plPlotter *plotter, double x, double y, double r); -int pl_fcirclerel_r (plPlotter *plotter, double dx, double dy, double r); -int pl_fcont_r (plPlotter *plotter, double x, double y); -int pl_fcontrel_r (plPlotter *plotter, double dx, double dy); -int pl_fellarc_r (plPlotter *plotter, double xc, double yc, double x0, double y0, double x1, double y1); -int pl_fellarcrel_r (plPlotter *plotter, double dxc, double dyc, double dx0, double dy0, double dx1, double dy1); -int pl_fellipse_r (plPlotter *plotter, double x, double y, double rx, double ry, double angle); -int pl_fellipserel_r (plPlotter *plotter, double dx, double dy, double rx, double ry, double angle); -int pl_flinedash_r (plPlotter *plotter, int n, const double *dashes, double offset); -int pl_fline_r (plPlotter *plotter, double x0, double y0, double x1, double y1); -int pl_flinerel_r (plPlotter *plotter, double dx0, double dy0, double dx1, double dy1); -int pl_flinewidth_r (plPlotter *plotter, double size); -int pl_fmarker_r (plPlotter *plotter, double x, double y, int type, double size); -int pl_fmarkerrel_r (plPlotter *plotter, double dx, double dy, int type, double size); -int pl_fmove_r (plPlotter *plotter, double x, double y); -int pl_fmoverel_r (plPlotter *plotter, double dx, double dy); -int pl_fpoint_r (plPlotter *plotter, double x, double y); -int pl_fpointrel_r (plPlotter *plotter, double dx, double dy); -int pl_fspace_r (plPlotter *plotter, double x0, double y0, double x1, double y1); -int pl_fspace2_r (plPlotter *plotter, double x0, double y0, double x1, double y1, double x2, double y2); - -/* 6 floating point operations with no integer counterpart (GNU additions) */ -int pl_fconcat_r (plPlotter *plotter, double m0, double m1, double m2, double m3, double m4, double m5); -int pl_fmiterlimit_r (plPlotter *plotter, double limit); -int pl_frotate_r (plPlotter *plotter, double theta); -int pl_fscale_r (plPlotter *plotter, double x, double y); -int pl_fsetmatrix_r (plPlotter *plotter, double m0, double m1, double m2, double m3, double m4, double m5); -int pl_ftranslate_r (plPlotter *plotter, double x, double y); - -/* THE OLD (non-thread-safe) C API */ - -/* 3 functions specific to the old C API. (For construction/destruction - and selection of Plotters, and setting of Plotter parameters. The fact - that a single Plotter is globally `selected' makes the old API - non-thread-safe.) */ -int pl_newpl (const char *type, FILE *infile, FILE *outfile, FILE *errfile); -int pl_selectpl (int handle); -int pl_deletepl (int handle); - -/* A function for setting parameters of Plotters that will subsequently be - created. This also makes the old API non-thread-safe. */ -int pl_parampl (const char *parameter, void *value); - -/* THE PLOTTER METHODS */ -/* In the old API, the Plotter to be acted on is specified by first calling - selectpl(). */ - -/* 13 functions in traditional (pre-GNU) libplot */ -int pl_arc (int xc, int yc, int x0, int y0, int x1, int y1); -int pl_box (int x0, int y0, int x1, int y1); -int pl_circle (int x, int y, int r); -int pl_closepl (void); -int pl_cont (int x, int y); -int pl_erase (void); -int pl_label (const char *s); -int pl_line (int x0, int y0, int x1, int y1); -int pl_linemod (const char *s); -int pl_move (int x, int y); -int pl_openpl (void); -int pl_point (int x, int y); -int pl_space (int x0, int y0, int x1, int y1); - -/* 46 additional functions in GNU libplot, plus 1 obsolete function - [pl_outfile]. */ -FILE* pl_outfile (FILE* outfile);/* OBSOLETE */ -int pl_alabel (int x_justify, int y_justify, const char *s); -int pl_arcrel (int dxc, int dyc, int dx0, int dy0, int dx1, int dy1); -int pl_bezier2 (int x0, int y0, int x1, int y1, int x2, int y2); -int pl_bezier2rel (int dx0, int dy0, int dx1, int dy1, int dx2, int dy2); -int pl_bezier3 (int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3); -int pl_bezier3rel (int dx0, int dy0, int dx1, int dy1, int dx2, int dy2, int dx3, int dy3); -int pl_bgcolor (int red, int green, int blue); -int pl_bgcolorname (const char *name); -int pl_boxrel (int dx0, int dy0, int dx1, int dy1); -int pl_capmod (const char *s); -int pl_circlerel (int dx, int dy, int r); -int pl_closepath (void); -int pl_color (int red, int green, int blue); -int pl_colorname (const char *name); -int pl_contrel (int x, int y); -int pl_ellarc (int xc, int yc, int x0, int y0, int x1, int y1); -int pl_ellarcrel (int dxc, int dyc, int dx0, int dy0, int dx1, int dy1); -int pl_ellipse (int x, int y, int rx, int ry, int angle); -int pl_ellipserel (int dx, int dy, int rx, int ry, int angle); -int pl_endpath (void); -int pl_endsubpath (void); -int pl_fillcolor (int red, int green, int blue); -int pl_fillcolorname (const char *name); -int pl_fillmod (const char *s); -int pl_filltype (int level); -int pl_flushpl (void); -int pl_fontname (const char *s); -int pl_fontsize (int size); -int pl_havecap (const char *s); -int pl_joinmod (const char *s); -int pl_labelwidth (const char *s); -int pl_linedash (int n, const int *dashes, int offset); -int pl_linerel (int dx0, int dy0, int dx1, int dy1); -int pl_linewidth (int size); -int pl_marker (int x, int y, int type, int size); -int pl_markerrel (int dx, int dy, int type, int size); -int pl_moverel (int x, int y); -int pl_orientation (int direction); -int pl_pencolor (int red, int green, int blue); -int pl_pencolorname (const char *name); -int pl_pentype (int level); -int pl_pointrel (int dx, int dy); -int pl_restorestate (void); -int pl_savestate (void); -int pl_space2 (int x0, int y0, int x1, int y1, int x2, int y2); -int pl_textangle (int angle); - -/* 32 floating point counterparts to some of the above (all GNU additions) */ -double pl_ffontname (const char *s); -double pl_ffontsize (double size); -double pl_flabelwidth (const char *s); -double pl_ftextangle (double angle); -int pl_farc (double xc, double yc, double x0, double y0, double x1, double y1); -int pl_farcrel (double dxc, double dyc, double dx0, double dy0, double dx1, double dy1); -int pl_fbezier2 (double x0, double y0, double x1, double y1, double x2, double y2); -int pl_fbezier2rel (double dx0, double dy0, double dx1, double dy1, double dx2, double dy2); -int pl_fbezier3 (double x0, double y0, double x1, double y1, double x2, double y2, double x3, double y3); -int pl_fbezier3rel (double dx0, double dy0, double dx1, double dy1, double dx2, double dy2, double dx3, double dy3); -int pl_fbox (double x0, double y0, double x1, double y1); -int pl_fboxrel (double dx0, double dy0, double dx1, double dy1); -int pl_fcircle (double x, double y, double r); -int pl_fcirclerel (double dx, double dy, double r); -int pl_fcont (double x, double y); -int pl_fcontrel (double dx, double dy); -int pl_fellarc (double xc, double yc, double x0, double y0, double x1, double y1); -int pl_fellarcrel (double dxc, double dyc, double dx0, double dy0, double dx1, double dy1); -int pl_fellipse (double x, double y, double rx, double ry, double angle); -int pl_fellipserel (double dx, double dy, double rx, double ry, double angle); -int pl_flinedash (int n, const double *dashes, double offset); -int pl_fline (double x0, double y0, double x1, double y1); -int pl_flinerel (double dx0, double dy0, double dx1, double dy1); -int pl_flinewidth (double size); -int pl_fmarker (double x, double y, int type, double size); -int pl_fmarkerrel (double dx, double dy, int type, double size); -int pl_fmove (double x, double y); -int pl_fmoverel (double dx, double dy); -int pl_fpoint (double x, double y); -int pl_fpointrel (double dx, double dy); -int pl_fspace (double x0, double y0, double x1, double y1); -int pl_fspace2 (double x0, double y0, double x1, double y1, double x2, double y2); - -/* 6 floating point operations with no integer counterpart (GNU additions) */ -int pl_fconcat (double m0, double m1, double m2, double m3, double m4, double m5); -int pl_fmiterlimit (double limit); -int pl_frotate (double theta); -int pl_fscale (double x, double y); -int pl_fsetmatrix (double m0, double m1, double m2, double m3, double m4, double m5); -int pl_ftranslate (double x, double y); - - -/* UNDOCUMENTED FONT API CALLS */ -/* These are used by the graphics programs in the plotutils package (e.g., - `graph') to access the font tables within libplot, so that the user can - be given lists of font names. */ - -void *_pl_get_hershey_font_info (plPlotter *plotter); -void *_pl_get_ps_font_info (plPlotter *plotter); -void *_pl_get_pcl_font_info (plPlotter *plotter); -void *_pl_get_stick_font_info (plPlotter *plotter); - -___END_DECLS - -/* THE GLOBAL VARIABLES IN GNU LIBPLOT */ -/* There are two: user-settable error handlers (not yet documented). */ -extern int (*pl_libplot_warning_handler) (const char *msg); -extern int (*pl_libplot_error_handler) (const char *msg); - -#undef const - - -/***********************************************************************/ - -/* Useful definitions, included in both plot.h and plotter.h. */ - -#ifndef _PL_LIBPLOT_USEFUL_DEFS -#define _PL_LIBPLOT_USEFUL_DEFS 1 - -/* Symbol types for the marker() function, extending over the range 0..31. - (1 through 5 are the same as in the GKS [Graphical Kernel System].) - - These are now defined as enums rather than ints. Cast them to ints if - necessary. */ -enum -{ M_NONE, M_DOT, M_PLUS, M_ASTERISK, M_CIRCLE, M_CROSS, - M_SQUARE, M_TRIANGLE, M_DIAMOND, M_STAR, M_INVERTED_TRIANGLE, - M_STARBURST, M_FANCY_PLUS, M_FANCY_CROSS, M_FANCY_SQUARE, - M_FANCY_DIAMOND, M_FILLED_CIRCLE, M_FILLED_SQUARE, M_FILLED_TRIANGLE, - M_FILLED_DIAMOND, M_FILLED_INVERTED_TRIANGLE, M_FILLED_FANCY_SQUARE, - M_FILLED_FANCY_DIAMOND, M_HALF_FILLED_CIRCLE, M_HALF_FILLED_SQUARE, - M_HALF_FILLED_TRIANGLE, M_HALF_FILLED_DIAMOND, - M_HALF_FILLED_INVERTED_TRIANGLE, M_HALF_FILLED_FANCY_SQUARE, - M_HALF_FILLED_FANCY_DIAMOND, M_OCTAGON, M_FILLED_OCTAGON -}; - -/* ONE-BYTE OPERATION CODES FOR GNU METAFILE FORMAT. These are now defined - as enums rather than ints. Cast them to ints if necessary. - - There are 85 currently recognized op codes. The first 10 date back to - Unix plot(5) format. */ - -enum -{ -/* 10 op codes for primitive graphics operations, as in Unix plot(5) format. */ - O_ARC = 'a', - O_CIRCLE = 'c', - O_CONT = 'n', - O_ERASE = 'e', - O_LABEL = 't', - O_LINEMOD = 'f', - O_LINE = 'l', - O_MOVE = 'm', - O_POINT = 'p', - O_SPACE = 's', - -/* 42 op codes that are GNU extensions */ - O_ALABEL = 'T', - O_ARCREL = 'A', - O_BEZIER2 = 'q', - O_BEZIER2REL = 'r', - O_BEZIER3 = 'y', - O_BEZIER3REL = 'z', - O_BGCOLOR = '~', - O_BOX = 'B', /* not an op code in Unix plot(5) */ - O_BOXREL = 'H', - O_CAPMOD = 'K', - O_CIRCLEREL = 'G', - O_CLOSEPATH = 'k', - O_CLOSEPL = 'x', /* not an op code in Unix plot(5) */ - O_COMMENT = '#', - O_CONTREL = 'N', - O_ELLARC = '?', - O_ELLARCREL = '/', - O_ELLIPSE = '+', - O_ELLIPSEREL = '=', - O_ENDPATH = 'E', - O_ENDSUBPATH = ']', - O_FILLTYPE = 'L', - O_FILLCOLOR = 'D', - O_FILLMOD = 'g', - O_FONTNAME = 'F', - O_FONTSIZE = 'S', - O_JOINMOD = 'J', - O_LINEDASH = 'd', - O_LINEREL = 'I', - O_LINEWIDTH = 'W', - O_MARKER = 'Y', - O_MARKERREL = 'Z', - O_MOVEREL = 'M', - O_OPENPL = 'o', /* not an op code in Unix plot(5) */ - O_ORIENTATION = 'b', - O_PENCOLOR = '-', - O_PENTYPE = 'h', - O_POINTREL = 'P', - O_RESTORESTATE= 'O', - O_SAVESTATE = 'U', - O_SPACE2 = ':', - O_TEXTANGLE = 'R', - -/* 30 floating point counterparts to many of the above. They are not even - slightly mnemonic. */ - O_FARC = '1', - O_FARCREL = '2', - O_FBEZIER2 = '`', - O_FBEZIER2REL = '\'', - O_FBEZIER3 = ',', - O_FBEZIER3REL = '.', - O_FBOX = '3', - O_FBOXREL = '4', - O_FCIRCLE = '5', - O_FCIRCLEREL = '6', - O_FCONT = ')', - O_FCONTREL = '_', - O_FELLARC = '}', - O_FELLARCREL = '|', - O_FELLIPSE = '{', - O_FELLIPSEREL = '[', - O_FFONTSIZE = '7', - O_FLINE = '8', - O_FLINEDASH = 'w', - O_FLINEREL = '9', - O_FLINEWIDTH = '0', - O_FMARKER = '!', - O_FMARKERREL = '@', - O_FMOVE = '$', - O_FMOVEREL = '%', - O_FPOINT = '^', - O_FPOINTREL = '&', - O_FSPACE = '*', - O_FSPACE2 = ';', - O_FTEXTANGLE = '(', - -/* 3 op codes for floating point operations with no integer counterpart */ - O_FCONCAT = '\\', - O_FMITERLIMIT = 'i', - O_FSETMATRIX = 'j' -}; - -#endif /* not _PL_LIBPLOT_USEFUL_DEFS */ - -/***********************************************************************/ - -#endif /* not _PLOT_H_ */ diff --git a/src/output/charts/np-plot.c b/src/output/charts/np-plot.c index dba20bac..565b5e14 100644 --- a/src/output/charts/np-plot.c +++ b/src/output/charts/np-plot.c @@ -121,54 +121,54 @@ dnp_plot_create (const struct np *np, const struct casereader *reader, } static void -np_plot_chart_draw (const struct chart *chart, plPlotter *lp, +np_plot_chart_draw (const struct chart *chart, cairo_t *cr, struct chart_geometry *geom) { const struct np_plot_chart *npp = (struct np_plot_chart *) chart; struct casereader *data; struct ccase *c; - chart_write_title (lp, geom, _("Normal Q-Q Plot of %s"), npp->label); - chart_write_xlabel (lp, geom, _("Observed Value")); - chart_write_ylabel (lp, geom, _("Expected Normal")); - chart_write_xscale (lp, geom, + chart_write_title (cr, geom, _("Normal Q-Q Plot of %s"), npp->label); + chart_write_xlabel (cr, geom, _("Observed Value")); + chart_write_ylabel (cr, geom, _("Expected Normal")); + chart_write_xscale (cr, geom, npp->x_lower - npp->slack, npp->x_upper + npp->slack, 5); - chart_write_yscale (lp, geom, npp->y_first, npp->y_last, 5); + chart_write_yscale (cr, geom, npp->y_first, npp->y_last, 5); data = casereader_clone (npp->data); for (; (c = casereader_read (data)) != NULL; case_unref (c)) - chart_datum (lp, geom, 0, + chart_datum (cr, geom, 0, case_data_idx (c, NP_IDX_Y)->f, case_data_idx (c, NP_IDX_NS)->f); casereader_destroy (data); - chart_line (lp, geom, npp->slope, npp->intercept, + chart_line (cr, geom, npp->slope, npp->intercept, npp->y_first, npp->y_last, CHART_DIM_Y); } static void -dnp_plot_chart_draw (const struct chart *chart, plPlotter *lp, +dnp_plot_chart_draw (const struct chart *chart, cairo_t *cr, struct chart_geometry *geom) { const struct np_plot_chart *dnpp = (struct np_plot_chart *) chart; struct casereader *data; struct ccase *c; - chart_write_title (lp, geom, _("Detrended Normal Q-Q Plot of %s"), + chart_write_title (cr, geom, _("Detrended Normal Q-Q Plot of %s"), dnpp->label); - chart_write_xlabel (lp, geom, _("Observed Value")); - chart_write_ylabel (lp, geom, _("Dev from Normal")); - chart_write_xscale (lp, geom, dnpp->y_min, dnpp->y_max, 5); - chart_write_yscale (lp, geom, dnpp->dns_min, dnpp->dns_max, 5); + chart_write_xlabel (cr, geom, _("Observed Value")); + chart_write_ylabel (cr, geom, _("Dev from Normal")); + chart_write_xscale (cr, geom, dnpp->y_min, dnpp->y_max, 5); + chart_write_yscale (cr, geom, dnpp->dns_min, dnpp->dns_max, 5); data = casereader_clone (dnpp->data); for (; (c = casereader_read (data)) != NULL; case_unref (c)) - chart_datum (lp, geom, 0, case_data_idx (c, NP_IDX_Y)->f, + chart_datum (cr, geom, 0, case_data_idx (c, NP_IDX_Y)->f, case_data_idx (c, NP_IDX_DNS)->f); casereader_destroy (data); - chart_line (lp, geom, 0, 0, dnpp->y_min, dnpp->y_max, CHART_DIM_X); + chart_line (cr, geom, 0, 0, dnpp->y_min, dnpp->y_max, CHART_DIM_X); } static void diff --git a/src/output/charts/piechart.c b/src/output/charts/piechart.c index e33fd086..91f92088 100644 --- a/src/output/charts/piechart.c +++ b/src/output/charts/piechart.c @@ -44,7 +44,7 @@ static const struct chart_class piechart_class; /* Draw a single slice of the pie */ static void -draw_segment(plPlotter *, +draw_segment(cairo_t *, double centre_x, double centre_y, double radius, double start_angle, double segment_angle, @@ -77,7 +77,7 @@ piechart_create (const char *title, const struct slice *slices, int n_slices) } static void -piechart_draw (const struct chart *chart, plPlotter *lp, +piechart_draw (const struct chart *chart, cairo_t *cr, struct chart_geometry *geom) { struct piechart *pie = (struct piechart *) chart; @@ -88,16 +88,19 @@ piechart_draw (const struct chart *chart, plPlotter *lp, double angle; int i; + centre_x = (geom->data_right + geom->data_left) / 2.0 ; + centre_y = (geom->data_top + geom->data_bottom) / 2.0 ; + left_label = geom->data_left + (geom->data_right - geom->data_left)/10.0; right_label = geom->data_right - (geom->data_right - geom->data_left)/10.0; - centre_x = (geom->data_right + geom->data_left) / 2.0 ; - centre_y = (geom->data_top + geom->data_bottom) / 2.0 ; + radius = MIN (5.0 / 12.0 * (geom->data_top - geom->data_bottom), + 1.0 / 4.0 * (geom->data_right - geom->data_left)); radius = MIN (5.0 / 12.0 * (geom->data_top - geom->data_bottom), 1.0 / 4.0 * (geom->data_right - geom->data_left)); - chart_write_title (lp, geom, "%s", pie->title); + chart_write_title (cr, geom, "%s", pie->title); total_magnitude = 0.0; for (i = 0; i < pie->n_slices; i++) @@ -116,7 +119,7 @@ piechart_draw (const struct chart *chart, plPlotter *lp, radius * cos(angle + segment_angle/2.0); /* Fill the segment */ - draw_segment (lp, + draw_segment (cr, centre_x, centre_y, radius, angle, segment_angle, &data_colour[i % N_CHART_COLOURS]); @@ -124,97 +127,48 @@ piechart_draw (const struct chart *chart, plPlotter *lp, /* Now add the labels */ if ( label_x < centre_x ) { - pl_line_r (lp, label_x, label_y, left_label, label_y ); - pl_moverel_r (lp, 0, 5); - pl_alabel_r (lp, 0, 0, ds_cstr (&pie->slices[i].label)); + cairo_move_to (cr, label_x, label_y); + cairo_line_to (cr, left_label, label_y); + cairo_stroke (cr); + cairo_move_to (cr, left_label, label_y + 5); + chart_label (cr, 'l', 'x', ds_cstr (&pie->slices[i].label)); } else { - pl_line_r (lp, label_x, label_y, right_label, label_y); - pl_moverel_r (lp, 0, 5); - pl_alabel_r (lp, 'r', 0, ds_cstr (&pie->slices[i].label)); + cairo_move_to (cr, label_x, label_y); + cairo_line_to (cr, right_label, label_y); + cairo_stroke (cr); + cairo_move_to (cr, right_label, label_y + 5); + chart_label (cr, 'r', 'x', ds_cstr (&pie->slices[i].label)); } angle += segment_angle; } /* Draw an outline to the pie */ - pl_filltype_r (lp,0); - pl_fcircle_r (lp, centre_x, centre_y, radius); -} - -/* Fill a segment with the current fill colour */ -static void -fill_segment(plPlotter *lp, - double x0, double y0, - double radius, - double start_angle, double segment_angle) -{ - - const double start_x = x0 - radius * sin(start_angle); - const double start_y = y0 + radius * cos(start_angle); - - const double stop_x = - x0 - radius * sin(start_angle + segment_angle); - - const double stop_y = - y0 + radius * cos(start_angle + segment_angle); - - assert(segment_angle <= 2 * M_PI); - assert(segment_angle >= 0); - - if ( segment_angle > M_PI ) - { - /* Then we must draw it in two halves */ - fill_segment(lp, x0, y0, radius, start_angle, segment_angle / 2.0 ); - fill_segment(lp, x0, y0, radius, start_angle + segment_angle / 2.0, - segment_angle / 2.0 ); - } - else - { - pl_move_r(lp, x0, y0); - - pl_cont_r(lp, stop_x, stop_y); - pl_cont_r(lp, start_x, start_y); - - pl_arc_r(lp, - x0, y0, - stop_x, stop_y, - start_x, start_y - ); - - pl_endpath_r(lp); - } + cairo_arc (cr, centre_x, centre_y, radius, 0, 2 * M_PI); + cairo_stroke (cr); } /* Draw a single slice of the pie */ static void -draw_segment(plPlotter *lp, +draw_segment(cairo_t *cr, double x0, double y0, double radius, double start_angle, double segment_angle, const struct chart_colour *colour) { - const double start_x = x0 - radius * sin(start_angle); - const double start_y = y0 + radius * cos(start_angle); - - pl_savestate_r(lp); - - pl_savestate_r(lp); - pl_color_r(lp, colour->red * 257, colour->green * 257, colour->blue * 257); - - pl_pentype_r(lp,1); - pl_filltype_r(lp,1); - - fill_segment(lp, x0, y0, radius, start_angle, segment_angle); - pl_restorestate_r(lp); - - /* Draw line dividing segments */ - pl_pentype_r(lp, 1); - pl_fline_r(lp, x0, y0, start_x, start_y); - - - pl_restorestate_r(lp); + cairo_move_to (cr, x0, y0); + cairo_arc (cr, x0, y0, radius, start_angle, start_angle + segment_angle); + cairo_line_to (cr, x0, y0); + cairo_save (cr); + cairo_set_source_rgb (cr, + colour->red / 255.0, + colour->green / 255.0, + colour->blue / 255.0); + cairo_fill_preserve (cr); + cairo_restore (cr); + cairo_stroke (cr); } static void diff --git a/src/output/charts/plot-chart.c b/src/output/charts/plot-chart.c index 9d298cd2..8d499866 100644 --- a/src/output/charts/plot-chart.c +++ b/src/output/charts/plot-chart.c @@ -18,13 +18,17 @@ #include -#include -#include -#include -#include -#include #include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include #include #include @@ -48,77 +52,176 @@ const struct chart_colour data_colour[N_CHART_COLOURS] = { 255, 192, 203 }, /* pink */ }; +void +chart_draw_marker (cairo_t *cr, double x, double y, enum marker_type marker, + double size) +{ + cairo_save (cr); + cairo_translate (cr, x, y); + cairo_scale (cr, size / 2.0, size / 2.0); + cairo_set_line_width (cr, cairo_get_line_width (cr) / (size / 2.0)); + switch (marker) + { + case MARKER_CIRCLE: + cairo_arc (cr, 0, 0, 1.0, 0, 2 * M_PI); + cairo_stroke (cr); + break; + + case MARKER_ASTERISK: + cairo_move_to (cr, 0, -1.0); /* | */ + cairo_line_to (cr, 0, 1.0); + cairo_move_to (cr, -M_SQRT1_2, -M_SQRT1_2); /* / */ + cairo_line_to (cr, M_SQRT1_2, M_SQRT1_2); + cairo_move_to (cr, -M_SQRT1_2, M_SQRT1_2); /* \ */ + cairo_line_to (cr, M_SQRT1_2, -M_SQRT1_2); + cairo_stroke (cr); + break; + + case MARKER_SQUARE: + cairo_rectangle (cr, -1.0, -1.0, 2.0, 2.0); + cairo_stroke (cr); + break; + } + cairo_restore (cr); +} +void +chart_label (cairo_t *cr, int horz_justify, int vert_justify, + const char *string) +{ + PangoFontDescription *desc; + PangoLayout *layout; + double x, y; + + desc = pango_font_description_from_string ("sans serif"); + if (desc == NULL) + { + cairo_new_path (cr); + return; + } + pango_font_description_set_absolute_size (desc, 15 * PANGO_SCALE); + + cairo_save (cr); + cairo_get_current_point (cr, &x, &y); + cairo_translate (cr, x, y); + cairo_move_to (cr, 0, 0); + cairo_scale (cr, 1.0, -1.0); + + layout = pango_cairo_create_layout (cr); + pango_layout_set_font_description (layout, desc); + pango_layout_set_text (layout, string, -1); + if (horz_justify != 'l') + { + int width_pango; + double width; + + pango_layout_get_size (layout, &width_pango, NULL); + width = (double) width_pango / PANGO_SCALE; + if (horz_justify == 'r') + cairo_rel_move_to (cr, -width, 0); + else + cairo_rel_move_to (cr, -width / 2.0, 0); + } + if (vert_justify != 't') + { + int height_pango; + double height; + + pango_layout_get_size (layout, NULL, &height_pango); + height = (double) height_pango / PANGO_SCALE; + if (vert_justify == 'b' || vert_justify == 'x') + cairo_rel_move_to (cr, 0, -height); + else if (vert_justify == 'c') + cairo_rel_move_to (cr, 0, -height / 2.0); + } + pango_cairo_show_layout (cr, layout); + g_object_unref (layout); + + cairo_restore (cr); + + cairo_new_path (cr); + + pango_font_description_free (desc); +} /* Draw a tick mark at position If label is non zero, then print it at the tick mark */ void -draw_tick (plPlotter *lp, const struct chart_geometry *geom, +draw_tick (cairo_t *cr, const struct chart_geometry *geom, enum tick_orientation orientation, double position, const char *label, ...) { const int tickSize = 10; + double x, y; - pl_savestate_r (lp); - pl_move_r (lp, geom->data_left, geom->data_bottom); + cairo_move_to (cr, geom->data_left, geom->data_bottom); if (orientation == TICK_ABSCISSA) - pl_flinerel_r (lp, position, 0, position, -tickSize); + { + cairo_rel_move_to (cr, position, 0); + cairo_rel_line_to (cr, 0, -tickSize); + } else if (orientation == TICK_ORDINATE) - pl_flinerel_r (lp, 0, position, -tickSize, position); + { + cairo_rel_move_to (cr, 0, position); + cairo_rel_line_to (cr, -tickSize, 0); + } else NOT_REACHED (); + cairo_get_current_point (cr, &x, &y); + + cairo_stroke (cr); if (label != NULL) { va_list ap; char *s; + cairo_move_to (cr, x, y); + va_start (ap, label); s = xvasprintf (label, ap); if (orientation == TICK_ABSCISSA) - pl_alabel_r (lp, 'c', 't', s); + chart_label (cr, 'c', 't', s); else if (orientation == TICK_ORDINATE) { if (fabs (position) < DBL_EPSILON) - pl_moverel_r (lp, 0, 10); - pl_alabel_r (lp, 'r', 'c', s); + cairo_rel_move_to (cr, 0, 10); + chart_label (cr, 'r', 'c', s); } free (s); va_end (ap); } - - pl_restorestate_r (lp); } /* Write the title on a chart*/ void -chart_write_title (plPlotter *lp, const struct chart_geometry *geom, +chart_write_title (cairo_t *cr, const struct chart_geometry *geom, const char *title, ...) { va_list ap; char *s; - pl_savestate_r (lp); - pl_ffontsize_r (lp, geom->font_size * 1.5); - pl_move_r (lp, geom->data_left, geom->title_bottom); + cairo_save (cr); + // pl_ffontsize_r (cr, geom->font_size * 1.5); /* XXX */ + cairo_move_to (cr, geom->data_left, geom->title_bottom); va_start(ap, title); s = xvasprintf (title, ap); - pl_alabel_r (lp, 0, 0, s); + chart_label (cr, 'l', 'x', s); free (s); va_end (ap); - pl_restorestate_r (lp); + cairo_restore (cr); } /* Set the scale for the abscissa */ void -chart_write_xscale (plPlotter *lp, struct chart_geometry *geom, +chart_write_xscale (cairo_t *cr, struct chart_geometry *geom, double min, double max, int ticks) { double x; @@ -132,14 +235,14 @@ chart_write_xscale (plPlotter *lp, struct chart_geometry *geom, fabs(geom->x_max - geom->x_min); for (x = geom->x_min; x <= geom->x_max; x += tick_interval) - draw_tick (lp, geom, TICK_ABSCISSA, + draw_tick (cr, geom, TICK_ABSCISSA, (x - geom->x_min) * geom->abscissa_scale, "%g", x); } /* Set the scale for the ordinate */ void -chart_write_yscale (plPlotter *lp, struct chart_geometry *geom, +chart_write_yscale (cairo_t *cr, struct chart_geometry *geom, double smin, double smax, int ticks) { double y; @@ -155,29 +258,28 @@ chart_write_yscale (plPlotter *lp, struct chart_geometry *geom, / fabs (geom->y_max - geom->y_min)); for (y = geom->y_min; y <= geom->y_max; y += tick_interval) - draw_tick (lp, geom, TICK_ORDINATE, + draw_tick (cr, geom, TICK_ORDINATE, (y - geom->y_min) * geom->ordinate_scale, "%g", y); } /* Write the abscissa label */ void -chart_write_xlabel (plPlotter *lp, const struct chart_geometry *geom, +chart_write_xlabel (cairo_t *cr, const struct chart_geometry *geom, const char *label) { - pl_savestate_r (lp); - pl_move_r (lp, geom->data_left, geom->abscissa_top); - pl_alabel_r (lp, 0, 't', label); - pl_restorestate_r (lp); + cairo_move_to (cr, geom->data_left, geom->abscissa_top); + chart_label (cr, 'l', 't', label); } /* Write the ordinate label */ void -chart_write_ylabel (plPlotter *lp, const struct chart_geometry *geom, +chart_write_ylabel (cairo_t *cr, const struct chart_geometry *geom, const char *label) { - pl_savestate_r (lp); - pl_move_r (lp, geom->data_bottom, geom->ordinate_right); - pl_textangle_r (lp, 90); - pl_alabel_r (lp, 0, 0, label); - pl_restorestate_r(lp); + cairo_save (cr); + cairo_translate (cr, -geom->data_bottom, -geom->ordinate_right); + cairo_move_to (cr, 0, 0); + cairo_rotate (cr, M_PI / 2.0); + chart_label (cr, 'l', 'x', label); + cairo_restore (cr); } diff --git a/src/output/charts/plot-chart.h b/src/output/charts/plot-chart.h index e425987b..1a44212c 100644 --- a/src/output/charts/plot-chart.h +++ b/src/output/charts/plot-chart.h @@ -17,6 +17,7 @@ #ifndef PLOT_CHART_H #define PLOT_CHART_H +#include #include #include #include @@ -47,10 +48,23 @@ enum tick_orientation struct chart_geometry; +enum marker_type + { + MARKER_CIRCLE, /* Hollow circle. */ + MARKER_ASTERISK, /* Asterisk (*). */ + MARKER_SQUARE /* Hollow square. */ + }; + +void chart_draw_marker (cairo_t *, double x, double y, enum marker_type, + double size); + +void chart_label (cairo_t *, int horz_justify, int vert_justify, + const char *); + /* Draw a tick mark at position If label is non zero, then print it at the tick mark */ -void draw_tick(plPlotter *, const struct chart_geometry *, +void draw_tick(cairo_t *, const struct chart_geometry *, enum tick_orientation orientation, double position, const char *label, ...) @@ -58,25 +72,25 @@ void draw_tick(plPlotter *, const struct chart_geometry *, /* Write the title on a chart*/ -void chart_write_title(plPlotter *, const struct chart_geometry *, +void chart_write_title(cairo_t *, const struct chart_geometry *, const char *title, ...) PRINTF_FORMAT (3, 4); /* Set the scale for the abscissa */ -void chart_write_xscale(plPlotter *, struct chart_geometry *, +void chart_write_xscale(cairo_t *, struct chart_geometry *, double min, double max, int ticks); /* Set the scale for the ordinate */ -void chart_write_yscale(plPlotter *, struct chart_geometry *, +void chart_write_yscale(cairo_t *, struct chart_geometry *, double smin, double smax, int ticks); -void chart_write_xlabel(plPlotter *, const struct chart_geometry *, +void chart_write_xlabel(cairo_t *, const struct chart_geometry *, const char *label) ; /* Write the ordinate label */ -void chart_write_ylabel(plPlotter *, const struct chart_geometry *, +void chart_write_ylabel(cairo_t *, const struct chart_geometry *, const char *label); #endif diff --git a/src/output/charts/plot-hist.c b/src/output/charts/plot-hist.c index 97656751..b7586a18 100644 --- a/src/output/charts/plot-hist.c +++ b/src/output/charts/plot-hist.c @@ -40,17 +40,17 @@ static const struct chart_class histogram_chart_class; /* Write the legend of the chart */ static void -histogram_write_legend (plPlotter *lp, const struct chart_geometry *geom, +histogram_write_legend (cairo_t *cr, const struct chart_geometry *geom, double n, double mean, double stddev) { double y = geom->data_bottom; - pl_savestate_r (lp); + cairo_save (cr); if (n != SYSMIS) { char *buf = xasprintf ("N = %.2f", n); - pl_move_r (lp, geom->legend_left, y); - pl_alabel_r (lp, 0, 'b', buf); + cairo_move_to (cr, geom->legend_left, y); + chart_label (cr, 'l', 'b', buf); y += geom->font_size * 1.5; free (buf); } @@ -58,8 +58,8 @@ histogram_write_legend (plPlotter *lp, const struct chart_geometry *geom, if (mean != SYSMIS) { char *buf = xasprintf ("Mean = %.1f", mean); - pl_fmove_r (lp,geom->legend_left, y); - pl_alabel_r (lp, 0, 'b', buf); + cairo_move_to (cr,geom->legend_left, y); + chart_label (cr, 'l', 'b', buf); y += geom->font_size * 1.5; free (buf); } @@ -67,16 +67,16 @@ histogram_write_legend (plPlotter *lp, const struct chart_geometry *geom, if (stddev != SYSMIS) { char *buf = xasprintf ("Std. Dev = %.2f", stddev); - pl_fmove_r (lp, geom->legend_left, y); - pl_alabel_r (lp, 0, 'b', buf); + cairo_move_to (cr, geom->legend_left, y); + chart_label (cr, 'l', 'b', buf); free (buf); } - pl_restorestate_r (lp); + cairo_restore (cr); } static void -hist_draw_bar (plPlotter *lp, const struct chart_geometry *geom, +hist_draw_bar (cairo_t *cr, const struct chart_geometry *geom, const gsl_histogram *h, int bar) { double upper; @@ -94,22 +94,18 @@ hist_draw_bar (plPlotter *lp, const struct chart_geometry *geom, height = gsl_histogram_get (h, bar) * (geom->data_top - geom->data_bottom) / gsl_histogram_max_val (h); - pl_savestate_r (lp); - pl_move_r (lp,geom->data_left, geom->data_bottom); - pl_fillcolor_r (lp, - geom->fill_colour.red * 257, - geom->fill_colour.green * 257, - geom->fill_colour.blue * 257); - pl_filltype_r (lp,1); - - - pl_fboxrel_r (lp, - x_pos, 0, - x_pos + width, height); - - pl_restorestate_r (lp); - - draw_tick (lp, geom, TICK_ABSCISSA, + cairo_rectangle (cr, geom->data_left + x_pos, geom->data_bottom, + width, height); + cairo_save (cr); + cairo_set_source_rgb (cr, + geom->fill_colour.red / 255.0, + geom->fill_colour.green / 255.0, + geom->fill_colour.blue / 255.0); + cairo_fill_preserve (cr); + cairo_restore (cr); + cairo_stroke (cr); + + draw_tick (cr, geom, TICK_ABSCISSA, x_pos + width / 2.0, "%g", (upper + lower) / 2.0); } @@ -147,17 +143,17 @@ histogram_chart_create (const struct histogram *hist, const char *label, } static void -histogram_chart_draw (const struct chart *chart, plPlotter *lp, +histogram_chart_draw (const struct chart *chart, cairo_t *cr, struct chart_geometry *geom) { struct histogram_chart *h = (struct histogram_chart *) chart; int i; int bins; - chart_write_title (lp, geom, _("HISTOGRAM")); + chart_write_title (cr, geom, _("HISTOGRAM")); - chart_write_ylabel (lp, geom, _("Frequency")); - chart_write_xlabel (lp, geom, h->label); + chart_write_ylabel (cr, geom, _("Frequency")); + chart_write_xlabel (cr, geom, h->label); if (h->gsl_hist == NULL) { @@ -167,12 +163,12 @@ histogram_chart_draw (const struct chart *chart, plPlotter *lp, bins = gsl_histogram_bins (h->gsl_hist); - chart_write_yscale (lp, geom, 0, gsl_histogram_max_val (h->gsl_hist), 5); + chart_write_yscale (cr, geom, 0, gsl_histogram_max_val (h->gsl_hist), 5); for (i = 0; i < bins; i++) - hist_draw_bar (lp, geom, h->gsl_hist, i); + hist_draw_bar (cr, geom, h->gsl_hist, i); - histogram_write_legend (lp, geom, h->n, h->mean, h->stddev); + histogram_write_legend (cr, geom, h->n, h->mean, h->stddev); if (h->show_normal && h->n != SYSMIS && h->mean != SYSMIS && h->stddev != SYSMIS) @@ -192,7 +188,7 @@ histogram_chart_draw (const struct chart *chart, plPlotter *lp, ordinate_scale = (geom->data_top - geom->data_bottom) / gsl_histogram_max_val (h->gsl_hist); - pl_move_r (lp, geom->data_left, geom->data_bottom); + cairo_move_to (cr, geom->data_left, geom->data_bottom); for (d = geom->data_left; d <= geom->data_right; d += (geom->data_right - geom->data_left) / 100.0) @@ -201,10 +197,10 @@ histogram_chart_draw (const struct chart *chart, plPlotter *lp, const double y = h->n * range * gsl_ran_gaussian_pdf (x - h->mean, h->stddev); - pl_fcont_r (lp, d, geom->data_bottom + y * ordinate_scale); + cairo_line_to (cr, d, geom->data_bottom + y * ordinate_scale); } - pl_endpath_r (lp); + cairo_stroke (cr); } } diff --git a/src/output/html.c b/src/output/html.c index d943f192..3a8be8eb 100644 --- a/src/output/html.c +++ b/src/output/html.c @@ -138,14 +138,6 @@ html_close_driver (struct outp_driver *this) return ok; } -/* Link the image contained in FILE_NAME to the - HTML stream in FILE. */ -static void -link_image (FILE *file, char *file_name) -{ - fprintf (file, "", file_name); - } - /* Generic option types. */ enum { @@ -208,22 +200,10 @@ static void html_output_chart (struct outp_driver *this, const struct chart *chart) { struct html_driver_ext *x = this->ext; - struct chart_geometry geom; char *file_name; - plPlotter *lp; - - /* Draw chart in separate file. */ - if (!chart_create_file ("png", x->chart_file_name, x->chart_cnt, - NULL, &file_name, &lp)) - return; - x->chart_cnt++; - chart_geometry_init (lp, &geom, 1000.0, 1000.0); - chart_draw (chart, lp, &geom); - chart_geometry_free (lp); - pl_deletepl_r (lp); - - link_image (x->file, file_name); + file_name = chart_draw_png (chart, x->chart_file_name, x->chart_cnt++); + fprintf (x->file, "", file_name); free (file_name); } diff --git a/src/output/postscript.c b/src/output/postscript.c index 743aea4e..394ebbb2 100644 --- a/src/output/postscript.c +++ b/src/output/postscript.c @@ -603,80 +603,6 @@ ps_close_page (struct outp_driver *this) x->file); } -static void -ps_output_chart (struct outp_driver *this, const struct chart *chart) -{ - struct ps_driver_ext *x = this->ext; - struct chart_geometry geom; - plPlotterParams *params; - int x_origin, y_origin; - char buf[BUFSIZ]; - char *page_size; - plPlotter *lp; - FILE *file; - int size; - - /* Create temporary file for chart. */ - file = tmpfile (); - if (file == NULL) - { - error (0, errno, _("failed to create temporary file")); - return; - } - - /* Create plotter for chart. */ - size = this->width < this->length ? this->width : this->length; - x_origin = x->left_margin + (size - this->width) / 2; - y_origin = x->bottom_margin + (size - this->length) / 2; - page_size = xasprintf ("a,xsize=%.3f,ysize=%.3f,xorigin=%.3f,yorigin=%.3f", - (double) size / PSUS, (double) size / PSUS, - (double) x_origin / PSUS, (double) y_origin / PSUS); - - params = pl_newplparams (); - pl_setplparam (params, "PAGESIZE", page_size); - free (page_size); - lp = pl_newpl_r ("ps", 0, file, stderr, params); - pl_deleteplparams (params); - - if (lp == NULL) - { - fclose (file); - return; - } - - /* Draw chart and free plotter. */ - chart_geometry_init (lp, &geom, 1000.0, 1000.0); - chart_draw (chart, lp, &geom); - chart_geometry_free (lp); - pl_deletepl_r (lp); - - /* Write prologue for chart. */ - outp_eject_page (this); - fprintf (x->file, - "/sp save def\n" - "%d %d translate 1000 dup scale\n" - "userdict begin\n" - "/showpage { } def\n" - "0 setgray 0 setlinecap 1 setlinewidth\n" - "0 setlinejoin 10 setmiterlimit [ ] 0 setdash newpath clear\n" - "%%%%BeginDocument: %d\n", - -x->left_margin, -x->bottom_margin, - x->doc_num++); - - /* Copy chart into output file. */ - rewind (file); - while (fwrite (buf, 1, fread (buf, 1, sizeof buf, file), x->file)) - continue; - fclose (file); - - /* Write epilogue for chart. */ - fputs ("%%EndDocument\n" - "end\n" - "sp restore\n", - x->file); - outp_close_page (this); -} - static void ps_submit (struct outp_driver *this UNUSED, struct som_entity *s) { @@ -1448,7 +1374,7 @@ const struct outp_class postscript_class = ps_close_page, NULL, - ps_output_chart, + NULL, /* output_chart */ ps_submit, diff --git a/src/ui/automake.mk b/src/ui/automake.mk index c21b681d..743d0b6d 100644 --- a/src/ui/automake.mk +++ b/src/ui/automake.mk @@ -1,7 +1,7 @@ ## Process this file with automake to produce Makefile.in -*- makefile -*- include $(top_srcdir)/src/ui/terminal/automake.mk -if WITHGUI +if HAVE_GUI include $(top_srcdir)/src/ui/gui/automake.mk endif diff --git a/src/ui/gui/automake.mk b/src/ui/gui/automake.mk index 110ef43f..838f0d69 100644 --- a/src/ui/gui/automake.mk +++ b/src/ui/gui/automake.mk @@ -29,6 +29,7 @@ src_ui_gui_psppire_LDADD = \ src/libpspp.la \ src/libpspp-core.la \ $(GTK_LIBS) \ + $(CAIRO_LIBS) \ @LIBINTL@ src_ui_gui_psppiredir = $(pkgdatadir) -- 2.30.2