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();
119 * Checks that object has 2D presentation. Base implementation returns false.
121 HYDRODATA_EXPORT virtual bool IsHas2dPrs() const;
124 * Show object at the top of other model objects.
126 HYDRODATA_EXPORT virtual void Show();
130 * Returns data of object wrapped to QVariant.
131 * Base implementation returns null value.
133 HYDRODATA_EXPORT virtual QVariant GetDataVariant();
137 * Sets the "MustBeUpdated" flag: if object is depended on updated features.
138 * \param theFlag is true for objects that must be updated, false for up-to-date
140 HYDRODATA_EXPORT virtual void SetToUpdate( bool theFlag );
143 * Returns the "MustBeUpdated" flag: is object data must be updated or not
144 * \returns false if object is up to date
146 HYDRODATA_EXPORT virtual bool IsMustBeUpdated() const;
149 * Returns flag indicating that object is updateble or not.
151 HYDRODATA_EXPORT virtual bool CanBeUpdated() const;
155 * Checks is object exists in the data structure.
156 * \returns true is object is not exists in the data model
158 HYDRODATA_EXPORT bool IsRemoved() const;
161 * Removes object and it child sub-objects from the data structure.
163 HYDRODATA_EXPORT virtual void Remove();
166 * Returns flag indicating that object can be removed or not.
167 * Reimplement this method in class which can't be removed
168 * separately with it parent object.
169 * Base implementaiton returns always TRUE.
171 HYDRODATA_EXPORT virtual bool CanRemove();
174 * Copies all properties of this to the destinated object.
175 * Objects must be the same type.
176 * \param theDestination initialized object (from any document) - target of copying
178 HYDRODATA_EXPORT void CopyTo( const Handle(HYDROData_Entity)& theDestination ) const;
181 * Returns the label of this object.
183 HYDRODATA_EXPORT TDF_Label& Label() { return myLab; }
187 * Returns father object. For object created under root document label
188 * this method always return NULL object.
190 HYDRODATA_EXPORT virtual Handle(HYDROData_Entity) GetFatherObject() const;
194 * Returns the list of all reference objects of this object.
195 * Base implementation always return empty list.
197 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetAllReferenceObjects() const;
201 * Returns the z-level for object presentation, -1 if no z-level.
203 HYDRODATA_EXPORT virtual Standard_Boolean GetZLevel( Standard_Integer& theLevel ) const;
206 * Set the z-level for object presentation.
208 HYDRODATA_EXPORT virtual void SetZLevel( const Standard_Integer& theLevel );
211 * Remove the z-level of object presentation.
213 HYDRODATA_EXPORT virtual void RemoveZLevel();
218 friend class HYDROData_Iterator;
221 * Creates new object in the internal data structure. Use higher level objects
222 * to create objects with real content.
224 HYDRODATA_EXPORT HYDROData_Entity();
227 * Destructs properties of the object and object itself, removes it from the document.
229 virtual HYDRODATA_EXPORT ~HYDROData_Entity();
232 * Put the object to the label of the document.
233 * \param theLabel new label of the object
235 HYDRODATA_EXPORT virtual void SetLabel( const TDF_Label& theLabel );
238 * Internal method that used to store the byte array attribute
239 * \param theTag tag of a label to store attribute (for 0 this is myLab)
240 * \param theData pointer to bytes array
241 * \param theLen number of bytes in byte array that must be stored
243 void SaveByteArray(const int theTag, const char* theData, const int theLen);
246 * Internal method that used to retreive the content of byte array attribute
247 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
248 * \param theLen number of bytes in byte array
249 * \returns pointer to the internal data structure wit harray content,
250 * or NULL if array size is zero
252 const char* ByteArray(const int theTag, int& theLen) const;
255 * Internal method that used to store the reference object label attribute
256 * \param theObj pointer to reference object
257 * \param theTag tag of a label to store attribute (for 0 this is myLab)
259 int NbReferenceObjects( const int theTag = 0 ) const;
262 * Internal method that used to check object for entry into the reference list
263 * \param theObj pointer to reference object
264 * \param theTag tag of a label to store attribute (for 0 this is myLab)
266 bool HasReference( const Handle_HYDROData_Entity& theObj,
267 const int theTag = 0 ) const;
270 * Internal method that used to store the reference object label attribute
271 * \param theObj pointer to reference object
272 * \param theTag tag of a label to store attribute (for 0 this is myLab)
274 void AddReferenceObject( const Handle_HYDROData_Entity& theObj,
275 const int theTag = 0 );
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)
281 * \param theIndex index in the list of references
282 - if more that len then just append it to the end of list
283 - if less than zero then prepend to the list
284 - indexing starts from 0
286 void SetReferenceObject( const Handle_HYDROData_Entity& theObj,
287 const int theTag = 0,
288 const int theIndex = 0 );
291 * Internal method that used to store the reference object label attribute
292 * \param theObj pointer to reference object
293 * \param theTag tag of a label to store attribute (for 0 this is myLab)
294 * \param theBeforeIndex index in the list of references
295 - if more that len then just append it to the end of list
296 - if less than zero then prepend to the list
297 - indexing starts from 0
299 void InsertReferenceObject( const Handle_HYDROData_Entity& theObj,
300 const int theTag = 0,
301 const int theBeforeIndex = 0 );
304 * Internal method that used to store the reference object label attribute
305 * \param theObjects sequence with pointers to reference objects
306 * \param theTag tag of a label to store attribute (for 0 this is myLab)
308 void SetReferenceObjects( const HYDROData_SequenceOfObjects& theObjects,
309 const int theTag = 0 );
312 * Internal method that used to retreive the reference object(s) attribute
313 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
314 * \param theIndex index in the list of references
315 * - indexing starts from 0
316 * \returns pointer to reference object or NULL if label is not set
318 Handle_HYDROData_Entity GetReferenceObject( const int theTag = 0,
319 const int theIndex = 0 ) const;
321 HYDROData_SequenceOfObjects GetReferenceObjects( const int theTag = 0 ) const;
324 * Internal method that used to remove the reference object attribute
325 * \param theRefLabel reference object label to remove
326 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
328 void RemoveReferenceObject( const TDF_Label& theRefLabel, const int theTag = 0 );
331 * Internal method that used to remove the reference object attribute
332 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
333 * \param theIndex index in the list of references
334 * - indexing starts from 0
336 void RemoveReferenceObject( const int theTag = 0, const int theIndex = 0 );
339 * Internal method that used to clear list of the reference objects attribute
340 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
342 void ClearReferenceObjects( const int theTag = 0 );
345 * Internal method that used to store the color attribute
346 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
347 * \param theColor color to save
349 void SetColor( const QColor& theColor, const int theTag = 0 );
352 * Internal method that used to retreive the color attribute
353 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
354 * \param theDefColor default color to return if attribute has not been set before
356 QColor GetColor( const QColor& theDefColor, const int theTag = 0 ) const;
362 * Dump the initial object creation to a Python script.
363 * You should call it from DumpToPython implementation before
364 * dumping fields of the object.
366 HYDRODATA_EXPORT virtual QStringList dumpObjectCreation( MapOfTreatedObjects& theTreatedObjects ) const;
369 * Returns an object type name as a string for dumping to Python.
371 QString getPyTypeID() const;
373 void setPythonReferenceObject( MapOfTreatedObjects& theTreatedObjects,
374 QStringList& theScript,
375 const Handle(HYDROData_Entity)& theRefObject,
376 const QString& theMethod ) const;
378 bool checkObjectPythonDefinition( MapOfTreatedObjects& theTreatedObjects,
379 QStringList& theScript,
380 const Handle(HYDROData_Entity)& theRefObject ) const;
382 void setPythonObjectColor( QStringList& theScript,
383 const QColor& theColor,
384 const QColor& theDefaultColor,
385 const QString& theMethod ) const;
389 Handle(TDataStd_ReferenceList) getReferenceList( const int theTag,
390 const bool theIsCreate ) const;
394 /// Array of pointers to the properties of this object; index in this array is returned by \a AddProperty.
395 TDF_Label myLab; ///< label of this object