diff --git a/src/Gui/Application.cpp b/src/Gui/Application.cpp index aaf0aa1d9..18fca7a49 100644 --- a/src/Gui/Application.cpp +++ b/src/Gui/Application.cpp @@ -409,13 +409,14 @@ Application::Application(bool GUIenabled) } // Python console binding - PythonDebugModule ::init_module(); - PythonStdout ::init_type(); - PythonStderr ::init_type(); - OutputStdout ::init_type(); - OutputStderr ::init_type(); - PythonStdin ::init_type(); - View3DInventorPy ::init_type(); + PythonDebugModule ::init_module(); + PythonStdout ::init_type(); + PythonStderr ::init_type(); + OutputStdout ::init_type(); + OutputStderr ::init_type(); + PythonStdin ::init_type(); + View3DInventorPy ::init_type(); + View3DInventorViewerPy ::init_type(); d = new ApplicationP; diff --git a/src/Gui/CMakeLists.txt b/src/Gui/CMakeLists.txt index c6e9e43b2..a3f334c4d 100644 --- a/src/Gui/CMakeLists.txt +++ b/src/Gui/CMakeLists.txt @@ -661,6 +661,7 @@ SET(View3D_CPP_SRCS View3DInventorRiftViewer.cpp CoinRiftWidget.cpp View3DPy.cpp + View3DViewerPy.cpp ) SET(View3D_SRCS ${View3D_CPP_SRCS} @@ -675,8 +676,8 @@ SET(View3D_SRCS View3DInventorViewer.h View3DPy.h View3DInventorRiftViewer.h - CoinRiftWidget.h - + CoinRiftWidget.h + View3DViewerPy.h ) SOURCE_GROUP("View3D" FILES ${View3D_SRCS}) diff --git a/src/Gui/View3DInventorViewer.cpp b/src/Gui/View3DInventorViewer.cpp index 2a87b70fe..ac547e401 100644 --- a/src/Gui/View3DInventorViewer.cpp +++ b/src/Gui/View3DInventorViewer.cpp @@ -115,6 +115,7 @@ #include "GLPainter.h" #include #include +#include "View3DViewerPy.h" #include @@ -1437,6 +1438,14 @@ SbVec3f View3DInventorViewer::getViewDirection() const return lookat; } +void View3DInventorViewer::setViewDirection(SbVec3f dir) +{ + SoCamera* cam = this->getSoRenderManager()->getCamera(); + if (cam) + cam->orientation.setValue(SbRotation(SbVec3f(0, 0, -1), dir)); +} + + SbVec3f View3DInventorViewer::getUpDirection() const { SoCamera* cam = this->getSoRenderManager()->getCamera(); @@ -2610,3 +2619,11 @@ View3DInventorViewer::AntiAliasing View3DInventorViewer::getAntiAliasingMode() c }; } +PyObject *View3DInventorViewer::getPyObject(void) +{ + if (!_viewerPy) + _viewerPy = new View3DInventorViewerPy(this); + + Py_INCREF(_viewerPy); + return _viewerPy; +} diff --git a/src/Gui/View3DInventorViewer.h b/src/Gui/View3DInventorViewer.h index 6ae2b68f3..191870206 100644 --- a/src/Gui/View3DInventorViewer.h +++ b/src/Gui/View3DInventorViewer.h @@ -253,6 +253,7 @@ public: * The vector is normalized to length of 1. */ SbVec3f getViewDirection() const; + void setViewDirection(SbVec3f); /** Returns the up direction */ SbVec3f getUpDirection() const; /** Returns the orientation of the camera. */ @@ -343,6 +344,8 @@ public: NavigationStyle* navigationStyle() const; void setDocument(Gui::Document *pcDocument); + + virtual PyObject *getPyObject(void); protected: void renderScene(); @@ -406,6 +409,8 @@ private: std::string overrideMode; ViewerEventFilter* viewerEventFilter; + + PyObject *_viewerPy; // friends friend class NavigationStyle; diff --git a/src/Gui/View3DPy.cpp b/src/Gui/View3DPy.cpp index 22d82c4d7..dc4f93aad 100644 --- a/src/Gui/View3DPy.cpp +++ b/src/Gui/View3DPy.cpp @@ -47,6 +47,7 @@ #include "SoFCDB.h" #include "View3DInventor.h" #include "View3DInventorViewer.h" +#include "View3DViewerPy.h" #include #include @@ -101,7 +102,13 @@ void View3DInventorPy::init_type() add_varargs_method("saveVectorGraphic",&View3DInventorPy::saveVectorGraphic,"saveVectorGraphic()"); add_varargs_method("getCamera",&View3DInventorPy::getCamera,"getCamera()"); add_varargs_method("getCameraNode",&View3DInventorPy::getCameraNode,"getCameraNode()"); - add_varargs_method("getViewDirection",&View3DInventorPy::getViewDirection,"getViewDirection()"); + add_varargs_method("getViewDirection",&View3DInventorPy::getViewDirection,"getViewDirection() --> tuple of integers\n" + "returns the direction vector the view is currently pointing at as tuple with xyz values\n" + ); + add_varargs_method("setViewDirection",&View3DInventorPy::setViewDirection,"setViewDirection(tuple) --> None\n" + "Sets the direction the view is pointing at. The direction must be given as tuple with\n" + "three coordinates xyz" + ); add_varargs_method("setCamera",&View3DInventorPy::setCamera,"setCamera()"); add_varargs_method("setCameraOrientation",&View3DInventorPy::setCameraOrientation,"setCameraOrientation()"); add_varargs_method("getCameraOrientation",&View3DInventorPy::getCameraOrientation,"getCameraOrientation()"); @@ -834,6 +841,43 @@ Py::Object View3DInventorPy::getViewDirection(const Py::Tuple& args) } } +Py::Object View3DInventorPy::setViewDirection(const Py::Tuple& args) +{ + PyObject* object; + if (!PyArg_ParseTuple(args.ptr(), "O", &object)) + throw Py::Exception(); + + try { + if (PyTuple_Check(object)) { + Py::Tuple tuple(object); + Py::Float x(tuple.getItem(0)); + Py::Float y(tuple.getItem(1)); + Py::Float z(tuple.getItem(2)); + SbVec3f dir; + dir.setValue((float)x, (float)y, (float)z); + if (dir.length() < 0.001f) + throw Py::ValueError("Null vector cannot be used to set direction"); + _view->getViewer()->setViewDirection(dir); + return Py::None(); + } + } + catch (const Py::Exception&) { + throw; // re-throw + } + catch (const Base::Exception& e) { + throw Py::Exception(e.what()); + } + catch (const std::exception& e) { + throw Py::Exception(e.what()); + } + catch(...) { + throw Py::Exception("Unknown C++ exception"); + } + + return Py::None(); + +} + Py::Object View3DInventorPy::setCamera(const Py::Tuple& args) { @@ -1801,227 +1845,13 @@ Py::Object View3DInventorPy::getSceneGraph(const Py::Tuple& args) } } -// ----------------------------------------------------------------- - -static PyObject * -wrap_SoQtViewer_setViewDirection(PyObject *proxy, PyObject *args) -{/* - PyObject* object; - if (!PyArg_ParseTuple(args, "O", &object)) // convert args: Python->C - return NULL; // NULL triggers exception - - void* ptr = 0; - try { - Base::Interpreter().convertSWIGPointerObj("pivy.gui.soqt", "SoQtViewer *", proxy, &ptr, 0); - } - catch (const Base::Exception& e) { - PyErr_SetString(PyExc_RuntimeError, e.what()); - return 0; - } - - SoQtViewer* viewer = reinterpret_cast(ptr); - try { - Py::Tuple tuple(object); - Py::Float x(tuple.getItem(0)); - Py::Float y(tuple.getItem(1)); - Py::Float z(tuple.getItem(2)); - SbVec3f dir; - dir.setValue((float)x, (float)y, (float)z); - if (dir.length() < 0.001f) - throw Py::ValueError("Null vector cannot be used to set direction"); - SoCamera* cam = viewer->getCamera(); - if (cam) - cam->orientation.setValue(SbRotation(SbVec3f(0, 0, -1), dir)); - return Py::new_reference_to(Py::None()); - } - catch (Py::Exception&) { - return NULL; - }*/ -} - -static PyObject * -wrap_SoQtViewer_getViewDirection(PyObject *proxy, PyObject *args) -{/* - if (!PyArg_ParseTuple(args, "")) // convert args: Python->C - return NULL; // NULL triggers exception - - void* ptr = 0; - try { - Base::Interpreter().convertSWIGPointerObj("pivy.gui.soqt", "SoQtViewer *", proxy, &ptr, 0); - } - catch (const Base::Exception& e) { - PyErr_SetString(PyExc_RuntimeError, e.what()); - return 0; - } - - SoQtViewer* viewer = reinterpret_cast(ptr); - try { - SoCamera* cam = viewer->getCamera(); - if (!cam) { - PyErr_SetString(PyExc_RuntimeError, "No camera set"); - return 0; - } - SbRotation camrot = cam->orientation.getValue(); - SbVec3f lookat(0, 0, -1); // init to default view direction vector - camrot.multVec(lookat, lookat); - - Py::Tuple tuple(3); - tuple.setItem(0, Py::Float(lookat[0])); - tuple.setItem(1, Py::Float(lookat[1])); - tuple.setItem(2, Py::Float(lookat[2])); - return Py::new_reference_to(tuple); - } - catch (Py::Exception&) { - return NULL; - }*/ -} - -static PyObject * -wrap_SoQtViewer_setFocalDistance(PyObject *proxy, PyObject *args) -{/* - float distance; - if (!PyArg_ParseTuple(args, "f", &distance)) // convert args: Python->C - return NULL; // NULL triggers exception - - void* ptr = 0; - try { - Base::Interpreter().convertSWIGPointerObj("pivy.gui.soqt", "SoQtViewer *", proxy, &ptr, 0); - } - catch (const Base::Exception& e) { - PyErr_SetString(PyExc_RuntimeError, e.what()); - return 0; - } - - SoQtViewer* viewer = reinterpret_cast(ptr); - PY_TRY { - SoCamera* cam = viewer->getCamera(); - if (cam) - cam->focalDistance.setValue(distance); - } PY_CATCH; - - Py_Return;*/ -} - -static PyObject * -wrap_SoQtViewer_getFocalDistance(PyObject *proxy, PyObject *args) -{/* - if (!PyArg_ParseTuple(args, "")) // convert args: Python->C - return NULL; // NULL triggers exception - - void* ptr = 0; - try { - Base::Interpreter().convertSWIGPointerObj("pivy.gui.soqt", "SoQtViewer *", proxy, &ptr, 0); - } - catch (const Base::Exception& e) { - PyErr_SetString(PyExc_RuntimeError, e.what()); - return 0; - } - - SoQtViewer* viewer = reinterpret_cast(ptr); - double dist = 0; - SoCamera* cam = viewer->getCamera(); - if (cam) dist = cam->focalDistance.getValue(); - return PyFloat_FromDouble(dist);*/ -} - -static PyObject * -wrap_SoQtViewer_seekToPoint(PyObject *proxy, PyObject *args) -{/* - PyObject* object; - if (!PyArg_ParseTuple(args, "O", &object)) // convert args: Python->C - return NULL; // NULL triggers exception - - void* ptr = 0; - try { - Base::Interpreter().convertSWIGPointerObj("pivy.gui.soqt", "SoQtViewer *", proxy, &ptr, 0); - } - catch (const Base::Exception& e) { - PyErr_SetString(PyExc_RuntimeError, e.what()); - return 0; - } - - View3DInventorViewer* viewer = reinterpret_cast(ptr); - try { - const Py::Tuple tuple(object); - - // If the 3d point is given - if (tuple.size() == 3) { - Py::Float x = tuple[0]; - Py::Float y = tuple[1]; - Py::Float z = tuple[2]; - - SbVec3f hitpoint((float)x,(float)y,(float)z); - viewer->pubSeekToPoint(hitpoint); - } - else { - Py::Int x(tuple[0]); - Py::Int y(tuple[1]); - - SbVec2s hitpoint ((long)x,(long)y); - viewer->pubSeekToPoint(hitpoint); - } - - return Py::new_reference_to(Py::None()); // increment ref counter - } - catch (const Py::Exception&) { - return NULL; - }*/ -} - -struct PyMethodDef wrap_SoQtViewer_methods[] = { - {"setViewDirection",wrap_SoQtViewer_setViewDirection,METH_VARARGS, - "setViewDirection(tuple) -> None"}, - {"getViewDirection",wrap_SoQtViewer_getViewDirection,METH_VARARGS, - "getViewDirection() -> tuple"}, - {"setFocalDistance",wrap_SoQtViewer_setFocalDistance,METH_VARARGS, - "setFocalDistance(float) -> None"}, - {"getFocalDistance",wrap_SoQtViewer_getFocalDistance,METH_VARARGS, - "getFocalDistance() -> float"}, - {"seekToPoint",wrap_SoQtViewer_seekToPoint,METH_VARARGS, - "seekToPoint(tuple) -> None\n" - "Initiate a seek action towards the 3D intersection of the scene and the\n" - "ray from the screen coordinate's point and in the same direction as the\n" - "camera is pointing"}, - {NULL, NULL} /* sentinel */ -}; - Py::Object View3DInventorPy::getViewer(const Py::Tuple& args) { if (!PyArg_ParseTuple(args.ptr(), "")) throw Py::Exception(); - PyObject* proxy = 0; - try { - // Note: As there is no ref'counting mechanism for the viewer class we must - // pass '0' as the third parameter so that the Python object does not 'own' - // the viewer. - // Note: Once we have closed the viewer the Python object must not be used - // anymore as it has a dangling pointer. - Quarter::SoQTQuarterAdaptor* view = _view->getViewer(); - proxy = Base::Interpreter().createSWIGPointerObj("pivy.gui.soqt", "SoQtViewer *", (void*)view, 0); - } - catch (const Base::Exception& e) { - throw Py::Exception(e.what()); - } - - // Add some additional methods to the viewer's type object - static bool first=true; - if (first && proxy) { - first = false; - PyMethodDef *meth = wrap_SoQtViewer_methods; - PyTypeObject *type = proxy->ob_type; - PyObject *dict = type->tp_dict; - for (; meth->ml_name != NULL; meth++) { - PyObject *descr; - descr = PyDescr_NewMethod(type, meth); - if (descr == NULL) - break; - if (PyDict_SetItemString(dict, meth->ml_name, descr) < 0) - break; - Py_DECREF(descr); - } - } - return Py::Object(proxy, true); // no further incremention needed + View3DInventorViewer* viewer = _view->getViewer(); + return Py::Object(viewer->getPyObject(), true); } void View3DInventorPy::eventCallbackPivy(void * ud, SoEventCallback * n) diff --git a/src/Gui/View3DPy.h b/src/Gui/View3DPy.h index c5a9caabd..77cf3c180 100644 --- a/src/Gui/View3DPy.h +++ b/src/Gui/View3DPy.h @@ -73,6 +73,7 @@ public: Py::Object saveVectorGraphic(const Py::Tuple&); Py::Object getCamera(const Py::Tuple&); Py::Object getViewDirection(const Py::Tuple&); + Py::Object setViewDirection(const Py::Tuple&); Py::Object setCamera(const Py::Tuple&); Py::Object setCameraOrientation(const Py::Tuple&); Py::Object getCameraOrientation(const Py::Tuple&); diff --git a/src/Gui/View3DViewerPy.cpp b/src/Gui/View3DViewerPy.cpp new file mode 100644 index 000000000..4c4da1fe7 --- /dev/null +++ b/src/Gui/View3DViewerPy.cpp @@ -0,0 +1,260 @@ +/*************************************************************************** + * Copyright (c) Stefan Tröger (stefantroeger@gmx.net) 2014 * + * * + * 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 __InventorAll__ +# include "InventorAll.h" +#endif + + +#include "View3DViewerPy.h" +#include +#include +#include + +using namespace Gui; + + +void View3DInventorViewerPy::init_type() +{ + behaviors().name("View3DInventorViewerPy"); + behaviors().doc("Python binding class for the 3D viewer class"); + // you must have overwritten the virtual functions + behaviors().supportRepr(); + behaviors().supportGetattr(); + behaviors().supportSetattr(); + + add_varargs_method("getSoRenderManager",&View3DInventorViewerPy::getSoRenderManager,"getSoRenderManager() -> SoRenderManager\n" + "Returns the render manager which is used to handle everything related to\n" + "rendering the scene graph. It can be used to get full control over the\n" + "render process\n" + ); + add_varargs_method("getSoEventManager",&View3DInventorViewerPy::getSoEventManager,"getSoEventManager() -> SoEventManager\n" + "Returns the event manager which is used to handle everything event related in\n" + "the viewer. It can be used to change the event processing. This must however be\n" + "done very carefully to not change the user interaction in an unpredictable manner.\n" + ); + + add_varargs_method("seekToPoint",&View3DInventorViewerPy::seekToPoint,"seekToPoint(tuple) -> None\n" + "Initiate a seek action towards the 3D intersection of the scene and the\n" + "ray from the screen coordinate's point and in the same direction as the\n" + "camera is pointing. If the tuple has two entries it is interpretet as the\n" + "screen coordinates xy and the intersection point with the scene is\n" + "calculated. If three entries are given it is interpretet as the intersection\n" + "point xyz and the seek is done towards this point" + ); + add_varargs_method("setFocalDistance",&View3DInventorViewerPy::setFocalDistance,"setFocalDistance(float) -> None\n"); + add_varargs_method("getFocalDistance",&View3DInventorViewerPy::getFocalDistance,"getFocalDistance() -> float\n"); + +} + +View3DInventorViewerPy::View3DInventorViewerPy(View3DInventorViewer *vi) + : _viewer(vi) +{ +} + +View3DInventorViewerPy::~View3DInventorViewerPy() +{ + Base::PyGILStateLocker lock; + for (std::list::iterator it = callbacks.begin(); it != callbacks.end(); ++it) + Py_DECREF(*it); +} + + +Py::Object View3DInventorViewerPy::repr() +{ + std::ostringstream s_out; + if (!_viewer) + throw Py::RuntimeError("Cannot print representation of deleted object"); + s_out << "View3DInventorViewer"; + return Py::String(s_out.str()); +} + +View3DInventorViewerPy::method_varargs_handler View3DInventorViewerPy::pycxx_handler = 0; + +PyObject *View3DInventorViewerPy::method_varargs_ext_handler(PyObject *_self_and_name_tuple, PyObject *_args) +{ + try { + return pycxx_handler(_self_and_name_tuple, _args); + } + catch (const Base::Exception& e) { + throw Py::Exception(e.what()); + } + catch (const std::exception& e) { + throw Py::Exception(e.what()); + } + catch(...) { + throw Py::Exception("Unknown C++ exception"); + } +} + +Py::Object View3DInventorViewerPy::getattr(const char * attr) +{ + if (!_viewer) { + std::string s; + std::ostringstream s_out; + s_out << "Cannot access attribute '" << attr << "' of deleted object"; + throw Py::RuntimeError(s_out.str()); + } + else { + Py::Object obj = Py::PythonExtension::getattr(attr); + if (PyCFunction_Check(obj.ptr())) { + PyCFunctionObject* op = reinterpret_cast(obj.ptr()); + if (!pycxx_handler) + pycxx_handler = op->m_ml->ml_meth; + op->m_ml->ml_meth = method_varargs_ext_handler; + } + return obj; + } +} + +int View3DInventorViewerPy::setattr(const char * attr, const Py::Object & value) +{ + if (!_viewer) { + std::string s; + std::ostringstream s_out; + s_out << "Cannot access attribute '" << attr << "' of deleted object"; + throw Py::RuntimeError(s_out.str()); + } + else { + return Py::PythonExtension::setattr(attr, value); + } +} + +Py::Object View3DInventorViewerPy::getSoRenderManager(const Py::Tuple& args) +{ + + if (!PyArg_ParseTuple(args.ptr(), "")) + throw Py::Exception(); + + try { + SoEventManager* manager = _viewer->getSoEventManager(); + PyObject* proxy = 0; + proxy = Base::Interpreter().createSWIGPointerObj("pivy.coin", "SoEventManager *", (void*)manager, 1); + return Py::Object(proxy, true); + } + catch (const Base::Exception& e) { + throw Py::Exception(e.what()); + } +} + +Py::Object View3DInventorViewerPy::getSoEventManager(const Py::Tuple& args) +{ + if (!PyArg_ParseTuple(args.ptr(), "")) + throw Py::Exception(); + + try { + SoRenderManager* manager = _viewer->getSoRenderManager(); + PyObject* proxy = 0; + proxy = Base::Interpreter().createSWIGPointerObj("pivy.coin", "SoRenderManager *", (void*)manager, 1); + return Py::Object(proxy, true); + } + catch (const Base::Exception& e) { + throw Py::Exception(e.what()); + } +} + + +Py::Object View3DInventorViewerPy::seekToPoint(const Py::Tuple& args) +{ + PyObject* object; + if (!PyArg_ParseTuple(args.ptr(), "O", &object)) + throw Py::Exception(); + + try { + const Py::Tuple tuple(object); + + // If the 3d point is given + if (tuple.size() == 3) { + Py::Float x = tuple[0]; + Py::Float y = tuple[1]; + Py::Float z = tuple[2]; + + SbVec3f hitpoint((float)x,(float)y,(float)z); + _viewer->seekToPoint(hitpoint); + } + else { + Py::Int x(tuple[0]); + Py::Int y(tuple[1]); + + SbVec2s hitpoint ((long)x,(long)y); + _viewer->seekToPoint(hitpoint); + } + + return Py::None(); + } + catch (const Py::Exception&) { + throw; + } + + return Py::None(); +} + + +Py::Object View3DInventorViewerPy::setFocalDistance(const Py::Tuple& args) +{ + float distance; + if (!PyArg_ParseTuple(args.ptr(), "f", &distance)) + throw Py::Exception(); + + try { + SoCamera* cam = _viewer->getSoRenderManager()->getCamera(); + if (cam) + cam->focalDistance.setValue(distance); + } + catch (const Py::Exception&) { + throw; // re-throw + } + catch (const Base::Exception& e) { + throw Py::Exception(e.what()); + } + catch (const std::exception& e) { + throw Py::Exception(e.what()); + } + catch(...) { + throw Py::Exception("Unknown C++ exception"); + } + + return Py::None(); +} + +Py::Object View3DInventorViewerPy::getFocalDistance(const Py::Tuple& args) +{ + if (!PyArg_ParseTuple(args.ptr(), "")) + throw Py::Exception(); + + try { + double d = _viewer->getSoRenderManager()->getCamera()->focalDistance.getValue(); + return Py::Float(d); + } + catch (const Base::Exception& e) { + throw Py::Exception(e.what()); + } + catch (const std::exception& e) { + throw Py::Exception(e.what()); + } + catch(...) { + throw Py::Exception("Unknown C++ exception"); + } +} \ No newline at end of file diff --git a/src/Gui/View3DViewerPy.h b/src/Gui/View3DViewerPy.h new file mode 100644 index 000000000..48cf565f7 --- /dev/null +++ b/src/Gui/View3DViewerPy.h @@ -0,0 +1,77 @@ +/*************************************************************************** + * Copyright (c) Stefan Tröger (stefantroeger@gmx.net) 2014 * + * * + * 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 * + * * + ***************************************************************************/ + + +#ifndef GUI_VIEW3DVIEWERPY_H +#define GUI_VIEW3DVIEWERPY_H + +#include +#include + +namespace Gui { + +class View3DInventorViewer; + +/** + * @brief Python interface for View3DInventorViewer + * + * The interface does not offer all methods the c++ View3DInventorViewer counterpart has, respectivly + * also not everything the QuarterWidget and the SoQtQuarterAdaptor offers. It only exposes + * methods with additioanl functionality in comparison to the View3DInventorPy class. Everything that + * can be done from there has no interface here. + */ +class View3DInventorViewerPy : public Py::PythonExtension +{ +public: + static void init_type(void); // announce properties and methods + + View3DInventorViewerPy(View3DInventorViewer *vi); + ~View3DInventorViewerPy(); + + Py::Object repr(); + Py::Object getattr(const char *); + int setattr(const char *, const Py::Object &); + + //exposed methods + Py::Object getSoEventManager(const Py::Tuple&); + Py::Object getSoRenderManager(const Py::Tuple&); + + Py::Object seekToPoint(const Py::Tuple&); + Py::Object setFocalDistance(const Py::Tuple& args); + Py::Object getFocalDistance(const Py::Tuple& args); + + +private: + private: + typedef PyObject* (*method_varargs_handler)(PyObject *_self, PyObject *_args); + static method_varargs_handler pycxx_handler; + static PyObject *method_varargs_ext_handler(PyObject *_self, PyObject *_args); + +private: + std::list callbacks; + View3DInventorViewer* _viewer; + friend class View3DInventorViewer; +}; + +} // namespace Gui + +#endif //GUI_VIEW3DPY_H