]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Added ability to deselect objects on edit in Boolean operation and reselect them...
authormpv <mpv@opencascade.com>
Wed, 1 Jul 2015 08:06:32 +0000 (11:06 +0300)
committermpv <mpv@opencascade.com>
Wed, 1 Jul 2015 08:06:32 +0000 (11:06 +0300)
src/Model/Model_AttributeSelectionList.cpp
src/Model/Model_Data.cpp
src/Model/Model_Data.h
src/Model/Model_Objects.cpp

index 3b67df9eb0a9063e23a7874fde696432fdaa9857..ae079d7a1673e8158816beeb0416511202124aae 100644 (file)
@@ -96,7 +96,15 @@ void Model_AttributeSelectionList::clear()
     mySize->Set(0);
     TDF_ChildIterator aSubIter(mySize->Label());
     for(; aSubIter.More(); aSubIter.Next()) {
-      aSubIter.Value().ForgetAllAttributes(Standard_True);
+      TDF_Label aLab = aSubIter.Value();
+      std::shared_ptr<Model_AttributeSelection> aNewAttr = 
+        std::shared_ptr<Model_AttributeSelection>(new Model_AttributeSelection(aLab));
+      if (owner()) {
+        aNewAttr->setObject(owner());
+      }
+      REMOVE_BACK_REF(aNewAttr->context());
+
+      aLab.ForgetAllAttributes(Standard_True);
     }
     owner()->data()->sendAttributeUpdated(this);
   }
index 4546128eb5625815766cddcb2e1d22f60a302f07..ae09db9b06f8fbb9155e3007648aff42fc3a4d9d 100644 (file)
@@ -321,6 +321,31 @@ void Model_Data::removeBackReference(FeaturePtr theFeature, std::string theAttrI
     return;
 
   myRefsToMe.erase(anAttribute);
+
+  // remove concealment immideately: on deselection it must be posible to reselect in GUI the same
+  if (ModelAPI_Session::get()->validators()->isConcealed(theFeature->getKind(), theAttrID)) {
+    std::set<AttributePtr>::iterator aRefsIter = myRefsToMe.begin();
+    for(; aRefsIter != myRefsToMe.end(); aRefsIter++) {
+      if (aRefsIter->get()) {
+        FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>((*aRefsIter)->owner());
+        if (aFeature.get()) {
+          if (ModelAPI_Session::get()->validators()->isConcealed(
+                aFeature->getKind(), (*aRefsIter)->id())) {
+            return; // it is still concealed, nothing to do
+          }
+        }
+      }
+    }
+    // thus, no concealment references anymore => make not-concealed
+    std::shared_ptr<ModelAPI_Result> aRes = 
+      std::dynamic_pointer_cast<ModelAPI_Result>(myObject);
+    if (aRes.get()) {
+      aRes->setIsConcealed(false);
+      static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_CREATED);
+      ModelAPI_EventCreator::get()->sendUpdated(aRes, anEvent);
+      Events_Loop::loop()->flush(anEvent);
+    }
+  }
 }
 
 void Model_Data::addBackReference(FeaturePtr theFeature, std::string theAttrID, 
index fba3cd500f1d3b3a0ac6c3f8d8026783a7cf4bfb..9b46312b80babac57da023c2bce956cf2f762d91 100644 (file)
@@ -69,6 +69,7 @@ class Model_Data : public ModelAPI_Data
   friend class Model_AttributeRefAttr;
   friend class Model_AttributeRefList;
   friend class Model_AttributeSelection;
+  friend class Model_AttributeSelectionList;
 
  public:
   /// The simplest constructor. "setLabel" must be called just after to initialize correctly.
index 5d27392b94eee04a3880e2398d97907f43a33870..1361a931a49baca81ba39b0b83ee3ac10d237a62 100644 (file)
@@ -339,10 +339,9 @@ ObjectPtr Model_Objects::object(TDF_Label theLabel)
 
 ObjectPtr Model_Objects::object(const std::string& theGroupID, const int theIndex)
 {
-  createHistory(theGroupID);
-  //TODO: mpv stabilization hotfix
-  if (myHistory[theGroupID].size() <= (const unsigned int)theIndex)
+  if (theIndex == -1)
     return ObjectPtr();
+  createHistory(theGroupID);
   return myHistory[theGroupID][theIndex];
 }