itom  4.1.0
pythonRegion.h
1 /* ********************************************************************
2  itom software
3  URL: http://www.uni-stuttgart.de/ito
4  Copyright (C) 2020, Institut fuer Technische Optik (ITO),
5  Universitaet Stuttgart, Germany
6 
7  This file is part of itom.
8 
9  itom is free software; you can redistribute it and/or modify it
10  under the terms of the GNU Library General Public Licence as published by
11  the Free Software Foundation; either version 2 of the Licence, or (at
12  your option) any later version.
13 
14  itom is distributed in the hope that it will be useful, but
15  WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library
17  General Public Licence for more details.
18 
19  You should have received a copy of the GNU Library General Public License
20  along with itom. If not, see <http://www.gnu.org/licenses/>.
21 *********************************************************************** */
22 
23 #ifndef PYTHONREGION_H
24 #define PYTHONREGION_H
25 
26 /* includes */
27 #ifndef Q_MOC_RUN
28  #define PY_ARRAY_UNIQUE_SYMBOL itom_ARRAY_API //see numpy help ::array api :: Miscellaneous :: Importing the api (this line must bebefore include global.h)
29  #define NO_IMPORT_ARRAY
30 
31  //python
32  // see http://vtk.org/gitweb?p=VTK.git;a=commitdiff;h=7f3f750596a105d48ea84ebfe1b1c4ca03e0bab3
33  #if (defined _DEBUG) && (defined WIN32)
34  #undef _DEBUG
35  #include "python/pythonWrapper.h"
36  #define _DEBUG
37  #else
38  #include "python/pythonWrapper.h"
39  #endif
40 #endif
41 
42 #include <qregion.h>
43 
44 namespace ito
45 {
46 
48 {
49 public:
50  typedef struct
51  {
52  PyObject_HEAD
53  QRegion *r;
54  }
55  PyRegion;
56 
57  #define PyRegion_Check(op) PyObject_TypeCheck(op, &ito::PythonRegion::PyRegionType)
58 
59  //-------------------------------------------------------------------------------------------------
60  // constructor, deconstructor, alloc, dellaoc
61  //-------------------------------------------------------------------------------------------------
62  static void PyRegion_dealloc(PyRegion *self);
63  static PyObject* PyRegion_new(PyTypeObject *type, PyObject *args, PyObject *kwds);
64  static int PyRegion_init(PyRegion *self, PyObject *args, PyObject *kwds);
65 
66  static PyObject* createPyRegion(const QRegion &region);
67 
68  //-------------------------------------------------------------------------------------------------
69  // general members
70  //-------------------------------------------------------------------------------------------------
71  static PyObject* PyRegion_repr(PyRegion *self);
72 
73  static PyObject* PyRegion_contains(PyRegion *self, PyObject *args, PyObject *kwds);
74  static PyObject* PyRegion_intersected(PyRegion *self, PyObject *args, PyObject *kwds);
75  static PyObject* PyRegion_intersects(PyRegion *self, PyObject *args, PyObject *kwds);
76  static PyObject* PyRegion_subtracted(PyRegion *self, PyObject *args, PyObject *kwds);
77  static PyObject* PyRegion_translate(PyRegion *self, PyObject *args, PyObject *kwds);
78  static PyObject* PyRegion_translated(PyRegion *self, PyObject *args, PyObject *kwds);
79  static PyObject* PyRegion_united(PyRegion *self, PyObject *args, PyObject *kwds);
80  static PyObject* PyRegion_xored(PyRegion *self, PyObject *args, PyObject *kwds);
81 
82  static PyObject* PyRegion_createMask(PyRegion *self, PyObject *args, PyObject *kwds);
83 
84  //-------------------------------------------------------------------------------------------------
85  // pickling
86  //-------------------------------------------------------------------------------------------------
87  static PyObject* PyRegion_Reduce(PyRegion *self, PyObject *args);
88  static PyObject* PyRegion_SetState(PyRegion *self, PyObject *args);
89 
90  //-------------------------------------------------------------------------------------------------
91  // number protocol
92  //-------------------------------------------------------------------------------------------------
93  static PyObject* PyRegion_nbAdd(PyRegion* o1, PyRegion* o2);
94  static PyObject* PyRegion_nbSubtract(PyRegion* o1, PyRegion* o2);
95  static PyObject* PyRegion_nbAnd(PyRegion* o1, PyRegion* o2);
96  static PyObject* PyRegion_nbXor(PyRegion* o1, PyRegion* o2);
97  static PyObject* PyRegion_nbOr(PyRegion* o1, PyRegion* o2);
98  static PyObject* PyRegion_nbInplaceAdd(PyRegion* o1, PyRegion* o2);
99  static PyObject* PyRegion_nbInplaceSubtract(PyRegion* o1, PyRegion* o2);
100  static PyObject* PyRegion_nbInplaceAnd(PyRegion* o1, PyRegion* o2);
101  static PyObject* PyRegion_nbInplaceXor(PyRegion* o1, PyRegion* o2);
102  static PyObject* PyRegion_nbInplaceOr(PyRegion* o1, PyRegion* o2);
103 
104  //-------------------------------------------------------------------------------------------------
105  // getter / setter
106  //-------------------------------------------------------------------------------------------------
107  static PyObject* PyRegion_getEmpty(PyRegion *self, void *closure);
108  static PyObject* PyRegion_getRectCount(PyRegion *self, void *closure);
109  static PyObject* PyRegion_getRects(PyRegion *self, void *closure);
110  static PyObject* PyRegion_getBoundingRect(PyRegion *self, void *closure);
111 
112  //-------------------------------------------------------------------------------------------------
113  // type structures
114  //-------------------------------------------------------------------------------------------------
115  //static PyMemberDef PyRegion_members[];
116  static PyMethodDef PyRegion_methods[];
117  static PyGetSetDef PyRegion_getseters[];
118  static PyTypeObject PyRegionType;
119  static PyModuleDef PyRegionModule;
120  static PyNumberMethods PyRegion_numberProtocol;
121 
122  static void PyRegion_addTpDict(PyObject *tp_dict);
123 
124 
125 
126 };
127 
128 }; //end namespace ito
129 
130 
131 #endif
Definition: apiFunctionsGraph.cpp:39
Definition: pythonRegion.h:47
Definition: pythonRegion.h:50