2 #ifndef HYDROData_Entity_HeaderFile
3 #define HYDROData_Entity_HeaderFile
7 #include <NCollection_Sequence.hxx>
9 #include <TDF_Label.hxx>
17 class Handle(TDataStd_ReferenceList);
18 class Handle_HYDROData_Entity;
20 ///! Kind of an object in a document
21 typedef int ObjectKind;
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_ARTIFICIAL_OBJECT = 19;
43 const ObjectKind KIND_NATURAL_OBJECT = 20;
44 const ObjectKind KIND_DUMMY_3D = 21;
45 const ObjectKind KIND_LAST = KIND_DUMMY_3D;
47 DEFINE_STANDARD_HANDLE(HYDROData_Entity, MMgt_TShared)
49 typedef QMap<QString,Handle(Standard_Transient)> MapOfTreatedObjects;
51 typedef NCollection_Sequence<Handle_HYDROData_Entity> HYDROData_SequenceOfObjects;
54 /**\class HYDROData_Entity
55 * \brief Generic class of any object in the data model.
57 * Interface for getting access to the object that belong to the data model.
58 * Managed by Document. Provides access to the common properties:
59 * kind of an object, name.
61 class HYDROData_Entity : public MMgt_TShared
67 * Enumeration of tags corresponding to the persistent object parameters.
71 DataTag_First = 0 ///< first tag, to reserve
76 DEFINE_STANDARD_RTTI(HYDROData_Entity);
79 * Returns the kind of this object. Must be redefined in all objects of known type.
81 HYDRODATA_EXPORT virtual const ObjectKind GetKind() const { return KIND_UNKNOWN; }
84 * Returns the name of this object.
86 HYDRODATA_EXPORT virtual QString GetName() const;
89 * Updates the name of this object.
91 HYDRODATA_EXPORT virtual void SetName( const QString& theName );
94 * Dump object to Python script representation.
95 * Base implementation returns empty list,
96 * You should reimplement this function in your derived class if it
97 * has Python API and can be imported/exported from/to Python script.
99 HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
102 * Updates object state. Base implementation dose nothing.
104 HYDRODATA_EXPORT virtual void Update();
107 * Returns data of object wrapped to QVariant.
108 * Base implementation returns null value.
110 HYDRODATA_EXPORT virtual QVariant GetDataVariant();
114 * Sets the "MustBeUpdated" flag: if object is depended on updated features.
115 * \param theFlag is true for objects that must be updated, false for up-to-date
117 HYDRODATA_EXPORT virtual void SetToUpdate( bool theFlag );
120 * Returns the "MustBeUpdated" flag: is object data must be updated or not
121 * \returns false if object is up to date
123 HYDRODATA_EXPORT virtual bool IsMustBeUpdated() const;
126 * Returns flag indicating that object is updateble or not.
128 HYDRODATA_EXPORT virtual bool CanBeUpdated() const;
132 * Checks is object exists in the data structure.
133 * \returns true is object is not exists in the data model
135 HYDRODATA_EXPORT bool IsRemoved() const;
138 * Removes object and it child sub-objects from the data structure.
140 HYDRODATA_EXPORT virtual void Remove();
143 * Returns flag indicating that object can be removed or not.
144 * Reimplement this method in class which can't be removed
145 * separately with it parent object.
146 * Base implementaiton returns always TRUE.
148 HYDRODATA_EXPORT virtual bool CanRemove();
151 * Returns unique integer identifier of the object (may be used for ordering of objects)
153 HYDRODATA_EXPORT inline int ID() const { return myLab.Tag(); }
156 * Copies all properties of this to the destinated object.
157 * Objects must be the same type.
158 * \param theDestination initialized object (from any document) - target of copying
160 HYDRODATA_EXPORT void CopyTo( Handle_HYDROData_Entity theDestination ) const;
163 * Returns the label of this object.
165 HYDRODATA_EXPORT TDF_Label& Label() { return myLab; }
169 * Returns father object. For object created under root document label
170 * this method always return NULL object.
172 HYDRODATA_EXPORT virtual Handle(HYDROData_Entity) GetFatherObject() const;
176 * Returns the list of all reference objects of this object.
177 * Base implementation always return empty list.
179 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetAllReferenceObjects() const;
184 friend class HYDROData_Iterator;
187 * Creates new object in the internal data structure. Use higher level objects
188 * to create objects with real content.
190 HYDRODATA_EXPORT HYDROData_Entity();
193 * Destructs properties of the object and object itself, removes it from the document.
195 virtual HYDRODATA_EXPORT ~HYDROData_Entity();
198 * Put the object to the label of the document.
199 * \param theLabel new label of the object
201 HYDRODATA_EXPORT virtual void SetLabel(TDF_Label theLabel);
204 * Internal method that used to store the byte array attribute
205 * \param theTag tag of a label to store attribute (for 0 this is myLab)
206 * \param theData pointer to bytes array
207 * \param theLen number of bytes in byte array that must be stored
209 void SaveByteArray(const int theTag, const char* theData, const int theLen);
212 * Internal method that used to retreive the content of byte array attribute
213 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
214 * \param theLen number of bytes in byte array
215 * \returns pointer to the internal data structure wit harray content,
216 * or NULL if array size is zero
218 const char* ByteArray(const int theTag, int& theLen) const;
221 * Internal method that used to store the reference object label attribute
222 * \param theObj pointer to reference object
223 * \param theTag tag of a label to store attribute (for 0 this is myLab)
225 int NbReferenceObjects( const int theTag = 0 ) const;
228 * Internal method that used to check object for entry into the reference list
229 * \param theObj pointer to reference object
230 * \param theTag tag of a label to store attribute (for 0 this is myLab)
232 bool HasReference( const Handle_HYDROData_Entity& theObj,
233 const int theTag = 0 ) const;
236 * Internal method that used to store the reference object label attribute
237 * \param theObj pointer to reference object
238 * \param theTag tag of a label to store attribute (for 0 this is myLab)
240 void AddReferenceObject( const Handle_HYDROData_Entity& theObj,
241 const int theTag = 0 );
244 * Internal method that used to store the reference object label attribute
245 * \param theObj pointer to reference object
246 * \param theTag tag of a label to store attribute (for 0 this is myLab)
247 * \param theIndex index in the list of references
248 - if more that len then just append it to the end of list
249 - if less than zero then prepend to the list
250 - indexing starts from 0
252 void SetReferenceObject( const Handle_HYDROData_Entity& theObj,
253 const int theTag = 0,
254 const int theIndex = 0 );
257 * Internal method that used to store the reference object label attribute
258 * \param theObj pointer to reference object
259 * \param theTag tag of a label to store attribute (for 0 this is myLab)
260 * \param theBeforeIndex index in the list of references
261 - if more that len then just append it to the end of list
262 - if less than zero then prepend to the list
263 - indexing starts from 0
265 void InsertReferenceObject( const Handle_HYDROData_Entity& theObj,
266 const int theTag = 0,
267 const int theBeforeIndex = 0 );
270 * Internal method that used to store the reference object label attribute
271 * \param theObjects sequence with pointers to reference objects
272 * \param theTag tag of a label to store attribute (for 0 this is myLab)
274 void SetReferenceObjects( const HYDROData_SequenceOfObjects& theObjects,
275 const int theTag = 0 );
278 * Internal method that used to retreive the reference object(s) attribute
279 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
280 * \param theIndex index in the list of references
281 * - indexing starts from 0
282 * \returns pointer to reference object or NULL if label is not set
284 Handle_HYDROData_Entity GetReferenceObject( const int theTag = 0,
285 const int theIndex = 0 ) const;
287 HYDROData_SequenceOfObjects GetReferenceObjects( const int theTag = 0 ) const;
290 * Internal method that used to remove the reference object attribute
291 * \param theRefLabel reference object label to remove
292 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
294 void RemoveReferenceObject( const TDF_Label& theRefLabel, const int theTag = 0 );
297 * Internal method that used to remove the reference object attribute
298 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
299 * \param theIndex index in the list of references
300 * - indexing starts from 0
302 void RemoveReferenceObject( const int theTag = 0, const int theIndex = 0 );
305 * Internal method that used to clear list of the reference objects attribute
306 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
308 void ClearReferenceObjects( const int theTag = 0 );
311 * Internal method that used to store the color attribute
312 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
313 * \param theColor color to save
315 void SetColor( const QColor& theColor, const int theTag = 0 );
318 * Internal method that used to retreive the color attribute
319 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
320 * \param theDefColor default color to return if attribute has not been set before
322 QColor GetColor( const QColor& theDefColor, const int theTag = 0 ) const;
327 void setPythonReferenceObject( MapOfTreatedObjects& theTreatedObjects,
328 QStringList& theScript,
329 const Handle(HYDROData_Entity)& theRefObject,
330 const QString& theMethod ) const;
333 Handle(TDataStd_ReferenceList) getReferenceList( const int theTag,
334 const bool theIsCreate ) const;
338 /// Array of pointers to the properties of this object; index in this array is returned by \a AddProperty.
339 TDF_Label myLab; ///< label of this object
342 ///! Is Equal for HYDROData_Entity mapping
343 HYDRODATA_EXPORT bool IsEqual(const Handle_HYDROData_Entity& theObj1, const Handle_HYDROData_Entity& theObj2);