From 4fb000f0c8e545d388f8e07a9b0b73fd79169cbc Mon Sep 17 00:00:00 2001 From: wmayer Date: Sun, 9 Feb 2014 15:28:43 +0100 Subject: [PATCH] + expose zoomIn/zoomOut to Python --- src/Gui/View3DPy.cpp | 44 ++++++++++++++++++++++++++++++++++++++++++++ src/Gui/View3DPy.h | 2 ++ 2 files changed, 46 insertions(+) diff --git a/src/Gui/View3DPy.cpp b/src/Gui/View3DPy.cpp index 8a49232af..63899b9aa 100644 --- a/src/Gui/View3DPy.cpp +++ b/src/Gui/View3DPy.cpp @@ -83,6 +83,8 @@ void View3DInventorPy::init_type() add_varargs_method("viewAxometric",&View3DInventorPy::viewAxometric,"viewAxometric()"); add_varargs_method("viewRotateLeft",&View3DInventorPy::viewRotateLeft,"viewRotateLeft()"); add_varargs_method("viewRotateRight",&View3DInventorPy::viewRotateRight,"viewRotateRight()"); + add_varargs_method("zoomIn",&View3DInventorPy::zoomIn,"zoomIn()"); + add_varargs_method("zoomOut",&View3DInventorPy::zoomOut,"zoomOut()"); add_varargs_method("viewPosition",&View3DInventorPy::viewPosition,"viewPosition()"); add_varargs_method("startAnimating",&View3DInventorPy::startAnimating,"startAnimating()"); add_varargs_method("stopAnimating",&View3DInventorPy::stopAnimating,"stopAnimating()"); @@ -473,6 +475,48 @@ Py::Object View3DInventorPy::viewRotateRight(const Py::Tuple& args) return Py::None(); } +Py::Object View3DInventorPy::zoomIn(const Py::Tuple& args) +{ + if (!PyArg_ParseTuple(args.ptr(), "")) + throw Py::Exception(); + + try { + _view->getViewer()->navigationStyle()->zoomIn(); + } + 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::zoomOut(const Py::Tuple& args) +{ + if (!PyArg_ParseTuple(args.ptr(), "")) + throw Py::Exception(); + + try { + _view->getViewer()->navigationStyle()->zoomOut(); + } + 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::setCameraOrientation(const Py::Tuple& args) { PyObject* o; diff --git a/src/Gui/View3DPy.h b/src/Gui/View3DPy.h index 932a709d7..7e934163b 100644 --- a/src/Gui/View3DPy.h +++ b/src/Gui/View3DPy.h @@ -58,6 +58,8 @@ public: Py::Object viewPosition(const Py::Tuple&); Py::Object viewRotateLeft(const Py::Tuple&); Py::Object viewRotateRight(const Py::Tuple&); + Py::Object zoomIn(const Py::Tuple&); + Py::Object zoomOut(const Py::Tuple&); Py::Object startAnimating(const Py::Tuple&); Py::Object stopAnimating(const Py::Tuple&); Py::Object setAnimationEnabled(const Py::Tuple&);