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_LAST = KIND_VISUAL_STATE;
44 DEFINE_STANDARD_HANDLE(HYDROData_Entity, MMgt_TShared)
46 typedef QMap<QString,Handle(Standard_Transient)> MapOfTreatedObjects;
48 typedef NCollection_Sequence<Handle_HYDROData_Entity> HYDROData_SequenceOfObjects;
51 /**\class HYDROData_Entity
52 * \brief Generic class of any object in the data model.
54 * Interface for getting access to the object that belong to the data model.
55 * Managed by Document. Provides access to the common properties:
56 * kind of an object, name.
58 class HYDROData_Entity : public MMgt_TShared
64 * Enumeration of tags corresponding to the persistent object parameters.
68 DataTag_First = 0 ///< first tag, to reserve
73 DEFINE_STANDARD_RTTI(HYDROData_Entity);
76 * Returns the kind of this object. Must be redefined in all objects of known type.
78 HYDRODATA_EXPORT virtual const ObjectKind GetKind() const { return KIND_UNKNOWN; }
81 * Returns the name of this object.
83 HYDRODATA_EXPORT QString GetName() const;
86 * Updates the name of this object.
88 HYDRODATA_EXPORT void SetName(const QString& theName);
91 * Dump object to Python script representation.
92 * Base implementation returns empty list,
93 * You should reimplement this function in your derived class if it
94 * has Python API and can be imported/exported from/to Python script.
96 HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
99 * Updates object state. Base implementation dose nothing.
101 HYDRODATA_EXPORT virtual void Update();
104 * Returns data of object wrapped to QVariant.
105 * Base implementation returns null value.
107 HYDRODATA_EXPORT virtual QVariant GetDataVariant();
110 * Checks is object exists in the data structure.
111 * \returns true is object is not exists in the data model
113 HYDRODATA_EXPORT bool IsRemoved() const;
116 * Removes object and it child sub-objects from the data structure.
118 HYDRODATA_EXPORT virtual void Remove();
121 * Returns unique integer identifier of the object (may be used for ordering of objects)
123 HYDRODATA_EXPORT inline int ID() const {return myLab.Tag();}
126 * Copies all properties of this to the destinated object.
127 * Objects must be the same type.
128 * \param theDestination initialized object (from any document) - target of copying
130 HYDRODATA_EXPORT void CopyTo(Handle_HYDROData_Entity theDestination) const;
133 * Returns the label of this object.
135 HYDRODATA_EXPORT TDF_Label& Label() {return myLab;}
138 * Returns father object. For object created under root document label
139 * this method always return NULL object.
141 HYDRODATA_EXPORT virtual Handle(HYDROData_Entity) GetFatherObject() const;
145 friend class HYDROData_Iterator;
148 * Creates new object in the internal data structure. Use higher level objects
149 * to create objects with real content.
151 HYDRODATA_EXPORT HYDROData_Entity();
154 * Destructs properties of the object and object itself, removes it from the document.
156 virtual HYDRODATA_EXPORT ~HYDROData_Entity();
159 * Put the object to the label of the document.
160 * \param theLabel new label of the object
162 HYDRODATA_EXPORT virtual void SetLabel(TDF_Label theLabel);
165 * Internal method that used to store the byte array attribute
166 * \param theTag tag of a label to store attribute (for 0 this is myLab)
167 * \param theData pointer to bytes array
168 * \param theLen number of bytes in byte array that must be stored
170 void SaveByteArray(const int theTag, const char* theData, const int theLen);
173 * Internal method that used to retreive the content of byte array attribute
174 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
175 * \param theLen number of bytes in byte array
176 * \returns pointer to the internal data structure wit harray content,
177 * or NULL if array size is zero
179 const char* ByteArray(const int theTag, int& theLen) const;
182 * Internal method that used to store the reference object label attribute
183 * \param theObj pointer to reference object
184 * \param theTag tag of a label to store attribute (for 0 this is myLab)
186 int NbReferenceObjects( const int theTag = 0 ) const;
189 * Internal method that used to check object for entry into the reference list
190 * \param theObj pointer to reference object
191 * \param theTag tag of a label to store attribute (for 0 this is myLab)
193 bool HasReference( const Handle_HYDROData_Entity& theObj,
194 const int theTag = 0 ) const;
197 * Internal method that used to store the reference object label attribute
198 * \param theObj pointer to reference object
199 * \param theTag tag of a label to store attribute (for 0 this is myLab)
201 void AddReferenceObject( const Handle_HYDROData_Entity& theObj,
202 const int theTag = 0 );
205 * Internal method that used to store the reference object label attribute
206 * \param theObj pointer to reference object
207 * \param theTag tag of a label to store attribute (for 0 this is myLab)
208 * \param theIndex index in the list of references
209 - if more that len then just append it to the end of list
210 - if less than zero then prepend to the list
211 - indexing starts from 0
213 void SetReferenceObject( const Handle_HYDROData_Entity& theObj,
214 const int theTag = 0,
215 const int theIndex = 0 );
218 * Internal method that used to store the reference object label attribute
219 * \param theObj pointer to reference object
220 * \param theTag tag of a label to store attribute (for 0 this is myLab)
221 * \param theBeforeIndex index in the list of references
222 - if more that len then just append it to the end of list
223 - if less than zero then prepend to the list
224 - indexing starts from 0
226 void InsertReferenceObject( const Handle_HYDROData_Entity& theObj,
227 const int theTag = 0,
228 const int theBeforeIndex = 0 );
231 * Internal method that used to store the reference object label attribute
232 * \param theObjects sequence with pointers to reference objects
233 * \param theTag tag of a label to store attribute (for 0 this is myLab)
235 void SetReferenceObjects( const HYDROData_SequenceOfObjects& theObjects,
236 const int theTag = 0 );
239 * Internal method that used to retreive the reference object(s) attribute
240 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
241 * \param theIndex index in the list of references
242 * - indexing starts from 0
243 * \returns pointer to reference object or NULL if label is not set
245 Handle_HYDROData_Entity GetReferenceObject( const int theTag = 0,
246 const int theIndex = 0 ) const;
248 HYDROData_SequenceOfObjects GetReferenceObjects( const int theTag = 0 ) const;
251 * Internal method that used to remove the reference object attribute
252 * \param theRefLabel reference object label to remove
253 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
255 void RemoveReferenceObject( const TDF_Label& theRefLabel, const int theTag = 0 );
258 * Internal method that used to remove the reference object attribute
259 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
260 * \param theIndex index in the list of references
261 * - indexing starts from 0
263 void RemoveReferenceObject( const int theTag = 0, const int theIndex = 0 );
266 * Internal method that used to clear list of the reference objects attribute
267 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
269 void ClearReferenceObjects( const int theTag = 0 );
272 * Internal method that used to store the color attribute
273 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
274 * \param theColor color to save
276 void SetColor( const QColor& theColor, const int theTag = 0 );
279 * Internal method that used to retreive the color attribute
280 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
281 * \param theDefColor default color to return if attribute has not been set before
283 QColor GetColor( const QColor& theDefColor, const int theTag = 0 ) const;
288 void setPythonReferenceObject( MapOfTreatedObjects& theTreatedObjects,
289 QStringList& theScript,
290 const Handle(HYDROData_Entity)& theRefObject,
291 const QString& theMethod ) const;
294 Handle(TDataStd_ReferenceList) getReferenceList( const int theTag,
295 const bool theIsCreate ) const;
299 /// Array of pointers to the properties of this object; index in this array is returned by \a AddProperty.
300 TDF_Label myLab; ///< label of this object
303 ///! Is Equal for HYDROData_Entity mapping
304 HYDRODATA_EXPORT bool IsEqual(const Handle_HYDROData_Entity& theObj1, const Handle_HYDROData_Entity& theObj2);