Update all #include directives to the currently preferred style.
[pspp-builds.git] / src / output / cairo-chart.h
1 /* PSPP - a program for statistical analysis.
2    Copyright (C) 2009, 2011 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_CAIRO_CHART_H
18 #define OUTPUT_CAIRO_CHART_H 1
19
20 #include <cairo/cairo.h>
21 #include <stdbool.h>
22 #include <stdint.h>
23 #include "libpspp/compiler.h"
24
25 struct chart_item;
26
27 struct xrchart_colour
28   {
29     uint8_t red;
30     uint8_t green;
31     uint8_t blue;
32   };
33
34 /* The geometry of a chart. */
35 struct xrchart_geometry
36   {
37     int data_top;
38     int data_right;
39     int data_bottom;
40     int data_left;
41
42     int abscissa_top;
43
44     int ordinate_right;
45
46     int title_bottom;
47
48     /* Legend. */
49     int legend_left;
50     int legend_right;
51     char **dataset;
52     int n_datasets;
53
54     /* Default font size for the plot. */
55     double font_size;
56
57     struct xrchart_colour fill_colour;
58
59     /* Stuff particular to cartesians and boxplots. */
60     double ordinate_scale;
61     double abscissa_scale;
62     double x_min;
63     double x_max;
64     double y_min;
65     double y_max;
66     bool in_path;
67   };
68
69 void xrchart_geometry_init (cairo_t *, struct xrchart_geometry *,
70                             double width, double length);
71 void xrchart_geometry_free (cairo_t *, struct xrchart_geometry *);
72
73 #define XRCHART_N_COLOURS 9
74 extern const struct xrchart_colour data_colour[];
75
76 enum tick_orientation
77   {
78     TICK_ABSCISSA=0,
79     TICK_ORDINATE
80   };
81
82 enum xrmarker_type
83   {
84     XRMARKER_CIRCLE,              /* Hollow circle. */
85     XRMARKER_ASTERISK,            /* Asterisk (*). */
86     XRMARKER_SQUARE               /* Hollow square. */
87   };
88
89 void xrchart_draw_marker (cairo_t *, double x, double y, enum xrmarker_type,
90                           double size);
91
92 void xrchart_label (cairo_t *, int horz_justify, int vert_justify,
93                     double font_size, const char *);
94
95 /* Draw a tick mark at position
96    If label is non zero, then print it at the tick mark
97 */
98 void draw_tick (cairo_t *, const struct xrchart_geometry *,
99                 enum tick_orientation orientation, double position,
100                 const char *label, ...)
101   PRINTF_FORMAT (5, 6);
102
103
104 /* Write the title on a chart*/
105 void xrchart_write_title (cairo_t *, const struct xrchart_geometry *,
106                           const char *title, ...)
107   PRINTF_FORMAT (3, 4);
108
109 /* Set the scale for the abscissa */
110 void xrchart_write_xscale (cairo_t *, struct xrchart_geometry *,
111                            double min, double max, int ticks);
112
113
114 /* Set the scale for the ordinate */
115 void xrchart_write_yscale (cairo_t *, struct xrchart_geometry *,
116                            double smin, double smax, int ticks);
117
118 void xrchart_write_xlabel (cairo_t *, const struct xrchart_geometry *,
119                            const char *label) ;
120
121 /* Write the ordinate label */
122 void xrchart_write_ylabel (cairo_t *, const struct xrchart_geometry *,
123                            const char *label);
124
125 void xrchart_write_legend (cairo_t *, const struct xrchart_geometry *);
126
127 enum xrchart_dim
128   {
129     XRCHART_DIM_X,
130     XRCHART_DIM_Y
131   };
132
133 void xrchart_vector_start (cairo_t *, struct xrchart_geometry *,
134                            const char *name);
135 void xrchart_vector_end (cairo_t *, struct xrchart_geometry *);
136 void xrchart_vector (cairo_t *, struct xrchart_geometry *, double x, double y);
137
138 /* Plot a data point */
139 void xrchart_datum (cairo_t *, const struct xrchart_geometry *,
140                     int dataset UNUSED, double x, double y);
141
142 /* Draw a line with slope SLOPE and intercept INTERCEPT.
143    between the points limit1 and limit2.
144    If lim_dim is XRCHART_DIM_Y then the limit{1,2} are on the
145    y axis otherwise the x axis
146 */
147 void xrchart_line (cairo_t *, const struct xrchart_geometry *,
148                    double slope, double intercept,
149                    double limit1, double limit2, enum xrchart_dim lim_dim);
150
151 /* Drawing various kinds of charts. */
152 void xrchart_draw_boxplot (const struct chart_item *, cairo_t *,
153                            struct xrchart_geometry *);
154 void xrchart_draw_roc (const struct chart_item *, cairo_t *,
155                        struct xrchart_geometry *);
156 void xrchart_draw_piechart (const struct chart_item *, cairo_t *,
157                             struct xrchart_geometry *);
158 void xrchart_draw_histogram (const struct chart_item *, cairo_t *,
159                              struct xrchart_geometry *);
160 void xrchart_draw_np_plot (const struct chart_item *, cairo_t *,
161                            struct xrchart_geometry *);
162 void xrchart_draw_scree (const struct chart_item *, cairo_t *,
163                          struct xrchart_geometry *);
164
165 #endif /* output/cairo-chart.h */