1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
3 // File: FeaturesAPI_Recover.cpp
4 // Created: 07 June 2016
5 // Author: Dmitry Bobylev
7 #include "FeaturesAPI_Recover.h"
9 #include <ModelHighAPI_Dumper.h>
10 #include <ModelHighAPI_Reference.h>
11 #include <ModelHighAPI_Tools.h>
13 //=================================================================================================
14 FeaturesAPI_Recover::FeaturesAPI_Recover(const std::shared_ptr<ModelAPI_Feature>& theFeature)
15 : ModelHighAPI_Interface(theFeature)
20 //=================================================================================================
21 FeaturesAPI_Recover::FeaturesAPI_Recover(const std::shared_ptr<ModelAPI_Feature>& theFeature,
22 const ModelHighAPI_Reference& theBaseFeature,
23 const std::list<ModelHighAPI_Selection>& theRecoveredList, const bool thePersistent)
24 : ModelHighAPI_Interface(theFeature)
27 setBaseFeature(theBaseFeature);
28 setRecoveredList(theRecoveredList);
29 setIsPersistent(thePersistent);
33 //=================================================================================================
34 FeaturesAPI_Recover::~FeaturesAPI_Recover()
37 //=================================================================================================
38 void FeaturesAPI_Recover::setBaseFeature(const ModelHighAPI_Reference& theBaseFeature)
41 fillAttribute(theBaseFeature.feature(), mybaseFeature);
42 // do not need to execute because on attribute changed it does everything anyway
45 //=================================================================================================
46 void FeaturesAPI_Recover::setRecoveredList(const std::list<ModelHighAPI_Selection>& theRecoverList)
48 fillAttribute(theRecoverList, myrecoveredList);
49 // do not need to execute because on attribute changed it does everything anyway
52 //=================================================================================================
53 void FeaturesAPI_Recover::setIsPersistent(bool thePersistent)
55 fillAttribute(thePersistent, myisPersistent);
56 // do not need to execute because on attribute changed it does everything anyway
59 //==================================================================================================
60 void FeaturesAPI_Recover::dump(ModelHighAPI_Dumper& theDumper) const
62 FeaturePtr aBase = feature();
63 const std::string& aDocName = theDumper.name(aBase->document());
65 AttributeReferencePtr anAttrBaseFeature =
66 aBase->reference(FeaturesPlugin_Recover::BASE_FEATURE());
67 AttributeRefListPtr anAttrRecoveredEntities =
68 aBase->reflist(FeaturesPlugin_Recover::RECOVERED_ENTITIES());
69 AttributeBooleanPtr anAttrPersistent = aBase->boolean(FeaturesPlugin_Recover::PERSISTENT());
71 FeaturePtr aFeature = ModelAPI_Feature::feature(anAttrBaseFeature->value());
73 theDumper << aBase << " = model.addRecover(" << aDocName << ", "
74 << aFeature << ", " << anAttrRecoveredEntities << ", "
75 << anAttrPersistent << ")" << std::endl;
78 //=================================================================================================
79 RecoverPtr addRecover(const std::shared_ptr<ModelAPI_Document>& thePart,
80 const ModelHighAPI_Reference& theBaseFeature,
81 const std::list<ModelHighAPI_Selection>& theRecoveredList, const bool thePersistent)
83 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Recover::ID());
84 return RecoverPtr(new FeaturesAPI_Recover(
85 aFeature, theBaseFeature, theRecoveredList, thePersistent));