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;}
142 friend class HYDROData_Iterator;
145 * Creates new object in the internal data structure. Use higher level objects
146 * to create objects with real content.
148 HYDRODATA_EXPORT HYDROData_Entity();
151 * Destructs properties of the object and object itself, removes it from the document.
153 virtual HYDRODATA_EXPORT ~HYDROData_Entity();
156 * Put the object to the label of the document.
157 * \param theLabel new label of the object
159 HYDRODATA_EXPORT virtual void SetLabel(TDF_Label theLabel);
162 * Internal method that used to store the byte array attribute
163 * \param theTag tag of a label to store attribute (for 0 this is myLab)
164 * \param theData pointer to bytes array
165 * \param theLen number of bytes in byte array that must be stored
167 void SaveByteArray(const int theTag, const char* theData, const int theLen);
170 * Internal method that used to retreive the content of byte array attribute
171 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
172 * \param theLen number of bytes in byte array
173 * \returns pointer to the internal data structure wit harray content,
174 * or NULL if array size is zero
176 const char* ByteArray(const int theTag, int& theLen) const;
179 * Internal method that used to store the reference object label attribute
180 * \param theObj pointer to reference object
181 * \param theTag tag of a label to store attribute (for 0 this is myLab)
183 int NbReferenceObjects( const int theTag = 0 ) 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 void AddReferenceObject( const Handle_HYDROData_Entity& theObj,
191 const int theTag = 0 );
194 * Internal method that used to store the reference object label attribute
195 * \param theObj pointer to reference object
196 * \param theTag tag of a label to store attribute (for 0 this is myLab)
197 * \param theIndex index in the list of references
198 - if more that len then just append it to the end of list
199 - if less than zero then prepend to the list
200 - indexing starts from 0
202 void SetReferenceObject( const Handle_HYDROData_Entity& theObj,
203 const int theTag = 0,
204 const int theIndex = 0 );
207 * Internal method that used to store the reference object label attribute
208 * \param theObj pointer to reference object
209 * \param theTag tag of a label to store attribute (for 0 this is myLab)
210 * \param theBeforeIndex index in the list of references
211 - if more that len then just append it to the end of list
212 - if less than zero then prepend to the list
213 - indexing starts from 0
215 void InsertReferenceObject( const Handle_HYDROData_Entity& theObj,
216 const int theTag = 0,
217 const int theBeforeIndex = 0 );
220 * Internal method that used to store the reference object label attribute
221 * \param theObjects sequence with pointers to reference objects
222 * \param theTag tag of a label to store attribute (for 0 this is myLab)
224 void SetReferenceObjects( const HYDROData_SequenceOfObjects& theObjects,
225 const int theTag = 0 );
228 * Internal method that used to retreive the reference object(s) attribute
229 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
230 * \param theIndex index in the list of references
231 * - indexing starts from 0
232 * \returns pointer to reference object or NULL if label is not set
234 Handle_HYDROData_Entity GetReferenceObject( const int theTag = 0,
235 const int theIndex = 0 ) const;
237 HYDROData_SequenceOfObjects GetReferenceObjects( const int theTag = 0 ) const;
240 * Internal method that used to remove the reference object attribute
241 * \param theRefLabel reference object label to remove
242 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
244 void RemoveReferenceObject( const TDF_Label& theRefLabel, const int theTag = 0 );
247 * Internal method that used to remove the reference object attribute
248 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
249 * \param theIndex index in the list of references
250 * - indexing starts from 0
252 void RemoveReferenceObject( const int theTag = 0, const int theIndex = 0 );
255 * Internal method that used to clear list of the reference objects attribute
256 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
258 void ClearReferenceObjects( const int theTag = 0 );
261 * Internal method that used to store the color attribute
262 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
263 * \param theColor color to save
265 void SetColor( const QColor& theColor, const int theTag = 0 );
268 * Internal method that used to retreive the color attribute
269 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
270 * \param theDefColor default color to return if attribute has not been set before
272 QColor GetColor( const QColor& theDefColor, const int theTag = 0 ) const;
277 void setPythonReferenceObject( MapOfTreatedObjects& theTreatedObjects,
278 QStringList& theScript,
279 const Handle(HYDROData_Entity)& theRefObject,
280 const QString& theMethod ) const;
283 Handle(TDataStd_ReferenceList) getReferenceList( const int theTag,
284 const bool theIsCreate ) const;
288 /// Array of pointers to the properties of this object; index in this array is returned by \a AddProperty.
289 TDF_Label myLab; ///< label of this object
292 ///! Is Equal for HYDROData_Entity mapping
293 HYDRODATA_EXPORT bool IsEqual(const Handle_HYDROData_Entity& theObj1, const Handle_HYDROData_Entity& theObj2);