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
11 void PartSetPlugin_Remove::execute()
12 {
13   boost::shared_ptr<ModelAPI_PluginManager> aPManager = ModelAPI_PluginManager::get();
14   boost::shared_ptr<ModelAPI_Document> aRoot = aPManager->rootDocument();
15   boost::shared_ptr<ModelAPI_Document> aCurrent;
16   boost::shared_ptr<PartSetPlugin_Part> a;
17   for(int a = aRoot->size(getGroup()) - 1; a >= 0; a--) {
18     FeaturePtr aFeature = 
19       boost::dynamic_pointer_cast<ModelAPI_Feature>(aRoot->object(ModelAPI_Feature::group(), a));
20     if (aFeature->getKind() == PartSetPlugin_Part::ID()) {
21       boost::shared_ptr<PartSetPlugin_Part> aPart = 
22         boost::static_pointer_cast<PartSetPlugin_Part>(aFeature);
23       if (aPart->data()->docRef(PartSetPlugin_Part::DOC_REF())->value() == aPManager->currentDocument()) {
24         // do remove
25         aPart->data()->docRef(PartSetPlugin_Part::DOC_REF())->value()->close();
26         aRoot->removeFeature(aPart);
27       }
28     }
29   }
30 }