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;
58 /**\class HYDROData_Entity
59 * \brief Generic class of any object in the data model.
61 * Interface for getting access to the object that belong to the data model.
62 * Managed by Document. Provides access to the common properties:
63 * kind of an object, name.
65 class HYDROData_Entity : public MMgt_TShared
71 * Enumeration of tags corresponding to the persistent object parameters.
75 DataTag_First = 0 ///< first tag, to reserve
80 DEFINE_STANDARD_RTTI(HYDROData_Entity);
83 * Returns the kind of this object. Must be redefined in all objects of known type.
85 HYDRODATA_EXPORT virtual const ObjectKind GetKind() const { return KIND_UNKNOWN; }
88 * Returns the name of this object.
90 HYDRODATA_EXPORT virtual QString GetName() const;
93 * Updates the name of this object.
95 HYDRODATA_EXPORT virtual void SetName( const QString& theName );
98 * Returns the name of this object valid for Python script.
100 HYDRODATA_EXPORT virtual QString GetObjPyName() const;
103 * Dump object to Python script representation.
104 * Base implementation returns empty list,
105 * You should reimplement this function in your derived class if it
106 * has Python API and can be imported/exported from/to Python script.
108 HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
111 * Updates object state. Base implementation dose nothing.
113 HYDRODATA_EXPORT virtual void Update();
116 * Show object at the top of other model objects.
118 HYDRODATA_EXPORT virtual void Show();
121 * Returns data of object wrapped to QVariant.
122 * Base implementation returns null value.
124 HYDRODATA_EXPORT virtual QVariant GetDataVariant();
128 * Sets the "MustBeUpdated" flag: if object is depended on updated features.
129 * \param theFlag is true for objects that must be updated, false for up-to-date
131 HYDRODATA_EXPORT virtual void SetToUpdate( bool theFlag );
134 * Returns the "MustBeUpdated" flag: is object data must be updated or not
135 * \returns false if object is up to date
137 HYDRODATA_EXPORT virtual bool IsMustBeUpdated() const;
140 * Returns flag indicating that object is updateble or not.
142 HYDRODATA_EXPORT virtual bool CanBeUpdated() const;
146 * Checks is object exists in the data structure.
147 * \returns true is object is not exists in the data model
149 HYDRODATA_EXPORT bool IsRemoved() const;
152 * Removes object and it child sub-objects from the data structure.
154 HYDRODATA_EXPORT virtual void Remove();
157 * Returns flag indicating that object can be removed or not.
158 * Reimplement this method in class which can't be removed
159 * separately with it parent object.
160 * Base implementaiton returns always TRUE.
162 HYDRODATA_EXPORT virtual bool CanRemove();
165 * Copies all properties of this to the destinated object.
166 * Objects must be the same type.
167 * \param theDestination initialized object (from any document) - target of copying
169 HYDRODATA_EXPORT void CopyTo( const Handle(HYDROData_Entity)& theDestination ) const;
172 * Returns the label of this object.
174 HYDRODATA_EXPORT TDF_Label& Label() { return myLab; }
178 * Returns father object. For object created under root document label
179 * this method always return NULL object.
181 HYDRODATA_EXPORT virtual Handle(HYDROData_Entity) GetFatherObject() const;
185 * Returns the list of all reference objects of this object.
186 * Base implementation always return empty list.
188 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetAllReferenceObjects() const;
193 friend class HYDROData_Iterator;
196 * Creates new object in the internal data structure. Use higher level objects
197 * to create objects with real content.
199 HYDRODATA_EXPORT HYDROData_Entity();
202 * Destructs properties of the object and object itself, removes it from the document.
204 virtual HYDRODATA_EXPORT ~HYDROData_Entity();
207 * Put the object to the label of the document.
208 * \param theLabel new label of the object
210 HYDRODATA_EXPORT virtual void SetLabel(TDF_Label theLabel);
213 * Internal method that used to store the byte array attribute
214 * \param theTag tag of a label to store attribute (for 0 this is myLab)
215 * \param theData pointer to bytes array
216 * \param theLen number of bytes in byte array that must be stored
218 void SaveByteArray(const int theTag, const char* theData, const int theLen);
221 * Internal method that used to retreive the content of byte array attribute
222 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
223 * \param theLen number of bytes in byte array
224 * \returns pointer to the internal data structure wit harray content,
225 * or NULL if array size is zero
227 const char* ByteArray(const int theTag, int& theLen) const;
230 * Internal method that used to store the reference object label attribute
231 * \param theObj pointer to reference object
232 * \param theTag tag of a label to store attribute (for 0 this is myLab)
234 int NbReferenceObjects( const int theTag = 0 ) const;
237 * Internal method that used to check object for entry into the reference list
238 * \param theObj pointer to reference object
239 * \param theTag tag of a label to store attribute (for 0 this is myLab)
241 bool HasReference( const Handle_HYDROData_Entity& theObj,
242 const int theTag = 0 ) const;
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)
249 void AddReferenceObject( const Handle_HYDROData_Entity& theObj,
250 const int theTag = 0 );
253 * Internal method that used to store the reference object label attribute
254 * \param theObj pointer to reference object
255 * \param theTag tag of a label to store attribute (for 0 this is myLab)
256 * \param theIndex index in the list of references
257 - if more that len then just append it to the end of list
258 - if less than zero then prepend to the list
259 - indexing starts from 0
261 void SetReferenceObject( const Handle_HYDROData_Entity& theObj,
262 const int theTag = 0,
263 const int theIndex = 0 );
266 * Internal method that used to store the reference object label attribute
267 * \param theObj pointer to reference object
268 * \param theTag tag of a label to store attribute (for 0 this is myLab)
269 * \param theBeforeIndex index in the list of references
270 - if more that len then just append it to the end of list
271 - if less than zero then prepend to the list
272 - indexing starts from 0
274 void InsertReferenceObject( const Handle_HYDROData_Entity& theObj,
275 const int theTag = 0,
276 const int theBeforeIndex = 0 );
279 * Internal method that used to store the reference object label attribute
280 * \param theObjects sequence with pointers to reference objects
281 * \param theTag tag of a label to store attribute (for 0 this is myLab)
283 void SetReferenceObjects( const HYDROData_SequenceOfObjects& theObjects,
284 const int theTag = 0 );
287 * Internal method that used to retreive the reference object(s) attribute
288 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
289 * \param theIndex index in the list of references
290 * - indexing starts from 0
291 * \returns pointer to reference object or NULL if label is not set
293 Handle_HYDROData_Entity GetReferenceObject( const int theTag = 0,
294 const int theIndex = 0 ) const;
296 HYDROData_SequenceOfObjects GetReferenceObjects( const int theTag = 0 ) const;
299 * Internal method that used to remove the reference object attribute
300 * \param theRefLabel reference object label to remove
301 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
303 void RemoveReferenceObject( const TDF_Label& theRefLabel, const int theTag = 0 );
306 * Internal method that used to remove the reference object attribute
307 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
308 * \param theIndex index in the list of references
309 * - indexing starts from 0
311 void RemoveReferenceObject( const int theTag = 0, const int theIndex = 0 );
314 * Internal method that used to clear list of the reference objects attribute
315 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
317 void ClearReferenceObjects( const int theTag = 0 );
320 * Internal method that used to store the color attribute
321 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
322 * \param theColor color to save
324 void SetColor( const QColor& theColor, const int theTag = 0 );
327 * Internal method that used to retreive the color attribute
328 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
329 * \param theDefColor default color to return if attribute has not been set before
331 QColor GetColor( const QColor& theDefColor, const int theTag = 0 ) const;
336 void setPythonReferenceObject( MapOfTreatedObjects& theTreatedObjects,
337 QStringList& theScript,
338 const Handle(HYDROData_Entity)& theRefObject,
339 const QString& theMethod ) const;
341 bool checkObjectPythonDefinition( MapOfTreatedObjects& theTreatedObjects,
342 QStringList& theScript,
343 const Handle(HYDROData_Entity)& theRefObject ) const;
345 void setPythonObjectColor( QStringList& theScript,
346 const QColor& theColor,
347 const QColor& theDefaultColor,
348 const QString& theMethod ) const;
351 * Dump the initial object creation to a Python script.
352 * You should call it from DumpToPython implementation before
353 * dumping fields of the object.
355 HYDRODATA_EXPORT virtual QStringList dumpObjectCreation( MapOfTreatedObjects& theTreatedObjects ) const;
358 * Returns an object type name as a string for dumping to Python.
360 QString getPyTypeID() const;
364 Handle(TDataStd_ReferenceList) getReferenceList( const int theTag,
365 const bool theIsCreate ) const;
369 /// Array of pointers to the properties of this object; index in this array is returned by \a AddProperty.
370 TDF_Label myLab; ///< label of this object
373 ///! Is Equal for HYDROData_Entity mapping
374 HYDRODATA_EXPORT bool IsEqual(const Handle_HYDROData_Entity& theObj1, const Handle_HYDROData_Entity& theObj2);