Salome HOME
Remove extra files
[modules/shaper.git] / src / Model / Model_ResultBody.cpp
index 8418ba22fa5c63adfe506f5f044f939c64ddc977..80bce61ab64f34182544043f4b18c45e0ef3132e 100644 (file)
@@ -6,8 +6,9 @@
 
 #include <Model_ResultBody.h>
 #include <Model_BodyBuilder.h>
-#include <ModelAPI_AttributeIntArray.h>
+#include <ModelAPI_Tools.h>
 #include <Config_PropManager.h>
+#include <ModelAPI_Events.h>
 // DEB
 //#include <TCollection_AsciiString.hxx>
 //#include <TDF_Tool.hxx>
 Model_ResultBody::Model_ResultBody()
 {
   myBuilder = new Model_BodyBuilder(this);
-}
-
-void Model_ResultBody::initAttributes()
-{
-  // append the color attribute. It is empty, the attribute will be filled by a request
-  DataPtr aData = data();
-  aData->addAttribute(COLOR_ID(), ModelAPI_AttributeIntArray::typeId());
+  myWasConcealed = false;
+  myConnect = ConnectionNotComputed;
 }
 
 void Model_ResultBody::colorConfigInfo(std::string& theSection, std::string& theName,
@@ -46,3 +42,35 @@ bool Model_ResultBody::isLatestEqual(const std::shared_ptr<GeomAPI_Shape>& theSh
 {
   return myBuilder->isLatestEqual(theShape);
 }
+
+bool Model_ResultBody::isConcealed()
+{
+  bool aResult = false;
+  if (ModelAPI_ResultBody::isConcealed()) {
+    aResult = true;
+  } else {
+    ResultPtr aThis = std::dynamic_pointer_cast<ModelAPI_Result>(data()->owner());
+    if (aThis.get()) {
+      ResultCompSolidPtr aParent = ModelAPI_Tools::compSolidOwner(aThis);
+      if (aParent.get()) {
+        if (aParent->isConcealed())
+          aResult = true;
+      }
+    }
+  }
+  if (myWasConcealed != aResult) {
+    myWasConcealed = aResult;
+    if (aResult) { // hidden unit must be redisplayed (hidden)
+      ModelAPI_EventCreator::get()->sendDeleted(document(), this->groupName());
+      // redisplay for the viewer (it must be disappeared also)
+      static Events_ID EVENT_DISP = 
+        Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
+      ModelAPI_EventCreator::get()->sendUpdated(data()->owner(), EVENT_DISP);
+    } else { // was not concealed become concealed => delete event
+      static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_CREATED);
+      ModelAPI_EventCreator::get()->sendUpdated(data()->owner(), anEvent);
+    }
+  }
+
+  return aResult;
+}