From 54dfd9457e6b9346d8855e1ad6e7c128409d28dc Mon Sep 17 00:00:00 2001 From: dismine Date: Fri, 30 May 2014 14:50:41 +0300 Subject: [PATCH] Fixed issue #43. --HG-- branch : feature --- src/app/tools/drawTools/vtoolalongline.cpp | 20 ++-- src/app/tools/drawTools/vtoolalongline.h | 2 +- src/app/tools/drawTools/vtoolarc.cpp | 20 ++-- src/app/tools/drawTools/vtoolarc.h | 6 +- src/app/tools/drawTools/vtoolbisector.cpp | 15 ++- src/app/tools/drawTools/vtoolbisector.h | 2 +- src/app/tools/drawTools/vtoolcutarc.cpp | 9 +- src/app/tools/drawTools/vtoolcutarc.h | 2 +- src/app/tools/drawTools/vtoolcutspline.cpp | 14 ++- src/app/tools/drawTools/vtoolcutspline.h | 5 +- .../tools/drawTools/vtoolcutsplinepath.cpp | 9 +- src/app/tools/drawTools/vtoolcutsplinepath.h | 7 +- src/app/tools/drawTools/vtoolendline.cpp | 12 +-- src/app/tools/drawTools/vtoolheight.cpp | 10 +- src/app/tools/drawTools/vtoolline.cpp | 6 +- .../tools/drawTools/vtoollineintersect.cpp | 10 +- src/app/tools/drawTools/vtoolnormal.cpp | 15 ++- src/app/tools/drawTools/vtoolnormal.h | 2 +- .../tools/drawTools/vtoolpointofcontact.cpp | 18 ++-- src/app/tools/drawTools/vtoolpointofcontact.h | 2 +- .../drawTools/vtoolpointofintersection.cpp | 6 +- .../tools/drawTools/vtoolshoulderpoint.cpp | 15 ++- src/app/tools/drawTools/vtoolshoulderpoint.h | 2 +- src/app/tools/drawTools/vtoolspline.cpp | 14 +-- src/app/tools/drawTools/vtooltriangle.cpp | 10 +- src/app/xml/vpattern.cpp | 94 ++++++++++++++++--- src/app/xml/vpattern.h | 2 +- 27 files changed, 188 insertions(+), 141 deletions(-) diff --git a/src/app/tools/drawTools/vtoolalongline.cpp b/src/app/tools/drawTools/vtoolalongline.cpp index 1d8613d48..b6ca59ec2 100644 --- a/src/app/tools/drawTools/vtoolalongline.cpp +++ b/src/app/tools/drawTools/vtoolalongline.cpp @@ -164,27 +164,25 @@ void VToolAlongLine::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPatt DialogAlongLine *dialogTool = qobject_cast(dialog); Q_CHECK_PTR(dialogTool); QString formula = dialogTool->getFormula(); - quint32 firstPointId = dialogTool->getFirstPointId(); - quint32 secondPointId = dialogTool->getSecondPointId(); - QString typeLine = dialogTool->getTypeLine(); - QString pointName = dialogTool->getPointName(); + const quint32 firstPointId = dialogTool->getFirstPointId(); + const quint32 secondPointId = dialogTool->getSecondPointId(); + const QString typeLine = dialogTool->getTypeLine(); + const QString pointName = dialogTool->getPointName(); Create(0, pointName, typeLine, formula, firstPointId, secondPointId, 5, 10, scene, doc, data, Document::FullParse, Valentina::FromGui); } //--------------------------------------------------------------------------------------------------------------------- -void VToolAlongLine::Create(const quint32 _id, const QString &pointName, const QString &typeLine, - const QString &formula, const quint32 &firstPointId, const quint32 &secondPointId, - const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, - VContainer *data, const Document::Documents &parse, const Valentina::Sources &typeCreation) +void VToolAlongLine::Create(const quint32 _id, const QString &pointName, const QString &typeLine, QString &formula, + const quint32 &firstPointId, const quint32 &secondPointId, const qreal &mx, const qreal &my, + VMainGraphicsScene *scene, VPattern *doc, VContainer *data, + const Document::Documents &parse, const Valentina::Sources &typeCreation) { const VPointF *firstPoint = data->GeometricObject(firstPointId); const VPointF *secondPoint = data->GeometricObject(secondPointId); QLineF line = QLineF(firstPoint->toQPointF(), secondPoint->toQPointF()); - Calculator cal(data); - const qreal result = cal.EvalFormula(formula); - line.setLength(qApp->toPixel(result)); + line.setLength(qApp->toPixel(CheckFormula(formula, data))); quint32 id = _id; if (typeCreation == Valentina::FromGui) diff --git a/src/app/tools/drawTools/vtoolalongline.h b/src/app/tools/drawTools/vtoolalongline.h index f9a50f86e..8276c3954 100644 --- a/src/app/tools/drawTools/vtoolalongline.h +++ b/src/app/tools/drawTools/vtoolalongline.h @@ -81,7 +81,7 @@ public: * @param parse parser file mode. * @param typeCreation way we create this tool. */ - static void Create(const quint32 _id, const QString &pointName, const QString &typeLine, const QString &formula, + static void Create(const quint32 _id, const QString &pointName, const QString &typeLine, QString &formula, const quint32 &firstPointId, const quint32 &secondPointId, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document::Documents &parse, const Valentina::Sources &typeCreation); diff --git a/src/app/tools/drawTools/vtoolarc.cpp b/src/app/tools/drawTools/vtoolarc.cpp index af9754b26..9664f2528 100644 --- a/src/app/tools/drawTools/vtoolarc.cpp +++ b/src/app/tools/drawTools/vtoolarc.cpp @@ -73,13 +73,12 @@ void VToolArc::setDialog() } //--------------------------------------------------------------------------------------------------------------------- -void VToolArc::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, - VContainer *data) +void VToolArc::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data) { Q_CHECK_PTR(dialog); DialogArc *dialogTool = qobject_cast(dialog); Q_CHECK_PTR(dialogTool); - quint32 center = dialogTool->GetCenter(); + const quint32 center = dialogTool->GetCenter(); QString radius = dialogTool->GetRadius(); QString f1 = dialogTool->GetF1(); QString f2 = dialogTool->GetF2(); @@ -87,19 +86,16 @@ void VToolArc::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *d } //--------------------------------------------------------------------------------------------------------------------- -void VToolArc::Create(const quint32 _id, const quint32 ¢er, const QString &radius, const QString &f1, - const QString &f2, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, - const Document::Documents &parse, const Valentina::Sources &typeCreation) +void VToolArc::Create(const quint32 _id, const quint32 ¢er, QString &radius, QString &f1, QString &f2, + VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document::Documents &parse, + const Valentina::Sources &typeCreation) { qreal calcRadius = 0, calcF1 = 0, calcF2 = 0; - Calculator cal(data); + calcRadius = qApp->toPixel(CheckFormula(radius, data)); - qreal result = cal.EvalFormula(radius); - calcRadius = qApp->toPixel(result); - - calcF1 = cal.EvalFormula(f1); - calcF2 = cal.EvalFormula(f2); + calcF1 = CheckFormula(f1, data); + calcF2 = CheckFormula(f2, data); VPointF c = *data->GeometricObject(center); VArc *arc = new VArc(c, calcRadius, radius, calcF1, f1, calcF2, f2 ); diff --git a/src/app/tools/drawTools/vtoolarc.h b/src/app/tools/drawTools/vtoolarc.h index f6ae530a9..b601a230a 100644 --- a/src/app/tools/drawTools/vtoolarc.h +++ b/src/app/tools/drawTools/vtoolarc.h @@ -75,9 +75,9 @@ public: * @param parse parser file mode. * @param typeCreation way we create this tool. */ - static void Create(const quint32 _id, const quint32 ¢er, const QString &radius, const QString &f1, - const QString &f2, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, - const Document::Documents &parse, const Valentina::Sources &typeCreation); + static void Create(const quint32 _id, const quint32 ¢er, QString &radius, QString &f1, QString &f2, + VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document::Documents &parse, + const Valentina::Sources &typeCreation); static const QString TagName; static const QString ToolType; public slots: diff --git a/src/app/tools/drawTools/vtoolbisector.cpp b/src/app/tools/drawTools/vtoolbisector.cpp index 36d3436e6..07a136106 100644 --- a/src/app/tools/drawTools/vtoolbisector.cpp +++ b/src/app/tools/drawTools/vtoolbisector.cpp @@ -94,17 +94,17 @@ void VToolBisector::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPatte DialogBisector *dialogTool = qobject_cast(dialog); Q_CHECK_PTR(dialogTool); QString formula = dialogTool->getFormula(); - quint32 firstPointId = dialogTool->getFirstPointId(); - quint32 secondPointId = dialogTool->getSecondPointId(); - quint32 thirdPointId = dialogTool->getThirdPointId(); - QString typeLine = dialogTool->getTypeLine(); - QString pointName = dialogTool->getPointName(); + const quint32 firstPointId = dialogTool->getFirstPointId(); + const quint32 secondPointId = dialogTool->getSecondPointId(); + const quint32 thirdPointId = dialogTool->getThirdPointId(); + const QString typeLine = dialogTool->getTypeLine(); + const QString pointName = dialogTool->getPointName(); Create(0, formula, firstPointId, secondPointId, thirdPointId, typeLine, pointName, 5, 10, scene, doc, data, Document::FullParse, Valentina::FromGui); } //--------------------------------------------------------------------------------------------------------------------- -void VToolBisector::Create(const quint32 _id, const QString &formula, const quint32 &firstPointId, +void VToolBisector::Create(const quint32 _id, QString &formula, const quint32 &firstPointId, const quint32 &secondPointId, const quint32 &thirdPointId, const QString &typeLine, const QString &pointName, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, @@ -114,8 +114,7 @@ void VToolBisector::Create(const quint32 _id, const QString &formula, const quin const VPointF *secondPoint = data->GeometricObject(secondPointId); const VPointF *thirdPoint = data->GeometricObject(thirdPointId); - Calculator cal(data); - const qreal result = cal.EvalFormula(formula); + const qreal result = CheckFormula(formula, data); QPointF fPoint = VToolBisector::FindPoint(firstPoint->toQPointF(), secondPoint->toQPointF(), thirdPoint->toQPointF(), qApp->toPixel(result)); diff --git a/src/app/tools/drawTools/vtoolbisector.h b/src/app/tools/drawTools/vtoolbisector.h index 9af080e12..f49d6fa5b 100644 --- a/src/app/tools/drawTools/vtoolbisector.h +++ b/src/app/tools/drawTools/vtoolbisector.h @@ -93,7 +93,7 @@ public: * @param parse parser file mode. * @param typeCreation way we create this tool. */ - static void Create(const quint32 _id, const QString &formula, const quint32 &firstPointId, + static void Create(const quint32 _id, QString &formula, const quint32 &firstPointId, const quint32 &secondPointId, const quint32 &thirdPointId, const QString &typeLine, const QString &pointName, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document::Documents &parse, diff --git a/src/app/tools/drawTools/vtoolcutarc.cpp b/src/app/tools/drawTools/vtoolcutarc.cpp index 2f1a8cf81..50521d867 100644 --- a/src/app/tools/drawTools/vtoolcutarc.cpp +++ b/src/app/tools/drawTools/vtoolcutarc.cpp @@ -83,21 +83,20 @@ void VToolCutArc::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern Q_CHECK_PTR(dialog); DialogCutArc *dialogTool = qobject_cast(dialog); Q_CHECK_PTR(dialogTool); - QString pointName = dialogTool->getPointName(); + const QString pointName = dialogTool->getPointName(); QString formula = dialogTool->getFormula(); - quint32 arcId = dialogTool->getArcId(); + const quint32 arcId = dialogTool->getArcId(); Create(0, pointName, formula, arcId, 5, 10, scene, doc, data, Document::FullParse, Valentina::FromGui); } //--------------------------------------------------------------------------------------------------------------------- -void VToolCutArc::Create(const quint32 _id, const QString &pointName, const QString &formula, const quint32 &arcId, +void VToolCutArc::Create(const quint32 _id, const QString &pointName, QString &formula, const quint32 &arcId, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document::Documents &parse, const Valentina::Sources &typeCreation) { const VArc *arc = data->GeometricObject(arcId); - Calculator cal(data); - const qreal result = cal.EvalFormula(formula); + const qreal result = CheckFormula(formula, data); VArc arc1; VArc arc2; diff --git a/src/app/tools/drawTools/vtoolcutarc.h b/src/app/tools/drawTools/vtoolcutarc.h index e9933f812..53dbcd740 100644 --- a/src/app/tools/drawTools/vtoolcutarc.h +++ b/src/app/tools/drawTools/vtoolcutarc.h @@ -80,7 +80,7 @@ public: * @param parse parser file mode. * @param typeCreation way we create this tool. */ - static void Create(const quint32 _id, const QString &pointName, const QString &formula, const quint32 &arcId, + static void Create(const quint32 _id, const QString &pointName, QString &formula, const quint32 &arcId, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document::Documents &parse, const Valentina::Sources &typeCreation); static const QString ToolType; diff --git a/src/app/tools/drawTools/vtoolcutspline.cpp b/src/app/tools/drawTools/vtoolcutspline.cpp index 1f1f14c1f..4e74b31d6 100644 --- a/src/app/tools/drawTools/vtoolcutspline.cpp +++ b/src/app/tools/drawTools/vtoolcutspline.cpp @@ -83,22 +83,20 @@ void VToolCutSpline::Create(DialogTool *dialog, VMainGraphicsScene *scene, Q_CHECK_PTR(dialog); DialogCutSpline *dialogTool = qobject_cast(dialog); Q_CHECK_PTR(dialogTool); - QString pointName = dialogTool->getPointName(); + const QString pointName = dialogTool->getPointName(); QString formula = dialogTool->getFormula(); - quint32 splineId = dialogTool->getSplineId(); + const quint32 splineId = dialogTool->getSplineId(); Create(0, pointName, formula, splineId, 5, 10, scene, doc, data, Document::FullParse, Valentina::FromGui); } //--------------------------------------------------------------------------------------------------------------------- -void VToolCutSpline::Create(const quint32 _id, const QString &pointName, - const QString &formula, const quint32 &splineId, const qreal &mx, const qreal &my, - VMainGraphicsScene *scene, VPattern *doc, VContainer *data, - const Document::Documents &parse, const Valentina::Sources &typeCreation) +void VToolCutSpline::Create(const quint32 _id, const QString &pointName, QString &formula, const quint32 &splineId, + const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, + VContainer *data, const Document::Documents &parse, const Valentina::Sources &typeCreation) { const VSpline *spl = data->GeometricObject(splineId); - Calculator cal(data); - const qreal result = cal.EvalFormula(formula); + const qreal result = CheckFormula(formula, data); QPointF spl1p2, spl1p3, spl2p2, spl2p3; QPointF point = spl->CutSpline(qApp->toPixel(result), spl1p2, spl1p3, spl2p2, spl2p3); diff --git a/src/app/tools/drawTools/vtoolcutspline.h b/src/app/tools/drawTools/vtoolcutspline.h index 0bff6ea89..b5cae8641 100644 --- a/src/app/tools/drawTools/vtoolcutspline.h +++ b/src/app/tools/drawTools/vtoolcutspline.h @@ -78,9 +78,8 @@ public: * @param parse parser file mode. * @param typeCreation way we create this tool. */ - static void Create(const quint32 _id, const QString &pointName, - const QString &formula, const quint32 &splineId, const qreal &mx, const qreal &my, - VMainGraphicsScene *scene, VPattern *doc, VContainer *data, + static void Create(const quint32 _id, const QString &pointName, QString &formula, const quint32 &splineId, + const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document::Documents &parse, const Valentina::Sources &typeCreation); static const QString ToolType; static const QString AttrSpline; diff --git a/src/app/tools/drawTools/vtoolcutsplinepath.cpp b/src/app/tools/drawTools/vtoolcutsplinepath.cpp index 290aa92ef..e21db71cd 100644 --- a/src/app/tools/drawTools/vtoolcutsplinepath.cpp +++ b/src/app/tools/drawTools/vtoolcutsplinepath.cpp @@ -83,14 +83,14 @@ void VToolCutSplinePath::Create(DialogTool *dialog, VMainGraphicsScene *scene, V Q_CHECK_PTR(dialog); DialogCutSplinePath *dialogTool = qobject_cast(dialog); Q_CHECK_PTR(dialogTool); - QString pointName = dialogTool->getPointName(); + const QString pointName = dialogTool->getPointName(); QString formula = dialogTool->getFormula(); - quint32 splinePathId = dialogTool->getSplinePathId(); + const quint32 splinePathId = dialogTool->getSplinePathId(); Create(0, pointName, formula, splinePathId, 5, 10, scene, doc, data, Document::FullParse, Valentina::FromGui); } //--------------------------------------------------------------------------------------------------------------------- -void VToolCutSplinePath::Create(const quint32 _id, const QString &pointName, const QString &formula, +void VToolCutSplinePath::Create(const quint32 _id, const QString &pointName, QString &formula, const quint32 &splinePathId, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document::Documents &parse, const Valentina::Sources &typeCreation) @@ -98,8 +98,7 @@ void VToolCutSplinePath::Create(const quint32 _id, const QString &pointName, con const VSplinePath *splPath = data->GeometricObject(splinePathId); Q_CHECK_PTR(splPath); - Calculator cal(data); - const qreal result = cal.EvalFormula(formula); + const qreal result = CheckFormula(formula, data); quint32 id = _id; QPointF spl1p2, spl1p3, spl2p2, spl2p3; diff --git a/src/app/tools/drawTools/vtoolcutsplinepath.h b/src/app/tools/drawTools/vtoolcutsplinepath.h index e2c288291..9bd1c9dcd 100644 --- a/src/app/tools/drawTools/vtoolcutsplinepath.h +++ b/src/app/tools/drawTools/vtoolcutsplinepath.h @@ -81,10 +81,9 @@ public: * @param parse parser file mode. * @param typeCreation way we create this tool. */ - static void Create(const quint32 _id, const QString &pointName, const QString &formula, - const quint32 &splinePathId, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, - VPattern *doc, VContainer *data, const Document::Documents &parse, - const Valentina::Sources &typeCreation); + static void Create(const quint32 _id, const QString &pointName, QString &formula, const quint32 &splinePathId, + const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, + const Document::Documents &parse, const Valentina::Sources &typeCreation); static const QString ToolType; static const QString AttrSplinePath; public slots: diff --git a/src/app/tools/drawTools/vtoolendline.cpp b/src/app/tools/drawTools/vtoolendline.cpp index dbfece704..107a6e107 100644 --- a/src/app/tools/drawTools/vtoolendline.cpp +++ b/src/app/tools/drawTools/vtoolendline.cpp @@ -72,11 +72,11 @@ void VToolEndLine::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPatter Q_CHECK_PTR(dialog); DialogEndLine *dialogTool = qobject_cast(dialog); Q_CHECK_PTR(dialogTool); - QString pointName = dialogTool->getPointName(); - QString typeLine = dialogTool->getTypeLine(); + const QString pointName = dialogTool->getPointName(); + const QString typeLine = dialogTool->getTypeLine(); QString formula = dialogTool->getFormula(); - qreal angle = dialogTool->getAngle(); - quint32 basePointId = dialogTool->getBasePointId(); + const qreal angle = dialogTool->getAngle(); + const quint32 basePointId = dialogTool->getBasePointId(); Create(0, pointName, typeLine, formula, angle, basePointId, 5, 10, scene, doc, data, Document::FullParse, Valentina::FromGui); } @@ -90,9 +90,7 @@ 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 = CheckFormula(formula, data); - - line.setLength(qApp->toPixel(result)); + line.setLength(qApp->toPixel(CheckFormula(formula, data))); line.setAngle(angle); quint32 id = _id; if (typeCreation == Valentina::FromGui) diff --git a/src/app/tools/drawTools/vtoolheight.cpp b/src/app/tools/drawTools/vtoolheight.cpp index ab1381ac0..88b92801e 100644 --- a/src/app/tools/drawTools/vtoolheight.cpp +++ b/src/app/tools/drawTools/vtoolheight.cpp @@ -70,11 +70,11 @@ void VToolHeight::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern DialogHeight *dialogTool = qobject_cast(dialog); Q_CHECK_PTR(dialogTool); disconnect(doc, &VPattern::FullUpdateFromFile, dialogTool, &DialogHeight::UpdateList); - QString pointName = dialogTool->getPointName(); - QString typeLine = dialogTool->getTypeLine(); - quint32 basePointId = dialogTool->getBasePointId(); - quint32 p1LineId = dialogTool->getP1LineId(); - quint32 p2LineId = dialogTool->getP2LineId(); + const QString pointName = dialogTool->getPointName(); + const QString typeLine = dialogTool->getTypeLine(); + const quint32 basePointId = dialogTool->getBasePointId(); + const quint32 p1LineId = dialogTool->getP1LineId(); + const quint32 p2LineId = dialogTool->getP2LineId(); Create(0, pointName, typeLine, basePointId, p1LineId, p2LineId, 5, 10, scene, doc, data, Document::FullParse, Valentina::FromGui); } diff --git a/src/app/tools/drawTools/vtoolline.cpp b/src/app/tools/drawTools/vtoolline.cpp index d4aab43df..49014357d 100644 --- a/src/app/tools/drawTools/vtoolline.cpp +++ b/src/app/tools/drawTools/vtoolline.cpp @@ -76,9 +76,9 @@ void VToolLine::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern * Q_CHECK_PTR(dialog); DialogLine *dialogTool = qobject_cast(dialog); Q_CHECK_PTR(dialogTool); - quint32 firstPoint = dialogTool->getFirstPoint(); - quint32 secondPoint = dialogTool->getSecondPoint(); - QString typeLine = dialogTool->getTypeLine(); + const quint32 firstPoint = dialogTool->getFirstPoint(); + const quint32 secondPoint = dialogTool->getSecondPoint(); + const QString typeLine = dialogTool->getTypeLine(); Create(0, firstPoint, secondPoint, typeLine, scene, doc, data, Document::FullParse, Valentina::FromGui); } diff --git a/src/app/tools/drawTools/vtoollineintersect.cpp b/src/app/tools/drawTools/vtoollineintersect.cpp index 1f737fe20..b73cafaf0 100644 --- a/src/app/tools/drawTools/vtoollineintersect.cpp +++ b/src/app/tools/drawTools/vtoollineintersect.cpp @@ -70,11 +70,11 @@ void VToolLineIntersect::Create(DialogTool *dialog, VMainGraphicsScene *scene, V Q_CHECK_PTR(dialog); DialogLineIntersect *dialogTool = qobject_cast(dialog); Q_CHECK_PTR(dialogTool); - quint32 p1Line1Id = dialogTool->getP1Line1(); - quint32 p2Line1Id = dialogTool->getP2Line1(); - quint32 p1Line2Id = dialogTool->getP1Line2(); - quint32 p2Line2Id = dialogTool->getP2Line2(); - QString pointName = dialogTool->getPointName(); + const quint32 p1Line1Id = dialogTool->getP1Line1(); + const quint32 p2Line1Id = dialogTool->getP2Line1(); + const quint32 p1Line2Id = dialogTool->getP1Line2(); + const quint32 p2Line2Id = dialogTool->getP2Line2(); + const QString pointName = dialogTool->getPointName(); Create(0, p1Line1Id, p2Line1Id, p1Line2Id, p2Line2Id, pointName, 5, 10, scene, doc, data, Document::FullParse, Valentina::FromGui); } diff --git a/src/app/tools/drawTools/vtoolnormal.cpp b/src/app/tools/drawTools/vtoolnormal.cpp index 93f8a3efa..ef5b9ba9b 100644 --- a/src/app/tools/drawTools/vtoolnormal.cpp +++ b/src/app/tools/drawTools/vtoolnormal.cpp @@ -72,17 +72,17 @@ void VToolNormal::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern DialogNormal *dialogTool = qobject_cast(dialog); Q_CHECK_PTR(dialogTool); QString formula = dialogTool->getFormula(); - quint32 firstPointId = dialogTool->getFirstPointId(); - quint32 secondPointId = dialogTool->getSecondPointId(); - QString typeLine = dialogTool->getTypeLine(); - QString pointName = dialogTool->getPointName(); - qreal angle = dialogTool->getAngle(); + const quint32 firstPointId = dialogTool->getFirstPointId(); + const quint32 secondPointId = dialogTool->getSecondPointId(); + const QString typeLine = dialogTool->getTypeLine(); + const QString pointName = dialogTool->getPointName(); + const qreal angle = dialogTool->getAngle(); Create(0, formula, firstPointId, secondPointId, typeLine, pointName, angle, 5, 10, scene, doc, data, Document::FullParse, Valentina::FromGui); } //--------------------------------------------------------------------------------------------------------------------- -void VToolNormal::Create(const quint32 _id, const QString &formula, const quint32 &firstPointId, +void VToolNormal::Create(const quint32 _id, QString &formula, const quint32 &firstPointId, const quint32 &secondPointId, const QString &typeLine, const QString &pointName, const qreal angle, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document::Documents &parse, @@ -91,8 +91,7 @@ void VToolNormal::Create(const quint32 _id, const QString &formula, const quint3 const VPointF *firstPoint = data->GeometricObject(firstPointId); const VPointF *secondPoint = data->GeometricObject(secondPointId); - Calculator cal(data); - const qreal result = cal.EvalFormula(formula); + const qreal result = CheckFormula(formula, data); QPointF fPoint = VToolNormal::FindPoint(firstPoint->toQPointF(), secondPoint->toQPointF(), qApp->toPixel(result), angle); diff --git a/src/app/tools/drawTools/vtoolnormal.h b/src/app/tools/drawTools/vtoolnormal.h index 415b70e33..f054b3280 100644 --- a/src/app/tools/drawTools/vtoolnormal.h +++ b/src/app/tools/drawTools/vtoolnormal.h @@ -84,7 +84,7 @@ public: * @param parse parser file mode. * @param typeCreation way we create this tool. */ - static void Create(const quint32 _id, const QString &formula, const quint32 &firstPointId, + static void Create(const quint32 _id, QString &formula, const quint32 &firstPointId, const quint32 &secondPointId, const QString &typeLine, const QString &pointName, const qreal angle, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document::Documents &parse, diff --git a/src/app/tools/drawTools/vtoolpointofcontact.cpp b/src/app/tools/drawTools/vtoolpointofcontact.cpp index ae836dea3..25d942d7c 100644 --- a/src/app/tools/drawTools/vtoolpointofcontact.cpp +++ b/src/app/tools/drawTools/vtoolpointofcontact.cpp @@ -98,27 +98,25 @@ void VToolPointOfContact::Create(DialogTool *dialog, VMainGraphicsScene *scene, DialogPointOfContact *dialogTool = qobject_cast(dialog); Q_CHECK_PTR(dialogTool); QString radius = dialogTool->getRadius(); - quint32 center = dialogTool->getCenter(); - quint32 firstPointId = dialogTool->getFirstPoint(); - quint32 secondPointId = dialogTool->getSecondPoint(); - QString pointName = dialogTool->getPointName(); + const quint32 center = dialogTool->getCenter(); + const quint32 firstPointId = dialogTool->getFirstPoint(); + const quint32 secondPointId = dialogTool->getSecondPoint(); + const QString pointName = dialogTool->getPointName(); Create(0, radius, center, firstPointId, secondPointId, pointName, 5, 10, scene, doc, data, Document::FullParse, Valentina::FromGui); } //--------------------------------------------------------------------------------------------------------------------- -void VToolPointOfContact::Create(const quint32 _id, const QString &radius, const quint32 ¢er, - const quint32 &firstPointId, const quint32 &secondPointId, - const QString &pointName, const qreal &mx, const qreal &my, - VMainGraphicsScene *scene, VPattern *doc, VContainer *data, +void VToolPointOfContact::Create(const quint32 _id, QString &radius, const quint32 ¢er, const quint32 &firstPointId, + const quint32 &secondPointId, const QString &pointName, const qreal &mx, + const qreal &my, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document::Documents &parse, const Valentina::Sources &typeCreation) { const VPointF *centerP = data->GeometricObject(center); const VPointF *firstP = data->GeometricObject(firstPointId); const VPointF *secondP = data->GeometricObject(secondPointId); - Calculator cal(data); - const qreal result = cal.EvalFormula(radius); + const qreal result = CheckFormula(radius, data); QPointF fPoint = VToolPointOfContact::FindPoint(qApp->toPixel(result), centerP->toQPointF(), firstP->toQPointF(), secondP->toQPointF()); diff --git a/src/app/tools/drawTools/vtoolpointofcontact.h b/src/app/tools/drawTools/vtoolpointofcontact.h index b283f238a..ce02fdd50 100644 --- a/src/app/tools/drawTools/vtoolpointofcontact.h +++ b/src/app/tools/drawTools/vtoolpointofcontact.h @@ -91,7 +91,7 @@ public: * @param parse parser file mode. * @param typeCreation way we create this tool. */ - static void Create(const quint32 _id, const QString &arcRadius, const quint32 ¢er, + static void Create(const quint32 _id, QString &arcRadius, const quint32 ¢er, const quint32 &firstPointId, const quint32 &secondPointId, const QString &pointName, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document::Documents &parse, const Valentina::Sources &typeCreation); diff --git a/src/app/tools/drawTools/vtoolpointofintersection.cpp b/src/app/tools/drawTools/vtoolpointofintersection.cpp index 8d0a35a14..9ff688a39 100644 --- a/src/app/tools/drawTools/vtoolpointofintersection.cpp +++ b/src/app/tools/drawTools/vtoolpointofintersection.cpp @@ -67,9 +67,9 @@ void VToolPointOfIntersection::Create(DialogTool *dialog, VMainGraphicsScene *sc Q_CHECK_PTR(dialog); DialogPointOfIntersection *dialogTool = qobject_cast(dialog); Q_CHECK_PTR(dialogTool); - quint32 firstPointId = dialogTool->getFirstPointId(); - quint32 secondPointId = dialogTool->getSecondPointId(); - QString pointName = dialogTool->getPointName(); + const quint32 firstPointId = dialogTool->getFirstPointId(); + const quint32 secondPointId = dialogTool->getSecondPointId(); + const QString pointName = dialogTool->getPointName(); Create(0, pointName, firstPointId, secondPointId, 5, 10, scene, doc, data, Document::FullParse, Valentina::FromGui); } diff --git a/src/app/tools/drawTools/vtoolshoulderpoint.cpp b/src/app/tools/drawTools/vtoolshoulderpoint.cpp index cd29ce3b1..354aec712 100644 --- a/src/app/tools/drawTools/vtoolshoulderpoint.cpp +++ b/src/app/tools/drawTools/vtoolshoulderpoint.cpp @@ -100,17 +100,17 @@ void VToolShoulderPoint::Create(DialogTool *dialog, VMainGraphicsScene *scene, V DialogShoulderPoint *dialogTool = qobject_cast(dialog); Q_CHECK_PTR(dialogTool); QString formula = dialogTool->getFormula(); - quint32 p1Line = dialogTool->getP1Line(); - quint32 p2Line = dialogTool->getP2Line(); - quint32 pShoulder = dialogTool->getPShoulder(); - QString typeLine = dialogTool->getTypeLine(); - QString pointName = dialogTool->getPointName(); + const quint32 p1Line = dialogTool->getP1Line(); + const quint32 p2Line = dialogTool->getP2Line(); + const quint32 pShoulder = dialogTool->getPShoulder(); + const QString typeLine = dialogTool->getTypeLine(); + const QString pointName = dialogTool->getPointName(); Create(0, formula, p1Line, p2Line, pShoulder, typeLine, pointName, 5, 10, scene, doc, data, Document::FullParse, Valentina::FromGui); } //--------------------------------------------------------------------------------------------------------------------- -void VToolShoulderPoint::Create(const quint32 _id, const QString &formula, const quint32 &p1Line, +void VToolShoulderPoint::Create(const quint32 _id, QString &formula, const quint32 &p1Line, const quint32 &p2Line, const quint32 &pShoulder, const QString &typeLine, const QString &pointName, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, @@ -120,8 +120,7 @@ void VToolShoulderPoint::Create(const quint32 _id, const QString &formula, const const VPointF *secondPoint = data->GeometricObject(p2Line); const VPointF *shoulderPoint = data->GeometricObject(pShoulder); - Calculator cal(data); - const qreal result = cal.EvalFormula(formula); + const qreal result = CheckFormula(formula, data); QPointF fPoint = VToolShoulderPoint::FindPoint(firstPoint->toQPointF(), secondPoint->toQPointF(), shoulderPoint->toQPointF(), qApp->toPixel(result)); diff --git a/src/app/tools/drawTools/vtoolshoulderpoint.h b/src/app/tools/drawTools/vtoolshoulderpoint.h index ba5e2b96f..9e9462d9d 100644 --- a/src/app/tools/drawTools/vtoolshoulderpoint.h +++ b/src/app/tools/drawTools/vtoolshoulderpoint.h @@ -94,7 +94,7 @@ public: * @param parse parser file mode. * @param typeCreation way we create this tool. */ - static void Create(const quint32 _id, const QString &formula, const quint32 &p1Line, const quint32 &p2Line, + static void Create(const quint32 _id, QString &formula, const quint32 &p1Line, const quint32 &p2Line, const quint32 &pShoulder, const QString &typeLine, const QString &pointName, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document::Documents &parse, const Valentina::Sources &typeCreation); diff --git a/src/app/tools/drawTools/vtoolspline.cpp b/src/app/tools/drawTools/vtoolspline.cpp index ca87c745a..0e0a5e844 100644 --- a/src/app/tools/drawTools/vtoolspline.cpp +++ b/src/app/tools/drawTools/vtoolspline.cpp @@ -95,13 +95,13 @@ void VToolSpline::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern Q_CHECK_PTR(dialog); DialogSpline *dialogTool = qobject_cast(dialog); Q_CHECK_PTR(dialogTool); - quint32 p1 = dialogTool->getP1(); - quint32 p4 = dialogTool->getP4(); - qreal kAsm1 = dialogTool->getKAsm1(); - qreal kAsm2 = dialogTool->getKAsm2(); - qreal angle1 = dialogTool->getAngle1(); - qreal angle2 = dialogTool->getAngle2(); - qreal kCurve = dialogTool->getKCurve(); + const quint32 p1 = dialogTool->getP1(); + const quint32 p4 = dialogTool->getP4(); + const qreal kAsm1 = dialogTool->getKAsm1(); + const qreal kAsm2 = dialogTool->getKAsm2(); + const qreal angle1 = dialogTool->getAngle1(); + const qreal angle2 = dialogTool->getAngle2(); + const qreal kCurve = dialogTool->getKCurve(); Create(0, p1, p4, kAsm1, kAsm2, angle1, angle2, kCurve, scene, doc, data, Document::FullParse, Valentina::FromGui); } diff --git a/src/app/tools/drawTools/vtooltriangle.cpp b/src/app/tools/drawTools/vtooltriangle.cpp index d9c679201..28ca05b8c 100644 --- a/src/app/tools/drawTools/vtooltriangle.cpp +++ b/src/app/tools/drawTools/vtooltriangle.cpp @@ -70,11 +70,11 @@ void VToolTriangle::Create(DialogTool *dialog, VMainGraphicsScene *scene, Q_CHECK_PTR(dialog); DialogTriangle *dialogTool = qobject_cast(dialog); Q_CHECK_PTR(dialogTool); - quint32 axisP1Id = dialogTool->getAxisP1Id(); - quint32 axisP2Id = dialogTool->getAxisP2Id(); - quint32 firstPointId = dialogTool->getFirstPointId(); - quint32 secondPointId = dialogTool->getSecondPointId(); - QString pointName = dialogTool->getPointName(); + const quint32 axisP1Id = dialogTool->getAxisP1Id(); + const quint32 axisP2Id = dialogTool->getAxisP2Id(); + const quint32 firstPointId = dialogTool->getFirstPointId(); + const quint32 secondPointId = dialogTool->getSecondPointId(); + const QString pointName = dialogTool->getPointName(); Create(0, pointName, axisP1Id, axisP2Id, firstPointId, secondPointId, 5, 10, scene, doc, data, Document::FullParse, Valentina::FromGui); } diff --git a/src/app/xml/vpattern.cpp b/src/app/xml/vpattern.cpp index 8a885a141..67fb89c45 100644 --- a/src/app/xml/vpattern.cpp +++ b/src/app/xml/vpattern.cpp @@ -845,7 +845,7 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem //Rewrite attribute formula. Need for situation when we have wrong formula. if (f != formula) { - SetAttribute(domElement, VToolEndLine::AttrLength, f); + SetAttribute(domElement, VAbstractTool::AttrLength, f); haveLiteChange(); } } @@ -874,11 +874,18 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem const QString typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine, VAbstractTool::TypeLineLine); const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0"); + QString f = formula;//need for saving fixed formula; const quint32 firstPointId = GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0"); const quint32 secondPointId = GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0"); - VToolAlongLine::Create(id, name, typeLine, formula, firstPointId, secondPointId, mx, my, scene, this, + VToolAlongLine::Create(id, name, typeLine, f, firstPointId, secondPointId, mx, my, scene, this, data, parse, Valentina::FromFile); + //Rewrite attribute formula. Need for situation when we have wrong formula. + if (f != formula) + { + SetAttribute(domElement, VAbstractTool::AttrLength, f); + haveLiteChange(); + } } catch (const VExceptionBadId &e) { @@ -905,12 +912,19 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem const QString typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine, VAbstractTool::TypeLineLine); const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0"); + QString f = formula;//need for saving fixed formula; const quint32 p1Line = GetParametrUInt(domElement, VAbstractTool::AttrP1Line, "0"); const quint32 p2Line = GetParametrUInt(domElement, VAbstractTool::AttrP2Line, "0"); const quint32 pShoulder = GetParametrUInt(domElement, VAbstractTool::AttrPShoulder, "0"); - VToolShoulderPoint::Create(id, formula, p1Line, p2Line, pShoulder, typeLine, name, mx, my, scene, this, + VToolShoulderPoint::Create(id, f, p1Line, p2Line, pShoulder, typeLine, name, mx, my, scene, this, data, parse, Valentina::FromFile); + //Rewrite attribute formula. Need for situation when we have wrong formula. + if (f != formula) + { + SetAttribute(domElement, VAbstractTool::AttrLength, f); + haveLiteChange(); + } } catch (const VExceptionBadId &e) { @@ -937,12 +951,19 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem const QString typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine, VAbstractTool::TypeLineLine); const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0"); + QString f = formula;//need for saving fixed formula; const quint32 firstPointId = GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0"); const quint32 secondPointId = GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0"); const qreal angle = GetParametrDouble(domElement, VAbstractTool::AttrAngle, "0.0"); - VToolNormal::Create(id, formula, firstPointId, secondPointId, typeLine, name, angle, mx, my, scene, + VToolNormal::Create(id, f, firstPointId, secondPointId, typeLine, name, angle, mx, my, scene, this, data, parse, Valentina::FromFile); + //Rewrite attribute formula. Need for situation when we have wrong formula. + if (f != formula) + { + SetAttribute(domElement, VAbstractTool::AttrLength, f); + haveLiteChange(); + } } catch (const VExceptionBadId &e) { @@ -969,12 +990,19 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem const QString typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine, VAbstractTool::TypeLineLine); const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0"); + QString f = formula;//need for saving fixed formula; const quint32 firstPointId = GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0"); const quint32 secondPointId = GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0"); const quint32 thirdPointId = GetParametrUInt(domElement, VAbstractTool::AttrThirdPoint, "0"); - VToolBisector::Create(id, formula, firstPointId, secondPointId, thirdPointId, + VToolBisector::Create(id, f, firstPointId, secondPointId, thirdPointId, typeLine, name, mx, my, scene, this, data, parse, Valentina::FromFile); + //Rewrite attribute formula. Need for situation when we have wrong formula. + if (f != formula) + { + SetAttribute(domElement, VAbstractTool::AttrLength, f); + haveLiteChange(); + } } catch (const VExceptionBadId &e) { @@ -1021,12 +1049,19 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0")); const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0")); const QString radius = GetParametrString(domElement, VAbstractTool::AttrRadius, "0"); + QString f = radius;//need for saving fixed formula; const quint32 center = GetParametrUInt(domElement, VAbstractTool::AttrCenter, "0"); const quint32 firstPointId = GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0"); const quint32 secondPointId = GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0"); - VToolPointOfContact::Create(id, radius, center, firstPointId, secondPointId, name, mx, my, scene, this, + VToolPointOfContact::Create(id, f, center, firstPointId, secondPointId, name, mx, my, scene, this, data, parse, Valentina::FromFile); + //Rewrite attribute formula. Need for situation when we have wrong formula. + if (f != radius) + { + SetAttribute(domElement, VAbstractTool::AttrRadius, f); + haveLiteChange(); + } } catch (const VExceptionBadId &e) { @@ -1136,10 +1171,16 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0")); const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0")); const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "0"); + QString f = formula;//need for saving fixed formula; const quint32 splineId = GetParametrUInt(domElement, VToolCutSpline::AttrSpline, "0"); - VToolCutSpline::Create(id, name, formula, splineId, mx, my, scene, this, data, parse, - Valentina::FromFile); + VToolCutSpline::Create(id, name, f, splineId, mx, my, scene, this, data, parse, Valentina::FromFile); + //Rewrite attribute formula. Need for situation when we have wrong formula. + if (f != formula) + { + SetAttribute(domElement, VAbstractTool::AttrLength, f); + haveLiteChange(); + } } catch (const VExceptionBadId &e) { @@ -1164,10 +1205,17 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0")); const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0")); const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "0"); + QString f = formula;//need for saving fixed formula; const quint32 splinePathId = GetParametrUInt(domElement, VToolCutSplinePath::AttrSplinePath, "0"); - VToolCutSplinePath::Create(id, name, formula, splinePathId, mx, my, - scene, this, data, parse, Valentina::FromFile); + VToolCutSplinePath::Create(id, name, f, splinePathId, mx, my, scene, this, data, parse, + Valentina::FromFile); + //Rewrite attribute formula. Need for situation when we have wrong formula. + if (f != formula) + { + SetAttribute(domElement, VAbstractTool::AttrLength, f); + haveLiteChange(); + } } catch (const VExceptionBadId &e) { @@ -1192,9 +1240,16 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0")); const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0")); const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "0"); + QString f = formula;//need for saving fixed formula; const quint32 arcId = GetParametrUInt(domElement, VToolCutArc::AttrArc, "0"); - VToolCutArc::Create(id, name, formula, arcId, mx, my, scene, this, data, parse, Valentina::FromFile); + VToolCutArc::Create(id, name, f, arcId, mx, my, scene, this, data, parse, Valentina::FromFile); + //Rewrite attribute formula. Need for situation when we have wrong formula. + if (f != formula) + { + SetAttribute(domElement, VAbstractTool::AttrLength, f); + haveLiteChange(); + } } catch (const VExceptionBadId &e) { @@ -1364,8 +1419,8 @@ void VPattern::ParseSplineElement(VMainGraphicsScene *scene, const QDomElement & } //--------------------------------------------------------------------------------------------------------------------- -void VPattern::ParseArcElement(VMainGraphicsScene *scene, const QDomElement &domElement, - const Document::Documents &parse, const QString &type) +void VPattern::ParseArcElement(VMainGraphicsScene *scene, QDomElement &domElement, const Document::Documents &parse, + const QString &type) { Q_CHECK_PTR(scene); Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null"); @@ -1381,10 +1436,21 @@ void VPattern::ParseArcElement(VMainGraphicsScene *scene, const QDomElement &dom const quint32 id = GetParametrId(domElement); const quint32 center = GetParametrUInt(domElement, VAbstractTool::AttrCenter, "0"); const QString radius = GetParametrString(domElement, VAbstractTool::AttrRadius, "10"); + QString r = radius;//need for saving fixed formula; const QString f1 = GetParametrString(domElement, VAbstractTool::AttrAngle1, "180"); + QString f1Fix = f1;//need for saving fixed formula; const QString f2 = GetParametrString(domElement, VAbstractTool::AttrAngle2, "270"); + QString f2Fix = f2;//need for saving fixed formula; - VToolArc::Create(id, center, radius, f1, f2, scene, this, data, parse, Valentina::FromFile); + VToolArc::Create(id, center, r, f1Fix, f2Fix, scene, this, data, parse, Valentina::FromFile); + //Rewrite attribute formula. Need for situation when we have wrong formula. + if (r != radius || f1Fix != f1 || f2Fix != f2) + { + SetAttribute(domElement, VAbstractTool::AttrRadius, r); + SetAttribute(domElement, VAbstractTool::AttrAngle1, f1Fix); + SetAttribute(domElement, VAbstractTool::AttrAngle2, f2Fix); + haveLiteChange(); + } } catch (const VExceptionBadId &e) { diff --git a/src/app/xml/vpattern.h b/src/app/xml/vpattern.h index 79ed6b197..8d32ed97a 100644 --- a/src/app/xml/vpattern.h +++ b/src/app/xml/vpattern.h @@ -363,7 +363,7 @@ private: * @param type type of spline. * @param mode draw mode. */ - void ParseArcElement(VMainGraphicsScene *scene, const QDomElement& domElement, + void ParseArcElement(VMainGraphicsScene *scene, QDomElement &domElement, const Document::Documents &parse, const QString& type); /** * @brief ParseToolsElement parse tools tag.