Skip to content
Snippets Groups Projects
Commit 9bf30c14 authored by Jan Möbius's avatar Jan Möbius
Browse files

Merge branch 'python-vsi' into 'master'

Changed vsi metadata to produce python code

See merge request !2
parents bf0b3f97 45492fd0
No related branches found
No related tags found
1 merge request!2Changed vsi metadata to produce python code
include (plugin)
openflipper_plugin ( TRANSLATION_LANGUAGES de_DE
openflipper_plugin ( PYTHONINTERFACE
TRANSLATION_LANGUAGES de_DE
INSTALLDATA Icons VsiMetadata
DIRS widgets)
......@@ -50,6 +50,7 @@
#include "OpenFlipper/BasePlugin/StatusbarInterface.hh"
#include "OpenFlipper/BasePlugin/OptionsInterface.hh"
#include "OpenFlipper/BasePlugin/INIInterface.hh"
#include <OpenFlipper/BasePlugin/PythonInterface.hh>
#include <QObject>
#include <QMenuBar>
......@@ -58,7 +59,7 @@
class ColorPlugin : public QObject, BaseInterface, MenuInterface, ScriptInterface, ToolbarInterface, StatusbarInterface, OptionsInterface, INIInterface
class ColorPlugin : public QObject, BaseInterface, MenuInterface, ScriptInterface, ToolbarInterface, StatusbarInterface, OptionsInterface, INIInterface, PythonInterface
{
Q_OBJECT
......@@ -70,6 +71,7 @@ class ColorPlugin : public QObject, BaseInterface, MenuInterface, ScriptInterfac
Q_INTERFACES(StatusbarInterface)
Q_INTERFACES(OptionsInterface)
Q_INTERFACES(INIInterface)
Q_INTERFACES(PythonInterface)
Q_PLUGIN_METADATA(IID "org.OpenFlipper.Plugins.Plugin-Color")
......
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (c) 2001-2015, RWTH-Aachen University *
* Department of Computer Graphics and Multimedia *
* All rights reserved. *
* www.openflipper.org *
* *
*---------------------------------------------------------------------------*
* This file is part of OpenFlipper. *
*---------------------------------------------------------------------------*
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* 1. Redistributions of source code must retain the above copyright notice, *
* this list of conditions and the following disclaimer. *
* *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the following disclaimer in the *
* documentation and/or other materials provided with the distribution. *
* *
* 3. Neither the name of the copyright holder nor the names of its *
* contributors may be used to endorse or promote products derived from *
* this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
* *
\*===========================================================================*/
#include <pybind11/include/pybind11/pybind11.h>
#include <pybind11/include/pybind11/embed.h>
#include <ColorPlugin.hh>
#include <OpenFlipper/BasePlugin/PythonFunctions.hh>
#include <OpenFlipper/PythonInterpreter/PythonTypeConversions.hh>
namespace py = pybind11;
PYBIND11_EMBEDDED_MODULE(ColorPlugin, m) {
QObject* pluginPointer = getPluginPointer("ColorPlugin");
if (!pluginPointer) {
std::cerr << "Error Getting plugin pointer for Plugin-Color" << std::endl;
return;
}
ColorPlugin* plugin = qobject_cast<ColorPlugin*>(pluginPointer);
if (!plugin) {
std::cerr << "Error converting plugin pointer for Plugin-Color" << std::endl;
return;
}
// Export our core. Make sure that the c++ worlds core object is not deleted if
// the python side gets deleted!!
py::class_< ColorPlugin,std::unique_ptr<ColorPlugin, py::nodelete> > color(m, "ColorPlugin");
// On the c++ side we will just return the existing core instance
// and prevent the system to recreate a new core as we need
// to work on the existing one.
color.def(py::init([plugin]() { return plugin; }));
color.def("setObjectSpecularColor", &ColorPlugin::setObjectSpecularColor,
QCoreApplication::translate("PythonDocColor","Changes the object specular color").toLatin1().data(),
py::arg(QCoreApplication::translate("PythonDocColor","Object").toLatin1().data()),
py::arg(QCoreApplication::translate("PythonDocColor","Color").toLatin1().data()));
color.def("setObjectEmissiveColor", &ColorPlugin::setObjectEmissiveColor,
QCoreApplication::translate("PythonDocColor","Changes the object emissive color").toLatin1().data(),
py::arg(QCoreApplication::translate("PythonDocColor","Object").toLatin1().data()),
py::arg(QCoreApplication::translate("PythonDocColor","Color").toLatin1().data()));
color.def("setObjectAmbientColor", &ColorPlugin::setObjectAmbientColor,
QCoreApplication::translate("PythonDocColor","Changes the object ambient color").toLatin1().data(),
py::arg(QCoreApplication::translate("PythonDocColor","Object").toLatin1().data()),
py::arg(QCoreApplication::translate("PythonDocColor","Color").toLatin1().data()));
color.def("setObjectDiffuseColor", &ColorPlugin::setObjectDiffuseColor,
QCoreApplication::translate("PythonDocColor","Changes the object diffuse color").toLatin1().data(),
py::arg(QCoreApplication::translate("PythonDocColor","Object").toLatin1().data()),
py::arg(QCoreApplication::translate("PythonDocColor","Color").toLatin1().data()));
color.def("setBackgroundColor", &ColorPlugin::setBackgroundColor,
QCoreApplication::translate("PythonDocColor","Changes the background color").toLatin1().data(),
py::arg(QCoreApplication::translate("PythonDocColor","Color").toLatin1().data()));
}
......@@ -12,7 +12,7 @@
</input>
</inputs>
<code>
colorplugin.setBackgroundColor([input="color"])
ColorPlugin.ColorPlugin().setBackgroundColor([input="color"])
</code>
</element>
......@@ -49,17 +49,14 @@
</input>
</inputs>
<code>
if ([is_connected="color_emissive"])
colorplugin.setObjectEmissiveColor([input="obj"],[input="color_emissive"]);
if ([is_connected="color_ambient"])
colorplugin.setObjectAmbientColor([input="obj"],[input="color_ambient"]);
if ([is_connected="color_diffuse"])
colorplugin.setObjectDiffuseColor([input="obj"],[input="color_diffuse"]);
if ([is_connected="color_specular"])
colorplugin.setObjectSpecularColor([input="obj"],[input="color_specular"]);
if ([is_connected="color_emissive"] or [is_set="color_emissive"]):
ColorPlugin.ColorPlugin().setObjectEmissiveColor([input="obj"],[input="color_emissive"]);
if ([is_connected="color_ambient"] or [is_set="color_ambient"]):
ColorPlugin.ColorPlugin().setObjectAmbientColor([input="obj"],[input="color_ambient"]);
if ([is_connected="color_diffuse"] or [is_set="color_diffuse"]):
ColorPlugin.ColorPlugin().setObjectDiffuseColor([input="obj"],[input="color_diffuse"]);
if ([is_connected="color_specular"] or [is_set="color_specular"]):
ColorPlugin.ColorPlugin().setObjectSpecularColor([input="obj"],[input="color_specular"]);
</code>
</element>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment