Salome HOME
Fix for the issue #2753 : error when dump/load script
[modules/shaper.git] / src / Model / Model_Data.h
index 72875fc5a6ef170756c549039bd3b5625b3db6c3..2ed26625f42b0da7b4a12cd01cbaeea42d30e7f5 100644 (file)
@@ -96,6 +96,7 @@ class Model_Data : public ModelAPI_Data
   friend class Model_ValidatorsFactory;
   friend class Model_SelectionNaming;
   friend class Model_ResultConstruction;
+  friend class Model_ResultBody;
 
  public:
   /// The simplest constructor. "setLabel" must be called just after to initialize correctly.
@@ -104,6 +105,8 @@ class Model_Data : public ModelAPI_Data
   MODEL_EXPORT virtual std::string name();
   /// Defines the name of the feature visible by the user in the object browser
   MODEL_EXPORT virtual void setName(const std::string& theName);
+  /// Return \c true if the object has been renamed by the user
+  MODEL_EXPORT virtual bool hasUserDefinedName() const;
   /// Returns the attribute that references to another document
   MODEL_EXPORT virtual std::shared_ptr<ModelAPI_AttributeDocRef> document(const std::string& theID);
   /// Returns the attribute that contains real value with double precision
@@ -169,9 +172,9 @@ class Model_Data : public ModelAPI_Data
   MODEL_EXPORT virtual bool isValid();
 
   /// Returns the label where the shape must be stored (used in ResultBody)
-  TDF_Label& shapeLab()
+  TDF_Label shapeLab() const
   {
-    return myLab;
+    return myLab.IsNull() ? myLab : myLab.Father().FindChild(2);
   }
 
   /// Initializes object by the attributes: must be called just after the object is created
@@ -316,7 +319,7 @@ private:
     else { \
       FolderPtr anAttributeOwnerFolder = std::dynamic_pointer_cast<ModelAPI_Folder>(owner()); \
       if (anAttributeOwnerFolder.get()) \
-        aTargetData->addBackReference(anAttributeOwnerFolder, id()); \
+        aTargetData->addBackReference(ObjectPtr(anAttributeOwnerFolder), id()); \
     } \
   }
 
@@ -332,7 +335,7 @@ private:
     else { \
       FolderPtr anAttributeOwnerFolder = std::dynamic_pointer_cast<ModelAPI_Folder>(owner()); \
       if (anAttributeOwnerFolder.get()) \
-        aTargetData->removeBackReference(anAttributeOwnerFolder, id()); \
+        aTargetData->removeBackReference(ObjectPtr(anAttributeOwnerFolder), id()); \
     } \
   }