aboutsummaryrefslogtreecommitdiff
path: root/src/control.h
blob: 6d318e9c0857e6b0e2f232eb1631099f7896680d (plain)
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
/*
 * control.h
 *
 * Common control structure
 *
 * (c) 2007 Thomas White <taw27@cam.ac.uk>
 *
 *  dtr - Diffraction Tomography Reconstruction
 *
 */
 
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#ifndef CONTROL_H
#define CONTROL_H

#include <gtk/gtk.h>
#include <inttypes.h>
#include <GL/gl.h>

typedef enum ift_enum {
	INPUT_NONE,
	INPUT_QDRP,
	INPUT_MRC,
	INPUT_CACHE,
	INPUT_DRX
} InputFileType;

typedef enum {
	FORMULATION_CLEN,
	FORMULATION_PIXELSIZE
} FormulationMode;

typedef enum {
	PEAKSEARCH_NONE,
	PEAKSEARCH_THRESHOLD,
	PEAKSEARCH_ADAPTIVE_THRESHOLD,
	PEAKSEARCH_LSQ,
	PEAKSEARCH_ZAEFFERER,
	PEAKSEARCH_STAT,
	PEAKSEARCH_CACHED
} PeakSearchMode;

typedef struct imagerecord_struct {

	uint16_t	*image;
	double		tilt;		/* Degrees.  Defines where the pattern lies in reciprocal space */
	double		omega;		/* Degrees.  Defines where the pattern lies in reciprocal space */
	double		slop;		/* Degrees.  Defines where the pattern lies "on the negative" */
	
	FormulationMode fmode;
	double		pixel_size;
	double		camera_len;
	double		lambda;
	double		resolution;
	
	int		width;
	int		height;
	int		x_centre;
	int		y_centre;

} ImageRecord;

typedef struct {
	ImageRecord	*parent;
	int		x;
	int		y;
	double		intensity;
} ImageReflection;

typedef struct cctx_struct {
	
	/* Modes */
	InputFileType			inputfiletype;
	PeakSearchMode 			psmode;
	unsigned int			prealign;
	unsigned int			have_centres;
	
	/* Input filename */
	char 				*filename;
	char				*cache_filename;
	
	/* Basic parameters, stored here solely so they can be copied
	 * into the ImageRecord(s) more easily */
	FormulationMode			fmode;
	double				camera_length;
	double				omega;		/* Degrees */
	double				resolution;
	double				lambda;
	double				pixel_size;
	double				x_centre;
	double				y_centre;
	
	/* QDRP Parser flags */
	unsigned int			started;
	unsigned int			camera_length_set;
	unsigned int			omega_set;
	unsigned int			resolution_set;
	unsigned int			lambda_set;
	
	/* The input images */
	int				n_images;
	ImageRecord			*images;
	
	/* Output */
	struct reflectionlist_struct	*reflectionlist;
	struct dw_struct		*dw;
	struct basis_struct		*cell;			/* Current estimate of the reciprocal unit cell */
	struct reflectionlist_struct	*cell_lattice;		/* Reflections calculated from 'cell' */
	
	/* GTK bits */
	GtkWidget			*combo_peaksearch;
	GtkWidget			*checkbox_prealign;
	GtkWidget			*checkbox_savecache;
	GtkWidget			*checkbox_dirax;
	GtkWidget			*cache_file_selector;
	
	/* IPR stuff */
	int				ipr_cur_image;
	struct imagedisplay_struct	*ipr_id;
	struct reflectionlist_struct	*ipr_lat;
	struct basis_struct		*ipr_basis;
	
	/* DirAx low-level stuff */
	GIOChannel			*dirax;
	int				dirax_pty;
	pid_t				dirax_pid;
	char				*dirax_rbuffer;
	int				dirax_rbufpos;
	int				dirax_rbuflen;
	
	/* DirAx high-level stuff */
	int				dirax_step;
	int				dirax_read_cell;
	
	/* Reprojection stuff */
	int				reproject_cur_image;
	struct imagedisplay_struct	*reproject_id;
	
} ControlContext;

extern int control_add_image(ControlContext *ctx, uint16_t *image, int width, int height, double tilt);
extern ControlContext *control_ctx_new(void);
extern double control_min_tilt(ControlContext *ctx);
extern double control_max_tilt(ControlContext *ctx);
extern ImageRecord *control_image_nearest_tilt(ControlContext *ctx, double tilt);

#endif	/* CONTROL_H */