]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Single delete is active now
authormpv <mikhail.ponikarov@opencascade.com>
Fri, 19 Sep 2014 13:28:38 +0000 (17:28 +0400)
committermpv <mikhail.ponikarov@opencascade.com>
Fri, 19 Sep 2014 13:28:38 +0000 (17:28 +0400)
src/SketchPlugin/SketchPlugin_Sketch.cpp
src/SketchPlugin/SketchPlugin_Sketch.h
src/SketchSolver/SketchSolver_ConstraintGroup.cpp
src/XGUI/XGUI_ContextMenuMgr.cpp

index fdf230c58769d026c21e81f79b3e94572be3313e..256ba9d5e5057573512dfde8770fe3bb6569fac1 100644 (file)
@@ -167,3 +167,17 @@ AISObjectPtr SketchPlugin_Sketch::getAISObject(AISObjectPtr thePrevious)
   }
   return AISObjectPtr();
 }
+
+void SketchPlugin_Sketch::erase()
+{
+  boost::shared_ptr<ModelAPI_AttributeRefList> aRefList = boost::dynamic_pointer_cast<
+      ModelAPI_AttributeRefList>(data()->attribute(SketchPlugin_Sketch::FEATURES_ID()));
+  std::list<ObjectPtr> aFeatures = aRefList->list();
+  std::list<ObjectPtr>::const_iterator anIt = aFeatures.begin();
+  for (; anIt != aFeatures.end(); anIt++) {
+    FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(*anIt);
+    if (aFeature)
+      document()->removeFeature(aFeature);
+  }
+  SketchPlugin_Feature::erase();
+}
index 806025dd7c608c0465096cb55238141be762c9bb..07f8ae269ec8e34eee0af6f9a4559b15e9c61d7d 100644 (file)
@@ -115,6 +115,9 @@ class SketchPlugin_Sketch : public SketchPlugin_Feature, public GeomAPI_IPresent
 
   virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
 
+  /// removes also all sub-sketch elements
+  SKETCHPLUGIN_EXPORT virtual void erase();
+
  protected:
   /// Creates a plane and append it to the list
   /// \param theX the X normal value
index 81a812ca5b619950684d85b871356739ffaaeeca..bd70204c7cc386a41f59a36b979e24a89c4a6221 100644 (file)
@@ -817,7 +817,7 @@ bool SketchSolver_ConstraintGroup::updateGroup()
 
     std::set<boost::shared_ptr<SketchPlugin_Constraint> >::iterator aCIter = anExtraCopy.begin();
     for (; aCIter != anExtraCopy.end(); aCIter++)
-      if ((*aCIter)->data()->isValid())
+      if ((*aCIter)->data() && (*aCIter)->data()->isValid())
         changeConstraint(*aCIter);
   }
 
index ec698bc5246d8eb6edc6d1c0954bbf6c06ae3e01..5f69add11a41e395d1a382899d325b2e9b5a8013 100644 (file)
@@ -108,18 +108,30 @@ QMenu* XGUI_ContextMenuMgr::objectBrowserMenu() const
   if (aSelected > 0) {
     SessionPtr aMgr = ModelAPI_Session::get();
     XGUI_Displayer* aDisplayer = myWorkshop->displayer();
+    bool hasResult = false;
+    bool hasFeature = false;
+    foreach(ObjectPtr aObj, aObjects)
+    {
+      FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(aObj);
+      ResultPtr aResult = boost::dynamic_pointer_cast<ModelAPI_Result>(aObj);
+      if (aResult)
+        hasResult = true;
+      if (aFeature)
+        hasFeature = true;
+      if (hasFeature && hasResult)
+        break;
+    }
     //Process Feature
     if (aSelected == 1) {
       ObjectPtr aObject = aObjects.first();
       if (aObject) {
         ResultPartPtr aPart = boost::dynamic_pointer_cast<ModelAPI_ResultPart>(aObject);
-        FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(aObject);
         if (aPart) {
           if (aMgr->activeDocument() == aPart->partDoc())
             aMenu->addAction(action("DEACTIVATE_PART_CMD"));
           else
             aMenu->addAction(action("ACTIVATE_PART_CMD"));
-        } else if (aFeature) {
+        } else if (hasFeature) {
           aMenu->addAction(action("EDIT_CMD"));
         } else {
           if (aDisplayer->isVisible(aObject))
@@ -133,28 +145,15 @@ QMenu* XGUI_ContextMenuMgr::objectBrowserMenu() const
         if (aMgr->activeDocument() != aMgr->moduleDocument())
           aMenu->addAction(action("ACTIVATE_PART_CMD"));
       }
-    } else if (aSelected >= 1) {
-      bool hasResult = false;
-      bool hasFeature = false;
-      foreach(ObjectPtr aObj, aObjects)
-      {
-        FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(aObj);
-        ResultPtr aResult = boost::dynamic_pointer_cast<ModelAPI_Result>(aObj);
-        if (aResult)
-          hasResult = true;
-        if (aFeature)
-          hasFeature = true;
-        if (hasFeature && hasResult)
-          break;
-      }
+    } else {
       if (hasResult) {
         aMenu->addAction(action("SHOW_CMD"));
         aMenu->addAction(action("HIDE_CMD"));
         aMenu->addAction(action("SHOW_ONLY_CMD"));
       }
-      if (hasFeature)
-        aMenu->addAction(action("DELETE_CMD"));
     }
+    if (hasFeature)
+      aMenu->addAction(action("DELETE_CMD"));
   }
   aMenu->addActions(myWorkshop->objectBrowser()->actions());
   if (aMenu->actions().size() > 0) {