X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FModel%2FModel_Data.cpp;h=35137cce8ee6a06b3bca1444e21832fcdee6afaf;hb=70bdd86989ad2e604040b3a17aa1bd8ee82d0de7;hp=697bfedd91724a9702dfeb8fe834f6aab255101e;hpb=48b3193b3aa7ad3413effc73276ab77d6226d73f;p=modules%2Fshaper.git diff --git a/src/Model/Model_Data.cpp b/src/Model/Model_Data.cpp index 697bfedd9..35137cce8 100644 --- a/src/Model/Model_Data.cpp +++ b/src/Model/Model_Data.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2017 CEA/DEN, EDF R&D +// Copyright (C) 2014-2019 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -12,10 +12,9 @@ // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or -// email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include @@ -39,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -96,22 +96,13 @@ void Model_Data::setLabel(TDF_Label theLab) 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); } } std::string Model_Data::name() { Handle(TDataStd_Name) aName; - if (myLab.FindAttribute(TDataStd_Name::GetID(), aName)) { + if (shapeLab().FindAttribute(TDataStd_Name::GetID(), aName)) { #ifdef DEBUG_NAMES myObject->myName = TCollection_AsciiString(aName->Get()).ToCString(); #endif @@ -125,8 +116,8 @@ void Model_Data::setName(const std::string& theName) bool isModified = false; std::string anOldName = name(); Handle(TDataStd_Name) aName; - if (!myLab.FindAttribute(TDataStd_Name::GetID(), aName)) { - TDataStd_Name::Set(myLab, theName.c_str()); + if (!shapeLab().FindAttribute(TDataStd_Name::GetID(), aName)) { + TDataStd_Name::Set(shapeLab(), theName.c_str()); isModified = true; } else { isModified = !aName->Get().IsEqual(theName.c_str()); @@ -138,12 +129,12 @@ void Model_Data::setName(const std::string& theName) bool isUserDefined = true; ResultPtr aResult = std::dynamic_pointer_cast(myObject); if (aResult) { - std::string aDefaultName = ModelAPI_Tools::getDefaultName(aResult).first; + std::string aDefaultName = ModelAPI_Tools::getDefaultName(aResult, false).first; isUserDefined = aDefaultName != theName; } if (isUserDefined) { // name is user-defined, thus special attribute is set - TDataStd_UAttribute::Set(myLab, kUSER_DEFINED_NAME); + TDataStd_UAttribute::Set(shapeLab(), kUSER_DEFINED_NAME); } } } @@ -151,7 +142,7 @@ void Model_Data::setName(const std::string& theName) ModelAPI_ObjectRenamedMessage::send(myObject, anOldName, theName, this); if (isModified && myObject && myObject->document()) { std::dynamic_pointer_cast(myObject->document())-> - changeNamingName(anOldName, theName, myLab); + changeNamingName(anOldName, theName, shapeLab()); } #ifdef DEBUG_NAMES myObject->myName = theName; @@ -160,7 +151,7 @@ void Model_Data::setName(const std::string& theName) bool Model_Data::hasUserDefinedName() const { - return myLab.IsAttribute(kUSER_DEFINED_NAME); + return shapeLab().IsAttribute(kUSER_DEFINED_NAME); } AttributePtr Model_Data::addAttribute(const std::string& theID, const std::string theAttrType) @@ -345,8 +336,8 @@ void Model_Data::sendAttributeUpdated(ModelAPI_Attribute* theAttr) myWasChangedButBlocked.push_back(theAttr); } } else { - // trim: need to redisplay - if (myObject) { + // trim: need to redisplay or set color in the python script + if (myObject && (theAttr->attributeType() == "Point2D" || theAttr->id() == "Color")) { static const Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY); ModelAPI_EventCreator::get()->sendUpdated(myObject, anEvent); } @@ -417,7 +408,7 @@ enum StatesIndexes { STATE_INDEX_TRANSACTION = 2, // transaction ID }; -/// Returns the label array, initialises it by default values if not exists +/// Returns the label array, initializes it by default values if not exists static Handle(TDataStd_IntegerArray) stateArray(TDF_Label& theLab) { Handle(TDataStd_IntegerArray) aStateArray; @@ -481,15 +472,6 @@ int Model_Data::featureId() const return myLab.Father().Tag(); // tag of the feature label } -void Model_Data::eraseBackReferences() -{ - myRefsToMe.clear(); - std::shared_ptr aRes = std::dynamic_pointer_cast(myObject); - if (aRes) { - aRes->setIsConcealed(false); - } -} - void Model_Data::removeBackReference(ObjectPtr theObject, std::string theAttrID) { AttributePtr anAttribute = theObject->data()->attribute(theAttrID); @@ -503,7 +485,7 @@ void Model_Data::removeBackReference(AttributePtr theAttr) myRefsToMe.erase(theAttr); - // remove concealment immideately: on deselection it must be posible to reselect in GUI the same + // remove concealment immediately: on deselection it must be possible to reselect in GUI the same FeaturePtr aFeatureOwner = std::dynamic_pointer_cast(theAttr->owner()); if (aFeatureOwner.get() && ModelAPI_Session::get()->validators()->isConcealed(aFeatureOwner->getKind(), theAttr->id())) { @@ -523,7 +505,7 @@ void Model_Data::addBackReference(FeaturePtr theFeature, std::string theAttrID, // be displayed and previewed; also for avoiding of quick show/hide on history // moving deep down if (aRes && !theFeature->isDisabled()) { - aRes->setIsConcealed(true); + aRes->setIsConcealed(true, theFeature->getKind() == "RemoveResults"); } } } @@ -545,10 +527,16 @@ void Model_Data::updateConcealmentFlag() if (aFeature.get() && !aFeature->isDisabled() && aFeature->isStable()) { if (ModelAPI_Session::get()->validators()->isConcealed( aFeature->getKind(), (*aRefsIter)->id())) { - std::shared_ptr aRes = std::dynamic_pointer_cast(myObject); + std::shared_ptr aRes = + std::dynamic_pointer_cast(myObject); if (aRes.get()) { - aRes->setIsConcealed(true); // set concealed - return; + if (aRes->groupName() != ModelAPI_ResultConstruction::group()) { + aRes->setIsConcealed(true); // set concealed + return; + } else if (aFeature->getKind() == "RemoveResults") { + aRes->setIsConcealed(true, true); + return; + } } } } @@ -740,7 +728,7 @@ void Model_Data::copyTo(std::shared_ptr theTarget) // reinitialize Model_Attributes by TDF_Attributes set std::shared_ptr aTData = std::dynamic_pointer_cast(theTarget); aTData->myAttrs.clear(); - theTarget->owner()->initAttributes(); // reinit feature attributes + theTarget->owner()->initAttributes(); // reinitialize feature attributes } bool Model_Data::isInHistory()