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-2015 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
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
);
58 #define SURFACE_PARAMETERS(_x, _y, _z) \
60 HKL_PARAMETER_DEFAULTS, .name = "x", ._value = (_x), \
61 .description = "the x coordinate of the surface $\\vec{n}$", \
62 .range = { .min=-1, .max=1 }, \
65 HKL_PARAMETER_DEFAULTS, .name = "y", ._value = (_y), \
66 .description = "the y coordinate of the surface $\\vec{n}$", \
67 .range = { .min=-1, .max=1 }, \
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
[] = {
76 SURFACE_PARAMETERS(0, 1, 0),
79 #define P99_PROTECT(...) __VA_ARGS__
81 #define HKL_MODE_INFO_incidence_DEFAULTS(_axes) \
82 HKL_MODE_INFO_RO_WITH_PARAMS("incidence", (_axes), surface_parameters)
84 #define HKL_MODE_INFO_emergence_DEFAULTS(_axes) \
85 HKL_MODE_INFO_RO_WITH_PARAMS("emergence", (_axes), surface_parameters)
87 #define REGISTER_READONLY(_engine, _func, _axes) \
88 static HklEngine* _func(HklEngineList *engines) \
90 HklEngine *self = hkl_engine_ ## _engine ## _new(engines); \
91 static const char *axes[] = _axes; \
92 static const HklModeInfo info = { \
93 HKL_MODE_INFO_ ## _engine ## _DEFAULTS(axes), \
95 HklMode *default_mode = hkl_mode_ ## _engine ## _new(&info); \
96 hkl_engine_add_mode(self, default_mode); \
97 hkl_engine_mode_set(self, default_mode); \
101 #define REGISTER_READONLY_INCIDENCE(_func, _axes) REGISTER_READONLY(incidence, _func, P99_PROTECT(_axes))
102 #define REGISTER_READONLY_EMERGENCE(_func, _axes) REGISTER_READONLY(emergence, _func, P99_PROTECT(_axes))