improve error messages for Pocket, Hole and Groove feature
This commit is contained in:
@@ -36,6 +36,7 @@
|
||||
# include <gp_Lin.hxx>
|
||||
#endif
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <Base/Axis.h>
|
||||
#include <Base/Console.h>
|
||||
#include <Base/Exception.h>
|
||||
@@ -50,6 +51,8 @@ using namespace PartDesign;
|
||||
namespace PartDesign {
|
||||
|
||||
|
||||
/* TRANSLATOR PartDesign::Groove */
|
||||
|
||||
PROPERTY_SOURCE(PartDesign::Groove, PartDesign::ProfileBased)
|
||||
|
||||
Groove::Groove()
|
||||
@@ -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();
|
||||
|
||||
@@ -51,6 +51,7 @@
|
||||
# include <Standard_Version.hxx>
|
||||
#endif
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <Base/Placement.h>
|
||||
#include <Base/Exception.h>
|
||||
#include <Base/Tools.h>
|
||||
@@ -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};
|
||||
@@ -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 {
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
# include <BRepAlgoAPI_Common.hxx>
|
||||
#endif
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <Base/Console.h>
|
||||
#include <Base/Exception.h>
|
||||
#include <Base/Placement.h>
|
||||
@@ -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)
|
||||
@@ -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
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
#include <QApplication>
|
||||
#include <QMessageBox>
|
||||
#endif
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user