itom  3.0.0
pythonShape.h
1 /* ********************************************************************
2  itom software
3  URL: http://www.uni-stuttgart.de/ito
4  Copyright (C) 2016, 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.h"
36  #define _DEBUG
37  #else
38  #include "Python.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 
82  //-------------------------------------------------------------------------------------------------
83  // pickling
84  //-------------------------------------------------------------------------------------------------
85  static PyObject* PyShape_reduce(PyShape *self, PyObject *args);
86  static PyObject* PyShape_setState(PyShape *self, PyObject *args);
87 
88  //-------------------------------------------------------------------------------------------------
89  // getter / setter
90  //-------------------------------------------------------------------------------------------------
91  static PyObject* PyShape_getType(PyShape *self, void *closure);
92 
93  static PyObject* PyShape_getValid(PyShape *self, void *closure);
94 
95  static PyObject* PyShape_getFlags(PyShape *self, void *closure);
96  static int PyShape_setFlags(PyShape *self, PyObject *value, void *closure);
97 
98  static PyObject* PyShape_getIndex(PyShape *self, void *closure);
99  static int PyShape_setIndex(PyShape *self, PyObject *value, void *closure);
100 
101  static PyObject* PyShape_getName(PyShape *self, void *closure);
102  static int PyShape_setName(PyShape *self, PyObject *value, void *closure);
103 
104  static PyObject* PyShape_getTransform(PyShape *self, void *closure);
105  static int PyShape_setTransform(PyShape *self, PyObject *value, void *closure);
106 
107  static PyObject* PyShape_getArea(PyShape *self, void *closure);
108 
109  static PyObject* PyShape_getBasePoints(PyShape *self, void *closure);
110 
111  static PyObject* PyShape_getPoint1(PyShape *self, void *closure);
112  static int PyShape_setPoint1(PyShape *self, PyObject *value, void *closure);
113 
114  static PyObject* PyShape_getPoint2(PyShape *self, void *closure);
115  static int PyShape_setPoint2(PyShape *self, PyObject *value, void *closure);
116 
117  static PyObject* PyShape_getCenter(PyShape *self, void *closure);
118  static int PyShape_setCenter(PyShape *self, PyObject *value, void *closure);
119 
120  static PyObject* PyShape_getAngleDeg(PyShape *self, void *closure);
121  static int PyShape_setAngleDeg(PyShape *self, PyObject *value, void *closure);
122 
123  static PyObject* PyShape_getAngleRad(PyShape *self, void *closure);
124  static int PyShape_setAngleRad(PyShape *self, PyObject *value, void *closure);
125 
126  static PyObject* PyShape_getRadius(PyShape *self, void *closure);
127  static int PyShape_setRadius(PyShape *self, PyObject *value, void *closure);
128 
129  static PyObject* PyShape_getWidth(PyShape *self, void *closure);
130  static int PyShape_setWidth(PyShape *self, PyObject *value, void *closure);
131 
132  static PyObject* PyShape_getHeight(PyShape *self, void *closure);
133  static int PyShape_setHeight(PyShape *self, PyObject *value, void *closure);
134 
135  //-------------------------------------------------------------------------------------------------
136  // type structures
137  //-------------------------------------------------------------------------------------------------
138  //static PyMemberDef PyShape_members[];
139  static PyMethodDef PyShape_methods[];
140  static PyGetSetDef PyShape_getseters[];
141  static PyTypeObject PyShapeType;
142  static PyModuleDef PyShapeModule;
143 
144  static void PyShape_addTpDict(PyObject *tp_dict);
145 
146 private:
147  static QPointF PyObject2PointF(PyObject *value, ito::RetVal &retval, const char* paramName);
148  static PyObject* PointF2PyObject(const QPointF &point);
149 
150 };
151 
152 }; //end namespace ito
153 
154 
155 #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:53