itom
Loading...
Searching...
No Matches
pythonRgba.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 PYTHONRGBA
24#define PYTHONRGBA
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 #include "python/pythonWrapper.h"
31#endif
32
33#include "../../common/typeDefs.h"
34#include "../../common/color.h"
35#include "structmember.h"
36#include <qobject.h>
37
38namespace ito
39{
41 {
42
43 public:
44
45 //-------------------------------------------------------------------------------------------------
46 // typedefs
47 //-------------------------------------------------------------------------------------------------
48 typedef struct
49 {
50 PyObject_HEAD
51 ito::Rgba32 rgba;
52 }
53 PyRgba;
54
55
56 #define PyRgba_Check(op) PyObject_TypeCheck(op, &ito::PythonRgba::PyRgbaType)
57
58
59 //-------------------------------------------------------------------------------------------------
60 // constructor, deconstructor, alloc, dellaoc
61 //-------------------------------------------------------------------------------------------------
62
63 static void PyRgba_dealloc(PyRgba *self);
64 static PyObject *PyRgba_new(PyTypeObject *type, PyObject *args, PyObject *kwds);
65 static int PyRgba_init(PyRgba *self, PyObject *args, PyObject *kwds);
66
67 static PyRgba* createEmptyPyRgba();
68 static bool checkPyRgba(int number, PyObject* rgba1 = NULL, PyObject* rgba2 = NULL, PyObject* rgba3 = NULL);
69
70
71 //-------------------------------------------------------------------------------------------------
72 // general members
73 //-------------------------------------------------------------------------------------------------
74 static PyObject *PyRgba_name(PyRgba *self);
75
76 static PyObject* PyRgba_repr(PyRgba *self);
77
78 static PyObject *PyRgba_toGray(PyRgba *self);
79
80 static PyObject *PyRgba_toColor(PyRgba *self);
81
82 static PyObject* PyRgba_RichCompare(PyRgba *self, PyObject *other, int cmp_op);
83
84 static PyGetSetDef PyRgba_getseters[];
85
86 static PyObject* PyRgba_getValue(PyRgba *self, void *closure);
87 static int PyRgba_setValue(PyRgba *self, PyObject *value, void *closure);
88
89 static PyObject* PyRgba_Reduce(PyRgba *self, PyObject *args);
90 static PyObject* PyRgba_SetState(PyRgba *self, PyObject *args);
91
92 //-------------------------------------------------------------------------------------------------
93 // number protocol
94 //
95 // python note: Binary and ternary functions must check the type of all their operands, and implement
96 // the necessary conversions (at least one of the operands is an instance of the defined type).
97 // If the operation is not defined for the given operands, binary and ternary functions must return
98 // Py_NotImplemented, if another error occurred they must return NULL and set an exception.
99 //-------------------------------------------------------------------------------------------------
100 static PyObject* PyRgba_nbAdd(PyObject* o1, PyObject* o2);
101 static PyObject* PyRgba_nbSubtract(PyObject* o1, PyObject* o2);
102 static PyObject* PyRgba_nbMultiply(PyObject* o1, PyObject* o2);
103 static PyObject* PyRgba_nbPositive(PyObject* o1);
104 static PyObject* PyRgba_nbAbsolute(PyObject* o1);
105 static PyObject* PyRgba_nbInvert(PyObject* o1);
106 static PyObject* PyRgba_nbLshift(PyObject* o1, PyObject* o2);
107 static PyObject* PyRgba_nbRshift(PyObject* o1, PyObject* o2);
108 static PyObject* PyRgba_nbAnd(PyObject* o1, PyObject* o2);
109 static PyObject* PyRgba_nbXor(PyObject* o1, PyObject* o2);
110 static PyObject* PyRgba_nbOr(PyObject* o1, PyObject* o2);
111
112 static PyObject* PyRgba_nbInplaceAdd(PyObject* o1, PyObject* o2);
113 static PyObject* PyRgba_nbInplaceSubtract(PyObject* o1, PyObject* o2);
114 static PyObject* PyRgba_nbInplaceMultiply(PyObject* o1, PyObject* o2);
115 static PyObject* PyRgba_nbInplaceLshift(PyObject* o1, PyObject* o2);
116 static PyObject* PyRgba_nbInplaceRshift(PyObject* o1, PyObject* o2);
117 static PyObject* PyRgba_nbInplaceAnd(PyObject* o1, PyObject* o2);
118 static PyObject* PyRgba_nbInplaceXor(PyObject* o1, PyObject* o2);
119 static PyObject* PyRgba_nbInplaceOr(PyObject* o1, PyObject* o2);
120
121
122 //-------------------------------------------------------------------------------------------------
123 // type structures
124 //-------------------------------------------------------------------------------------------------
125 static PyMemberDef PyRgba_members[];
126 static PyMethodDef PyRgba_methods[];
127 static PyTypeObject PyRgbaType;
128 static PyModuleDef PyRgbaModule;
129
130 static PyNumberMethods PyRgba_numberProtocol;
131
132 //-------------------------------------------------------------------------------------------------
133 // helper methods
134 //-------------------------------------------------------------------------------------------------
135
136 //-------------------------------------------------------------------------------------------------
137 // static type methods
138 //-------------------------------------------------------------------------------------------------
139
140
141};
142
143} //end namespace ito
144
145#endif
Definition pythonRgba.h:41
This class implements basic functionality for color handling in itom. \detail This class implements A...
Definition color.h:47
Definition apiFunctionsGraph.cpp:40
Definition pythonRgba.h:49