prepare for PyCXX 7.0

This commit is contained in:
wmayer
2018-04-18 19:20:50 +02:00
parent 08286c407e
commit 99ec96acd5
36 changed files with 226 additions and 239 deletions

View File

@@ -211,13 +211,13 @@ PyObject *View3DInventorPy::method_varargs_ext_handler(PyObject *_self_and_name_
return pycxx_handler(_self_and_name_tuple, _args);
}
catch (const Base::Exception& e) {
throw Py::Exception(e.what());
throw Py::RuntimeError(e.what());
}
catch (const std::exception& e) {
throw Py::Exception(e.what());
throw Py::RuntimeError(e.what());
}
catch(...) {
throw Py::Exception("Unknown C++ exception");
throw Py::RuntimeError("Unknown C++ exception");
}
}
@@ -275,13 +275,13 @@ Py::Object View3DInventorPy::message(const Py::Tuple& args)
_view->onMsg(psMsgStr,ppReturn);
}
catch (const Base::Exception& e) {
throw Py::Exception(e.what());
throw Py::RuntimeError(e.what());
}
catch (const std::exception& e) {
throw Py::Exception(e.what());
throw Py::RuntimeError(e.what());
}
catch(...) {
throw Py::Exception("Unknown C++ exception");
throw Py::RuntimeError("Unknown C++ exception");
}
return Py::None();
}
@@ -296,13 +296,13 @@ Py::Object View3DInventorPy::fitAll(const Py::Tuple& args)
_view->getViewer()->viewAll((float)factor);
}
catch (const Base::Exception& e) {
throw Py::Exception(e.what());
throw Py::RuntimeError(e.what());
}
catch (const std::exception& e) {
throw Py::Exception(e.what());
throw Py::RuntimeError(e.what());
}
catch(...) {
throw Py::Exception("Unknown C++ exception");
throw Py::RuntimeError("Unknown C++ exception");
}
return Py::None();
}
@@ -329,13 +329,13 @@ Py::Object View3DInventorPy::viewBottom(const Py::Tuple& args)
_view->getViewer()->setCameraOrientation(SbRotation(0, -1, 0, 0));
}
catch (const Base::Exception& e) {
throw Py::Exception(e.what());
throw Py::RuntimeError(e.what());
}
catch (const std::exception& e) {
throw Py::Exception(e.what());
throw Py::RuntimeError(e.what());
}
catch(...) {
throw Py::Exception("Unknown C++ exception");
throw Py::RuntimeError("Unknown C++ exception");
}
return Py::None();
@@ -351,13 +351,13 @@ Py::Object View3DInventorPy::viewFront(const Py::Tuple& args)
_view->getViewer()->setCameraOrientation(SbRotation(-root, 0, 0, -root));
}
catch (const Base::Exception& e) {
throw Py::Exception(e.what());
throw Py::RuntimeError(e.what());
}
catch (const std::exception& e) {
throw Py::Exception(e.what());
throw Py::RuntimeError(e.what());
}
catch(...) {
throw Py::Exception("Unknown C++ exception");
throw Py::RuntimeError("Unknown C++ exception");
}
return Py::None();
@@ -372,13 +372,13 @@ Py::Object View3DInventorPy::viewLeft(const Py::Tuple& args)
_view->getViewer()->setCameraOrientation(SbRotation(-0.5, 0.5, 0.5, -0.5));
}
catch (const Base::Exception& e) {
throw Py::Exception(e.what());
throw Py::RuntimeError(e.what());
}
catch (const std::exception& e) {
throw Py::Exception(e.what());
throw Py::RuntimeError(e.what());
}
catch(...) {
throw Py::Exception("Unknown C++ exception");
throw Py::RuntimeError("Unknown C++ exception");
}
return Py::None();
@@ -394,13 +394,13 @@ Py::Object View3DInventorPy::viewRear(const Py::Tuple& args)
_view->getViewer()->setCameraOrientation(SbRotation(0, root, root, 0));
}
catch (const Base::Exception& e) {
throw Py::Exception(e.what());
throw Py::RuntimeError(e.what());
}
catch (const std::exception& e) {
throw Py::Exception(e.what());
throw Py::RuntimeError(e.what());
}
catch(...) {
throw Py::Exception("Unknown C++ exception");
throw Py::RuntimeError("Unknown C++ exception");
}
return Py::None();
@@ -415,13 +415,13 @@ Py::Object View3DInventorPy::viewRight(const Py::Tuple& args)
_view->getViewer()->setCameraOrientation(SbRotation(0.5, 0.5, 0.5, 0.5));
}
catch (const Base::Exception& e) {
throw Py::Exception(e.what());
throw Py::RuntimeError(e.what());
}
catch (const std::exception& e) {
throw Py::Exception(e.what());
throw Py::RuntimeError(e.what());
}
catch(...) {
throw Py::Exception("Unknown C++ exception");
throw Py::RuntimeError("Unknown C++ exception");
}
return Py::None();
@@ -436,13 +436,13 @@ Py::Object View3DInventorPy::viewTop(const Py::Tuple& args)
_view->getViewer()->setCameraOrientation(SbRotation(0, 0, 0, 1));
}
catch (const Base::Exception& e) {
throw Py::Exception(e.what());
throw Py::RuntimeError(e.what());
}
catch (const std::exception& e) {
throw Py::Exception(e.what());
throw Py::RuntimeError(e.what());
}
catch(...) {
throw Py::Exception("Unknown C++ exception");
throw Py::RuntimeError("Unknown C++ exception");
}
return Py::None();
@@ -471,13 +471,13 @@ Py::Object View3DInventorPy::viewAxonometric(const Py::Tuple& args)
(0.424708f, 0.17592f, 0.339851f, 0.820473f));
}
catch (const Base::Exception& e) {
throw Py::Exception(e.what());
throw Py::RuntimeError(e.what());
}
catch (const std::exception& e) {
throw Py::Exception(e.what());
throw Py::RuntimeError(e.what());
}
catch(...) {
throw Py::Exception("Unknown C++ exception");
throw Py::RuntimeError("Unknown C++ exception");
}
return Py::None();
@@ -497,13 +497,13 @@ Py::Object View3DInventorPy::viewRotateLeft(const Py::Tuple& args)
cam->orientation.setValue(rot*nrot);
}
catch (const Base::Exception& e) {
throw Py::Exception(e.what());
throw Py::RuntimeError(e.what());
}
catch (const std::exception& e) {
throw Py::Exception(e.what());
throw Py::RuntimeError(e.what());
}
catch(...) {
throw Py::Exception("Unknown C++ exception");
throw Py::RuntimeError("Unknown C++ exception");
}
return Py::None();
@@ -523,13 +523,13 @@ Py::Object View3DInventorPy::viewRotateRight(const Py::Tuple& args)
cam->orientation.setValue(rot*nrot);
}
catch (const Base::Exception& e) {
throw Py::Exception(e.what());
throw Py::RuntimeError(e.what());
}
catch (const std::exception& e) {
throw Py::Exception(e.what());
throw Py::RuntimeError(e.what());
}
catch(...) {
throw Py::Exception("Unknown C++ exception");
throw Py::RuntimeError("Unknown C++ exception");
}
return Py::None();
@@ -544,13 +544,13 @@ Py::Object View3DInventorPy::zoomIn(const Py::Tuple& args)
_view->getViewer()->navigationStyle()->zoomIn();
}
catch (const Base::Exception& e) {
throw Py::Exception(e.what());
throw Py::RuntimeError(e.what());
}
catch (const std::exception& e) {
throw Py::Exception(e.what());
throw Py::RuntimeError(e.what());
}
catch(...) {
throw Py::Exception("Unknown C++ exception");
throw Py::RuntimeError("Unknown C++ exception");
}
return Py::None();
@@ -565,13 +565,13 @@ Py::Object View3DInventorPy::zoomOut(const Py::Tuple& args)
_view->getViewer()->navigationStyle()->zoomOut();
}
catch (const Base::Exception& e) {
throw Py::Exception(e.what());
throw Py::RuntimeError(e.what());
}
catch (const std::exception& e) {
throw Py::Exception(e.what());
throw Py::RuntimeError(e.what());
}
catch(...) {
throw Py::Exception("Unknown C++ exception");
throw Py::RuntimeError("Unknown C++ exception");
}
return Py::None();
@@ -607,13 +607,13 @@ Py::Object View3DInventorPy::setCameraOrientation(const Py::Tuple& args)
throw; // re-throw
}
catch (const Base::Exception& e) {
throw Py::Exception(e.what());
throw Py::RuntimeError(e.what());
}
catch (const std::exception& e) {
throw Py::Exception(e.what());
throw Py::RuntimeError(e.what());
}
catch(...) {
throw Py::Exception("Unknown C++ exception");
throw Py::RuntimeError("Unknown C++ exception");
}
return Py::None();
@@ -750,14 +750,14 @@ Py::Object View3DInventorPy::saveVectorGraphic(const Py::Tuple& args)
vo = std::unique_ptr<SoVectorizeAction>(new SoFCVectorizeU3DAction());
}
else {
throw Py::Exception("Not supported vector graphic");
throw Py::RuntimeError("Not supported vector graphic");
}
SoVectorOutput * out = vo->getOutput();
if (!out || !out->openFile(filename)) {
std::ostringstream a_out;
a_out << "Cannot open file '" << filename << "'";
throw Py::Exception(a_out.str());
throw Py::RuntimeError(a_out.str());
}
QColor bg;
@@ -789,7 +789,7 @@ Py::Object View3DInventorPy::getCameraNode(const Py::Tuple& args)
return Py::Object(proxy, true);
}
catch (const Base::Exception& e) {
throw Py::Exception(e.what());
throw Py::RuntimeError(e.what());
}
}
@@ -810,13 +810,13 @@ Py::Object View3DInventorPy::getCamera(const Py::Tuple& args)
return Py::String(buffer);
}
catch (const Base::Exception& e) {
throw Py::Exception(e.what());
throw Py::RuntimeError(e.what());
}
catch (const std::exception& e) {
throw Py::Exception(e.what());
throw Py::RuntimeError(e.what());
}
catch(...) {
throw Py::Exception("Unknown C++ exception");
throw Py::RuntimeError("Unknown C++ exception");
}
}
@@ -829,13 +829,13 @@ Py::Object View3DInventorPy::getViewDirection(const Py::Tuple& args)
return Py::Vector(Base::Vector3f(dvec[0], dvec[1], dvec[2]));
}
catch (const Base::Exception& e) {
throw Py::Exception(e.what());
throw Py::RuntimeError(e.what());
}
catch (const std::exception& e) {
throw Py::Exception(e.what());
throw Py::RuntimeError(e.what());
}
catch(...) {
throw Py::Exception("Unknown C++ exception");
throw Py::RuntimeError("Unknown C++ exception");
}
}
@@ -863,13 +863,13 @@ Py::Object View3DInventorPy::setViewDirection(const Py::Tuple& args)
throw; // re-throw
}
catch (const Base::Exception& e) {
throw Py::Exception(e.what());
throw Py::RuntimeError(e.what());
}
catch (const std::exception& e) {
throw Py::Exception(e.what());
throw Py::RuntimeError(e.what());
}
catch(...) {
throw Py::Exception("Unknown C++ exception");
throw Py::RuntimeError("Unknown C++ exception");
}
return Py::None();
@@ -888,13 +888,13 @@ Py::Object View3DInventorPy::setCamera(const Py::Tuple& args)
return Py::None();
}
catch (const Base::Exception& e) {
throw Py::Exception(e.what());
throw Py::RuntimeError(e.what());
}
catch (const std::exception& e) {
throw Py::Exception(e.what());
throw Py::RuntimeError(e.what());
}
catch(...) {
throw Py::Exception("Unknown C++ exception");
throw Py::RuntimeError("Unknown C++ exception");
}
}
@@ -908,7 +908,7 @@ Py::Object View3DInventorPy::getCameraType(const Py::Tuple& args)
SoCamera* cam = _view->getViewer()->getSoRenderManager()->getCamera();
if (!cam) {
throw Py::Exception("No camera set!");
throw Py::RuntimeError("No camera set!");
}
else if (cam->getTypeId() == SoOrthographicCamera::getClassTypeId()) {
return Py::String(CameraTypeEnums[0]);
@@ -917,7 +917,7 @@ Py::Object View3DInventorPy::getCameraType(const Py::Tuple& args)
return Py::String(CameraTypeEnums[1]);
}
else {
throw Py::Exception("Unknown camera type");
throw Py::TypeError("Unknown camera type");
}
}
@@ -945,7 +945,7 @@ Py::Object View3DInventorPy::setCameraType(const Py::Tuple& args)
}
if (cameratype < 0 || cameratype > 1)
throw Py::Exception("Out of range");
throw Py::IndexError("Out of range");
if (cameratype==0)
_view->getViewer()->setCameraType(SoOrthographicCamera::getClassTypeId());
else
@@ -966,13 +966,13 @@ Py::Object View3DInventorPy::listCameraTypes(const Py::Tuple& args)
return list;
}
catch (const Base::Exception& e) {
throw Py::Exception(e.what());
throw Py::RuntimeError(e.what());
}
catch (const std::exception& e) {
throw Py::Exception(e.what());
throw Py::RuntimeError(e.what());
}
catch(...) {
throw Py::Exception("Unknown C++ exception");
throw Py::RuntimeError("Unknown C++ exception");
}
}
@@ -987,13 +987,13 @@ Py::Object View3DInventorPy::dump(const Py::Tuple& args)
return Py::None();
}
catch (const Base::Exception& e) {
throw Py::Exception(e.what());
throw Py::RuntimeError(e.what());
}
catch (const std::exception& e) {
throw Py::Exception(e.what());
throw Py::RuntimeError(e.what());
}
catch(...) {
throw Py::Exception("Unknown C++ exception");
throw Py::RuntimeError("Unknown C++ exception");
}
}
@@ -1008,7 +1008,7 @@ Py::Object View3DInventorPy::dumpNode(const Py::Tuple& args)
Base::Interpreter().convertSWIGPointerObj("pivy.coin", "SoNode *", object, &ptr, 0);
}
catch (const Base::Exception& e) {
throw Py::Exception(e.what());
throw Py::RuntimeError(e.what());
}
SoNode* node = reinterpret_cast<SoNode*>(ptr);
return Py::String(SoFCDB::writeNodesToString(node));
@@ -1042,19 +1042,19 @@ Py::Object View3DInventorPy::setStereoType(const Py::Tuple& args)
try {
if (stereomode < 0 || stereomode > 4)
throw Py::Exception("Out of range");
throw Py::IndexError("Out of range");
Quarter::SoQTQuarterAdaptor::StereoMode mode = Quarter::SoQTQuarterAdaptor::StereoMode(stereomode);
_view->getViewer()->setStereoMode(mode);
return Py::None();
}
catch (const Base::Exception& e) {
throw Py::Exception(e.what());
throw Py::RuntimeError(e.what());
}
catch (const std::exception& e) {
throw Py::Exception(e.what());
throw Py::RuntimeError(e.what());
}
catch(...) {
throw Py::Exception("Unknown C++ exception");
throw Py::RuntimeError("Unknown C++ exception");
}
}
@@ -1068,13 +1068,13 @@ Py::Object View3DInventorPy::getStereoType(const Py::Tuple& args)
return Py::String(StereoTypeEnums[mode]);
}
catch (const Base::Exception& e) {
throw Py::Exception(e.what());
throw Py::RuntimeError(e.what());
}
catch (const std::exception& e) {
throw Py::Exception(e.what());
throw Py::RuntimeError(e.what());
}
catch(...) {
throw Py::Exception("Unknown C++ exception");
throw Py::RuntimeError("Unknown C++ exception");
}
}
@@ -1092,13 +1092,13 @@ Py::Object View3DInventorPy::listStereoTypes(const Py::Tuple& args)
return list;
}
catch (const Base::Exception& e) {
throw Py::Exception(e.what());
throw Py::RuntimeError(e.what());
}
catch (const std::exception& e) {
throw Py::Exception(e.what());
throw Py::RuntimeError(e.what());
}
catch(...) {
throw Py::Exception("Unknown C++ exception");
throw Py::RuntimeError("Unknown C++ exception");
}
}
@@ -1324,7 +1324,7 @@ Py::Object View3DInventorPy::getPoint(const Py::Tuple& args)
return Py::Vector(Base::Vector3f(pt[0], pt[1], pt[2]));
}
catch (const Base::Exception& e) {
throw Py::Exception(e.what());
throw Py::RuntimeError(e.what());
}
catch (const Py::Exception&) {
throw;
@@ -1344,7 +1344,7 @@ Py::Object View3DInventorPy::getPointOnScreen(const Py::Tuple& args)
else {
PyErr_Clear();
if (!PyArg_ParseTuple(args.ptr(), "ddd", &vx,&vy,&vz)) {
throw Py::Exception("Wrong argument, Vector or three floats expected expected");
throw Py::TypeError("Wrong argument, Vector or three floats expected expected");
}
}
@@ -1374,7 +1374,7 @@ Py::Object View3DInventorPy::getPointOnScreen(const Py::Tuple& args)
return tuple;
}
catch (const Base::Exception& e) {
throw Py::Exception(e.what());
throw Py::RuntimeError(e.what());
}
catch (const Py::Exception&) {
throw;
@@ -1771,14 +1771,14 @@ Py::Object View3DInventorPy::addEventCallback(const Py::Tuple& args)
throw Py::Exception();
try {
if (PyCallable_Check(method) == 0) {
throw Py::Exception("object is not callable");
throw Py::TypeError("object is not callable");
}
SoType eventId = SoType::fromName(eventtype);
if (eventId.isBad() || !eventId.isDerivedFrom(SoEvent::getClassTypeId())) {
std::string s;
std::ostringstream s_out;
s_out << eventtype << " is not a valid event type";
throw Py::Exception(s_out.str());
throw Py::TypeError(s_out.str());
}
_view->getViewer()->addEventCallback(eventId, View3DInventorPy::eventCallback, method);
@@ -1799,14 +1799,14 @@ Py::Object View3DInventorPy::removeEventCallback(const Py::Tuple& args)
throw Py::Exception();
try {
if (PyCallable_Check(method) == 0) {
throw Py::Exception("object is not callable");
throw Py::RuntimeError("object is not callable");
}
SoType eventId = SoType::fromName(eventtype);
if (eventId.isBad() || !eventId.isDerivedFrom(SoEvent::getClassTypeId())) {
std::string s;
std::ostringstream s_out;
s_out << eventtype << " is not a valid event type";
throw Py::Exception(s_out.str());
throw Py::TypeError(s_out.str());
}
_view->getViewer()->removeEventCallback(eventId, View3DInventorPy::eventCallback, method);
@@ -1831,7 +1831,7 @@ Py::Object View3DInventorPy::setAnnotation(const Py::Tuple& args)
}
catch (const Base::Exception& e) {
delete view;
throw Py::Exception(e.what());
throw Py::RuntimeError(e.what());
}
_view->getGuiDocument()->setAnnotationViewProvider(psAnnoName, view);
@@ -1870,7 +1870,7 @@ Py::Object View3DInventorPy::getSceneGraph(const Py::Tuple& args)
return Py::Object(proxy, true);
}
catch (const Base::Exception& e) {
throw Py::Exception(e.what());
throw Py::RuntimeError(e.what());
}
}
@@ -1964,7 +1964,7 @@ Py::Object View3DInventorPy::addEventCallbackPivy(const Py::Tuple& args)
Base::Interpreter().convertSWIGPointerObj("pivy.coin", "SoType *", proxy, &ptr, 0);
}
catch (const Base::Exception& e) {
throw Py::Exception(e.what());
throw Py::RuntimeError(e.what());
}
SoType* eventId = reinterpret_cast<SoType*>(ptr);
@@ -1972,12 +1972,12 @@ Py::Object View3DInventorPy::addEventCallbackPivy(const Py::Tuple& args)
std::string s;
std::ostringstream s_out;
s_out << eventId->getName().getString() << "is not a valid event type";
throw Py::Exception(s_out.str());
throw Py::TypeError(s_out.str());
}
try {
if (PyCallable_Check(method) == 0) {
throw Py::Exception("object is not callable");
throw Py::TypeError("object is not callable");
}
SoEventCallbackCB* callback = (ex == 1 ?
@@ -2006,7 +2006,7 @@ Py::Object View3DInventorPy::removeEventCallbackPivy(const Py::Tuple& args)
Base::Interpreter().convertSWIGPointerObj("pivy.coin", "SoType *", proxy, &ptr, 0);
}
catch (const Base::Exception& e) {
throw Py::Exception(e.what());
throw Py::RuntimeError(e.what());
}
SoType* eventId = reinterpret_cast<SoType*>(ptr);
@@ -2014,12 +2014,12 @@ Py::Object View3DInventorPy::removeEventCallbackPivy(const Py::Tuple& args)
std::string s;
std::ostringstream s_out;
s_out << eventId->getName().getString() << "is not a valid event type";
throw Py::Exception(s_out.str());
throw Py::TypeError(s_out.str());
}
try {
if (PyCallable_Check(method) == 0) {
throw Py::Exception("object is not callable");
throw Py::TypeError("object is not callable");
}
SoEventCallbackCB* callback = (ex == 1 ?
@@ -2066,7 +2066,7 @@ void View3DInventorPy::draggerCallback(void * ud, SoDragger* n)
method.apply(args);
}
catch (const Base::Exception& e) {
throw Py::Exception(e.what());
throw Py::RuntimeError(e.what());
}
catch (const Py::Exception& e) {
Py::Object o = Py::type(e);
@@ -2098,13 +2098,13 @@ Py::Object View3DInventorPy::addDraggerCallback(const Py::Tuple& args)
Base::Interpreter().convertSWIGPointerObj("pivy.coin", "SoDragger *", dragger, &ptr, 0);
}
catch (const Base::Exception&) {
throw Py::Exception("The first argument must be of type SoDragger");
throw Py::TypeError("The first argument must be of type SoDragger");
}
SoDragger* drag = reinterpret_cast<SoDragger*>(ptr);
//Check if method is callable
if (PyCallable_Check(method) == 0) {
throw Py::Exception("the method is not callable");
throw Py::TypeError("the method is not callable");
}
try {
@@ -2124,7 +2124,7 @@ Py::Object View3DInventorPy::addDraggerCallback(const Py::Tuple& args)
std::string s;
std::ostringstream s_out;
s_out << type << " is not a valid dragger callback type";
throw Py::Exception(s_out.str());
throw Py::TypeError(s_out.str());
}
callbacks.push_back(method);
@@ -2150,7 +2150,7 @@ Py::Object View3DInventorPy::removeDraggerCallback(const Py::Tuple& args)
Base::Interpreter().convertSWIGPointerObj("pivy.coin", "SoDragger *", dragger, &ptr, 0);
}
catch (const Base::Exception&) {
throw Py::Exception("The first argument must be of type SoDragger");
throw Py::TypeError("The first argument must be of type SoDragger");
}
SoDragger* drag = reinterpret_cast<SoDragger*>(ptr);
@@ -2171,7 +2171,7 @@ Py::Object View3DInventorPy::removeDraggerCallback(const Py::Tuple& args)
std::string s;
std::ostringstream s_out;
s_out << type << " is not a valid dragger callback type";
throw Py::Exception(s_out.str());
throw Py::TypeError(s_out.str());
}
callbacks.remove(method);