]> SALOME platform Git repositories - modules/shaper.git/blob - src/PartSetPlugin/PartSetPlugin_Remove.cpp
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
12 void PartSetPlugin_Remove::execute()
13 {
14   boost::shared_ptr<ModelAPI_PluginManager> aPManager = ModelAPI_PluginManager::get();
15   boost::shared_ptr<ModelAPI_Document> aRoot = aPManager->rootDocument();
16   boost::shared_ptr<ModelAPI_Document> aCurrent;
17   boost::shared_ptr<PartSetPlugin_Part> a;
18   for(int a = aRoot->size(ModelAPI_Feature::group()) - 1; a >= 0; a--) {
19     FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(
20       aRoot->object(ModelAPI_Feature::group(), a));
21     if (aFeature->getKind() == PartSetPlugin_Part::ID()) {
22       boost::shared_ptr<PartSetPlugin_Part> aPart = 
23         boost::static_pointer_cast<PartSetPlugin_Part>(aFeature);
24       if (aPart && aPart->firstResult() &&
25           aPart->firstResult()->data()->docRef(ModelAPI_ResultPart::DOC_REF())->value() == 
26             aPManager->currentDocument()) {
27         // do remove
28         aPart->firstResult()->data()->docRef(ModelAPI_ResultPart::DOC_REF())->value()->close();
29         aRoot->removeFeature(aPart);
30       }
31     }
32   }
33 }