X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModel%2FModel_Data.cpp;h=64574892c2f6cc47dd140f191b25da6fd520ebd4;hb=5264a2bcac399b5ac51a1838a9ffb10c68f03a31;hp=aeb1489c47ac39f298439a7dc4090be4d5a174ed;hpb=773696804ec4f543a421f1ebd71be86d95cb581b;p=modules%2Fshaper.git diff --git a/src/Model/Model_Data.cpp b/src/Model/Model_Data.cpp index aeb1489c4..64574892c 100644 --- a/src/Model/Model_Data.cpp +++ b/src/Model/Model_Data.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -41,6 +42,7 @@ #include #include #include +#include #include @@ -52,6 +54,8 @@ static const int kFlagInHistory = 0; // 1 - is displayed or not static const int kFlagDisplayed = 1; +// 2 - is deleted (for results) or not +static const int kFlagDeleted = 2; // invalid data const static std::shared_ptr kInvalid(new Model_Data()); @@ -66,9 +70,19 @@ void Model_Data::setLabel(TDF_Label theLab) // set or get the default flags if (!myLab.FindAttribute(TDataStd_BooleanArray::GetID(), myFlags)) { // set default values if not found - myFlags = TDataStd_BooleanArray::Set(myLab, 0, 1); + myFlags = TDataStd_BooleanArray::Set(myLab, 0, 2); myFlags->SetValue(kFlagInHistory, Standard_True); // is in history by default is true myFlags->SetValue(kFlagDisplayed, Standard_True); // is displayed by default is true + myFlags->SetValue(kFlagDeleted, Standard_False); // is deleted by default is false + } else if (myFlags->Length() != 3) { // for old formats support + Standard_Boolean aFlag0 = myFlags->Upper() >= 0 ? myFlags->Value(0) : Standard_True; + Standard_Boolean aFlag1 = myFlags->Upper() >= 1 ? myFlags->Value(1) : Standard_True; + Standard_Boolean aFlag2 = myFlags->Upper() >= 2 ? myFlags->Value(2) : Standard_True; + Handle(TColStd_HArray1OfByte) aNewArray = new TColStd_HArray1OfByte(0, 2); + myFlags->SetInternalArray(aNewArray); + myFlags->SetValue(0, aFlag0); + myFlags->SetValue(1, aFlag1); + myFlags->SetValue(2, aFlag2); } } @@ -288,7 +302,12 @@ static Handle(TDataStd_IntegerArray) stateArray(TDF_Label& theLab) void Model_Data::execState(const ModelAPI_ExecState theState) { if (theState != ModelAPI_StateNothing) { - stateArray(myLab)->SetValue(STATE_INDEX_STATE, (int)theState); + if (stateArray(myLab)->Value(STATE_INDEX_STATE) != (int)theState) { + stateArray(myLab)->SetValue(STATE_INDEX_STATE, (int)theState); + } + // send signal even if the new value corresponds to the one in data model: undo issue 980 + static const Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_ERROR_CHANGED); + ModelAPI_EventCreator::get()->sendUpdated(myObject, anEvent, false); } } @@ -314,6 +333,13 @@ void Model_Data::setError(const std::string& theError, bool theSend) Events_Error::send(theError); } TDataStd_AsciiString::Set(myLab, theError.c_str()); + static const Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_ERROR_CHANGED); + ModelAPI_EventCreator::get()->sendUpdated(myObject, anEvent, false); +} + +void Model_Data::eraseErrorString() +{ + myLab.ForgetAttribute(TDataStd_AsciiString::GetID()); } std::string Model_Data::error() const @@ -362,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 aRes = std::dynamic_pointer_cast(myObject); @@ -392,7 +418,7 @@ void Model_Data::updateConcealmentFlag() // thus, no concealment references anymore => make not-concealed std::shared_ptr aRes = std::dynamic_pointer_cast(myObject); - if (aRes.get()) { + if (aRes.get() && aRes->isConcealed()) { aRes->setIsConcealed(false); static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_CREATED); ModelAPI_EventCreator::get()->sendUpdated(aRes, anEvent); @@ -400,8 +426,6 @@ void Model_Data::updateConcealmentFlag() } } -#include - std::set set_union(const std::set& theLeft, const std::set& theRight) { @@ -548,6 +572,16 @@ void Model_Data::setIsInHistory(const bool theFlag) return myFlags->SetValue(kFlagInHistory, theFlag); } +bool Model_Data::isDeleted() +{ + return myFlags->Value(kFlagDeleted) == Standard_True; +} + +void Model_Data::setIsDeleted(const bool theFlag) +{ + return myFlags->SetValue(kFlagDeleted, theFlag); +} + bool Model_Data::isDisplayed() { if (!myObject.get() || !myObject->document().get() || // object is in valid