diff --git a/src/app/valentina/core/vtooloptionspropertybrowser.cpp b/src/app/valentina/core/vtooloptionspropertybrowser.cpp index 072cb8ddb..da1c1104c 100644 --- a/src/app/valentina/core/vtooloptionspropertybrowser.cpp +++ b/src/app/valentina/core/vtooloptionspropertybrowser.cpp @@ -77,7 +77,7 @@ void VToolOptionsPropertyBrowser::ClearPropertyBrowser() void VToolOptionsPropertyBrowser::ShowItemOptions(QGraphicsItem *item) { // This check helps to find missed tools in the switch - Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 51, "Not all tools were used in switch."); + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 52, "Not all tools were used in switch."); switch (item->type()) { @@ -213,7 +213,7 @@ void VToolOptionsPropertyBrowser::UpdateOptions() } // This check helps to find missed tools in the switch - Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 51, "Not all tools were used in switch."); + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 52, "Not all tools were used in switch."); switch (currentItem->type()) { @@ -360,7 +360,7 @@ void VToolOptionsPropertyBrowser::userChangedData(VProperty *property) } // This check helps to find missed tools in the switch - Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 51, "Not all tools were used in switch."); + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 52, "Not all tools were used in switch."); switch (currentItem->type()) { diff --git a/src/app/valentina/dialogs/dialoghistory.cpp b/src/app/valentina/dialogs/dialoghistory.cpp index c5a6e8014..b5483ac93 100644 --- a/src/app/valentina/dialogs/dialoghistory.cpp +++ b/src/app/valentina/dialogs/dialoghistory.cpp @@ -209,7 +209,7 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default") QString DialogHistory::Record(const VToolRecord &tool) { // This check helps to find missed tools in the switch - Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 51, "Not all tools was used in history."); + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 52, "Not all tools were used in history."); const QDomElement domElem = doc->elementById(tool.getId()); if (domElem.isElement() == false) @@ -393,6 +393,7 @@ QString DialogHistory::Record(const VToolRecord &tool) case Tool::Piece: case Tool::UnionDetails: case Tool::NodeArc: + case Tool::NodeElArc: case Tool::NodePoint: case Tool::NodeSpline: case Tool::NodeSplinePath: diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index f995b073b..2918c24cd 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -1769,7 +1769,7 @@ void MainWindow::InitToolButtons() } // This check helps to find missed tools - Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 51, "Check if all tools were connected."); + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 52, "Check if all tools were connected."); connect(ui->toolButtonEndLine, &QToolButton::clicked, this, &MainWindow::ToolEndLine); connect(ui->toolButtonLine, &QToolButton::clicked, this, &MainWindow::ToolLine); @@ -1842,7 +1842,7 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default") void MainWindow::CancelTool() { // This check helps to find missed tools in the switch - Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 51, "Not all tools were handled."); + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 52, "Not all tools were handled."); qCDebug(vMainWindow, "Canceling tool."); delete dialogTool; @@ -1875,6 +1875,7 @@ void MainWindow::CancelTool() case Tool::LAST_ONE_DO_NOT_USE: case Tool::NodePoint: case Tool::NodeArc: + case Tool::NodeElArc: case Tool::NodeSpline: case Tool::NodeSplinePath: Q_UNREACHABLE(); //-V501 @@ -3052,7 +3053,7 @@ void MainWindow::SetEnableTool(bool enable) } // This check helps to find missed tools - Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 51, "Not all tools were handled."); + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 52, "Not all tools were handled."); //Drawing Tools ui->toolButtonEndLine->setEnabled(drawTools); @@ -3374,7 +3375,7 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default") void MainWindow::LastUsedTool() { // This check helps to find missed tools in the switch - Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 51, "Not all tools were handled."); + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 52, "Not all tools were handled."); if (currentTool == lastUsedTool) { @@ -3399,6 +3400,7 @@ void MainWindow::LastUsedTool() case Tool::LAST_ONE_DO_NOT_USE: case Tool::NodePoint: case Tool::NodeArc: + case Tool::NodeElArc: case Tool::NodeSpline: case Tool::NodeSplinePath: Q_UNREACHABLE(); //-V501 diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index 27a417254..562f4519d 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -45,6 +45,7 @@ #include "../vmisc/vmath.h" #include "../qmuparser/qmuparsererror.h" #include "../vgeometry/varc.h" +#include "../vgeometry/vellipticalarc.h" #include "../vgeometry/vsplinepath.h" #include "../vgeometry/vcubicbezier.h" #include "../vgeometry/vcubicbezierpath.h" @@ -535,7 +536,8 @@ VNodeDetail VPattern::ParseDetailNode(const QDomElement &domElement) const QStringList types = QStringList() << VAbstractPattern::NodePoint << VAbstractPattern::NodeArc << VAbstractPattern::NodeSpline - << VAbstractPattern::NodeSplinePath; + << VAbstractPattern::NodeSplinePath + << VAbstractPattern::NodeElArc; switch (types.indexOf(t)) { case 0: // NodePoint @@ -550,6 +552,9 @@ VNodeDetail VPattern::ParseDetailNode(const QDomElement &domElement) const case 3: // NodeSplinePath tool = Tool::NodeSplinePath; break; + case 4: // NodeElArc + tool = Tool::NodeElArc; + break; default: VException e(tr("Wrong tag name '%1'.").arg(t)); throw e; @@ -2694,6 +2699,41 @@ void VPattern::ParseToolEllipticalArc(VMainGraphicsScene *scene, QDomElement &do } } +//--------------------------------------------------------------------------------------------------------------------- +void VPattern::ParseNodeEllipticalArc(const QDomElement &domElement, const Document &parse) +{ + Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null"); + + try + { + quint32 id = 0; + + ToolsCommonAttributes(domElement, id); + const quint32 idObject = GetParametrUInt(domElement, AttrIdObject, NULL_ID_STR); + const quint32 idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, NULL_ID_STR); + VEllipticalArc *arc = nullptr; + try + { + arc = new VEllipticalArc(*data->GeometricObject(idObject)); + } + catch (const VExceptionBadId &e) + { // Possible case. Parent was deleted, but the node object is still here. + Q_UNUSED(e); + return;// Just ignore + } + arc->setIdObject(idObject); + arc->setMode(Draw::Modeling); + data->UpdateGObject(id, arc); + VNodeEllipticalArc::Create(this, data, id, idObject, parse, Source::FromFile, "", idTool); + } + catch (const VExceptionBadId &e) + { + VExceptionObjectError excep(tr("Error creating or updating modeling elliptical arc"), domElement); + excep.AddMoreInformation(e.ErrorMessage()); + throw excep; + } +} + //--------------------------------------------------------------------------------------------------------------------- void VPattern::ParseNodeArc(const QDomElement &domElement, const Document &parse) { @@ -3136,13 +3176,17 @@ void VPattern::ParseEllipticalArcElement(VMainGraphicsScene *scene, QDomElement Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null"); Q_ASSERT_X(not type.isEmpty(), Q_FUNC_INFO, "type of elliptical arc is empty"); - QStringList arcs = QStringList() << VToolEllipticalArc::ToolType; /*0*/ + const QStringList arcs = QStringList() << VToolEllipticalArc::ToolType /*0*/ + << VNodeEllipticalArc::ToolType; /*1*/ switch (arcs.indexOf(type)) { case 0: //VToolArc::ToolType ParseToolEllipticalArc(scene, domElement, parse); break; + case 1: //VNodeEllipticalArc::ToolType + ParseNodeEllipticalArc(domElement, parse); + break; default: VException e(tr("Unknown elliptical arc type '%1'.").arg(type)); throw e; @@ -3776,7 +3820,7 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default") QRectF VPattern::ActiveDrawBoundingRect() const { // This check helps to find missed tools in the switch - Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 51, "Not all tools were used."); + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 52, "Not all tools were used."); QRectF rec; @@ -3905,6 +3949,7 @@ QRectF VPattern::ActiveDrawBoundingRect() const case Tool::Piece: case Tool::UnionDetails: case Tool::NodeArc: + case Tool::NodeElArc: case Tool::NodePoint: case Tool::NodeSpline: case Tool::NodeSplinePath: diff --git a/src/app/valentina/xml/vpattern.h b/src/app/valentina/xml/vpattern.h index 8570b15d8..53d3b663a 100644 --- a/src/app/valentina/xml/vpattern.h +++ b/src/app/valentina/xml/vpattern.h @@ -135,7 +135,7 @@ private: void ParseArcElement(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse, const QString& type); void ParseEllipticalArcElement(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse, - const QString &type); + const QString &type); void ParseToolsElement(VMainGraphicsScene *scene, const QDomElement& domElement, const Document &parse, const QString& type); void ParseOperationElement(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse, @@ -209,6 +209,7 @@ private: void ParseToolArcWithLength(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse); void ParseToolEllipticalArc(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse); + void ParseNodeEllipticalArc(const QDomElement &domElement, const Document &parse); void ParseToolRotation(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse); void ParseToolFlippingByLine(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse); diff --git a/src/libs/ifc/xml/vabstractpattern.cpp b/src/libs/ifc/xml/vabstractpattern.cpp index 33cb16d1d..b0a9596be 100644 --- a/src/libs/ifc/xml/vabstractpattern.cpp +++ b/src/libs/ifc/xml/vabstractpattern.cpp @@ -166,6 +166,7 @@ const QString VAbstractPattern::IncrementFormula = QStringLiteral("formula") const QString VAbstractPattern::IncrementDescription = QStringLiteral("description"); const QString VAbstractPattern::NodeArc = QStringLiteral("NodeArc"); +const QString VAbstractPattern::NodeElArc = QStringLiteral("NodeElArc"); const QString VAbstractPattern::NodePoint = QStringLiteral("NodePoint"); const QString VAbstractPattern::NodeSpline = QStringLiteral("NodeSpline"); const QString VAbstractPattern::NodeSplinePath = QStringLiteral("NodeSplinePath"); @@ -656,6 +657,7 @@ quint32 VAbstractPattern::SiblingNodeId(const quint32 &nodeId) const case Tool::Detail: case Tool::UnionDetails: case Tool::NodeArc: + case Tool::NodeElArc: case Tool::NodePoint: case Tool::NodeSpline: case Tool::NodeSplinePath: @@ -1444,7 +1446,7 @@ QStringList VAbstractPattern::ListPointExpressions() const // Check if new tool doesn't bring new attribute with a formula. // If no just increment a number. // If new tool bring absolutely new type and has formula(s) create new method to cover it. - Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 51); + Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 52); QStringList expressions; const QDomNodeList list = elementsByTagName(TagPoint); @@ -1516,7 +1518,7 @@ QStringList VAbstractPattern::ListArcExpressions() const // Check if new tool doesn't bring new attribute with a formula. // If no just increment number. // If new tool bring absolutely new type and has formula(s) create new method to cover it. - Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 51); + Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 52); QStringList expressions; const QDomNodeList list = elementsByTagName(TagArc); @@ -1570,7 +1572,7 @@ QStringList VAbstractPattern::ListElArcExpressions() const // Check if new tool doesn't bring new attribute with a formula. // If no just increment number. // If new tool bring absolutely new type and has formula(s) create new method to cover it. - Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 51); + Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 52); QStringList expressions; const QDomNodeList list = elementsByTagName(TagElArc); @@ -1641,7 +1643,7 @@ QStringList VAbstractPattern::ListPathPointExpressions() const // Check if new tool doesn't bring new attribute with a formula. // If no just increment number. // If new tool bring absolutely new type and has formula(s) create new method to cover it. - Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 51); + Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 52); QStringList expressions; const QDomNodeList list = elementsByTagName(AttrPathPoint); @@ -1708,7 +1710,7 @@ QStringList VAbstractPattern::ListOperationExpressions() const // Check if new tool doesn't bring new attribute with a formula. // If no just increment number. // If new tool bring absolutely new type and has formula(s) create new method to cover it. - Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 51); + Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 52); QStringList expressions; const QDomNodeList list = elementsByTagName(TagOperation); diff --git a/src/libs/ifc/xml/vabstractpattern.h b/src/libs/ifc/xml/vabstractpattern.h index 1adf77f14..1e2c8e34c 100644 --- a/src/libs/ifc/xml/vabstractpattern.h +++ b/src/libs/ifc/xml/vabstractpattern.h @@ -269,6 +269,7 @@ public: static const QString IncrementDescription; static const QString NodeArc; + static const QString NodeElArc; static const QString NodePoint; static const QString NodeSpline; static const QString NodeSplinePath; diff --git a/src/libs/vgeometry/vellipticalarc.h b/src/libs/vgeometry/vellipticalarc.h index 8527f3498..3d0cc0fe4 100644 --- a/src/libs/vgeometry/vellipticalarc.h +++ b/src/libs/vgeometry/vellipticalarc.h @@ -57,7 +57,8 @@ public: VEllipticalArc (const VPointF ¢er, qreal radius1, qreal radius2, qreal f1, qreal f2, qreal rotationAngle); VEllipticalArc (qreal length, const QString &formulaLength, const VPointF ¢er, qreal radius1, qreal radius2, const QString &formulaRadius1, const QString &formulaRadius2, qreal f1, const QString &formulaF1, - qreal rotationAngle, const QString &formulaRotationAngle, quint32 idObject = 0, Draw mode = Draw::Calculation); + qreal rotationAngle, const QString &formulaRotationAngle, quint32 idObject = 0, + Draw mode = Draw::Calculation); VEllipticalArc (qreal length, const VPointF ¢er, qreal radius1, qreal radius2, qreal f1, qreal rotationAngle); VEllipticalArc(const VEllipticalArc &arc); diff --git a/src/libs/vmisc/def.h b/src/libs/vmisc/def.h index 308655d71..8a0790b1a 100644 --- a/src/libs/vmisc/def.h +++ b/src/libs/vmisc/def.h @@ -57,7 +57,7 @@ class VTranslateMeasurements; #define DefPointRadius 1.5//mm enum class NodeDetail : char { Contour, Modeling }; -enum class SceneObject : char { Point, Line, Spline, Arc, SplinePath, Detail, Unknown }; +enum class SceneObject : char { Point, Line, Spline, Arc, ElArc, SplinePath, Detail, Unknown }; enum class MeasurementsType : char { Standard, Individual , Unknown}; enum class Unit : char { Mm = 0, Cm, Inch, Px, LAST_UNIT_DO_NOT_USE}; enum class Source : char { FromGui, FromFile, FromTool }; @@ -114,6 +114,7 @@ enum class Tool : ToolVisHolderType PiecePath, NodePoint, NodeArc, + NodeElArc, NodeSpline, NodeSplinePath, Height, diff --git a/src/libs/vpatterndb/vdetail.cpp b/src/libs/vpatterndb/vdetail.cpp index 3da63174e..665f3fd9b 100644 --- a/src/libs/vpatterndb/vdetail.cpp +++ b/src/libs/vpatterndb/vdetail.cpp @@ -404,6 +404,7 @@ QVector VDetail::ContourPoints(const VContainer *data) const } break; case (Tool::NodeArc): + case (Tool::NodeElArc): case (Tool::NodeSpline): case (Tool::NodeSplinePath): { @@ -448,6 +449,7 @@ QVector VDetail::SeamAllowancePoints(const VContainer *data) const } break; case (Tool::NodeArc): + case (Tool::NodeElArc): case (Tool::NodeSpline): case (Tool::NodeSplinePath): { diff --git a/src/libs/vtools/dialogs/tools/dialogcurveintersectaxis.cpp b/src/libs/vtools/dialogs/tools/dialogcurveintersectaxis.cpp index d4ae3165e..272dae97c 100644 --- a/src/libs/vtools/dialogs/tools/dialogcurveintersectaxis.cpp +++ b/src/libs/vtools/dialogs/tools/dialogcurveintersectaxis.cpp @@ -229,7 +229,10 @@ void DialogCurveIntersectAxis::ChosenObject(quint32 id, const SceneObject &type) switch (number) { case (0): - if (type == SceneObject::Spline || type == SceneObject::Arc || type == SceneObject::SplinePath) + if (type == SceneObject::Spline + || type == SceneObject::Arc + || type == SceneObject::ElArc + || type == SceneObject::SplinePath) { if (SetObject(id, ui->comboBoxCurve, tr("Select axis point"))) { diff --git a/src/libs/vtools/dialogs/tools/dialogdetail.cpp b/src/libs/vtools/dialogs/tools/dialogdetail.cpp index 6b0a6333c..1475c6f29 100644 --- a/src/libs/vtools/dialogs/tools/dialogdetail.cpp +++ b/src/libs/vtools/dialogs/tools/dialogdetail.cpp @@ -193,6 +193,9 @@ void DialogDetail::ChosenObject(quint32 id, const SceneObject &type) case (SceneObject::Arc): NewItem(id, Tool::NodeArc, NodeDetail::Contour); break; + case (SceneObject::ElArc): + NewItem(id, Tool::NodeElArc, NodeDetail::Contour); + break; case (SceneObject::Point): NewItem(id, Tool::NodePoint, NodeDetail::Contour); break; @@ -394,6 +397,7 @@ void DialogDetail::NewItem(quint32 id, const Tool &typeTool, const NodeDetail &t { case (Tool::NodePoint): case (Tool::NodeArc): + case (Tool::NodeElArc): case (Tool::NodeSpline): case (Tool::NodeSplinePath): { diff --git a/src/libs/vtools/dialogs/tools/dialogflippingbyaxis.cpp b/src/libs/vtools/dialogs/tools/dialogflippingbyaxis.cpp index f5d60d6da..2939be0ad 100644 --- a/src/libs/vtools/dialogs/tools/dialogflippingbyaxis.cpp +++ b/src/libs/vtools/dialogs/tools/dialogflippingbyaxis.cpp @@ -166,10 +166,12 @@ void DialogFlippingByAxis::ShowDialog(bool click) operation->VisualMode(); scene->ToggleArcSelection(false); + scene->ToggleElArcSelection(false); scene->ToggleSplineSelection(false); scene->ToggleSplinePathSelection(false); scene->ToggleArcHover(false); + scene->ToggleElArcHover(false); scene->ToggleSplineHover(false); scene->ToggleSplinePathHover(false); diff --git a/src/libs/vtools/dialogs/tools/dialogflippingbyline.cpp b/src/libs/vtools/dialogs/tools/dialogflippingbyline.cpp index 0fc11f2cb..3565eea83 100644 --- a/src/libs/vtools/dialogs/tools/dialogflippingbyline.cpp +++ b/src/libs/vtools/dialogs/tools/dialogflippingbyline.cpp @@ -165,10 +165,12 @@ void DialogFlippingByLine::ShowDialog(bool click) operation->VisualMode(); scene->ToggleArcSelection(false); + scene->ToggleElArcSelection(false); scene->ToggleSplineSelection(false); scene->ToggleSplinePathSelection(false); scene->ToggleArcHover(false); + scene->ToggleElArcHover(false); scene->ToggleSplineHover(false); scene->ToggleSplinePathHover(false); diff --git a/src/libs/vtools/dialogs/tools/dialogmove.cpp b/src/libs/vtools/dialogs/tools/dialogmove.cpp index 0a1960da8..9ed45b505 100644 --- a/src/libs/vtools/dialogs/tools/dialogmove.cpp +++ b/src/libs/vtools/dialogs/tools/dialogmove.cpp @@ -213,10 +213,12 @@ void DialogMove::ShowDialog(bool click) connect(operation, &VisToolMove::ToolTip, window, &VAbstractMainWindow::ShowToolTip); scene->ToggleArcSelection(false); + scene->ToggleElArcSelection(false); scene->ToggleSplineSelection(false); scene->ToggleSplinePathSelection(false); scene->ToggleArcHover(false); + scene->ToggleElArcHover(false); scene->ToggleSplineHover(false); scene->ToggleSplinePathHover(false); } diff --git a/src/libs/vtools/dialogs/tools/dialogpointofintersectioncurves.cpp b/src/libs/vtools/dialogs/tools/dialogpointofintersectioncurves.cpp index eb6804844..9d26ad3b2 100644 --- a/src/libs/vtools/dialogs/tools/dialogpointofintersectioncurves.cpp +++ b/src/libs/vtools/dialogs/tools/dialogpointofintersectioncurves.cpp @@ -166,7 +166,10 @@ void DialogPointOfIntersectionCurves::ChosenObject(quint32 id, const SceneObject { if (prepare == false)// After first choose we ignore all objects { - if (type == SceneObject::Spline || type == SceneObject::Arc || type == SceneObject::SplinePath) + if (type == SceneObject::Spline + || type == SceneObject::Arc + || type == SceneObject::ElArc + || type == SceneObject::SplinePath) { auto point = qobject_cast(vis); SCASSERT(point != nullptr); diff --git a/src/libs/vtools/dialogs/tools/dialogrotation.cpp b/src/libs/vtools/dialogs/tools/dialogrotation.cpp index 9ba34bdc9..4e7a6bb2f 100644 --- a/src/libs/vtools/dialogs/tools/dialogrotation.cpp +++ b/src/libs/vtools/dialogs/tools/dialogrotation.cpp @@ -190,10 +190,12 @@ void DialogRotation::ShowDialog(bool click) operation->VisualMode(); scene->ToggleArcSelection(false); + scene->ToggleElArcSelection(false); scene->ToggleSplineSelection(false); scene->ToggleSplinePathSelection(false); scene->ToggleArcHover(false); + scene->ToggleElArcHover(false); scene->ToggleSplineHover(false); scene->ToggleSplinePathHover(false); diff --git a/src/libs/vtools/tools/drawTools/operation/vabstractoperation.cpp b/src/libs/vtools/tools/drawTools/operation/vabstractoperation.cpp index ef1ffedd5..8949b583e 100644 --- a/src/libs/vtools/tools/drawTools/operation/vabstractoperation.cpp +++ b/src/libs/vtools/tools/drawTools/operation/vabstractoperation.cpp @@ -585,7 +585,6 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default") break; } case GOType::Arc: - case GOType::EllipticalArc: { VSimpleCurve *curve = InitCurve(object.id, &(VAbstractTool::data), obj->getType()); connect(curve, &VSimpleCurve::Choosed, [this](quint32 id) @@ -594,6 +593,15 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default") }); break; } + case GOType::EllipticalArc: + { + VSimpleCurve *curve = InitCurve(object.id, &(VAbstractTool::data), obj->getType()); + connect(curve, &VSimpleCurve::Choosed, [this](quint32 id) + { + emit ChoosedTool(id, SceneObject::ElArc); + }); + break; + } case GOType::Spline: case GOType::CubicBezier: { diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolellipticalarc.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolellipticalarc.cpp index 9a03cac98..defc9bc0e 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolellipticalarc.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolellipticalarc.cpp @@ -74,7 +74,7 @@ VToolEllipticalArc::VToolEllipticalArc(VAbstractPattern *doc, VContainer *data, QGraphicsItem *parent) :VAbstractSpline(doc, data, id, parent) { - sceneType = SceneObject::Arc; + sceneType = SceneObject::ElArc; this->setPath(ToolPath()); this->setPen(QPen(Qt::black, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor)); diff --git a/src/libs/vtools/tools/nodeDetails/nodedetails.h b/src/libs/vtools/tools/nodeDetails/nodedetails.h index 3f410f313..918551ec5 100644 --- a/src/libs/vtools/tools/nodeDetails/nodedetails.h +++ b/src/libs/vtools/tools/nodeDetails/nodedetails.h @@ -30,6 +30,7 @@ #define NODEDETAILS_H #include "vnodearc.h" +#include "vnodeellipticalarc.h" #include "vnodepoint.h" #include "vnodespline.h" #include "vnodesplinepath.h" diff --git a/src/libs/vtools/tools/nodeDetails/vnodearc.cpp b/src/libs/vtools/tools/nodeDetails/vnodearc.cpp index 9642baa80..dba366d37 100644 --- a/src/libs/vtools/tools/nodeDetails/vnodearc.cpp +++ b/src/libs/vtools/tools/nodeDetails/vnodearc.cpp @@ -39,8 +39,6 @@ #include "../vdatatool.h" #include "vabstractnode.h" -class VContainer; - const QString VNodeArc::ToolType = QStringLiteral("modeling"); //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/tools/nodeDetails/vnodeellipticalarc.cpp b/src/libs/vtools/tools/nodeDetails/vnodeellipticalarc.cpp new file mode 100644 index 000000000..482a6ce11 --- /dev/null +++ b/src/libs/vtools/tools/nodeDetails/vnodeellipticalarc.cpp @@ -0,0 +1,131 @@ +/************************************************************************ + ** + ** @file + ** @author Roman Telezhynskyi + ** @date 20 12, 2016 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2016 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#include "vnodeellipticalarc.h" + +#include +#include +#include +#include + +#include "../ifc/xml/vdomdocument.h" +#include "../ifc/ifcdef.h" +#include "../vabstracttool.h" +#include "../vdatatool.h" +#include "vabstractnode.h" + +const QString VNodeEllipticalArc::ToolType = QStringLiteral("modeling"); + +//--------------------------------------------------------------------------------------------------------------------- +void VNodeEllipticalArc::Create(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 idArc, + const Document &parse, const Source &typeCreation, const QString &drawName, + const quint32 &idTool) +{ + VAbstractTool::AddRecord(id, Tool::NodeElArc, doc); + if (parse == Document::FullParse) + { + VNodeEllipticalArc *arc = new VNodeEllipticalArc(doc, data, id, idArc, typeCreation, drawName, idTool, doc); + + doc->AddTool(id, arc); + if (idTool != NULL_ID) + { + //Some nodes we don't show on scene. Tool that create this nodes must free memory. + VDataTool *tool = doc->getTool(idTool); + SCASSERT(tool != nullptr); + arc->setParent(tool);// Adopted by a tool + } + else + { + // Help to delete the node before each FullParse + doc->AddToolOnRemove(arc); + } + } + else + { + doc->UpdateToolData(id, data); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VNodeEllipticalArc::getTagName() const +{ + return VAbstractPattern::TagElArc; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VNodeEllipticalArc::AllowHover(bool enabled) +{ + Q_UNUSED(enabled) + // do nothing +} + +//--------------------------------------------------------------------------------------------------------------------- +void VNodeEllipticalArc::AllowSelecting(bool enabled) +{ + Q_UNUSED(enabled) + // do nothing +} + +//--------------------------------------------------------------------------------------------------------------------- +void VNodeEllipticalArc::AddToFile() +{ + QDomElement domElement = doc->createElement(getTagName()); + + doc->SetAttribute(domElement, VDomDocument::AttrId, id); + doc->SetAttribute(domElement, AttrType, ToolType); + doc->SetAttribute(domElement, AttrIdObject, idNode); + if (idTool != NULL_ID) + { + doc->SetAttribute(domElement, AttrIdTool, idTool); + } + + AddToModeling(domElement); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VNodeEllipticalArc::RefreshDataInFile() +{ + QDomElement domElement = doc->elementById(id); + if (domElement.isElement()) + { + doc->SetAttribute(domElement, AttrIdObject, idNode); + if (idTool != NULL_ID) + { + doc->SetAttribute(domElement, AttrIdTool, idTool); + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +VNodeEllipticalArc::VNodeEllipticalArc(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 idArc, + const Source &typeCreation, const QString &drawName, const quint32 &idTool, + QObject *qoParent) + :VAbstractNode(doc, data, id, idArc, drawName, idTool, qoParent) +{ + ToolCreation(typeCreation); +} diff --git a/src/libs/vtools/tools/nodeDetails/vnodeellipticalarc.h b/src/libs/vtools/tools/nodeDetails/vnodeellipticalarc.h new file mode 100644 index 000000000..55fe206b5 --- /dev/null +++ b/src/libs/vtools/tools/nodeDetails/vnodeellipticalarc.h @@ -0,0 +1,71 @@ +/************************************************************************ + ** + ** @file + ** @author Roman Telezhynskyi + ** @date 20 12, 2016 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2016 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#ifndef VNODEELLIPTICALARC_H +#define VNODEELLIPTICALARC_H + +#include +#include +#include +#include +#include +#include + +#include "../ifc/xml/vabstractpattern.h" +#include "../vmisc/def.h" +#include "vabstractnode.h" + +class VContainer; + +class VNodeEllipticalArc :public VAbstractNode +{ + Q_OBJECT +public: + static void Create(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 idArc, const Document &parse, + const Source &typeCreation, const QString &drawName = QString(), + const quint32 &idTool = NULL_ID); + + static const QString ToolType; + virtual QString getTagName() const Q_DECL_OVERRIDE; +public slots: + virtual void FullUpdateFromFile() Q_DECL_OVERRIDE {} + virtual void AllowHover(bool enabled) Q_DECL_OVERRIDE; + virtual void AllowSelecting(bool enabled) Q_DECL_OVERRIDE; +protected: + virtual void AddToFile() Q_DECL_OVERRIDE; + virtual void RefreshDataInFile() Q_DECL_OVERRIDE; + virtual void ShowNode() Q_DECL_OVERRIDE {} + virtual void HideNode() Q_DECL_OVERRIDE {} +private: + Q_DISABLE_COPY(VNodeEllipticalArc) + + VNodeEllipticalArc(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 idArc, const Source &typeCreation, + const QString &drawName = QString(), const quint32 &idTool = 0, QObject *qoParent = nullptr); +}; + +#endif // VNODEELLIPTICALARC_H diff --git a/src/libs/vtools/tools/tools.pri b/src/libs/vtools/tools/tools.pri index 0ef1fb995..6a43ce9da 100644 --- a/src/libs/vtools/tools/tools.pri +++ b/src/libs/vtools/tools/tools.pri @@ -59,6 +59,7 @@ HEADERS += \ $$PWD/drawTools/operation/flipping/vabstractflipping.h \ $$PWD/drawTools/operation/vtoolmove.h \ $$PWD/drawTools/toolcurve/vtoolellipticalarc.h \ + $$PWD/nodeDetails/vnodeellipticalarc.h \ $$PWD/vtoolseamallowance.h \ $$PWD/nodeDetails/vtoolpiecepath.h @@ -117,5 +118,6 @@ SOURCES += \ $$PWD/drawTools/operation/flipping/vabstractflipping.cpp \ $$PWD/drawTools/operation/vtoolmove.cpp \ $$PWD/drawTools/toolcurve/vtoolellipticalarc.cpp \ + $$PWD/nodeDetails/vnodeellipticalarc.cpp \ $$PWD/vtoolseamallowance.cpp \ $$PWD/nodeDetails/vtoolpiecepath.cpp diff --git a/src/libs/vtools/tools/vtooldetail.cpp b/src/libs/vtools/tools/vtooldetail.cpp index 39125ccb6..00199b5f3 100644 --- a/src/libs/vtools/tools/vtooldetail.cpp +++ b/src/libs/vtools/tools/vtooldetail.cpp @@ -78,6 +78,7 @@ #include "../undocommands/savedetailoptions.h" #include "../undocommands/togglepieceinlayout.h" #include "../vgeometry/varc.h" +#include "../vgeometry/vellipticalarc.h" #include "../vgeometry/vcubicbezier.h" #include "../vgeometry/vcubicbezierpath.h" #include "../vgeometry/vgeometrydef.h" @@ -99,6 +100,7 @@ #include "vabstracttool.h" #include "nodeDetails/vabstractnode.h" #include "nodeDetails/vnodearc.h" +#include "nodeDetails/vnodeellipticalarc.h" #include "nodeDetails/vnodepoint.h" #include "nodeDetails/vnodespline.h" #include "nodeDetails/vnodesplinepath.h" @@ -130,6 +132,7 @@ const QString VToolDetail::NodeTypeContour = QStringLiteral("Contour"); const QString VToolDetail::NodeTypeModeling = QStringLiteral("Modeling"); const QString VToolDetail::NodeArc = QStringLiteral("NodeArc"); +const QString VToolDetail::NodeElArc = QStringLiteral("NodeElArc"); const QString VToolDetail::NodePoint = QStringLiteral("NodePoint"); const QString VToolDetail::NodeSpline = QStringLiteral("NodeSpline"); const QString VToolDetail::NodeSplinePath = QStringLiteral("NodeSplinePath"); @@ -162,11 +165,8 @@ VToolDetail::VToolDetail(VAbstractPattern *doc, VContainer *data, const quint32 break; } case (Tool::NodeArc): - doc->IncrementReferens(detail.at(i).getId()); - break; + case (Tool::NodeElArc): case (Tool::NodeSpline): - doc->IncrementReferens(detail.at(i).getId()); - break; case (Tool::NodeSplinePath): doc->IncrementReferens(detail.at(i).getId()); break; @@ -275,6 +275,12 @@ void VToolDetail::Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstrac VNodeArc::Create(doc, data, id, nodeD.getId(), Document::FullParse, Source::FromGui); } break; + case (Tool::NodeElArc): + { + id = CreateNode(data, nodeD.getId()); + VNodeEllipticalArc::Create(doc, data, id, nodeD.getId(), Document::FullParse, Source::FromGui); + } + break; case (Tool::NodeSpline): { const auto obj = data->GetGObject(nodeD.getId()); @@ -1155,6 +1161,9 @@ void VToolDetail::AddNode(VAbstractPattern *doc, QDomElement &domElement, const case (Tool::NodeArc): doc->SetAttribute(nod, AttrType, NodeArc); break; + case (Tool::NodeElArc): + doc->SetAttribute(nod, AttrType, NodeElArc); + break; case (Tool::NodePoint): doc->SetAttribute(nod, AttrType, NodePoint); break; diff --git a/src/libs/vtools/tools/vtooldetail.h b/src/libs/vtools/tools/vtooldetail.h index afefd8694..d46b144e6 100644 --- a/src/libs/vtools/tools/vtooldetail.h +++ b/src/libs/vtools/tools/vtooldetail.h @@ -83,6 +83,7 @@ public: static const QString NodeTypeContour; static const QString NodeTypeModeling; static const QString NodeArc; + static const QString NodeElArc; static const QString NodePoint; static const QString NodeSpline; static const QString NodeSplinePath; diff --git a/src/libs/vtools/tools/vtooluniondetails.cpp b/src/libs/vtools/tools/vtooluniondetails.cpp index 7b35d040b..51527a195 100644 --- a/src/libs/vtools/tools/vtooluniondetails.cpp +++ b/src/libs/vtools/tools/vtooluniondetails.cpp @@ -46,6 +46,7 @@ #include "../ifc/xml/vdomdocument.h" #include "../ifc/xml/vpatternconverter.h" #include "../vgeometry/varc.h" +#include "../vgeometry/vellipticalarc.h" #include "../vgeometry/vsplinepath.h" #include "../vgeometry/vabstractcubicbezier.h" #include "../vgeometry/vabstractcubicbezierpath.h" @@ -59,6 +60,7 @@ #include "../vpatterndb/vcontainer.h" #include "../dialogs/tools/dialogtool.h" #include "nodeDetails/vnodearc.h" +#include "nodeDetails/vnodeellipticalarc.h" #include "nodeDetails/vnodepoint.h" #include "nodeDetails/vnodespline.h" #include "nodeDetails/vnodesplinepath.h" @@ -188,24 +190,60 @@ void VToolUnionDetails::AddToNewDetail(VMainGraphicsScene *scene, VAbstractPatte VNodeArc::Create(doc, data, id, idObject, Document::FullParse, Source::FromGui, drawName, idTool); } break; - case (Tool::NodeSpline): + case (Tool::NodeElArc): { - const QSharedPointer spline = - data->GeometricObject(det.at(i).getId()); - - VPointF *p1 = new VPointF(spline->GetP1()); - VPointF p2 = VPointF(spline->GetP2()); - VPointF p3 = VPointF(spline->GetP3()); - VPointF *p4 = new VPointF(spline->GetP4()); + const QSharedPointer arc = data->GeometricObject(det.at(i).getId()); + VPointF p1 = VPointF(arc->GetP1(), "A", 0, 0); + VPointF p2 = VPointF(arc->GetP2(), "A", 0, 0); + VPointF *center = new VPointF(arc->GetCenter()); if (not qFuzzyIsNull(dx) || not qFuzzyIsNull(dy) || pRotate != NULL_ID) { const QPointF p = *data->GeometricObject(pRotate); - BiasRotatePoint(p1, dx, dy, p, angle); + BiasRotatePoint(&p1, dx, dy, p, angle); + BiasRotatePoint(&p2, dx, dy, p, angle); + BiasRotatePoint(center, dx, dy, p, angle); + } + + QLineF l1(*center, p1); + QLineF l2(*center, p2); + center->setMode(Draw::Modeling); + quint32 idCenter = data->AddGObject(center); + Q_UNUSED(idCenter); + VEllipticalArc *arc1 = new VEllipticalArc (*center, arc->GetRadius1(), arc->GetRadius2(), + arc->GetFormulaRadius1(), arc->GetFormulaRadius2(), + l1.angle(), QString().setNum(l1.angle()), l2.angle(), + QString().setNum(l2.angle()), 0, "0"); + arc1->setMode(Draw::Modeling); + idObject = data->AddGObject(arc1); + children.append(idObject); + + VEllipticalArc *arc2 = new VEllipticalArc(*arc1); + arc2->setMode(Draw::Modeling); + id = data->AddGObject(arc2); + + VNodeEllipticalArc::Create(doc, data, id, idObject, Document::FullParse, Source::FromGui, drawName, idTool); + } + break; + case (Tool::NodeSpline): + { + const QSharedPointer spline = + data->GeometricObject(det.at(i).getId()); + + QScopedPointer p1(new VPointF(spline->GetP1())); + VPointF p2 = VPointF(spline->GetP2()); + VPointF p3 = VPointF(spline->GetP3()); + QScopedPointer p4(new VPointF(spline->GetP4())); + + if (not qFuzzyIsNull(dx) || not qFuzzyIsNull(dy) || pRotate != NULL_ID) + { + const QPointF p = *data->GeometricObject(pRotate); + + BiasRotatePoint(p1.data(), dx, dy, p, angle); BiasRotatePoint(&p2, dx, dy, p, angle); BiasRotatePoint(&p3, dx, dy, p, angle); - BiasRotatePoint(p4, dx, dy, p, angle); + BiasRotatePoint(p4.data(), dx, dy, p, angle); } VSpline *spl = new VSpline(*p1, p2, p3, *p4, 0, Draw::Modeling); @@ -216,9 +254,6 @@ void VToolUnionDetails::AddToNewDetail(VMainGraphicsScene *scene, VAbstractPatte spl1->setMode(Draw::Modeling); id = data->AddGObject(spl1); VNodeSpline::Create(doc, data, id, idObject, Document::FullParse, Source::FromGui, drawName, idTool); - - delete p4; - delete p1; } break; case (Tool::NodeSplinePath): @@ -323,7 +358,7 @@ void VToolUnionDetails::UpdatePoints(VContainer *data, const VDetail &det, const const QSharedPointer arc = data->GeometricObject(det.at(i).getId()); VPointF p1 = VPointF(arc->GetP1()); VPointF p2 = VPointF(arc->GetP2()); - VPointF *center = new VPointF(arc->GetCenter()); + QScopedPointer center(new VPointF(arc->GetCenter())); if (not qFuzzyIsNull(dx) || not qFuzzyIsNull(dy) || pRotate != NULL_ID) { @@ -331,7 +366,7 @@ void VToolUnionDetails::UpdatePoints(VContainer *data, const VDetail &det, const BiasRotatePoint(&p1, dx, dy, p, angle); BiasRotatePoint(&p2, dx, dy, p, angle); - BiasRotatePoint(center, dx, dy, p, angle); + BiasRotatePoint(center.data(), dx, dy, p, angle); } QLineF l1(*center, p1); @@ -341,7 +376,33 @@ void VToolUnionDetails::UpdatePoints(VContainer *data, const VDetail &det, const QString().setNum(l1.angle()), l2.angle(), QString().setNum(l2.angle())); arc1->setMode(Draw::Modeling); data->UpdateGObject(TakeNextId(children), arc1); - delete center; + } + break; + case (Tool::NodeElArc): + { + const QSharedPointer arc = data->GeometricObject(det.at(i).getId()); + VPointF p1 = VPointF(arc->GetP1()); + VPointF p2 = VPointF(arc->GetP2()); + QScopedPointer center(new VPointF(arc->GetCenter())); + + if (not qFuzzyIsNull(dx) || not qFuzzyIsNull(dy) || pRotate != NULL_ID) + { + const QPointF p = *data->GeometricObject(pRotate); + + BiasRotatePoint(&p1, dx, dy, p, angle); + BiasRotatePoint(&p2, dx, dy, p, angle); + BiasRotatePoint(center.data(), dx, dy, p, angle); + } + + QLineF l1(*center, p1); + QLineF l2(*center, p2); + + VEllipticalArc *arc1 = new VEllipticalArc (*center, arc->GetRadius1(), arc->GetRadius2(), + arc->GetFormulaRadius1(), arc->GetFormulaRadius2(), + l1.angle(), QString().setNum(l1.angle()), l2.angle(), + QString().setNum(l2.angle()), 0, "0"); + arc1->setMode(Draw::Modeling); + data->UpdateGObject(TakeNextId(children), arc1); } break; case (Tool::NodeSpline): @@ -349,25 +410,23 @@ void VToolUnionDetails::UpdatePoints(VContainer *data, const VDetail &det, const const QSharedPointer spline = data->GeometricObject(det.at(i).getId()); - VPointF *p1 = new VPointF(spline->GetP1()); + QScopedPointer p1(new VPointF(spline->GetP1())); VPointF p2 = VPointF(spline->GetP2()); VPointF p3 = VPointF(spline->GetP3()); - VPointF *p4 = new VPointF(spline->GetP4()); + QScopedPointer p4(new VPointF(spline->GetP4())); if (not qFuzzyIsNull(dx) || not qFuzzyIsNull(dy) || pRotate != NULL_ID) { const QPointF p = *data->GeometricObject(pRotate); - BiasRotatePoint(p1, dx, dy, p, angle); + BiasRotatePoint(p1.data(), dx, dy, p, angle); BiasRotatePoint(&p2, dx, dy, p, angle); BiasRotatePoint(&p3, dx, dy, p, angle); - BiasRotatePoint(p4, dx, dy, p, angle); + BiasRotatePoint(p4.data(), dx, dy, p, angle); } VSpline *spl = new VSpline(*p1, p2, p3, *p4, 0, Draw::Modeling); data->UpdateGObject(TakeNextId(children), spl); - delete p1; - delete p4; } break; case (Tool::NodeSplinePath): @@ -381,19 +440,19 @@ void VToolUnionDetails::UpdatePoints(VContainer *data, const VDetail &det, const { const VSpline spline = splinePath->GetSpline(i); - VPointF *p1 = new VPointF(spline.GetP1()); + QScopedPointer p1(new VPointF(spline.GetP1())); VPointF p2 = VPointF(spline.GetP2()); VPointF p3 = VPointF(spline.GetP3()); - VPointF *p4 = new VPointF(spline.GetP4()); + QScopedPointer p4(new VPointF(spline.GetP4())); if (not qFuzzyIsNull(dx) || not qFuzzyIsNull(dy) || pRotate != NULL_ID) { const QPointF p = *data->GeometricObject(pRotate); - BiasRotatePoint(p1, dx, dy, p, angle); + BiasRotatePoint(p1.data(), dx, dy, p, angle); BiasRotatePoint(&p2, dx, dy, p, angle); BiasRotatePoint(&p3, dx, dy, p, angle); - BiasRotatePoint(p4, dx, dy, p, angle); + BiasRotatePoint(p4.data(), dx, dy, p, angle); } VSpline spl = VSpline(*p1, p2, p3, *p4); @@ -420,9 +479,6 @@ void VToolUnionDetails::UpdatePoints(VContainer *data, const VDetail &det, const path->append(VSplinePoint(*p4, spl.GetEndAngle(), spl.GetEndAngleFormula(), angle2, angle2F, spline.GetC2Length(), spline.GetC2LengthFormula(), pL2, pL2F)); - - delete p1; - delete p4; } data->UpdateGObject(TakeNextId(children), path); } @@ -798,19 +854,23 @@ QVector VToolUnionDetails::GetDetailFromFile(VAbstractPattern *doc, con Tool tool = Tool::NodePoint; NodeDetail nodeType = NodeDetail::Contour; QString t = doc->GetParametrString(element, "type", "NodePoint"); - if (t == "NodePoint") + if (t == QLatin1String("NodePoint")) { tool = Tool::NodePoint; } - else if (t == "NodeArc") + else if (t == QLatin1String("NodeArc")) { tool = Tool::NodeArc; } - else if (t == "NodeSpline") + else if (t == QLatin1String("NodeElArc")) + { + tool = Tool::NodeElArc; + } + else if (t == QLatin1String("NodeSpline")) { tool = Tool::NodeSpline; } - else if (t == "NodeSplinePath") + else if (t == QLatin1String("NodeSplinePath")) { tool = Tool::NodeSplinePath; } @@ -957,6 +1017,7 @@ void VToolUnionDetails::IncrementReferences(const VDetail &d) const break; } case (Tool::NodeArc): + case (Tool::NodeElArc): case (Tool::NodeSpline): case (Tool::NodeSplinePath): doc->IncrementReferens(d.at(i).getId()); @@ -982,6 +1043,7 @@ void VToolUnionDetails::DecrementReferences(const VDetail &d) const break; } case (Tool::NodeArc): + case (Tool::NodeElArc): case (Tool::NodeSpline): case (Tool::NodeSplinePath): doc->DecrementReferens(d.at(i).getId());