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_LAST = KIND_EDGES_GROUP;
48 DEFINE_STANDARD_HANDLE(HYDROData_Entity, MMgt_TShared)
50 typedef QMap<QString,Handle(Standard_Transient)> MapOfTreatedObjects;
52 typedef NCollection_Sequence<Handle_HYDROData_Entity> HYDROData_SequenceOfObjects;
55 /**\class HYDROData_Entity
56 * \brief Generic class of any object in the data model.
58 * Interface for getting access to the object that belong to the data model.
59 * Managed by Document. Provides access to the common properties:
60 * kind of an object, name.
62 class HYDROData_Entity : public MMgt_TShared
68 * Enumeration of tags corresponding to the persistent object parameters.
72 DataTag_First = 0 ///< first tag, to reserve
77 DEFINE_STANDARD_RTTI(HYDROData_Entity);
80 * Returns the kind of this object. Must be redefined in all objects of known type.
82 HYDRODATA_EXPORT virtual const ObjectKind GetKind() const { return KIND_UNKNOWN; }
85 * Returns the name of this object.
87 HYDRODATA_EXPORT virtual QString GetName() const;
90 * Updates the name of this object.
92 HYDRODATA_EXPORT virtual void SetName( const QString& theName );
95 * Dump object to Python script representation.
96 * Base implementation returns empty list,
97 * You should reimplement this function in your derived class if it
98 * has Python API and can be imported/exported from/to Python script.
100 HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
103 * Updates object state. Base implementation dose nothing.
105 HYDRODATA_EXPORT virtual void Update();
108 * Returns data of object wrapped to QVariant.
109 * Base implementation returns null value.
111 HYDRODATA_EXPORT virtual QVariant GetDataVariant();
115 * Sets the "MustBeUpdated" flag: if object is depended on updated features.
116 * \param theFlag is true for objects that must be updated, false for up-to-date
118 HYDRODATA_EXPORT virtual void SetToUpdate( bool theFlag );
121 * Returns the "MustBeUpdated" flag: is object data must be updated or not
122 * \returns false if object is up to date
124 HYDRODATA_EXPORT virtual bool IsMustBeUpdated() const;
127 * Returns flag indicating that object is updateble or not.
129 HYDRODATA_EXPORT virtual bool CanBeUpdated() const;
133 * Checks is object exists in the data structure.
134 * \returns true is object is not exists in the data model
136 HYDRODATA_EXPORT bool IsRemoved() const;
139 * Removes object and it child sub-objects from the data structure.
141 HYDRODATA_EXPORT virtual void Remove();
144 * Returns flag indicating that object can be removed or not.
145 * Reimplement this method in class which can't be removed
146 * separately with it parent object.
147 * Base implementaiton returns always TRUE.
149 HYDRODATA_EXPORT virtual bool CanRemove();
152 * Returns unique integer identifier of the object (may be used for ordering of objects)
154 HYDRODATA_EXPORT inline int ID() const { return myLab.Tag(); }
157 * Copies all properties of this to the destinated object.
158 * Objects must be the same type.
159 * \param theDestination initialized object (from any document) - target of copying
161 HYDRODATA_EXPORT void CopyTo( Handle_HYDROData_Entity theDestination ) const;
164 * Returns the label of this object.
166 HYDRODATA_EXPORT TDF_Label& Label() { return myLab; }
170 * Returns father object. For object created under root document label
171 * this method always return NULL object.
173 HYDRODATA_EXPORT virtual Handle(HYDROData_Entity) GetFatherObject() const;
177 * Returns the list of all reference objects of this object.
178 * Base implementation always return empty list.
180 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetAllReferenceObjects() const;
185 friend class HYDROData_Iterator;
188 * Creates new object in the internal data structure. Use higher level objects
189 * to create objects with real content.
191 HYDRODATA_EXPORT HYDROData_Entity();
194 * Destructs properties of the object and object itself, removes it from the document.
196 virtual HYDRODATA_EXPORT ~HYDROData_Entity();
199 * Put the object to the label of the document.
200 * \param theLabel new label of the object
202 HYDRODATA_EXPORT virtual void SetLabel(TDF_Label theLabel);
205 * Internal method that used to store the byte array attribute
206 * \param theTag tag of a label to store attribute (for 0 this is myLab)
207 * \param theData pointer to bytes array
208 * \param theLen number of bytes in byte array that must be stored
210 void SaveByteArray(const int theTag, const char* theData, const int theLen);
213 * Internal method that used to retreive the content of byte array attribute
214 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
215 * \param theLen number of bytes in byte array
216 * \returns pointer to the internal data structure wit harray content,
217 * or NULL if array size is zero
219 const char* ByteArray(const int theTag, int& theLen) const;
222 * Internal method that used to store the reference object label attribute
223 * \param theObj pointer to reference object
224 * \param theTag tag of a label to store attribute (for 0 this is myLab)
226 int NbReferenceObjects( const int theTag = 0 ) const;
229 * Internal method that used to check object for entry into the reference list
230 * \param theObj pointer to reference object
231 * \param theTag tag of a label to store attribute (for 0 this is myLab)
233 bool HasReference( const Handle_HYDROData_Entity& theObj,
234 const int theTag = 0 ) const;
237 * Internal method that used to store the reference object label attribute
238 * \param theObj pointer to reference object
239 * \param theTag tag of a label to store attribute (for 0 this is myLab)
241 void AddReferenceObject( const Handle_HYDROData_Entity& theObj,
242 const int theTag = 0 );
245 * Internal method that used to store the reference object label attribute
246 * \param theObj pointer to reference object
247 * \param theTag tag of a label to store attribute (for 0 this is myLab)
248 * \param theIndex index in the list of references
249 - if more that len then just append it to the end of list
250 - if less than zero then prepend to the list
251 - indexing starts from 0
253 void SetReferenceObject( const Handle_HYDROData_Entity& theObj,
254 const int theTag = 0,
255 const int theIndex = 0 );
258 * Internal method that used to store the reference object label attribute
259 * \param theObj pointer to reference object
260 * \param theTag tag of a label to store attribute (for 0 this is myLab)
261 * \param theBeforeIndex index in the list of references
262 - if more that len then just append it to the end of list
263 - if less than zero then prepend to the list
264 - indexing starts from 0
266 void InsertReferenceObject( const Handle_HYDROData_Entity& theObj,
267 const int theTag = 0,
268 const int theBeforeIndex = 0 );
271 * Internal method that used to store the reference object label attribute
272 * \param theObjects sequence with pointers to reference objects
273 * \param theTag tag of a label to store attribute (for 0 this is myLab)
275 void SetReferenceObjects( const HYDROData_SequenceOfObjects& theObjects,
276 const int theTag = 0 );
279 * Internal method that used to retreive the reference object(s) attribute
280 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
281 * \param theIndex index in the list of references
282 * - indexing starts from 0
283 * \returns pointer to reference object or NULL if label is not set
285 Handle_HYDROData_Entity GetReferenceObject( const int theTag = 0,
286 const int theIndex = 0 ) const;
288 HYDROData_SequenceOfObjects GetReferenceObjects( const int theTag = 0 ) const;
291 * Internal method that used to remove the reference object attribute
292 * \param theRefLabel reference object label to remove
293 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
295 void RemoveReferenceObject( const TDF_Label& theRefLabel, const int theTag = 0 );
298 * Internal method that used to remove the reference object attribute
299 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
300 * \param theIndex index in the list of references
301 * - indexing starts from 0
303 void RemoveReferenceObject( const int theTag = 0, const int theIndex = 0 );
306 * Internal method that used to clear list of the reference objects attribute
307 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
309 void ClearReferenceObjects( const int theTag = 0 );
312 * Internal method that used to store the color attribute
313 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
314 * \param theColor color to save
316 void SetColor( const QColor& theColor, const int theTag = 0 );
319 * Internal method that used to retreive the color attribute
320 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
321 * \param theDefColor default color to return if attribute has not been set before
323 QColor GetColor( const QColor& theDefColor, const int theTag = 0 ) const;
328 void setPythonReferenceObject( MapOfTreatedObjects& theTreatedObjects,
329 QStringList& theScript,
330 const Handle(HYDROData_Entity)& theRefObject,
331 const QString& theMethod ) const;
334 Handle(TDataStd_ReferenceList) getReferenceList( const int theTag,
335 const bool theIsCreate ) const;
339 /// Array of pointers to the properties of this object; index in this array is returned by \a AddProperty.
340 TDF_Label myLab; ///< label of this object
343 ///! Is Equal for HYDROData_Entity mapping
344 HYDRODATA_EXPORT bool IsEqual(const Handle_HYDROData_Entity& theObj1, const Handle_HYDROData_Entity& theObj2);