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_Iterator;
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";
22 static const std::string PARTS_GROUP = "Parts";
24 static const std::string SKETCHS_GROUP = "Sketchs";
26 /**\class Model_Document
28 * \brief Document for internal data structure of any object storage.
29 * Document contains all data that must be stored/retrived in the file.
30 * Also it provides acces to this data: open/save, transactions management etc.
32 class ModelAPI_Document
35 //! Loads the OCAF document from the file.
36 //! \param theFileName full name of the file to load
37 //! \param theStudyID identifier of the SALOME study to associate with loaded file
38 //! \returns true if file was loaded successfully
39 MODELAPI_EXPORT virtual bool load(const char* theFileName) = 0;
41 //! Saves the OCAF document to the file.
42 //! \param theFileName full name of the file to store
43 //! \returns true if file was stored successfully
44 MODELAPI_EXPORT virtual bool save(const char* theFileName) = 0;
46 //! Removes document data
47 MODELAPI_EXPORT virtual void close() = 0;
49 //! Starts a new operation (opens a tansaction)
50 MODELAPI_EXPORT virtual void startOperation() = 0;
51 //! Finishes the previously started operation (closes the transaction)
52 MODELAPI_EXPORT virtual void finishOperation() = 0;
53 //! Aborts the operation
54 MODELAPI_EXPORT virtual void abortOperation() = 0;
55 //! Returns true if operation has been started, but not yet finished or aborted
56 MODELAPI_EXPORT virtual bool isOperation() = 0;
57 //! Returns true if document was modified (since creation/opening)
58 MODELAPI_EXPORT virtual bool isModified() = 0;
60 //! Returns True if there are available Undos
61 MODELAPI_EXPORT virtual bool canUndo() = 0;
62 //! Undoes last operation
63 MODELAPI_EXPORT virtual void undo() = 0;
64 //! Returns True if there are available Redos
65 MODELAPI_EXPORT virtual bool canRedo() = 0;
66 //! Redoes last operation
67 MODELAPI_EXPORT virtual void redo() = 0;
69 //! Adds to the document the new feature of the given feature id
70 //! \param creates feature and puts it in the document
71 MODELAPI_EXPORT virtual boost::shared_ptr<ModelAPI_Feature> addFeature(std::string theID) = 0;
73 ///! Adds a new sub-document by the identifier, or returns existing one if it is already exist
74 MODELAPI_EXPORT virtual boost::shared_ptr<ModelAPI_Document> subDocument(std::string theDocID) = 0;
76 ///! Creates an iterator of the features by the specific groups
77 MODELAPI_EXPORT virtual boost::shared_ptr<ModelAPI_Iterator> featuresIterator(
78 const std::string theGroup) = 0;
80 ///! Returns the id of hte document
81 MODELAPI_EXPORT virtual const std::string& id() const = 0;
83 //! Returns the feature in the group by the index (started from zero)
84 MODELAPI_EXPORT virtual boost::shared_ptr<ModelAPI_Feature>
85 feature(const std::string& theGroupID, const int theIndex) = 0;
87 //! Returns the index of feature in the group (zero based)
88 MODELAPI_EXPORT virtual int featureIndex(boost::shared_ptr<ModelAPI_Feature> theFeature) = 0;
90 ///! Returns the vector of groups already added to the document
91 MODELAPI_EXPORT virtual const std::vector<std::string>& getGroups() const = 0;
93 /// To virtually destroy the fields of successors
94 virtual ~ModelAPI_Document() {}
97 /// Only for SWIG wrapping it is here
98 MODELAPI_EXPORT ModelAPI_Document()