Salome HOME
Issue #640 It is impossible to remove dimension
[modules/shaper.git] / src / Model / Model_Objects.cpp
index deadfd2a3c8b686c80147f0f0517e5de4135251f..1b8e3253b9eda85fc235449e940f623707305434 100644 (file)
@@ -340,6 +340,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() <= theIndex)
+    return ObjectPtr();
   return myHistory[theGroupID][theIndex];
 }
 
@@ -473,7 +476,7 @@ void Model_Objects::synchronizeFeatures(
   static Events_ID aRedispEvent = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
   static Events_ID aDeleteEvent = Events_Loop::eventByName(EVENT_OBJECT_DELETED);
   static Events_ID aToHideEvent = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
-  aLoop->activateFlushes(false);
+  bool isActive = aLoop->activateFlushes(false);
 
   // update all objects by checking are they on labels or not
   std::set<FeaturePtr> aNewFeatures, aKeptFeatures;
@@ -556,7 +559,7 @@ void Model_Objects::synchronizeFeatures(
   }
 
   anOwner->executeFeatures() = false;
-  aLoop->activateFlushes(true);
+  aLoop->activateFlushes(isActive);
 
   if (theFlush) {
     aLoop->flush(aCreateEvent);
@@ -895,6 +898,20 @@ FeaturePtr Model_Objects::lastFeature()
   return FeaturePtr(); // no features at all
 }
 
+std::list<std::shared_ptr<ModelAPI_Feature> > Model_Objects::allFeatures()
+{
+  std::list<std::shared_ptr<ModelAPI_Feature> > aResult;
+  Handle(TDataStd_ReferenceArray) aRefs;
+  if (featuresLabel().FindAttribute(TDataStd_ReferenceArray::GetID(), aRefs)) {
+    for(int a = aRefs->Lower(); a <= aRefs->Upper(); a++) {
+      FeaturePtr aFeature = feature(aRefs->Value(a));
+      if (aFeature.get())
+        aResult.push_back(aFeature);
+    }
+  }
+  return aResult;
+}
+
 Standard_Integer HashCode(const TDF_Label& theLab, const Standard_Integer theUpper)
 {
   return TDF_LabelMapHasher::HashCode(theLab, theUpper);