Salome HOME
Fix for hang up of modification of radius-dimension of an arc
authormpv <mpv@opencascade.com>
Mon, 26 Jan 2015 08:20:45 +0000 (11:20 +0300)
committermpv <mpv@opencascade.com>
Mon, 26 Jan 2015 08:20:45 +0000 (11:20 +0300)
src/Model/Model_Data.cpp
src/Model/Model_Data.h
src/ModelAPI/ModelAPI_Data.h
src/SketchPlugin/SketchPlugin_Feature.h
src/SketchSolver/SketchSolver_ConstraintGroup.cpp

index 1bd4dc1b96c3e861f0936e9d65badc93f4886fee..e13eaa406e5b6199c198ebf86dfb074140c5130a 100644 (file)
@@ -35,7 +35,7 @@
 // TDataStd_Name - name of the object
 // TDataStd_Integer - state of the object execution
 
-Model_Data::Model_Data()
+Model_Data::Model_Data() : mySendAttributeUpdated(true)
 {
 }
 
@@ -197,12 +197,17 @@ void Model_Data::sendAttributeUpdated(ModelAPI_Attribute* theAttr)
   if (theAttr->isArgument()) {
     static const Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED);
     ModelAPI_EventCreator::get()->sendUpdated(myObject, anEvent);
-    if (myObject) {
+    if (mySendAttributeUpdated && myObject) {
       myObject->attributeChanged(theAttr->id());
     }
   }
 }
 
+void Model_Data::blockSendAttributeUpdated(const bool theBlock)
+{
+  mySendAttributeUpdated = !theBlock;
+}
+
 void Model_Data::erase()
 {
   if (!myLab.IsNull())
index 64479abe1243c553a1f0c09fd23e9b27dea11e2a..e8ddf546dae72bc56a31d781eb5532a361c57b37 100644 (file)
@@ -49,6 +49,8 @@ class Model_Data : public ModelAPI_Data
 
   /// List of attributes referenced to owner (updated only during the transaction change)
   std::set<AttributePtr> myRefsToMe;
+  /// flag that may block the "attribute updated" sending
+  bool mySendAttributeUpdated;
 
   Model_Data();
 
@@ -132,6 +134,8 @@ class Model_Data : public ModelAPI_Data
   /// Useful method for "set" methods of the attributes: sends an UPDATE event and
   /// makes attribute initialized
   MODEL_EXPORT virtual void sendAttributeUpdated(ModelAPI_Attribute* theAttr);
+  /// Blocks sending "attribute updated" if theBlock is true
+  MODEL_EXPORT virtual void blockSendAttributeUpdated(const bool theBlock);
 
   /// Puts feature to the document data sub-structure
   MODEL_EXPORT void setLabel(TDF_Label theLab);
index 03e21b36fef4ae3f239c4f87f496b714607e82fb..99cf5a902af803bedc093063826f0e40899e955b 100644 (file)
@@ -103,6 +103,8 @@ class MODELAPI_EXPORT ModelAPI_Data
   /// Useful method for "set" methods of the attributes: sends an UPDATE event and
   /// makes attribute initialized
   virtual void sendAttributeUpdated(ModelAPI_Attribute* theAttr) = 0;
+  /// Blocks sending "attribute updated" if theBlock is true
+  virtual void blockSendAttributeUpdated(const bool theBlock) = 0;
 
   /// Erases all the data from the data model
   virtual void erase() = 0;
index b862bb0045c6d4d9f34f351cb2aa696d26509289..b69de135ba91d246cd0ef9e24ded6df0bf745563 100644 (file)
@@ -59,7 +59,7 @@ class SketchPlugin_Feature : public ModelAPI_Feature, public GeomAPI_ICustomPrs
   {
     AttributeSelectionPtr aAttr = data()->selection(EXTERNAL_ID());
     if (aAttr)
-      return aAttr->context().get();
+      return aAttr->context().get() == NULL;
     return false;
   }
 
index f311546396df5e0c87daf3ab05c3ab0fad49e324..6a6fe158e47ef4e8f06eb711ae9d1876c381eaa5 100644 (file)
@@ -897,9 +897,17 @@ bool SketchSolver_ConstraintGroup::resolveConstraints()
     // We should go through the attributes map, because only attributes have valued parameters
     std::map<std::shared_ptr<ModelAPI_Attribute>, Slvs_hEntity>::iterator anEntIter =
         myEntityAttrMap.begin();
-    for (; anEntIter != myEntityAttrMap.end(); anEntIter++)
+    for (; anEntIter != myEntityAttrMap.end(); anEntIter++) {
+      if (anEntIter->first->owner().get() && anEntIter->first->owner()->data().get())
+        anEntIter->first->owner()->data()->blockSendAttributeUpdated(true);
       if (updateAttribute(anEntIter->first, anEntIter->second))
         updateRelatedConstraints(anEntIter->first);
+    }
+    // unblock all features then
+    for (; anEntIter != myEntityAttrMap.end(); anEntIter++) {
+      if (anEntIter->first->owner().get() && anEntIter->first->owner()->data().get())
+        anEntIter->first->owner()->data()->blockSendAttributeUpdated(false);
+    }
   } else if (!myConstraints.empty())
     Events_Error::send(SketchSolver_Error::CONSTRAINTS(), this);