Salome HOME
Debug of move to the end of history
[modules/shaper.git] / src / Model / Model_AttributeSelection.h
index cafa6ea379ac2cb52855309641faef2eba8e3c79..ed233f85ff0e863f60c70746364a2e33dd1e4d72 100644 (file)
@@ -24,6 +24,7 @@
 #include "Model.h"
 #include "Model_AttributeReference.h"
 #include <ModelAPI_AttributeSelection.h>
+#include <Selector_NameGenerator.h>
 #include <TDF_LabelMap.hxx>
 #include <TopoDS_Shape.hxx>
 #include <TopTools_ListOfShape.hxx>
@@ -35,10 +36,10 @@ class Model_Document;
  * \ingroup DataModel
  * \brief Attribute that contains reference to the sub-shape of some result, the selected shape.
  */
-class Model_AttributeSelection : public ModelAPI_AttributeSelection
+class Model_AttributeSelection : public ModelAPI_AttributeSelection,
+                                 public Selector_NameGenerator
 {
   Model_AttributeReference myRef;  ///< The reference functionality reusage
-  TDF_LabelMap myScope; ///< the map of valid labels for naming selection solving
   /// temporarily storages to avoid keeping in the data structure if not needed
   ResultPtr myTmpContext;
   /// temporarily storages to avoid keeping in the data structure if not needed
@@ -47,6 +48,8 @@ class Model_AttributeSelection : public ModelAPI_AttributeSelection
   CenterType myTmpCenterType;
   /// Reference to the partent attribute, if any (to split selection compounds in issue 1799)
   Model_AttributeSelectionList* myParent;
+
+  std::shared_ptr<Model_Document> myRestoreDocument; // current document to restore by name
 public:
   /// Defines the result and its selected sub-shape
   /// \param theContext object where the sub-shape was selected
@@ -125,6 +128,22 @@ public:
   /// or reorder of features upper in the history line (issue #1757)
   MODEL_EXPORT virtual void updateInHistory();
 
+  /// Returns true if the name was stored using weak naming principle
+  MODEL_EXPORT virtual bool isWeakNaming();
+
+  // Implementation of the name generator method from the Selector package
+  // This method returns the context name by the label of the sub-selected shape
+  MODEL_EXPORT virtual std::string contextName(const TDF_Label theSelectionLab) override;
+
+  /// This method restores by the context and value name the context label and
+  /// sub-label where the value is. Returns true if it is valid.
+  MODEL_EXPORT virtual bool restoreContext(std::string theName,
+    TDF_Label& theContext, TDF_Label& theValue) override;
+
+  /// Returns true if the first result is newer than the second one in the tree of features
+  MODEL_EXPORT virtual bool isLater(const TDF_Label theResult1, const TDF_Label theResult2)
+    const override;
+
 protected:
   /// Objects are created for features automatically
   MODEL_EXPORT Model_AttributeSelection(TDF_Label& theLabel);
@@ -155,9 +174,6 @@ protected:
   /// Note: there must be no attributes stored at the same label because Selector clears this lab
   TDF_Label selectionLabel();
 
-  /// Returns the prepared map of valid labels for naming selection solving (creates if not exists)
-  TDF_LabelMap& scope();
-
   /// Sets the ID of the attribute in Data (called from Data): here it is used for myRef ID setting
   MODEL_EXPORT virtual void setID(const std::string theID);