Salome HOME
Issue #1662: implementation of Recover feature.
[modules/shaper.git] / src / FeaturesAPI / FeaturesAPI_Recover.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
2
3 // File:        FeaturesAPI_Recover.cpp
4 // Created:     07 June 2016
5 // Author:      Dmitry Bobylev
6
7 #include "FeaturesAPI_Recover.h"
8
9 #include <ModelHighAPI_Reference.h>
10 #include <ModelHighAPI_Tools.h>
11
12 FeaturesAPI_Recover::FeaturesAPI_Recover(const std::shared_ptr<ModelAPI_Feature>& theFeature)
13 : ModelHighAPI_Interface(theFeature)
14 {
15   initialize();
16 }
17
18 FeaturesAPI_Recover::FeaturesAPI_Recover(const std::shared_ptr<ModelAPI_Feature>& theFeature,
19   const ModelHighAPI_Reference& theBaseFeature,
20   const std::list<ModelHighAPI_Selection>& theRecoveredList, const bool thePersistent)
21 : ModelHighAPI_Interface(theFeature)
22 {
23   if(initialize()) {
24     setBaseFeature(theBaseFeature);
25     setRecoveredList(theRecoveredList);
26     setIsPersistent(thePersistent);
27   }
28 }
29
30 FeaturesAPI_Recover::~FeaturesAPI_Recover()
31 {}
32
33 void FeaturesAPI_Recover::setBaseFeature(const ModelHighAPI_Reference& theBaseFeature)
34 {
35   fillAttribute(theBaseFeature, mybaseFeature);
36   // do not need to execute because on attribute changed it does everything anyway
37 }
38
39 void FeaturesAPI_Recover::setRecoveredList(const std::list<ModelHighAPI_Selection>& theRecoverList)
40 {
41   fillAttribute(theRecoverList, myrecoveredList);
42   // do not need to execute because on attribute changed it does everything anyway
43 }
44
45 void FeaturesAPI_Recover::setIsPersistent(bool thePersistent)
46 {
47   fillAttribute(thePersistent, myisPersistent);
48   // do not need to execute because on attribute changed it does everything anyway
49 }
50
51 RecoverPtr addRecover(const std::shared_ptr<ModelAPI_Document>& thePart,
52   const ModelHighAPI_Reference& theBaseFeature,
53   const std::list<ModelHighAPI_Selection>& theRecoveredList, const bool thePersistent)
54 {
55   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Recover::ID());
56   return RecoverPtr(new FeaturesAPI_Recover(
57     aFeature, theBaseFeature, theRecoveredList, thePersistent));
58 }