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_IMMERSIBLE_ZONE = 4;
28 const ObjectKind KIND_GUIDE_LINE = 5;
29 const ObjectKind KIND_PROFILE = 6;
30 const ObjectKind KIND_CALCULATION = 7;
31 const ObjectKind KIND_ZONE = 8;
32 const ObjectKind KIND_REGION = 9;
33 const ObjectKind KIND_VISUAL_STATE = 10;
34 const ObjectKind KIND_LAST = KIND_VISUAL_STATE;
36 DEFINE_STANDARD_HANDLE(HYDROData_Entity, MMgt_TShared)
38 typedef QMap<QString,Handle(Standard_Transient)> MapOfTreatedObjects;
40 typedef NCollection_Sequence<Handle_HYDROData_Entity> HYDROData_SequenceOfObjects;
43 /**\class HYDROData_Entity
44 * \brief Generic class of any object in the data model.
46 * Interface for getting access to the object that belong to the data model.
47 * Managed by Document. Provides access to the common properties:
48 * kind of an object, name.
50 class HYDROData_Entity : public MMgt_TShared
56 * Enumeration of tags corresponding to the persistent object parameters.
60 DataTag_First = 0 ///< first tag, to reserve
65 * Enumeration of tags corresponding to the child sub-objects of object.
69 ChildTag_First = 0 ///< first tag, to reserve
74 DEFINE_STANDARD_RTTI(HYDROData_Entity);
77 * Returns the kind of this object. Must be redefined in all objects of known type.
79 HYDRODATA_EXPORT virtual const ObjectKind GetKind() const { return KIND_UNKNOWN; }
82 * Returns the name of this object.
84 HYDRODATA_EXPORT QString GetName() const;
87 * Updates the name of this object.
89 HYDRODATA_EXPORT void SetName(const QString& theName);
92 * Dump object to Python script representation.
93 * Base implementation returns empty list,
94 * You should reimplement this function in your derived class if it
95 * has Python API and can be imported/exported from/to Python script.
97 HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
100 * Updates object state.
101 * Base implementation dose nothing.
102 * \param theIsForce force reupdating of data object
104 HYDRODATA_EXPORT virtual void Update( const bool theIsForce = true );
107 * Returns data of object wrapped to QVariant.
108 * Base implementation returns null value.
110 HYDRODATA_EXPORT virtual QVariant GetDataVariant();
113 * Checks is object exists in the data structure.
114 * \returns true is object is not exists in the data model
116 HYDRODATA_EXPORT bool IsRemoved() const;
119 * Removes object and it child sub-objects from the data structure.
121 HYDRODATA_EXPORT virtual void Remove();
124 * Returns unique integer identifier of the object (may be used for ordering of objects)
126 HYDRODATA_EXPORT inline int ID() const {return myLab.Tag();}
129 * Copies all properties of this to the destinated object.
130 * Objects must be the same type.
131 * \param theDestination initialized object (from any document) - target of copying
133 HYDRODATA_EXPORT void CopyTo(Handle_HYDROData_Entity theDestination) const;
136 * Returns the label of this object.
138 HYDRODATA_EXPORT TDF_Label& Label() {return myLab;}
141 * Returns father object. For object created under root document label
142 * this method always return NULL object.
144 HYDRODATA_EXPORT virtual Handle(HYDROData_Entity) GetFatherObject() const;
148 friend class HYDROData_Iterator;
151 * Creates new object in the internal data structure. Use higher level objects
152 * to create objects with real content.
154 HYDRODATA_EXPORT HYDROData_Entity();
157 * Destructs properties of the object and object itself, removes it from the document.
159 virtual HYDRODATA_EXPORT ~HYDROData_Entity();
162 * Put the object to the label of the document.
163 * \param theLabel new label of the object
165 HYDRODATA_EXPORT virtual void SetLabel(TDF_Label theLabel);
168 * Internal method that used to store the byte array attribute
169 * \param theTag tag of a label to store attribute (for 0 this is myLab)
170 * \param theData pointer to bytes array
171 * \param theLen number of bytes in byte array that must be stored
173 void SaveByteArray(const int theTag, const char* theData, const int theLen);
176 * Internal method that used to retreive the content of byte array attribute
177 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
178 * \param theLen number of bytes in byte array
179 * \returns pointer to the internal data structure wit harray content,
180 * or NULL if array size is zero
182 const char* ByteArray(const int theTag, int& theLen) const;
185 * Internal method that used to store the reference object label attribute
186 * \param theObj pointer to reference object
187 * \param theTag tag of a label to store attribute (for 0 this is myLab)
189 int NbReferenceObjects( const int theTag = 0 ) const;
192 * Internal method that used to check object for entry into the reference list
193 * \param theObj pointer to reference object
194 * \param theTag tag of a label to store attribute (for 0 this is myLab)
196 bool HasReference( const Handle_HYDROData_Entity& theObj,
197 const int theTag = 0 ) const;
200 * Internal method that used to store the reference object label attribute
201 * \param theObj pointer to reference object
202 * \param theTag tag of a label to store attribute (for 0 this is myLab)
204 void AddReferenceObject( const Handle_HYDROData_Entity& theObj,
205 const int theTag = 0 );
208 * Internal method that used to store the reference object label attribute
209 * \param theObj pointer to reference object
210 * \param theTag tag of a label to store attribute (for 0 this is myLab)
211 * \param theIndex index in the list of references
212 - if more that len then just append it to the end of list
213 - if less than zero then prepend to the list
214 - indexing starts from 0
216 void SetReferenceObject( const Handle_HYDROData_Entity& theObj,
217 const int theTag = 0,
218 const int theIndex = 0 );
221 * Internal method that used to store the reference object label attribute
222 * \param theObj pointer to reference object
223 * \param theTag tag of a label to store attribute (for 0 this is myLab)
224 * \param theBeforeIndex index in the list of references
225 - if more that len then just append it to the end of list
226 - if less than zero then prepend to the list
227 - indexing starts from 0
229 void InsertReferenceObject( const Handle_HYDROData_Entity& theObj,
230 const int theTag = 0,
231 const int theBeforeIndex = 0 );
234 * Internal method that used to store the reference object label attribute
235 * \param theObjects sequence with pointers to reference objects
236 * \param theTag tag of a label to store attribute (for 0 this is myLab)
238 void SetReferenceObjects( const HYDROData_SequenceOfObjects& theObjects,
239 const int theTag = 0 );
242 * Internal method that used to retreive the reference object(s) attribute
243 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
244 * \param theIndex index in the list of references
245 * - indexing starts from 0
246 * \returns pointer to reference object or NULL if label is not set
248 Handle_HYDROData_Entity GetReferenceObject( const int theTag = 0,
249 const int theIndex = 0 ) const;
251 HYDROData_SequenceOfObjects GetReferenceObjects( const int theTag = 0 ) const;
254 * Internal method that used to remove the reference object attribute
255 * \param theRefLabel reference object label to remove
256 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
258 void RemoveReferenceObject( const TDF_Label& theRefLabel, const int theTag = 0 );
261 * Internal method that used to remove the reference object attribute
262 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
263 * \param theIndex index in the list of references
264 * - indexing starts from 0
266 void RemoveReferenceObject( const int theTag = 0, const int theIndex = 0 );
269 * Internal method that used to clear list of the reference objects attribute
270 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
272 void ClearReferenceObjects( const int theTag = 0 );
275 * Internal method that used to store the color attribute
276 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
277 * \param theColor color to save
279 void SetColor( const QColor& theColor, const int theTag = 0 );
282 * Internal method that used to retreive the color attribute
283 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
284 * \param theDefColor default color to return if attribute has not been set before
286 QColor GetColor( const QColor& theDefColor, const int theTag = 0 ) const;
291 void setPythonReferenceObject( MapOfTreatedObjects& theTreatedObjects,
292 QStringList& theScript,
293 const Handle(HYDROData_Entity)& theRefObject,
294 const QString& theMethod ) const;
297 Handle(TDataStd_ReferenceList) getReferenceList( const int theTag,
298 const bool theIsCreate ) const;
302 /// Array of pointers to the properties of this object; index in this array is returned by \a AddProperty.
303 TDF_Label myLab; ///< label of this object
306 ///! Is Equal for HYDROData_Entity mapping
307 HYDRODATA_EXPORT bool IsEqual(const Handle_HYDROData_Entity& theObj1, const Handle_HYDROData_Entity& theObj2);