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_LAST = KIND_NATURAL_OBJECT;
46 DEFINE_STANDARD_HANDLE(HYDROData_Entity, MMgt_TShared)
48 typedef QMap<QString,Handle(Standard_Transient)> MapOfTreatedObjects;
50 typedef NCollection_Sequence<Handle_HYDROData_Entity> HYDROData_SequenceOfObjects;
53 /**\class HYDROData_Entity
54 * \brief Generic class of any object in the data model.
56 * Interface for getting access to the object that belong to the data model.
57 * Managed by Document. Provides access to the common properties:
58 * kind of an object, name.
60 class HYDROData_Entity : public MMgt_TShared
66 * Enumeration of tags corresponding to the persistent object parameters.
70 DataTag_First = 0 ///< first tag, to reserve
75 DEFINE_STANDARD_RTTI(HYDROData_Entity);
78 * Returns the kind of this object. Must be redefined in all objects of known type.
80 HYDRODATA_EXPORT virtual const ObjectKind GetKind() const { return KIND_UNKNOWN; }
83 * Returns the name of this object.
85 HYDRODATA_EXPORT virtual QString GetName() const;
88 * Updates the name of this object.
90 HYDRODATA_EXPORT virtual void SetName( const QString& theName );
93 * Dump object to Python script representation.
94 * Base implementation returns empty list,
95 * You should reimplement this function in your derived class if it
96 * has Python API and can be imported/exported from/to Python script.
98 HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
101 * Updates object state. Base implementation dose nothing.
103 HYDRODATA_EXPORT virtual void Update();
106 * Returns data of object wrapped to QVariant.
107 * Base implementation returns null value.
109 HYDRODATA_EXPORT virtual QVariant GetDataVariant();
112 * Sets the "MustBeUpdated" flag: if object is depended on updated features.
113 * \param theFlag is true for objects that must be updated, false for up-to-date
115 HYDRODATA_EXPORT void SetToUpdate( bool theFlag );
118 * Returns the "MustBeUpdated" flag: is object data must be updated or not
119 * \returns false if object is up to date
121 HYDRODATA_EXPORT bool IsMustBeUpdated() const;
124 * Checks is object exists in the data structure.
125 * \returns true is object is not exists in the data model
127 HYDRODATA_EXPORT bool IsRemoved() const;
130 * Removes object and it child sub-objects from the data structure.
132 HYDRODATA_EXPORT virtual void Remove();
135 * Returns flag indicating that object can be removed or not.
136 * Reimplement this method in class which can't be removed
137 * separately with it parent object.
138 * Base implementaiton returns always TRUE.
140 HYDRODATA_EXPORT virtual bool CanRemove();
143 * Returns unique integer identifier of the object (may be used for ordering of objects)
145 HYDRODATA_EXPORT inline int ID() const { return myLab.Tag(); }
148 * Copies all properties of this to the destinated object.
149 * Objects must be the same type.
150 * \param theDestination initialized object (from any document) - target of copying
152 HYDRODATA_EXPORT void CopyTo( Handle_HYDROData_Entity theDestination ) const;
155 * Returns the label of this object.
157 HYDRODATA_EXPORT TDF_Label& Label() { return myLab; }
161 * Returns father object. For object created under root document label
162 * this method always return NULL object.
164 HYDRODATA_EXPORT virtual Handle(HYDROData_Entity) GetFatherObject() const;
168 * Returns the list of all reference objects of this object.
169 * Base implementation always return empty list.
171 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetAllReferenceObjects() const;
176 friend class HYDROData_Iterator;
179 * Creates new object in the internal data structure. Use higher level objects
180 * to create objects with real content.
182 HYDRODATA_EXPORT HYDROData_Entity();
185 * Destructs properties of the object and object itself, removes it from the document.
187 virtual HYDRODATA_EXPORT ~HYDROData_Entity();
190 * Put the object to the label of the document.
191 * \param theLabel new label of the object
193 HYDRODATA_EXPORT virtual void SetLabel(TDF_Label theLabel);
196 * Internal method that used to store the byte array attribute
197 * \param theTag tag of a label to store attribute (for 0 this is myLab)
198 * \param theData pointer to bytes array
199 * \param theLen number of bytes in byte array that must be stored
201 void SaveByteArray(const int theTag, const char* theData, const int theLen);
204 * Internal method that used to retreive the content of byte array attribute
205 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
206 * \param theLen number of bytes in byte array
207 * \returns pointer to the internal data structure wit harray content,
208 * or NULL if array size is zero
210 const char* ByteArray(const int theTag, int& theLen) const;
213 * Internal method that used to store the reference object label attribute
214 * \param theObj pointer to reference object
215 * \param theTag tag of a label to store attribute (for 0 this is myLab)
217 int NbReferenceObjects( const int theTag = 0 ) const;
220 * Internal method that used to check object for entry into the reference list
221 * \param theObj pointer to reference object
222 * \param theTag tag of a label to store attribute (for 0 this is myLab)
224 bool HasReference( const Handle_HYDROData_Entity& theObj,
225 const int theTag = 0 ) const;
228 * Internal method that used to store the reference object label attribute
229 * \param theObj pointer to reference object
230 * \param theTag tag of a label to store attribute (for 0 this is myLab)
232 void AddReferenceObject( const Handle_HYDROData_Entity& theObj,
233 const int theTag = 0 );
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)
239 * \param theIndex index in the list of references
240 - if more that len then just append it to the end of list
241 - if less than zero then prepend to the list
242 - indexing starts from 0
244 void SetReferenceObject( const Handle_HYDROData_Entity& theObj,
245 const int theTag = 0,
246 const int theIndex = 0 );
249 * Internal method that used to store the reference object label attribute
250 * \param theObj pointer to reference object
251 * \param theTag tag of a label to store attribute (for 0 this is myLab)
252 * \param theBeforeIndex index in the list of references
253 - if more that len then just append it to the end of list
254 - if less than zero then prepend to the list
255 - indexing starts from 0
257 void InsertReferenceObject( const Handle_HYDROData_Entity& theObj,
258 const int theTag = 0,
259 const int theBeforeIndex = 0 );
262 * Internal method that used to store the reference object label attribute
263 * \param theObjects sequence with pointers to reference objects
264 * \param theTag tag of a label to store attribute (for 0 this is myLab)
266 void SetReferenceObjects( const HYDROData_SequenceOfObjects& theObjects,
267 const int theTag = 0 );
270 * Internal method that used to retreive the reference object(s) attribute
271 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
272 * \param theIndex index in the list of references
273 * - indexing starts from 0
274 * \returns pointer to reference object or NULL if label is not set
276 Handle_HYDROData_Entity GetReferenceObject( const int theTag = 0,
277 const int theIndex = 0 ) const;
279 HYDROData_SequenceOfObjects GetReferenceObjects( const int theTag = 0 ) const;
282 * Internal method that used to remove the reference object attribute
283 * \param theRefLabel reference object label to remove
284 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
286 void RemoveReferenceObject( const TDF_Label& theRefLabel, const int theTag = 0 );
289 * Internal method that used to remove the reference object attribute
290 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
291 * \param theIndex index in the list of references
292 * - indexing starts from 0
294 void RemoveReferenceObject( const int theTag = 0, const int theIndex = 0 );
297 * Internal method that used to clear list of the reference objects attribute
298 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
300 void ClearReferenceObjects( const int theTag = 0 );
303 * Internal method that used to store the color attribute
304 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
305 * \param theColor color to save
307 void SetColor( const QColor& theColor, const int theTag = 0 );
310 * Internal method that used to retreive the color attribute
311 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
312 * \param theDefColor default color to return if attribute has not been set before
314 QColor GetColor( const QColor& theDefColor, const int theTag = 0 ) const;
319 void setPythonReferenceObject( MapOfTreatedObjects& theTreatedObjects,
320 QStringList& theScript,
321 const Handle(HYDROData_Entity)& theRefObject,
322 const QString& theMethod ) const;
325 Handle(TDataStd_ReferenceList) getReferenceList( const int theTag,
326 const bool theIsCreate ) const;
330 /// Array of pointers to the properties of this object; index in this array is returned by \a AddProperty.
331 TDF_Label myLab; ///< label of this object
334 ///! Is Equal for HYDROData_Entity mapping
335 HYDRODATA_EXPORT bool IsEqual(const Handle_HYDROData_Entity& theObj1, const Handle_HYDROData_Entity& theObj2);