Salome HOME
Make same planes cannot be used twice in partition tool
[modules/shaper.git] / src / XGUI / XGUI_WorkshopListener.cpp
index d8934f2da7c14d455a1122de8a410ca25d40b953..03aaf4fa1f10e729201c7bcaafa8a27d82a62145 100755 (executable)
@@ -29,6 +29,7 @@
 #include <ModelAPI_Feature.h>
 #include <ModelAPI_Data.h>
 #include <ModelAPI_ResultBody.h>
+#include <ModelAPI_ResultGroup.h>
 #include <ModelAPI_ResultCompSolid.h>
 #include <ModelAPI_Tools.h>
 
@@ -283,6 +284,7 @@ void XGUI_WorkshopListener::onFeatureRedisplayMsg(const std::shared_ptr<ModelAPI
   bool aFirstVisualizedBody = false;
 
   bool aRedisplayed = false;
+  //std::list<ObjectPtr> aHiddenObjects;
   for (aIt = anObjects.begin(); aIt != anObjects.end(); ++aIt) {
     ObjectPtr aObj = (*aIt);
 
@@ -292,7 +294,13 @@ void XGUI_WorkshopListener::onFeatureRedisplayMsg(const std::shared_ptr<ModelAPI
     if (!aHide) { // check that this is not hidden result
       ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(aObj);
       aHide = aRes && aRes->isConcealed();
+
+      // Hide the presentation with an empty shape. But isDisplayed state of the object should not
+      // be changed to the object becomes visible when the shape becomes not empty
+      if (!aHide && aRes.get())
+        aHide = !aRes->shape().get() || aRes->shape()->isNull();
     }
+
 #ifdef DEBUG_RESULT_COMPSOLID
     ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(aObj);
     if (aRes.get()) {
@@ -316,6 +324,9 @@ void XGUI_WorkshopListener::onFeatureRedisplayMsg(const std::shared_ptr<ModelAPI
       }
     #endif
     if (aHide) {
+      //we should provide objects which are hidden in the viewer, e.g. sketch always should visualizes
+      // all sub-features, if some features are to be hidden, sould be proposed may be to removed #1223
+      //aHiddenObjects.push_back(aObj);
       aRedisplayed = aDisplayer->erase(aObj, false) || aRedisplayed;
       #ifdef DEBUG_FEATURE_REDISPLAY
         // Redisplay the visible object or the object of the current operation
@@ -355,6 +366,11 @@ void XGUI_WorkshopListener::onFeatureRedisplayMsg(const std::shared_ptr<ModelAPI
       }
     }
   }
+  // this processing should be moved in another place in order to do not cause problems in
+  // flush messages chain
+  //if (aHiddenObjects.size() > 0)
+  //  myWorkshop->module()->processHiddenObject(aHiddenObjects);
+
   bool isCustomized = customizeCurrentObject(anObjects, aRedisplayed);
   if (aRedisplayed || isCustomized) {
     //VSV FitAll updated viewer by it self
@@ -406,6 +422,10 @@ void XGUI_WorkshopListener::onFeatureCreatedMsg(const std::shared_ptr<ModelAPI_O
       ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
       bool isConcealed = aRes && aRes->isConcealed();
       aHide = aRes && aRes->isConcealed();
+      // Hide the presentation with an empty shape. But isDisplayed state of the object should not
+      // be changed to the object becomes visible when the shape becomes not empty
+      if (!aHide && aRes.get())
+        aHide = !aRes->shape().get() || aRes->shape()->isNull();
     }
     if (!aHide) {
       // setDisplayed has to be called in order to synchronize internal state of the object 
@@ -556,9 +576,16 @@ bool XGUI_WorkshopListener::displayObject(ObjectPtr theObj, bool& theFirstVisual
     aDisplayed = aDisplayer->display(theObj, false);
     if (aNb == 0)
       theFirstVisualizedBody = true;
-  } else 
+  } else {
     aDisplayed = aDisplayer->display(theObj, false);
-
+    if (aDisplayed) {
+      ResultPtr aGroup = std::dynamic_pointer_cast<ModelAPI_ResultGroup>(theObj);
+      if (aGroup.get() != NULL) {
+        std::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(aGroup);
+          theFirstVisualizedBody = aShapePtr.get() != NULL;
+      }
+    }
+  }
   return aDisplayed;
 }
 
@@ -583,7 +610,9 @@ bool XGUI_WorkshopListener::customizeCurrentObject(const std::set<ObjectPtr>& th
     // e.g. extrusion is hidden(h=0) but sketch is chosen
     if (theForceRedisplay || theObjects.find(aCurrentFeature) != theObjects.end()) {
       aCustomized = myWorkshop->module()->customizeObject(aCurrentFeature,
-                                           ModuleBase_IModule::CustomizeDependedAndResults, false);
+                                           ModuleBase_IModule::CustomizeArguments, false);
+      aCustomized = myWorkshop->module()->customizeObject(aCurrentFeature,
+                                           ModuleBase_IModule::CustomizeResults, false);
       aCustomized = myWorkshop->module()->customizeObject(aCurrentFeature,
                                            ModuleBase_IModule::CustomizeHighlightedObjects, false);
     }