Commit 525171a4 authored by Jan Möbius's avatar Jan Möbius

Merge branch 'Python-Tests' into 'master'

Initial Python  support

See merge request !1
parents 445a93ab 22b1b28b
......@@ -4,6 +4,8 @@ if (EXISTS ${CMAKE_SOURCE_DIR}/ObjectTypes/TSplineMesh)
add_definitions (-DENABLE_TSPLINEMESH_SUPPORT)
endif ()
openflipper_plugin (DIRS TSplineMesh
openflipper_plugin (PYTHONINTERFACE
DIRS TSplineMesh
INSTALLDATA Icons
TYPES POLYMESH TRIANGLEMESH)
TYPES POLYMESH TRIANGLEMESH
)
#include <pybind11/include/pybind11/pybind11.h>
#include <pybind11/include/pybind11/embed.h>
#include <ViewControlPlugin.hh>
#include <OpenFlipper/BasePlugin/PythonFunctions.hh>
namespace py = pybind11;
PYBIND11_EMBEDDED_MODULE(ViewControl, m) {
QObject* pluginPointer = getPluginPointer("ViewControl");
// Export our core. Make sure that the c++ worlds core object is not deleted if
// the python side gets deleted!!
py::class_< ViewControlPlugin,std::unique_ptr<ViewControlPlugin, py::nodelete> > view(m, "viewControl");
// 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.
view.def(py::init([&pluginPointer]() { return qobject_cast<ViewControlPlugin*>(pluginPointer); }));
view.def("viewAll", static_cast<void (ViewControlPlugin::*)()>(&ViewControlPlugin::viewAll),"Change View in all viewers to view whole scene");
view.def("viewAll", static_cast<void (ViewControlPlugin::*)(int)>(&ViewControlPlugin::viewAll),"Change View in given viewer to view whole scene",py::arg("Id of the viewer which should be switched") );
view.def("orthographicProjection", static_cast<void (ViewControlPlugin::*)()>(&ViewControlPlugin::orthographicProjection) );
view.def("orthographicProjection", static_cast<void (ViewControlPlugin::*)(int)>(&ViewControlPlugin::orthographicProjection) );
}
......@@ -39,10 +39,7 @@
* *
\*===========================================================================*/
#ifndef ViewControlPlugin_HH
#define ViewControlPlugin_HH
#pragma once
#include <QObject>
#include <QMenuBar>
......@@ -52,6 +49,7 @@
#include <OpenFlipper/BasePlugin/BaseInterface.hh>
#include <OpenFlipper/BasePlugin/LoggingInterface.hh>
#include <OpenFlipper/BasePlugin/PickingInterface.hh>
#include <OpenFlipper/BasePlugin/PythonInterface.hh>
#include <OpenFlipper/BasePlugin/ToolbarInterface.hh>
#include <OpenFlipper/BasePlugin/ContextMenuInterface.hh>
#include <OpenFlipper/common/Types.hh>
......@@ -82,7 +80,7 @@ struct ShaderInfo {
QStringList uniformsMin;
};
class ViewControlPlugin : public QObject, BaseInterface , PickingInterface, LoggingInterface, ToolbarInterface, ContextMenuInterface
class ViewControlPlugin : public QObject, BaseInterface , PickingInterface, LoggingInterface, ToolbarInterface, ContextMenuInterface, PythonInterface
{
Q_OBJECT
Q_INTERFACES(BaseInterface)
......@@ -90,6 +88,7 @@ class ViewControlPlugin : public QObject, BaseInterface , PickingInterface, Logg
Q_INTERFACES(LoggingInterface)
Q_INTERFACES(ToolbarInterface)
Q_INTERFACES(ContextMenuInterface)
Q_INTERFACES(PythonInterface)
Q_PLUGIN_METADATA(IID "org.OpenFlipper.Plugins.Plugin-ViewControl")
......@@ -355,4 +354,4 @@ class ViewControlPlugin : public QObject, BaseInterface , PickingInterface, Logg
};
#endif //ViewControlPlugin_HH
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment