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