1 #ifndef HYDROData_Object_HeaderFile
2 #define HYDROData_Object_HeaderFile
6 #include <NCollection_Sequence.hxx>
7 #include <TDF_Label.hxx>
13 class Handle(TDataStd_ReferenceList);
14 class Handle_HYDROData_Object;
16 ///! Kind of an object in a document
17 typedef int ObjectKind;
18 ///! Unrecognized object
19 const ObjectKind KIND_UNKNOWN = 0;
20 const ObjectKind KIND_IMAGE = 1;
21 const ObjectKind KIND_POLYLINE = 2;
22 const ObjectKind KIND_VISUAL_STATE = 3;
23 const ObjectKind KIND_BATHYMETRY = 4;
24 const ObjectKind KIND_CALCULATION = 5;
25 const ObjectKind KIND_PROFILE = 6;
26 const ObjectKind KIND_PROFILES_GROUP = 7;
27 const ObjectKind KIND_GUIDE_LINE = 8;
28 const ObjectKind KIND_ZONE = 9;
29 const ObjectKind KIND_LAST = KIND_ZONE;
31 DEFINE_STANDARD_HANDLE(HYDROData_Object, MMgt_TShared)
33 typedef QMap<QString,Handle(Standard_Transient)> MapOfTreatedObjects;
35 typedef NCollection_Sequence<Handle_HYDROData_Object> HYDROData_SequenceOfObjects;
38 /**\class HYDROData_Object
39 * \brief Generic class of any object in the data model.
41 * Interface for getting access to the object that belong to the data model.
42 * Managed by Document. Provides access to the common properties:
43 * kind of an object, name.
45 class HYDROData_Object : public MMgt_TShared
49 * Enumeration of tags corresponding to the persistent object parameters.
53 DataTag_First = 0 ///< first tag, to reserve
58 DEFINE_STANDARD_RTTI(HYDROData_Object);
61 * Returns the kind of this object. Must be redefined in all objects of known type.
63 HYDRODATA_EXPORT virtual const ObjectKind GetKind() const {return KIND_UNKNOWN;}
66 * Returns the name of this object.
68 HYDRODATA_EXPORT QString GetName() const;
71 * Updates the name of this object.
73 HYDRODATA_EXPORT void SetName(const QString& theName);
76 * Dump object to Python script representation.
77 * Base implementation returns empty list,
78 * You should reimplement this function in your derived class if it
79 * has Python API and can be imported/exported from/to Python script.
81 HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
84 * Updates object state.
85 * Base implementation dose nothing.
86 * \param theIsForce force reupdating of data object
88 HYDRODATA_EXPORT virtual void Update( const bool theIsForce = true );
91 * Returns data of object wrapped to QVariant.
92 * Base implementation returns null value.
94 HYDRODATA_EXPORT virtual QVariant GetDataVariant();
97 * Checks is object exists in the data structure.
98 * \returns true is object is not exists in the data model
100 HYDRODATA_EXPORT bool IsRemoved() const;
103 * Removes object from the data structure.
105 HYDRODATA_EXPORT void Remove();
108 * Returns unique integer identifier of the object (may be used for ordering of objects)
110 HYDRODATA_EXPORT inline int ID() const {return myLab.Tag();}
113 * Copies all properties of this to the destinated object.
114 * Objects must be the same type.
115 * \param theDestination initialized object (from any document) - target of copying
117 HYDRODATA_EXPORT void CopyTo(Handle_HYDROData_Object theDestination) const;
120 * Returns the label of this object.
122 HYDRODATA_EXPORT TDF_Label& Label() {return myLab;}
126 friend class HYDROData_Iterator;
129 * Creates new object in the internal data structure. Use higher level objects
130 * to create objects with real content.
132 HYDRODATA_EXPORT HYDROData_Object();
135 * Destructs properties of the object and object itself, removes it from the document.
137 virtual HYDRODATA_EXPORT ~HYDROData_Object();
140 * Put the object to the label of the document.
141 * \param theLabel new label of the object
143 HYDRODATA_EXPORT virtual void SetLabel(TDF_Label theLabel);
146 * Internal method that used to store the byte array attribute
147 * \param theTag tag of a label to store attribute (for 0 this is myLab)
148 * \param theData pointer to bytes array
149 * \param theLen number of bytes in byte array that must be stored
151 void SaveByteArray(const int theTag, const char* theData, const int theLen);
154 * Internal method that used to retreive the content of byte array attribute
155 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
156 * \param theLen number of bytes in byte array
157 * \returns pointer to the internal data structure wit harray content,
158 * or NULL if array size is zero
160 const char* ByteArray(const int theTag, int& theLen) const;
163 * Internal method that used to store the reference object label attribute
164 * \param theObj pointer to reference object
165 * \param theTag tag of a label to store attribute (for 0 this is myLab)
167 int NbReferenceObjects( const int theTag = 0 ) const;
170 * Internal method that used to store the reference object label attribute
171 * \param theObj pointer to reference object
172 * \param theTag tag of a label to store attribute (for 0 this is myLab)
174 void AddReferenceObject( const Handle_HYDROData_Object& theObj,
175 const int theTag = 0 );
178 * Internal method that used to store the reference object label attribute
179 * \param theObj pointer to reference object
180 * \param theTag tag of a label to store attribute (for 0 this is myLab)
181 * \param theIndex index in the list of references
182 - if more that len then just append it to the end of list
183 - if less than zero then prepend to the list
184 - indexing starts from 0
186 void SetReferenceObject( const Handle_HYDROData_Object& theObj,
187 const int theTag = 0,
188 const int theIndex = 0 );
191 * Internal method that used to retreive the reference object(s) attribute
192 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
193 * \param theIndex index in the list of references
194 * - indexing starts from 0
195 * \returns pointer to reference object or NULL if label is not set
197 Handle_HYDROData_Object GetReferenceObject( const int theTag = 0,
198 const int theIndex = 0 ) const;
200 HYDROData_SequenceOfObjects GetReferenceObjects( const int theTag = 0 ) const;
203 * Internal method that used to remove the reference object attribute
204 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
205 * \param theIndex index in the list of references
206 * - indexing starts from 0
208 void RemoveReferenceObject( const int theTag = 0, const int theIndex = 0 );
211 * Internal method that used to clear list of the reference objects attribute
212 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
214 void ClearReferenceObjects( const int theTag = 0 );
218 Handle(TDataStd_ReferenceList) getReferenceList( const int theTag,
219 const bool theIsCreate ) const;
222 /// Array of pointers to the properties of this object; index in this array is returned by \a AddProperty.
223 TDF_Label myLab; ///< label of this object
226 ///! Is Equal for HYDROData_Object mapping
227 HYDRODATA_EXPORT bool IsEqual(const Handle_HYDROData_Object& theObj1, const Handle_HYDROData_Object& theObj2);