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_SHAPES_GROUP = 22;
46 const ObjectKind KIND_SPLITTED_GROUP = 23;
47 const ObjectKind KIND_STREAM_ALTITUDE = 24;
48 const ObjectKind KIND_OBSTACLE_ALTITUDE = 25;
49 const ObjectKind KIND_LAST = KIND_OBSTACLE_ALTITUDE;
51 DEFINE_STANDARD_HANDLE(HYDROData_Entity, MMgt_TShared)
53 typedef QMap<QString,Handle(Standard_Transient)> MapOfTreatedObjects;
55 typedef NCollection_Sequence<Handle_HYDROData_Entity> HYDROData_SequenceOfObjects;
57 ///! Is Equal for HYDROData_Entity mapping
58 HYDRODATA_EXPORT bool IsEqual(const Handle_HYDROData_Entity& theObj1, const Handle_HYDROData_Entity& theObj2);
60 /**\class HYDROData_Entity
61 * \brief Generic class of any object in the data model.
63 * Interface for getting access to the object that belong to the data model.
64 * Managed by Document. Provides access to the common properties:
65 * kind of an object, name.
67 class HYDROData_Entity : public MMgt_TShared
73 * Enumeration of tags corresponding to the persistent object parameters.
77 DataTag_First = 0, ///< first tag, to reserve
78 DataTag_ZLevel, ///< z-level of object presentation
82 DEFINE_STANDARD_RTTI(HYDROData_Entity);
85 * Returns the kind of this object. Must be redefined in all objects of known type.
87 HYDRODATA_EXPORT virtual const ObjectKind GetKind() const { return KIND_UNKNOWN; }
90 * Returns the name of this object.
92 HYDRODATA_EXPORT virtual QString GetName() const;
95 * Updates the name of this object.
97 HYDRODATA_EXPORT virtual void SetName( const QString& theName );
100 * Returns the name of this object valid for Python script.
102 HYDRODATA_EXPORT virtual QString GetObjPyName() const;
105 * Dump object to Python script representation.
106 * Base implementation returns empty list,
107 * You should reimplement this function in your derived class if it
108 * has Python API and can be imported/exported from/to Python script.
110 HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
113 * Updates object state. Base implementation dose nothing.
115 HYDRODATA_EXPORT virtual void Update();
117 HYDRODATA_EXPORT virtual void UpdateLocalCS( double theDx, double theDy );
120 * Checks that object has 2D presentation. Base implementation returns false.
122 HYDRODATA_EXPORT virtual bool IsHas2dPrs() const;
125 * Show object at the top of other model objects.
127 HYDRODATA_EXPORT virtual void Show();
131 * Returns data of object wrapped to QVariant.
132 * Base implementation returns null value.
134 HYDRODATA_EXPORT virtual QVariant GetDataVariant();
138 * Sets the "MustBeUpdated" flag: if object is depended on updated features.
139 * \param theFlag is true for objects that must be updated, false for up-to-date
141 HYDRODATA_EXPORT virtual void SetToUpdate( bool theFlag );
144 * Returns the "MustBeUpdated" flag: is object data must be updated or not
145 * \returns false if object is up to date
147 HYDRODATA_EXPORT virtual bool IsMustBeUpdated() const;
150 * Returns flag indicating that object is updateble or not.
152 HYDRODATA_EXPORT virtual bool CanBeUpdated() const;
156 * Checks is object exists in the data structure.
157 * \returns true is object is not exists in the data model
159 HYDRODATA_EXPORT bool IsRemoved() const;
162 * Removes object and it child sub-objects from the data structure.
164 HYDRODATA_EXPORT virtual void Remove();
167 * Returns flag indicating that object can be removed or not.
168 * Reimplement this method in class which can't be removed
169 * separately with it parent object.
170 * Base implementaiton returns always TRUE.
172 HYDRODATA_EXPORT virtual bool CanRemove();
175 * Copies all properties of this to the destinated object.
176 * Objects must be the same type.
177 * \param theDestination initialized object (from any document) - target of copying
179 HYDRODATA_EXPORT void CopyTo( const Handle(HYDROData_Entity)& theDestination ) const;
182 * Returns the label of this object.
184 HYDRODATA_EXPORT TDF_Label& Label() { return myLab; }
188 * Returns father object. For object created under root document label
189 * this method always return NULL object.
191 HYDRODATA_EXPORT virtual Handle(HYDROData_Entity) GetFatherObject() const;
195 * Returns the list of all reference objects of this object.
196 * Base implementation always return empty list.
198 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetAllReferenceObjects() const;
202 * Returns the z-level for object presentation, -1 if no z-level.
204 HYDRODATA_EXPORT virtual Standard_Boolean GetZLevel( Standard_Integer& theLevel ) const;
207 * Set the z-level for object presentation.
209 HYDRODATA_EXPORT virtual void SetZLevel( const Standard_Integer& theLevel );
212 * Remove the z-level of object presentation.
214 HYDRODATA_EXPORT virtual void RemoveZLevel();
217 Find the Python object in the document by the object name.
218 @param theTreatedObjects the map of treated objects
219 @param theScript the script
221 void findPythonReferenceObject( MapOfTreatedObjects& theTreatedObjects,
222 QStringList& theScript ) const;
226 friend class HYDROData_Iterator;
229 * Creates new object in the internal data structure. Use higher level objects
230 * to create objects with real content.
232 HYDRODATA_EXPORT HYDROData_Entity();
235 * Destructs properties of the object and object itself, removes it from the document.
237 virtual HYDRODATA_EXPORT ~HYDROData_Entity();
240 * Put the object to the label of the document.
241 * \param theLabel new label of the object
243 HYDRODATA_EXPORT virtual void SetLabel( const TDF_Label& theLabel );
246 * Internal method that used to store the byte array attribute
247 * \param theTag tag of a label to store attribute (for 0 this is myLab)
248 * \param theData pointer to bytes array
249 * \param theLen number of bytes in byte array that must be stored
251 void SaveByteArray(const int theTag, const char* theData, const int theLen);
254 * Internal method that used to retreive the content of byte array attribute
255 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
256 * \param theLen number of bytes in byte array
257 * \returns pointer to the internal data structure wit harray content,
258 * or NULL if array size is zero
260 const char* ByteArray(const int theTag, int& theLen) const;
263 * Internal method that used to store the reference object label attribute
264 * \param theObj pointer to reference object
265 * \param theTag tag of a label to store attribute (for 0 this is myLab)
267 int NbReferenceObjects( const int theTag = 0 ) const;
270 * Internal method that used to check object for entry into the reference list
271 * \param theObj pointer to reference object
272 * \param theTag tag of a label to store attribute (for 0 this is myLab)
274 bool HasReference( const Handle_HYDROData_Entity& theObj,
275 const int theTag = 0 ) const;
278 * Internal method that used to store the reference object label attribute
279 * \param theObj pointer to reference object
280 * \param theTag tag of a label to store attribute (for 0 this is myLab)
282 void AddReferenceObject( const Handle_HYDROData_Entity& theObj,
283 const int theTag = 0 );
286 * Internal method that used to store the reference object label attribute
287 * \param theObj pointer to reference object
288 * \param theTag tag of a label to store attribute (for 0 this is myLab)
289 * \param theIndex index in the list of references
290 - if more that len then just append it to the end of list
291 - if less than zero then prepend to the list
292 - indexing starts from 0
294 void SetReferenceObject( const Handle_HYDROData_Entity& theObj,
295 const int theTag = 0,
296 const int theIndex = 0 );
299 * Internal method that used to store the reference object label attribute
300 * \param theObj pointer to reference object
301 * \param theTag tag of a label to store attribute (for 0 this is myLab)
302 * \param theBeforeIndex index in the list of references
303 - if more that len then just append it to the end of list
304 - if less than zero then prepend to the list
305 - indexing starts from 0
307 void InsertReferenceObject( const Handle_HYDROData_Entity& theObj,
308 const int theTag = 0,
309 const int theBeforeIndex = 0 );
312 * Internal method that used to store the reference object label attribute
313 * \param theObjects sequence with pointers to reference objects
314 * \param theTag tag of a label to store attribute (for 0 this is myLab)
316 void SetReferenceObjects( const HYDROData_SequenceOfObjects& theObjects,
317 const int theTag = 0 );
320 * Internal method that used to retreive the reference object(s) attribute
321 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
322 * \param theIndex index in the list of references
323 * - indexing starts from 0
324 * \returns pointer to reference object or NULL if label is not set
326 Handle_HYDROData_Entity GetReferenceObject( const int theTag = 0,
327 const int theIndex = 0 ) const;
329 HYDROData_SequenceOfObjects GetReferenceObjects( const int theTag = 0 ) const;
332 * Internal method that used to remove the reference object attribute
333 * \param theRefLabel reference object label to remove
334 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
336 void RemoveReferenceObject( const TDF_Label& theRefLabel, const int theTag = 0 );
339 * Internal method that used to remove the reference object attribute
340 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
341 * \param theIndex index in the list of references
342 * - indexing starts from 0
344 void RemoveReferenceObject( const int theTag = 0, const int theIndex = 0 );
347 * Internal method that used to clear list of the reference objects attribute
348 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
350 void ClearReferenceObjects( const int theTag = 0 );
353 * Internal method that used to store the color attribute
354 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
355 * \param theColor color to save
357 void SetColor( const QColor& theColor, const int theTag = 0 );
360 * Internal method that used to retreive the color attribute
361 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
362 * \param theDefColor default color to return if attribute has not been set before
364 QColor GetColor( const QColor& theDefColor, const int theTag = 0 ) const;
369 * Dump the initial object creation to a Python script.
370 * You should call it from DumpToPython implementation before
371 * dumping fields of the object.
373 HYDRODATA_EXPORT virtual QStringList dumpObjectCreation( MapOfTreatedObjects& theTreatedObjects ) const;
376 * Returns an object type name as a string for dumping to Python.
378 QString getPyTypeID() const;
380 void setPythonReferenceObject( MapOfTreatedObjects& theTreatedObjects,
381 QStringList& theScript,
382 const Handle(HYDROData_Entity)& theRefObject,
383 const QString& theMethod ) const;
385 bool checkObjectPythonDefinition( MapOfTreatedObjects& theTreatedObjects,
386 QStringList& theScript,
387 const Handle(HYDROData_Entity)& theRefObject ) const;
389 void setPythonObjectColor( QStringList& theScript,
390 const QColor& theColor,
391 const QColor& theDefaultColor,
392 const QString& theMethod ) const;
396 Handle(TDataStd_ReferenceList) getReferenceList( const int theTag,
397 const bool theIsCreate ) const;
401 /// Array of pointers to the properties of this object; index in this array is returned by \a AddProperty.
402 TDF_Label myLab; ///< label of this object