1
/***************************************************************************
2
* Copyright (c) 2010 Werner Mayer <wmayer[at]users.sourceforge.net> *
4
* This file is part of the FreeCAD CAx development system. *
6
* This library is free software; you can redistribute it and/or *
7
* modify it under the terms of the GNU Library General Public *
8
* License as published by the Free Software Foundation; either *
9
* version 2 of the License, or (at your option) any later version. *
11
* This library is distributed in the hope that it will be useful, *
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14
* GNU Library General Public License for more details. *
16
* You should have received a copy of the GNU Library General Public *
17
* License along with this library; see the file COPYING.LIB. If not, *
18
* write to the Free Software Foundation, Inc., 59 Temple Place, *
19
* Suite 330, Boston, MA 02111-1307, USA *
21
***************************************************************************/
24
#include "PreCompiled.h"
26
// inclusion of the generated files (generated out of MaterialPy.xml)
27
#include "MaterialPy.h"
28
#include "MaterialPy.cpp"
29
#include <Base/PyWrapParseTupleAndKeywords.h>
33
PyObject *MaterialPy::PyMake(struct _typeobject *, PyObject *, PyObject *) // Python wrapper
35
// create a new instance of MaterialPy and the Twin object
36
return new MaterialPy(new Material);
40
int MaterialPy::PyInit(PyObject* args, PyObject* kwds)
42
PyObject* diffuse = nullptr;
43
PyObject* ambient = nullptr;
44
PyObject* specular = nullptr;
45
PyObject* emissive = nullptr;
46
PyObject* shininess = nullptr;
47
PyObject* transparency = nullptr;
48
static const std::array<const char *, 7> kwds_colors{"DiffuseColor", "AmbientColor", "SpecularColor",
49
"EmissiveColor", "Shininess", "Transparency", nullptr};
51
if (!Base::Wrapped_ParseTupleAndKeywords(args, kwds, "|OOOOOO", kwds_colors,
52
&diffuse, &ambient, &specular, &emissive, &shininess, &transparency)) {
57
setDiffuseColor(Py::Tuple(diffuse));
61
setAmbientColor(Py::Tuple(ambient));
65
setSpecularColor(Py::Tuple(specular));
69
setEmissiveColor(Py::Tuple(emissive));
73
setShininess(Py::Float(shininess));
77
setTransparency(Py::Float(transparency));
83
// returns a string which represents the object e.g. when printed in python
84
std::string MaterialPy::representation() const
86
return {"<Material object>"};
89
PyObject* MaterialPy::set(PyObject * args)
92
if (!PyArg_ParseTuple(args, "s", &pstr))
95
getMaterialPtr()->set(pstr);
100
Py::Tuple MaterialPy::getAmbientColor() const
103
tuple.setItem(0, Py::Float(getMaterialPtr()->ambientColor.r));
104
tuple.setItem(1, Py::Float(getMaterialPtr()->ambientColor.g));
105
tuple.setItem(2, Py::Float(getMaterialPtr()->ambientColor.b));
106
tuple.setItem(3, Py::Float(getMaterialPtr()->ambientColor.a));
110
void MaterialPy::setAmbientColor(Py::Tuple arg)
113
c.r = Py::Float(arg.getItem(0));
114
c.g = Py::Float(arg.getItem(1));
115
c.b = Py::Float(arg.getItem(2));
117
c.a = Py::Float(arg.getItem(3));
118
getMaterialPtr()->ambientColor = c;
121
Py::Tuple MaterialPy::getDiffuseColor() const
124
tuple.setItem(0, Py::Float(getMaterialPtr()->diffuseColor.r));
125
tuple.setItem(1, Py::Float(getMaterialPtr()->diffuseColor.g));
126
tuple.setItem(2, Py::Float(getMaterialPtr()->diffuseColor.b));
127
tuple.setItem(3, Py::Float(getMaterialPtr()->diffuseColor.a));
131
void MaterialPy::setDiffuseColor(Py::Tuple arg)
134
c.r = Py::Float(arg.getItem(0));
135
c.g = Py::Float(arg.getItem(1));
136
c.b = Py::Float(arg.getItem(2));
138
c.a = Py::Float(arg.getItem(3));
139
getMaterialPtr()->diffuseColor = c;
142
Py::Tuple MaterialPy::getEmissiveColor() const
145
tuple.setItem(0, Py::Float(getMaterialPtr()->emissiveColor.r));
146
tuple.setItem(1, Py::Float(getMaterialPtr()->emissiveColor.g));
147
tuple.setItem(2, Py::Float(getMaterialPtr()->emissiveColor.b));
148
tuple.setItem(3, Py::Float(getMaterialPtr()->emissiveColor.a));
152
void MaterialPy::setEmissiveColor(Py::Tuple arg)
155
c.r = Py::Float(arg.getItem(0));
156
c.g = Py::Float(arg.getItem(1));
157
c.b = Py::Float(arg.getItem(2));
159
c.a = Py::Float(arg.getItem(3));
160
getMaterialPtr()->emissiveColor = c;
163
Py::Tuple MaterialPy::getSpecularColor() const
166
tuple.setItem(0, Py::Float(getMaterialPtr()->specularColor.r));
167
tuple.setItem(1, Py::Float(getMaterialPtr()->specularColor.g));
168
tuple.setItem(2, Py::Float(getMaterialPtr()->specularColor.b));
169
tuple.setItem(3, Py::Float(getMaterialPtr()->specularColor.a));
173
void MaterialPy::setSpecularColor(Py::Tuple arg)
176
c.r = Py::Float(arg.getItem(0));
177
c.g = Py::Float(arg.getItem(1));
178
c.b = Py::Float(arg.getItem(2));
180
c.a = Py::Float(arg.getItem(3));
181
getMaterialPtr()->specularColor = c;
184
Py::Float MaterialPy::getShininess() const
186
return Py::Float(getMaterialPtr()->shininess);
189
void MaterialPy::setShininess(Py::Float arg)
191
getMaterialPtr()->shininess = arg;
194
Py::Float MaterialPy::getTransparency() const
196
return Py::Float(getMaterialPtr()->transparency);
199
void MaterialPy::setTransparency(Py::Float arg)
201
getMaterialPtr()->transparency = arg;
204
PyObject *MaterialPy::getCustomAttributes(const char* /*attr*/) const
209
int MaterialPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)