itom 2.2.1
|
00001 /* ******************************************************************** 00002 itom software 00003 URL: http://www.uni-stuttgart.de/ito 00004 Copyright (C) 2016, Institut fuer Technische Optik (ITO), 00005 Universitaet Stuttgart, Germany 00006 00007 This file is part of itom. 00008 00009 itom is free software; you can redistribute it and/or modify it 00010 under the terms of the GNU Library General Public Licence as published by 00011 the Free Software Foundation; either version 2 of the Licence, or (at 00012 your option) any later version. 00013 00014 itom is distributed in the hope that it will be useful, but 00015 WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library 00017 General Public Licence for more details. 00018 00019 You should have received a copy of the GNU Library General Public License 00020 along with itom. If not, see <http://www.gnu.org/licenses/>. 00021 *********************************************************************** */ 00022 00023 #ifndef PYTHONSHAPE_H 00024 #define PYTHONSHAPE_H 00025 00026 /* includes */ 00027 #ifndef Q_MOC_RUN 00028 #define PY_ARRAY_UNIQUE_SYMBOL itom_ARRAY_API //see numpy help ::array api :: Miscellaneous :: Importing the api (this line must bebefore include global.h) 00029 #define NO_IMPORT_ARRAY 00030 00031 //python 00032 // see http://vtk.org/gitweb?p=VTK.git;a=commitdiff;h=7f3f750596a105d48ea84ebfe1b1c4ca03e0bab3 00033 #if (defined _DEBUG) && (defined WIN32) 00034 #undef _DEBUG 00035 #include "Python.h" 00036 #define _DEBUG 00037 #else 00038 #include "Python.h" 00039 #endif 00040 #endif 00041 00042 #include <qpoint.h> 00043 #include "../common/retVal.h" 00044 00045 namespace ito 00046 { 00047 00048 class Shape; //forward declaration 00049 00050 class PythonShape 00051 { 00052 public: 00053 typedef struct 00054 { 00055 PyObject_HEAD 00056 Shape *shape; 00057 } 00058 PyShape; 00059 00060 #define PyShape_Check(op) PyObject_TypeCheck(op, &ito::PythonShape::PyShapeType) 00061 00062 //------------------------------------------------------------------------------------------------- 00063 // constructor, deconstructor, alloc, dellaoc 00064 //------------------------------------------------------------------------------------------------- 00065 static void PyShape_dealloc(PyShape *self); 00066 static PyObject* PyShape_new(PyTypeObject *type, PyObject *args, PyObject *kwds); 00067 static int PyShape_init(PyShape *self, PyObject *args, PyObject *kwds); 00068 00069 static PyObject* createPyShape(const Shape &shape); 00070 00071 //------------------------------------------------------------------------------------------------- 00072 // general members 00073 //------------------------------------------------------------------------------------------------- 00074 static PyObject* PyShape_repr(PyShape *self); 00075 static PyObject* PyShape_rotateDeg(PyShape *self, PyObject *args); 00076 static PyObject* PyShape_rotateRad(PyShape *self, PyObject *args); 00077 static PyObject* PyShape_translate(PyShape *self, PyObject *args); 00078 static PyObject* PyShape_region(PyShape *self); 00079 static PyObject* PyShape_normalized(PyShape *self); 00080 static PyObject* PyShape_contour(PyShape *self, PyObject *args, PyObject *kwds); 00081 00082 //------------------------------------------------------------------------------------------------- 00083 // pickling 00084 //------------------------------------------------------------------------------------------------- 00085 static PyObject* PyShape_reduce(PyShape *self, PyObject *args); 00086 static PyObject* PyShape_setState(PyShape *self, PyObject *args); 00087 00088 //------------------------------------------------------------------------------------------------- 00089 // getter / setter 00090 //------------------------------------------------------------------------------------------------- 00091 static PyObject* PyShape_getType(PyShape *self, void *closure); 00092 00093 static PyObject* PyShape_getValid(PyShape *self, void *closure); 00094 00095 static PyObject* PyShape_getFlags(PyShape *self, void *closure); 00096 static int PyShape_setFlags(PyShape *self, PyObject *value, void *closure); 00097 00098 static PyObject* PyShape_getIndex(PyShape *self, void *closure); 00099 static int PyShape_setIndex(PyShape *self, PyObject *value, void *closure); 00100 00101 static PyObject* PyShape_getName(PyShape *self, void *closure); 00102 static int PyShape_setName(PyShape *self, PyObject *value, void *closure); 00103 00104 static PyObject* PyShape_getTransform(PyShape *self, void *closure); 00105 static int PyShape_setTransform(PyShape *self, PyObject *value, void *closure); 00106 00107 static PyObject* PyShape_getArea(PyShape *self, void *closure); 00108 00109 static PyObject* PyShape_getBasePoints(PyShape *self, void *closure); 00110 00111 static PyObject* PyShape_getPoint1(PyShape *self, void *closure); 00112 static int PyShape_setPoint1(PyShape *self, PyObject *value, void *closure); 00113 00114 static PyObject* PyShape_getPoint2(PyShape *self, void *closure); 00115 static int PyShape_setPoint2(PyShape *self, PyObject *value, void *closure); 00116 00117 static PyObject* PyShape_getCenter(PyShape *self, void *closure); 00118 static int PyShape_setCenter(PyShape *self, PyObject *value, void *closure); 00119 00120 static PyObject* PyShape_getAngleDeg(PyShape *self, void *closure); 00121 static int PyShape_setAngleDeg(PyShape *self, PyObject *value, void *closure); 00122 00123 static PyObject* PyShape_getAngleRad(PyShape *self, void *closure); 00124 static int PyShape_setAngleRad(PyShape *self, PyObject *value, void *closure); 00125 00126 static PyObject* PyShape_getRadius(PyShape *self, void *closure); 00127 static int PyShape_setRadius(PyShape *self, PyObject *value, void *closure); 00128 00129 static PyObject* PyShape_getWidth(PyShape *self, void *closure); 00130 static int PyShape_setWidth(PyShape *self, PyObject *value, void *closure); 00131 00132 static PyObject* PyShape_getHeight(PyShape *self, void *closure); 00133 static int PyShape_setHeight(PyShape *self, PyObject *value, void *closure); 00134 00135 //------------------------------------------------------------------------------------------------- 00136 // type structures 00137 //------------------------------------------------------------------------------------------------- 00138 //static PyMemberDef PyShape_members[]; 00139 static PyMethodDef PyShape_methods[]; 00140 static PyGetSetDef PyShape_getseters[]; 00141 static PyTypeObject PyShapeType; 00142 static PyModuleDef PyShapeModule; 00143 00144 static void PyShape_addTpDict(PyObject *tp_dict); 00145 00146 private: 00147 static QPointF PyObject2PointF(PyObject *value, ito::RetVal &retval, const char* paramName); 00148 static PyObject* PointF2PyObject(const QPointF &point); 00149 00150 }; 00151 00152 }; //end namespace ito 00153 00154 00155 #endif