]> SALOME platform Git repositories - modules/shaper.git/blob - src/PartSetPlugin/PartSetPlugin_Remove.cpp
Salome HOME
Merge branch 'Dev_0.6.1' of newgeom:newgeom into Dev_0.6.1
[modules/shaper.git] / src / PartSetPlugin / PartSetPlugin_Remove.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        PartSetPlugin_Remove.cxx
4 // Created:     20 May 2014
5 // Author:      Mikhail PONIKAROV
6
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>
14
15 void PartSetPlugin_Remove::execute()
16 {
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));
24     if (aPart
25         && aPart->data()->document(ModelAPI_ResultPart::DOC_REF())->value()
26             == aPManager->activeDocument()) {
27       FeaturePtr aFeature = aRoot->feature(aPart);
28       if (aFeature) {
29         // do remove
30         aPart->data()->document(ModelAPI_ResultPart::DOC_REF())->value()->close();
31         aRoot->removeFeature(aFeature);
32       }
33     }
34   }
35 }