X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModel%2FModel_Document.h;h=d82b853f65131b7c4bdb7a7c2a338e6fd50deb81;hb=69290817c24cb8b9d240129d8573b46807a007ef;hp=fc0c0f353ecafde91bbda083e9ec24c1e365aa1a;hpb=bcc91b0593370bf3ab30bae7ba7f510be965587e;p=modules%2Fshaper.git diff --git a/src/Model/Model_Document.h b/src/Model/Model_Document.h index fc0c0f353..d82b853f6 100644 --- a/src/Model/Model_Document.h +++ b/src/Model/Model_Document.h @@ -19,6 +19,7 @@ class Handle_Model_Document; class Model_Objects; +class ModelAPI_AttributeSelectionList; /**\class Model_Document * \ingroup DataModel @@ -73,7 +74,8 @@ class Model_Document : public ModelAPI_Document //! Adds to the document the new feature of the given feature id //! \param theID creates feature and puts it in the document - MODEL_EXPORT virtual FeaturePtr addFeature(std::string theID); + //! \param theMakeCurrent to make current this new feature in this document + MODEL_EXPORT virtual FeaturePtr addFeature(std::string theID, const bool theMakeCurrent = true); //! Return a list of features, which refers to the feature //! \param theFeature a feature @@ -87,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 @@ -105,7 +110,7 @@ class Model_Document : public ModelAPI_Document //! Internal sub-document by ID MODEL_EXPORT virtual std::shared_ptr 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; @@ -132,6 +137,14 @@ class Model_Document : public ModelAPI_Document MODEL_EXPORT virtual void setCurrentFeature(std::shared_ptr 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 internalFeature(const int theIndex); + /// Creates a construction cresults MODEL_EXPORT virtual std::shared_ptr createConstruction( const std::shared_ptr& theFeatureData, const int theIndex = 0); @@ -141,6 +154,10 @@ class Model_Document : public ModelAPI_Document /// Creates a part results MODEL_EXPORT virtual std::shared_ptr createPart( const std::shared_ptr& theFeatureData, const int theIndex = 0); + //! Copies a part result, keeping the reference to origin + MODEL_EXPORT virtual std::shared_ptr copyPart( + const std::shared_ptr& theOrigin, + const std::shared_ptr& theFeatureData, const int theIndex = 0); /// Creates a group results MODEL_EXPORT virtual std::shared_ptr createGroup( const std::shared_ptr& theFeatureData, const int theIndex = 0); @@ -164,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 > 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; @@ -196,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 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 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 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: @@ -225,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 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 myTransactions; - /// list of info about transactions undone (first is oldest undone) + //! list of info about transactions undone (first is oldest undone) std::list myRedos; - /// Optimization for finding the shape-label by topological naming names + //! Optimization for finding the shape-label by topological naming names std::map 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