File: extern.h

package info (click to toggle)
siril 1.4.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 47,656 kB
  • sloc: ansic: 175,395; cpp: 28,654; python: 8,476; makefile: 974; xml: 879; sh: 280
file content (146 lines) | stat: -rw-r--r-- 4,382 bytes parent folder | download | duplicates (6)
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
/*	$Id: extern.h,v 1.20 2015/02/12 00:19:43 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 EXTERN_H
#define EXTERN_H

struct	kdatahist {
	double		 rmin; /* minimum inclusive */
	double		 rmax; /* maximum non-inclusive */
};

struct	kdatabucket {
	size_t		 rmin; /* minimum inclusive */
	size_t		 rmax; /* maximum non-inclusive */
};

struct	kdatamean {
	size_t		*ns; /* number of bucket modifications */
};

struct	kdatastddev {
	size_t		*ns; /* number of bucket modifications */
	double		*m1s; /* incremental mean */
	double		*m2s; /* incremental variance parameter */
};

struct	kdatavector {
	size_t		 stepsz; /* vector increase slush size */
	size_t		 pairbufsz; /* allocated buffer size */
};

enum	kdatatype {
	KDATA_ARRAY,
	KDATA_BUCKET,
	KDATA_BUFFER,
	KDATA_HIST,
	KDATA_MEAN,
	KDATA_STDDEV,
	KDATA_VECTOR
};

typedef	int (*ksetfunc)(struct kdata *, size_t, double, double);

/*
 * A dependant tacks on to a data source and is notified (by way of
 * "func") whenever the value of a bucket has changed.
 */
struct	kdep {
	struct kdata	 *dep;
	ksetfunc	  func;
};

/*
 * A data source can either be "real" (in the sense of being modified by
 * the calling code) or a "dependant" (in the sense of being updated
 * from another data source).
 */
struct	kdata {
	struct kpair	*pairs; /* data pairs */
	size_t		 pairsz; /* number of pairs */
	size_t		 refs; /* >0 references to data */
	struct kdep	*deps; /* dependants */
	size_t		 depsz; /* number of dependants */
	enum kdatatype	 type;
	union {
		struct kdatahist	hist;
		struct kdatavector	vector;
		struct kdatabucket	bucket;
		struct kdatamean	mean;
		struct kdatastddev	stddev;
	} d;
};

struct	kplotdat {
	struct kdata	**datas; /* referenced data */
	size_t		  datasz; /* number of data sets */
	struct kdatacfg	 *cfgs; /* plot configurations */
	enum kplottype	 *types; /* plot types */
	enum kplotstype	  stype; /* multiplot type */
	enum ksmthtype	  smthtype; /* smoothing type */
	struct ksmthcfg	  smth; /* smooth configuration */
	double		  sum; /* used for KSMOOTH_CDF */
};

struct	kplot {
	struct kplotdat	*datas; /* data sets per plot */
	size_t		 datasz; /* number of data sets */
	struct kplotcfg	 cfg; /* configuration */
};

struct	kplotctx {
	cairo_t		*cr; /* cairo context */
	double		 h; /* height of context */
	double		 w; /* width of context */
	struct kpair	 minv; /* minimum data point values */
	struct kpair	 maxv; /* maximum data point values */
	struct kplotcfg	 cfg;

	/*
	 * When computing the plot context, we need to account for a
	 * margin, labels, and boundary.
	 * To do this, we use these "soft" offset and dimensions.
	 * Once we've accounted for the above, we'll use this to
	 * translate and resize the Cairo context for graphing.
	 */
	struct kpair	 offs;
	struct kpair	 dims;
};

__BEGIN_DECLS

int	 kdata_dep_add(struct kdata *, struct kdata *, ksetfunc);
int	 kdata_dep_run(struct kdata *, size_t);
int	 kdata_set(struct kdata *, size_t, double, double);

void	 kplotctx_border_init(struct kplotctx *);
void	 kplotctx_grid_init(struct kplotctx *);
void	 kplotctx_margin_init(struct kplotctx *);
void	 kplotctx_tic_init(struct kplotctx *);
void	 kplotctx_label_init(struct kplotctx *);

double	 kplotctx_line_fix(const struct kplotctx *, double, double);

void	 kplotctx_font_init(struct kplotctx *, struct kplotfont *);
void	 kplotctx_line_init(struct kplotctx *, struct kplotline *);
void	 kplotctx_point_init(struct kplotctx *, struct kplotpoint *);
void	 kplotctx_ticln_init(struct kplotctx *, struct kplotticln *);

void	 kplotccfg_init_palette(struct kplotccfg *, size_t);

__END_DECLS

#endif