itom 1.3.0
D:/git-itom/sources/itom/Qitom/python/pythonRgba.h
00001 /* ********************************************************************
00002     itom software
00003     URL: http://www.uni-stuttgart.de/ito
00004     Copyright (C) 2013, 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 linux)
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_RichCompare(PyRgba *self, PyObject *other, int cmp_op);
00087 
00088         static PyGetSetDef PyRgba_getseters[];
00089 
00090         static PyObject* PyRgba_getValue(PyRgba *self, void *closure);
00091         static int PyRgba_setValue(PyRgba *self, PyObject *value, void *closure);
00092 
00093         static PyObject* PyRgba_Reduce(PyRgba *self, PyObject *args);
00094         static PyObject* PyRgba_SetState(PyRgba *self, PyObject *args);
00095 
00096         //-------------------------------------------------------------------------------------------------
00097         // number protocol
00098         //
00099         // python note: Binary and ternary functions must check the type of all their operands, and implement 
00100         //    the necessary conversions (at least one of the operands is an instance of the defined type). 
00101         //    If the operation is not defined for the given operands, binary and ternary functions must return 
00102         //    Py_NotImplemented, if another error occurred they must return NULL and set an exception.
00103         //------------------------------------------------------------------------------------------------- 
00104         static PyObject* PyRgba_nbAdd(PyObject* o1, PyObject* o2);
00105         static PyObject* PyRgba_nbSubtract(PyObject* o1, PyObject* o2);
00106         static PyObject* PyRgba_nbMultiply(PyObject* o1, PyObject* o2);
00107         static PyObject* PyRgba_nbPositive(PyObject* o1);
00108         static PyObject* PyRgba_nbAbsolute(PyObject* o1);
00109         static PyObject* PyRgba_nbInvert(PyObject* o1);
00110         static PyObject* PyRgba_nbLshift(PyObject* o1, PyObject* o2);
00111         static PyObject* PyRgba_nbRshift(PyObject* o1, PyObject* o2);
00112         static PyObject* PyRgba_nbAnd(PyObject* o1, PyObject* o2);
00113         static PyObject* PyRgba_nbXor(PyObject* o1, PyObject* o2);
00114         static PyObject* PyRgba_nbOr(PyObject* o1, PyObject* o2);
00115 
00116         static PyObject* PyRgba_nbInplaceAdd(PyObject* o1, PyObject* o2);
00117         static PyObject* PyRgba_nbInplaceSubtract(PyObject* o1, PyObject* o2);
00118         static PyObject* PyRgba_nbInplaceMultiply(PyObject* o1, PyObject* o2);
00119         static PyObject* PyRgba_nbInplaceLshift(PyObject* o1, PyObject* o2);
00120         static PyObject* PyRgba_nbInplaceRshift(PyObject* o1, PyObject* o2);
00121         static PyObject* PyRgba_nbInplaceAnd(PyObject* o1, PyObject* o2);
00122         static PyObject* PyRgba_nbInplaceXor(PyObject* o1, PyObject* o2);
00123         static PyObject* PyRgba_nbInplaceOr(PyObject* o1, PyObject* o2);
00124 
00125         
00126         //-------------------------------------------------------------------------------------------------
00127         // type structures
00128         //------------------------------------------------------------------------------------------------- 
00129         static PyMemberDef PyRgba_members[];
00130         static PyMethodDef PyRgba_methods[];
00131         static PyTypeObject PyRgbaType;
00132         static PyModuleDef PyRgbaModule;
00133 
00134         static PyNumberMethods PyRgba_numberProtocol;
00135 
00136         //-------------------------------------------------------------------------------------------------
00137         // helper methods
00138         //-------------------------------------------------------------------------------------------------    
00139 
00140         //-------------------------------------------------------------------------------------------------
00141         // static type methods
00142         //-------------------------------------------------------------------------------------------------
00143         static PyObject* PyRgba_StaticZeros(PyObject *self, PyObject *args, PyObject *kwds);
00144         static PyObject* PyRgba_StaticOnes(PyObject *self, PyObject *args, PyObject *kwds);
00145         static PyObject* PyRgba_StaticRand(PyObject *self, PyObject *args, PyObject *kwds);
00146         static PyObject* PyRgba_StaticRandN(PyObject *self, PyObject *args, PyObject *kwds);
00147         static PyObject* PyRgba_StaticEye(PyObject *self, PyObject *args /*, PyObject *kwds*/);
00148 
00149 
00150 };
00151 
00152 } //end namespace ito
00153 
00154 #endif
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends