Salome HOME
Make Boolean operation conceal the selected argument: sub-body of compsolid or the...
authormpv <mpv@opencascade.com>
Tue, 25 Aug 2015 09:27:27 +0000 (12:27 +0300)
committermpv <mpv@opencascade.com>
Tue, 25 Aug 2015 09:27:27 +0000 (12:27 +0300)
src/Model/Model_ResultCompSolid.cpp
src/Model/Model_ResultCompSolid.h
src/ModelAPI/ModelAPI_Result.h
src/SketchSolver/SketchSolver_ConstraintManager.cpp

index 4747d651174244f7cc3b9abc858af3067f289b54..16fda2569cb37f5f07ebccb8775cd11621d28a25 100755 (executable)
@@ -108,6 +108,27 @@ bool Model_ResultCompSolid::isConcealed()
   return false;
 }
 
+void Model_ResultCompSolid::setIsConcealed(const bool theValue)
+{
+  ModelAPI_ResultCompSolid::setIsConcealed(theValue);
+  std::vector<std::shared_ptr<ModelAPI_ResultBody> >::const_iterator aSubIter = mySubs.cbegin();
+  for(; aSubIter != mySubs.cend(); aSubIter++) {
+    if ((*aSubIter)->isConcealed() != theValue) {
+      (*aSubIter)->setIsConcealed(theValue);
+      if (theValue) { // hidden unit must be redisplayed (hidden)
+        ModelAPI_EventCreator::get()->sendDeleted(document(), (*aSubIter)->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(*aSubIter, EVENT_DISP);
+      } else { // was not concealed become concealed => delete event
+        static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_CREATED);
+        ModelAPI_EventCreator::get()->sendUpdated(*aSubIter, anEvent);
+      }
+    }
+  }
+}
+
 void Model_ResultCompSolid::updateSubs(const std::shared_ptr<GeomAPI_Shape>& theThisShape)
 {
   static Events_Loop* aLoop = Events_Loop::loop();
index 152ef4bba942210e94c09a525632d5fcc696f9b1..3f228b388610fd8e2a85dfc3f6ba5f6c171380c1 100755 (executable)
@@ -62,6 +62,10 @@ public:
 
   /// The compsolid is concealed if at least one of the sub is concealed
   MODEL_EXPORT virtual bool isConcealed();
+
+  /// Sets all subs as concealed in the data tree (referenced by other objects)
+  MODEL_EXPORT virtual void setIsConcealed(const bool theValue);
+
 protected:
   /// Makes a body on the given feature
   Model_ResultCompSolid();
index 97359e5ad74d9d43b3fa3bc9f6acedaedb53e60e..5508f4273dcad6e826316f1329e9b9d99e09ab07 100644 (file)
@@ -37,8 +37,8 @@ class ModelAPI_Result : public ModelAPI_Object
   /// Returns true if the result is concealed from the data tree (referenced by other objects)
   MODELAPI_EXPORT virtual bool isConcealed();
 
-  /// Returns true if the result is concealed from the data tree (referenced by other objects)
-  MODELAPI_EXPORT void setIsConcealed(const bool theValue);
+  /// Sets the result as concealed in the data tree (referenced by other objects)
+  MODELAPI_EXPORT virtual void setIsConcealed(const bool theValue);
 
   /// Enables/disables the result. The disabled result does not participate in any calculation
   /// and visualization: like it was removed. But it keeps the general parameters: colors, 
index 4034c0b7e0558355b0f2f976e6ea753d8b8aa13b..b06db8d968ac7028cb9b2cb61433788114c0c5d1 100644 (file)
@@ -76,81 +76,81 @@ void SketchSolver_ConstraintManager::processEvent(
   if (myIsComputed)
     return;
   if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_CREATED)
-      || theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_UPDATED)
-      || theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_MOVED)) {
-    std::shared_ptr<ModelAPI_ObjectUpdatedMessage> anUpdateMsg =
+    || theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_UPDATED)
+    || theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_MOVED)) {
+      std::shared_ptr<ModelAPI_ObjectUpdatedMessage> anUpdateMsg =
         std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
-    std::set<ObjectPtr> aFeatures = anUpdateMsg->objects();
+      std::set<ObjectPtr> aFeatures = anUpdateMsg->objects();
 
-    // Shows the message has at least one feature applicable for solver
-    bool hasProperFeature = false;
+      // Shows the message has at least one feature applicable for solver
+      bool hasProperFeature = false;
 
-    bool isMovedEvt = theMessage->eventID()
+      bool isMovedEvt = theMessage->eventID()
         == Events_Loop::loop()->eventByName(EVENT_OBJECT_MOVED);
-    if (isMovedEvt) {
-      std::set<ObjectPtr>::iterator aFeatIter;
-      for (aFeatIter = aFeatures.begin(); aFeatIter != aFeatures.end(); aFeatIter++) {
-        std::shared_ptr<SketchPlugin_Feature> aSFeature = 
+      if (isMovedEvt) {
+        std::set<ObjectPtr>::iterator aFeatIter;
+        for (aFeatIter = aFeatures.begin(); aFeatIter != aFeatures.end(); aFeatIter++) {
+          std::shared_ptr<SketchPlugin_Feature> aSFeature = 
             std::dynamic_pointer_cast<SketchPlugin_Feature>(*aFeatIter);
-        if (aSFeature) {
-          moveEntity(aSFeature);
-          hasProperFeature = true;
+          if (aSFeature) {
+            moveEntity(aSFeature);
+            hasProperFeature = true;
+          }
         }
-      }
-    } else {
-      std::set<ObjectPtr>::iterator aFeatIter;
-      // iterate sketchers fisrt to create all sketches before (on load may exist several sketches)
-      for (aFeatIter = aFeatures.begin(); aFeatIter != aFeatures.end(); aFeatIter++) {
-        FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(*aFeatIter);
-        if (!aFeature)
-          continue;
-        const std::string& aFeatureKind = aFeature->getKind();
-        if (aFeatureKind.compare(SketchPlugin_Sketch::ID()) == 0) {
-          std::shared_ptr<ModelAPI_CompositeFeature> aSketch = std::dynamic_pointer_cast<
+      } else {
+        std::set<ObjectPtr>::iterator aFeatIter;
+        // iterate sketchers fisrt to create all sketches before (on load may exist several sketches)
+        for (aFeatIter = aFeatures.begin(); aFeatIter != aFeatures.end(); aFeatIter++) {
+          FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(*aFeatIter);
+          if (!aFeature)
+            continue;
+          const std::string& aFeatureKind = aFeature->getKind();
+          if (aFeatureKind.compare(SketchPlugin_Sketch::ID()) == 0) {
+            std::shared_ptr<ModelAPI_CompositeFeature> aSketch = std::dynamic_pointer_cast<
               ModelAPI_CompositeFeature>(aFeature);
-          hasProperFeature = changeWorkplane(aSketch) || hasProperFeature;
+            hasProperFeature = changeWorkplane(aSketch) || hasProperFeature;
+          }
         }
-      }
-      // then get anything but not the sketch
-      std::set<ObjectPtr> aComplexConstraints;
-      // fillet and mirror an tangency constraints will be processed later
-      for (aFeatIter = aFeatures.begin(); aFeatIter != aFeatures.end(); aFeatIter++) {
-        std::shared_ptr<SketchPlugin_Feature> aFeature = 
-          std::dynamic_pointer_cast<SketchPlugin_Feature>(*aFeatIter);
-        if (!aFeature)
-          continue;
-        if (aFeature->getKind() == SketchPlugin_ConstraintFillet::ID())
-          continue; // skip Fillet features
-        if (SketchSolver_Group::isComplexConstraint(aFeature)) {
-          aComplexConstraints.insert(aFeature);
-          continue;
+        // then get anything but not the sketch
+        std::set<ObjectPtr> aComplexConstraints;
+        // fillet and mirror an tangency constraints will be processed later
+        for (aFeatIter = aFeatures.begin(); aFeatIter != aFeatures.end(); aFeatIter++) {
+          std::shared_ptr<SketchPlugin_Feature> aFeature = 
+            std::dynamic_pointer_cast<SketchPlugin_Feature>(*aFeatIter);
+          if (!aFeature)
+            continue;
+          if (aFeature->getKind() == SketchPlugin_ConstraintFillet::ID())
+            continue; // skip Fillet features
+          if (SketchSolver_Group::isComplexConstraint(aFeature)) {
+            aComplexConstraints.insert(aFeature);
+            continue;
+          }
+          hasProperFeature = changeConstraintOrEntity(aFeature) || hasProperFeature;
+        }
+        // processing remain constraints
+        aFeatIter = aComplexConstraints.begin();
+        for (; aFeatIter != aComplexConstraints.end(); aFeatIter++) {
+          std::shared_ptr<SketchPlugin_Feature> aFeature = 
+            std::dynamic_pointer_cast<SketchPlugin_Feature>(*aFeatIter);
+          if (!aFeature)
+            continue;
+          hasProperFeature = changeConstraintOrEntity(aFeature) || hasProperFeature;
         }
-        hasProperFeature = changeConstraintOrEntity(aFeature) || hasProperFeature;
-      }
-      // processing remain constraints
-      aFeatIter = aComplexConstraints.begin();
-      for (; aFeatIter != aComplexConstraints.end(); aFeatIter++) {
-        std::shared_ptr<SketchPlugin_Feature> aFeature = 
-          std::dynamic_pointer_cast<SketchPlugin_Feature>(*aFeatIter);
-        if (!aFeature)
-          continue;
-        hasProperFeature = changeConstraintOrEntity(aFeature) || hasProperFeature;
       }
-    }
 
-    // Solve the set of constraints
-    if (hasProperFeature)
-      resolveConstraints(isMovedEvt); // send update for movement in any case
+      // Solve the set of constraints
+      if (hasProperFeature)
+        resolveConstraints(isMovedEvt); // send update for movement in any case
   } else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_DELETED)) {
     std::shared_ptr<ModelAPI_ObjectDeletedMessage> aDeleteMsg =
-        std::dynamic_pointer_cast<ModelAPI_ObjectDeletedMessage>(theMessage);
+      std::dynamic_pointer_cast<ModelAPI_ObjectDeletedMessage>(theMessage);
     const std::set<std::string>& aFeatureGroups = aDeleteMsg->groups();
 
     // Find SketchPlugin_Sketch::ID() in groups. The constraint groups should be updated when an object removed from Sketch
     std::set<std::string>::const_iterator aFGrIter;
     for (aFGrIter = aFeatureGroups.begin(); aFGrIter != aFeatureGroups.end(); aFGrIter++)
       if (aFGrIter->compare(ModelAPI_ResultConstruction::group()) == 0 ||
-          aFGrIter->compare(ModelAPI_Feature::group()) == 0)
+        aFGrIter->compare(ModelAPI_Feature::group()) == 0)
         break;
 
     if (aFGrIter != aFeatureGroups.end()) {