From b01adfa388255239418b88602dbdc23b7149f367 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Sun, 17 Sep 2017 19:52:18 +0300 Subject: [PATCH] Saving to file works for simple point. --HG-- branch : feature --- src/app/valentina/xml/vpattern.cpp | 121 ++- src/app/valentina/xml/vpattern.h | 4 +- src/libs/ifc/ifcdef.cpp | 1 + src/libs/ifc/ifcdef.h | 1 + src/libs/ifc/schema.qrc | 1 + src/libs/ifc/schema/pattern/v0.6.3.xsd | 969 ++++++++++++++++++ src/libs/ifc/xml/vpatternconverter.cpp | 22 +- src/libs/ifc/xml/vpatternconverter.h | 3 +- .../toolsinglepoint/toolcut/vtoolcutarc.cpp | 9 +- .../toolsinglepoint/toolcut/vtoolcutarc.h | 4 +- .../toolcut/vtoolcutspline.cpp | 7 +- .../toolsinglepoint/toolcut/vtoolcutspline.h | 2 +- .../toolcut/vtoolcutsplinepath.cpp | 5 +- .../toolcut/vtoolcutsplinepath.h | 2 +- .../toollinepoint/vtoolalongline.cpp | 13 +- .../toollinepoint/vtoolalongline.h | 2 +- .../toollinepoint/vtoolbisector.cpp | 20 +- .../toollinepoint/vtoolbisector.h | 11 +- .../toollinepoint/vtoolcurveintersectaxis.cpp | 14 +- .../toollinepoint/vtoolcurveintersectaxis.h | 4 +- .../toollinepoint/vtoolendline.cpp | 16 +- .../toollinepoint/vtoolendline.h | 2 +- .../toollinepoint/vtoolheight.cpp | 16 +- .../toollinepoint/vtoolheight.h | 4 +- .../toollinepoint/vtoollineintersectaxis.cpp | 16 +- .../toollinepoint/vtoollineintersectaxis.h | 6 +- .../toollinepoint/vtoolnormal.cpp | 20 +- .../toollinepoint/vtoolnormal.h | 9 +- .../toollinepoint/vtoolshoulderpoint.cpp | 21 +- .../toollinepoint/vtoolshoulderpoint.h | 6 +- .../toolsinglepoint/vtoollineintersect.cpp | 22 +- .../toolsinglepoint/vtoollineintersect.h | 6 +- .../vtoolpointfromarcandtangent.cpp | 14 +- .../vtoolpointfromarcandtangent.h | 7 +- .../vtoolpointfromcircleandtangent.cpp | 15 +- .../vtoolpointfromcircleandtangent.h | 2 +- .../toolsinglepoint/vtoolpointofcontact.cpp | 18 +- .../toolsinglepoint/vtoolpointofcontact.h | 6 +- .../vtoolpointofintersection.cpp | 17 +- .../vtoolpointofintersection.h | 4 +- .../vtoolpointofintersectionarcs.cpp | 21 +- .../vtoolpointofintersectionarcs.h | 6 +- .../vtoolpointofintersectioncircles.cpp | 17 +- .../vtoolpointofintersectioncircles.h | 2 +- .../vtoolpointofintersectioncurves.cpp | 15 +- .../vtoolpointofintersectioncurves.h | 2 +- .../toolsinglepoint/vtoolsinglepoint.cpp | 11 + .../toolsinglepoint/vtoolsinglepoint.h | 1 + .../toolsinglepoint/vtooltriangle.cpp | 16 +- .../toolpoint/toolsinglepoint/vtooltriangle.h | 6 +- src/libs/vtools/tools/drawTools/vdrawtool.h | 15 +- .../vtools/undocommands/label/showlabel.cpp | 95 ++ .../vtools/undocommands/label/showlabel.h | 55 + src/libs/vtools/undocommands/undocommands.pri | 6 +- 54 files changed, 1478 insertions(+), 232 deletions(-) create mode 100644 src/libs/ifc/schema/pattern/v0.6.3.xsd create mode 100644 src/libs/vtools/undocommands/label/showlabel.cpp create mode 100644 src/libs/vtools/undocommands/label/showlabel.h diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index 4f206a78c..0d779a307 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -988,18 +988,20 @@ void VPattern::ParseDetails(const QDomElement &domElement, const Document &parse //--------------------------------------------------------------------------------------------------------------------- void VPattern::PointsCommonAttributes(const QDomElement &domElement, quint32 &id, QString &name, qreal &mx, qreal &my, - QString &typeLine, QString &lineColor) + bool &labelVisible, QString &typeLine, QString &lineColor) { - PointsCommonAttributes(domElement, id, name, mx, my); + PointsCommonAttributes(domElement, id, name, mx, my, labelVisible); typeLine = GetParametrString(domElement, AttrTypeLine, TypeLineLine); lineColor = GetParametrString(domElement, AttrLineColor, ColorBlack); } //--------------------------------------------------------------------------------------------------------------------- -void VPattern::PointsCommonAttributes(const QDomElement &domElement, quint32 &id, QString &name, qreal &mx, qreal &my) +void VPattern::PointsCommonAttributes(const QDomElement &domElement, quint32 &id, QString &name, qreal &mx, qreal &my, + bool &labelVisible) { PointsCommonAttributes(domElement, id, mx, my); name = GetParametrString(domElement, AttrName, "A"); + labelVisible = GetParametrBool(domElement, AttrShowLabel, trueStr); } //--------------------------------------------------------------------------------------------------------------------- @@ -1259,12 +1261,14 @@ void VPattern::ParseToolBasePoint(VMainGraphicsScene *scene, const QDomElement & QString name; qreal mx = 0; qreal my = 0; + bool showLabel = true; - PointsCommonAttributes(domElement, id, name, mx, my); + PointsCommonAttributes(domElement, id, name, mx, my, showLabel); const qreal x = qApp->toPixel(GetParametrDouble(domElement, AttrX, "10.0")); const qreal y = qApp->toPixel(GetParametrDouble(domElement, AttrY, "10.0")); VPointF *point = new VPointF(x, y, name, mx, my); + point->SetShowLabel(showLabel); spoint = VToolBasePoint::Create(id, nameActivPP, point, scene, this, data, parse, Source::FromFile); } catch (const VExceptionBadId &e) @@ -1291,8 +1295,9 @@ void VPattern::ParseToolEndLine(VMainGraphicsScene *scene, QDomElement &domEleme qreal my = 0; QString typeLine; QString lineColor; + bool showLabel = true; - PointsCommonAttributes(domElement, id, name, mx, my, typeLine, lineColor); + PointsCommonAttributes(domElement, id, name, mx, my, showLabel, typeLine, lineColor); const QString formula = GetParametrString(domElement, AttrLength, "100.0"); QString f = formula;//need for saving fixed formula; @@ -1302,8 +1307,8 @@ void VPattern::ParseToolEndLine(VMainGraphicsScene *scene, QDomElement &domEleme const QString angle = GetParametrString(domElement, AttrAngle, "0.0"); QString angleFix = angle; - VToolEndLine::Create(id, name, typeLine, lineColor, f, angleFix, basePointId, mx, my, scene, this, data, - parse, Source::FromFile); + VToolEndLine::Create(id, name, typeLine, lineColor, f, angleFix, basePointId, mx, my, showLabel, scene, this, + data, parse, Source::FromFile); //Rewrite attribute formula. Need for situation when we have wrong formula. if (f != formula || angleFix != angle) { @@ -1341,14 +1346,15 @@ void VPattern::ParseToolAlongLine(VMainGraphicsScene *scene, QDomElement &domEle qreal my = 0; QString typeLine; QString lineColor; + bool showLabel = true; - PointsCommonAttributes(domElement, id, name, mx, my, typeLine, lineColor); + PointsCommonAttributes(domElement, id, name, mx, my, showLabel, typeLine, lineColor); const QString formula = GetParametrString(domElement, AttrLength, "100.0"); QString f = formula;//need for saving fixed formula; const quint32 firstPointId = GetParametrUInt(domElement, AttrFirstPoint, NULL_ID_STR); const quint32 secondPointId = GetParametrUInt(domElement, AttrSecondPoint, NULL_ID_STR); - VToolAlongLine::Create(id, name, typeLine, lineColor, f, firstPointId, secondPointId, mx, my, scene, + VToolAlongLine::Create(id, name, typeLine, lineColor, f, firstPointId, secondPointId, mx, my, showLabel, scene, this, data, parse, Source::FromFile); //Rewrite attribute formula. Need for situation when we have wrong formula. if (f != formula) @@ -1386,16 +1392,17 @@ void VPattern::ParseToolShoulderPoint(VMainGraphicsScene *scene, QDomElement &do qreal my = 0; QString typeLine; QString lineColor; + bool showLabel = true; - PointsCommonAttributes(domElement, id, name, mx, my, typeLine, lineColor); + PointsCommonAttributes(domElement, id, name, mx, my, showLabel, typeLine, lineColor); const QString formula = GetParametrString(domElement, AttrLength, "100.0"); QString f = formula;//need for saving fixed formula; const quint32 p1Line = GetParametrUInt(domElement, AttrP1Line, NULL_ID_STR); const quint32 p2Line = GetParametrUInt(domElement, AttrP2Line, NULL_ID_STR); const quint32 pShoulder = GetParametrUInt(domElement, AttrPShoulder, NULL_ID_STR); - VToolShoulderPoint::Create(id, f, p1Line, p2Line, pShoulder, typeLine, lineColor, name, mx, my, scene, - this, data, parse, Source::FromFile); + VToolShoulderPoint::Create(id, f, p1Line, p2Line, pShoulder, typeLine, lineColor, name, mx, my, showLabel, + scene, this, data, parse, Source::FromFile); //Rewrite attribute formula. Need for situation when we have wrong formula. if (f != formula) { @@ -1432,16 +1439,17 @@ void VPattern::ParseToolNormal(VMainGraphicsScene *scene, QDomElement &domElemen qreal my = 0; QString typeLine; QString lineColor; + bool showLabel = true; - PointsCommonAttributes(domElement, id, name, mx, my, typeLine, lineColor); + PointsCommonAttributes(domElement, id, name, mx, my, showLabel, typeLine, lineColor); const QString formula = GetParametrString(domElement, AttrLength, "100.0"); QString f = formula;//need for saving fixed formula; const quint32 firstPointId = GetParametrUInt(domElement, AttrFirstPoint, NULL_ID_STR); const quint32 secondPointId = GetParametrUInt(domElement, AttrSecondPoint, NULL_ID_STR); const qreal angle = GetParametrDouble(domElement, AttrAngle, "0.0"); - VToolNormal::Create(id, f, firstPointId, secondPointId, typeLine, lineColor, name, angle, mx, my, scene, - this, data, parse, Source::FromFile); + VToolNormal::Create(id, f, firstPointId, secondPointId, typeLine, lineColor, name, angle, mx, my, showLabel, + scene, this, data, parse, Source::FromFile); //Rewrite attribute formula. Need for situation when we have wrong formula. if (f != formula) { @@ -1478,8 +1486,9 @@ void VPattern::ParseToolBisector(VMainGraphicsScene *scene, QDomElement &domElem qreal my = 0; QString typeLine; QString lineColor; + bool showLabel = true; - PointsCommonAttributes(domElement, id, name, mx, my, typeLine, lineColor); + PointsCommonAttributes(domElement, id, name, mx, my, showLabel, typeLine, lineColor); const QString formula = GetParametrString(domElement, AttrLength, "100.0"); QString f = formula;//need for saving fixed formula; const quint32 firstPointId = GetParametrUInt(domElement, AttrFirstPoint, NULL_ID_STR); @@ -1487,7 +1496,7 @@ void VPattern::ParseToolBisector(VMainGraphicsScene *scene, QDomElement &domElem const quint32 thirdPointId = GetParametrUInt(domElement, AttrThirdPoint, NULL_ID_STR); VToolBisector::Create(id, f, firstPointId, secondPointId, thirdPointId, - typeLine, lineColor, name, mx, my, scene, this, data, parse, Source::FromFile); + typeLine, lineColor, name, mx, my, showLabel, scene, this, data, parse, Source::FromFile); //Rewrite attribute formula. Need for situation when we have wrong formula. if (f != formula) { @@ -1522,15 +1531,16 @@ void VPattern::ParseToolLineIntersect(VMainGraphicsScene *scene, const QDomEleme QString name; qreal mx = 0; qreal my = 0; + bool showLabel = true; - PointsCommonAttributes(domElement, id, name, mx, my); + PointsCommonAttributes(domElement, id, name, mx, my, showLabel); const quint32 p1Line1Id = GetParametrUInt(domElement, AttrP1Line1, NULL_ID_STR); const quint32 p2Line1Id = GetParametrUInt(domElement, AttrP2Line1, NULL_ID_STR); const quint32 p1Line2Id = GetParametrUInt(domElement, AttrP1Line2, NULL_ID_STR); const quint32 p2Line2Id = GetParametrUInt(domElement, AttrP2Line2, NULL_ID_STR); VToolLineIntersect::Create(id, p1Line1Id, p2Line1Id, p1Line2Id, p2Line2Id, name, - mx, my, scene, this, data, parse, Source::FromFile); + mx, my, showLabel, scene, this, data, parse, Source::FromFile); } catch (const VExceptionBadId &e) { @@ -1552,15 +1562,16 @@ void VPattern::ParseToolPointOfContact(VMainGraphicsScene *scene, QDomElement &d QString name; qreal mx = 0; qreal my = 0; + bool showLabel = true; - PointsCommonAttributes(domElement, id, name, mx, my); + PointsCommonAttributes(domElement, id, name, mx, my, showLabel); const QString radius = GetParametrString(domElement, AttrRadius, "0"); QString f = radius;//need for saving fixed formula; const quint32 center = GetParametrUInt(domElement, AttrCenter, NULL_ID_STR); const quint32 firstPointId = GetParametrUInt(domElement, AttrFirstPoint, NULL_ID_STR); const quint32 secondPointId = GetParametrUInt(domElement, AttrSecondPoint, NULL_ID_STR); - VToolPointOfContact::Create(id, f, center, firstPointId, secondPointId, name, mx, my, scene, this, + VToolPointOfContact::Create(id, f, center, firstPointId, secondPointId, name, mx, my, showLabel, scene, this, data, parse, Source::FromFile); //Rewrite attribute formula. Need for situation when we have wrong formula. if (f != radius) @@ -1656,14 +1667,15 @@ void VPattern::ParseToolHeight(VMainGraphicsScene *scene, const QDomElement &dom qreal my = 0; QString typeLine; QString lineColor; + bool showLabel = true; - PointsCommonAttributes(domElement, id, name, mx, my, typeLine, lineColor); + PointsCommonAttributes(domElement, id, name, mx, my, showLabel, typeLine, lineColor); const quint32 basePointId = GetParametrUInt(domElement, AttrBasePoint, NULL_ID_STR); const quint32 p1LineId = GetParametrUInt(domElement, AttrP1Line, NULL_ID_STR); const quint32 p2LineId = GetParametrUInt(domElement, AttrP2Line, NULL_ID_STR); VToolHeight::Create(id, name, typeLine, lineColor, basePointId, p1LineId, p2LineId, - mx, my, scene, this, data, parse, Source::FromFile); + mx, my, showLabel, scene, this, data, parse, Source::FromFile); } catch (const VExceptionBadId &e) { @@ -1685,14 +1697,15 @@ void VPattern::ParseToolTriangle(VMainGraphicsScene *scene, const QDomElement &d QString name; qreal mx = 0; qreal my = 0; + bool showLabel = true; - PointsCommonAttributes(domElement, id, name, mx, my); + PointsCommonAttributes(domElement, id, name, mx, my, showLabel); const quint32 axisP1Id = GetParametrUInt(domElement, AttrAxisP1, NULL_ID_STR); const quint32 axisP2Id = GetParametrUInt(domElement, AttrAxisP2, NULL_ID_STR); const quint32 firstPointId = GetParametrUInt(domElement, AttrFirstPoint, NULL_ID_STR); const quint32 secondPointId = GetParametrUInt(domElement, AttrSecondPoint, NULL_ID_STR); - VToolTriangle::Create(id, name, axisP1Id, axisP2Id, firstPointId, secondPointId, mx, my, scene, this, + VToolTriangle::Create(id, name, axisP1Id, axisP2Id, firstPointId, secondPointId, mx, my, showLabel, scene, this, data, parse, Source::FromFile); } catch (const VExceptionBadId &e) @@ -1716,12 +1729,13 @@ void VPattern::ParseToolPointOfIntersection(VMainGraphicsScene *scene, const QDo QString name; qreal mx = 0; qreal my = 0; + bool showLabel = true; - PointsCommonAttributes(domElement, id, name, mx, my); + PointsCommonAttributes(domElement, id, name, mx, my, showLabel); const quint32 firstPointId = GetParametrUInt(domElement, AttrFirstPoint, NULL_ID_STR); const quint32 secondPointId = GetParametrUInt(domElement, AttrSecondPoint, NULL_ID_STR); - VToolPointOfIntersection::Create(id, name, firstPointId, secondPointId, mx, my, scene, this, data, + VToolPointOfIntersection::Create(id, name, firstPointId, secondPointId, mx, my, showLabel, scene, this, data, parse, Source::FromFile); } catch (const VExceptionBadId &e) @@ -1744,13 +1758,14 @@ void VPattern::ParseToolCutSpline(VMainGraphicsScene *scene, QDomElement &domEle QString name; qreal mx = 0; qreal my = 0; + bool showLabel = true; - PointsCommonAttributes(domElement, id, name, mx, my); + PointsCommonAttributes(domElement, id, name, mx, my, showLabel); const QString formula = GetParametrString(domElement, AttrLength, "0"); QString f = formula;//need for saving fixed formula; const quint32 splineId = GetParametrUInt(domElement, VToolCutSpline::AttrSpline, NULL_ID_STR); - VToolCutSpline::Create(id, name, f, splineId, mx, my, scene, this, data, parse, Source::FromFile); + VToolCutSpline::Create(id, name, f, splineId, mx, my, showLabel, scene, this, data, parse, Source::FromFile); //Rewrite attribute formula. Need for situation when we have wrong formula. if (f != formula) { @@ -1785,14 +1800,16 @@ void VPattern::ParseToolCutSplinePath(VMainGraphicsScene *scene, QDomElement &do QString name; qreal mx = 0; qreal my = 0; + bool showLabel = true; - PointsCommonAttributes(domElement, id, name, mx, my); + PointsCommonAttributes(domElement, id, name, mx, my, showLabel); const QString formula = GetParametrString(domElement, AttrLength, "0"); QString f = formula;//need for saving fixed formula; const quint32 splinePathId = GetParametrUInt(domElement, VToolCutSplinePath::AttrSplinePath, NULL_ID_STR); - VToolCutSplinePath::Create(id, name, f, splinePathId, mx, my, scene, this, data, parse, Source::FromFile); + VToolCutSplinePath::Create(id, name, f, splinePathId, mx, my, showLabel, scene, this, data, parse, + Source::FromFile); //Rewrite attribute formula. Need for situation when we have wrong formula. if (f != formula) { @@ -1827,13 +1844,14 @@ void VPattern::ParseToolCutArc(VMainGraphicsScene *scene, QDomElement &domElemen QString name; qreal mx = 0; qreal my = 0; + bool showLabel = true; - PointsCommonAttributes(domElement, id, name, mx, my); + PointsCommonAttributes(domElement, id, name, mx, my, showLabel); const QString formula = GetParametrString(domElement, AttrLength, "0"); QString f = formula;//need for saving fixed formula; const quint32 arcId = GetParametrUInt(domElement, AttrArc, NULL_ID_STR); - VToolCutArc::Create(id, name, f, arcId, mx, my, scene, this, data, parse, Source::FromFile); + VToolCutArc::Create(id, name, f, arcId, mx, my, showLabel, scene, this, data, parse, Source::FromFile); //Rewrite attribute formula. Need for situation when we have wrong formula. if (f != formula) { @@ -1871,8 +1889,9 @@ void VPattern::ParseToolLineIntersectAxis(VMainGraphicsScene *scene, QDomElement qreal my = 0; QString typeLine; QString lineColor; + bool showLabel = true; - PointsCommonAttributes(domElement, id, name, mx, my, typeLine, lineColor); + PointsCommonAttributes(domElement, id, name, mx, my, showLabel, typeLine, lineColor); const quint32 basePointId = GetParametrUInt(domElement, AttrBasePoint, NULL_ID_STR); const quint32 firstPointId = GetParametrUInt(domElement, AttrP1Line, NULL_ID_STR); @@ -1882,7 +1901,7 @@ void VPattern::ParseToolLineIntersectAxis(VMainGraphicsScene *scene, QDomElement QString angleFix = angle; VToolLineIntersectAxis::Create(id, name, typeLine, lineColor, angleFix, basePointId, firstPointId, - secondPointId, mx, my, scene, this, data, parse, Source::FromFile); + secondPointId, mx, my, showLabel, scene, this, data, parse, Source::FromFile); //Rewrite attribute formula. Need for situation when we have wrong formula. if (angleFix != angle) { @@ -1922,8 +1941,9 @@ void VPattern::ParseToolCurveIntersectAxis(VMainGraphicsScene *scene, QDomElemen qreal my = 0; QString typeLine; QString lineColor; + bool showLabel = true; - PointsCommonAttributes(domElement, id, name, mx, my, typeLine, lineColor); + PointsCommonAttributes(domElement, id, name, mx, my, showLabel, typeLine, lineColor); const quint32 basePointId = GetParametrUInt(domElement, AttrBasePoint, NULL_ID_STR); const quint32 curveId = GetParametrUInt(domElement, AttrCurve, NULL_ID_STR); @@ -1931,7 +1951,7 @@ void VPattern::ParseToolCurveIntersectAxis(VMainGraphicsScene *scene, QDomElemen QString angleFix = angle; VToolCurveIntersectAxis::Create(id, name, typeLine, lineColor, angleFix, basePointId, curveId, mx, my, - scene, this, data, parse, Source::FromFile); + showLabel, scene, this, data, parse, Source::FromFile); //Rewrite attribute formula. Need for situation when we have wrong formula. if (angleFix != angle) { @@ -1969,16 +1989,17 @@ void VPattern::ParseToolPointOfIntersectionArcs(VMainGraphicsScene *scene, const QString name; qreal mx = 0; qreal my = 0; + bool showLabel = true; - PointsCommonAttributes(domElement, id, name, mx, my); + PointsCommonAttributes(domElement, id, name, mx, my, showLabel); const quint32 firstArcId = GetParametrUInt(domElement, AttrFirstArc, NULL_ID_STR); const quint32 secondArcId = GetParametrUInt(domElement, AttrSecondArc, NULL_ID_STR); const CrossCirclesPoint crossPoint = static_cast(GetParametrUInt(domElement, AttrCrossPoint, "1")); - VToolPointOfIntersectionArcs::Create(id, name, firstArcId, secondArcId, crossPoint, mx, my, scene, this, - data, parse, Source::FromFile); + VToolPointOfIntersectionArcs::Create(id, name, firstArcId, secondArcId, crossPoint, mx, my, showLabel, scene, + this, data, parse, Source::FromFile); } catch (const VExceptionBadId &e) { @@ -2001,8 +2022,9 @@ void VPattern::ParseToolPointOfIntersectionCircles(VMainGraphicsScene *scene, QD QString name; qreal mx = 0; qreal my = 0; + bool showLabel = true; - PointsCommonAttributes(domElement, id, name, mx, my); + PointsCommonAttributes(domElement, id, name, mx, my, showLabel); const quint32 c1CenterId = GetParametrUInt(domElement, AttrC1Center, NULL_ID_STR); const quint32 c2CenterId = GetParametrUInt(domElement, AttrC2Center, NULL_ID_STR); const QString c1Radius = GetParametrString(domElement, AttrC1Radius); @@ -2013,7 +2035,7 @@ void VPattern::ParseToolPointOfIntersectionCircles(VMainGraphicsScene *scene, QD AttrCrossPoint, "1")); VToolPointOfIntersectionCircles::Create(id, name, c1CenterId, c2CenterId, c1R, c2R, crossPoint, mx, my, - scene, this, data, parse, Source::FromFile); + showLabel, scene, this, data, parse, Source::FromFile); //Rewrite attribute formula. Need for situation when we have wrong formula. if (c1R != c1Radius || c2R != c2Radius) { @@ -2044,15 +2066,16 @@ void VPattern::ParseToolPointOfIntersectionCurves(VMainGraphicsScene *scene, QDo QString name; qreal mx = 0; qreal my = 0; + bool showLabel = true; - PointsCommonAttributes(domElement, id, name, mx, my); + PointsCommonAttributes(domElement, id, name, mx, my, showLabel); const auto curve1Id = GetParametrUInt(domElement, AttrCurve1, NULL_ID_STR); const auto curve2Id = GetParametrUInt(domElement, AttrCurve2, NULL_ID_STR); const auto vCrossPoint = static_cast(GetParametrUInt(domElement, AttrVCrossPoint, "1")); const auto hCrossPoint = static_cast(GetParametrUInt(domElement, AttrHCrossPoint, "1")); VToolPointOfIntersectionCurves::Create(id, name, curve1Id, curve2Id, vCrossPoint, hCrossPoint, mx, my, - scene, this, data, parse, Source::FromFile); + showLabel, scene, this, data, parse, Source::FromFile); } catch (const VExceptionBadId &e) { @@ -2075,8 +2098,9 @@ void VPattern::ParseToolPointFromCircleAndTangent(VMainGraphicsScene *scene, QDo QString name; qreal mx = 0; qreal my = 0; + bool showLabel = true; - PointsCommonAttributes(domElement, id, name, mx, my); + PointsCommonAttributes(domElement, id, name, mx, my, showLabel); const quint32 cCenterId = GetParametrUInt(domElement, AttrCCenter, NULL_ID_STR); const quint32 tangentId = GetParametrUInt(domElement, AttrTangent, NULL_ID_STR); const QString cRadius = GetParametrString(domElement, AttrCRadius); @@ -2085,7 +2109,7 @@ void VPattern::ParseToolPointFromCircleAndTangent(VMainGraphicsScene *scene, QDo AttrCrossPoint, "1")); - VToolPointFromCircleAndTangent::Create(id, name, cCenterId, cR, tangentId, crossPoint, mx, my, + VToolPointFromCircleAndTangent::Create(id, name, cCenterId, cR, tangentId, crossPoint, mx, my, showLabel, scene, this, data, parse, Source::FromFile); //Rewrite attribute formula. Need for situation when we have wrong formula. if (cR != cRadius) @@ -2116,15 +2140,16 @@ void VPattern::ParseToolPointFromArcAndTangent(VMainGraphicsScene *scene, const QString name; qreal mx = 0; qreal my = 0; + bool showLabel = true; - PointsCommonAttributes(domElement, id, name, mx, my); + PointsCommonAttributes(domElement, id, name, mx, my, showLabel); const quint32 arcId = GetParametrUInt(domElement, AttrArc, NULL_ID_STR); const quint32 tangentId = GetParametrUInt(domElement, AttrTangent, NULL_ID_STR); const CrossCirclesPoint crossPoint = static_cast(GetParametrUInt(domElement, AttrCrossPoint, "1")); - VToolPointFromArcAndTangent::Create(id, name, arcId, tangentId, crossPoint, mx, my, + VToolPointFromArcAndTangent::Create(id, name, arcId, tangentId, crossPoint, mx, my, showLabel, scene, this, data, parse, Source::FromFile); } catch (const VExceptionBadId &e) diff --git a/src/app/valentina/xml/vpattern.h b/src/app/valentina/xml/vpattern.h index d3a98c638..dd2023ba7 100644 --- a/src/app/valentina/xml/vpattern.h +++ b/src/app/valentina/xml/vpattern.h @@ -156,9 +156,9 @@ private: void PrepareForParse(const Document &parse); void ToolsCommonAttributes(const QDomElement &domElement, quint32 &id); void PointsCommonAttributes(const QDomElement &domElement, quint32 &id, QString &name, qreal &mx, - qreal &my, QString &typeLine, QString &lineColor); + qreal &my, bool &labelVisible, QString &typeLine, QString &lineColor); void PointsCommonAttributes(const QDomElement &domElement, quint32 &id, QString &name, qreal &mx, - qreal &my); + qreal &my, bool &labelVisible); void PointsCommonAttributes(const QDomElement &domElement, quint32 &id, qreal &mx, qreal &my); void SplinesCommonAttributes(const QDomElement &domElement, quint32 &id, quint32 &idObject, quint32 &idTool); diff --git a/src/libs/ifc/ifcdef.cpp b/src/libs/ifc/ifcdef.cpp index 1a88d5c34..33e62e8f0 100644 --- a/src/libs/ifc/ifcdef.cpp +++ b/src/libs/ifc/ifcdef.cpp @@ -122,6 +122,7 @@ const QString AttrIdObject = QStringLiteral("idObject"); const QString AttrInLayout = QStringLiteral("inLayout"); const QString AttrRotationAngle = QStringLiteral("rotationAngle"); const QString AttrClosed = QStringLiteral("closed"); +const QString AttrShowLabel = QStringLiteral("showLabel"); const QString TypeLineNone = QStringLiteral("none"); const QString TypeLineLine = QStringLiteral("hair"); diff --git a/src/libs/ifc/ifcdef.h b/src/libs/ifc/ifcdef.h index a6a0df2ec..86cdbb41c 100644 --- a/src/libs/ifc/ifcdef.h +++ b/src/libs/ifc/ifcdef.h @@ -141,6 +141,7 @@ extern const QString AttrSuffix; extern const QString AttrIdObject; extern const QString AttrInLayout; extern const QString AttrClosed; +extern const QString AttrShowLabel; extern const QString TypeLineNone; extern const QString TypeLineLine; diff --git a/src/libs/ifc/schema.qrc b/src/libs/ifc/schema.qrc index 9b12757fb..a60d729ca 100644 --- a/src/libs/ifc/schema.qrc +++ b/src/libs/ifc/schema.qrc @@ -37,6 +37,7 @@ schema/pattern/v0.6.0.xsd schema/pattern/v0.6.1.xsd schema/pattern/v0.6.2.xsd + schema/pattern/v0.6.3.xsd schema/standard_measurements/v0.3.0.xsd schema/standard_measurements/v0.4.0.xsd schema/standard_measurements/v0.4.1.xsd diff --git a/src/libs/ifc/schema/pattern/v0.6.3.xsd b/src/libs/ifc/schema/pattern/v0.6.3.xsd new file mode 100644 index 000000000..3a990fe84 --- /dev/null +++ b/src/libs/ifc/schema/pattern/v0.6.3.xsd @@ -0,0 +1,969 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/libs/ifc/xml/vpatternconverter.cpp b/src/libs/ifc/xml/vpatternconverter.cpp index 01edf624e..9bef2aea3 100644 --- a/src/libs/ifc/xml/vpatternconverter.cpp +++ b/src/libs/ifc/xml/vpatternconverter.cpp @@ -58,8 +58,8 @@ class QDomElement; */ const QString VPatternConverter::PatternMinVerStr = QStringLiteral("0.1.0"); -const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.6.2"); -const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.6.2.xsd"); +const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.6.3"); +const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.6.3.xsd"); //VPatternConverter::PatternMinVer; // <== DON'T FORGET TO UPDATE TOO!!!! //VPatternConverter::PatternMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!! @@ -246,6 +246,8 @@ QString VPatternConverter::XSDSchema(int ver) const case (0x000601): return QStringLiteral("://schema/pattern/v0.6.1.xsd"); case (0x000602): + return QStringLiteral("://schema/pattern/v0.6.2.xsd"); + case (0x000603): return CurrentSchema; default: InvalidVersion(ver); @@ -404,6 +406,10 @@ void VPatternConverter::ApplyPatches() ValidateXML(XSDSchema(0x000602), m_convertedFileName); V_FALLTHROUGH case (0x000602): + ToV0_6_3(); + ValidateXML(XSDSchema(0x000603), m_convertedFileName); + V_FALLTHROUGH + case (0x000603): break; default: InvalidVersion(m_ver); @@ -422,7 +428,7 @@ void VPatternConverter::DowngradeToCurrentMaxVersion() bool VPatternConverter::IsReadOnly() const { // Check if attribute readOnly was not changed in file format - Q_STATIC_ASSERT_X(VPatternConverter::PatternMaxVer == CONVERTER_VERSION_CHECK(0, 6, 2), + Q_STATIC_ASSERT_X(VPatternConverter::PatternMaxVer == CONVERTER_VERSION_CHECK(0, 6, 3), "Check attribute readOnly."); // Possibly in future attribute readOnly will change position etc. @@ -846,6 +852,16 @@ void VPatternConverter::ToV0_6_2() Save(); } +//--------------------------------------------------------------------------------------------------------------------- +void VPatternConverter::ToV0_6_3() +{ + // TODO. Delete if minimal supported version is 0.6.3 + Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < CONVERTER_VERSION_CHECK(0, 6, 3), + "Time to refactor the code."); + SetVersion(QStringLiteral("0.6.3")); + Save(); +} + //--------------------------------------------------------------------------------------------------------------------- void VPatternConverter::TagUnitToV0_2_0() { diff --git a/src/libs/ifc/xml/vpatternconverter.h b/src/libs/ifc/xml/vpatternconverter.h index bb4dd407a..441cbd584 100644 --- a/src/libs/ifc/xml/vpatternconverter.h +++ b/src/libs/ifc/xml/vpatternconverter.h @@ -53,7 +53,7 @@ public: static const QString PatternMaxVerStr; static const QString CurrentSchema; static Q_DECL_CONSTEXPR const int PatternMinVer = CONVERTER_VERSION_CHECK(0, 1, 0); - static Q_DECL_CONSTEXPR const int PatternMaxVer = CONVERTER_VERSION_CHECK(0, 6, 2); + static Q_DECL_CONSTEXPR const int PatternMaxVer = CONVERTER_VERSION_CHECK(0, 6, 3); protected: virtual int MinVer() const Q_DECL_OVERRIDE; @@ -108,6 +108,7 @@ private: void ToV0_6_0(); void ToV0_6_1(); void ToV0_6_2(); + void ToV0_6_3(); void TagUnitToV0_2_0(); void TagIncrementToV0_2_0(); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.cpp index d16d97ebd..181f6b5f2 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.cpp @@ -106,7 +106,7 @@ VToolCutArc* VToolCutArc::Create(QSharedPointer dialog, VMainGraphic const QString pointName = dialogTool->getPointName(); QString formula = dialogTool->GetFormula(); const quint32 arcId = dialogTool->getArcId(); - VToolCutArc* point = Create(0, pointName, formula, arcId, 5, 10, scene, doc, data, Document::FullParse, + VToolCutArc* point = Create(0, pointName, formula, arcId, 5, 10, true, scene, doc, data, Document::FullParse, Source::FromGui); if (point != nullptr) { @@ -130,8 +130,8 @@ VToolCutArc* VToolCutArc::Create(QSharedPointer dialog, VMainGraphic * @param parse parser file mode. * @param typeCreation way we create this tool. */ -VToolCutArc* VToolCutArc::Create(const quint32 _id, const QString &pointName, QString &formula, const quint32 &arcId, - const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VAbstractPattern *doc, +VToolCutArc* VToolCutArc::Create(const quint32 _id, const QString &pointName, QString &formula, quint32 arcId, + qreal mx, qreal my, bool showLabel, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation) { const QSharedPointer arc = data->GeometricObject(arcId); @@ -143,7 +143,10 @@ VToolCutArc* VToolCutArc::Create(const quint32 _id, const QString &pointName, QS QPointF point = arc->CutArc(qApp->toPixel(result), arc1, arc2); quint32 id = _id; + VPointF *p = new VPointF(point, pointName, mx, my); + p->SetShowLabel(showLabel); + auto a1 = QSharedPointer(new VArc(arc1)); auto a2 = QSharedPointer(new VArc(arc2)); if (typeCreation == Source::FromGui) diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.h index df46da7de..aa3eb0a53 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.h @@ -53,8 +53,8 @@ public: virtual void setDialog() Q_DECL_OVERRIDE; static VToolCutArc* Create(QSharedPointer dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data); - static VToolCutArc* Create(const quint32 _id, const QString &pointName, QString &formula, const quint32 &arcId, - const qreal &mx, const qreal &my, VMainGraphicsScene *scene, + static VToolCutArc* Create(const quint32 _id, const QString &pointName, QString &formula, quint32 arcId, + qreal mx, qreal my, bool showLabel, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation); static const QString ToolType; diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.cpp index def45024c..9cff3d991 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.cpp @@ -109,7 +109,7 @@ VToolCutSpline* VToolCutSpline::Create(QSharedPointer dialog, VMainG const QString pointName = dialogTool->getPointName(); QString formula = dialogTool->GetFormula(); const quint32 splineId = dialogTool->getSplineId(); - VToolCutSpline* point = Create(0, pointName, formula, splineId, 5, 10, scene, doc, data, Document::FullParse, + VToolCutSpline* point = Create(0, pointName, formula, splineId, 5, 10, true, scene, doc, data, Document::FullParse, Source::FromGui); if (point != nullptr) { @@ -134,7 +134,7 @@ VToolCutSpline* VToolCutSpline::Create(QSharedPointer dialog, VMainG * @param typeCreation way we create this tool. */ VToolCutSpline* VToolCutSpline::Create(const quint32 _id, const QString &pointName, QString &formula, - const quint32 &splineId, const qreal &mx, const qreal &my, + quint32 splineId, qreal mx, qreal my, bool showLabel, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation) { @@ -146,7 +146,10 @@ VToolCutSpline* VToolCutSpline::Create(const quint32 _id, const QString &pointNa QPointF point = spl->CutSpline(qApp->toPixel(result), spl1p2, spl1p3, spl2p2, spl2p3); quint32 id = _id; + VPointF *p = new VPointF(point, pointName, mx, my); + p->SetShowLabel(showLabel); + auto spline1 = QSharedPointer(new VSpline(spl->GetP1(), spl1p2, spl1p3, *p)); auto spline2 = QSharedPointer(new VSpline(*p, spl2p2, spl2p3, spl->GetP4())); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.h index d849c2db0..0c62c260e 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.h @@ -54,7 +54,7 @@ public: static VToolCutSpline *Create(QSharedPointer dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data); static VToolCutSpline *Create(const quint32 _id, const QString &pointName, QString &formula, - const quint32 &splineId, const qreal &mx, const qreal &my, + quint32 splineId, qreal mx, qreal my, bool showLabel, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.cpp index 3dadb1f31..b49029f07 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.cpp @@ -113,7 +113,7 @@ VToolCutSplinePath* VToolCutSplinePath::Create(QSharedPointer dialog const QString pointName = dialogTool->getPointName(); QString formula = dialogTool->GetFormula(); const quint32 splinePathId = dialogTool->getSplinePathId(); - VToolCutSplinePath* point = Create(0, pointName, formula, splinePathId, 5, 10, scene, doc, data, + VToolCutSplinePath* point = Create(0, pointName, formula, splinePathId, 5, 10, true, scene, doc, data, Document::FullParse, Source::FromGui); if (point != nullptr) { @@ -138,7 +138,7 @@ VToolCutSplinePath* VToolCutSplinePath::Create(QSharedPointer dialog * @param typeCreation way we create this tool. */ VToolCutSplinePath* VToolCutSplinePath::Create(const quint32 _id, const QString &pointName, QString &formula, - const quint32 &splinePathId, const qreal &mx, const qreal &my, + quint32 splinePathId, qreal mx, qreal my, bool showLabel, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation) { @@ -151,6 +151,7 @@ VToolCutSplinePath* VToolCutSplinePath::Create(const quint32 _id, const QString VSplinePath *splPath1 = nullptr; VSplinePath *splPath2 = nullptr; VPointF *p = VToolCutSplinePath::CutSplinePath(qApp->toPixel(result), splPath, pointName, &splPath1, &splPath2); + p->SetShowLabel(showLabel); SCASSERT(splPath1 != nullptr) SCASSERT(splPath2 != nullptr) diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.h index a5b815ae7..8e98848f8 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.h @@ -56,7 +56,7 @@ public: static VToolCutSplinePath *Create(QSharedPointer dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data); static VToolCutSplinePath *Create(const quint32 _id, const QString &pointName, QString &formula, - const quint32 &splinePathId, const qreal &mx, const qreal &my, + quint32 splinePathId, qreal mx, qreal my, bool showLabel, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation); static const QString ToolType; diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.cpp index 250e4cca5..8d3e7c03e 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.cpp @@ -251,7 +251,7 @@ VToolAlongLine* VToolAlongLine::Create(QSharedPointer dialog, VMainG const QString lineColor = dialogTool->GetLineColor(); const QString pointName = dialogTool->getPointName(); VToolAlongLine *point = Create(0, pointName, typeLine, lineColor, formula, firstPointId, secondPointId, - 5, 10, scene, doc, data, Document::FullParse, Source::FromGui); + 5, 10, true, scene, doc, data, Document::FullParse, Source::FromGui); if (point != nullptr) { point->m_dialog = dialogTool; @@ -270,6 +270,7 @@ VToolAlongLine* VToolAlongLine::Create(QSharedPointer dialog, VMainG * @param secondPointId id second point of line. * @param mx label bias x axis. * @param my label bias y axis. + * @param showLabel show/hide label. * @param scene pointer to scene. * @param doc dom document container. * @param data container with variables. @@ -278,7 +279,7 @@ VToolAlongLine* VToolAlongLine::Create(QSharedPointer dialog, VMainG */ VToolAlongLine* VToolAlongLine::Create(const quint32 _id, const QString &pointName, const QString &typeLine, const QString &lineColor, QString &formula, const quint32 &firstPointId, - const quint32 &secondPointId, const qreal &mx, const qreal &my, + quint32 secondPointId, qreal mx, qreal my, bool showLabel, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation) { @@ -295,15 +296,19 @@ VToolAlongLine* VToolAlongLine::Create(const quint32 _id, const QString &pointNa line.setLength(qApp->toPixel(CheckFormula(_id, formula, data))); quint32 id = _id; + + VPointF *p = new VPointF(line.p2(), pointName, mx, my); + p->SetShowLabel(showLabel); + if (typeCreation == Source::FromGui) { - id = data->AddGObject( new VPointF(line.p2(), pointName, mx, my)); + id = data->AddGObject(p); data->AddLine(firstPointId, id); data->AddLine(id, secondPointId); } else { - data->UpdateGObject(id, new VPointF(line.p2(), pointName, mx, my)); + data->UpdateGObject(id, p); data->AddLine(firstPointId, id); data->AddLine(id, secondPointId); if (parse != Document::FullParse) diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.h index dc873e96a..260f99bef 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.h @@ -55,7 +55,7 @@ public: VAbstractPattern *doc, VContainer *data); static VToolAlongLine* Create(const quint32 _id, const QString &pointName, const QString &typeLine, const QString &lineColor, QString &formula, const quint32 &firstPointId, - const quint32 &secondPointId, const qreal &mx, const qreal &my, + quint32 secondPointId, qreal mx, qreal my, bool showLabel, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolbisector.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolbisector.cpp index 691cfb6ba..be1c5f055 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolbisector.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolbisector.cpp @@ -156,7 +156,7 @@ VToolBisector* VToolBisector::Create(QSharedPointer dialog, VMainGra const QString lineColor = dialogTool->GetLineColor(); const QString pointName = dialogTool->getPointName(); VToolBisector *point = Create(0, formula, firstPointId, secondPointId, thirdPointId, typeLine, lineColor, - pointName, 5, 10, scene, doc, data, Document::FullParse, Source::FromGui); + pointName, 5, 10, true, scene, doc, data, Document::FullParse, Source::FromGui); if (point != nullptr) { point->m_dialog = dialogTool; @@ -176,17 +176,17 @@ VToolBisector* VToolBisector::Create(QSharedPointer dialog, VMainGra * @param pointName point name. * @param mx label bias x axis. * @param my label bias y axis. + * @param showLabel show/hide label. * @param scene pointer to scene. * @param doc dom document container. * @param data container with variables. * @param parse parser file mode. * @param typeCreation way we create this tool. */ -VToolBisector* VToolBisector::Create(const quint32 _id, QString &formula, const quint32 &firstPointId, - const quint32 &secondPointId, const quint32 &thirdPointId, const QString &typeLine, - const QString &lineColor, const QString &pointName, const qreal &mx, - const qreal &my, VMainGraphicsScene *scene, VAbstractPattern *doc, - VContainer *data, +VToolBisector* VToolBisector::Create(const quint32 _id, QString &formula, quint32 firstPointId, quint32 secondPointId, + quint32 thirdPointId, const QString &typeLine, const QString &lineColor, + const QString &pointName, qreal mx, qreal my, bool showLabel, + VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation) { const QSharedPointer firstPoint = data->GeometricObject(firstPointId); @@ -198,14 +198,18 @@ VToolBisector* VToolBisector::Create(const quint32 _id, QString &formula, const QPointF fPoint = VToolBisector::FindPoint(static_cast(*firstPoint), static_cast(*secondPoint), static_cast(*thirdPoint), qApp->toPixel(result)); quint32 id = _id; + + VPointF *p = new VPointF(fPoint, pointName, mx, my); + p->SetShowLabel(showLabel); + if (typeCreation == Source::FromGui) { - id = data->AddGObject(new VPointF(fPoint, pointName, mx, my)); + id = data->AddGObject(p); data->AddLine(secondPointId, id); } else { - data->UpdateGObject(id, new VPointF(fPoint, pointName, mx, my)); + data->UpdateGObject(id, p); data->AddLine(secondPointId, id); if (parse != Document::FullParse) { diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolbisector.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolbisector.h index 185ce7940..05c11acf0 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolbisector.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolbisector.h @@ -57,12 +57,11 @@ public: virtual void setDialog() Q_DECL_OVERRIDE; static VToolBisector* Create(QSharedPointer dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data); - static VToolBisector* Create(const quint32 _id, QString &formula, const quint32 &firstPointId, - const quint32 &secondPointId, const quint32 &thirdPointId, const QString &typeLine, - const QString &lineColor, const QString &pointName, const qreal &mx, const qreal &my, - VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data, - const Document &parse, - const Source &typeCreation); + static VToolBisector* Create(const quint32 _id, QString &formula, quint32 firstPointId, quint32 secondPointId, + quint32 thirdPointId, const QString &typeLine, const QString &lineColor, + const QString &pointName, qreal mx, qreal my, bool showLabel, + VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data, + const Document &parse, const Source &typeCreation); static const QString ToolType; virtual int type() const Q_DECL_OVERRIDE {return Type;} enum { Type = UserType + static_cast(Tool::Bisector)}; diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.cpp index 28cd9eceb..8a04dd63d 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.cpp @@ -113,7 +113,8 @@ VToolCurveIntersectAxis *VToolCurveIntersectAxis::Create(QSharedPointergetCurveId(); VToolCurveIntersectAxis *point = Create(0, pointName, typeLine, lineColor, formulaAngle, basePointId, - curveId, 5, 10, scene, doc, data, Document::FullParse, Source::FromGui); + curveId, 5, 10, true, scene, doc, data, Document::FullParse, + Source::FromGui); if (point != nullptr) { point->m_dialog = dialogTool; @@ -124,11 +125,11 @@ VToolCurveIntersectAxis *VToolCurveIntersectAxis::Create(QSharedPointer basePoint = data->GeometricObject(basePointId); const qreal angle = CheckFormula(_id, formulaAngle, data); @@ -137,7 +138,10 @@ VToolCurveIntersectAxis *VToolCurveIntersectAxis::Create(const quint32 _id, cons const QPointF fPoint = FindPoint(static_cast(*basePoint), angle, curve); const qreal segLength = curve->GetLengthByPoint(fPoint); quint32 id = _id; + VPointF *p = new VPointF(fPoint, pointName, mx, my); + p->SetShowLabel(showLabel); + if (typeCreation == Source::FromGui) { id = data->AddGObject(p); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.h index e5ca57bf9..2df2fb29e 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.h @@ -56,8 +56,8 @@ public: static VToolCurveIntersectAxis *Create(QSharedPointer dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data); static VToolCurveIntersectAxis *Create(const quint32 _id, const QString &pointName, const QString &typeLine, - const QString &lineColor, QString &formulaAngle, const quint32 &basePointId, - const quint32 &curveId, const qreal &mx, const qreal &my, + const QString &lineColor, QString &formulaAngle, quint32 basePointId, + quint32 curveId, qreal mx, qreal my, bool showLabel, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolendline.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolendline.cpp index 5f04f5132..b896febd8 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolendline.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolendline.cpp @@ -120,7 +120,7 @@ VToolEndLine* VToolEndLine::Create(QSharedPointer dialog, VMainGraph const quint32 basePointId = dialogTool->GetBasePointId(); VToolEndLine *point = Create(0, pointName, typeLine, lineColor, formulaLength, formulaAngle, - basePointId, 5, 10, scene, doc, data, Document::FullParse, Source::FromGui); + basePointId, 5, 10, true, scene, doc, data, Document::FullParse, Source::FromGui); if (point != nullptr) { point->m_dialog = dialogTool; @@ -140,6 +140,7 @@ VToolEndLine* VToolEndLine::Create(QSharedPointer dialog, VMainGraph * @param basePointId id first point of line. * @param mx label bias x axis. * @param my label bias y axis. + * @param showLabel show/hide label * @param scene pointer to scene. * @param doc dom document container. * @param data container with variables. @@ -149,10 +150,9 @@ VToolEndLine* VToolEndLine::Create(QSharedPointer dialog, VMainGraph */ VToolEndLine* VToolEndLine::Create(const quint32 _id, const QString &pointName, const QString &typeLine, const QString &lineColor, QString &formulaLength, QString &formulaAngle, - const quint32 &basePointId, const qreal &mx, const qreal &my, + quint32 basePointId, qreal mx, qreal my, bool showLabel, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data, - const Document &parse, - const Source &typeCreation) + const Document &parse, const Source &typeCreation) { const QSharedPointer basePoint = data->GeometricObject(basePointId); QLineF line = QLineF(static_cast(*basePoint), QPointF(basePoint->x()+100, basePoint->y())); @@ -160,14 +160,18 @@ VToolEndLine* VToolEndLine::Create(const quint32 _id, const QString &pointName, line.setAngle(CheckFormula(_id, formulaAngle, data)); //First set angle. line.setLength(qApp->toPixel(CheckFormula(_id, formulaLength, data))); quint32 id = _id; + + VPointF *p = new VPointF(line.p2(), pointName, mx, my); + p->SetShowLabel(showLabel); + if (typeCreation == Source::FromGui) { - id = data->AddGObject(new VPointF(line.p2(), pointName, mx, my)); + id = data->AddGObject(p); data->AddLine(basePointId, id); } else { - data->UpdateGObject(id, new VPointF(line.p2(), pointName, mx, my)); + data->UpdateGObject(id, p); data->AddLine(basePointId, id); if (parse != Document::FullParse) { diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolendline.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolendline.h index 5c234b382..c063ab959 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolendline.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolendline.h @@ -57,7 +57,7 @@ public: VContainer *data); static VToolEndLine *Create(const quint32 _id, const QString &pointName, const QString &typeLine, const QString &lineColor, QString &formulaLength, QString &formulaAngle, - const quint32 &basePointId, const qreal &mx, const qreal &my, + quint32 basePointId, qreal mx, qreal my, bool showLabel, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.cpp index f971340cd..c9a3d541a 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.cpp @@ -114,8 +114,8 @@ VToolHeight* VToolHeight::Create(QSharedPointer dialog, VMainGraphic const quint32 p1LineId = dialogTool->GetP1LineId(); const quint32 p2LineId = dialogTool->GetP2LineId(); - VToolHeight *point = Create(0, pointName, typeLine, lineColor, basePointId, p1LineId, p2LineId, 5, 10, scene, doc, - data, Document::FullParse, Source::FromGui); + VToolHeight *point = Create(0, pointName, typeLine, lineColor, basePointId, p1LineId, p2LineId, 5, 10, true, scene, + doc, data, Document::FullParse, Source::FromGui); if (point != nullptr) { point->m_dialog = dialogTool; @@ -142,8 +142,8 @@ VToolHeight* VToolHeight::Create(QSharedPointer dialog, VMainGraphic * @return the created tool */ VToolHeight* VToolHeight::Create(const quint32 _id, const QString &pointName, const QString &typeLine, - const QString &lineColor, const quint32 &basePointId, const quint32 &p1LineId, - const quint32 &p2LineId, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, + const QString &lineColor, quint32 basePointId, quint32 p1LineId, + quint32 p2LineId, qreal mx, qreal my, bool showLabel, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation) { @@ -154,16 +154,20 @@ VToolHeight* VToolHeight::Create(const quint32 _id, const QString &pointName, co QPointF pHeight = FindPoint(QLineF(static_cast(*p1Line), static_cast(*p2Line)), static_cast(*basePoint)); quint32 id = _id; + + VPointF *p = new VPointF(pHeight, pointName, mx, my); + p->SetShowLabel(showLabel); + if (typeCreation == Source::FromGui) { - id = data->AddGObject(new VPointF(pHeight, pointName, mx, my)); + id = data->AddGObject(p); data->AddLine(basePointId, id); data->AddLine(p1LineId, id); data->AddLine(p2LineId, id); } else { - data->UpdateGObject(id, new VPointF(pHeight, pointName, mx, my)); + data->UpdateGObject(id, p); data->AddLine(basePointId, id); data->AddLine(p1LineId, id); data->AddLine(p2LineId, id); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.h index c22e50215..b66d0682e 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.h @@ -56,8 +56,8 @@ public: static VToolHeight *Create(QSharedPointer dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data); static VToolHeight *Create(const quint32 _id, const QString &pointName, const QString &typeLine, - const QString &lineColor, const quint32 &basePointId, const quint32 &p1LineId, - const quint32 &p2LineId, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, + const QString &lineColor, quint32 basePointId, quint32 p1LineId, + quint32 p2LineId, qreal mx, qreal my, bool showLabel, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation); static QPointF FindPoint(const QLineF &line, const QPointF &point); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.cpp index 8bb55fedb..d185c708c 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.cpp @@ -100,7 +100,7 @@ VToolLineIntersectAxis *VToolLineIntersectAxis::Create(QSharedPointerGetSecondPointId(); VToolLineIntersectAxis *point = Create(0, pointName, typeLine, lineColor, formulaAngle, - basePointId, firstPointId, secondPointId, 5, 10, + basePointId, firstPointId, secondPointId, 5, 10, true, scene, doc, data, Document::FullParse, Source::FromGui); if (point != nullptr) { @@ -112,9 +112,9 @@ VToolLineIntersectAxis *VToolLineIntersectAxis::Create(QSharedPointerSetShowLabel(showLabel); + if (typeCreation == Source::FromGui) { - id = data->AddGObject(new VPointF(fPoint, pointName, mx, my)); + id = data->AddGObject(p); data->AddLine(basePointId, id); data->AddLine(firstPointId, id); data->AddLine(id, secondPointId); } else { - data->UpdateGObject(id, new VPointF(fPoint, pointName, mx, my)); + data->UpdateGObject(id, p); data->AddLine(basePointId, id); data->AddLine(firstPointId, id); data->AddLine(id, secondPointId); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.h index 6547c1f42..33f06fcb1 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.h @@ -56,9 +56,9 @@ public: static VToolLineIntersectAxis *Create(QSharedPointer dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data); static VToolLineIntersectAxis *Create(const quint32 _id, const QString &pointName, const QString &typeLine, - const QString &lineColor, QString &formulaAngle, const quint32 &basePointId, - const quint32 &firstPointId, const quint32 &secondPointId, - const qreal &mx, const qreal &my, VMainGraphicsScene *scene, + const QString &lineColor, QString &formulaAngle, quint32 basePointId, + quint32 firstPointId, quint32 secondPointId, + qreal mx, qreal my, bool showLabel, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolnormal.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolnormal.cpp index e212ff69e..c576b04ff 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolnormal.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolnormal.cpp @@ -121,7 +121,7 @@ VToolNormal* VToolNormal::Create(QSharedPointer dialog, VMainGraphic const QString pointName = dialogTool->getPointName(); const qreal angle = dialogTool->GetAngle(); VToolNormal *point = Create(0, formula, firstPointId, secondPointId, typeLine, lineColor, pointName, angle, 5, 10, - scene, doc, data, Document::FullParse, Source::FromGui); + true, scene, doc, data, Document::FullParse, Source::FromGui); if (point != nullptr) { point->m_dialog = dialogTool; @@ -141,18 +141,18 @@ VToolNormal* VToolNormal::Create(QSharedPointer dialog, VMainGraphic * @param angle additional angle. * @param mx label bias x axis. * @param my label bias y axis. + * @param showLabel show/hide label. * @param scene pointer to scene. * @param doc dom document container. * @param data container with variables. * @param parse parser file mode. * @param typeCreation way we create this tool. */ -VToolNormal* VToolNormal::Create(const quint32 _id, QString &formula, const quint32 &firstPointId, - const quint32 &secondPointId, const QString &typeLine, const QString &lineColor, - const QString &pointName, const qreal angle, const qreal &mx, const qreal &my, +VToolNormal* VToolNormal::Create(const quint32 _id, QString &formula, quint32 firstPointId, quint32 secondPointId, + const QString &typeLine, const QString &lineColor, + const QString &pointName, qreal angle, qreal mx, qreal my, bool showLabel, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data, - const Document &parse, - const Source &typeCreation) + const Document &parse, const Source &typeCreation) { const QSharedPointer firstPoint = data->GeometricObject(firstPointId); const QSharedPointer secondPoint = data->GeometricObject(secondPointId); @@ -162,14 +162,18 @@ VToolNormal* VToolNormal::Create(const quint32 _id, QString &formula, const quin QPointF fPoint = VToolNormal::FindPoint(static_cast(*firstPoint), static_cast(*secondPoint), qApp->toPixel(result), angle); quint32 id = _id; + + VPointF *p = new VPointF(fPoint, pointName, mx, my); + p->SetShowLabel(showLabel); + if (typeCreation == Source::FromGui) { - id = data->AddGObject(new VPointF(fPoint, pointName, mx, my)); + id = data->AddGObject(p); data->AddLine(firstPointId, id); } else { - data->UpdateGObject(id, new VPointF(fPoint, pointName, mx, my)); + data->UpdateGObject(id, p); data->AddLine(firstPointId, id); if (parse != Document::FullParse) { diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolnormal.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolnormal.h index a02d8e0b8..bbfcd32d2 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolnormal.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolnormal.h @@ -54,12 +54,11 @@ public: virtual void setDialog() Q_DECL_OVERRIDE; static VToolNormal* Create(QSharedPointer dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data); - static VToolNormal* Create(const quint32 _id, QString &formula, const quint32 &firstPointId, - const quint32 &secondPointId, const QString &typeLine, const QString &lineColor, - const QString &pointName, const qreal angle, const qreal &mx, const qreal &my, + static VToolNormal* Create(const quint32 _id, QString &formula, quint32 firstPointId, + quint32 secondPointId, const QString &typeLine, const QString &lineColor, + const QString &pointName, const qreal angle, qreal mx, qreal my, bool showLabel, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data, - const Document &parse, - const Source &typeCreation); + const Document &parse, const Source &typeCreation); static QPointF FindPoint(const QPointF &firstPoint, const QPointF &secondPoint, const qreal &length, const qreal &angle = 0); static const QString ToolType; diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.cpp index 76ca60a49..496f0fc06 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.cpp @@ -170,7 +170,7 @@ VToolShoulderPoint* VToolShoulderPoint::Create(QSharedPointer dialog const QString lineColor = dialogTool->GetLineColor(); const QString pointName = dialogTool->getPointName(); VToolShoulderPoint * point = Create(0, formula, p1Line, p2Line, pShoulder, typeLine, lineColor, pointName, 5, - 10, scene, doc, data, Document::FullParse, Source::FromGui); + 10, true, scene, doc, data, Document::FullParse, Source::FromGui); if (point != nullptr) { point->m_dialog = dialogTool; @@ -190,6 +190,7 @@ VToolShoulderPoint* VToolShoulderPoint::Create(QSharedPointer dialog * @param pointName point name. * @param mx label bias x axis. * @param my label bias y axis. + * @param showLabel show/hide label. * @param scene pointer to scene. * @param doc dom document container. * @param data container with variables. @@ -197,11 +198,11 @@ VToolShoulderPoint* VToolShoulderPoint::Create(QSharedPointer dialog * @param typeCreation way we create this tool. * @return the created tool */ -VToolShoulderPoint* VToolShoulderPoint::Create(const quint32 _id, QString &formula, const quint32 &p1Line, - const quint32 &p2Line, const quint32 &pShoulder, const QString &typeLine, - const QString &lineColor, const QString &pointName, const qreal &mx, - const qreal &my, VMainGraphicsScene *scene, VAbstractPattern *doc, - VContainer *data, const Document &parse, const Source &typeCreation) +VToolShoulderPoint* VToolShoulderPoint::Create(const quint32 _id, QString &formula, quint32 p1Line, quint32 p2Line, + quint32 pShoulder, const QString &typeLine, const QString &lineColor, + const QString &pointName, qreal mx, qreal my, bool showLabel, + VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data, + const Document &parse, const Source &typeCreation) { const QSharedPointer firstPoint = data->GeometricObject(p1Line); const QSharedPointer secondPoint = data->GeometricObject(p2Line); @@ -213,15 +214,19 @@ VToolShoulderPoint* VToolShoulderPoint::Create(const quint32 _id, QString &formu static_cast(*secondPoint), static_cast(*shoulderPoint), qApp->toPixel(result)); quint32 id = _id; + + VPointF *p = new VPointF(fPoint, pointName, mx, my); + p->SetShowLabel(showLabel); + if (typeCreation == Source::FromGui) { - id = data->AddGObject(new VPointF(fPoint, pointName, mx, my)); + id = data->AddGObject(p); data->AddLine(p1Line, id); data->AddLine(p2Line, id); } else { - data->UpdateGObject(id, new VPointF(fPoint, pointName, mx, my)); + data->UpdateGObject(id, p); data->AddLine(p1Line, id); data->AddLine(p2Line, id); if (parse != Document::FullParse) diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.h index 18ae1c0c9..23897c804 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.h @@ -57,9 +57,9 @@ public: const qreal &length); static VToolShoulderPoint* Create(QSharedPointer dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data); - static VToolShoulderPoint* Create(const quint32 _id, QString &formula, const quint32 &p1Line, const quint32 &p2Line, - const quint32 &pShoulder, const QString &typeLine, const QString &lineColor, - const QString &pointName, const qreal &mx, const qreal &my, + static VToolShoulderPoint* Create(const quint32 _id, QString &formula, quint32 p1Line, quint32 p2Line, + quint32 pShoulder, const QString &typeLine, const QString &lineColor, + const QString &pointName, qreal mx, qreal my, bool showLabel, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.cpp index 8fc6a6f75..baa90523c 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.cpp @@ -115,8 +115,8 @@ VToolLineIntersect* VToolLineIntersect::Create(QSharedPointer dialog const quint32 p1Line2Id = dialogTool->GetP1Line2(); const quint32 p2Line2Id = dialogTool->GetP2Line2(); const QString pointName = dialogTool->getPointName(); - VToolLineIntersect* point = Create(0, p1Line1Id, p2Line1Id, p1Line2Id, p2Line2Id, pointName, 5, 10, scene, doc, - data, Document::FullParse, Source::FromGui); + VToolLineIntersect* point = Create(0, p1Line1Id, p2Line1Id, p1Line2Id, p2Line2Id, pointName, 5, 10, true, scene, + doc, data, Document::FullParse, Source::FromGui); if (point != nullptr) { point->m_dialog = dialogTool; @@ -142,11 +142,11 @@ VToolLineIntersect* VToolLineIntersect::Create(QSharedPointer dialog * @param typeCreation way we create this tool. * @return the created tool */ -VToolLineIntersect* VToolLineIntersect::Create(const quint32 _id, const quint32 &p1Line1Id, const quint32 &p2Line1Id, - const quint32 &p1Line2Id, const quint32 &p2Line2Id, - const QString &pointName, const qreal &mx, const qreal &my, - VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data, - const Document &parse, const Source &typeCreation) +VToolLineIntersect* VToolLineIntersect::Create(const quint32 _id, quint32 p1Line1Id, quint32 p2Line1Id, + quint32 p1Line2Id, quint32 p2Line2Id, const QString &pointName, + qreal mx, qreal my, bool showLabel, VMainGraphicsScene *scene, + VAbstractPattern *doc, VContainer *data, const Document &parse, + const Source &typeCreation) { const QSharedPointer p1Line1 = data->GeometricObject(p1Line1Id); const QSharedPointer p2Line1 = data->GeometricObject(p2Line1Id); @@ -160,9 +160,13 @@ VToolLineIntersect* VToolLineIntersect::Create(const quint32 _id, const quint32 if (intersect == QLineF::UnboundedIntersection || intersect == QLineF::BoundedIntersection) { quint32 id = _id; + + VPointF *p = new VPointF(fPoint, pointName, mx, my); + p->SetShowLabel(showLabel); + if (typeCreation == Source::FromGui) { - id = data->AddGObject(new VPointF(fPoint, pointName, mx, my)); + id = data->AddGObject(p); data->AddLine(p1Line1Id, id); data->AddLine(id, p2Line1Id); data->AddLine(p1Line2Id, id); @@ -170,7 +174,7 @@ VToolLineIntersect* VToolLineIntersect::Create(const quint32 _id, const quint32 } else { - data->UpdateGObject(id, new VPointF(fPoint, pointName, mx, my)); + data->UpdateGObject(id, p); data->AddLine(p1Line1Id, id); data->AddLine(id, p2Line1Id); data->AddLine(p1Line2Id, id); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.h index cf7820099..5db39bfe8 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.h @@ -53,9 +53,9 @@ public: virtual void setDialog() Q_DECL_OVERRIDE; static VToolLineIntersect *Create(QSharedPointer dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data); - static VToolLineIntersect *Create(const quint32 _id, const quint32 &p1Line1Id, const quint32 &p2Line1Id, - const quint32 &p1Line2Id, const quint32 &p2Line2Id, const QString &pointName, - const qreal &mx, const qreal &my, VMainGraphicsScene *scene, + static VToolLineIntersect *Create(const quint32 _id, quint32 p1Line1Id, quint32 p2Line1Id, + quint32 p1Line2Id, quint32 p2Line2Id, const QString &pointName, + qreal mx, qreal my, bool showLabel, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation); static const QString ToolType; diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.cpp index f1e4009ee..f722b4803 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.cpp @@ -89,7 +89,7 @@ VToolPointFromArcAndTangent *VToolPointFromArcAndTangent::Create(QSharedPointer< const quint32 tangentPointId = dialogTool->GetTangentPointId(); const CrossCirclesPoint pType = dialogTool->GetCrossCirclesPoint(); const QString pointName = dialogTool->getPointName(); - VToolPointFromArcAndTangent *point = Create(0, pointName, arcId, tangentPointId, pType, 5, 10, scene, doc, + VToolPointFromArcAndTangent *point = Create(0, pointName, arcId, tangentPointId, pType, 5, 10, true, scene, doc, data, Document::FullParse, Source::FromGui); if (point != nullptr) { @@ -101,8 +101,8 @@ VToolPointFromArcAndTangent *VToolPointFromArcAndTangent::Create(QSharedPointer< //--------------------------------------------------------------------------------------------------------------------- VToolPointFromArcAndTangent *VToolPointFromArcAndTangent::Create(const quint32 _id, const QString &pointName, quint32 arcId, quint32 tangentPointId, - CrossCirclesPoint crossPoint, const qreal &mx, - const qreal &my, VMainGraphicsScene *scene, + CrossCirclesPoint crossPoint, qreal mx, + qreal my, bool showLabel, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation) { @@ -111,13 +111,17 @@ VToolPointFromArcAndTangent *VToolPointFromArcAndTangent::Create(const quint32 _ const QPointF point = VToolPointFromArcAndTangent::FindPoint(static_cast(tPoint), &arc, crossPoint); quint32 id = _id; + + VPointF *p = new VPointF(point, pointName, mx, my); + p->SetShowLabel(showLabel); + if (typeCreation == Source::FromGui) { - id = data->AddGObject(new VPointF(point, pointName, mx, my)); + id = data->AddGObject(p); } else { - data->UpdateGObject(id, new VPointF(point, pointName, mx, my)); + data->UpdateGObject(id, p); if (parse != Document::FullParse) { doc->UpdateToolData(id, data); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.h index 9e9b0f8ea..0fec16103 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.h @@ -52,9 +52,10 @@ public: static VToolPointFromArcAndTangent *Create(QSharedPointer dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data); static VToolPointFromArcAndTangent *Create(const quint32 _id, const QString &pointName, quint32 arcId, - quint32 tangentPointId, CrossCirclesPoint crossPoint, const qreal &mx, - const qreal &my, VMainGraphicsScene *scene, VAbstractPattern *doc, - VContainer *data, const Document &parse, const Source &typeCreation); + quint32 tangentPointId, CrossCirclesPoint crossPoint, qreal mx, + qreal my, bool showLabel, VMainGraphicsScene *scene, + VAbstractPattern *doc, VContainer *data, const Document &parse, + const Source &typeCreation); static QPointF FindPoint(const QPointF &p, const VArc *arc, const CrossCirclesPoint pType); static const QString ToolType; virtual int type() const Q_DECL_OVERRIDE {return Type;} diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.cpp index feedfe8ad..e26dc783c 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.cpp @@ -95,7 +95,7 @@ VToolPointFromCircleAndTangent *VToolPointFromCircleAndTangent::Create(QSharedPo const CrossCirclesPoint pType = dialogTool->GetCrossCirclesPoint(); const QString pointName = dialogTool->getPointName(); VToolPointFromCircleAndTangent *point = Create(0, pointName, circleCenterId, circleRadius, tangentPointId, pType, - 5, 10, scene, doc, data, Document::FullParse, Source::FromGui); + 5, 10, true, scene, doc, data, Document::FullParse, Source::FromGui); if (point != nullptr) { point->m_dialog = dialogTool; @@ -107,8 +107,9 @@ VToolPointFromCircleAndTangent *VToolPointFromCircleAndTangent::Create(QSharedPo VToolPointFromCircleAndTangent *VToolPointFromCircleAndTangent::Create(const quint32 _id, const QString &pointName, quint32 circleCenterId, QString &circleRadius, quint32 tangentPointId, - CrossCirclesPoint crossPoint, const qreal &mx, - const qreal &my, VMainGraphicsScene *scene, + CrossCirclesPoint crossPoint, qreal mx, + qreal my, bool showLabel, + VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation) @@ -120,13 +121,17 @@ VToolPointFromCircleAndTangent *VToolPointFromCircleAndTangent::Create(const qui const QPointF point = VToolPointFromCircleAndTangent::FindPoint(static_cast(tPoint), static_cast(cPoint), radius, crossPoint); quint32 id = _id; + + VPointF *p = new VPointF(point, pointName, mx, my); + p->SetShowLabel(showLabel); + if (typeCreation == Source::FromGui) { - id = data->AddGObject(new VPointF(point, pointName, mx, my)); + id = data->AddGObject(p); } else { - data->UpdateGObject(id, new VPointF(point, pointName, mx, my)); + data->UpdateGObject(id, p); if (parse != Document::FullParse) { doc->UpdateToolData(id, data); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.h index 892a54094..769c1b823 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.h @@ -54,7 +54,7 @@ public: VAbstractPattern *doc, VContainer *data); static VToolPointFromCircleAndTangent *Create(const quint32 _id, const QString &pointName, quint32 circleCenterId, QString &circleRadius, quint32 tangentPointId, - CrossCirclesPoint crossPoint, const qreal &mx, const qreal &my, + CrossCirclesPoint crossPoint, qreal mx, qreal my, bool showLabel, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation); static QPointF FindPoint(const QPointF &p, const QPointF ¢er, qreal radius, const CrossCirclesPoint crossPoint); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.cpp index 966b50da8..ef2dec366 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.cpp @@ -175,8 +175,8 @@ VToolPointOfContact* VToolPointOfContact::Create(QSharedPointer dial const quint32 firstPointId = dialogTool->GetFirstPoint(); const quint32 secondPointId = dialogTool->GetSecondPoint(); const QString pointName = dialogTool->getPointName(); - VToolPointOfContact *point = Create(0, radius, center, firstPointId, secondPointId, pointName, 5, 10, scene, doc, - data, Document::FullParse, Source::FromGui); + VToolPointOfContact *point = Create(0, radius, center, firstPointId, secondPointId, pointName, 5, 10, true, scene, + doc, data, Document::FullParse, Source::FromGui); if (point != nullptr) { point->m_dialog = dialogTool; @@ -201,9 +201,9 @@ VToolPointOfContact* VToolPointOfContact::Create(QSharedPointer dial * @param parse parser file mode. * @param typeCreation way we create this tool. */ -VToolPointOfContact* 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, +VToolPointOfContact* VToolPointOfContact::Create(const quint32 _id, QString &radius, quint32 center, + quint32 firstPointId, quint32 secondPointId, + const QString &pointName, qreal mx, qreal my, bool showLabel, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation) { @@ -216,16 +216,20 @@ VToolPointOfContact* VToolPointOfContact::Create(const quint32 _id, QString &rad QPointF fPoint = VToolPointOfContact::FindPoint(qApp->toPixel(result), static_cast(*centerP), static_cast(*firstP), static_cast(*secondP)); quint32 id = _id; + + VPointF *p = new VPointF(fPoint, pointName, mx, my); + p->SetShowLabel(showLabel); + if (typeCreation == Source::FromGui) { - id = data->AddGObject(new VPointF(fPoint, pointName, mx, my)); + id = data->AddGObject(p); data->AddLine(firstPointId, id); data->AddLine(secondPointId, id); data->AddLine(center, id); } else { - data->UpdateGObject(id, new VPointF(fPoint, pointName, mx, my)); + data->UpdateGObject(id, p); data->AddLine(firstPointId, id); data->AddLine(secondPointId, id); data->AddLine(center, id); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.h index b08b57bd5..545542090 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.h @@ -57,10 +57,10 @@ public: const QPointF &secondPoint); static VToolPointOfContact* Create(QSharedPointer dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data); - static VToolPointOfContact* Create(const quint32 _id, QString &radius, const quint32 ¢er, - const quint32 &firstPointId, const quint32 &secondPointId, + static VToolPointOfContact* Create(const quint32 _id, QString &radius, quint32 center, + quint32 firstPointId, quint32 secondPointId, const QString &pointName, - const qreal &mx, const qreal &my, VMainGraphicsScene *scene, + qreal mx, qreal my, bool showLabel, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation); static const QString ToolType; diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersection.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersection.cpp index 871ede5b7..5e859b528 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersection.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersection.cpp @@ -105,7 +105,7 @@ VToolPointOfIntersection *VToolPointOfIntersection::Create(QSharedPointerGetFirstPointId(); const quint32 secondPointId = dialogTool->GetSecondPointId(); const QString pointName = dialogTool->getPointName(); - VToolPointOfIntersection *point = Create(0, pointName, firstPointId, secondPointId, 5, 10, scene, doc, + VToolPointOfIntersection *point = Create(0, pointName, firstPointId, secondPointId, 5, 10, true, scene, doc, data, Document::FullParse, Source::FromGui); if (point != nullptr) { @@ -131,24 +131,27 @@ VToolPointOfIntersection *VToolPointOfIntersection::Create(QSharedPointer firstPoint = data->GeometricObject(firstPointId); const QSharedPointer secondPoint = data->GeometricObject(secondPointId); QPointF point(firstPoint->x(), secondPoint->y()); quint32 id = _id; + + VPointF *p = new VPointF(point, pointName, mx, my); + p->SetShowLabel(showLabel); + if (typeCreation == Source::FromGui) { - id = data->AddGObject(new VPointF(point, pointName, mx, my)); + id = data->AddGObject(p); } else { - data->UpdateGObject(id, new VPointF(point, pointName, mx, my)); + data->UpdateGObject(id, p); if (parse != Document::FullParse) { doc->UpdateToolData(id, data); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersection.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersection.h index 1e8a61fff..800282974 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersection.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersection.h @@ -53,8 +53,8 @@ public: virtual void setDialog() Q_DECL_OVERRIDE; static VToolPointOfIntersection *Create(QSharedPointer dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data); - static VToolPointOfIntersection *Create(const quint32 _id, const QString &pointName, const quint32 &firstPointId, - const quint32 &secondPointId, const qreal &mx, const qreal &my, + static VToolPointOfIntersection *Create(const quint32 _id, const QString &pointName, quint32 firstPointId, + quint32 secondPointId, qreal mx, qreal my, bool showLabel, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation); static const QString ToolType; diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectionarcs.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectionarcs.cpp index 824eb7636..a0a24032b 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectionarcs.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectionarcs.cpp @@ -89,7 +89,7 @@ VToolPointOfIntersectionArcs *VToolPointOfIntersectionArcs::Create(QSharedPointe const quint32 secondArcId = dialogTool->GetSecondArcId(); const CrossCirclesPoint pType = dialogTool->GetCrossArcPoint(); const QString pointName = dialogTool->getPointName(); - VToolPointOfIntersectionArcs *point = Create(0, pointName, firstArcId, secondArcId, pType, 5, 10, scene, doc, + VToolPointOfIntersectionArcs *point = Create(0, pointName, firstArcId, secondArcId, pType, 5, 10, true, scene, doc, data, Document::FullParse, Source::FromGui); if (point != nullptr) { @@ -100,25 +100,28 @@ VToolPointOfIntersectionArcs *VToolPointOfIntersectionArcs::Create(QSharedPointe //--------------------------------------------------------------------------------------------------------------------- VToolPointOfIntersectionArcs *VToolPointOfIntersectionArcs::Create(const quint32 _id, const QString &pointName, - const quint32 &firstArcId, - const quint32 &secondArcId, CrossCirclesPoint pType, - const qreal &mx, const qreal &my, - VMainGraphicsScene *scene, VAbstractPattern *doc, - VContainer *data, const Document &parse, - const Source &typeCreation) + quint32 firstArcId, quint32 secondArcId, + CrossCirclesPoint pType, qreal mx, qreal my, + bool showLabel, VMainGraphicsScene *scene, + VAbstractPattern *doc, VContainer *data, + const Document &parse, const Source &typeCreation) { const QSharedPointer firstArc = data->GeometricObject(firstArcId); const QSharedPointer secondArc = data->GeometricObject(secondArcId); const QPointF point = FindPoint(firstArc.data(), secondArc.data(), pType); quint32 id = _id; + + VPointF *p = new VPointF(point, pointName, mx, my); + p->SetShowLabel(showLabel); + if (typeCreation == Source::FromGui) { - id = data->AddGObject(new VPointF(point, pointName, mx, my)); + id = data->AddGObject(p); } else { - data->UpdateGObject(id, new VPointF(point, pointName, mx, my)); + data->UpdateGObject(id, p); if (parse != Document::FullParse) { doc->UpdateToolData(id, data); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectionarcs.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectionarcs.h index 779a145f5..b4cc84af8 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectionarcs.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectionarcs.h @@ -52,9 +52,9 @@ public: virtual void setDialog() Q_DECL_OVERRIDE; static VToolPointOfIntersectionArcs *Create(QSharedPointer dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data); - static VToolPointOfIntersectionArcs *Create(const quint32 _id, const QString &pointName, const quint32 &firstArcId, - const quint32 &secondArcId, CrossCirclesPoint pType, - const qreal &mx, const qreal &my, VMainGraphicsScene *scene, + static VToolPointOfIntersectionArcs *Create(const quint32 _id, const QString &pointName, quint32 firstArcId, + quint32 secondArcId, CrossCirclesPoint pType, + qreal mx, qreal my, bool showLabel, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation); static QPointF FindPoint(const VArc *arc1, const VArc *arc2, const CrossCirclesPoint pType); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.cpp index e95b672ae..68e7cb236 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.cpp @@ -103,8 +103,8 @@ VToolPointOfIntersectionCircles *VToolPointOfIntersectionCircles::Create(QShared const CrossCirclesPoint pType = dialogTool->GetCrossCirclesPoint(); const QString pointName = dialogTool->getPointName(); VToolPointOfIntersectionCircles *point = Create(0, pointName, firstCircleCenterId, secondCircleCenterId, - firstCircleRadius, secondCircleRadius, pType, 5, 10, scene, doc, - data, Document::FullParse, Source::FromGui); + firstCircleRadius, secondCircleRadius, pType, 5, 10, true, scene, + doc, data, Document::FullParse, Source::FromGui); if (point != nullptr) { point->m_dialog = dialogTool; @@ -118,8 +118,9 @@ VToolPointOfIntersectionCircles *VToolPointOfIntersectionCircles::Create(const q quint32 secondCircleCenterId, QString &firstCircleRadius, QString &secondCircleRadius, - CrossCirclesPoint crossPoint, const qreal &mx, - const qreal &my, VMainGraphicsScene *scene, + CrossCirclesPoint crossPoint, qreal mx, + qreal my, bool showLabel, + VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation) @@ -133,13 +134,17 @@ VToolPointOfIntersectionCircles *VToolPointOfIntersectionCircles::Create(const q const QPointF point = FindPoint(static_cast(c1Point), static_cast(c2Point), calcC1Radius, calcC2Radius, crossPoint); quint32 id = _id; + + VPointF *p = new VPointF(point, pointName, mx, my); + p->SetShowLabel(showLabel); + if (typeCreation == Source::FromGui) { - id = data->AddGObject(new VPointF(point, pointName, mx, my)); + id = data->AddGObject(p); } else { - data->UpdateGObject(id, new VPointF(point, pointName, mx, my)); + data->UpdateGObject(id, p); if (parse != Document::FullParse) { doc->UpdateToolData(id, data); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.h index f961be30e..75f42229e 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.h @@ -56,7 +56,7 @@ public: quint32 firstCircleCenterId, quint32 secondCircleCenterId, QString &firstCircleRadius, QString &secondCircleRadius, CrossCirclesPoint crossPoint, - const qreal &mx, const qreal &my, VMainGraphicsScene *scene, + qreal mx, qreal my, bool showLabel, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation); static QPointF FindPoint(const QPointF &c1Point, const QPointF &c2Point, qreal c1Radius, qreal c2Radius, diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.cpp index cf4d5175f..5e704cb72 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.cpp @@ -97,7 +97,7 @@ VToolPointOfIntersectionCurves *VToolPointOfIntersectionCurves::Create(QSharedPo const HCrossCurvesPoint hCrossPoint = dialogTool->GetHCrossPoint(); const QString pointName = dialogTool->getPointName(); VToolPointOfIntersectionCurves *point = Create(0, pointName, firstCurveId, secondCurveId, vCrossPoint, hCrossPoint, - 5, 10, scene, doc, data, Document::FullParse, Source::FromGui); + 5, 10, true, scene, doc, data, Document::FullParse, Source::FromGui); if (point != nullptr) { point->m_dialog = dialogTool; @@ -109,8 +109,9 @@ VToolPointOfIntersectionCurves *VToolPointOfIntersectionCurves::Create(QSharedPo VToolPointOfIntersectionCurves *VToolPointOfIntersectionCurves::Create(const quint32 _id, const QString &pointName, quint32 firstCurveId, quint32 secondCurveId, VCrossCurvesPoint vCrossPoint, - HCrossCurvesPoint hCrossPoint, const qreal &mx, - const qreal &my, VMainGraphicsScene *scene, + HCrossCurvesPoint hCrossPoint,qreal mx, + qreal my, bool showLabel, + VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation) @@ -121,13 +122,17 @@ VToolPointOfIntersectionCurves *VToolPointOfIntersectionCurves::Create(const qui const QPointF point = VToolPointOfIntersectionCurves::FindPoint(curve1->GetPoints(), curve2->GetPoints(), vCrossPoint, hCrossPoint); quint32 id = _id; + + VPointF *p = new VPointF(point, pointName, mx, my); + p->SetShowLabel(showLabel); + if (typeCreation == Source::FromGui) { - id = data->AddGObject(new VPointF(point, pointName, mx, my)); + id = data->AddGObject(p); } else { - data->UpdateGObject(id, new VPointF(point, pointName, mx, my)); + data->UpdateGObject(id, p); if (parse != Document::FullParse) { doc->UpdateToolData(id, data); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.h index 57e69153e..2db1b7dba 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.h @@ -55,7 +55,7 @@ public: static VToolPointOfIntersectionCurves *Create(const quint32 _id, const QString &pointName, quint32 firstCurveId, quint32 secondCurveId, VCrossCurvesPoint vCrossPoint, HCrossCurvesPoint hCrossPoint, - const qreal &mx, const qreal &my, VMainGraphicsScene *scene, + qreal mx, qreal my, bool showLabel, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation); static QPointF FindPoint(const QVector &curve1Points, const QVector &curve2Points, diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.cpp index eab9beeda..8fe6d6ddc 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.cpp @@ -44,6 +44,7 @@ #include #include "../../../../undocommands/label/movelabel.h" +#include "../../../../undocommands/label/showlabel.h" #include "../ifc/exception/vexception.h" #include "../ifc/exception/vexceptionbadid.h" #include "../ifc/ifcdef.h" @@ -310,6 +311,16 @@ void VToolSinglePoint::SaveOptions(QDomElement &tag, QSharedPointer &o doc->SetAttribute(tag, AttrName, point->name()); doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx())); doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my())); + doc->SetAttribute(tag, AttrShowLabel, point->IsShowLabel()); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolSinglePoint::ChangeLabelVisibility(quint32 id, bool visible) +{ + if (id == m_id) + { + qApp->getUndoStack()->push(new ShowLabel(doc, id, visible)); + } } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.h index d913d3638..cb4479bbb 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.h @@ -88,6 +88,7 @@ protected: virtual void keyReleaseEvent(QKeyEvent * event) Q_DECL_OVERRIDE; virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE; virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj) Q_DECL_OVERRIDE; + virtual void ChangeLabelVisibility(quint32 id, bool visible); private: Q_DISABLE_COPY(VToolSinglePoint) }; diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.cpp index 12f95cce9..73a616a60 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.cpp @@ -114,7 +114,7 @@ VToolTriangle* VToolTriangle::Create(QSharedPointer dialog, VMainGra const quint32 firstPointId = dialogTool->GetFirstPointId(); const quint32 secondPointId = dialogTool->GetSecondPointId(); const QString pointName = dialogTool->getPointName(); - VToolTriangle* point = Create(0, pointName, axisP1Id, axisP2Id, firstPointId, secondPointId, 5, 10, + VToolTriangle* point = Create(0, pointName, axisP1Id, axisP2Id, firstPointId, secondPointId, 5, 10, true, scene, doc, data, Document::FullParse, Source::FromGui); if (point != nullptr) { @@ -141,9 +141,9 @@ VToolTriangle* VToolTriangle::Create(QSharedPointer dialog, VMainGra * @param typeCreation way we create this tool. * @return the created tool */ -VToolTriangle* VToolTriangle::Create(const quint32 _id, const QString &pointName, const quint32 &axisP1Id, - const quint32 &axisP2Id, const quint32 &firstPointId, const quint32 &secondPointId, - const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VAbstractPattern *doc, +VToolTriangle* VToolTriangle::Create(const quint32 _id, const QString &pointName, quint32 axisP1Id, quint32 axisP2Id, + quint32 firstPointId, quint32 secondPointId, qreal mx, qreal my, bool showLabel, + VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation) { const QSharedPointer axisP1 = data->GeometricObject(axisP1Id); @@ -154,13 +154,17 @@ VToolTriangle* VToolTriangle::Create(const quint32 _id, const QString &pointName QPointF point = FindPoint(static_cast(*axisP1), static_cast(*axisP2), static_cast(*firstPoint), static_cast(*secondPoint)); quint32 id = _id; + + VPointF *p = new VPointF(point, pointName, mx, my); + p->SetShowLabel(showLabel); + if (typeCreation == Source::FromGui) { - id = data->AddGObject(new VPointF(point, pointName, mx, my)); + id = data->AddGObject(p); } else { - data->UpdateGObject(id, new VPointF(point, pointName, mx, my)); + data->UpdateGObject(id, p); if (parse != Document::FullParse) { doc->UpdateToolData(id, data); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.h index 4d00789f2..d0b1d9b86 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.h @@ -55,9 +55,9 @@ public: virtual void setDialog() Q_DECL_OVERRIDE; static VToolTriangle *Create(QSharedPointer dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data); - static VToolTriangle *Create(const quint32 _id, const QString &pointName, const quint32 &axisP1Id, - const quint32 &axisP2Id, const quint32 &firstPointId, const quint32 &secondPointId, - const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VAbstractPattern *doc, + static VToolTriangle *Create(const quint32 _id, const QString &pointName, quint32 axisP1Id, + quint32 axisP2Id, quint32 firstPointId, quint32 secondPointId, + qreal mx, qreal my, bool showLabel, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation); static QPointF FindPoint(const QPointF &axisP1, const QPointF &axisP2, const QPointF &firstPoint, const QPointF &secondPoint); diff --git a/src/libs/vtools/tools/drawTools/vdrawtool.h b/src/libs/vtools/tools/drawTools/vdrawtool.h index 266fc7ea7..c2169c25c 100644 --- a/src/libs/vtools/tools/drawTools/vdrawtool.h +++ b/src/libs/vtools/tools/drawTools/vdrawtool.h @@ -82,7 +82,6 @@ public slots: virtual void DetailsMode(bool mode); protected slots: virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID)=0; - virtual void ChangeLabelVisibility(quint32 id, bool visible); protected: enum class RemoveOption : bool {Disable = false, Enable = true}; @@ -108,6 +107,7 @@ protected: void ReadAttributes(); virtual void ReadToolAttributes(const QDomElement &domElement)=0; + virtual void ChangeLabelVisibility(quint32 id, bool visible); template void ContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 itemId, @@ -151,16 +151,7 @@ void VDrawTool::ContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 itemI QAction *actionShowLabel = menu.addAction(tr("Show label")); actionShowLabel->setCheckable(true); - - try - { - const QSharedPointer point = VAbstractTool::data.GeometricObject(itemId); - actionShowLabel->setChecked(point->IsShowLabel()); - } - catch(const VExceptionBadId &) - { - actionShowLabel->setVisible(false); - } + actionShowLabel->setChecked(IsLabelVisible(itemId)); QAction *actionRemove = menu.addAction(QIcon::fromTheme("edit-delete"), tr("Delete")); if (showRemove == RemoveOption::Enable) @@ -213,7 +204,7 @@ void VDrawTool::ContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 itemI } else if (selectedAction == actionShowLabel) { - SetLabelVisible(itemId, selectedAction->isChecked()); + ChangeLabelVisibility(itemId, selectedAction->isChecked()); } } diff --git a/src/libs/vtools/undocommands/label/showlabel.cpp b/src/libs/vtools/undocommands/label/showlabel.cpp new file mode 100644 index 000000000..485099147 --- /dev/null +++ b/src/libs/vtools/undocommands/label/showlabel.cpp @@ -0,0 +1,95 @@ +/************************************************************************ + ** + ** @file + ** @author Roman Telezhynskyi + ** @date 17 9, 2017 + ** + ** @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) 2017 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 "showlabel.h" + +#include + +#include "../ifc/xml/vabstractpattern.h" +#include "../vmisc/logging.h" +#include "../vwidgets/vmaingraphicsview.h" +#include "../vmisc/vabstractapplication.h" +#include "../vtools/tools/drawTools/vdrawtool.h" + +//--------------------------------------------------------------------------------------------------------------------- +ShowLabel::ShowLabel(VAbstractPattern *doc, quint32 id, bool visible, QUndoCommand *parent) + : VUndoCommand(QDomElement(), doc, parent), + m_visible(visible), + m_oldVisible(true), + m_scene(qApp->getCurrentScene()) +{ + setText(tr("toggle label")); + + nodeId = id; + + QDomElement domElement = doc->elementById(nodeId, VAbstractPattern::TagPoint); + if (domElement.isElement()) + { + m_oldVisible = doc->GetParametrBool(domElement, AttrShowLabel, trueStr); + } + else + { + qCDebug(vUndo, "Can't find point with id = %u.", nodeId); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void ShowLabel::undo() +{ + qCDebug(vUndo, "Undo."); + + Do(m_oldVisible); +} + +//--------------------------------------------------------------------------------------------------------------------- +void ShowLabel::redo() +{ + qCDebug(vUndo, "Redo."); + + Do(m_visible); +} + +//--------------------------------------------------------------------------------------------------------------------- +void ShowLabel::Do(bool visible) +{ + QDomElement domElement = doc->elementById(nodeId, VAbstractPattern::TagPoint); + if (domElement.isElement()) + { + doc->SetAttribute(domElement, AttrShowLabel, QString().setNum(visible)); + + VMainGraphicsView::NewSceneRect(m_scene, qApp->getSceneView()); + if (VDrawTool *tool = qobject_cast(VAbstractPattern::getTool(nodeId))) + { + tool->SetLabelVisible(nodeId, visible); + } + } + else + { + qCDebug(vUndo, "Can't find point with id = %u.", nodeId); + } +} diff --git a/src/libs/vtools/undocommands/label/showlabel.h b/src/libs/vtools/undocommands/label/showlabel.h new file mode 100644 index 000000000..540b43c0a --- /dev/null +++ b/src/libs/vtools/undocommands/label/showlabel.h @@ -0,0 +1,55 @@ +/************************************************************************ + ** + ** @file + ** @author Roman Telezhynskyi + ** @date 17 9, 2017 + ** + ** @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) 2017 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 SHOWLABEL_H +#define SHOWLABEL_H + +#include "../vundocommand.h" + +class QGraphicsScene; + +class ShowLabel : public VUndoCommand +{ +public: + ShowLabel(VAbstractPattern *doc, quint32 id, bool visible, + QUndoCommand *parent = nullptr); + virtual ~ShowLabel()=default; + + virtual void undo() Q_DECL_OVERRIDE; + virtual void redo() Q_DECL_OVERRIDE; +private: + Q_DISABLE_COPY(ShowLabel) + bool m_visible; + bool m_oldVisible; + //Need for resizing scene rect + QGraphicsScene *m_scene; + + void Do(bool visible); +}; + +#endif // SHOWLABEL_H diff --git a/src/libs/vtools/undocommands/undocommands.pri b/src/libs/vtools/undocommands/undocommands.pri index b77b22ae9..731009a06 100644 --- a/src/libs/vtools/undocommands/undocommands.pri +++ b/src/libs/vtools/undocommands/undocommands.pri @@ -24,7 +24,8 @@ HEADERS += \ $$PWD/movepiece.h \ $$PWD/savepieceoptions.h \ $$PWD/togglepieceinlayout.h \ - $$PWD/savepiecepathoptions.h + $$PWD/savepiecepathoptions.h \ + $$PWD/label/showlabel.h SOURCES += \ $$PWD/addtocalc.cpp \ @@ -49,4 +50,5 @@ SOURCES += \ $$PWD/movepiece.cpp \ $$PWD/savepieceoptions.cpp \ $$PWD/togglepieceinlayout.cpp \ - $$PWD/savepiecepathoptions.cpp + $$PWD/savepiecepathoptions.cpp \ + $$PWD/label/showlabel.cpp