Salome HOME
Fix for synchronization of selection in object Browser and multi-selector (Example...
authorvsv <vsv@opencascade.com>
Tue, 28 Aug 2018 11:27:23 +0000 (14:27 +0300)
committervsv <vsv@opencascade.com>
Tue, 28 Aug 2018 11:27:23 +0000 (14:27 +0300)
src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp

index c3ced396b3766843a11050b83f80219608c2575c..f5f69327487492ca54bf8f83885df36840df36de 100755 (executable)
@@ -222,7 +222,7 @@ bool ModuleBase_WidgetMultiSelector::storeValueCustom()
   std::string aType = anAttribute->attributeType();
   if (aType == ModelAPI_AttributeSelectionList::typeId()) {
     AttributeSelectionListPtr aSelectionListAttr = myFeature->data()->selectionList(attributeID());
-
+    int aa = aSelectionListAttr->size();
     std::string aMode = myTypeCtrl->textValue().toStdString();
     if (myTypeCtrl->isVisible() && myIsFirst && (!myDefMode.empty()))
       aMode = myDefMode;
@@ -787,7 +787,7 @@ void ModuleBase_WidgetMultiSelector::convertIndicesToViewerSelection(std::set<in
       if (!theAttributeIds.empty() && theAttributeIds.find(i) == theAttributeIds.end())
         continue;
       AttributeSelectionPtr anAttr = aSelectionListAttr->value(i);
-      ResultPtr anObject = anAttr->context();
+      ObjectPtr anObject = anAttr->contextObject();
       if (anObject.get())
         theValues.append(std::shared_ptr<ModuleBase_ViewerPrs>(
                new ModuleBase_ViewerPrs(anObject, anAttr->value(), NULL)));
@@ -837,18 +837,23 @@ bool ModuleBase_WidgetMultiSelector::removeUnusedAttributeObjects
   std::string aType = anAttribute->attributeType();
   std::set<GeomShapePtr> aShapes;
   std::set<int> anIndicesToBeRemoved;
+  FeaturePtr aFeature;
   if (aType == ModelAPI_AttributeSelectionList::typeId()) {
     // iteration through data model to find not selected elements to remove them
     AttributeSelectionListPtr aSelectionListAttr = aData->selectionList(attributeID());
     for (int i = 0; i < aSelectionListAttr->size(); i++) {
       AttributeSelectionPtr anAttr = aSelectionListAttr->value(i);
-      bool aFound = findInSelection(
-        anAttr->contextObject(), anAttr->value(), aGeomSelection, myWorkshop);
-      if (!aFound)
-        anIndicesToBeRemoved.insert(i);
+      //aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(anAttr->contextObject());
+      //if (!aFeature.get()) { // Feature can not be found as geometry selection
+        bool aFound = findInSelection(
+          anAttr->contextObject(), anAttr->value(), aGeomSelection, myWorkshop);
+        if (!aFound)
+          anIndicesToBeRemoved.insert(i);
+//      }
     }
     isDone = anIndicesToBeRemoved.size() > 0;
-    aSelectionListAttr->remove(anIndicesToBeRemoved);
+    if (isDone)
+      aSelectionListAttr->remove(anIndicesToBeRemoved);
   }
   else if (aType == ModelAPI_AttributeRefList::typeId()) {
     AttributeRefListPtr aRefListAttr = aData->reflist(attributeID());