output: Refactor implementation of charts.
[pspp-builds.git] / src / output / chart-provider.h
1 /* PSPP - a program for statistical analysis.
2    Copyright (C) 2004, 2009 Free Software Foundation, Inc.
3
4    This program is free software: you can redistribute it and/or modify
5    it under the terms of the GNU General Public License as published by
6    the Free Software Foundation, either version 3 of the License, or
7    (at your option) any later version.
8
9    This program is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12    GNU General Public License for more details.
13
14    You should have received a copy of the GNU General Public License
15    along with this program.  If not, see <http://www.gnu.org/licenses/>. */
16
17 #ifndef OUTPUT_CHART_PROVIDER_H
18 #define OUTPUT_CHART_PROVIDER_H 1
19
20 #include <stdbool.h>
21 #include <output/chart.h>
22
23 struct chart_class
24   {
25     void (*draw) (const struct chart *, plPlotter *);
26     void (*destroy) (struct chart *);
27   };
28
29 struct chart
30   {
31     const struct chart_class *class;
32     int ref_cnt;
33   };
34
35 void chart_init (struct chart *, const struct chart_class *);
36 bool chart_create_file (const char *type, const char *file_name_tmpl,
37                         int number, plPlotterParams *,
38                         char **file_namep, plPlotter **lpp);
39
40 /* The geometry of a chart. */
41 struct chart_geometry
42   {
43     int data_top   ;
44     int data_right ;
45     int data_bottom;
46     int data_left  ;
47
48     int abscissa_top;
49
50     int ordinate_right ;
51
52     int title_bottom ;
53
54     int legend_left ;
55     int legend_right ;
56
57     /* Default font size for the plot (if zero, then use plotter default) */
58     int font_size;
59
60     char fill_colour[10];
61
62     /* Stuff Particular to Cartesians (and Boxplots ) */
63     double ordinate_scale;
64     double abscissa_scale;
65     double x_min;
66     double x_max;
67     double y_min;
68     double y_max;
69   };
70
71 void chart_geometry_init (plPlotter *, struct chart_geometry *);
72 void chart_geometry_free (plPlotter *);
73
74 #endif /* output/chart-provider.h */