Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
improve error messages for Pocket, Hole and Groove feature
  • Loading branch information
wwmayer committed Dec 31, 2018
1 parent fd9516e commit 563d020
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 7 deletions.
12 changes: 10 additions & 2 deletions src/Mod/PartDesign/App/FeatureGroove.cpp
Expand Up @@ -36,6 +36,7 @@
# include <gp_Lin.hxx>
#endif

#include <QCoreApplication>
#include <Base/Axis.h>
#include <Base/Console.h>
#include <Base/Exception.h>
Expand All @@ -50,6 +51,8 @@ using namespace PartDesign;
namespace PartDesign {


/* TRANSLATOR PartDesign::Groove */

PROPERTY_SOURCE(PartDesign::Groove, PartDesign::ProfileBased)

Groove::Groove()
Expand Down Expand Up @@ -98,8 +101,13 @@ App::DocumentObjectExecReturn *Groove::execute(void)
TopoDS_Shape base;
try {
base = getBaseShape();
} catch (const Base::Exception&) {
return new App::DocumentObjectExecReturn("No sketch support and no base shape: Please tell me where to remove the material of the groove!");
}
catch (const Base::Exception&) {
std::string text(QT_TR_NOOP("The requested feature cannot be created. The reason may be that:\n\n"
" \xe2\x80\xa2 the active Body does not contain a base shape, so there is no\n"
" material to be removed;\n"
" \xe2\x80\xa2 the selected sketch does not belong to the active Body."));
return new App::DocumentObjectExecReturn(text);
}

updateAxis();
Expand Down
12 changes: 10 additions & 2 deletions src/Mod/PartDesign/App/FeatureHole.cpp
Expand Up @@ -51,6 +51,7 @@
# include <Standard_Version.hxx>
#endif

#include <QCoreApplication>
#include <Base/Placement.h>
#include <Base/Exception.h>
#include <Base/Tools.h>
Expand All @@ -62,6 +63,8 @@

using namespace PartDesign;

/* TRANSLATOR PartDesign::Hole */

const char* Hole::DepthTypeEnums[] = { "Dimension", "ThroughAll", /*, "UpToFirst", */ NULL };
const char* Hole::ThreadTypeEnums[] = { "None", "ISOMetricProfile", "ISOMetricFineProfile", "UNC", "UNF", "UNEF", NULL};
const char* Hole::ThreadFitEnums[] = { "Standard", "Close", NULL};
Expand Down Expand Up @@ -948,8 +951,13 @@ App::DocumentObjectExecReturn *Hole::execute(void)
TopoDS_Shape base;
try {
base = getBaseShape();
} catch (const Base::Exception&) {
return new App::DocumentObjectExecReturn("No sketch support and no base shape: Please tell me where to remove the material of the hole!");
}
catch (const Base::Exception&) {
std::string text(QT_TR_NOOP("The requested feature cannot be created. The reason may be that:\n\n"
" \xe2\x80\xa2 the active Body does not contain a base shape, so there is no\n"
" material to be removed;\n"
" \xe2\x80\xa2 the selected sketch does not belong to the active Body."));
return new App::DocumentObjectExecReturn(text);
}

try {
Expand Down
12 changes: 10 additions & 2 deletions src/Mod/PartDesign/App/FeaturePocket.cpp
Expand Up @@ -43,6 +43,7 @@
# include <BRepAlgoAPI_Common.hxx>
#endif

#include <QCoreApplication>
#include <Base/Console.h>
#include <Base/Exception.h>
#include <Base/Placement.h>
Expand All @@ -53,6 +54,8 @@

using namespace PartDesign;

/* TRANSLATOR PartDesign::Pocket */

const char* Pocket::TypeEnums[]= {"Length","ThroughAll","UpToFirst","UpToFace","TwoLengths",NULL};

PROPERTY_SOURCE(PartDesign::Pocket, PartDesign::ProfileBased)
Expand Down Expand Up @@ -113,8 +116,13 @@ App::DocumentObjectExecReturn *Pocket::execute(void)
TopoDS_Shape base;
try {
base = getBaseShape();
} catch (const Base::Exception&) {
return new App::DocumentObjectExecReturn("No sketch support and no base shape: Please tell me where to remove the material of the pocket!");
}
catch (const Base::Exception&) {
std::string text(QT_TR_NOOP("The requested feature cannot be created. The reason may be that:\n\n"
" \xe2\x80\xa2 the active Body does not contain a base shape, so there is no\n"
" material to be removed;\n"
" \xe2\x80\xa2 the selected sketch does not belong to the active Body."));
return new App::DocumentObjectExecReturn(text);
}

// get the Sketch plane
Expand Down
8 changes: 7 additions & 1 deletion src/Mod/PartDesign/Gui/TaskFeatureParameters.cpp
Expand Up @@ -22,6 +22,7 @@

#include "PreCompiled.h"
#ifndef _PreComp_
#include <QApplication>
#include <QMessageBox>
#endif

Expand Down Expand Up @@ -131,7 +132,12 @@ bool TaskDlgFeatureParameters::accept() {
Gui::Command::commitCommand();
} catch (const Base::Exception& e) {
// Generally the only thing that should fail is feature->isValid() others should be fine
QMessageBox::warning(Gui::getMainWindow(), tr("Input error"), QString::fromLatin1(e.what()));
#if (QT_VERSION >= 0x050000)
QString errorText = QApplication::translate(feature->getTypeId().getName(), e.what());
#else
QString errorText = QApplication::translate(feature->getTypeId().getName(), e.what(), 0, QApplication::UnicodeUTF8);
#endif
QMessageBox::warning(Gui::getMainWindow(), tr("Input error"), errorText);
return false;
}

Expand Down

0 comments on commit 563d020

Please sign in to comment.