Salome HOME
Issue #599 - hide trihedron when create Sketch,
authornds <natalia.donis@opencascade.com>
Thu, 18 Jun 2015 08:43:15 +0000 (11:43 +0300)
committernds <natalia.donis@opencascade.com>
Thu, 18 Jun 2015 08:43:15 +0000 (11:43 +0300)
A fix for external objects using. activateFlushes(true) in setCurrentDocument leads to visualization external edge out of its turn. There was a bug in distance constraint creation to the external edge.

src/Events/Events_Loop.cpp
src/Events/Events_Loop.h
src/Model/Model_Document.cpp
src/Model/Model_Objects.cpp
src/ModuleBase/ModuleBase_WidgetValidated.cpp

index 139e862340007e89ce5dec7723768cb401df18cd..83091a254d4971b0432960bd1be432f2fc1a766f 100644 (file)
@@ -133,9 +133,11 @@ void Events_Loop::flush(const Events_ID& theID)
   }
 }
 
-void Events_Loop::activateFlushes(const bool theActivate)
+bool Events_Loop::activateFlushes(const bool theActivate)
 {
+  bool isActive = myFlushActive;
   myFlushActive = theActivate;
+  return isActive;
 }
 
 void Events_Loop::clear(const Events_ID& theID)
index a11426f1b99263f8581a0d4b5640c14db9167bd3..adc88835198dda23e4121ac4dd07620217475e19 100644 (file)
@@ -68,8 +68,10 @@ class Events_Loop
 
   //! Allows to disable flushes: needed in synchronization of document mechanism 
   //! (to synchronize all and only then flush create, update, etc in correct order)
-  EVENTS_EXPORT void activateFlushes(const bool theActivate);
-
+  //! \param theActivate a state about flushe is active. If false, the flush is disabled
+  //! \return the previous active flush state
+  EVENTS_EXPORT bool activateFlushes(const bool theActivate);
+  
   //! Clears all collected messages
   EVENTS_EXPORT void clear(const Events_ID& theID);
 
index c2e4c355f64ea7028dcabb986617bf00e319b82a..2913075901a1c12bf6c05823643c786bb872ffa2 100644 (file)
@@ -665,7 +665,7 @@ void Model_Document::setCurrentFeature(std::shared_ptr<ModelAPI_Feature> theCurr
   // blocks the flush signals to avoid each objects visualization in the viewer
   // they should not be shown once after all modifications are performed
   Events_Loop* aLoop = Events_Loop::loop();
-  aLoop->activateFlushes(false);
+  bool isActive = aLoop->activateFlushes(false);
 
   TDF_Label aRefLab = generalLabel().FindChild(TAG_CURRENT_FEATURE);
   CompositeFeaturePtr aMain; // main feature that may nest the new current
@@ -699,7 +699,10 @@ void Model_Document::setCurrentFeature(std::shared_ptr<ModelAPI_Feature> theCurr
   }
   if (theCurrent.get()) {
     std::shared_ptr<Model_Data> aData = std::static_pointer_cast<Model_Data>(theCurrent->data());
-    if (!aData.get() || !aData->isValid()) return;
+    if (!aData.get() || !aData->isValid()) {
+      aLoop->activateFlushes(isActive);
+      return;
+    }
     TDF_Label aFeatureLabel = aData->label().Father();
 
     Handle(TDF_Reference) aRef;
@@ -736,7 +739,7 @@ void Model_Document::setCurrentFeature(std::shared_ptr<ModelAPI_Feature> theCurr
     }
   }
   // unblock  the flush signals and up them after this
-  aLoop->activateFlushes(true);
+  aLoop->activateFlushes(isActive);
 
   aLoop->flush(aCreateEvent);
   aLoop->flush(aRedispEvent);
index be9e80ff3baa9d5699588845a9592874b507fc34..1b8e3253b9eda85fc235449e940f623707305434 100644 (file)
@@ -476,7 +476,7 @@ void Model_Objects::synchronizeFeatures(
   static Events_ID aRedispEvent = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
   static Events_ID aDeleteEvent = Events_Loop::eventByName(EVENT_OBJECT_DELETED);
   static Events_ID aToHideEvent = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
-  aLoop->activateFlushes(false);
+  bool isActive = aLoop->activateFlushes(false);
 
   // update all objects by checking are they on labels or not
   std::set<FeaturePtr> aNewFeatures, aKeptFeatures;
@@ -559,7 +559,7 @@ void Model_Objects::synchronizeFeatures(
   }
 
   anOwner->executeFeatures() = false;
-  aLoop->activateFlushes(true);
+  aLoop->activateFlushes(isActive);
 
   if (theFlush) {
     aLoop->flush(aCreateEvent);
index c8e76a6c60512ff6ed1dfdfcf66572b072482eba..29d81e6c20f0205cdc0c76dba994171657fc2234 100644 (file)
@@ -71,7 +71,7 @@ bool ModuleBase_WidgetValidated::isValidSelection(const ModuleBase_ViewerPrs& th
   Events_Loop* aLoop = Events_Loop::loop();
   // blocks the flush signals to avoid the temporary objects visualization in the viewer
   // they should not be shown in order to do not lose highlight by erasing them
-  aLoop->activateFlushes(false);
+  bool isActive = aLoop->activateFlushes(false);
 
   aData->blockSendAttributeUpdated(true);
   bool isAttributeBlocked = anAttribute->blockSetInitialized(true);
@@ -87,7 +87,7 @@ bool ModuleBase_WidgetValidated::isValidSelection(const ModuleBase_ViewerPrs& th
   restoreAttributeValue(aValid);
   aData->blockSendAttributeUpdated(false);
   anAttribute->blockSetInitialized(isAttributeBlocked);
-  aLoop->activateFlushes(true);
+  aLoop->activateFlushes(isActive);
 
   // In particular case the results are deleted and called as redisplayed inside of this
   // highlight-selection, to they must be flushed as soon as possible.