File: kplot.h

package info (click to toggle)
siril 1.4.0~rc2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 47,352 kB
  • sloc: ansic: 174,082; cpp: 28,254; python: 7,891; makefile: 974; xml: 777; sh: 271
file content (253 lines) | stat: -rw-r--r-- 7,009 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
/*	$Id: kplot.h,v 1.40 2015/03/24 13:05:05 kristaps Exp $ */
/*
 * Copyright (c) 2014, 2015 Kristaps Dzonsons <kristaps@bsd.lv>
 *
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */
#ifndef KPLOT_H
#define KPLOT_H

struct 	kpair {
	double	 x;
	double	 y;
};

enum	kplottype {
	KPLOT_UNDEFINED = -1,
	KPLOT_POINTS,
	KPLOT_MARKS,
	KPLOT_HYPHENS,
	KPLOT_LINES,
	KPLOT_LINESPOINTS,
	KPLOT_LINESMARKS,
	KPLOT_LINESHYPHENS
};

enum	ksmthtype {
	KSMOOTH_NONE,
	KSMOOTH_MOVAVG,
	KSMOOTH_CDF,
	KSMOOTH_PMF
};

enum	kplotstype {
	KPLOTS_SINGLE,
	KPLOTS_YERRORLINE,
	KPLOTS_YERRORBAR
};

enum	kplotctype {
	KPLOTCTYPE_DEFAULT = 0,
	KPLOTCTYPE_PALETTE,
	KPLOTCTYPE_PATTERN,
	KPLOTCTYPE_RGBA
};

struct	kplotccfg {
	enum kplotctype	 type;
	size_t		 palette;
	cairo_pattern_t	*pattern;
	double		 rgba[4];
};

struct 	kplotfont {
	cairo_font_slant_t   slant;
	cairo_font_weight_t  weight;
	const char	    *family;
	double		     sz;
	struct kplotccfg     clr;
};

struct	kplotticln {
	double		  sz;
	double		  len;
#define	KPLOT_DASH_MAX	  8
	double	  	  dashes[KPLOT_DASH_MAX];
	size_t		  dashesz;
	double	 	  dashoff;
	struct kplotccfg  clr;
};

struct	kplotpoint {
	double		  sz;
	double		  radius;
	double	  	  dashes[KPLOT_DASH_MAX];
	size_t		  dashesz;
	double	 	  dashoff;
	struct kplotccfg  clr;
};

struct	kplotline {
	double		  sz;
	double	  	  dashes[KPLOT_DASH_MAX];
	size_t		  dashesz;
	double	 	  dashoff;
	cairo_line_join_t join;
	struct kplotccfg  clr;
};

struct	ksmthcfg {
	size_t		  movsamples;
};

struct	kdatacfg {
	struct kplotline  line;
	struct kplotpoint point;
};

struct	kplotcfg {
	struct kplotccfg *clrs;
	size_t		  clrsz; 
	double		  marginsz; 
#define	MARGIN_LEFT	  0x01
#define	MARGIN_RIGHT	  0x02
#define	MARGIN_TOP	  0x04
#define	MARGIN_BOTTOM	  0x08
#define	MARGIN_ALL	  0xf
	unsigned int	  margin;
	struct kplotline  borderline;
	double		  bordersz;
#define	BORDER_LEFT	  0x01
#define	BORDER_RIGHT	  0x02
#define	BORDER_TOP	  0x04
#define	BORDER_BOTTOM	  0x08
#define	BORDER_ALL	  0xf
	unsigned int	  border;
	size_t		  xtics;
	size_t		  ytics;
	struct kplotticln ticline;
#define	TIC_LEFT_IN	  0x01
#define	TIC_LEFT_OUT	  0x02
#define	TIC_RIGHT_IN	  0x04
#define	TIC_RIGHT_OUT	  0x08
#define	TIC_TOP_IN	  0x10
#define	TIC_TOP_OUT	  0x20
#define	TIC_BOTTOM_IN	  0x40
#define	TIC_BOTTOM_OUT	  0x80
	unsigned int	  tic;
	double		  xticlabelrot;
	void		(*xticlabelfmt)(double, char *, size_t);
	void		(*yticlabelfmt)(double, char *, size_t);
	char	 	*xticlabelfmtstr;
	char	 	*yticlabelfmtstr;
	double		  yticlabelpad;
	double		  xticlabelpad;
	struct kplotfont  ticlabelfont;
#define	TICLABEL_LEFT	  0x01
#define	TICLABEL_RIGHT	  0x02
#define	TICLABEL_TOP	  0x04
#define	TICLABEL_BOTTOM	  0x08
	unsigned int	  ticlabel;
#define	GRID_X 		  0x01
#define GRID_Y 		  0x02
#define GRID_ALL 	  0x03
	unsigned int 	  grid;
	struct kplotline  gridline;
	double		  xaxislabelpad;
	double		  yaxislabelpad;
	const char	 *xaxislabel;
	const char	 *x2axislabel;
	const char	 *yaxislabel;
	const char	 *y2axislabel;
	struct kplotfont  axislabelfont;
	double		  xaxislabelrot;
	double		  yaxislabelrot;
#define	EXTREMA_XMIN	  0x01
#define	EXTREMA_XMAX	  0x02
#define	EXTREMA_YMIN	  0x04
#define	EXTREMA_YMAX	  0x08
	unsigned int	  extrema;
	double		  extrema_xmin;
	double		  extrema_xmax;
	double		  extrema_ymin;
	double		  extrema_ymax;
	unsigned int 		xaxisrevert;
	unsigned int		yaxisrevert;
};

