]> SALOME platform Git repositories - modules/shaper.git/blob - src/Model/Model_Document.h
Salome HOME
Connection of the feature to the document
[modules/shaper.git] / src / Model / Model_Document.h
1 // File:        Model_Document.cxx
2 // Created:     28 Feb 2014
3 // Author:      Mikhail PONIKAROV
4
5 #ifndef Model_Document_HeaderFile
6 #define Model_Document_HeaderFile
7
8 #include <Model.h>
9 #include <ModelAPI_Document.h>
10 #include <TDocStd_Document.hxx>
11
12 class Handle_Model_Document;
13
14 /**\class Model_Document
15  * \ingroup DataModel
16  * \brief Document for internal data structure of any object storage. Corresponds to the SALOME study.
17  * Document contains all data of te SALOME Study specific to this module
18  * that must be written into the HDF file.
19  * Also it provides acces to this data: open/save, transactions management etc.
20  * to provide access to all stored data.
21  */
22
23 class Model_Document: public TDocStd_Document, public ModelAPI_Document
24 {
25 public:
26
27   DEFINE_STANDARD_RTTI(Model_Document);
28
29   //! Creates new document by the format string of a storage
30   Model_Document(const TCollection_ExtendedString& theStorageFormat);
31   //! Deletes all high-level data, managed this document
32   ~Model_Document();
33
34   //! Loads the OCAF document from the file.
35   //! \param theFileName full name of the file to load
36   //! \param theStudyID identifier of the SALOME study to associate with loaded file
37   //! \returns true if file was loaded successfully
38   MODEL_EXPORT bool Load(const char* theFileName);
39
40   //! Saves the OCAF document to the file.
41   //! \param theFileName full name of the file to store
42   //! \returns true if file was stored successfully
43   MODEL_EXPORT bool Save(const char* theFileName);
44
45   //! Removes document data
46   MODEL_EXPORT void Close();
47
48   //! Starts a new operation (opens a tansaction)
49   MODEL_EXPORT void StartOperation();
50   //! Finishes the previously started operation (closes the transaction)
51   MODEL_EXPORT void FinishOperation();
52   //! Aborts the operation 
53   MODEL_EXPORT void AbortOperation();
54   //! Returns true if operation has been started, but not yet finished or aborted
55   MODEL_EXPORT bool IsOperation();
56   //! Returns true if document was modified (since creation/opening)
57   MODEL_EXPORT bool IsModified();
58
59   //! Returns True if there are available Undos
60   MODEL_EXPORT bool CanUndo();
61   //! Undoes last operation
62   MODEL_EXPORT void Undo();
63   //! Returns True if there are available Redos
64   MODEL_EXPORT bool CanRedo();
65   //! Redoes last operation
66   MODEL_EXPORT void Redo();
67
68   //! Adds to the document the new object of the given group id
69   //! \param theFeature a feature object that will be connected to the document in this method
70   //! \param theGroupID identifier of the groups of objects (must be greater than zero)
71   MODEL_EXPORT virtual void AddObject(boost::shared_ptr<ModelAPI_Feature> theFeature,
72     const int theGroupID);
73
74 protected:
75
76 private:
77   int myTransactionsAfterSave; ///< number of transactions after the last "save" call, used for "IsModified" method
78 };
79
80 // Define handle class 
81 DEFINE_STANDARD_HANDLE(Model_Document, TDocStd_Document)
82
83 #endif