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