scatterplot: fixed compiler warnings
[pspp] / src / output / charts / scatterplot.h
1 /* PSPP - a program for statistical analysis.
2    Copyright (C) 2014, 2015 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_CHARTS_SCATTERPLOT_H
18 #define OUTPUT_CHARTS_SCATTERPLOT_H 1
19
20 #include "output/chart-item.h"
21
22 /* Indices for the scatterplot_proto members */
23 enum
24   {
25     SP_IDX_X,    /* x value */
26     SP_IDX_Y,    /* y value */
27     SP_IDX_BY,   /* graph category for xy plot */
28   };
29
30 /* A  scatterplot. */
31 struct scatterplot_chart
32   {
33     struct chart_item chart_item;
34     struct casereader *data;
35     struct variable *byvar;
36     char *xlabel;
37     char *ylabel;
38
39     double y_min, y_max;
40     double x_min, x_max;
41     /* If the number of distinct values of byvar */
42     /* exceeds a certain limit, the warning flag */
43     /* is activated after the chart is drawn     */
44     bool *byvar_overflow;
45   };
46
47 struct scatterplot_chart *
48 scatterplot_create (struct casereader *,
49                     const char *xlabel,
50                     const char *ylabel,
51                     const struct variable *,
52                     bool *,
53                     const char *label,
54                     double xmin, double xmax, double ymin, double ymax);
55 \f
56 /* This boilerplate for scatterplot_chart, a subclass of chart_item, was
57    autogenerated by mk-class-boilerplate. */
58
59 #include <assert.h>
60 #include "libpspp/cast.h"
61
62 extern const struct chart_item_class scatterplot_chart_class;
63
64 /* Returns true if SUPER is a scatterplot_chart, otherwise false. */
65 static inline bool
66 is_scatterplot_chart (const struct chart_item *super)
67 {
68   return super->class == &scatterplot_chart_class;
69 }
70
71 /* Returns SUPER converted to scatterplot_chart.  SUPER must be a scatterplot_chart, as
72    reported by is_scatterplot_chart. */
73 static inline struct scatterplot_chart *
74 to_scatterplot_chart (const struct chart_item *super)
75 {
76   assert (is_scatterplot_chart (super));
77   return UP_CAST (super, struct scatterplot_chart, chart_item);
78 }
79
80 /* Returns INSTANCE converted to chart_item. */
81 static inline struct chart_item *
82 scatterplot_chart_super (const struct scatterplot_chart *instance)
83 {
84   return CONST_CAST (struct chart_item *, &instance->chart_item);
85 }
86
87 /* Increments INSTANCE's reference count and returns INSTANCE. */
88 static inline struct scatterplot_chart *
89 scatterplot_chart_ref (const struct scatterplot_chart *instance)
90 {
91   return to_scatterplot_chart (chart_item_ref (&instance->chart_item));
92 }
93
94 /* Decrements INSTANCE's reference count, then destroys INSTANCE if
95    the reference count is now zero. */
96 static inline void
97 scatterplot_chart_unref (struct scatterplot_chart *instance)
98 {
99   chart_item_unref (&instance->chart_item);
100 }
101
102 /* Returns true if INSTANCE's reference count is greater than 1,
103    false otherwise. */
104 static inline bool
105 scatterplot_chart_is_shared (const struct scatterplot_chart *instance)
106 {
107   return chart_item_is_shared (&instance->chart_item);
108 }
109
110 static inline void
111 scatterplot_chart_submit (struct scatterplot_chart *instance)
112 {
113   chart_item_submit (&instance->chart_item);
114 }
115 \f
116 #endif /* output/charts/scatterplot.h */