]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Make not-stable features lose the concealment ability
authormpv <mpv@opencascade.com>
Fri, 9 Oct 2015 06:06:55 +0000 (09:06 +0300)
committermpv <mpv@opencascade.com>
Fri, 9 Oct 2015 06:06:55 +0000 (09:06 +0300)
src/Model/Model_Data.cpp
src/Model/Model_Update.cpp
src/Model/Model_Update.h
src/ModelAPI/ModelAPI_Events.h
src/ModelAPI/ModelAPI_Feature.cpp

index 8d21b7a7834e5a8ed8d12fcf21fa41fb80dc7af1..64574892c2f6cc47dd140f191b25da6fd520ebd4 100644 (file)
@@ -388,7 +388,7 @@ void Model_Data::addBackReference(FeaturePtr theFeature, std::string theAttrID,
     return;
 
   myRefsToMe.insert(theFeature->data()->attribute(theAttrID));
-  if (theApplyConcealment && 
+  if (theApplyConcealment &&  theFeature->isStable() && 
       ModelAPI_Session::get()->validators()->isConcealed(theFeature->getKind(), theAttrID)) {
     std::shared_ptr<ModelAPI_Result> aRes = 
       std::dynamic_pointer_cast<ModelAPI_Result>(myObject);
index 69a10d74524b891531046efd56878009db4102eb..21e38c5a49de0145a6f0cfa2f98f6c3e934e5f11 100644 (file)
@@ -54,6 +54,8 @@ Model_Update::Model_Update()
   aLoop->registerListener(this, kOpAbortEvent);
   static const Events_ID kOpStartEvent = aLoop->eventByName("StartOperation");
   aLoop->registerListener(this, kOpStartEvent);
+  static const Events_ID kStabilityEvent = aLoop->eventByName(EVENT_STABILITY_CHANGED);
+  aLoop->registerListener(this, kStabilityEvent);
 
   /* not needed now with history line
   Config_PropManager::registerProp("Model update", "automatic_rebuild", "Rebuild immediately",
@@ -76,9 +78,12 @@ void Model_Update::processEvent(const std::shared_ptr<Events_Message>& theMessag
   static const Events_ID kOpFinishEvent = aLoop->eventByName("FinishOperation");
   static const Events_ID kOpAbortEvent = aLoop->eventByName("AbortOperation");
   static const Events_ID kOpStartEvent = aLoop->eventByName("StartOperation");
+  static const Events_ID kStabilityEvent = aLoop->eventByName(EVENT_STABILITY_CHANGED);
 #ifdef DEB_UPDATE
   std::cout<<"****** Event "<<theMessage->eventID().eventText()<<std::endl;
 #endif
+  if (theMessage->eventID() == kStabilityEvent)
+    updateStability(theMessage->sender());
   if (theMessage->eventID() == kChangedEvent) { // automatic and manual rebuild flag is changed
     /*bool aPropVal =
       Config_PropManager::findProp("Model update", "automatic_rebuild")->value() == "true";
@@ -669,6 +674,18 @@ void Model_Update::executeFeature(FeaturePtr theFeature)
   redisplayWithResults(theFeature, aState);
 }
 
+void Model_Update::updateStability(void* theSender)
+{
+  ModelAPI_Object* aSender = static_cast<ModelAPI_Object*>(theSender);
+  if (aSender && aSender->document()) {
+    Model_Objects* aDocObjects = 
+      std::dynamic_pointer_cast<Model_Document>(aSender->document())->objects();
+    if (aDocObjects) {
+      aDocObjects->synchronizeBackRefs();
+    }
+  }
+}
+
 ///////////////// Updated items iterator ////////////////////////
 Model_Update::IterationItem::IterationItem(std::shared_ptr<ModelAPI_CompositeFeature> theFeature)
 {
index 862a078cee86db631bcff1f09868a8beb4345618..3b543c1f540996c4fe157d991b193a3141a90dee 100644 (file)
@@ -125,6 +125,8 @@ protected:
   /// Returns true if the feature is older that the argument and it must be updated
   bool isOlder(std::shared_ptr<ModelAPI_Feature> theFeature, 
                std::shared_ptr<ModelAPI_Object> theArgument);
+  /// Updates the properties of object because of stability state changes
+  void updateStability(void* theSender);
 };
 
 #endif
index 45349a52c3c97fb6415be40b221a9d36e4d3aab6..f4fee024af80ffcb7445c878186228bbc48287d9 100644 (file)
@@ -56,6 +56,9 @@ static const char * EVENT_SOLVER_REPAIRED = "SolverRepaired";
 /// Event ID that order of objects in group is changed, so, tree must be fully rectreated (movement of feature)
 static const char * EVENT_ORDER_UPDATED = "OrderUpdated";
 
+/// Event ID that informs that some object has changed the stability
+static const char * EVENT_STABILITY_CHANGED = "StabilityChanged";
+
 /// Message that feature was changed (used for Object Browser update): moved, updated and deleted
 class MODELAPI_EXPORT ModelAPI_ObjectUpdatedMessage : public Events_MessageGroup
 {
index 6d17254bc33383fff8a533b141217fda5382099a..5b9d7e3d4e0f3da971bd37d24dd6347179928f9f 100644 (file)
@@ -203,6 +203,11 @@ bool ModelAPI_Feature::setStable(const bool theFlag)
 {
   if (myIsStable != theFlag) {
     myIsStable = theFlag;
+    // send an event about the stability change (editing is started/finished)
+    static Events_Loop* aLoop = Events_Loop::loop();
+    static Events_ID EVENT_STAB = aLoop->eventByName(EVENT_STABILITY_CHANGED);
+    std::shared_ptr<Events_Message> aMessage(new Events_Message(EVENT_STAB, this));
+    aLoop->send(aMessage, false);
     return true;
   }
   return false;