struct 	kdata;
struct	kplot;
struct 	kplotctx;

__BEGIN_DECLS

void	kdata_destroy(struct kdata *);
int		 kdata_get(const struct kdata *, size_t, struct kpair *);

int		 kdata_array_add(struct kdata *, size_t, double);
struct kdata	*kdata_array_alloc(const struct kpair *, size_t);
int		 kdata_array_fill(struct kdata *, void *,
			void (*)(size_t, struct kpair *, void *));
int		 kdata_array_fill_ydoubles(struct kdata *, const double *);
int		 kdata_array_fill_ysizes(struct kdata *, const size_t *);
int		 kdata_array_set(struct kdata *, size_t, double, double);

int		 kdata_bucket_add(struct kdata *, size_t, double);
struct kdata	*kdata_bucket_alloc(size_t, size_t);
int		 kdata_bucket_set(struct kdata *, size_t, double, double);

struct kdata	*kdata_buffer_alloc(size_t);
int		 kdata_buffer_copy(struct kdata *, const struct kdata *);

int		 kdata_hist_add(struct kdata *, double, double);
struct kdata	*kdata_hist_alloc(double, double, size_t);
int		 kdata_hist_set(struct kdata *, double, double);

struct kdata	*kdata_mean_alloc(struct kdata *);
int		 kdata_mean_attach(struct kdata *, struct kdata *);

struct kdata	*kdata_stddev_alloc(struct kdata *);
int		 kdata_stddev_attach(struct kdata *, struct kdata *);

struct kdata	*kdata_vector_alloc(size_t);
int		 kdata_vector_append(struct kdata *, double, double);
int		 kdata_vector_set(struct kdata *, size_t, double, double);

double		 kdata_pmfmean(const struct kdata *);
double		 kdata_pmfvar(const struct kdata *);
double		 kdata_pmfstddev(const struct kdata *);

ssize_t		 kdata_xmax(const struct kdata *, struct kpair *);
double		 kdata_xmean(const struct kdata *);
ssize_t		 kdata_xmin(const struct kdata *, struct kpair *);

double		 kdata_xstddev(const struct kdata *);
ssize_t		 kdata_ymax(const struct kdata *, struct kpair *);
double		 kdata_ymean(const struct kdata *);
double		 kdata_ystddev(const struct kdata *);
ssize_t		 kdata_ymin(const struct kdata *, struct kpair *);

void		 kdatacfg_defaults(struct kdatacfg *);
void		 kplotcfg_defaults(struct kplotcfg *);
int		 kplotcfg_default_palette(struct kplotccfg **, size_t *);
void		 ksmthcfg_defaults(struct ksmthcfg *);

struct kplot	*kplot_alloc(const struct kplotcfg *);
int		 kplot_detach(struct kplot *, const struct kdata *);
int		 kplot_attach_data(struct kplot *, struct kdata *, 
			enum kplottype, const struct kdatacfg *);
int		 kplot_attach_smooth(struct kplot *, struct kdata *, 
			enum kplottype, const struct kdatacfg *,
			enum ksmthtype, const struct ksmthcfg *);
int		 kplot_attach_datas(struct kplot *, size_t, 
			struct kdata **, const enum kplottype *, 
			const struct kdatacfg *const *, enum kplotstype);
void	kplot_draw(struct kplot *, double, double, cairo_t *, struct kplotctx *);
void	kplot_free(struct kplot *);
int		kplot_get_datacfg(struct kplot *, size_t,
			struct kdatacfg **, size_t *);
struct kplotcfg	*kplot_get_plotcfg(struct kplot *);

__END_DECLS

#endif