From 9cbde183bbdb90bb7986be1a32bee58bc232efe0 Mon Sep 17 00:00:00 2001 From: nds Date: Wed, 24 Jan 2018 07:09:34 +0300 Subject: [PATCH] Issue #2420 Invalid sketch after creation second circle (reentrant operation) --- src/PartSet/PartSet_ExternalObjectsMgr.h | 4 ++++ src/PartSet/PartSet_SketcherReentrantMgr.cpp | 14 ++++++++++++++ src/PartSet/PartSet_WidgetPoint2d.h | 4 ++++ 3 files changed, 22 insertions(+) diff --git a/src/PartSet/PartSet_ExternalObjectsMgr.h b/src/PartSet/PartSet_ExternalObjectsMgr.h index 59d014158..a2253c1e7 100755 --- a/src/PartSet/PartSet_ExternalObjectsMgr.h +++ b/src/PartSet/PartSet_ExternalObjectsMgr.h @@ -83,6 +83,10 @@ class PARTSET_EXPORT PartSet_ExternalObjectsMgr const CompositeFeaturePtr& theSketch, const bool theTemporary); + /// Returns created external object or NULL + /// \return an object instance + ObjectPtr getExternalObjectValidated() const { return myExternalObjectValidated; } + // Removes the external presentation from the model /// \param theSketch a current sketch /// \param theFeature a current feature diff --git a/src/PartSet/PartSet_SketcherReentrantMgr.cpp b/src/PartSet/PartSet_SketcherReentrantMgr.cpp index b0d19549b..6fbeaa5d1 100644 --- a/src/PartSet/PartSet_SketcherReentrantMgr.cpp +++ b/src/PartSet/PartSet_SketcherReentrantMgr.cpp @@ -19,6 +19,7 @@ // #include "PartSet_SketcherReentrantMgr.h" +#include "PartSet_ExternalObjectsMgr.h" #include "PartSet_Module.h" #include "PartSet_SketcherMgr.h" #include "PartSet_WidgetPoint2d.h" @@ -254,6 +255,7 @@ bool PartSet_SketcherReentrantMgr::processMouseReleased(ModuleBase_IViewWindow* myClickedSketchPoint = PartSet_Tools::getPnt2d(theEvent, theWindow, module()->sketchMgr()->activeSketch()); + FeaturePtr anExternalCreatedFeature; if (!aPreSelected.empty()) { ModuleBase_ViewerPrsPtr aValue = aPreSelected.first(); module()->getGeomSelection(aValue, mySelectedObject, mySelectedAttribute); @@ -262,10 +264,22 @@ bool PartSet_SketcherReentrantMgr::processMouseReleased(ModuleBase_IViewWindow* if (aPointWidget) { GeomShapePtr aShape; aPointWidget->getGeomSelection_(aValue, mySelectedObject, aShape); + ObjectPtr anExternalObject = aPointWidget->getExternalObjectMgr()->getExternalObjectValidated(); + // if external object has been created before staring new operation and is used as a parameter, + // it should be removed after the operation is restarted. (Circle feature, Projection) + if (anExternalObject.get()) + anExternalCreatedFeature = ModelAPI_Feature::feature(anExternalObject); } } restartOperation(); + // remove created external feature + if (anExternalCreatedFeature.get()) { + QObjectPtrList anObjects; + anObjects.append(anExternalCreatedFeature); + workshop()->deleteFeatures(anObjects); + } + myClickedSketchPoint = std::shared_ptr(); mySelectedObject = ObjectPtr(); mySelectedAttribute = AttributePtr(); diff --git a/src/PartSet/PartSet_WidgetPoint2d.h b/src/PartSet/PartSet_WidgetPoint2d.h index aa4fbc477..eddd587d7 100755 --- a/src/PartSet/PartSet_WidgetPoint2d.h +++ b/src/PartSet/PartSet_WidgetPoint2d.h @@ -159,6 +159,10 @@ Q_OBJECT std::shared_ptr& theObject, std::shared_ptr& theShape); + /// Return reference to external objects manager + /// \return manager instance + PartSet_ExternalObjectsMgr* getExternalObjectMgr() const { return myExternalObjectMgr; } + signals: /// Signal about selection of an existing vertex from an object void vertexSelected(); -- 2.39.2