Salome HOME
Fix for the issue #937 and crashes:
[modules/shaper.git] / src / Model / Model_Document.h
index 586d50a28b8981ee6443a898a4a3c8d84c48a9d4..d82b853f65131b7c4bdb7a7c2a338e6fd50deb81 100644 (file)
@@ -19,6 +19,7 @@
 
 class Handle_Model_Document;
 class Model_Objects;
+class ModelAPI_AttributeSelectionList;
 
 /**\class Model_Document
  * \ingroup DataModel
@@ -88,6 +89,9 @@ class Model_Document : public ModelAPI_Document
   //! \param theFeature a removed feature
   MODEL_EXPORT virtual void removeFeature(FeaturePtr theFeature);
 
+  //! Moves the feature to make it after the given one in the history.
+  MODEL_EXPORT virtual void moveFeature(FeaturePtr theMoved, FeaturePtr theAfterThis);
+
   //! Returns the first found object in the group by the object name
   //! \param theGroupID group that contains an object
   //! \param theName name of the object to search
@@ -106,7 +110,7 @@ class Model_Document : public ModelAPI_Document
   //! Internal sub-document by ID
   MODEL_EXPORT virtual std::shared_ptr<Model_Document> subDoc(std::string theDocID);
 
-  ///! Returns the id of hte document
+  ///! Returns the id of the document
   MODEL_EXPORT virtual const std::string& id() const
   {
     return myID;
@@ -136,6 +140,11 @@ class Model_Document : public ModelAPI_Document
   //! Makes the current feature one feature upper
   MODEL_EXPORT virtual void setCurrentFeatureUp();
 
+  //! Returns the number of all features: in the history or not
+  MODEL_EXPORT virtual int numInternalFeatures();
+  //! Returns the feature by zero-based index: features in the history or not
+  MODEL_EXPORT virtual std::shared_ptr<ModelAPI_Feature> internalFeature(const int theIndex);
+
   /// Creates a construction cresults
   MODEL_EXPORT virtual std::shared_ptr<ModelAPI_ResultConstruction> createConstruction(
       const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0);
@@ -145,6 +154,10 @@ class Model_Document : public ModelAPI_Document
   /// Creates a part results
   MODEL_EXPORT virtual std::shared_ptr<ModelAPI_ResultPart> createPart(
       const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0);
+  //! Copies a part result, keeping the reference to origin
+  MODEL_EXPORT virtual std::shared_ptr<ModelAPI_ResultPart> copyPart(
+    const std::shared_ptr<ModelAPI_ResultPart>& theOrigin,
+    const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0);
   /// Creates a group results
   MODEL_EXPORT virtual std::shared_ptr<ModelAPI_ResultGroup> createGroup(
       const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0);
@@ -182,6 +195,10 @@ class Model_Document : public ModelAPI_Document
   /// Returns true if document is opened and valid
   MODEL_EXPORT virtual bool isOpened();
 
+  /// Returns the last feature in the document (even not visible or disabled)
+  /// \returns null if there is no features
+  FeaturePtr lastFeature();
+
  protected:
   //! Returns (creates if needed) the general label
   TDF_Label generalLabel() const;
@@ -233,6 +250,9 @@ class Model_Document : public ModelAPI_Document
   //! Returns true if this document is currently active
   virtual bool isActive() const;
 
+  //! Returns the selection attribute that is used for calculation of selection externally from the document
+  std::shared_ptr<ModelAPI_AttributeSelectionList> selectionInPartFeature();
+
   friend class Model_Application;
   friend class Model_Session;
   friend class Model_Update;
@@ -240,6 +260,7 @@ class Model_Document : public ModelAPI_Document
   friend class Model_AttributeRefAttr;
   friend class Model_AttributeRefList;
   friend class Model_ResultPart;
+  friend class Model_ResultCompSolid;
   friend class DFBrowser;
 
  private:
@@ -275,6 +296,9 @@ class Model_Document : public ModelAPI_Document
   bool myExecuteFeatures;
 
   bool myIsActive; ///< flag that stores the active/not active state
+
+  //! The selection feature, if needed
+  FeaturePtr mySelectionFeature;
 };
 
 #endif