]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #2420 Invalid sketch after creation second circle (reentrant operation)
authornds <nds@opencascade.com>
Wed, 24 Jan 2018 04:09:34 +0000 (07:09 +0300)
committernds <nds@opencascade.com>
Wed, 24 Jan 2018 04:09:34 +0000 (07:09 +0300)
src/PartSet/PartSet_ExternalObjectsMgr.h
src/PartSet/PartSet_SketcherReentrantMgr.cpp
src/PartSet/PartSet_WidgetPoint2d.h

index 59d0141584376fcebb1bc2e3132782859e4473ef..a2253c1e75d1a772ccf8b60d0847b9aa46299811 100755 (executable)
@@ -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
index b0d19549b987d7aab87e7248646d2a6fd2642ef9..6fbeaa5d187c04b5aed49d0883851450036749d8 100644 (file)
@@ -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<GeomAPI_Pnt2d>();
       mySelectedObject = ObjectPtr();
       mySelectedAttribute = AttributePtr();
index aa4fbc47752dcc0e7ac195bdbba69ff6d2f7cbc4..eddd587d797babc5ac27fcb8d57d89500be40290 100755 (executable)
@@ -159,6 +159,10 @@ Q_OBJECT
                          std::shared_ptr<ModelAPI_Object>& theObject,
                          std::shared_ptr<GeomAPI_Shape>& 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();