| 1 |
/*************************************************************************** |
| 2 |
* Copyright (c) 2020 Werner Mayer <wmayer[at]users.sourceforge.net> * |
| 3 |
* * |
| 4 |
* This file is part of the FreeCAD CAx development system. * |
| 5 |
* * |
| 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. * |
| 10 |
* * |
| 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. * |
| 15 |
* * |
| 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 * |
| 20 |
* * |
| 21 |
***************************************************************************/ |
| 22 |
|
| 23 |
|
| 24 |
#include <sstream> |
| 25 |
|
| 26 |
|
| 27 |
// inclusion of the generated files (generated out of PropertyContainerPy.pyi) |
| 28 |
#include "ViewProviderExtensionPy.h" |
| 29 |
#include "ViewProviderExtensionPy.cpp" |
| 30 |
#include "ViewProviderDocumentObject.h" |
| 31 |
|
| 32 |
using namespace Gui; |
| 33 |
|
| 34 |
// returns a string which represent the object e.g. when printed in python |
| 35 |
std::string ViewProviderExtensionPy::representation() const |
| 36 |
{ |
| 37 |
return {"<view provider extension>"}; |
| 38 |
} |
| 39 |
|
| 40 |
PyObject* ViewProviderExtensionPy::setIgnoreOverlayIcon(PyObject* args) |
| 41 |
{ |
| 42 |
PyObject* ignore; |
| 43 |
const char* name = nullptr; |
| 44 |
if (!PyArg_ParseTuple(args, "O!s", &PyBool_Type, &ignore, &name)) { |
| 45 |
return nullptr; |
| 46 |
} |
| 47 |
|
| 48 |
ViewProviderExtension* ext = getViewProviderExtensionPtr(); |
| 49 |
if (name) { |
| 50 |
Base::Type type = Base::Type::fromName(name); |
| 51 |
ext = dynamic_cast<ViewProviderExtension*>( |
| 52 |
ext->getExtendedContainer()->getExtension(type, true, true) |
| 53 |
); |
| 54 |
if (!ext) { |
| 55 |
PyErr_SetString(PyExc_NameError, "no such extension"); |
| 56 |
return nullptr; |
| 57 |
} |
| 58 |
} |
| 59 |
|
| 60 |
ext->setIgnoreOverlayIcon(Base::asBoolean(ignore)); |
| 61 |
Py_Return; |
| 62 |
} |
| 63 |
|
| 64 |
PyObject* ViewProviderExtensionPy::ignoreOverlayIcon(PyObject* args) const |
| 65 |
{ |
| 66 |
const char* name = nullptr; |
| 67 |
if (!PyArg_ParseTuple(args, "s", &name)) { |
| 68 |
return nullptr; |
| 69 |
} |
| 70 |
|
| 71 |
ViewProviderExtension* ext = getViewProviderExtensionPtr(); |
| 72 |
if (name) { |
| 73 |
Base::Type type = Base::Type::fromName(name); |
| 74 |
ext = dynamic_cast<ViewProviderExtension*>( |
| 75 |
ext->getExtendedContainer()->getExtension(type, true, true) |
| 76 |
); |
| 77 |
if (!ext) { |
| 78 |
PyErr_SetString(PyExc_NameError, "no such extension"); |
| 79 |
return nullptr; |
| 80 |
} |
| 81 |
} |
| 82 |
|
| 83 |
bool ignore = ext->ignoreOverlayIcon(); |
| 84 |
return Py_BuildValue("O", (ignore ? Py_True : Py_False)); |
| 85 |
} |
| 86 |
|
| 87 |
PyObject* ViewProviderExtensionPy::getCustomAttributes(const char* /*attr*/) const |
| 88 |
{ |
| 89 |
return nullptr; |
| 90 |
} |
| 91 |
|
| 92 |
int ViewProviderExtensionPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/) |
| 93 |
{ |
| 94 |
return 0; |
| 95 |
} |