itom  4.1.0
pythonShape.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 PYTHONSHAPE_H
24 #define PYTHONSHAPE_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 <qpoint.h>
43 #include "../common/retVal.h"
44 
45 namespace ito
46 {
47 
48 class Shape; //forward declaration
49 
51 {
52 public:
53  typedef struct
54  {
55  PyObject_HEAD
56  Shape *shape;
57  }
58  PyShape;
59 
60  #define PyShape_Check(op) PyObject_TypeCheck(op, &ito::PythonShape::PyShapeType)
61 
62  //-------------------------------------------------------------------------------------------------
63  // constructor, deconstructor, alloc, dellaoc
64  //-------------------------------------------------------------------------------------------------
65  static void PyShape_dealloc(PyShape *self);
66  static PyObject* PyShape_new(PyTypeObject *type, PyObject *args, PyObject *kwds);
67  static int PyShape_init(PyShape *self, PyObject *args, PyObject *kwds);
68 
69  static PyObject* createPyShape(const Shape &shape);
70 
71  //-------------------------------------------------------------------------------------------------
72  // general members
73  //-------------------------------------------------------------------------------------------------
74  static PyObject* PyShape_repr(PyShape *self);
75  static PyObject* PyShape_rotateDeg(PyShape *self, PyObject *args);
76  static PyObject* PyShape_rotateRad(PyShape *self, PyObject *args);
77  static PyObject* PyShape_translate(PyShape *self, PyObject *args);
78  static PyObject* PyShape_region(PyShape *self);
79  static PyObject* PyShape_normalized(PyShape *self);
80  static PyObject* PyShape_contour(PyShape *self, PyObject *args, PyObject *kwds);
81  static PyObject* PyShape_contains(PyShape *self, PyObject *args, PyObject *kwds);
82  static PyObject* PyShape_copy(PyShape *self);
83 
84  //-------------------------------------------------------------------------------------------------
85  // static members
86  //-------------------------------------------------------------------------------------------------
87  static PyObject* PyShape_StaticPoint(PyObject *self, PyObject *args, PyObject *kwds);
88  static PyObject* PyShape_StaticLine(PyObject *self, PyObject *args, PyObject *kwds);
89  static PyObject* PyShape_StaticCircle(PyObject *self, PyObject *args, PyObject *kwds);
90  static PyObject* PyShape_StaticEllipse(PyObject *self, PyObject *args, PyObject *kwds);
91  static PyObject* PyShape_StaticSquare(PyObject *self, PyObject *args, PyObject *kwds);
92  static PyObject* PyShape_StaticRectangle(PyObject *self, PyObject *args, PyObject *kwds);
93  static PyObject* PyShape_StaticPolygon(PyObject *self, PyObject *args, PyObject *kwds);
94 
95  //-------------------------------------------------------------------------------------------------
96  // pickling
97  //-------------------------------------------------------------------------------------------------
98  static PyObject* PyShape_reduce(PyShape *self, PyObject *args);
99  static PyObject* PyShape_setState(PyShape *self, PyObject *args);
100 
101  //-------------------------------------------------------------------------------------------------
102  // getter / setter
103  //-------------------------------------------------------------------------------------------------
104  static PyObject* PyShape_getType(PyShape *self, void *closure);
105 
106  static PyObject* PyShape_getValid(PyShape *self, void *closure);
107 
108  static PyObject* PyShape_getFlags(PyShape *self, void *closure);
109  static int PyShape_setFlags(PyShape *self, PyObject *value, void *closure);
110 
111  static PyObject* PyShape_getIndex(PyShape *self, void *closure);
112  static int PyShape_setIndex(PyShape *self, PyObject *value, void *closure);
113 
114  static PyObject* PyShape_getName(PyShape *self, void *closure);
115  static int PyShape_setName(PyShape *self, PyObject *value, void *closure);
116 
117  static PyObject* PyShape_getColor(PyShape *self, void *closure);
118  static int PyShape_setColor(PyShape *self, PyObject *value, void *closure);
119 
120  static PyObject* PyShape_getTransform(PyShape *self, void *closure);
121  static int PyShape_setTransform(PyShape *self, PyObject *value, void *closure);
122 
123  static PyObject* PyShape_getArea(PyShape *self, void *closure);
124 
125  static PyObject* PyShape_getBasePoints(PyShape *self, void *closure);
126 
127  static PyObject* PyShape_getPoint1(PyShape *self, void *closure);
128  static int PyShape_setPoint1(PyShape *self, PyObject *value, void *closure);
129 
130  static PyObject* PyShape_getPoint2(PyShape *self, void *closure);
131  static int PyShape_setPoint2(PyShape *self, PyObject *value, void *closure);
132 
133  static PyObject* PyShape_getCenter(PyShape *self, void *closure);
134  static int PyShape_setCenter(PyShape *self, PyObject *value, void *closure);
135 
136  static PyObject* PyShape_getAngleDeg(PyShape *self, void *closure);
137  static int PyShape_setAngleDeg(PyShape *self, PyObject *value, void *closure);
138 
139  static PyObject* PyShape_getAngleRad(PyShape *self, void *closure);
140  static int PyShape_setAngleRad(PyShape *self, PyObject *value, void *closure);
141 
142  static PyObject* PyShape_getRadius(PyShape *self, void *closure);
143  static int PyShape_setRadius(PyShape *self, PyObject *value, void *closure);
144 
145  static PyObject* PyShape_getWidth(PyShape *self, void *closure);
146  static int PyShape_setWidth(PyShape *self, PyObject *value, void *closure);
147 
148  static PyObject* PyShape_getHeight(PyShape *self, void *closure);
149  static int PyShape_setHeight(PyShape *self, PyObject *value, void *closure);
150 
151  //-------------------------------------------------------------------------------------------------
152  // type structures
153  //-------------------------------------------------------------------------------------------------
154  //static PyMemberDef PyShape_members[];
155  static PyMethodDef PyShape_methods[];
156  static PyGetSetDef PyShape_getseters[];
157  static PyTypeObject PyShapeType;
158  static PyModuleDef PyShapeModule;
159 
160  static void PyShape_addTpDict(PyObject *tp_dict);
161 
162 private:
163  static QPointF PyObject2PointF(PyObject *value, ito::RetVal &retval, const char* paramName);
164  static PyObject* PointF2PyObject(const QPointF &point);
165 
166 };
167 
168 }; //end namespace ito
169 
170 
171 #endif
Class for managing status values (like errors or warning)
Definition: retVal.h:54
Definition: pythonShape.h:53
Definition: pythonShape.h:50
Definition: apiFunctionsGraph.cpp:39
Definition: shape.h:52