X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModel%2FModel_Data.cpp;h=e2ef4c7477e1357cfae8ae05164661d08040f092;hb=6f77dfcd9833cdba0c583e6218350f1f7043eb8b;hp=d537db894aa04f9a905c4a8339b9c7ddfbaa555f;hpb=7fcf163a8a369889707c5b73eeeb2bc68a4b906e;p=modules%2Fshaper.git diff --git a/src/Model/Model_Data.cpp b/src/Model/Model_Data.cpp index d537db894..e2ef4c747 100644 --- a/src/Model/Model_Data.cpp +++ b/src/Model/Model_Data.cpp @@ -29,6 +29,7 @@ #include #include +#include #include #include #include @@ -239,10 +240,22 @@ ModelAPI_ExecState Model_Data::execState() return ModelAPI_StateMustBeUpdated; // default value } -void Model_Data::setError(const std::string& theError) +void Model_Data::setError(const std::string& theError, bool theSend) { execState(ModelAPI_StateExecFailed); - Events_Error::send(theError); + if (theSend) { + Events_Error::send(theError); + } + TDataStd_AsciiString::Set(myLab, theError.c_str()); +} + +std::string Model_Data::error() const +{ + Handle(TDataStd_AsciiString) anErrorAttr; + if (myLab.FindAttribute(TDataStd_AsciiString::GetID(), anErrorAttr)) { + return std::string(anErrorAttr->Get().ToCString()); + } + return std::string(); } int Model_Data::featureId() const @@ -259,10 +272,26 @@ void Model_Data::eraseBackReferences() aRes->setIsConcealed(false); } -void Model_Data::addBackReference(FeaturePtr theFeature, std::string theAttrID) +void Model_Data::removeBackReference(FeaturePtr theFeature, std::string theAttrID) { + AttributePtr anAttribute = theFeature->data()->attribute(theAttrID); + if (myRefsToMe.find(anAttribute) == myRefsToMe.end()) + return; + + myRefsToMe.erase(anAttribute); +} + +void Model_Data::addBackReference(FeaturePtr theFeature, std::string theAttrID, + const bool theApplyConcealment) +{ + // do not add the same attribute twice + AttributePtr anAttribute = theFeature->data()->attribute(theAttrID); + if (myRefsToMe.find(anAttribute) != myRefsToMe.end()) + return; + myRefsToMe.insert(theFeature->data()->attribute(theAttrID)); - if (ModelAPI_Session::get()->validators()->isConcealed(theFeature->getKind(), theAttrID)) { + if (theApplyConcealment && + ModelAPI_Session::get()->validators()->isConcealed(theFeature->getKind(), theAttrID)) { std::shared_ptr aRes = std::dynamic_pointer_cast(myObject); if (aRes) {