]> SALOME platform Git repositories - modules/shaper.git/blob - src/ModelAPI/ModelAPI_Document.h
Salome HOME
9f5f838e92457f1f0daba8fd311aae840744922c
[modules/shaper.git] / src / ModelAPI / ModelAPI_Document.h
1 // File:        ModelAPI_Document.cxx
2 // Created:     28 Feb 2014
3 // Author:      Mikhail PONIKAROV
4
5 #ifndef ModelAPI_Document_HeaderFile
6 #define ModelAPI_Document_HeaderFile
7
8 #include <ModelAPI.h>
9 #include <string>
10 #include <memory>
11 #include <vector>
12
13 class ModelAPI_Feature;
14 class ModelAPI_Iterator;
15
16 /// Common groups identifiers
17 /// Group of parameters
18 static const std::string PARAMETERS_GROUP = "Parameters";
19 /// Group of constructions
20 static const std::string CONSTRUCTIONS_GROUP = "Construction";
21 /// Group of parts
22 static const std::string PARTS_GROUP = "Parts";
23
24 /**\class Model_Document
25  * \ingroup DataModel
26  * \brief Document for internal data structure of any object storage.
27  * Document contains all data that must be stored/retrived in the file.
28  * Also it provides acces to this data: open/save, transactions management etc.
29  */
30 class ModelAPI_Document
31 {
32 public:
33   //! Loads the OCAF document from the file.
34   //! \param theFileName full name of the file to load
35   //! \param theStudyID identifier of the SALOME study to associate with loaded file
36   //! \returns true if file was loaded successfully
37   MODELAPI_EXPORT virtual bool load(const char* theFileName) = 0;
38
39   //! Saves the OCAF document to the file.
40   //! \param theFileName full name of the file to store
41   //! \returns true if file was stored successfully
42   MODELAPI_EXPORT virtual bool save(const char* theFileName) = 0;
43
44   //! Removes document data
45   MODELAPI_EXPORT virtual void close() = 0;
46
47   //! Starts a new operation (opens a tansaction)
48   MODELAPI_EXPORT virtual void startOperation() = 0;
49   //! Finishes the previously started operation (closes the transaction)
50   MODELAPI_EXPORT virtual void finishOperation() = 0;
51   //! Aborts the operation 
52   MODELAPI_EXPORT virtual void abortOperation() = 0;
53   //! Returns true if operation has been started, but not yet finished or aborted
54   MODELAPI_EXPORT virtual bool isOperation() = 0;
55   //! Returns true if document was modified (since creation/opening)
56   MODELAPI_EXPORT virtual bool isModified() = 0;
57
58   //! Returns True if there are available Undos
59   MODELAPI_EXPORT virtual bool canUndo() = 0;
60   //! Undoes last operation
61   MODELAPI_EXPORT virtual void undo() = 0;
62   //! Returns True if there are available Redos
63   MODELAPI_EXPORT virtual bool canRedo() = 0;
64   //! Redoes last operation
65   MODELAPI_EXPORT virtual void redo() = 0;
66
67   //! Adds to the document the new feature of the given feature id
68   //! \param creates feature and puts it in the document
69   MODELAPI_EXPORT virtual std::shared_ptr<ModelAPI_Feature> addFeature(std::string theID) = 0;
70
71   ///! Adds a new sub-document by the identifier, or returns existing one if it is already exist
72   MODELAPI_EXPORT virtual std::shared_ptr<ModelAPI_Document> subDocument(std::string theDocID) = 0;
73
74   ///! Creates an iterator of the features by the specific groups
75   MODELAPI_EXPORT virtual std::shared_ptr<ModelAPI_Iterator> featuresIterator(
76     const std::string theGroup) = 0;
77
78   ///! Returns the id of hte document
79   MODELAPI_EXPORT virtual const std::string& id() const = 0;
80
81   //! Returns the feature in the group by the index (started from zero)
82   MODELAPI_EXPORT virtual std::shared_ptr<ModelAPI_Feature> 
83     feature(const std::string& theGroupID, const int theIndex) = 0;
84
85   //! Returns the index of feature in the group (zero based)
86   MODELAPI_EXPORT virtual int featureIndex(std::shared_ptr<ModelAPI_Feature> theFeature) = 0;
87
88   ///! Returns the vector of groups already added to the document
89   MODELAPI_EXPORT virtual const std::vector<std::string>& getGroups() const = 0;
90
91   /// To virtually destroy the fields of successors
92   virtual ~ModelAPI_Document() {}
93
94 protected:
95   /// Only for SWIG wrapping it is here
96   MODELAPI_EXPORT ModelAPI_Document()
97   {}
98 };
99
100 #endif