From c47decf94380d5c06fd22a03634e464f8ed33de6 Mon Sep 17 00:00:00 2001 From: mpv Date: Mon, 26 Jan 2015 11:20:45 +0300 Subject: [PATCH] Fix for hang up of modification of radius-dimension of an arc --- src/Model/Model_Data.cpp | 9 +++++++-- src/Model/Model_Data.h | 4 ++++ src/ModelAPI/ModelAPI_Data.h | 2 ++ src/SketchPlugin/SketchPlugin_Feature.h | 2 +- src/SketchSolver/SketchSolver_ConstraintGroup.cpp | 10 +++++++++- 5 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/Model/Model_Data.cpp b/src/Model/Model_Data.cpp index 1bd4dc1b9..e13eaa406 100644 --- a/src/Model/Model_Data.cpp +++ b/src/Model/Model_Data.cpp @@ -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()) diff --git a/src/Model/Model_Data.h b/src/Model/Model_Data.h index 64479abe1..e8ddf546d 100644 --- a/src/Model/Model_Data.h +++ b/src/Model/Model_Data.h @@ -49,6 +49,8 @@ class Model_Data : public ModelAPI_Data /// List of attributes referenced to owner (updated only during the transaction change) std::set 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); diff --git a/src/ModelAPI/ModelAPI_Data.h b/src/ModelAPI/ModelAPI_Data.h index 03e21b36f..99cf5a902 100644 --- a/src/ModelAPI/ModelAPI_Data.h +++ b/src/ModelAPI/ModelAPI_Data.h @@ -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; diff --git a/src/SketchPlugin/SketchPlugin_Feature.h b/src/SketchPlugin/SketchPlugin_Feature.h index b862bb004..b69de135b 100644 --- a/src/SketchPlugin/SketchPlugin_Feature.h +++ b/src/SketchPlugin/SketchPlugin_Feature.h @@ -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; } diff --git a/src/SketchSolver/SketchSolver_ConstraintGroup.cpp b/src/SketchSolver/SketchSolver_ConstraintGroup.cpp index f31154639..6a6fe158e 100644 --- a/src/SketchSolver/SketchSolver_ConstraintGroup.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintGroup.cpp @@ -897,9 +897,17 @@ bool SketchSolver_ConstraintGroup::resolveConstraints() // We should go through the attributes map, because only attributes have valued parameters std::map, 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); -- 2.39.2