output: Use Cairo and Pango to draw charts, instead of libplot.
[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 <cairo/cairo.h>
21 #include <stdbool.h>
22 #include <stdint.h>
23 #include <output/chart.h>
24
25 struct chart_colour
26   {
27     uint8_t red;
28     uint8_t green;
29     uint8_t blue;
30   };
31
32 /* The geometry of a chart. */
33 struct chart_geometry
34   {
35     int data_top   ;
36     int data_right ;
37     int data_bottom;
38     int data_left  ;
39
40     int abscissa_top;
41
42     int ordinate_right ;
43
44     int title_bottom ;
45
46     int legend_left ;
47     int legend_right ;
48
49     /* Default font size for the plot. */
50     int font_size;
51
52     struct chart_colour fill_colour;
53
54     /* Stuff Particular to Cartesians (and Boxplots ) */
55     double ordinate_scale;
56     double abscissa_scale;
57     double x_min;
58     double x_max;
59     double y_min;
60     double y_max;
61   };
62
63 struct chart_class
64   {
65     void (*draw) (const struct chart *, cairo_t *, struct chart_geometry *);
66     void (*destroy) (struct chart *);
67   };
68
69 struct chart
70   {
71     const struct chart_class *class;
72     int ref_cnt;
73   };
74
75 void chart_init (struct chart *, const struct chart_class *);
76
77 void chart_geometry_init (cairo_t *, struct chart_geometry *,
78                           double width, double length);
79 void chart_geometry_free (cairo_t *);
80
81 void chart_draw (const struct chart *, cairo_t *, struct chart_geometry *);
82 char *chart_draw_png (const struct chart *, const char *file_name_template,
83                       int number);
84
85 #endif /* output/chart-provider.h */