Salome HOME
Sketch line feature based on points attributes
[modules/shaper.git] / src / Model / Model_Data.h
1 // File:        Model_Data.hxx
2 // Created:     21 Mar 2014
3 // Author:      Mikhail PONIKAROV
4
5 #ifndef Model_Data_HeaderFile
6 #define Model_Data_HeaderFile
7
8 #include "Model.h"
9 #include <ModelAPI_Data.h>
10 #include <TDF_Label.hxx>
11
12 #include <map>
13
14 class ModelAPI_Attribute;
15
16 /**\class Model_Data
17  * \ingroup DataModel
18  * \brief General object of the application that allows
19  * to get/set attributes from the document and compute result of an operation.
20  */
21
22 class Model_Data: public ModelAPI_Data
23 {
24   TDF_Label myLab; ///< label of the feature in the document
25   /// All attributes of the object identified by the attribute ID
26   std::map<std::string, boost::shared_ptr<ModelAPI_Attribute> > myAttrs;
27
28   boost::shared_ptr<ModelAPI_Document> myDoc; ///< document this feature belongs to
29
30   Model_Data();
31
32   TDF_Label label() {return myLab;}
33
34   friend class Model_Document;
35   friend class Model_Iterator;
36
37 public:
38   /// Returns the name of the feature visible by the user in the object browser
39   MODEL_EXPORT virtual std::string getName();
40   /// Defines the name of the feature visible by the user in the object browser
41   MODEL_EXPORT virtual void setName(std::string theName);
42   /// Returns the attribute that references to another document
43   MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_AttributeDocRef> docRef(const std::string theID);
44   /// Returns the attribute that contains real value with double precision
45   MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_AttributeDouble> real(const std::string theID);
46   /// Returns the generic attribute by identifier
47   /// \param theID identifier of the attribute
48   MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Attribute> attribute(const std::string theID);
49
50   /// Initializes object by the attributes: must be called just after the object is created
51   /// for each attribute of the object
52   /// \param theID identifier of the attribute that can be referenced by this ID later
53   /// \param theAttrType type of the created attribute (received from the type method)
54   MODEL_EXPORT virtual void addAttribute(std::string theID, std::string theAttrType);
55
56   /// Returns the document of this data
57   MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Document> document() {return myDoc;}
58
59   /// Puts feature to the document data sub-structure
60   MODEL_EXPORT void setLabel(TDF_Label& theLab);
61
62   /// Sets the document of this data
63   MODEL_EXPORT virtual void setDocument(const boost::shared_ptr<ModelAPI_Document>& theDoc) {myDoc = theDoc;}
64 };
65
66 #endif