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_GUIDE_LINE = 6;
30 const ObjectKind KIND_PROFILE = 7;
31 const ObjectKind KIND_CALCULATION = 8;
32 const ObjectKind KIND_ZONE = 9;
33 const ObjectKind KIND_REGION = 10;
34 const ObjectKind KIND_VISUAL_STATE = 11;
35 const ObjectKind KIND_LAST = KIND_VISUAL_STATE;
37 DEFINE_STANDARD_HANDLE(HYDROData_Entity, MMgt_TShared)
39 typedef QMap<QString,Handle(Standard_Transient)> MapOfTreatedObjects;
41 typedef NCollection_Sequence<Handle_HYDROData_Entity> HYDROData_SequenceOfObjects;
44 /**\class HYDROData_Entity
45 * \brief Generic class of any object in the data model.
47 * Interface for getting access to the object that belong to the data model.
48 * Managed by Document. Provides access to the common properties:
49 * kind of an object, name.
51 class HYDROData_Entity : public MMgt_TShared
57 * Enumeration of tags corresponding to the persistent object parameters.
61 DataTag_First = 0 ///< first tag, to reserve
66 * Enumeration of tags corresponding to the child sub-objects of object.
70 ChildTag_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 QString GetName() const;
88 * Updates the name of this object.
90 HYDRODATA_EXPORT 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.
102 * Base implementation dose nothing.
103 * \param theIsForce force reupdating of data object
105 HYDRODATA_EXPORT virtual void Update( const bool theIsForce = true );
108 * Returns data of object wrapped to QVariant.
109 * Base implementation returns null value.
111 HYDRODATA_EXPORT virtual QVariant GetDataVariant();
114 * Checks is object exists in the data structure.
115 * \returns true is object is not exists in the data model
117 HYDRODATA_EXPORT bool IsRemoved() const;
120 * Removes object and it child sub-objects from the data structure.
122 HYDRODATA_EXPORT virtual void Remove();
125 * Returns unique integer identifier of the object (may be used for ordering of objects)
127 HYDRODATA_EXPORT inline int ID() const {return myLab.Tag();}
130 * Copies all properties of this to the destinated object.
131 * Objects must be the same type.
132 * \param theDestination initialized object (from any document) - target of copying
134 HYDRODATA_EXPORT void CopyTo(Handle_HYDROData_Entity theDestination) const;
137 * Returns the label of this object.
139 HYDRODATA_EXPORT TDF_Label& Label() {return myLab;}
142 * Returns father object. For object created under root document label
143 * this method always return NULL object.
145 HYDRODATA_EXPORT virtual Handle(HYDROData_Entity) GetFatherObject() const;
149 friend class HYDROData_Iterator;
152 * Creates new object in the internal data structure. Use higher level objects
153 * to create objects with real content.
155 HYDRODATA_EXPORT HYDROData_Entity();
158 * Destructs properties of the object and object itself, removes it from the document.
160 virtual HYDRODATA_EXPORT ~HYDROData_Entity();
163 * Put the object to the label of the document.
164 * \param theLabel new label of the object
166 HYDRODATA_EXPORT virtual void SetLabel(TDF_Label theLabel);
169 * Internal method that used to store the byte array attribute
170 * \param theTag tag of a label to store attribute (for 0 this is myLab)
171 * \param theData pointer to bytes array
172 * \param theLen number of bytes in byte array that must be stored
174 void SaveByteArray(const int theTag, const char* theData, const int theLen);
177 * Internal method that used to retreive the content of byte array attribute
178 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
179 * \param theLen number of bytes in byte array
180 * \returns pointer to the internal data structure wit harray content,
181 * or NULL if array size is zero
183 const char* ByteArray(const int theTag, int& theLen) const;
186 * Internal method that used to store the reference object label attribute
187 * \param theObj pointer to reference object
188 * \param theTag tag of a label to store attribute (for 0 this is myLab)
190 int NbReferenceObjects( const int theTag = 0 ) const;
193 * Internal method that used to check object for entry into the reference list
194 * \param theObj pointer to reference object
195 * \param theTag tag of a label to store attribute (for 0 this is myLab)
197 bool HasReference( const Handle_HYDROData_Entity& theObj,
198 const int theTag = 0 ) const;
201 * Internal method that used to store the reference object label attribute
202 * \param theObj pointer to reference object
203 * \param theTag tag of a label to store attribute (for 0 this is myLab)
205 void AddReferenceObject( const Handle_HYDROData_Entity& theObj,
206 const int theTag = 0 );
209 * Internal method that used to store the reference object label attribute
210 * \param theObj pointer to reference object
211 * \param theTag tag of a label to store attribute (for 0 this is myLab)
212 * \param theIndex index in the list of references
213 - if more that len then just append it to the end of list
214 - if less than zero then prepend to the list
215 - indexing starts from 0
217 void SetReferenceObject( const Handle_HYDROData_Entity& theObj,
218 const int theTag = 0,
219 const int theIndex = 0 );
222 * Internal method that used to store the reference object label attribute
223 * \param theObj pointer to reference object
224 * \param theTag tag of a label to store attribute (for 0 this is myLab)
225 * \param theBeforeIndex index in the list of references
226 - if more that len then just append it to the end of list
227 - if less than zero then prepend to the list
228 - indexing starts from 0
230 void InsertReferenceObject( const Handle_HYDROData_Entity& theObj,
231 const int theTag = 0,
232 const int theBeforeIndex = 0 );
235 * Internal method that used to store the reference object label attribute
236 * \param theObjects sequence with pointers to reference objects
237 * \param theTag tag of a label to store attribute (for 0 this is myLab)
239 void SetReferenceObjects( const HYDROData_SequenceOfObjects& theObjects,
240 const int theTag = 0 );
243 * Internal method that used to retreive the reference object(s) attribute
244 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
245 * \param theIndex index in the list of references
246 * - indexing starts from 0
247 * \returns pointer to reference object or NULL if label is not set
249 Handle_HYDROData_Entity GetReferenceObject( const int theTag = 0,
250 const int theIndex = 0 ) const;
252 HYDROData_SequenceOfObjects GetReferenceObjects( const int theTag = 0 ) const;
255 * Internal method that used to remove the reference object attribute
256 * \param theRefLabel reference object label to remove
257 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
259 void RemoveReferenceObject( const TDF_Label& theRefLabel, const int theTag = 0 );
262 * Internal method that used to remove the reference object attribute
263 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
264 * \param theIndex index in the list of references
265 * - indexing starts from 0
267 void RemoveReferenceObject( const int theTag = 0, const int theIndex = 0 );
270 * Internal method that used to clear list of the reference objects attribute
271 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
273 void ClearReferenceObjects( const int theTag = 0 );
276 * Internal method that used to store the color attribute
277 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
278 * \param theColor color to save
280 void SetColor( const QColor& theColor, const int theTag = 0 );
283 * Internal method that used to retreive the color attribute
284 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
285 * \param theDefColor default color to return if attribute has not been set before
287 QColor GetColor( const QColor& theDefColor, const int theTag = 0 ) const;
292 void setPythonReferenceObject( MapOfTreatedObjects& theTreatedObjects,
293 QStringList& theScript,
294 const Handle(HYDROData_Entity)& theRefObject,
295 const QString& theMethod ) const;
298 Handle(TDataStd_ReferenceList) getReferenceList( const int theTag,
299 const bool theIsCreate ) const;
303 /// Array of pointers to the properties of this object; index in this array is returned by \a AddProperty.
304 TDF_Label myLab; ///< label of this object
307 ///! Is Equal for HYDROData_Entity mapping
308 HYDRODATA_EXPORT bool IsEqual(const Handle_HYDROData_Entity& theObj1, const Handle_HYDROData_Entity& theObj2);