Salome HOME
Merge branch 'master' of newgeom:newgeom.git
[modules/shaper.git] / src / PartSetPlugin / PartSetPlugin_Remove.cpp
1 // File:        PartSetPlugin_Remove.cxx
2 // Created:     20 May 2014
3 // Author:      Mikhail PONIKAROV
4
5 #include "PartSetPlugin_Remove.h"
6 #include "PartSetPlugin_Part.h"
7 #include <ModelAPI_Document.h>
8 #include <ModelAPI_Data.h>
9 #include <ModelAPI_AttributeDocRef.h>
10 #include <ModelAPI_ResultPart.h>
11 #include <ModelAPI_Session.h>
12
13 void PartSetPlugin_Remove::execute()
14 {
15   boost::shared_ptr<ModelAPI_Session> aPManager = ModelAPI_Session::get();
16   boost::shared_ptr<ModelAPI_Document> aRoot = aPManager->moduleDocument();
17   boost::shared_ptr<ModelAPI_Document> aCurrent;
18   boost::shared_ptr<PartSetPlugin_Part> a;
19   for (int a = aRoot->size(ModelAPI_ResultPart::group()) - 1; a >= 0; a--) {
20     ResultPartPtr aPart = boost::dynamic_pointer_cast<ModelAPI_ResultPart>(
21         aRoot->object(ModelAPI_ResultPart::group(), a));
22     if (aPart
23         && aPart->data()->document(ModelAPI_ResultPart::DOC_REF())->value()
24             == aPManager->activeDocument()) {
25       FeaturePtr aFeature = aRoot->feature(aPart);
26       if (aFeature) {
27         // do remove
28         aPart->data()->document(ModelAPI_ResultPart::DOC_REF())->value()->close();
29         aRoot->removeFeature(aFeature);
30       }
31     }
32   }
33 }