Salome HOME
Issue #1662: implementation of Recover feature.
[modules/shaper.git] / src / FeaturesPlugin / FeaturesPlugin_Recover.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
2
3 // File:        FeaturesPlugin_Recover.h
4 // Created:     29 Jul 2016
5 // Author:      Natalia ERMOLAEVA
6
7 #ifndef FEATURESPLUGIN_RECOVER_H_
8 #define FEATURESPLUGIN_RECOVER_H_
9
10 #include "FeaturesPlugin.h"
11 #include <ModelAPI_Feature.h>
12 #include <GeomAPI_Shape.h>
13
14 /**\class FeaturesPlugin_Recover
15  * \ingroup Plugins
16  * \brief Feature for display of concealed attributes of some feature.
17  */
18 class FeaturesPlugin_Recover : public ModelAPI_Feature
19 {
20   /// List of already registered unconcealed pairs of unconcealed result and feature that caused
21   /// concealment. If attributes of this feature were changed, this list helps to synchronise
22   /// the current state with validators.
23   std::set<std::shared_ptr<ModelAPI_Object> > myRegistered;
24   /// The last stored Base to unregister Unconcealed when even attributes are already erased.
25   FeaturePtr myCurrentBase;
26   /// previous state of persistent flag
27   bool myPersistent;
28  public:
29   /// Extrusion kind
30   inline static const std::string& ID()
31   {
32     static const std::string MY_RECOVER_ID("Recover");
33     return MY_RECOVER_ID;
34   }
35   /// Attribute name of base feature.
36   inline static const std::string& BASE_FEATURE()
37   {
38     static const std::string MY_BASE_FEATURE("base_feature");
39     return MY_BASE_FEATURE;
40   }
41
42   /// Attribute name of recovered results list.
43   inline static const std::string& RECOVERED_ENTITIES()
44   {
45     static const std::string MY_RECOVERED_ENTITIES_ID("recovered");
46     return MY_RECOVERED_ENTITIES_ID;
47   }
48
49   /// Attribute name of persistenc concealment flag.
50   inline static const std::string& PERSISTENT()
51   {
52     static const std::string MY_PERSISTENT_ID("persistent");
53     return MY_PERSISTENT_ID;
54   }
55
56   /// Returns the kind of a feature
57   FEATURESPLUGIN_EXPORT virtual const std::string& getKind()
58   {
59     static std::string MY_KIND = FeaturesPlugin_Recover::ID();
60     return MY_KIND;
61   }
62
63   /// Creates a new part document if needed
64   FEATURESPLUGIN_EXPORT virtual void execute();
65
66   /// Request for initialization of data model of the feature: adding all attributes
67   FEATURESPLUGIN_EXPORT virtual void initAttributes();
68
69   /// Use plugin manager for features creation
70   FeaturesPlugin_Recover();
71
72   /// Called on change of any argument-attribute of this object. Needed here for synchronization
73   /// of registered unconcealed.
74   virtual void attributeChanged(const std::string& theID);
75
76   /// Synchronises myRegistered before all attributes are erased
77   virtual void erase();
78
79   /// on unstability of feature, remove all unconcealment effect
80   virtual bool setStable(const bool theFlag);
81   /// on disable of feature, remove all unconcealment effect
82   virtual bool setDisabled(const bool theFlag);
83 private:
84   /// Synchronises registration of unconcealed entities with the attributes values of this feature
85   void synchronizeRegistered();
86
87   /// Returns the base feature of this
88   FeaturePtr baseFeature();
89
90   /// erases all registered cashed values
91   void clearRegistered();
92 };
93
94 #endif