Salome HOME
Issue #2071 Fatal error when Create box
[modules/shaper.git] / src / PartSet / PartSet_SketcherReentrantMgr.cpp
index 45547cb74dce9290bb764f571bfe10940f9588b7..488f5660a99f9361880f0c25d393bf3b9159bf90 100644 (file)
@@ -25,7 +25,7 @@
 
 #include <SketchPlugin_Feature.h>
 #include <SketchPlugin_Line.h>
-#include <SketchPlugin_Arc.h>
+#include <SketchPlugin_MacroArc.h>
 #include <SketchPlugin_MacroCircle.h>
 #include <SketchPlugin_Point.h>
 
@@ -155,7 +155,7 @@ bool PartSet_SketcherReentrantMgr::processMouseMoved(ModuleBase_IViewWindow* the
         isLineFeature = anActiveWidget->attributeID() == anAttributeOnStart;
       }
       else if (isTangentArc(aFOperation, module()->sketchMgr()->activeSketch())) {
-        anAttributeOnStart = SketchPlugin_Arc::TANGENT_POINT_ID();
+        anAttributeOnStart = SketchPlugin_MacroArc::TANGENT_POINT_ID();
         isArcFeature = anActiveWidget->attributeID() == anAttributeOnStart;
       }
       bool aCanBeActivatedByMove = isLineFeature || isArcFeature;
@@ -389,9 +389,17 @@ bool PartSet_SketcherReentrantMgr::canBeCommittedByPreselection()
   return !isActiveMgr() || myRestartingMode == RM_None;
 }
 
-bool PartSet_SketcherReentrantMgr::isInternalEditStarted() const
+void PartSet_SketcherReentrantMgr::appendCreatedObjects(const std::set<ObjectPtr>& theObjects)
 {
-  return myIsInternalEditOperation;
+  if (!myIsFlagsBlocked) // we need to collect objects only when launch operation is called
+    return;
+
+  for (std::set<ObjectPtr>::const_iterator anIt = theObjects.begin();
+       anIt != theObjects.end(); ++anIt) {
+    FeaturePtr aFeature = ModelAPI_Feature::feature(*anIt);
+    if (myCreatedFeatures.find(aFeature) != myCreatedFeatures.end())
+      myCreatedFeatures.insert(aFeature);
+  }
 }
 
 bool PartSet_SketcherReentrantMgr::isActiveMgr() const
@@ -618,6 +626,7 @@ void PartSet_SketcherReentrantMgr::resetFlags()
     myIsInternalEditOperation = false;
     updateAcceptAllAction();
     myRestartingMode = RM_None;
+    myCreatedFeatures.clear();
   }
 }
 
@@ -656,32 +665,32 @@ bool PartSet_SketcherReentrantMgr::copyReetntrantAttributes(const FeaturePtr& th
     //ModuleBase_Tools::flushUpdated(theNewFeature);
     aChanged = true;
   }
-  else if (aFeatureKind == SketchPlugin_Arc::ID()) {
+  else if (aFeatureKind == SketchPlugin_MacroArc::ID()) {
     // set arc type
-    std::string aTypeAttributeId = SketchPlugin_Arc::ARC_TYPE();
+    std::string aTypeAttributeId = SketchPlugin_MacroArc::ARC_TYPE();
     AttributeStringPtr aSourceFeatureTypeAttr = theSourceFeature->data()->string(aTypeAttributeId);
     AttributeStringPtr aNewFeatureTypeAttr = theNewFeature->data()->string(aTypeAttributeId);
     aNewFeatureTypeAttr->setValue(aSourceFeatureTypeAttr->value());
 
-    // if the arc is tangent, set coincidence to end point of the previous arc
-    std::string anArcType = aSourceFeatureTypeAttr->value();
-    if (anArcType == SketchPlugin_Arc::ARC_TYPE_TANGENT()) {
-      // get the last point of the previuos arc feature(geom point 2d)
-      std::shared_ptr<ModelAPI_Data> aSData = theSourceFeature->data();
-      std::shared_ptr<GeomDataAPI_Point2D> aSPointAttr =
-                                      std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
-                                      aSData->attribute(SketchPlugin_Arc::END_ID()));
-      // get point attribute on the current feature
-      AttributeRefAttrPtr aTangentPointAttr = theNewFeature->data()->refattr(
-                                                    SketchPlugin_Arc::TANGENT_POINT_ID());
-      aTangentPointAttr->setAttr(aSPointAttr);
-
-      std::shared_ptr<GeomDataAPI_Point2D> aNPointAttr =
-                                    std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
-                                    theNewFeature->data()->attribute(SketchPlugin_Arc::END_ID()));
-      aNPointAttr->setValue(aSPointAttr->x(), aSPointAttr->y());
-
-    }
+    //// if the arc is tangent, set coincidence to end point of the previous arc
+    //std::string anArcType = aSourceFeatureTypeAttr->value();
+    //if (anArcType == SketchPlugin_Arc::ARC_TYPE_TANGENT()) {
+    //  // get the last point of the previuos arc feature(geom point 2d)
+    //  std::shared_ptr<ModelAPI_Data> aSData = theSourceFeature->data();
+    //  std::shared_ptr<GeomDataAPI_Point2D> aSPointAttr =
+    //                                  std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+    //                                  aSData->attribute(SketchPlugin_Arc::END_ID()));
+    //  // get point attribute on the current feature
+    //  AttributeRefAttrPtr aTangentPointAttr = theNewFeature->data()->refattr(
+    //                                                SketchPlugin_Arc::TANGENT_POINT_ID());
+    //  aTangentPointAttr->setAttr(aSPointAttr);
+
+    //  std::shared_ptr<GeomDataAPI_Point2D> aNPointAttr =
+    //                                std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+    //                                theNewFeature->data()->attribute(SketchPlugin_Arc::END_ID()));
+    //  aNPointAttr->setValue(aSPointAttr->x(), aSPointAttr->y());
+
+    //}
     //ModuleBase_Tools::flushUpdated(theNewFeature);
     aChanged = true;
   }
@@ -696,10 +705,10 @@ bool PartSet_SketcherReentrantMgr::isTangentArc(ModuleBase_Operation* theOperati
                                                                         (theOperation);
   if (aFOperation && module()->sketchMgr()->isNestedSketchOperation(aFOperation)) {
     FeaturePtr aFeature = aFOperation->feature();
-    if (aFeature.get() && aFeature->getKind() == SketchPlugin_Arc::ID()) {
-      AttributeStringPtr aTypeAttr = aFeature->data()->string(SketchPlugin_Arc::ARC_TYPE());
+    if (aFeature.get() && aFeature->getKind() == SketchPlugin_MacroArc::ID()) {
+      AttributeStringPtr aTypeAttr = aFeature->data()->string(SketchPlugin_MacroArc::ARC_TYPE());
       std::string anArcType = aTypeAttr.get() ? aTypeAttr->value() : "";
-      aTangentArc = anArcType == SketchPlugin_Arc::ARC_TYPE_TANGENT();
+      aTangentArc = anArcType == SketchPlugin_MacroArc::ARC_TYPE_BY_TANGENT_EDGE();
     }
   }
   return aTangentArc;