Salome HOME
External edge to be removed with all references. The same mechanizm should be applied...
[modules/shaper.git] / src / PartSet / PartSet_WidgetShapeSelector.cpp
index 578e1cdf9b7a7e7bc38d7919e96ce9d038635bd2..7352c1344cb42c50241b3fea9b8a860804f78c07 100644 (file)
 #include <ModelAPI_Session.h>
 #include <ModelAPI_Validator.h>
 
+#include <ModuleBase_Definitions.h>
+
 #include <PartSet_Tools.h>
 #include <SketchPlugin_Feature.h>
 
-#include <ModuleBase_IWorkshop.h>
-#include <XGUI_ModuleConnector.h>
 #include <XGUI_Workshop.h>
-#include <XGUI_Displayer.h>
+
+PartSet_WidgetShapeSelector::PartSet_WidgetShapeSelector(QWidget* theParent,
+                                                         ModuleBase_IWorkshop* theWorkshop,
+                                                         const Config_WidgetAPI* theData,
+                                                         const std::string& theParentId)
+: ModuleBase_WidgetShapeSelector(theParent, theWorkshop, theData, theParentId)
+{
+}
 
 bool PartSet_WidgetShapeSelector::setObject(ObjectPtr theSelectedObject, GeomShapePtr theShape)
 {
@@ -76,30 +83,11 @@ bool PartSet_WidgetShapeSelector::setObject(ObjectPtr theSelectedObject, GeomSha
   return ModuleBase_WidgetShapeSelector::setObject(aSelectedObject, aShape);
 }
 
-//********************************************************************
-void PartSet_WidgetShapeSelector::storeAttributeValue()
-{
-  /// this is a temporary code, will be removed when master is merged to this branch
-  /*XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myWorkshop);
-  XGUI_Workshop* aWorkshop = aConnector->workshop();
-  aWorkshop->displayer()->enableUpdateViewer(false);
-  */
-  ModuleBase_WidgetShapeSelector::storeAttributeValue();
-}
-
 //********************************************************************
 void PartSet_WidgetShapeSelector::restoreAttributeValue(const bool theValid)
 {
   ModuleBase_WidgetShapeSelector::restoreAttributeValue(theValid);
-  /// this is a temporary code, will be removed when master is merged to this branch
-  /// after merge, the external edge should be removed always, without flag checking
-  if (!theValid)
-    removeExternal();
-  /*
-  XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myWorkshop);
-  XGUI_Workshop* aWorkshop = aConnector->workshop();
-  aWorkshop->displayer()->enableUpdateViewer(false);//->erase(myExternalObject);
-  aWorkshop->displayer()->enableUpdateViewer(true);*/
+  removeExternal();
 }
 
 //********************************************************************
@@ -121,7 +109,12 @@ void PartSet_WidgetShapeSelector::removeExternal()
     DocumentPtr aDoc = myExternalObject->document();
     FeaturePtr aFeature = ModelAPI_Feature::feature(myExternalObject);
     if (aFeature.get() != NULL) {
-      aDoc->removeFeature(aFeature);
+      QObjectPtrList anObjects;
+      anObjects.append(aFeature);
+      // the external feature should be removed with all references, sketch feature should be ignored
+      std::set<FeaturePtr> anIgnoredFeatures;
+      anIgnoredFeatures.insert(sketch());
+      XGUI_Workshop::deleteFeatures(anObjects, anIgnoredFeatures);
     }
     myExternalObject = NULL;
   }