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 PYTHONRGBA 00024 #define PYTHONRGBA 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 //python 00031 // see http://vtk.org/gitweb?p=VTK.git;a=commitdiff;h=7f3f750596a105d48ea84ebfe1b1c4ca03e0bab3 00032 #if (defined _DEBUG) && (defined WIN32) 00033 #undef _DEBUG 00034 #include "Python.h" 00035 #define _DEBUG 00036 #else 00037 #include "Python.h" 00038 #endif 00039 #endif 00040 00041 #include "../../common/typeDefs.h" 00042 #include "../../common/color.h" 00043 #include "structmember.h" 00044 #include <qobject.h> 00045 00046 namespace ito 00047 { 00048 class PythonRgba 00049 { 00050 00051 public: 00052 00053 //------------------------------------------------------------------------------------------------- 00054 // typedefs 00055 //------------------------------------------------------------------------------------------------- 00056 typedef struct 00057 { 00058 PyObject_HEAD 00059 ito::Rgba32 rgba; 00060 } 00061 PyRgba; 00062 00063 00064 #define PyRgba_Check(op) PyObject_TypeCheck(op, &ito::PythonRgba::PyRgbaType) 00065 00066 00067 //------------------------------------------------------------------------------------------------- 00068 // constructor, deconstructor, alloc, dellaoc 00069 //------------------------------------------------------------------------------------------------- 00070 00071 static void PyRgba_dealloc(PyRgba *self); 00072 static PyObject *PyRgba_new(PyTypeObject *type, PyObject *args, PyObject *kwds); 00073 static int PyRgba_init(PyRgba *self, PyObject *args, PyObject *kwds); 00074 00075 static PyRgba* createEmptyPyRgba(); 00076 static bool checkPyRgba(int number, PyObject* rgba1 = NULL, PyObject* rgba2 = NULL, PyObject* rgba3 = NULL); 00077 00078 00079 //------------------------------------------------------------------------------------------------- 00080 // general members 00081 //------------------------------------------------------------------------------------------------- 00082 static PyObject *PyRgba_name(PyRgba *self); 00083 00084 static PyObject* PyRgba_repr(PyRgba *self); 00085 00086 static PyObject *PyRgba_toGray(PyRgba *self); 00087 00088 static PyObject *PyRgba_toColor(PyRgba *self); 00089 00090 static PyObject* PyRgba_RichCompare(PyRgba *self, PyObject *other, int cmp_op); 00091 00092 static PyGetSetDef PyRgba_getseters[]; 00093 00094 static PyObject* PyRgba_getValue(PyRgba *self, void *closure); 00095 static int PyRgba_setValue(PyRgba *self, PyObject *value, void *closure); 00096 00097 static PyObject* PyRgba_Reduce(PyRgba *self, PyObject *args); 00098 static PyObject* PyRgba_SetState(PyRgba *self, PyObject *args); 00099 00100 //------------------------------------------------------------------------------------------------- 00101 // number protocol 00102 // 00103 // python note: Binary and ternary functions must check the type of all their operands, and implement 00104 // the necessary conversions (at least one of the operands is an instance of the defined type). 00105 // If the operation is not defined for the given operands, binary and ternary functions must return 00106 // Py_NotImplemented, if another error occurred they must return NULL and set an exception. 00107 //------------------------------------------------------------------------------------------------- 00108 static PyObject* PyRgba_nbAdd(PyObject* o1, PyObject* o2); 00109 static PyObject* PyRgba_nbSubtract(PyObject* o1, PyObject* o2); 00110 static PyObject* PyRgba_nbMultiply(PyObject* o1, PyObject* o2); 00111 static PyObject* PyRgba_nbPositive(PyObject* o1); 00112 static PyObject* PyRgba_nbAbsolute(PyObject* o1); 00113 static PyObject* PyRgba_nbInvert(PyObject* o1); 00114 static PyObject* PyRgba_nbLshift(PyObject* o1, PyObject* o2); 00115 static PyObject* PyRgba_nbRshift(PyObject* o1, PyObject* o2); 00116 static PyObject* PyRgba_nbAnd(PyObject* o1, PyObject* o2); 00117 static PyObject* PyRgba_nbXor(PyObject* o1, PyObject* o2); 00118 static PyObject* PyRgba_nbOr(PyObject* o1, PyObject* o2); 00119 00120 static PyObject* PyRgba_nbInplaceAdd(PyObject* o1, PyObject* o2); 00121 static PyObject* PyRgba_nbInplaceSubtract(PyObject* o1, PyObject* o2); 00122 static PyObject* PyRgba_nbInplaceMultiply(PyObject* o1, PyObject* o2); 00123 static PyObject* PyRgba_nbInplaceLshift(PyObject* o1, PyObject* o2); 00124 static PyObject* PyRgba_nbInplaceRshift(PyObject* o1, PyObject* o2); 00125 static PyObject* PyRgba_nbInplaceAnd(PyObject* o1, PyObject* o2); 00126 static PyObject* PyRgba_nbInplaceXor(PyObject* o1, PyObject* o2); 00127 static PyObject* PyRgba_nbInplaceOr(PyObject* o1, PyObject* o2); 00128 00129 00130 //------------------------------------------------------------------------------------------------- 00131 // type structures 00132 //------------------------------------------------------------------------------------------------- 00133 static PyMemberDef PyRgba_members[]; 00134 static PyMethodDef PyRgba_methods[]; 00135 static PyTypeObject PyRgbaType; 00136 static PyModuleDef PyRgbaModule; 00137 00138 static PyNumberMethods PyRgba_numberProtocol; 00139 00140 //------------------------------------------------------------------------------------------------- 00141 // helper methods 00142 //------------------------------------------------------------------------------------------------- 00143 00144 //------------------------------------------------------------------------------------------------- 00145 // static type methods 00146 //------------------------------------------------------------------------------------------------- 00147 00148 00149 }; 00150 00151 } //end namespace ito 00152 00153 #endif