comparison Sources/Autogenerated/sdk_OrthancPluginImage.impl.h @ 1:fef9a239df5c

adding auto-generated files
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 26 Mar 2020 18:50:10 +0100
parents
children b2bbb516056e
comparison
equal deleted inserted replaced
0:7ed502b17b8f 1:fef9a239df5c
1 /**
2 * Python plugin for Orthanc
3 * Copyright (C) 2017-2020 Osimis S.A., Belgium
4 *
5 * This program is free software: you can redistribute it and/or
6 * modify it under the terms of the GNU Affero General Public License
7 * as published by the Free Software Foundation, either version 3 of
8 * the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Affero General Public License for more details.
14 *
15 * You should have received a copy of the GNU Affero General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 **/
18
19
20 typedef struct
21 {
22 PyObject_HEAD
23
24 /* Type-specific fields go here. */
25 OrthancPluginImage* object_;
26 bool borrowed_;
27 } sdk_OrthancPluginImage_Object;
28
29
30
31 // Forward declaration of the methods
32 static PyObject *sdk_OrthancPluginImage_OrthancPluginGetImagePixelFormat(
33 sdk_OrthancPluginImage_Object* self, PyObject *args);
34 static PyObject *sdk_OrthancPluginImage_OrthancPluginGetImageWidth(
35 sdk_OrthancPluginImage_Object* self, PyObject *args);
36 static PyObject *sdk_OrthancPluginImage_OrthancPluginGetImageHeight(
37 sdk_OrthancPluginImage_Object* self, PyObject *args);
38 static PyObject *sdk_OrthancPluginImage_OrthancPluginGetImagePitch(
39 sdk_OrthancPluginImage_Object* self, PyObject *args);
40 static PyObject *sdk_OrthancPluginImage_OrthancPluginConvertPixelFormat(
41 sdk_OrthancPluginImage_Object* self, PyObject *args);
42 static PyObject *sdk_OrthancPluginImage_OrthancPluginDrawText(
43 sdk_OrthancPluginImage_Object* self, PyObject *args);
44
45
46 static PyMethodDef sdk_OrthancPluginImage_Methods[] = {
47 { "GetImagePixelFormat",
48 (PyCFunction) sdk_OrthancPluginImage_OrthancPluginGetImagePixelFormat, METH_VARARGS,
49 "Generated from C function OrthancPluginGetImagePixelFormat()" },
50 { "GetImageWidth",
51 (PyCFunction) sdk_OrthancPluginImage_OrthancPluginGetImageWidth, METH_VARARGS,
52 "Generated from C function OrthancPluginGetImageWidth()" },
53 { "GetImageHeight",
54 (PyCFunction) sdk_OrthancPluginImage_OrthancPluginGetImageHeight, METH_VARARGS,
55 "Generated from C function OrthancPluginGetImageHeight()" },
56 { "GetImagePitch",
57 (PyCFunction) sdk_OrthancPluginImage_OrthancPluginGetImagePitch, METH_VARARGS,
58 "Generated from C function OrthancPluginGetImagePitch()" },
59 { "ConvertPixelFormat",
60 (PyCFunction) sdk_OrthancPluginImage_OrthancPluginConvertPixelFormat, METH_VARARGS,
61 "Generated from C function OrthancPluginConvertPixelFormat()" },
62 { "DrawText",
63 (PyCFunction) sdk_OrthancPluginImage_OrthancPluginDrawText, METH_VARARGS,
64 "Generated from C function OrthancPluginDrawText()" },
65 { NULL } /* Sentinel */
66 };
67
68
69 static int sdk_OrthancPluginImage_Constructor(
70 sdk_OrthancPluginImage_Object *self, PyObject *args, PyObject *kwds)
71 {
72 OrthancPlugins::LogInfo("Creating Python object of class OrthancPluginImage");
73
74 self->object_ = NULL;
75 self->borrowed_ = false;
76
77 long long object = 0;
78 unsigned char borrowed = false;
79
80 if (PyArg_ParseTuple(args, "Lb", &object, &borrowed))
81 {
82 self->object_ = reinterpret_cast<OrthancPluginImage*>(static_cast<intptr_t>(object));
83 self->borrowed_ = borrowed;
84 return 0;
85 }
86 else
87 {
88 PyErr_SetString(PyExc_ValueError, "Expected a pair (pointer, borrowed) in the constructor");
89 return -1;
90 }
91 }
92
93
94 /**
95 * Static global structure => the fields that are beyond the last
96 * initialized field are set to zero.
97 * https://stackoverflow.com/a/11152199/881731
98 **/
99 static PyTypeObject sdk_OrthancPluginImage_Type = {
100 PyVarObject_HEAD_INIT(NULL, 0)
101 "orthanc.Image", /* tp_name */
102 sizeof(sdk_OrthancPluginImage_Object), /* tp_basicsize */
103 };
104
105
106 static void sdk_OrthancPluginImage_Destructor(PyObject *self)
107 {
108 OrthancPlugins::LogInfo("Destroying Python object of class OrthancPluginImage");
109
110 sdk_OrthancPluginImage_Object& tmp = *((sdk_OrthancPluginImage_Object*) self);
111
112 if (tmp.object_ != NULL &&
113 !tmp.borrowed_)
114 {
115 OrthancPluginFreeImage(OrthancPlugins::GetGlobalContext(), tmp.object_);
116 tmp.object_ = NULL;
117 }
118
119 Py_TYPE(self)->tp_free((PyObject *)self);
120 }
121
122
123 // Actual implementation of the methods
124 static PyObject *sdk_OrthancPluginImage_OrthancPluginGetImagePixelFormat(
125 sdk_OrthancPluginImage_Object* self, PyObject *args)
126 {
127 OrthancPlugins::LogInfo("Calling method OrthancPluginGetImagePixelFormat() on object of class OrthancPluginImage");
128
129 if (self->object_ == NULL)
130 {
131 // TODO: RAISE
132 //PythonLock::RaiseException(module, OrthancPluginErrorCode_NullPointer);
133 PyErr_SetString(PyExc_ValueError, "Invalid object");
134 return NULL;
135 }
136
137
138 OrthancPluginPixelFormat value = OrthancPluginGetImagePixelFormat(OrthancPlugins::GetGlobalContext(), self->object_);
139
140 return PyLong_FromLong(value);
141 }
142
143 static PyObject *sdk_OrthancPluginImage_OrthancPluginGetImageWidth(
144 sdk_OrthancPluginImage_Object* self, PyObject *args)
145 {
146 OrthancPlugins::LogInfo("Calling method OrthancPluginGetImageWidth() on object of class OrthancPluginImage");
147
148 if (self->object_ == NULL)
149 {
150 // TODO: RAISE
151 //PythonLock::RaiseException(module, OrthancPluginErrorCode_NullPointer);
152 PyErr_SetString(PyExc_ValueError, "Invalid object");
153 return NULL;
154 }
155
156
157 long value = OrthancPluginGetImageWidth(OrthancPlugins::GetGlobalContext(), self->object_);
158
159 return PyLong_FromLong(value);
160 }
161
162 static PyObject *sdk_OrthancPluginImage_OrthancPluginGetImageHeight(
163 sdk_OrthancPluginImage_Object* self, PyObject *args)
164 {
165 OrthancPlugins::LogInfo("Calling method OrthancPluginGetImageHeight() on object of class OrthancPluginImage");
166
167 if (self->object_ == NULL)
168 {
169 // TODO: RAISE
170 //PythonLock::RaiseException(module, OrthancPluginErrorCode_NullPointer);
171 PyErr_SetString(PyExc_ValueError, "Invalid object");
172 return NULL;
173 }
174
175
176 long value = OrthancPluginGetImageHeight(OrthancPlugins::GetGlobalContext(), self->object_);
177
178 return PyLong_FromLong(value);
179 }
180
181 static PyObject *sdk_OrthancPluginImage_OrthancPluginGetImagePitch(
182 sdk_OrthancPluginImage_Object* self, PyObject *args)
183 {
184 OrthancPlugins::LogInfo("Calling method OrthancPluginGetImagePitch() on object of class OrthancPluginImage");
185
186 if (self->object_ == NULL)
187 {
188 // TODO: RAISE
189 //PythonLock::RaiseException(module, OrthancPluginErrorCode_NullPointer);
190 PyErr_SetString(PyExc_ValueError, "Invalid object");
191 return NULL;
192 }
193
194
195 long value = OrthancPluginGetImagePitch(OrthancPlugins::GetGlobalContext(), self->object_);
196
197 return PyLong_FromLong(value);
198 }
199
200 static PyObject *sdk_OrthancPluginImage_OrthancPluginConvertPixelFormat(
201 sdk_OrthancPluginImage_Object* self, PyObject *args)
202 {
203 OrthancPlugins::LogInfo("Calling method OrthancPluginConvertPixelFormat() on object of class OrthancPluginImage");
204
205 if (self->object_ == NULL)
206 {
207 // TODO: RAISE
208 //PythonLock::RaiseException(module, OrthancPluginErrorCode_NullPointer);
209 PyErr_SetString(PyExc_ValueError, "Invalid object");
210 return NULL;
211 }
212
213 long int arg0 = 0;
214
215 if (!PyArg_ParseTuple(args, "l", &arg0))
216 {
217 // TODO => RAISE : https://stackoverflow.com/questions/60832317
218 PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (1 arguments expected)");
219 return NULL;
220 }
221 // This is the case of a constructor
222 OrthancPluginImage* obj = OrthancPluginConvertPixelFormat(OrthancPlugins::GetGlobalContext(), self->object_, static_cast<OrthancPluginPixelFormat>(arg0));
223
224 if (obj == NULL)
225 {
226 // TODO => RAISE : https://stackoverflow.com/questions/60832317
227 //PythonLock::RaiseException(module, OrthancPluginErrorCode_InternalError);
228 PyErr_SetString(PyExc_ValueError, "Internal error");
229 return NULL;
230 }
231 else
232 {
233 PyObject *argList = Py_BuildValue("Lb", obj, false /* not borrowed */);
234 PyObject *python = PyObject_CallObject((PyObject *) &sdk_OrthancPluginImage_Type, argList);
235 Py_DECREF(argList);
236 return python;
237 }
238 }
239
240 static PyObject *sdk_OrthancPluginImage_OrthancPluginDrawText(
241 sdk_OrthancPluginImage_Object* self, PyObject *args)
242 {
243 OrthancPlugins::LogInfo("Calling method OrthancPluginDrawText() on object of class OrthancPluginImage");
244
245 if (self->object_ == NULL)
246 {
247 // TODO: RAISE
248 //PythonLock::RaiseException(module, OrthancPluginErrorCode_NullPointer);
249 PyErr_SetString(PyExc_ValueError, "Invalid object");
250 return NULL;
251 }
252
253 unsigned long arg0 = 0;
254 const char* arg1 = NULL;
255 long int arg2 = 0;
256 long int arg3 = 0;
257 unsigned char arg4 = 0;
258 unsigned char arg5 = 0;
259 unsigned char arg6 = 0;
260
261 if (!PyArg_ParseTuple(args, "ksllbbb", &arg0, &arg1, &arg2, &arg3, &arg4, &arg5, &arg6))
262 {
263 // TODO => RAISE : https://stackoverflow.com/questions/60832317
264 PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (7 arguments expected)");
265 return NULL;
266 }
267 OrthancPluginErrorCode code = OrthancPluginDrawText(OrthancPlugins::GetGlobalContext(), self->object_, arg0, arg1, arg2, arg3, arg4, arg5, arg6);
268
269
270 if (code == OrthancPluginErrorCode_Success)
271 {
272 Py_INCREF(Py_None);
273 return Py_None;
274 }
275 else
276 {
277 // TODO => RAISE : https://stackoverflow.com/questions/60832317
278 //PythonLock::RaiseException(module, code);
279 PyErr_SetString(PyExc_ValueError, "Internal error");
280 return NULL;
281 }
282 }
283
284
285
286 static void RegisterOrthancPluginImageClass(PyObject* module)
287 {
288 sdk_OrthancPluginImage_Type.tp_new = PyType_GenericNew;
289 sdk_OrthancPluginImage_Type.tp_flags = Py_TPFLAGS_DEFAULT;
290 sdk_OrthancPluginImage_Type.tp_doc = "Generated from Orthanc C class: OrthancPluginImage";
291 sdk_OrthancPluginImage_Type.tp_methods = sdk_OrthancPluginImage_Methods;
292 sdk_OrthancPluginImage_Type.tp_init = (initproc) sdk_OrthancPluginImage_Constructor;
293
294 /**
295 * "tp_dealloc is called when the reference count of the object goes
296 * down to zero. This is where you destroy the object and its
297 * members. It should then free the memory occupied by the object by
298 * calling tp_free."
299 * https://stackoverflow.com/a/24863227/881731
300 **/
301 sdk_OrthancPluginImage_Type.tp_dealloc = sdk_OrthancPluginImage_Destructor;
302
303 if (PyType_Ready(&sdk_OrthancPluginImage_Type) < 0)
304 {
305 OrthancPlugins::LogError("Cannot register Python class: OrthancPluginImage");
306 ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError);
307 }
308
309 Py_INCREF(&sdk_OrthancPluginImage_Type);
310 if (PyModule_AddObject(module, "Image", (PyObject *)&sdk_OrthancPluginImage_Type) < 0)
311 {
312 OrthancPlugins::LogError("Cannot register Python class: OrthancPluginImage");
313 Py_DECREF(&sdk_OrthancPluginImage_Type);
314 ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError);
315 }
316 }
317
318
319 PyObject* GetOrthancPluginImageType()
320 {
321 return (PyObject*) &sdk_OrthancPluginImage_Type;
322 }