upgrading copyright year from 2015 to 2016
[hkl.git] / hkl / hkl-pseudoaxis-common-readonly-private.h
blobe92e25bc3fafe096d2ee442c207dc79b5a96008f
1 /* This file is part of the hkl library.
3 * The hkl library is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
8 * The hkl library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with the hkl library. If not, see <http://www.gnu.org/licenses/>.
16 * Copyright (C) 2003-2016 Synchrotron SOLEIL
17 * L'Orme des Merisiers Saint-Aubin
18 * BP 48 91192 GIF-sur-YVETTE CEDEX
20 * Authors: Picca Frédéric-Emmanuel <picca@synchrotron-soleil.fr>
21 * Maria-Teresa Nunez-Pardo-de-Verra <tnunez@mail.desy.de>
23 #ifndef __HKL_PSEUDOAXIS_COMMON_READONLY_PRIVATE__
24 #define __HKL_PSEUDOAXIS_COMMON_READONLY_PRIVATE__
26 #include "hkl-pseudoaxis-private.h"
28 typedef struct _HklModeIncidence HklModeIncidence;
30 struct _HklModeIncidence
32 HklMode parent;
33 HklParameter *n_x;
34 HklParameter *n_y;
35 HklParameter *n_z;
38 extern HklMode *hkl_mode_incidence_new(const HklModeInfo *info);
40 extern HklEngine *hkl_engine_incidence_new(HklEngineList *engines);
42 static inline double _incidence(const HklVector *v1, const HklVector *v2)
44 return hkl_vector_angle(v1, v2) - M_PI_2;
47 static inline double _emergence(const HklVector *v1, const HklVector *v2)
49 return M_PI_2 - hkl_vector_angle(v1, v2);
52 extern HklMode *hkl_mode_emergence_new(const HklModeInfo *info);
54 extern HklEngine *hkl_engine_emergence_new(HklEngineList *engines);
56 /* mode parameters */
58 #define SURFACE_PARAMETERS(_x, _y, _z) \
59 { \
60 HKL_PARAMETER_DEFAULTS, .name = "x", ._value = (_x), \
61 .description = "the x coordinate of the surface $\\vec{n}$", \
62 .range = { .min=-1, .max=1 }, \
63 }, \
64 { \
65 HKL_PARAMETER_DEFAULTS, .name = "y", ._value = (_y), \
66 .description = "the y coordinate of the surface $\\vec{n}$", \
67 .range = { .min=-1, .max=1 }, \
68 }, \
69 { \
70 HKL_PARAMETER_DEFAULTS, .name = "z", ._value = (_z), \
71 .description = "the z coordinate of the surface $\\vec{n}$", \
72 .range = { .min=-1, .max=1 }, \
75 static const HklParameter surface_parameters_y[] = {
76 SURFACE_PARAMETERS(0, 1, 0),
79 static const HklParameter surface_parameters_z[] = {
80 SURFACE_PARAMETERS(0, 0, 1),
83 #define P99_PROTECT(...) __VA_ARGS__
85 #define HKL_MODE_INFO_incidence_DEFAULTS(_axes, _parameters) \
86 HKL_MODE_INFO_RO_WITH_PARAMS("incidence", (_axes), (_parameters))
88 #define HKL_MODE_INFO_emergence_DEFAULTS(_axes, _parameters) \
89 HKL_MODE_INFO_RO_WITH_PARAMS("emergence", (_axes), (_parameters))
91 #define REGISTER_READONLY(_engine, _func, _axes, _parameters) \
92 static HklEngine* _func(HklEngineList *engines) \
93 { \
94 HklEngine *self = hkl_engine_ ## _engine ## _new(engines); \
95 static const char *axes[] = _axes; \
96 static const HklModeInfo info = { \
97 HKL_MODE_INFO_ ## _engine ## _DEFAULTS(axes, _parameters), \
98 }; \
99 HklMode *default_mode = hkl_mode_ ## _engine ## _new(&info); \
100 hkl_engine_add_mode(self, default_mode); \
101 hkl_engine_mode_set(self, default_mode); \
102 return self; \
105 #define REGISTER_READONLY_INCIDENCE(_func, _axes, _parameters) REGISTER_READONLY(incidence, _func, P99_PROTECT(_axes), _parameters)
106 #define REGISTER_READONLY_EMERGENCE(_func, _axes, _parameters) REGISTER_READONLY(emergence, _func, P99_PROTECT(_axes), _parameters)
108 #endif