From 51e90dd52b22dbe994c0ebbf2be56a628eba19f8 Mon Sep 17 00:00:00 2001 From: Abdullah Tahiri Date: Tue, 9 May 2017 00:16:00 +0200 Subject: [PATCH] SketchObject:ModifyBSplineKnotMultiplicity re written to use THROW macro and CADKernelError exception --- src/Mod/Sketcher/App/SketchObject.cpp | 14 +++++++------- src/Mod/Sketcher/Gui/CommandSketcherBSpline.cpp | 9 +++++++-- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/Mod/Sketcher/App/SketchObject.cpp b/src/Mod/Sketcher/App/SketchObject.cpp index aebe0fc3d2..55eaa58dbf 100644 --- a/src/Mod/Sketcher/App/SketchObject.cpp +++ b/src/Mod/Sketcher/App/SketchObject.cpp @@ -4099,32 +4099,32 @@ bool SketchObject::modifyBSplineKnotMultiplicity(int GeoId, int knotIndex, int m #endif if (GeoId < 0 || GeoId > getHighestCurveIndex()) - throw Base::ValueError("BSpline GeoId is out of bounds."); + THROWM(Base::ValueError,"BSpline GeoId is out of bounds.") if (multiplicityincr == 0) // no change in multiplicity - throw Base::ValueError("You are requesting no change in knot multiplicity."); + THROWM(Base::ValueError,"You are requesting no change in knot multiplicity.") const Part::Geometry *geo = getGeometry(GeoId); if(geo->getTypeId() != Part::GeomBSplineCurve::getClassTypeId()) - throw Base::TypeError("The GeoId provided is not a B-spline curve"); + THROWM(Base::TypeError,"The GeoId provided is not a B-spline curve."); const Part::GeomBSplineCurve *bsp = static_cast(geo); int degree = bsp->getDegree(); if( knotIndex > bsp->countKnots() || knotIndex < 1 ) // knotindex in OCC 1 -> countKnots - throw Base::ValueError("The knot index is out of bounds. Note that in accordance with OCC notation, the first knot has index 1 and not zero."); + THROWM(Base::ValueError,"The knot index is out of bounds. Note that in accordance with OCC notation, the first knot has index 1 and not zero."); Part::GeomBSplineCurve *bspline; int curmult = bsp->getMultiplicity(knotIndex); if ( (curmult + multiplicityincr) > degree ) // zero is removing the knot, degree is just positional continuity - throw Base::ValueError("The multiplicity cannot be increased beyond the degree of the b-spline."); + THROWM(Base::ValueError,"The multiplicity cannot be increased beyond the degree of the b-spline."); if ( (curmult + multiplicityincr) < 0) // zero is removing the knot, degree is just positional continuity - throw Base::ValueError("The multiplicity cannot be decreased beyond zero."); + THROWM(Base::ValueError,"The multiplicity cannot be decreased beyond zero."); try { @@ -4137,7 +4137,7 @@ bool SketchObject::modifyBSplineKnotMultiplicity(int GeoId, int knotIndex, int m bool result = bspline->removeKnot(knotIndex, curmult + multiplicityincr,1E6); if(!result) - throw Base::RuntimeError("OCC is unable to decrease the multiplicity within the maximum tolerance."); + THROWM(Base::CADKernelError, "OCC is unable to decrease the multiplicity within the maximum tolerance."); } } catch (const Base::Exception& e) { diff --git a/src/Mod/Sketcher/Gui/CommandSketcherBSpline.cpp b/src/Mod/Sketcher/Gui/CommandSketcherBSpline.cpp index 1158a31b37..1ad4cfbc10 100644 --- a/src/Mod/Sketcher/Gui/CommandSketcherBSpline.cpp +++ b/src/Mod/Sketcher/Gui/CommandSketcherBSpline.cpp @@ -576,9 +576,14 @@ void CmdSketcherIncreaseKnotMultiplicity::activated(int iMsg) // particularly B-spline GeoID might have changed. } + catch (const Base::CADKernelError& e) { + QMessageBox::warning(Gui::getMainWindow(), QObject::tr("CAD Kernel Error"), + QObject::tr(e.getMessage().c_str())); + getSelection().clearSelection(); + } catch (const Base::Exception& e) { - QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Error"), - QObject::tr(getStrippedPythonExceptionString(e).c_str())); + QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Input Error"), + QObject::tr(e.getMessage().c_str())); getSelection().clearSelection(); }