]> SALOME platform Git repositories - modules/hydro.git/blob - src/HYDROData/HYDROData_Object.h
Salome HOME
1) Show/Hide, Delete operations
[modules/hydro.git] / src / HYDROData / HYDROData_Object.h
1 #ifndef HYDROData_Object_HeaderFile
2 #define HYDROData_Object_HeaderFile
3
4 #include <HYDROData.h>
5
6 #include <NCollection_Sequence.hxx>
7 #include <TDF_Label.hxx>
8 #include <QString>
9
10 ///! Kind of an object in a document
11 typedef int ObjectKind;
12 ///! Unrecognized object
13 const ObjectKind KIND_UNKNOWN = 0;
14 const ObjectKind KIND_IMAGE = 1;
15 const ObjectKind KIND_POLYLINE = 2;
16
17 DEFINE_STANDARD_HANDLE(HYDROData_Object, MMgt_TShared)
18
19 /**\class HYDROData_Object
20  * \brief Generic class of any object in the data model.
21  *
22  * Interface for getting access to the object that belong to the data model.
23  * Managed by Document. Provides access to the common properties: 
24  * kind of an object, name.
25  */
26 class HYDROData_Object : public MMgt_TShared
27 {
28 public:
29   DEFINE_STANDARD_RTTI(HYDROData_Object);
30
31   /**
32    * Returns the kind of this object. Must be redefined in all objects of known type.
33    */
34   HYDRODATA_EXPORT virtual const ObjectKind GetKind() const {return KIND_UNKNOWN;}
35
36   /**
37    * Returns the name of this object.
38    */
39   HYDRODATA_EXPORT QString GetName() const;
40
41   /**
42    * Updates the name of this object.
43    */
44   HYDRODATA_EXPORT void SetName(const QString& theName);
45
46   /**
47    * Returns the object visibility state.
48    * \returns visibility state
49    */
50   HYDRODATA_EXPORT bool GetVisibility() const;
51
52   /**
53    * Sets the object visibility state.
54    * \param theState visibility state
55    */
56   HYDRODATA_EXPORT void SetVisibility(bool theState);
57
58   /**
59    * Checks is object exists in the data structure.
60    * \returns true is object is not exists in the data model
61    */
62   HYDRODATA_EXPORT bool IsRemoved() const;
63
64   /**
65    * Removes object from the data structure.
66    */
67   HYDRODATA_EXPORT void Remove();
68
69   /**
70    * Returns unique integer identifier of the object (may be used for ordering of objects)
71    */
72   HYDRODATA_EXPORT inline int ID() const {return myLab.Tag();}
73
74   /**
75    * Copies all properties of this to the destinated object.
76    * Objects must be the same type.
77    * \param theDestination initialized object (from any document) - target of copying
78    */
79   HYDRODATA_EXPORT void CopyTo(Handle_HYDROData_Object theDestination) const;
80
81   /**
82    * Returns the label of this object.
83    */
84   HYDRODATA_EXPORT TDF_Label& Label() {return myLab;}
85
86 protected:
87
88   friend class HYDROData_Iterator;
89
90   /**
91    * Creates new object in the internal data structure. Use higher level objects 
92    * to create objects with real content.
93    */
94   HYDRODATA_EXPORT HYDROData_Object();
95
96   /**
97    * Destructs properties of the object and object itself, removes it from the document.
98    */
99   virtual HYDRODATA_EXPORT ~HYDROData_Object();
100
101   /**
102    * Put the object to the label of the document.
103    * \param theLabel new label of the object
104    */
105   HYDRODATA_EXPORT virtual void SetLabel(TDF_Label theLabel);
106
107   /**
108    * Internal method that used to store the byte array attribute
109    * \param theTag tag of a label to store attribute (for 0 this is myLab)
110    * \param theData pointer to bytes array
111    * \param theLen number of bytes in byte array that must be stored
112    */
113   void SaveByteArray(const int theTag, const char* theData, const int theLen);
114
115   /**
116    * Internal method that used to retreive the content of byte array attribute
117    * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
118    * \param theLen number of bytes in byte array
119    * \returns pointer to the internal data structure wit harray content, 
120    *          or NULL if array size is zero
121    */
122   const char* ByteArray(const int theTag, int& theLen);
123
124 protected:
125   /// Array of pointers to the properties of this object; index in this array is returned by \a AddProperty.
126   TDF_Label myLab; ///< label of this object
127 };
128
129 typedef NCollection_Sequence<Handle_HYDROData_Object> HYDROData_SequenceOfObjects;
130
131 ///! Is Equal for HYDROData_Object mapping
132 HYDRODATA_EXPORT bool IsEqual(const Handle_HYDROData_Object& theObj1, const Handle_HYDROData_Object& theObj2);
133
134 #endif