aboutsummaryrefslogtreecommitdiff
path: root/src/control.c
blob: ac3de0b622fe82eb68c8dfffdbd406d053994279 (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
/*
 * control.c
 *
 * Common control structure
 *
 * (c) 2007 Thomas White <taw27@cam.ac.uk>
 *
 *  dtr - Diffraction Tomography Reconstruction
 *
 */

#include <inttypes.h>
#include <stdlib.h>

#include "control.h"

int control_add_image(ControlContext *ctx, uint16_t *image, int width, int height, double tilt) {

	ctx->images[ctx->n_images].tilt = tilt;
	ctx->images[ctx->n_images].omega = ctx->omega;
	ctx->images[ctx->n_images].image = image;
	ctx->images[ctx->n_images].width = width;
	ctx->images[ctx->n_images].height = height;
	ctx->images[ctx->n_images].lambda = ctx->lambda;
	ctx->images[ctx->n_images].fmode = ctx->fmode;
	ctx->images[ctx->n_images].x_centre = ctx->x_centre;
	ctx->images[ctx->n_images].y_centre = ctx->y_centre;
	
	if ( ctx->fmode == FORMULATION_PIXELSIZE ) {
		ctx->images[ctx->n_images].pixel_size = ctx->pixel_size;
		ctx->images[ctx->n_images].camera_len = 0;
		ctx->images[ctx->n_images].resolution = 0;
	} else if ( ctx->fmode == FORMULATION_CLEN ) {
		ctx->images[ctx->n_images].pixel_size = 0;
		ctx->images[ctx->n_images].camera_len = ctx->camera_length;
		ctx->images[ctx->n_images].resolution = ctx->resolution;
	}
	
	ctx->n_images++;
	
	return ctx->n_images - 1;

}

ControlContext *control_ctx_new() {

	ControlContext *ctx;
	
	ctx = malloc(sizeof(ControlContext));

	ctx->x_centre = 0;
	ctx->y_centre = 0;
	ctx->have_centres = 0;
	
	return ctx;

}