From eb9f8f4b60aba7a532cc1face9356632e677e06b Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Tue, 2 Feb 2016 15:34:29 +0200 Subject: [PATCH] Resolved issue #441. Broken reference incrementation for tool "True Dart point". --HG-- branch : release --- ChangeLog.txt | 1 + src/app/valentina/xml/vpattern.cpp | 2 +- src/libs/vgeometry/vgobject.cpp | 20 +++++++++++ src/libs/vgeometry/vgobject.h | 2 ++ .../tools/drawTools/toolcurve/vtoolarc.cpp | 6 ++-- .../toolcurve/vtoolarcwithlength.cpp | 6 ++-- .../tools/drawTools/toolcurve/vtoolspline.cpp | 10 +++--- .../drawTools/toolcurve/vtoolsplinepath.cpp | 6 ++-- .../tooldoublepoint/vtooltruedarts.cpp | 34 +++++++++++-------- .../toolsinglepoint/toolcut/vtoolcut.cpp | 4 ++- .../toolsinglepoint/toolcut/vtoolcutarc.cpp | 2 +- .../toolcut/vtoolcutspline.cpp | 2 +- .../toolcut/vtoolcutsplinepath.cpp | 2 +- .../toollinepoint/vtoolalongline.cpp | 7 ++-- .../toollinepoint/vtoolbisector.cpp | 13 ++++--- .../toollinepoint/vtoolcurveintersectaxis.cpp | 4 +-- .../toollinepoint/vtoolendline.cpp | 2 +- .../toollinepoint/vtoolheight.cpp | 6 ++-- .../toollinepoint/vtoollineintersectaxis.cpp | 6 ++-- .../toollinepoint/vtoollinepoint.cpp | 3 +- .../toollinepoint/vtoolnormal.cpp | 7 ++-- .../toollinepoint/vtoolshoulderpoint.cpp | 13 ++++--- .../toolsinglepoint/vtoollineintersect.cpp | 21 +++++++----- .../vtoolpointfromarcandtangent.cpp | 11 +++--- .../vtoolpointfromcircleandtangent.cpp | 11 +++--- .../toolsinglepoint/vtoolpointofcontact.cpp | 16 +++++---- .../vtoolpointofintersection.cpp | 11 +++--- .../vtoolpointofintersectionarcs.cpp | 11 +++--- .../vtoolpointofintersectioncircles.cpp | 11 +++--- .../toolsinglepoint/vtooltriangle.cpp | 21 +++++++----- src/libs/vtools/tools/drawTools/vtoolline.cpp | 15 +++++--- 31 files changed, 181 insertions(+), 105 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 0ac01274f..66b0a076c 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,4 +1,5 @@ # Version 0.4.2 +- [#441] Broken reference incrementation for tool "True Dart point". - [#439] Widen Formula Dialog. - Fixed broken tool dialogs "Intersection arcs" and "Point from arc and tangent". - [#442] 'Broken Formula' error when using Intersect Circles tool. diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index 0dcbece19..e8f251b61 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -1871,7 +1871,7 @@ void VPattern::ParseToolSplinePath(VMainGraphicsScene *scene, const QDomElement path->append(splPoint); if (parse == Document::FullParse) { - IncrementReferens(pSpline); + IncrementReferens(p.getIdTool()); } } } diff --git a/src/libs/vgeometry/vgobject.cpp b/src/libs/vgeometry/vgobject.cpp index 409c56173..aa4cd848f 100644 --- a/src/libs/vgeometry/vgobject.cpp +++ b/src/libs/vgeometry/vgobject.cpp @@ -180,6 +180,26 @@ void VGObject::setId(const quint32 &id) d->_id = id; } +//--------------------------------------------------------------------------------------------------------------------- +quint32 VGObject::getIdTool() const +{ + if (d->mode == Draw::Calculation) + { + if (d->idObject != NULL_ID) + { + return d->idObject; + } + else + { + return d->_id; + } + } + else + { + return d->_id; + } +} + //--------------------------------------------------------------------------------------------------------------------- QLineF VGObject::BuildLine(const QPointF &p1, const qreal &length, const qreal &angle) { diff --git a/src/libs/vgeometry/vgobject.h b/src/libs/vgeometry/vgobject.h index 58d6a3b1d..9cda0214a 100644 --- a/src/libs/vgeometry/vgobject.h +++ b/src/libs/vgeometry/vgobject.h @@ -68,6 +68,8 @@ public: quint32 id() const; virtual void setId(const quint32 &id); + quint32 getIdTool() const; + static QLineF BuildLine(const QPointF &p1, const qreal& length, const qreal &angle); static QPointF BuildRay(const QPointF &firstPoint, const qreal &angle, const QRectF &scRect); static QLineF BuildAxis(const QPointF &p, const qreal &angle, const QRectF &scRect); diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolarc.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolarc.cpp index f4b82d6e6..6508afcf9 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolarc.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolarc.cpp @@ -160,7 +160,7 @@ VToolArc* VToolArc::Create(const quint32 _id, const quint32 ¢er, QString &ra connect(scene, &VMainGraphicsScene::NewFactor, toolArc, &VToolArc::SetFactor); connect(scene, &VMainGraphicsScene::DisableItem, toolArc, &VToolArc::Disable); doc->AddTool(id, toolArc); - doc->IncrementReferens(center); + doc->IncrementReferens(c.getIdTool()); return toolArc; } return nullptr; @@ -310,8 +310,8 @@ void VToolArc::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) */ void VToolArc::RemoveReferens() { - const QSharedPointer arc = VAbstractTool::data.GeometricObject(id); - doc->DecrementReferens(arc->GetCenter().id()); + const auto arc = VAbstractTool::data.GeometricObject(id); + doc->DecrementReferens(arc->GetCenter().getIdTool()); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolarcwithlength.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolarcwithlength.cpp index 3dbfa983a..9f23961e9 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolarcwithlength.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolarcwithlength.cpp @@ -129,7 +129,7 @@ VToolArcWithLength *VToolArcWithLength::Create(const quint32 _id, const quint32 connect(scene, &VMainGraphicsScene::NewFactor, toolArc, &VToolArcWithLength::SetFactor); connect(scene, &VMainGraphicsScene::DisableItem, toolArc, &VToolArcWithLength::Disable); doc->AddTool(id, toolArc); - doc->IncrementReferens(center); + doc->IncrementReferens(c.getIdTool()); return toolArc; } return nullptr; @@ -269,8 +269,8 @@ void VToolArcWithLength::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) //--------------------------------------------------------------------------------------------------------------------- void VToolArcWithLength::RemoveReferens() { - const QSharedPointer arc = VAbstractTool::data.GeometricObject(id); - doc->DecrementReferens(arc->GetCenter().id()); + const auto arc = VAbstractTool::data.GeometricObject(id); + doc->DecrementReferens(arc->GetCenter().getIdTool()); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.cpp index 6af2977e2..6e487eb40 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.cpp @@ -201,8 +201,8 @@ VToolSpline* VToolSpline::Create(const quint32 _id, const quint32 &p1, const qui connect(scene, &VMainGraphicsScene::EnableToolMove, spl, &VToolSpline::EnableToolMove); connect(scene, &VMainGraphicsScene::CurveDetailsMode, spl, &VToolSpline::DetailsMode); doc->AddTool(id, spl); - doc->IncrementReferens(p1); - doc->IncrementReferens(p4); + doc->IncrementReferens(point1.getIdTool()); + doc->IncrementReferens(point4.getIdTool()); return spl; } return nullptr; @@ -287,9 +287,9 @@ void VToolSpline::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) */ void VToolSpline::RemoveReferens() { - const QSharedPointer spl = VAbstractTool::data.GeometricObject(id); - doc->DecrementReferens(spl->GetP1().id()); - doc->DecrementReferens(spl->GetP4().id()); + const auto spl = VAbstractTool::data.GeometricObject(id); + doc->DecrementReferens(spl->GetP1().getIdTool()); + doc->DecrementReferens(spl->GetP4().getIdTool()); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.cpp index 235fe3472..adef7f429 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.cpp @@ -130,7 +130,7 @@ VToolSplinePath* VToolSplinePath::Create(DialogTool *dialog, VMainGraphicsScene const QString color = dialogTool->GetColor(); for (qint32 i = 0; i < path->CountPoint(); ++i) { - doc->IncrementReferens((*path)[i].P().id()); + doc->IncrementReferens((*path)[i].P().getIdTool()); } VToolSplinePath* spl = Create(0, path, color, scene, doc, data, Document::FullParse, Source::FromGui); if (spl != nullptr) @@ -371,10 +371,10 @@ void VToolSplinePath::AddPathPoint(VAbstractPattern *doc, QDomElement &domElemen */ void VToolSplinePath::RemoveReferens() { - VSplinePath splPath = *VAbstractTool::data.GeometricObject(id); + const VSplinePath splPath = *VAbstractTool::data.GeometricObject(id); for (qint32 i = 0; i < splPath.Count(); ++i) { - doc->DecrementReferens(splPath.at(i).P().id()); + doc->DecrementReferens(splPath.at(i).P().getIdTool()); } } diff --git a/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.cpp b/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.cpp index abc78d74d..22fced903 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.cpp @@ -159,13 +159,13 @@ VToolTrueDarts *VToolTrueDarts::Create(quint32 _id, if (typeCreation == Source::FromGui) { id = data->getNextId();//Just reserve id for tool - p1id = data->AddGObject(new VPointF(fPoint1, point1Name, mx1, my1)); - p2id = data->AddGObject(new VPointF(fPoint2, point2Name, mx2, my2)); + p1id = data->AddGObject(new VPointF(fPoint1, point1Name, mx1, my1, id)); + p2id = data->AddGObject(new VPointF(fPoint2, point2Name, mx2, my2, id)); } else { - data->UpdateGObject(p1id, new VPointF(fPoint1, point1Name, mx1, my1)); - data->UpdateGObject(p2id, new VPointF(fPoint2, point2Name, mx2, my2)); + data->UpdateGObject(p1id, new VPointF(fPoint1, point1Name, mx1, my1, id)); + data->UpdateGObject(p2id, new VPointF(fPoint2, point2Name, mx2, my2, id)); if (parse != Document::FullParse) { doc->UpdateToolData(id, data); @@ -182,11 +182,11 @@ VToolTrueDarts *VToolTrueDarts::Create(quint32 _id, connect(scene, &VMainGraphicsScene::DisableItem, points, &VToolTrueDarts::Disable); connect(scene, &VMainGraphicsScene::EnableToolMove, points, &VToolTrueDarts::EnableToolMove); doc->AddTool(id, points); - doc->IncrementReferens(baseLineP1Id); - doc->IncrementReferens(baseLineP2Id); - doc->IncrementReferens(dartP1Id); - doc->IncrementReferens(dartP2Id); - doc->IncrementReferens(dartP3Id); + doc->IncrementReferens(baseLineP1->getIdTool()); + doc->IncrementReferens(baseLineP2->getIdTool()); + doc->IncrementReferens(dartP1->getIdTool()); + doc->IncrementReferens(dartP2->getIdTool()); + doc->IncrementReferens(dartP3->getIdTool()); return points; } return nullptr; @@ -305,11 +305,17 @@ void VToolTrueDarts::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) //--------------------------------------------------------------------------------------------------------------------- void VToolTrueDarts::RemoveReferens() { - doc->DecrementReferens(baseLineP1Id); - doc->DecrementReferens(baseLineP2Id); - doc->DecrementReferens(dartP1Id); - doc->DecrementReferens(dartP2Id); - doc->DecrementReferens(dartP3Id); + const auto baseLineP1 = VAbstractTool::data.GetGObject(baseLineP1Id); + const auto baseLineP2 = VAbstractTool::data.GetGObject(baseLineP2Id); + const auto dartP1 = VAbstractTool::data.GetGObject(dartP1Id); + const auto dartP2 = VAbstractTool::data.GetGObject(dartP2Id); + const auto dartP3 = VAbstractTool::data.GetGObject(dartP3Id); + + doc->DecrementReferens(baseLineP1->getIdTool()); + doc->DecrementReferens(baseLineP2->getIdTool()); + doc->DecrementReferens(dartP1->getIdTool()); + doc->DecrementReferens(dartP2->getIdTool()); + doc->DecrementReferens(dartP3->getIdTool()); VToolDoublePoint::RemoveReferens(); } diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcut.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcut.cpp index 96e04acb5..a5f263011 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcut.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcut.cpp @@ -123,7 +123,9 @@ void VToolCut::RefreshGeometry() */ void VToolCut::RemoveReferens() { - doc->DecrementReferens(curveCutId); + const auto curve = VAbstractTool::data.GetGObject(curveCutId); + + doc->DecrementReferens(curve->getIdTool()); } //--------------------------------------------------------------------------------------------------------------------- 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 fda07b74b..d77f17e50 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.cpp @@ -170,7 +170,7 @@ VToolCutArc* VToolCutArc::Create(const quint32 _id, const QString &pointName, QS doc->AddTool(id, point); doc->AddTool(arc1id, point); doc->AddTool(arc2id, point); - doc->IncrementReferens(arcId); + doc->IncrementReferens(arc->getIdTool()); return point; } return nullptr; 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 fcded45df..aa547566f 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.cpp @@ -178,7 +178,7 @@ VToolCutSpline* VToolCutSpline::Create(const quint32 _id, const QString &pointNa doc->AddTool(id, point); doc->AddTool(spl1id, point); doc->AddTool(spl2id, point); - doc->IncrementReferens(splineId); + doc->IncrementReferens(spl->getIdTool()); return point; } return nullptr; 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 3b659e0c4..8cdb34d6b 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.cpp @@ -222,7 +222,7 @@ VToolCutSplinePath* VToolCutSplinePath::Create(const quint32 _id, const QString doc->AddTool(id, point); doc->AddTool(splPath1id, point); doc->AddTool(splPath2id, point); - doc->IncrementReferens(splinePathId); + doc->IncrementReferens(splPath->getIdTool()); return point; } return nullptr; 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 04aadefcf..a85ff9e73 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.cpp @@ -94,7 +94,8 @@ void VToolAlongLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) */ void VToolAlongLine::RemoveReferens() { - doc->DecrementReferens(secondPointId); + const auto secondPoint = VAbstractTool::data.GetGObject(secondPointId); + doc->DecrementReferens(secondPoint->getIdTool()); VToolLinePoint::RemoveReferens(); } @@ -279,8 +280,8 @@ VToolAlongLine* VToolAlongLine::Create(const quint32 _id, const QString &pointNa connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolAlongLine::Disable); connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolAlongLine::EnableToolMove); doc->AddTool(id, point); - doc->IncrementReferens(firstPointId); - doc->IncrementReferens(secondPointId); + doc->IncrementReferens(firstPoint->getIdTool()); + doc->IncrementReferens(secondPoint->getIdTool()); return point; } return nullptr; 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 04522ac5c..ea29546fc 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolbisector.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolbisector.cpp @@ -205,9 +205,9 @@ VToolBisector* VToolBisector::Create(const quint32 _id, QString &formula, const connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolBisector::Disable); connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolBisector::EnableToolMove); doc->AddTool(id, point); - doc->IncrementReferens(firstPointId); - doc->IncrementReferens(secondPointId); - doc->IncrementReferens(thirdPointId); + doc->IncrementReferens(firstPoint->getIdTool()); + doc->IncrementReferens(secondPoint->getIdTool()); + doc->IncrementReferens(thirdPoint->getIdTool()); return point; } return nullptr; @@ -248,8 +248,11 @@ void VToolBisector::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) */ void VToolBisector::RemoveReferens() { - doc->DecrementReferens(firstPointId); - doc->DecrementReferens(thirdPointId); + const auto firstPoint = VAbstractTool::data.GetGObject(firstPointId); + const auto thirdPoint = VAbstractTool::data.GetGObject(thirdPointId); + + doc->DecrementReferens(firstPoint->getIdTool()); + doc->DecrementReferens(thirdPoint->getIdTool()); VToolLinePoint::RemoveReferens(); } 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 708f53cc4..7fd0239d1 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.cpp @@ -134,8 +134,8 @@ VToolCurveIntersectAxis *VToolCurveIntersectAxis::Create(const quint32 _id, cons connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolCurveIntersectAxis::Disable); connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolCurveIntersectAxis::EnableToolMove); doc->AddTool(id, point); - doc->IncrementReferens(basePointId); - doc->IncrementReferens(curveId); + doc->IncrementReferens(basePoint->getIdTool()); + doc->IncrementReferens(curve->getIdTool()); return point; } return nullptr; 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 55b6546ea..9ae71332a 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolendline.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolendline.cpp @@ -170,7 +170,7 @@ VToolEndLine* VToolEndLine::Create(const quint32 _id, const QString &pointName, connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolEndLine::Disable); connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolEndLine::EnableToolMove); doc->AddTool(id, point); - doc->IncrementReferens(basePointId); + doc->IncrementReferens(basePoint->getIdTool()); return point; } return nullptr; 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 4cddc1b2c..029215962 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.cpp @@ -162,9 +162,9 @@ VToolHeight* VToolHeight::Create(const quint32 _id, const QString &pointName, co connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolHeight::Disable); connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolHeight::EnableToolMove); doc->AddTool(id, point); - doc->IncrementReferens(basePointId); - doc->IncrementReferens(p1LineId); - doc->IncrementReferens(p2LineId); + doc->IncrementReferens(basePoint->getIdTool()); + doc->IncrementReferens(p1Line->getIdTool()); + doc->IncrementReferens(p2Line->getIdTool()); return point; } return nullptr; 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 983c748a9..67c9f72a0 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.cpp @@ -145,9 +145,9 @@ VToolLineIntersectAxis *VToolLineIntersectAxis::Create(const quint32 _id, const connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolLineIntersectAxis::Disable); connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolLineIntersectAxis::EnableToolMove); doc->AddTool(id, point); - doc->IncrementReferens(basePointId); - doc->IncrementReferens(firstPointId); - doc->IncrementReferens(secondPointId); + doc->IncrementReferens(basePoint->getIdTool()); + doc->IncrementReferens(firstPoint->getIdTool()); + doc->IncrementReferens(secondPoint->getIdTool()); return point; } return nullptr; diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollinepoint.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollinepoint.cpp index c612dc5f9..aa9ca24ab 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollinepoint.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollinepoint.cpp @@ -86,7 +86,8 @@ void VToolLinePoint::RefreshGeometry() */ void VToolLinePoint::RemoveReferens() { - doc->DecrementReferens(basePointId); + const auto basePoint = VAbstractTool::data.GetGObject(basePointId); + doc->DecrementReferens(basePoint->getIdTool()); } //--------------------------------------------------------------------------------------------------------------------- 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 63573b65f..55de6ab09 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolnormal.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolnormal.cpp @@ -165,8 +165,8 @@ VToolNormal* VToolNormal::Create(const quint32 _id, QString &formula, const quin connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolNormal::Disable); connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolNormal::EnableToolMove); doc->AddTool(id, point); - doc->IncrementReferens(firstPointId); - doc->IncrementReferens(secondPointId); + doc->IncrementReferens(firstPoint->getIdTool()); + doc->IncrementReferens(secondPoint->getIdTool()); return point; } return nullptr; @@ -226,7 +226,8 @@ void VToolNormal::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) */ void VToolNormal::RemoveReferens() { - doc->DecrementReferens(secondPointId); + const auto secondPoint = VAbstractTool::data.GetGObject(secondPointId); + doc->DecrementReferens(secondPoint->getIdTool()); VToolLinePoint::RemoveReferens(); } 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 984850531..14bd4d749 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.cpp @@ -209,9 +209,9 @@ VToolShoulderPoint* VToolShoulderPoint::Create(const quint32 _id, QString &formu connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolShoulderPoint::Disable); connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolShoulderPoint::EnableToolMove); doc->AddTool(id, point); - doc->IncrementReferens(p1Line); - doc->IncrementReferens(p2Line); - doc->IncrementReferens(pShoulder); + doc->IncrementReferens(firstPoint->getIdTool()); + doc->IncrementReferens(secondPoint->getIdTool()); + doc->IncrementReferens(shoulderPoint->getIdTool()); return point; } return nullptr; @@ -252,8 +252,11 @@ void VToolShoulderPoint::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) */ void VToolShoulderPoint::RemoveReferens() { - doc->DecrementReferens(p2Line); - doc->DecrementReferens(pShoulder); + const auto p2 = VAbstractTool::data.GetGObject(p2Line); + const auto pS = VAbstractTool::data.GetGObject(pShoulder); + + doc->DecrementReferens(p2->getIdTool()); + doc->DecrementReferens(pS->getIdTool()); VToolLinePoint::RemoveReferens(); } diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.cpp index af65be768..fff168ff4 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.cpp @@ -169,10 +169,10 @@ VToolLineIntersect* VToolLineIntersect::Create(const quint32 _id, const quint32 connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolLineIntersect::Disable); connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolLineIntersect::EnableToolMove); doc->AddTool(id, point); - doc->IncrementReferens(p1Line1Id); - doc->IncrementReferens(p2Line1Id); - doc->IncrementReferens(p1Line2Id); - doc->IncrementReferens(p2Line2Id); + doc->IncrementReferens(p1Line1->getIdTool()); + doc->IncrementReferens(p2Line1->getIdTool()); + doc->IncrementReferens(p1Line2->getIdTool()); + doc->IncrementReferens(p2Line2->getIdTool()); return point; } } @@ -214,10 +214,15 @@ void VToolLineIntersect::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) */ void VToolLineIntersect::RemoveReferens() { - doc->DecrementReferens(p1Line1); - doc->DecrementReferens(p2Line1); - doc->DecrementReferens(p1Line2); - doc->DecrementReferens(p2Line2); + const auto p1L1 = VAbstractTool::data.GetGObject(p1Line1); + const auto p2L1 = VAbstractTool::data.GetGObject(p2Line1); + const auto p1L2 = VAbstractTool::data.GetGObject(p1Line2); + const auto p2L2 = VAbstractTool::data.GetGObject(p2Line2); + + doc->DecrementReferens(p1L1->getIdTool()); + doc->DecrementReferens(p2L1->getIdTool()); + doc->DecrementReferens(p1L2->getIdTool()); + doc->DecrementReferens(p2L2->getIdTool()); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.cpp index 7b8250272..6e7b5c93b 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.cpp @@ -113,8 +113,8 @@ VToolPointFromArcAndTangent *VToolPointFromArcAndTangent::Create(const quint32 _ connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolPointFromArcAndTangent::Disable); connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolPointFromArcAndTangent::EnableToolMove); doc->AddTool(id, point); - doc->IncrementReferens(arcId); - doc->IncrementReferens(tangentPointId); + doc->IncrementReferens(arc.getIdTool()); + doc->IncrementReferens(tPoint.getIdTool()); return point; } return nullptr; @@ -260,8 +260,11 @@ void VToolPointFromArcAndTangent::ShowVisualization(bool show) //--------------------------------------------------------------------------------------------------------------------- void VToolPointFromArcAndTangent::RemoveReferens() { - doc->DecrementReferens(arcId); - doc->DecrementReferens(tangentPointId); + const auto arc = VAbstractTool::data.GetGObject(arcId); + const auto tP = VAbstractTool::data.GetGObject(tangentPointId); + + doc->DecrementReferens(arc->getIdTool()); + doc->DecrementReferens(tP->getIdTool()); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.cpp index 5f33471e2..4799ba0af 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.cpp @@ -123,8 +123,8 @@ VToolPointFromCircleAndTangent *VToolPointFromCircleAndTangent::Create(const qui connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolPointFromCircleAndTangent::Disable); connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolPointFromCircleAndTangent::EnableToolMove); doc->AddTool(id, point); - doc->IncrementReferens(circleCenterId); - doc->IncrementReferens(tangentPointId); + doc->IncrementReferens(cPoint.getIdTool()); + doc->IncrementReferens(tPoint.getIdTool()); return point; } return nullptr; @@ -244,8 +244,11 @@ void VToolPointFromCircleAndTangent::ShowVisualization(bool show) //--------------------------------------------------------------------------------------------------------------------- void VToolPointFromCircleAndTangent::RemoveReferens() { - doc->DecrementReferens(circleCenterId); - doc->DecrementReferens(tangentPointId); + const auto circleCenter = VAbstractTool::data.GetGObject(circleCenterId); + const auto tangentPoint = VAbstractTool::data.GetGObject(tangentPointId); + + doc->DecrementReferens(circleCenter->getIdTool()); + doc->DecrementReferens(tangentPoint->getIdTool()); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.cpp index c4153c436..05c0086e8 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.cpp @@ -225,9 +225,9 @@ VToolPointOfContact* VToolPointOfContact::Create(const quint32 _id, QString &rad connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolPointOfContact::Disable); connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolPointOfContact::EnableToolMove); doc->AddTool(id, point); - doc->IncrementReferens(center); - doc->IncrementReferens(firstPointId); - doc->IncrementReferens(secondPointId); + doc->IncrementReferens(centerP->getIdTool()); + doc->IncrementReferens(firstP->getIdTool()); + doc->IncrementReferens(secondP->getIdTool()); return point; } return nullptr; @@ -268,9 +268,13 @@ void VToolPointOfContact::contextMenuEvent(QGraphicsSceneContextMenuEvent *event */ void VToolPointOfContact::RemoveReferens() { - doc->DecrementReferens(center); - doc->DecrementReferens(firstPointId); - doc->DecrementReferens(secondPointId); + const auto c = VAbstractTool::data.GetGObject(center); + const auto firstPoint = VAbstractTool::data.GetGObject(firstPointId); + const auto secondPoint = VAbstractTool::data.GetGObject(secondPointId); + + doc->DecrementReferens(c->getIdTool()); + doc->DecrementReferens(firstPoint->getIdTool()); + doc->DecrementReferens(secondPoint->getIdTool()); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersection.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersection.cpp index 3350ecc8e..cb33d9f3f 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersection.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersection.cpp @@ -146,8 +146,8 @@ VToolPointOfIntersection *VToolPointOfIntersection::Create(const quint32 _id, co connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolPointOfIntersection::Disable); connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolPointOfIntersection::EnableToolMove); doc->AddTool(id, point); - doc->IncrementReferens(firstPointId); - doc->IncrementReferens(secondPointId); + doc->IncrementReferens(firstPoint->getIdTool()); + doc->IncrementReferens(secondPoint->getIdTool()); return point; } return nullptr; @@ -159,8 +159,11 @@ VToolPointOfIntersection *VToolPointOfIntersection::Create(const quint32 _id, co */ void VToolPointOfIntersection::RemoveReferens() { - doc->DecrementReferens(firstPointId); - doc->DecrementReferens(secondPointId); + const auto firstPoint = VAbstractTool::data.GetGObject(firstPointId); + const auto secondPoint = VAbstractTool::data.GetGObject(secondPointId); + + doc->DecrementReferens(firstPoint->getIdTool()); + doc->DecrementReferens(secondPoint->getIdTool()); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectionarcs.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectionarcs.cpp index e94124f50..b04c5b07f 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectionarcs.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectionarcs.cpp @@ -114,8 +114,8 @@ VToolPointOfIntersectionArcs *VToolPointOfIntersectionArcs::Create(const quint32 connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolPointOfIntersectionArcs::Disable); connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolPointOfIntersectionArcs::EnableToolMove); doc->AddTool(id, point); - doc->IncrementReferens(firstArcId); - doc->IncrementReferens(secondArcId); + doc->IncrementReferens(firstArc->getIdTool()); + doc->IncrementReferens(secondArc->getIdTool()); return point; } return nullptr; @@ -267,8 +267,11 @@ void VToolPointOfIntersectionArcs::ShowVisualization(bool show) //--------------------------------------------------------------------------------------------------------------------- void VToolPointOfIntersectionArcs::RemoveReferens() { - doc->DecrementReferens(firstArcId); - doc->DecrementReferens(secondArcId); + const auto firstArc = VAbstractTool::data.GetGObject(firstArcId); + const auto secondArc = VAbstractTool::data.GetGObject(secondArcId); + + doc->DecrementReferens(firstArc->getIdTool()); + doc->DecrementReferens(secondArc->getIdTool()); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.cpp index 950ee3fa1..107010fc6 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.cpp @@ -135,8 +135,8 @@ VToolPointOfIntersectionCircles *VToolPointOfIntersectionCircles::Create(const q connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolPointOfIntersectionCircles::Disable); connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolPointOfIntersectionCircles::EnableToolMove); doc->AddTool(id, point); - doc->IncrementReferens(firstCircleCenterId); - doc->IncrementReferens(secondCircleCenterId); + doc->IncrementReferens(c1Point.getIdTool()); + doc->IncrementReferens(c2Point.getIdTool()); return point; } return nullptr; @@ -280,8 +280,11 @@ void VToolPointOfIntersectionCircles::ShowVisualization(bool show) //--------------------------------------------------------------------------------------------------------------------- void VToolPointOfIntersectionCircles::RemoveReferens() { - doc->DecrementReferens(firstCircleCenterId); - doc->DecrementReferens(secondCircleCenterId); + const auto firstCircleCenter = VAbstractTool::data.GetGObject(firstCircleCenterId); + const auto secondCircleCenter = VAbstractTool::data.GetGObject(secondCircleCenterId); + + doc->DecrementReferens(firstCircleCenter->getIdTool()); + doc->DecrementReferens(secondCircleCenter->getIdTool()); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.cpp index c210f2265..dc5ae275a 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.cpp @@ -156,10 +156,10 @@ VToolTriangle* VToolTriangle::Create(const quint32 _id, const QString &pointName connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolTriangle::Disable); connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolTriangle::EnableToolMove); doc->AddTool(id, point); - doc->IncrementReferens(axisP1Id); - doc->IncrementReferens(axisP2Id); - doc->IncrementReferens(firstPointId); - doc->IncrementReferens(secondPointId); + doc->IncrementReferens(axisP1->getIdTool()); + doc->IncrementReferens(axisP2->getIdTool()); + doc->IncrementReferens(firstPoint->getIdTool()); + doc->IncrementReferens(secondPoint->getIdTool()); return point; } return nullptr; @@ -213,10 +213,15 @@ QPointF VToolTriangle::FindPoint(const QPointF &axisP1, const QPointF &axisP2, c */ void VToolTriangle::RemoveReferens() { - doc->DecrementReferens(axisP1Id); - doc->DecrementReferens(axisP2Id); - doc->DecrementReferens(firstPointId); - doc->DecrementReferens(secondPointId); + const auto axisP1 = VAbstractTool::data.GetGObject(axisP1Id); + const auto axisP2 = VAbstractTool::data.GetGObject(axisP2Id); + const auto firstPoint = VAbstractTool::data.GetGObject(firstPointId); + const auto secondPoint = VAbstractTool::data.GetGObject(secondPointId); + + doc->DecrementReferens(axisP1->getIdTool()); + doc->DecrementReferens(axisP2->getIdTool()); + doc->DecrementReferens(firstPoint->getIdTool()); + doc->DecrementReferens(secondPoint->getIdTool()); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/tools/drawTools/vtoolline.cpp b/src/libs/vtools/tools/drawTools/vtoolline.cpp index 59502a302..42c586268 100644 --- a/src/libs/vtools/tools/drawTools/vtoolline.cpp +++ b/src/libs/vtools/tools/drawTools/vtoolline.cpp @@ -155,8 +155,12 @@ VToolLine * VToolLine::Create(const quint32 &_id, const quint32 &firstPoint, con connect(scene, &VMainGraphicsScene::NewFactor, line, &VToolLine::SetFactor); connect(scene, &VMainGraphicsScene::DisableItem, line, &VToolLine::Disable); doc->AddTool(id, line); - doc->IncrementReferens(firstPoint); - doc->IncrementReferens(secondPoint); + + const QSharedPointer first = data->GeometricObject(firstPoint); + const QSharedPointer second = data->GeometricObject(secondPoint); + + doc->IncrementReferens(first->getIdTool()); + doc->IncrementReferens(second->getIdTool()); return line; } return nullptr; @@ -307,8 +311,11 @@ void VToolLine::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) */ void VToolLine::RemoveReferens() { - doc->DecrementReferens(firstPoint); - doc->DecrementReferens(secondPoint); + const auto p1 = VAbstractTool::data.GetGObject(firstPoint); + const auto p2 = VAbstractTool::data.GetGObject(secondPoint); + + doc->DecrementReferens(p1->getIdTool()); + doc->DecrementReferens(p2->getIdTool()); } //---------------------------------------------------------------------------------------------------------------------