1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: PartSetPlugin_Remove.cxx
4 // Created: 20 May 2014
5 // Author: Mikhail PONIKAROV
7 #include "PartSetPlugin_Remove.h"
8 #include "PartSetPlugin_Part.h"
9 #include <ModelAPI_Document.h>
10 #include <ModelAPI_Data.h>
11 #include <ModelAPI_AttributeDocRef.h>
12 #include <ModelAPI_ResultPart.h>
13 #include <ModelAPI_Session.h>
15 void PartSetPlugin_Remove::execute()
17 std::shared_ptr<ModelAPI_Session> aPManager = ModelAPI_Session::get();
18 std::shared_ptr<ModelAPI_Document> aRoot = aPManager->moduleDocument();
19 std::shared_ptr<ModelAPI_Document> aCurrent;
20 std::shared_ptr<PartSetPlugin_Part> a;
21 for (int a = aRoot->size(ModelAPI_ResultPart::group()) - 1; a >= 0; a--) {
22 ResultPartPtr aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(
23 aRoot->object(ModelAPI_ResultPart::group(), a));
25 && aPart->data()->document(ModelAPI_ResultPart::DOC_REF())->value()
26 == aPManager->activeDocument()) {
27 FeaturePtr aFeature = aRoot->feature(aPart);
30 aPart->data()->document(ModelAPI_ResultPart::DOC_REF())->value()->close();
31 aRoot->removeFeature(aFeature);