diff --git a/src/app/tools/drawTools/vtoolalongline.cpp b/src/app/tools/drawTools/vtoolalongline.cpp index debeca98c..1d8613d48 100644 --- a/src/app/tools/drawTools/vtoolalongline.cpp +++ b/src/app/tools/drawTools/vtoolalongline.cpp @@ -30,6 +30,8 @@ #include "../../container/calculator.h" #include "../../dialogs/tools/dialogalongline.h" +#include "exception/vexceptionobjecterror.h" + const QString VToolAlongLine::ToolType = QStringLiteral("alongLine"); //--------------------------------------------------------------------------------------------------------------------- @@ -180,24 +182,9 @@ void VToolAlongLine::Create(const quint32 _id, const QString &pointName, const Q const VPointF *secondPoint = data->GeometricObject(secondPointId); QLineF line = QLineF(firstPoint->toQPointF(), secondPoint->toQPointF()); - try - { - Calculator cal(data); - const qreal result = cal.EvalFormula(formula); - line.setLength(qApp->toPixel(result)); - } - catch(qmu::QmuParserError &e) - { - //TODO show error - qDebug() << "\nError:\n" - << "--------\n" - << "Message: " << e.GetMsg() << "\n" - << "Expression: \"" << e.GetExpr() << "\"\n" - << "Token: \"" << e.GetToken() << "\"\n" - << "Position: " << e.GetPos() << "\n" - << "Errc: " << QString::number(e.GetCode(), 16); - return; - } + Calculator cal(data); + const qreal result = cal.EvalFormula(formula); + line.setLength(qApp->toPixel(result)); quint32 id = _id; if (typeCreation == Valentina::FromGui) diff --git a/src/app/tools/drawTools/vtoolarc.cpp b/src/app/tools/drawTools/vtoolarc.cpp index ac36dfb44..af9754b26 100644 --- a/src/app/tools/drawTools/vtoolarc.cpp +++ b/src/app/tools/drawTools/vtoolarc.cpp @@ -93,28 +93,13 @@ void VToolArc::Create(const quint32 _id, const quint32 ¢er, const QString &r { qreal calcRadius = 0, calcF1 = 0, calcF2 = 0; - try - { - Calculator cal(data); + Calculator cal(data); - qreal result = cal.EvalFormula(radius); - calcRadius = qApp->toPixel(result); + qreal result = cal.EvalFormula(radius); + calcRadius = qApp->toPixel(result); - calcF1 = cal.EvalFormula(f1); - calcF2 = cal.EvalFormula(f2); - } - catch(qmu::QmuParserError &e) - { - //TODO show error message - qDebug() << "\nError:\n" - << "--------\n" - << "Message: " << e.GetMsg() << "\n" - << "Expression: \"" << e.GetExpr() << "\"\n" - << "Token: \"" << e.GetToken() << "\"\n" - << "Position: " << e.GetPos() << "\n" - << "Errc: " << QString::number(e.GetCode(), 16); - return; - } + calcF1 = cal.EvalFormula(f1); + calcF2 = cal.EvalFormula(f2); VPointF c = *data->GeometricObject(center); VArc *arc = new VArc(c, calcRadius, radius, calcF1, f1, calcF2, f2 ); diff --git a/src/app/tools/drawTools/vtoolbisector.cpp b/src/app/tools/drawTools/vtoolbisector.cpp index 2834e915b..36d3436e6 100644 --- a/src/app/tools/drawTools/vtoolbisector.cpp +++ b/src/app/tools/drawTools/vtoolbisector.cpp @@ -114,24 +114,8 @@ void VToolBisector::Create(const quint32 _id, const QString &formula, const quin const VPointF *secondPoint = data->GeometricObject(secondPointId); const VPointF *thirdPoint = data->GeometricObject(thirdPointId); - qreal result = 0; - try - { - Calculator cal(data); - result = cal.EvalFormula(formula); - } - catch(qmu::QmuParserError &e) - { - //TODO show error message - qDebug() << "\nError:\n" - << "--------\n" - << "Message: " << e.GetMsg() << "\n" - << "Expression: \"" << e.GetExpr() << "\"\n" - << "Token: \"" << e.GetToken() << "\"\n" - << "Position: " << e.GetPos() << "\n" - << "Errc: " << QString::number(e.GetCode(), 16); - return; - } + Calculator cal(data); + const qreal result = cal.EvalFormula(formula); QPointF fPoint = VToolBisector::FindPoint(firstPoint->toQPointF(), secondPoint->toQPointF(), thirdPoint->toQPointF(), qApp->toPixel(result)); diff --git a/src/app/tools/drawTools/vtoolcutarc.cpp b/src/app/tools/drawTools/vtoolcutarc.cpp index ca6db78f1..2f1a8cf81 100644 --- a/src/app/tools/drawTools/vtoolcutarc.cpp +++ b/src/app/tools/drawTools/vtoolcutarc.cpp @@ -95,24 +95,9 @@ void VToolCutArc::Create(const quint32 _id, const QString &pointName, const QStr VContainer *data, const Document::Documents &parse, const Valentina::Sources &typeCreation) { const VArc *arc = data->GeometricObject(arcId); - qreal result = 0; - try - { - Calculator cal(data); - result = cal.EvalFormula(formula); - } - catch(qmu::QmuParserError &e) - { - //TODO show error message - qDebug() << "\nError:\n" - << "--------\n" - << "Message: " << e.GetMsg() << "\n" - << "Expression: \"" << e.GetExpr() << "\"\n" - << "Token: \"" << e.GetToken() << "\"\n" - << "Position: " << e.GetPos() << "\n" - << "Errc: " << QString::number(e.GetCode(), 16); - return; - } + + Calculator cal(data); + const qreal result = cal.EvalFormula(formula); VArc arc1; VArc arc2; diff --git a/src/app/tools/drawTools/vtoolcutspline.cpp b/src/app/tools/drawTools/vtoolcutspline.cpp index df8ade3fe..1f1f14c1f 100644 --- a/src/app/tools/drawTools/vtoolcutspline.cpp +++ b/src/app/tools/drawTools/vtoolcutspline.cpp @@ -97,24 +97,8 @@ void VToolCutSpline::Create(const quint32 _id, const QString &pointName, { const VSpline *spl = data->GeometricObject(splineId); - qreal result = 0; - try - { - Calculator cal(data); - result = cal.EvalFormula(formula); - } - catch(qmu::QmuParserError &e) - { - //TODO show error message - qDebug() << "\nError:\n" - << "--------\n" - << "Message: " << e.GetMsg() << "\n" - << "Expression: \"" << e.GetExpr() << "\"\n" - << "Token: \"" << e.GetToken() << "\"\n" - << "Position: " << e.GetPos() << "\n" - << "Errc: " << QString::number(e.GetCode(), 16); - return; - } + Calculator cal(data); + const qreal result = cal.EvalFormula(formula); QPointF spl1p2, spl1p3, spl2p2, spl2p3; QPointF point = spl->CutSpline(qApp->toPixel(result), spl1p2, spl1p3, spl2p2, spl2p3); diff --git a/src/app/tools/drawTools/vtoolcutsplinepath.cpp b/src/app/tools/drawTools/vtoolcutsplinepath.cpp index d5ad485dd..290aa92ef 100644 --- a/src/app/tools/drawTools/vtoolcutsplinepath.cpp +++ b/src/app/tools/drawTools/vtoolcutsplinepath.cpp @@ -98,24 +98,8 @@ void VToolCutSplinePath::Create(const quint32 _id, const QString &pointName, con const VSplinePath *splPath = data->GeometricObject(splinePathId); Q_CHECK_PTR(splPath); - qreal result = 0; - try - { - Calculator cal(data); - result = cal.EvalFormula(formula); - } - catch(qmu::QmuParserError &e) - { - //TODO show error message - qDebug() << "\nError:\n" - << "--------\n" - << "Message: " << e.GetMsg() << "\n" - << "Expression: \"" << e.GetExpr() << "\"\n" - << "Token: \"" << e.GetToken() << "\"\n" - << "Position: " << e.GetPos() << "\n" - << "Errc: " << QString::number(e.GetCode(), 16); - return; - } + Calculator cal(data); + const qreal result = cal.EvalFormula(formula); quint32 id = _id; QPointF spl1p2, spl1p3, spl2p2, spl2p3; diff --git a/src/app/tools/drawTools/vtoolendline.cpp b/src/app/tools/drawTools/vtoolendline.cpp index 83971c71f..22c9639cc 100644 --- a/src/app/tools/drawTools/vtoolendline.cpp +++ b/src/app/tools/drawTools/vtoolendline.cpp @@ -89,24 +89,8 @@ void VToolEndLine::Create(const quint32 _id, const QString &pointName, const QSt const VPointF *basePoint = data->GeometricObject(basePointId); QLineF line = QLineF(basePoint->toQPointF(), QPointF(basePoint->x()+100, basePoint->y())); - qreal result = 0; - try - { - Calculator cal(data); - result = cal.EvalFormula(formula); - } - catch(qmu::QmuParserError &e) - { - //TODO show error message - qDebug() << "\nError:\n" - << "--------\n" - << "Message: " << e.GetMsg() << "\n" - << "Expression: \"" << e.GetExpr() << "\"\n" - << "Token: \"" << e.GetToken() << "\"\n" - << "Position: " << e.GetPos() << "\n" - << "Errc: " << QString::number(e.GetCode(), 16); - return; - } + Calculator cal(data); + const qreal result = cal.EvalFormula(formula); line.setLength(qApp->toPixel(result)); line.setAngle(angle); diff --git a/src/app/tools/drawTools/vtoolnormal.cpp b/src/app/tools/drawTools/vtoolnormal.cpp index 560f604f1..93f8a3efa 100644 --- a/src/app/tools/drawTools/vtoolnormal.cpp +++ b/src/app/tools/drawTools/vtoolnormal.cpp @@ -91,24 +91,8 @@ void VToolNormal::Create(const quint32 _id, const QString &formula, const quint3 const VPointF *firstPoint = data->GeometricObject(firstPointId); const VPointF *secondPoint = data->GeometricObject(secondPointId); - qreal result = 0; - try - { - Calculator cal(data); - result = cal.EvalFormula(formula); - } - catch(qmu::QmuParserError &e) - { - //TODO show error message - qDebug() << "\nError:\n" - << "--------\n" - << "Message: " << e.GetMsg() << "\n" - << "Expression: \"" << e.GetExpr() << "\"\n" - << "Token: \"" << e.GetToken() << "\"\n" - << "Position: " << e.GetPos() << "\n" - << "Errc: " << QString::number(e.GetCode(), 16); - return; - } + Calculator cal(data); + const qreal result = cal.EvalFormula(formula); QPointF fPoint = VToolNormal::FindPoint(firstPoint->toQPointF(), secondPoint->toQPointF(), qApp->toPixel(result), angle); diff --git a/src/app/tools/drawTools/vtoolpointofcontact.cpp b/src/app/tools/drawTools/vtoolpointofcontact.cpp index 6cae7f869..ae836dea3 100644 --- a/src/app/tools/drawTools/vtoolpointofcontact.cpp +++ b/src/app/tools/drawTools/vtoolpointofcontact.cpp @@ -117,24 +117,8 @@ void VToolPointOfContact::Create(const quint32 _id, const QString &radius, const const VPointF *firstP = data->GeometricObject(firstPointId); const VPointF *secondP = data->GeometricObject(secondPointId); - qreal result = 0; - try - { - Calculator cal(data); - result = cal.EvalFormula(radius); - } - catch(qmu::QmuParserError &e) - { - //TODO show error message - qDebug() << "\nError:\n" - << "--------\n" - << "Message: " << e.GetMsg() << "\n" - << "Expression: \"" << e.GetExpr() << "\"\n" - << "Token: \"" << e.GetToken() << "\"\n" - << "Position: " << e.GetPos() << "\n" - << "Errc: " << QString::number(e.GetCode(), 16); - return; - } + Calculator cal(data); + const qreal result = cal.EvalFormula(radius); QPointF fPoint = VToolPointOfContact::FindPoint(qApp->toPixel(result), centerP->toQPointF(), firstP->toQPointF(), secondP->toQPointF()); diff --git a/src/app/tools/drawTools/vtoolshoulderpoint.cpp b/src/app/tools/drawTools/vtoolshoulderpoint.cpp index a09e43163..b7da6c023 100644 --- a/src/app/tools/drawTools/vtoolshoulderpoint.cpp +++ b/src/app/tools/drawTools/vtoolshoulderpoint.cpp @@ -119,24 +119,8 @@ void VToolShoulderPoint::Create(const quint32 _id, const QString &formula, const const VPointF *secondPoint = data->GeometricObject(p2Line); const VPointF *shoulderPoint = data->GeometricObject(pShoulder); - qreal result = 0; - try - { - Calculator cal(data); - result = cal.EvalFormula(formula); - } - catch(qmu::QmuParserError &e) - { - //TODO show error message - qDebug() << "\nError:\n" - << "--------\n" - << "Message: " << e.GetMsg() << "\n" - << "Expression: \"" << e.GetExpr() << "\"\n" - << "Token: \"" << e.GetToken() << "\"\n" - << "Position: " << e.GetPos() << "\n" - << "Errc: " << QString::number(e.GetCode(), 16); - return; - } + Calculator cal(data); + const qreal result = cal.EvalFormula(formula); QPointF fPoint = VToolShoulderPoint::FindPoint(firstPoint->toQPointF(), secondPoint->toQPointF(), shoulderPoint->toQPointF(), qApp->toPixel(result)); diff --git a/src/app/xml/vpattern.cpp b/src/app/xml/vpattern.cpp index 1a0637923..dd214a9ca 100644 --- a/src/app/xml/vpattern.cpp +++ b/src/app/xml/vpattern.cpp @@ -39,6 +39,7 @@ #include "vindividualmeasurements.h" #include +#include const QString VPattern::TagPattern = QStringLiteral("pattern"); const QString VPattern::TagCalculation = QStringLiteral("calculation"); @@ -845,6 +846,17 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, const QDomElement &d excep.AddMoreInformation(e.ErrorMessage()); throw excep; } + catch(qmu::QmuParserError &e) + { + VExceptionObjectError excep(tr("Error creating or updating point of end line"), domElement); + QString message( "Message: " + e.GetMsg() + "\n"+ + + "Expression: \"" + e.GetExpr() + "\"\n"+ + + "Token: \"" + e.GetToken() + "\"\n"+ + + "Position: " + QString::number(e.GetPos()) + "\n"+ + + "Errc: " + QString::number(e.GetCode(), 16)); + excep.AddMoreInformation(message); + throw excep; + } break; case 2: //VToolAlongLine::ToolType try @@ -868,6 +880,17 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, const QDomElement &d excep.AddMoreInformation(e.ErrorMessage()); throw excep; } + catch(qmu::QmuParserError &e) + { + VExceptionObjectError excep(tr("Error creating or updating point along line"), domElement); + QString message( "Message: " + e.GetMsg() + "\n"+ + + "Expression: \"" + e.GetExpr() + "\"\n"+ + + "Token: \"" + e.GetToken() + "\"\n"+ + + "Position: " + QString::number(e.GetPos()) + "\n"+ + + "Errc: " + QString::number(e.GetCode(), 16)); + excep.AddMoreInformation(message); + throw excep; + } break; case 3: //VToolShoulderPoint::ToolType try @@ -892,6 +915,17 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, const QDomElement &d excep.AddMoreInformation(e.ErrorMessage()); throw excep; } + catch(qmu::QmuParserError &e) + { + VExceptionObjectError excep(tr("Error creating or updating point of shoulder"), domElement); + QString message( "Message: " + e.GetMsg() + "\n"+ + + "Expression: \"" + e.GetExpr() + "\"\n"+ + + "Token: \"" + e.GetToken() + "\"\n"+ + + "Position: " + QString::number(e.GetPos()) + "\n"+ + + "Errc: " + QString::number(e.GetCode(), 16)); + excep.AddMoreInformation(message); + throw excep; + } break; case 4: //VToolNormal::ToolType try @@ -916,6 +950,17 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, const QDomElement &d excep.AddMoreInformation(e.ErrorMessage()); throw excep; } + catch(qmu::QmuParserError &e) + { + VExceptionObjectError excep(tr("Error creating or updating point of normal"), domElement); + QString message( "Message: " + e.GetMsg() + "\n"+ + + "Expression: \"" + e.GetExpr() + "\"\n"+ + + "Token: \"" + e.GetToken() + "\"\n"+ + + "Position: " + QString::number(e.GetPos()) + "\n"+ + + "Errc: " + QString::number(e.GetCode(), 16)); + excep.AddMoreInformation(message); + throw excep; + } break; case 5: //VToolBisector::ToolType try @@ -940,6 +985,17 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, const QDomElement &d excep.AddMoreInformation(e.ErrorMessage()); throw excep; } + catch(qmu::QmuParserError &e) + { + VExceptionObjectError excep(tr("Error creating or updating point of bisector"), domElement); + QString message( "Message: " + e.GetMsg() + "\n"+ + + "Expression: \"" + e.GetExpr() + "\"\n"+ + + "Token: \"" + e.GetToken() + "\"\n"+ + + "Position: " + QString::number(e.GetPos()) + "\n"+ + + "Errc: " + QString::number(e.GetCode(), 16)); + excep.AddMoreInformation(message); + throw excep; + } break; case 6: //VToolLineIntersect::ToolType try @@ -984,6 +1040,17 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, const QDomElement &d excep.AddMoreInformation(e.ErrorMessage()); throw excep; } + catch(qmu::QmuParserError &e) + { + VExceptionObjectError excep(tr("Error creating or updating point of contact"), domElement); + QString message( "Message: " + e.GetMsg() + "\n"+ + + "Expression: \"" + e.GetExpr() + "\"\n"+ + + "Token: \"" + e.GetToken() + "\"\n"+ + + "Position: " + QString::number(e.GetPos()) + "\n"+ + + "Errc: " + QString::number(e.GetCode(), 16)); + excep.AddMoreInformation(message); + throw excep; + } break; case 8: //VNodePoint::ToolType try @@ -1089,6 +1156,17 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, const QDomElement &d excep.AddMoreInformation(e.ErrorMessage()); throw excep; } + catch(qmu::QmuParserError &e) + { + VExceptionObjectError excep(tr("Error creating or updating cut spline point"), domElement); + QString message( "Message: " + e.GetMsg() + "\n"+ + + "Expression: \"" + e.GetExpr() + "\"\n"+ + + "Token: \"" + e.GetToken() + "\"\n"+ + + "Position: " + QString::number(e.GetPos()) + "\n"+ + + "Errc: " + QString::number(e.GetCode(), 16)); + excep.AddMoreInformation(message); + throw excep; + } break; case 13: //VToolCutSplinePath::ToolType try @@ -1109,6 +1187,17 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, const QDomElement &d excep.AddMoreInformation(e.ErrorMessage()); throw excep; } + catch(qmu::QmuParserError &e) + { + VExceptionObjectError excep(tr("Error creating or updating cut spline path point"), domElement); + QString message( "Message: " + e.GetMsg() + "\n"+ + + "Expression: \"" + e.GetExpr() + "\"\n"+ + + "Token: \"" + e.GetToken() + "\"\n"+ + + "Position: " + QString::number(e.GetPos()) + "\n"+ + + "Errc: " + QString::number(e.GetCode(), 16)); + excep.AddMoreInformation(message); + throw excep; + } break; case 14: //VToolCutArc::ToolType try @@ -1128,6 +1217,17 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, const QDomElement &d excep.AddMoreInformation(e.ErrorMessage()); throw excep; } + catch(qmu::QmuParserError &e) + { + VExceptionObjectError excep(tr("Error creating or updating cut arc point"), domElement); + QString message( "Message: " + e.GetMsg() + "\n"+ + + "Expression: \"" + e.GetExpr() + "\"\n"+ + + "Token: \"" + e.GetToken() + "\"\n"+ + + "Position: " + QString::number(e.GetPos()) + "\n"+ + + "Errc: " + QString::number(e.GetCode(), 16)); + excep.AddMoreInformation(message); + throw excep; + } break; default: qDebug() << "Illegal point type in VDomDocument::ParsePointElement()."; @@ -1311,6 +1411,17 @@ void VPattern::ParseArcElement(VMainGraphicsScene *scene, const QDomElement &dom excep.AddMoreInformation(e.ErrorMessage()); throw excep; } + catch(qmu::QmuParserError &e) + { + VExceptionObjectError excep(tr("Error creating or updating simple arc"), domElement); + QString message( "Message: " + e.GetMsg() + "\n"+ + + "Expression: \"" + e.GetExpr() + "\"\n"+ + + "Token: \"" + e.GetToken() + "\"\n"+ + + "Position: " + QString::number(e.GetPos()) + "\n"+ + + "Errc: " + QString::number(e.GetCode(), 16)); + excep.AddMoreInformation(message); + throw excep; + } break; case 1: //VNodeArc::ToolType try