1 // File: ModelAPI_Document.cxx
2 // Created: 28 Feb 2014
3 // Author: Mikhail PONIKAROV
5 #ifndef ModelAPI_Document_HeaderFile
6 #define ModelAPI_Document_HeaderFile
10 #include <boost/shared_ptr.hpp>
13 class ModelAPI_Feature;
14 class ModelAPI_Object;
15 class ModelAPI_Result;
16 class ModelAPI_ResultConstruction;
18 /// Common groups identifiers
19 /// Group of parameters
20 static const std::string PARAMETERS_GROUP = "Parameters";
21 /// Group of constructions
22 static const std::string CONSTRUCTIONS_GROUP = "Construction";
24 static const std::string PARTS_GROUP = "Parts";
26 static const std::string BODIES_GROUP = "Bodies";
27 /// All created fetaures of the document (a history)
28 static const std::string FEATURES_GROUP = "Features";
30 /**\class Model_Document
32 * \brief Document for internal data structure of any object storage.
33 * Document contains all data that must be stored/retrived in the file.
34 * Also it provides acces to this data: open/save, transactions management etc.
36 class ModelAPI_Document
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 virtual bool load(const char* theFileName) = 0;
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 virtual bool save(const char* theFileName) = 0;
50 //! Removes document data
51 virtual void close() = 0;
53 //! Starts a new operation (opens a tansaction)
54 virtual void startOperation() = 0;
55 //! Finishes the previously started operation (closes the transaction)
56 virtual void finishOperation() = 0;
57 //! Aborts the operation
58 virtual void abortOperation() = 0;
59 //! Returns true if operation has been started, but not yet finished or aborted
60 virtual bool isOperation() = 0;
61 //! Returns true if document was modified (since creation/opening)
62 virtual bool isModified() = 0;
64 //! Returns True if there are available Undos
65 virtual bool canUndo() = 0;
66 //! Undoes last operation
67 virtual void undo() = 0;
68 //! Returns True if there are available Redos
69 virtual bool canRedo() = 0;
70 //! Redoes last operation
71 virtual void redo() = 0;
73 //! Adds to the document the new feature of the given feature id
74 //! \param creates feature and puts it in the document (if it is not action)
75 virtual boost::shared_ptr<ModelAPI_Feature> addFeature(std::string theID) = 0;
77 //! Removes the feature from the document
78 virtual void removeFeature(boost::shared_ptr<ModelAPI_Feature> theFeature) = 0;
80 ///! Adds a new sub-document by the identifier, or returns existing one if it is already exist
81 virtual boost::shared_ptr<ModelAPI_Document>
82 subDocument(std::string theDocID) = 0;
84 ///! Returns the id of the document
85 virtual const std::string& id() const = 0;
87 //! Returns the object in the group by the index (started from zero)
88 //! \param theGroupID group that contains an object
89 //! \param theIndex zero-based index of feature in the group
90 virtual boost::shared_ptr<ModelAPI_Object>
91 object(const std::string& theGroupID, const int theIndex) = 0;
93 //! Returns the number of objects in the group of objects
94 virtual int size(const std::string& theGroupID) = 0;
96 /// To virtually destroy the fields of successors
97 virtual ~ModelAPI_Document() {}
99 /// Creates a construction cresults
100 virtual boost::shared_ptr<ModelAPI_ResultConstruction> createConstruction() = 0;
103 /// Only for SWIG wrapping it is here
104 MODELAPI_EXPORT ModelAPI_Document()
109 //! Pointer on document object
110 typedef boost::shared_ptr<ModelAPI_Document> DocumentPtr;