Salome HOME
Bugfix and set Point to the Construction groups
[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 /// Event ID that model is updated
25 static const char* EVENT_MODEL_UPDATED = "ModelUpdated";
26
27
28 /**\class Model_Document
29  * \ingroup DataModel
30  * \brief Document for internal data structure of any object storage. Corresponds to the SALOME study.
31  * Document contains all data of te SALOME Study specific to this module
32  * that must be written into the HDF file.
33  * Also it provides acces to this data: open/save, transactions management etc.
34  * to provide access to all stored data.
35  */
36 class ModelAPI_Document
37 {
38 public:
39   //! Loads the OCAF document from the file.
40   //! \param theFileName full name of the file to load
41   //! \param theStudyID identifier of the SALOME study to associate with loaded file
42   //! \returns true if file was loaded successfully
43   MODELAPI_EXPORT virtual bool load(const char* theFileName) = 0;
44
45   //! Saves the OCAF document to the file.
46   //! \param theFileName full name of the file to store
47   //! \returns true if file was stored successfully
48   MODELAPI_EXPORT virtual bool save(const char* theFileName) = 0;
49
50   //! Removes document data
51   MODELAPI_EXPORT virtual void close() = 0;
52
53   //! Starts a new operation (opens a tansaction)
54   MODELAPI_EXPORT virtual void startOperation() = 0;
55   //! Finishes the previously started operation (closes the transaction)
56   MODELAPI_EXPORT virtual void finishOperation() = 0;
57   //! Aborts the operation 
58   MODELAPI_EXPORT virtual void abortOperation() = 0;
59   //! Returns true if operation has been started, but not yet finished or aborted
60   MODELAPI_EXPORT virtual bool isOperation() = 0;
61   //! Returns true if document was modified (since creation/opening)
62   MODELAPI_EXPORT virtual bool isModified() = 0;
63
64   //! Returns True if there are available Undos
65   MODELAPI_EXPORT virtual bool canUndo() = 0;
66   //! Undoes last operation
67   MODELAPI_EXPORT virtual void undo() = 0;
68   //! Returns True if there are available Redos
69   MODELAPI_EXPORT virtual bool canRedo() = 0;
70   //! Redoes last operation
71   MODELAPI_EXPORT virtual void redo() = 0;
72
73   //! Adds to the document the new feature of the given group id
74   //! \param theFeature a feature object that will be connected to the document in this method
75   //! \param theGroupID identifier of the groups of object
76   MODELAPI_EXPORT virtual void addFeature(std::shared_ptr<ModelAPI_Feature> theFeature,
77     const std::string theGroupID) = 0;
78
79   ///! Adds a new sub-document by the identifier, or returns existing one if it is already exist
80   MODELAPI_EXPORT virtual std::shared_ptr<ModelAPI_Document> subDocument(std::string theDocID) = 0;
81
82   ///! Creates an iterator of the features by the specific groups
83   MODELAPI_EXPORT virtual std::shared_ptr<ModelAPI_Iterator> featuresIterator(
84     const std::string theGroup) = 0;
85
86   ///! Returns the id of hte document
87   MODELAPI_EXPORT virtual const std::string& id() const = 0;
88
89   //! Returns the feature in the group by the index (started from zero)
90   MODELAPI_EXPORT virtual std::shared_ptr<ModelAPI_Feature> 
91     feature(const std::string& theGroupID, const int theIndex) = 0;
92
93   ///! Returns the vector of groups already added to the document
94   MODELAPI_EXPORT virtual const std::vector<std::string>& getGroups() const = 0;
95
96 protected:
97   /// Only for SWIG wrapping it is here
98   MODELAPI_EXPORT ModelAPI_Document()
99   {
100   }
101   ;
102 };
103
104 #endif