X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModel%2FModel_Objects.cpp;h=152aaaeb84ee27a8c4211c1c3d3618dae7221f50;hb=8d04b5f4360b23cf376beff9c5e7c12d0e6a5f1e;hp=d7ecf71879dc3ee3b39e5f34eadef130e13f536b;hpb=730d63e53e2e8761041241f10040bfc9922b587d;p=modules%2Fshaper.git diff --git a/src/Model/Model_Objects.cpp b/src/Model/Model_Objects.cpp index d7ecf7187..152aaaeb8 100644 --- a/src/Model/Model_Objects.cpp +++ b/src/Model/Model_Objects.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 @@ -29,9 +28,12 @@ #include #include #include +#include #include #include #include +#include + #include #include @@ -770,7 +772,7 @@ void Model_Objects::setUniqueName(FolderPtr theFolder) NCollection_DataMap::Iterator anIt(myFolders); while (anIt.More()) { if (anIt.Value()->data()->name() == aName) { - aName = composeName(ModelAPI_Folder::ID(), aNbFolders); + aName = composeName(ModelAPI_Folder::ID(), ++aNbFolders); // reinitialize iterator to make sure a new name is unique anIt.Initialize(myFolders); } else @@ -798,15 +800,6 @@ void Model_Objects::initData(ObjectPtr theObj, TDF_Label theLab, const int theTa theObj->initAttributes(); } -std::shared_ptr Model_Objects::featureById(const int theId) -{ - if (theId > 0) { - TDF_Label aLab = featuresLabel().FindChild(theId, Standard_False); - return feature(aLab); - } - return std::shared_ptr(); // not found -} - void Model_Objects::synchronizeFeatures( const TDF_LabelList& theUpdated, const bool theUpdateReferences, const bool theExecuteFeatures, const bool theOpen, const bool theFlush) @@ -883,11 +876,30 @@ void Model_Objects::synchronizeFeatures( if (anUpdatedMap.Contains(aFeatureLabel)) { if (!theOpen) { // on abort/undo/redo reinitialize attributes if something is changed - std::list > anAttrs = - anObject->data()->attributes(""); - std::list >::iterator anAttr = anAttrs.begin(); - for(; anAttr != anAttrs.end(); anAttr++) - (*anAttr)->reinit(); + FiltersFeaturePtr aFilter = std::dynamic_pointer_cast(anObject); + if (aFilter.get()) { // for filters attributes may be added/removed on undo/redo + std::dynamic_pointer_cast(aFilter->data())->clearAttributes(); + aFilter->initAttributes(); + } else { + std::list > anAttrs = + anObject->data()->attributes(""); + std::list >::iterator anAttr = anAttrs.begin(); + for(; anAttr != anAttrs.end(); anAttr++) + (*anAttr)->reinit(); + // if feature contains results, re-init them too + if (aFeature.get()) { + std::list aResults; + ModelAPI_Tools::allResults(aFeature, aResults); + std::list::iterator aResIter = aResults.begin(); + for(; aResIter != aResults.end(); aResIter++) { + std::list > anAttrs = + (*aResIter)->data()->attributes(""); + std::list >::iterator anAttr = anAttrs.begin(); + for(; anAttr != anAttrs.end(); anAttr++) + (*anAttr)->reinit(); + } + } + } } ModelAPI_EventCreator::get()->sendUpdated(anObject, anUpdateEvent); if (aFeature && aFeature->getKind() == "Parameter") { @@ -1004,6 +1016,12 @@ void Model_Objects::synchronizeBackRefsForObject(const std::set& t // iterate new list to compare with current std::set::iterator aNewIter = theNewRefs.begin(); for(; aNewIter != theNewRefs.end(); aNewIter++) { + // for the Model_AttributeRefList erase cash (issue #2819) + std::shared_ptr aRefList = + std::dynamic_pointer_cast(*aNewIter); + if (aRefList) + aRefList->eraseHash(); + if (aData->refsToMe().find(*aNewIter) == aData->refsToMe().end()) { FeaturePtr aRefFeat = std::dynamic_pointer_cast((*aNewIter)->owner()); if (aRefFeat) @@ -1830,6 +1848,10 @@ void Model_Objects::updateResults(FeaturePtr theFeature, std::set& t } } + // it may be on undo + if (!theFeature->data() || !theFeature->data()->isValid() || theFeature->isDisabled()) + return; + // check the existing results and remove them if there is nothing on the label std::list::const_iterator aResIter = theFeature->results().cbegin(); while(aResIter != theFeature->results().cend()) { @@ -1846,9 +1868,6 @@ void Model_Objects::updateResults(FeaturePtr theFeature, std::set& t } aResIter++; } - // it may be on undo - if (!theFeature->data() || !theFeature->data()->isValid() || theFeature->isDisabled()) - return; // check that results are presented on all labels int aResSize = int(theFeature->results().size()); TDF_ChildIterator aLabIter(resultLabel(theFeature->data(), 0).Father()); @@ -1880,7 +1899,9 @@ void Model_Objects::updateResults(FeaturePtr theFeature, std::set& t } else if (aGroup->Get() == ModelAPI_ResultGroup::group().c_str()) { aNewBody = createGroup(theFeature->data(), aResIndex); } else if (aGroup->Get() == ModelAPI_ResultField::group().c_str()) { - aNewBody = createField(theFeature->data(), aResIndex); + ResultFieldPtr aField = createField(theFeature->data(), aResIndex); + aField->updateSteps(); // to refresh the internal data + aNewBody = aField; } else if (aGroup->Get() == ModelAPI_ResultParameter::group().c_str()) { theFeature->attributeChanged("expression"); // just produce a value } else {