Salome HOME
FIx for the issue #951
[modules/shaper.git] / src / Model / Model_Document.h
index 127934e03f201519a994a428b089d96876634b1b..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;
@@ -133,6 +137,14 @@ class Model_Document : public ModelAPI_Document
   MODEL_EXPORT virtual void setCurrentFeature(std::shared_ptr<ModelAPI_Feature> theCurrent,
     const bool theVisible);
 
+  //! 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);
@@ -142,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);
@@ -165,6 +181,24 @@ class Model_Document : public ModelAPI_Document
   //! selection by name.
   ResultPtr findByName(const std::string theName);
 
+  ///! Returns all features of the document including the hidden features which are not in
+  ///! history. Not very fast method, for calling once, not in big cycles.
+  MODEL_EXPORT virtual std::list<std::shared_ptr<ModelAPI_Feature> > allFeatures();
+
+  /// Returns the global identifier of the current transaction (needed for the update algo)
+  MODEL_EXPORT virtual int transactionID();
+  /// Increases the transaction ID
+  MODEL_EXPORT virtual void incrementTransactionID();
+  /// Decreases the transaction ID
+  MODEL_EXPORT virtual void decrementTransactionID();
+
+  /// 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;
@@ -197,26 +231,36 @@ class Model_Document : public ModelAPI_Document
   //! Returns the list of Ids of the operations that can be redoed (called for the root document)
   std::list<std::string> redoList() const;
 
-  /// Internally makes document know that feature was removed or added in history after creation
+  //! Internally makes document know that feature was removed or added in history after creation
   virtual void updateHistory(const std::shared_ptr<ModelAPI_Object> theObject);
-  /// Internally makes document know that feature was removed or added in history after creation
+  //! Internally makes document know that feature was removed or added in history after creation
   virtual void updateHistory(const std::string theGroup);
 
-  /// Returns true if the document is root module document
+  //! Returns true if the document is root module document
   bool isRoot() const;
 
-  /// Sets shared pointer to this
+  //! Sets shared pointer to this
   void setThis(DocumentPtr theDoc);
 
-  /// Returns the objects manager
+  //! Returns the objects manager
   Model_Objects* objects() {return myObjs;}
 
+  ///! Informs the document that it becomes active and some actions must be performed
+  virtual void setActive(const bool theFlag);
+  //! 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;
   friend class Model_AttributeReference;
   friend class Model_AttributeRefAttr;
   friend class Model_AttributeRefList;
+  friend class Model_ResultPart;
+  friend class Model_ResultCompSolid;
   friend class DFBrowser;
 
  private:
@@ -226,30 +270,35 @@ class Model_Document : public ModelAPI_Document
 
   Model_Objects *myObjs; ///< data manager of this document
 
-  /// counter value of transaction on the last "save" call, used for "IsModified" method
+  //! counter value of transaction on the last "save" call, used for "IsModified" method
   int myTransactionSave;
-  /// number of nested transactions performed (list becasue may be nested inside of nested)
-  /// the list is empty if not nested transaction is performed
+  //! number of nested transactions performed (list becasue may be nested inside of nested)
+  //! the list is empty if not nested transaction is performed
   std::list<int> myNestedNum;
 
-  /// Information related to the every user-transaction
+  //! Information related to the every user-transaction
   struct Transaction {
     int myOCAFNum; ///< number of OCAF transactions related to each "this" transaction, may be 0
     std::string myId; ///< user-identifier string of transaction
-    /// default constructor with default Id
+    //! default constructor with default Id
     Transaction(): myOCAFNum(0), myId("") {}
   };
 
-  /// transaction indexes (related to myTransactionsAfterSave) and info about the real transactions
-  /// in myDocument connected to this operation (may be zero for empty transaction)
+  //! transaction indexes (related to myTransactionsAfterSave) and info about the real transactions
+  //! in myDocument connected to this operation (may be zero for empty transaction)
   std::list<Transaction> myTransactions;
-  /// list of info about transactions undone (first is oldest undone)
+  //! list of info about transactions undone (first is oldest undone)
   std::list<Transaction> myRedos;
 
-  /// Optimization for finding the shape-label by topological naming names
+  //! Optimization for finding the shape-label by topological naming names
   std::map<std::string, TDF_Label> myNamingNames;
-  /// If it is true, features are not executed on update (on abort, undo, redo)
+  //! If it is true, features are not executed on update (on abort, undo, redo)
   bool myExecuteFeatures;
+
+  bool myIsActive; ///< flag that stores the active/not active state
+
+  //! The selection feature, if needed
+  FeaturePtr mySelectionFeature;
 };
 
 #endif