]> SALOME platform Git repositories - modules/shaper.git/blob - src/PartSetPlugin/PartSetPlugin_Part.cpp
Salome HOME
Debug of loading parts
[modules/shaper.git] / src / PartSetPlugin / PartSetPlugin_Part.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        PartSetPlugin_Part.cxx
4 // Created:     27 Mar 2014
5 // Author:      Mikhail PONIKAROV
6
7 #include "PartSetPlugin_Part.h"
8 #include "ModelAPI_Session.h"
9 #include "ModelAPI_Document.h"
10 #include "ModelAPI_Data.h"
11 #include "ModelAPI_AttributeDocRef.h"
12 #include <ModelAPI_ResultPart.h>
13
14 using namespace std;
15
16 PartSetPlugin_Part::PartSetPlugin_Part()
17 {
18 }
19
20 void PartSetPlugin_Part::initAttributes()
21 {  // all is in part result
22 }
23
24 void PartSetPlugin_Part::execute()
25 {
26   ResultPartPtr aResult = std::dynamic_pointer_cast<ModelAPI_ResultPart>(firstResult());
27   if (!aResult) {
28     aResult = document()->createPart(data());
29     setResult(aResult);
30     // do not activate part by simple execution if it is not loaded yet: it must be explicitly
31     // activated for this
32     if (!ModelAPI_Session::get()->isLoadByDemand(aResult->data()->name())) {
33       aResult->activate();
34     }
35   }
36 }
37
38 const std::string& PartSetPlugin_Part::documentToAdd()
39 {
40   // part must be added only to the module document
41   return ModelAPI_Session::get()->moduleDocument()->kind();
42 }