X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPartSetPlugin%2FPartSetPlugin_Remove.cpp;h=56881ca51238c578361d7126271ac2b3127684bb;hb=refs%2Ftags%2FV_1.2.1;hp=0e09f3a607b7e440cbfe3a49fbfffd25cdbf440a;hpb=91dadfbad133cfb02e4a09adce80ec915d1fc6bd;p=modules%2Fshaper.git diff --git a/src/PartSetPlugin/PartSetPlugin_Remove.cpp b/src/PartSetPlugin/PartSetPlugin_Remove.cpp index 0e09f3a60..56881ca51 100644 --- a/src/PartSetPlugin/PartSetPlugin_Remove.cpp +++ b/src/PartSetPlugin/PartSetPlugin_Remove.cpp @@ -1,3 +1,5 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + // File: PartSetPlugin_Remove.cxx // Created: 20 May 2014 // Author: Mikhail PONIKAROV @@ -7,22 +9,27 @@ #include #include #include +#include +#include +#include void PartSetPlugin_Remove::execute() { - boost::shared_ptr aPManager = ModelAPI_PluginManager::get(); - boost::shared_ptr aRoot = aPManager->rootDocument(); - boost::shared_ptr aCurrent; - boost::shared_ptr a; - for(int a = aRoot->size(getGroup()) - 1; a >= 0; a--) { - FeaturePtr aFeature = aRoot->feature(getGroup(), a, true); - if (aFeature->getKind() == PARTSET_PART_KIND) { - boost::shared_ptr aPart = - boost::static_pointer_cast(aFeature); - if (aPart->data()->docRef(PART_ATTR_DOC_REF)->value() == aPManager->currentDocument()) { + std::shared_ptr aPManager = ModelAPI_Session::get(); + std::shared_ptr aRoot = aPManager->moduleDocument(); + std::shared_ptr a; + for (int a = aRoot->size(ModelAPI_ResultPart::group()) - 1; a >= 0; a--) { + ResultPartPtr aPart = std::dynamic_pointer_cast( + aRoot->object(ModelAPI_ResultPart::group(), a)); + if (aPart && aPart->data()->document(ModelAPI_ResultPart::DOC_REF())->value() == document()) { + FeaturePtr aFeature = aRoot->feature(aPart); + if (aFeature) { // do remove - aPart->data()->docRef(PART_ATTR_DOC_REF)->value()->close(); - aRoot->removeFeature(aPart); + aPart->data()->document(ModelAPI_ResultPart::DOC_REF())->value()->close(); + std::set > aRefFeatures; + aRoot->refsToFeature(aFeature, aRefFeatures); + if (aRefFeatures.empty()) + aRoot->removeFeature(aFeature); } } }