LIST: Remove WEIGHT subcommand.
[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     /* Legend. */
47     int legend_left ;
48     int legend_right ;
49     const char **dataset;
50     int n_datasets;
51
52     /* Default font size for the plot. */
53     double font_size;
54
55     struct chart_colour fill_colour;
56
57     /* Stuff Particular to Cartesians (and Boxplots ) */
58     double ordinate_scale;
59     double abscissa_scale;
60     double x_min;
61     double x_max;
62     double y_min;
63     double y_max;
64     bool in_path;
65   };
66
67 struct chart_class
68   {
69     void (*draw) (const struct chart *, cairo_t *, struct chart_geometry *);
70     void (*destroy) (struct chart *);
71   };
72
73 struct chart
74   {
75     const struct chart_class *class;
76     int ref_cnt;
77   };
78
79 void chart_init (struct chart *, const struct chart_class *);
80
81 void chart_geometry_init (cairo_t *, struct chart_geometry *,
82                           double width, double length);
83 void chart_geometry_free (cairo_t *, struct chart_geometry *);
84
85 void chart_draw (const struct chart *, cairo_t *, struct chart_geometry *);
86 char *chart_draw_png (const struct chart *, const char *file_name_template,
87                       int number);
88
89 #endif /* output/chart-provider.h */