Skip to content

Commit

Permalink
expose methods to Python to change navi cube settings
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Jul 29, 2018
1 parent c2ada8e commit e6658ed
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/Gui/View3DViewerPy.cpp
Expand Up @@ -75,6 +75,13 @@ void View3DInventorViewerPy::init_type()
"getPickRadius(): returns radius of confusion in pixels for picking objects on screen (selection).");
add_varargs_method("setPickRadius", &View3DInventorViewerPy::setPickRadius,
"setPickRadius(new_radius): sets radius of confusion in pixels for picking objects on screen (selection).");
add_varargs_method("setEnabledNaviCube", &View3DInventorViewerPy::setEnabledNaviCube,
"setEnabledNaviCube(bool): enables or disables the navi cube of the viewer.");
add_varargs_method("isEnabledNaviCube", &View3DInventorViewerPy::isEnabledNaviCube,
"isEnabledNaviCube() -> bool: check whether the navi cube is enabled.");
add_varargs_method("setNaviCubeCorner", &View3DInventorViewerPy::setNaviCubeCorner,
"setNaviCubeCorner(int): sets the corner where to show the navi cube:\n"
"0=top left, 1=top right, 2=bottom left, 3=bottom right");
}

View3DInventorViewerPy::View3DInventorViewerPy(View3DInventorViewer *vi)
Expand Down Expand Up @@ -351,3 +358,31 @@ Py::Object View3DInventorViewerPy::setPickRadius(const Py::Tuple& args)
throw Py::RuntimeError("Unknown C++ exception");
}
}

Py::Object View3DInventorViewerPy::setEnabledNaviCube(const Py::Tuple& args)
{
PyObject* m=Py_False;
if (!PyArg_ParseTuple(args.ptr(), "O!", &PyBool_Type, &m))
throw Py::Exception();
_viewer->setEnabledNaviCube(PyObject_IsTrue(m));
return Py::None();
}

Py::Object View3DInventorViewerPy::isEnabledNaviCube(const Py::Tuple& args)
{
if (!PyArg_ParseTuple(args.ptr(), ""))
throw Py::Exception();
bool ok = _viewer->isEnabledNaviCube();
return Py::Boolean(ok);
}

Py::Object View3DInventorViewerPy::setNaviCubeCorner(const Py::Tuple& args)
{
int pos;
if (!PyArg_ParseTuple(args.ptr(), "i", &pos))
throw Py::Exception();
if (pos < 0 || pos > 3)
throw Py::IndexError("Value out of range");
_viewer->setNaviCubeCorner(pos);
return Py::None();
}
4 changes: 4 additions & 0 deletions src/Gui/View3DViewerPy.h
Expand Up @@ -65,6 +65,10 @@ class View3DInventorViewerPy : public Py::PythonExtension<View3DInventorViewerPy
Py::Object getPickRadius(const Py::Tuple& args);
Py::Object setPickRadius(const Py::Tuple& args);

// NaviCube handling
Py::Object setEnabledNaviCube(const Py::Tuple& args);
Py::Object isEnabledNaviCube(const Py::Tuple& args);
Py::Object setNaviCubeCorner(const Py::Tuple& args);


private:
Expand Down

0 comments on commit e6658ed

Please sign in to comment.