Commit cbfb87f3 authored by Jan Möbius's avatar Jan Möbius

Example usage for Vector type via Python

parent 525171a4
......@@ -2,15 +2,26 @@
#include <pybind11/include/pybind11/pybind11.h>
#include <pybind11/include/pybind11/embed.h>
#include <ViewControlPlugin.hh>
#include <OpenFlipper/BasePlugin/PythonFunctions.hh>
#include <OpenFlipper/PythonInterpreter/PythonTypeConversions.hh>
namespace py = pybind11;
QObject* pluginPointer = getPluginPointer("ViewControl");
ViewControlPlugin* plugin = qobject_cast<ViewControlPlugin*>(pluginPointer);
if (!plugin) {
std::cerr << "Error Getting plugin pointer for Plugin-ViewControl" << std::endl;
// 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");
......@@ -18,7 +29,7 @@ PYBIND11_EMBEDDED_MODULE(ViewControl, m) {
// 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(py::init([&plugin]() { return plugin; }));
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") );
......@@ -26,5 +37,7 @@ PYBIND11_EMBEDDED_MODULE(ViewControl, m) {
view.def("orthographicProjection", static_cast<void (ViewControlPlugin::*)()>(&ViewControlPlugin::orthographicProjection) );
view.def("orthographicProjection", static_cast<void (ViewControlPlugin::*)(int)>(&ViewControlPlugin::orthographicProjection) );
view.def("translate", &ViewControlPlugin::translate,"Translate Scene",py::arg("Vector for the translation."),py::arg("Viewer id (default is all)")=PluginFunctions::ALL_VIEWERS );
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