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_EDGES_GROUP = 22;
46 const ObjectKind KIND_SPLITTED_GROUP = 23;
47 const ObjectKind KIND_LAST = KIND_SPLITTED_GROUP;
49 DEFINE_STANDARD_HANDLE(HYDROData_Entity, MMgt_TShared)
51 typedef QMap<QString,Handle(Standard_Transient)> MapOfTreatedObjects;
53 typedef NCollection_Sequence<Handle_HYDROData_Entity> HYDROData_SequenceOfObjects;
56 /**\class HYDROData_Entity
57 * \brief Generic class of any object in the data model.
59 * Interface for getting access to the object that belong to the data model.
60 * Managed by Document. Provides access to the common properties:
61 * kind of an object, name.
63 class HYDROData_Entity : public MMgt_TShared
69 * Enumeration of tags corresponding to the persistent object parameters.
73 DataTag_First = 0 ///< first tag, to reserve
78 DEFINE_STANDARD_RTTI(HYDROData_Entity);
81 * Returns the kind of this object. Must be redefined in all objects of known type.
83 HYDRODATA_EXPORT virtual const ObjectKind GetKind() const { return KIND_UNKNOWN; }
86 * Returns the name of this object.
88 HYDRODATA_EXPORT virtual QString GetName() const;
91 * Updates the name of this object.
93 HYDRODATA_EXPORT virtual void SetName( const QString& theName );
96 * Dump object to Python script representation.
97 * Base implementation returns empty list,
98 * You should reimplement this function in your derived class if it
99 * has Python API and can be imported/exported from/to Python script.
101 HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
104 * Updates object state. Base implementation dose nothing.
106 HYDRODATA_EXPORT virtual void Update();
109 * Returns data of object wrapped to QVariant.
110 * Base implementation returns null value.
112 HYDRODATA_EXPORT virtual QVariant GetDataVariant();
116 * Sets the "MustBeUpdated" flag: if object is depended on updated features.
117 * \param theFlag is true for objects that must be updated, false for up-to-date
119 HYDRODATA_EXPORT virtual void SetToUpdate( bool theFlag );
122 * Returns the "MustBeUpdated" flag: is object data must be updated or not
123 * \returns false if object is up to date
125 HYDRODATA_EXPORT virtual bool IsMustBeUpdated() const;
128 * Returns flag indicating that object is updateble or not.
130 HYDRODATA_EXPORT virtual bool CanBeUpdated() const;
134 * Checks is object exists in the data structure.
135 * \returns true is object is not exists in the data model
137 HYDRODATA_EXPORT bool IsRemoved() const;
140 * Removes object and it child sub-objects from the data structure.
142 HYDRODATA_EXPORT virtual void Remove();
145 * Returns flag indicating that object can be removed or not.
146 * Reimplement this method in class which can't be removed
147 * separately with it parent object.
148 * Base implementaiton returns always TRUE.
150 HYDRODATA_EXPORT virtual bool CanRemove();
153 * Returns unique integer identifier of the object (may be used for ordering of objects)
155 HYDRODATA_EXPORT inline int ID() const { return myLab.Tag(); }
158 * Copies all properties of this to the destinated object.
159 * Objects must be the same type.
160 * \param theDestination initialized object (from any document) - target of copying
162 HYDRODATA_EXPORT void CopyTo( Handle_HYDROData_Entity theDestination ) const;
165 * Returns the label of this object.
167 HYDRODATA_EXPORT TDF_Label& Label() { return myLab; }
171 * Returns father object. For object created under root document label
172 * this method always return NULL object.
174 HYDRODATA_EXPORT virtual Handle(HYDROData_Entity) GetFatherObject() const;
178 * Returns the list of all reference objects of this object.
179 * Base implementation always return empty list.
181 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetAllReferenceObjects() const;
186 friend class HYDROData_Iterator;
189 * Creates new object in the internal data structure. Use higher level objects
190 * to create objects with real content.
192 HYDRODATA_EXPORT HYDROData_Entity();
195 * Destructs properties of the object and object itself, removes it from the document.
197 virtual HYDRODATA_EXPORT ~HYDROData_Entity();
200 * Put the object to the label of the document.
201 * \param theLabel new label of the object
203 HYDRODATA_EXPORT virtual void SetLabel(TDF_Label theLabel);
206 * Internal method that used to store the byte array attribute
207 * \param theTag tag of a label to store attribute (for 0 this is myLab)
208 * \param theData pointer to bytes array
209 * \param theLen number of bytes in byte array that must be stored
211 void SaveByteArray(const int theTag, const char* theData, const int theLen);
214 * Internal method that used to retreive the content of byte array attribute
215 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
216 * \param theLen number of bytes in byte array
217 * \returns pointer to the internal data structure wit harray content,
218 * or NULL if array size is zero
220 const char* ByteArray(const int theTag, int& theLen) const;
223 * Internal method that used to store the reference object label attribute
224 * \param theObj pointer to reference object
225 * \param theTag tag of a label to store attribute (for 0 this is myLab)
227 int NbReferenceObjects( const int theTag = 0 ) const;
230 * Internal method that used to check object for entry into the reference list
231 * \param theObj pointer to reference object
232 * \param theTag tag of a label to store attribute (for 0 this is myLab)
234 bool HasReference( const Handle_HYDROData_Entity& theObj,
235 const int theTag = 0 ) const;
238 * Internal method that used to store the reference object label attribute
239 * \param theObj pointer to reference object
240 * \param theTag tag of a label to store attribute (for 0 this is myLab)
242 void AddReferenceObject( const Handle_HYDROData_Entity& theObj,
243 const int theTag = 0 );
246 * Internal method that used to store the reference object label attribute
247 * \param theObj pointer to reference object
248 * \param theTag tag of a label to store attribute (for 0 this is myLab)
249 * \param theIndex index in the list of references
250 - if more that len then just append it to the end of list
251 - if less than zero then prepend to the list
252 - indexing starts from 0
254 void SetReferenceObject( const Handle_HYDROData_Entity& theObj,
255 const int theTag = 0,
256 const int theIndex = 0 );
259 * Internal method that used to store the reference object label attribute
260 * \param theObj pointer to reference object
261 * \param theTag tag of a label to store attribute (for 0 this is myLab)
262 * \param theBeforeIndex index in the list of references
263 - if more that len then just append it to the end of list
264 - if less than zero then prepend to the list
265 - indexing starts from 0
267 void InsertReferenceObject( const Handle_HYDROData_Entity& theObj,
268 const int theTag = 0,
269 const int theBeforeIndex = 0 );
272 * Internal method that used to store the reference object label attribute
273 * \param theObjects sequence with pointers to reference objects
274 * \param theTag tag of a label to store attribute (for 0 this is myLab)
276 void SetReferenceObjects( const HYDROData_SequenceOfObjects& theObjects,
277 const int theTag = 0 );
280 * Internal method that used to retreive the reference object(s) attribute
281 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
282 * \param theIndex index in the list of references
283 * - indexing starts from 0
284 * \returns pointer to reference object or NULL if label is not set
286 Handle_HYDROData_Entity GetReferenceObject( const int theTag = 0,
287 const int theIndex = 0 ) const;
289 HYDROData_SequenceOfObjects GetReferenceObjects( const int theTag = 0 ) const;
292 * Internal method that used to remove the reference object attribute
293 * \param theRefLabel reference object label to remove
294 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
296 void RemoveReferenceObject( const TDF_Label& theRefLabel, const int theTag = 0 );
299 * Internal method that used to remove the reference object attribute
300 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
301 * \param theIndex index in the list of references
302 * - indexing starts from 0
304 void RemoveReferenceObject( const int theTag = 0, const int theIndex = 0 );
307 * Internal method that used to clear list of the reference objects attribute
308 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
310 void ClearReferenceObjects( const int theTag = 0 );
313 * Internal method that used to store the color attribute
314 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
315 * \param theColor color to save
317 void SetColor( const QColor& theColor, const int theTag = 0 );
320 * Internal method that used to retreive the color attribute
321 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
322 * \param theDefColor default color to return if attribute has not been set before
324 QColor GetColor( const QColor& theDefColor, const int theTag = 0 ) const;
329 void setPythonReferenceObject( MapOfTreatedObjects& theTreatedObjects,
330 QStringList& theScript,
331 const Handle(HYDROData_Entity)& theRefObject,
332 const QString& theMethod ) const;
335 Handle(TDataStd_ReferenceList) getReferenceList( const int theTag,
336 const bool theIsCreate ) const;
340 /// Array of pointers to the properties of this object; index in this array is returned by \a AddProperty.
341 TDF_Label myLab; ///< label of this object
344 ///! Is Equal for HYDROData_Entity mapping
345 HYDRODATA_EXPORT bool IsEqual(const Handle_HYDROData_Entity& theObj1, const Handle_HYDROData_Entity& theObj2);