class Handle_Model_Document;
class Model_Objects;
+class ModelAPI_AttributeSelectionList;
/**\class Model_Document
* \ingroup DataModel
//! Loads the OCAF document from the file.
//! \param theFileName full name of the file to load
+ //! \param theThis the common shared pointer to the document to manage with it later
//! \returns true if file was loaded successfully
- MODEL_EXPORT virtual bool load(const char* theFileName);
+ MODEL_EXPORT virtual bool load(const char* theFileName, DocumentPtr theThis);
//! Saves the OCAF document to the file.
//! \param theFileName full name of the file to store
//! 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
//! \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
//! 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;
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);
/// 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);
//! 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;
//! 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:
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