Squashed commit of the following:

commit 89eb699e69c05dda0ebecf4aa22acc85386ede8f
Author: looooo <sppedflyer@gmail.com>
Date:   Wed Apr 27 21:43:16 2016 +0200

    added close function

commit 2acc25adbc9df47194934ef4db18383919248c7d
Author: looooo <sppedflyer@gmail.com>
Date:   Wed Apr 27 21:12:18 2016 +0200

    some additions to the split-view-bindings

commit ec366d154a96a71c7716900f4de1c109a9160df8
Author: looooo <sppedflyer@gmail.com>
Date:   Sun Apr 24 20:55:26 2016 +0200

    SplitView: Antia-Aliasing, getViewer, handlinging of deletion
    added anti-aliasing for the SplitView3DInventor class
    added method getViewer to the AbstractSplitView
    delete python-object when c++ object gets deleted

commit 7225cd836b0001d302c9e14328b5eb7dd489cdb1
Author: looooo <sppedflyer@gmail.com>
Date:   Sun Apr 24 15:28:57 2016 +0200

    added function Gui.createViewer([int])->Viewer/SplitViewer
This commit is contained in:
wmayer
2016-05-01 15:46:53 +02:00
parent 8e19a2064f
commit c5aebfa872
6 changed files with 217 additions and 21 deletions

View File

@@ -31,6 +31,8 @@
#include "View3DViewerPy.h"
#include <CXX/Objects.hxx>
#include <Base/Interpreter.h>
#include <Base/GeometryPyCXX.h>
#include <Base/VectorPy.h>
#include <Gui/View3DInventorViewer.h>
using namespace Gui;
@@ -66,7 +68,7 @@ void View3DInventorViewerPy::init_type()
);
add_varargs_method("setFocalDistance",&View3DInventorViewerPy::setFocalDistance,"setFocalDistance(float) -> None\n");
add_varargs_method("getFocalDistance",&View3DInventorViewerPy::getFocalDistance,"getFocalDistance() -> float\n");
add_varargs_method("getPoint", &View3DInventorViewerPy::getPoint, "getPoint(x, y) -> Base::Vector(x,y,z)");
}
View3DInventorViewerPy::View3DInventorViewerPy(View3DInventorViewer *vi)
@@ -258,3 +260,24 @@ Py::Object View3DInventorViewerPy::getFocalDistance(const Py::Tuple& args)
throw Py::Exception("Unknown C++ exception");
}
}
Py::Object View3DInventorViewerPy::getPoint(const Py::Tuple& args)
{
short x,y;
if (!PyArg_ParseTuple(args.ptr(), "hh", &x, &y)) {
PyErr_Clear();
Py::Tuple t(args[0]);
x = (int)Py::Int(t[0]);
y = (int)Py::Int(t[1]);
}
try {
SbVec3f pt = _viewer->getPointOnScreen(SbVec2s(x,y));
return Py::Vector(Base::Vector3f(pt[0], pt[1], pt[2]));
}
catch (const Base::Exception& e) {
throw Py::Exception(e.what());
}
catch (const Py::Exception&) {
throw;
}
}