Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Gui: [skip ci] add method to Python binding of ViewProviderExtension …
…to ignore overlay icon
- Loading branch information
Showing
6 changed files
with
135 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<GenerateModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="generateMetaModel_Module.xsd"> | ||
<PythonExport | ||
Father="ExtensionPy" | ||
Name="ViewProviderExtensionPy" | ||
TwinPointer="ViewProviderExtension" | ||
Twin="ViewProviderExtension" | ||
Include="Gui/ViewProviderExtension.h" | ||
Namespace="Gui" | ||
FatherInclude="App/ExtensionPy.h" | ||
FatherNamespace="App"> | ||
<Documentation> | ||
<Author Licence="LGPL" Name="Werner Mayer" EMail="wmayer[at]users.sourceforge.net" /> | ||
<UserDocu>Base class for all view provider extensions</UserDocu> | ||
</Documentation> | ||
<Methode Name="setIgnoreOverlayIcon"> | ||
<Documentation> | ||
<UserDocu>Ignore the overlay icon of an extension</UserDocu> | ||
</Documentation> | ||
</Methode> | ||
<Methode Name="ignoreOverlayIcon" Const="true"> | ||
<Documentation> | ||
<UserDocu>Ignore the overlay icon of an extension</UserDocu> | ||
</Documentation> | ||
</Methode> | ||
<CustomAttributes /> | ||
</PythonExport> | ||
</GenerateModel> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/*************************************************************************** | ||
* Copyright (c) 2020 Werner Mayer <wmayer[at]users.sourceforge.net> * | ||
* * | ||
* This file is part of the FreeCAD CAx development system. * | ||
* * | ||
* This library is free software; you can redistribute it and/or * | ||
* modify it under the terms of the GNU Library General Public * | ||
* License as published by the Free Software Foundation; either * | ||
* version 2 of the License, or (at your option) any later version. * | ||
* * | ||
* This library is distributed in the hope that it will be useful, * | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of * | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | ||
* GNU Library General Public License for more details. * | ||
* * | ||
* You should have received a copy of the GNU Library General Public * | ||
* License along with this library; see the file COPYING.LIB. If not, * | ||
* write to the Free Software Foundation, Inc., 59 Temple Place, * | ||
* Suite 330, Boston, MA 02111-1307, USA * | ||
* * | ||
***************************************************************************/ | ||
|
||
|
||
#include "PreCompiled.h" | ||
|
||
#ifndef _PreComp_ | ||
# include <sstream> | ||
#endif | ||
|
||
// inclution of the generated files (generated out of PropertyContainerPy.xml) | ||
#include "ViewProviderExtensionPy.h" | ||
#include "ViewProviderExtensionPy.cpp" | ||
|
||
using namespace Gui; | ||
|
||
// returns a string which represent the object e.g. when printed in python | ||
std::string ViewProviderExtensionPy::representation(void) const | ||
{ | ||
return std::string("<view provider extension>"); | ||
} | ||
|
||
PyObject* ViewProviderExtensionPy::setIgnoreOverlayIcon(PyObject *args) | ||
{ | ||
PyObject* ignore; | ||
const char* name = nullptr; | ||
if (!PyArg_ParseTuple(args, "O!s", &PyBool_Type, &ignore, &name)) | ||
return nullptr; | ||
|
||
ViewProviderExtension* ext = getViewProviderExtensionPtr(); | ||
if (name) { | ||
Base::Type type = Base::Type::fromName(name); | ||
ext = dynamic_cast<ViewProviderExtension*>(ext->getExtendedContainer()->getExtension(type, true, true)); | ||
if (!ext) { | ||
PyErr_SetString(PyExc_NameError, "no such extension"); | ||
return nullptr; | ||
} | ||
} | ||
|
||
ext->setIgnoreOverlayIcon(PyObject_IsTrue(ignore) ? true : false); | ||
Py_Return; | ||
} | ||
|
||
PyObject* ViewProviderExtensionPy::ignoreOverlayIcon(PyObject *args) | ||
{ | ||
const char* name = nullptr; | ||
if (!PyArg_ParseTuple(args, "s", &name)) | ||
return nullptr; | ||
|
||
ViewProviderExtension* ext = getViewProviderExtensionPtr(); | ||
if (name) { | ||
Base::Type type = Base::Type::fromName(name); | ||
ext = dynamic_cast<ViewProviderExtension*>(ext->getExtendedContainer()->getExtension(type, true, true)); | ||
if (!ext) { | ||
PyErr_SetString(PyExc_NameError, "no such extension"); | ||
return nullptr; | ||
} | ||
} | ||
|
||
bool ignore = ext->ignoreOverlayIcon(); | ||
return Py_BuildValue("O", (ignore ? Py_True : Py_False)); | ||
} | ||
|
||
PyObject *ViewProviderExtensionPy::getCustomAttributes(const char* /*attr*/) const | ||
{ | ||
return 0; | ||
} | ||
|
||
int ViewProviderExtensionPy::setCustomAttributes(const char* /*attr*/, PyObject * /*obj*/) | ||
{ | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters