]> SALOME platform Git repositories - modules/hydro.git/blob - src/HYDROData/HYDROData_Entity.h
Salome HOME
Empty classes for all geometry objects has been added.
[modules/hydro.git] / src / HYDROData / HYDROData_Entity.h
1
2 #ifndef HYDROData_Entity_HeaderFile
3 #define HYDROData_Entity_HeaderFile
4
5 #include "HYDROData.h"
6
7 #include <NCollection_Sequence.hxx>
8
9 #include <TDF_Label.hxx>
10
11 #include <QMap>
12
13 class QColor;
14 class QString;
15 class QVariant;
16 class QStringList;
17 class Handle(TDataStd_ReferenceList);
18 class Handle_HYDROData_Entity;
19
20 ///! Kind of an object in a document
21 typedef int ObjectKind;
22
23 const ObjectKind KIND_UNKNOWN         = 0; ///! Unrecognized object
24 const ObjectKind KIND_IMAGE           = 1;
25 const ObjectKind KIND_POLYLINE        = 2;
26 const ObjectKind KIND_BATHYMETRY      = 3;
27 const ObjectKind KIND_ALTITUDE        = 4;
28 const ObjectKind KIND_IMMERSIBLE_ZONE = 5;
29 const ObjectKind KIND_RIVER           = 6;
30 const ObjectKind KIND_STREAM          = 7;
31 const ObjectKind KIND_CONFLUENCE      = 8;
32 const ObjectKind KIND_CHANNEL         = 9;
33 const ObjectKind KIND_OBSTACLE        = 10;
34 const ObjectKind KIND_DIGUE           = 11;
35 const ObjectKind KIND_PROFILE         = 12;
36 const ObjectKind KIND_PROFILEUZ       = 13;
37 const ObjectKind KIND_POLYLINEXY      = 14;
38 const ObjectKind KIND_CALCULATION     = 15;
39 const ObjectKind KIND_ZONE            = 16;
40 const ObjectKind KIND_REGION          = 17;
41 const ObjectKind KIND_VISUAL_STATE    = 18;
42 const ObjectKind KIND_LAST            = KIND_VISUAL_STATE;
43
44 DEFINE_STANDARD_HANDLE(HYDROData_Entity, MMgt_TShared)
45
46 typedef QMap<QString,Handle(Standard_Transient)> MapOfTreatedObjects;
47
48 typedef NCollection_Sequence<Handle_HYDROData_Entity> HYDROData_SequenceOfObjects;
49
50
51 /**\class HYDROData_Entity
52  * \brief Generic class of any object in the data model.
53  *
54  * Interface for getting access to the object that belong to the data model.
55  * Managed by Document. Provides access to the common properties: 
56  * kind of an object, name.
57  */
58 class HYDROData_Entity : public MMgt_TShared
59 {
60
61 protected:
62
63   /**
64    * Enumeration of tags corresponding to the persistent object parameters.
65    */
66   enum DataTag
67   {
68     DataTag_First = 0     ///< first tag, to reserve
69     // ...
70   };
71
72   /**
73    * Enumeration of tags corresponding to the child sub-objects of object.
74    */
75   enum ChildTag
76   {
77     ChildTag_First = 0    ///< first tag, to reserve
78     // ...
79   };
80
81 public:
82   DEFINE_STANDARD_RTTI(HYDROData_Entity);
83
84   /**
85    * Returns the kind of this object. Must be redefined in all objects of known type.
86    */
87   HYDRODATA_EXPORT virtual const ObjectKind GetKind() const { return KIND_UNKNOWN; }
88
89   /**
90    * Returns the name of this object.
91    */
92   HYDRODATA_EXPORT QString GetName() const;
93
94   /**
95    * Updates the name of this object.
96    */
97   HYDRODATA_EXPORT void SetName(const QString& theName);
98
99   /**
100    * Dump object to Python script representation.
101    * Base implementation returns empty list,
102    * You should reimplement this function in your derived class if it
103    * has Python API and can be imported/exported from/to Python script.
104    */
105   HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
106
107   /**
108    * Updates object state.
109    * Base implementation dose nothing.
110    * \param theIsForce force reupdating of data object
111    */
112   HYDRODATA_EXPORT virtual void Update( const bool theIsForce = true );
113
114   /**
115    * Returns data of object wrapped to QVariant.
116    * Base implementation returns null value.
117    */
118   HYDRODATA_EXPORT virtual QVariant GetDataVariant();
119
120   /**
121    * Checks is object exists in the data structure.
122    * \returns true is object is not exists in the data model
123    */
124   HYDRODATA_EXPORT bool IsRemoved() const;
125
126   /**
127    * Removes object and it child sub-objects from the data structure.
128    */
129   HYDRODATA_EXPORT virtual void Remove();
130
131   /**
132    * Returns unique integer identifier of the object (may be used for ordering of objects)
133    */
134   HYDRODATA_EXPORT inline int ID() const {return myLab.Tag();}
135
136   /**
137    * Copies all properties of this to the destinated object.
138    * Objects must be the same type.
139    * \param theDestination initialized object (from any document) - target of copying
140    */
141   HYDRODATA_EXPORT void CopyTo(Handle_HYDROData_Entity theDestination) const;
142
143   /**
144    * Returns the label of this object.
145    */
146   HYDRODATA_EXPORT TDF_Label& Label() {return myLab;}
147
148   /**
149    * Returns father object. For object created under root document label
150    * this method always return NULL object.
151    */
152   HYDRODATA_EXPORT virtual Handle(HYDROData_Entity) GetFatherObject() const;
153
154 protected:
155
156   friend class HYDROData_Iterator;
157
158   /**
159    * Creates new object in the internal data structure. Use higher level objects 
160    * to create objects with real content.
161    */
162   HYDRODATA_EXPORT HYDROData_Entity();
163
164   /**
165    * Destructs properties of the object and object itself, removes it from the document.
166    */
167   virtual HYDRODATA_EXPORT ~HYDROData_Entity();
168
169   /**
170    * Put the object to the label of the document.
171    * \param theLabel new label of the object
172    */
173   HYDRODATA_EXPORT virtual void SetLabel(TDF_Label theLabel);
174
175   /**
176    * Internal method that used to store the byte array attribute
177    * \param theTag tag of a label to store attribute (for 0 this is myLab)
178    * \param theData pointer to bytes array
179    * \param theLen number of bytes in byte array that must be stored
180    */
181   void SaveByteArray(const int theTag, const char* theData, const int theLen);
182
183   /**
184    * Internal method that used to retreive the content of byte array attribute
185    * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
186    * \param theLen number of bytes in byte array
187    * \returns pointer to the internal data structure wit harray content, 
188    *          or NULL if array size is zero
189    */
190   const char* ByteArray(const int theTag, int& theLen) const;
191
192   /**
193    * Internal method that used to store the reference object label attribute
194    * \param theObj pointer to reference object
195    * \param theTag tag of a label to store attribute (for 0 this is myLab)
196    */
197   int NbReferenceObjects( const int theTag = 0 ) const;
198
199   /**
200    * Internal method that used to check object for entry into the reference list
201    * \param theObj pointer to reference object
202    * \param theTag tag of a label to store attribute (for 0 this is myLab)
203    */
204   bool HasReference( const Handle_HYDROData_Entity& theObj,
205                      const int                      theTag = 0 ) const;
206
207   /**
208    * Internal method that used to store the reference object label attribute
209    * \param theObj pointer to reference object
210    * \param theTag tag of a label to store attribute (for 0 this is myLab)
211    */
212   void AddReferenceObject( const Handle_HYDROData_Entity& theObj,
213                            const int                      theTag = 0 );
214
215   /**
216    * Internal method that used to store the reference object label attribute
217    * \param theObj pointer to reference object
218    * \param theTag tag of a label to store attribute (for 0 this is myLab)
219    * \param theIndex index in the list of references 
220              - if more that len then just append it to the end of list
221              - if less than zero then prepend to the list
222              - indexing starts from 0
223    */
224   void SetReferenceObject( const Handle_HYDROData_Entity& theObj,
225                            const int                      theTag = 0,
226                            const int                      theIndex = 0 );
227
228   /**
229    * Internal method that used to store the reference object label attribute
230    * \param theObj pointer to reference object
231    * \param theTag tag of a label to store attribute (for 0 this is myLab)
232    * \param theBeforeIndex index in the list of references 
233              - if more that len then just append it to the end of list
234              - if less than zero then prepend to the list
235              - indexing starts from 0
236    */
237   void InsertReferenceObject( const Handle_HYDROData_Entity& theObj,
238                               const int                      theTag = 0,
239                               const int                      theBeforeIndex = 0 );
240
241   /**
242    * Internal method that used to store the reference object label attribute
243    * \param theObjects sequence with pointers to reference objects
244    * \param theTag tag of a label to store attribute (for 0 this is myLab)
245    */
246   void SetReferenceObjects( const HYDROData_SequenceOfObjects& theObjects,
247                             const int                          theTag = 0 );
248
249   /**
250    * Internal method that used to retreive the reference object(s) attribute
251    * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
252    * \param theIndex index in the list of references 
253    *        - indexing starts from 0
254    * \returns pointer to reference object or NULL if label is not set
255    */
256   Handle_HYDROData_Entity GetReferenceObject( const int theTag   = 0,
257                                               const int theIndex = 0 ) const;
258
259   HYDROData_SequenceOfObjects GetReferenceObjects( const int theTag = 0 ) const;
260
261   /**
262    * Internal method that used to remove the reference object attribute
263    * \param theRefLabel reference object label to remove
264    * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
265    */
266   void RemoveReferenceObject( const TDF_Label& theRefLabel, const int theTag = 0 );
267
268   /**
269    * Internal method that used to remove the reference object attribute
270    * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
271    * \param theIndex index in the list of references 
272    *        - indexing starts from 0
273    */
274   void RemoveReferenceObject( const int theTag = 0, const int theIndex = 0 );
275
276   /**
277    * Internal method that used to clear list of the reference objects attribute
278    * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
279    */
280   void ClearReferenceObjects( const int theTag = 0 );
281
282   /**
283    * Internal method that used to store the color attribute
284    * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
285    * \param theColor color to save
286    */
287   void SetColor( const QColor& theColor, const int theTag = 0 );
288
289   /**
290    * Internal method that used to retreive the color attribute
291    * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
292    * \param theDefColor default color to return if attribute has not been set before
293    */
294   QColor GetColor( const QColor& theDefColor, const int theTag = 0 ) const;
295
296  
297 protected:
298
299   void setPythonReferenceObject( MapOfTreatedObjects&            theTreatedObjects,
300                                  QStringList&                    theScript,
301                                  const Handle(HYDROData_Entity)& theRefObject,
302                                  const QString&                  theMethod ) const;
303 protected:
304
305   Handle(TDataStd_ReferenceList) getReferenceList( const int  theTag,
306                                                    const bool theIsCreate ) const;
307
308
309 protected:
310   /// Array of pointers to the properties of this object; index in this array is returned by \a AddProperty.
311   TDF_Label myLab; ///< label of this object
312 };
313
314 ///! Is Equal for HYDROData_Entity mapping
315 HYDRODATA_EXPORT bool IsEqual(const Handle_HYDROData_Entity& theObj1, const Handle_HYDROData_Entity& theObj2);
316
317 #endif