From a0917493bdb39667f78eba39db646c44d2bae29e Mon Sep 17 00:00:00 2001 From: Abdullah Tahiri Date: Sun, 2 Apr 2017 00:13:22 +0200 Subject: [PATCH] Sketcher: Increase/Decrease knot multiplicity toolbar commands adapted to provide more meaningful error messages --- .../Sketcher/Gui/CommandSketcherBSpline.cpp | 27 ++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/src/Mod/Sketcher/Gui/CommandSketcherBSpline.cpp b/src/Mod/Sketcher/Gui/CommandSketcherBSpline.cpp index 4a634e29cc..c971a40db2 100644 --- a/src/Mod/Sketcher/Gui/CommandSketcherBSpline.cpp +++ b/src/Mod/Sketcher/Gui/CommandSketcherBSpline.cpp @@ -540,6 +540,7 @@ void CmdSketcherIncreaseKnotMultiplicity::activated(int iMsg) openCommand("Increase knot multiplicity"); bool applied = false; + bool notaknot = true; boost::uuids::uuid bsplinetag; @@ -556,6 +557,8 @@ void CmdSketcherIncreaseKnotMultiplicity::activated(int iMsg) { bsplinetag = Obj->getGeometry((*it)->Second)->getTag(); + notaknot = false; + try { Gui::Command::doCommand( Doc,"App.ActiveDocument.%s.modifyBSplineKnotMultiplicity(%d,%d,%d) ", @@ -568,17 +571,24 @@ void CmdSketcherIncreaseKnotMultiplicity::activated(int iMsg) } catch (const Base::Exception& e) { - Base::Console().Error("%s\n", e.what()); + QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Error"), + QObject::tr(e.what())); getSelection().clearSelection(); } break; // we have already found our knot. } + } } + if(notaknot){ + QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), + QObject::tr("None of the selected elements is a knot of a bspline")); + } + if(applied) { // find new geoid for bspline as GeoId might have changed @@ -613,8 +623,6 @@ void CmdSketcherIncreaseKnotMultiplicity::activated(int iMsg) if(!applied) { abortCommand(); - QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), - QObject::tr("None of the selected elements is a knot of a bspline or the knot has already reached the maximum multiplicity.")); } else { commitCommand(); @@ -686,6 +694,7 @@ void CmdSketcherDecreaseKnotMultiplicity::activated(int iMsg) openCommand("Decrease knot multiplicity"); bool applied = false; + bool notaknot = true; boost::uuids::uuid bsplinetag; @@ -702,6 +711,8 @@ void CmdSketcherDecreaseKnotMultiplicity::activated(int iMsg) { bsplinetag = Obj->getGeometry((*it)->Second)->getTag(); + notaknot = false; + try { Gui::Command::doCommand( Doc,"App.ActiveDocument.%s.modifyBSplineKnotMultiplicity(%d,%d,%d) ", @@ -714,7 +725,8 @@ void CmdSketcherDecreaseKnotMultiplicity::activated(int iMsg) } catch (const Base::Exception& e) { - Base::Console().Error("%s\n", e.what()); + QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Error"), + QObject::tr(e.what())); getSelection().clearSelection(); } @@ -725,6 +737,11 @@ void CmdSketcherDecreaseKnotMultiplicity::activated(int iMsg) } + if(notaknot){ + QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), + QObject::tr("None of the selected elements is a knot of a bspline")); + } + if(applied) { // find new geoid for bspline as GeoId might have changed @@ -759,8 +776,6 @@ void CmdSketcherDecreaseKnotMultiplicity::activated(int iMsg) if(!applied) { abortCommand(); - QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), - QObject::tr("None of the selected elements is a knot of a bspline")); } else { commitCommand();