forked from AravisProject/aravis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharvgcconverternode.c
182 lines (151 loc) · 5.34 KB
/
arvgcconverternode.c
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
/* Aravis - Digital camera library
*
* Copyright © 2009-2022 Emmanuel Pacaud
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
* Author: Emmanuel Pacaud <[email protected]>
*/
/**
* SECTION: arvgcconverternode
* @short_description: Converter node class
*/
#include <arvgcconverterprivate.h>
#include <arvgcconverternode.h>
#include <arvgcfeaturenodeprivate.h>
#include <arvevaluator.h>
#include <arvgcfloat.h>
struct _ArvGcConverterNode {
ArvGcConverter converter;
};
struct _ArvGcConverterNodeClass {
ArvGcConverterClass parent_class;
};
static const char *
arv_gc_converter_node_get_node_name (ArvDomNode *node)
{
return "Converter";
}
ArvGcNode *
arv_gc_converter_node_new (void)
{
return g_object_new (ARV_TYPE_GC_CONVERTER_NODE, NULL);
}
static void
arv_gc_converter_node_init (ArvGcConverterNode *gc_converter_node)
{
}
static void
arv_gc_converter_node_class_init (ArvGcConverterNodeClass *this_class)
{
ArvDomNodeClass *dom_node_class = ARV_DOM_NODE_CLASS (this_class);
dom_node_class->get_node_name = arv_gc_converter_node_get_node_name;
}
static double
arv_gc_converter_get_float_value (ArvGcFloat *gc_float, GError **error)
{
return arv_gc_converter_convert_to_double (ARV_GC_CONVERTER (gc_float), ARV_GC_CONVERTER_NODE_TYPE_VALUE, error);
}
static double
arv_gc_converter_get_float_min (ArvGcFloat *gc_float, GError **error)
{
GError *local_error = NULL;
double a, b;
/* TODO: we should use the Slope node here, instead of using MIN (min, max) */
a = arv_gc_converter_convert_to_double (ARV_GC_CONVERTER (gc_float), ARV_GC_CONVERTER_NODE_TYPE_MIN, &local_error);
if (local_error != NULL) {
g_propagate_error (error, local_error);
return -G_MAXDOUBLE;
}
b = arv_gc_converter_convert_to_double (ARV_GC_CONVERTER (gc_float), ARV_GC_CONVERTER_NODE_TYPE_MAX, &local_error);
if (local_error != NULL) {
g_propagate_error (error, local_error);
return -G_MAXDOUBLE;
}
return MIN (a, b);
}
static double
arv_gc_converter_get_float_max (ArvGcFloat *gc_float, GError **error)
{
GError *local_error = NULL;
double a, b;
/* TODO: we should use the Slope node here, instead of using MAX (min, max) */
a = arv_gc_converter_convert_to_double (ARV_GC_CONVERTER (gc_float), ARV_GC_CONVERTER_NODE_TYPE_MIN, &local_error);
if (local_error != NULL) {
g_propagate_error (error, local_error);
return G_MAXDOUBLE;
}
b = arv_gc_converter_convert_to_double (ARV_GC_CONVERTER (gc_float), ARV_GC_CONVERTER_NODE_TYPE_MAX, &local_error);
if (local_error != NULL) {
g_propagate_error (error, local_error);
return G_MAXDOUBLE;
}
return MAX (a, b);
}
static double
_get_inc (ArvGcFloat *gc_float, GError **error)
{
GError *local_error = NULL;
ArvGcIsLinear is_linear;
is_linear = arv_gc_converter_get_is_linear (ARV_GC_CONVERTER (gc_float), &local_error);
if (local_error != NULL) {
g_propagate_error (error, local_error);
return G_MINDOUBLE;
}
if (is_linear == ARV_GC_IS_LINEAR_NO)
return G_MINDOUBLE;
return arv_gc_converter_convert_to_double (ARV_GC_CONVERTER (gc_float), ARV_GC_CONVERTER_NODE_TYPE_INC, &local_error);
}
static ArvGcRepresentation
arv_gc_converter_get_float_representation (ArvGcFloat *gc_float)
{
return arv_gc_converter_get_representation (ARV_GC_CONVERTER (gc_float));
}
static const char *
arv_gc_converter_get_float_unit (ArvGcFloat *gc_float)
{
return arv_gc_converter_get_unit (ARV_GC_CONVERTER (gc_float));
}
static ArvGcDisplayNotation
arv_gc_converter_get_float_display_notation (ArvGcFloat *gc_float)
{
return arv_gc_converter_get_display_notation (ARV_GC_CONVERTER (gc_float));
}
static gint64
arv_gc_converter_get_float_display_precision (ArvGcFloat *gc_float)
{
return arv_gc_converter_get_display_precision (ARV_GC_CONVERTER (gc_float));
}
static void
arv_gc_converter_set_float_value (ArvGcFloat *gc_float, double value, GError **error)
{
arv_gc_converter_convert_from_double (ARV_GC_CONVERTER (gc_float), value, error);
}
static void
arv_gc_converter_node_float_interface_init (ArvGcFloatInterface *interface)
{
interface->get_value = arv_gc_converter_get_float_value;
interface->get_min = arv_gc_converter_get_float_min;
interface->get_max = arv_gc_converter_get_float_max;
interface->get_inc = _get_inc;
interface->set_value = arv_gc_converter_set_float_value;
interface->get_representation = arv_gc_converter_get_float_representation;
interface->get_unit = arv_gc_converter_get_float_unit;
interface->get_display_notation = arv_gc_converter_get_float_display_notation;
interface->get_display_precision = arv_gc_converter_get_float_display_precision;
}
G_DEFINE_TYPE_WITH_CODE (ArvGcConverterNode, arv_gc_converter_node, ARV_TYPE_GC_CONVERTER,
G_IMPLEMENT_INTERFACE (ARV_TYPE_GC_FLOAT, arv_gc_converter_node_float_interface_init))