]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Send "redisplay" signal when compsolid result become alone or with sub-elements
authormpv <mpv@opencascade.com>
Fri, 21 Aug 2015 07:56:56 +0000 (10:56 +0300)
committermpv <mpv@opencascade.com>
Fri, 21 Aug 2015 07:56:56 +0000 (10:56 +0300)
src/Model/Model_AttributeRefList.cpp
src/Model/Model_ResultCompSolid.cpp

index b296125212dd52807c1254ab1da6a3bf801dae57..bb9fa83e26bd5ba038f77a9c3a1bd867773a811c 100644 (file)
@@ -75,7 +75,7 @@ int Model_AttributeRefList::size(const bool theWithEmpty) const
 
 bool Model_AttributeRefList::isInitialized()
 {
-  if (size() == 0) { // empty list is not initialized list: sketch will be not valid after add/undo
+  if (size(false) == 0) { // empty list is not initialized list: sketch will be not valid after add/undo
     return false;
   }
   return ModelAPI_AttributeRefList::isInitialized();
@@ -128,8 +128,12 @@ ObjectPtr Model_AttributeRefList::object(const int theIndex, const bool theWithE
     for (TDF_ListIteratorOfLabelList aLIter(aList); aLIter.More(); aLIter.Next()) {
       if (theWithEmpty || !aLIter.Value().IsNull())
         anIndex++;
-      if (anIndex == theIndex)
+      if (anIndex == theIndex) {
+        if (aLIter.Value().IsNull()) { // null label => null sub
+          return ObjectPtr();
+        }
         return aDoc->objects()->object(aLIter.Value());
+      }
     }
   }
   return ObjectPtr();
index 45dc68ae534fcdec0c69d670f8518fc1fb81e58c..5209b2d686648376481fb6b48f563898be6301d9 100755 (executable)
@@ -109,11 +109,16 @@ bool Model_ResultCompSolid::isConcealed()
 
 void Model_ResultCompSolid::updateSubs(const std::shared_ptr<GeomAPI_Shape>& theThisShape)
 {
+  static Events_Loop* aLoop = Events_Loop::loop();
+  static Events_ID EVENT_DISP = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
+  static Events_ID EVENT_UPD = aLoop->eventByName(EVENT_OBJECT_UPDATED);
+  static const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get();
   // iterate all sub-solids of compsolid to make sub-results synchronized with them
   TopoDS_Shape aThisShape;
   if (theThisShape.get()) aThisShape = theThisShape->impl<TopoDS_Shape>();
   if (!aThisShape.IsNull() && (aThisShape.ShapeType() == TopAbs_COMPSOLID ||
        aThisShape.ShapeType() == TopAbs_COMPOUND)) {
+    bool aWasEmpty = mySubs.empty();
     Model_Objects* anObjects = std::dynamic_pointer_cast<Model_Document>(document())->objects();
     unsigned int aSubIndex = 0;
     TopExp_Explorer aSolids(aThisShape, TopAbs_SOLID);
@@ -129,10 +134,6 @@ void Model_ResultCompSolid::updateSubs(const std::shared_ptr<GeomAPI_Shape>& the
       }
       if (!aSolidShape->isEqual(aSub->shape())) {
         aSub->store(aSolidShape);
-        static Events_Loop* aLoop = Events_Loop::loop();
-        static Events_ID EVENT_DISP = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
-        static Events_ID EVENT_UPD = aLoop->eventByName(EVENT_OBJECT_UPDATED);
-        static const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get();
         aECreator->sendUpdated(aSub, EVENT_DISP);
         aECreator->sendUpdated(aSub, EVENT_UPD);
       }
@@ -144,11 +145,17 @@ void Model_ResultCompSolid::updateSubs(const std::shared_ptr<GeomAPI_Shape>& the
       anErased->setDisabled(anErased, true);
       mySubs.pop_back();
     }
-  } else { // erase all subs
+    if (aWasEmpty) { // erase all subs
+      // redisplay this because result with and without subs are displayed differently
+      aECreator->sendUpdated(data()->owner(), EVENT_DISP);
+    }
+  } else if (!mySubs.empty()) { // erase all subs
     while(!mySubs.empty()) {
       ResultBodyPtr anErased = *(mySubs.rbegin());
       anErased->setDisabled(anErased, true);
       mySubs.pop_back();
     }
+    // redisplay this because result with and without subs are displayed differently
+    aECreator->sendUpdated(data()->owner(), EVENT_DISP);
   }
 }