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;
30 DEFINE_STANDARD_HANDLE(HYDROData_Object, MMgt_TShared)
32 typedef QMap<QString,Handle(Standard_Transient)> MapOfTreatedObjects;
34 typedef NCollection_Sequence<Handle_HYDROData_Object> HYDROData_SequenceOfObjects;
37 /**\class HYDROData_Object
38 * \brief Generic class of any object in the data model.
40 * Interface for getting access to the object that belong to the data model.
41 * Managed by Document. Provides access to the common properties:
42 * kind of an object, name.
44 class HYDROData_Object : public MMgt_TShared
48 * Enumeration of tags corresponding to the persistent object parameters.
52 DataTag_First = 0 ///< first tag, to reserve
57 DEFINE_STANDARD_RTTI(HYDROData_Object);
60 * Returns the kind of this object. Must be redefined in all objects of known type.
62 HYDRODATA_EXPORT virtual const ObjectKind GetKind() const {return KIND_UNKNOWN;}
65 * Returns the name of this object.
67 HYDRODATA_EXPORT QString GetName() const;
70 * Updates the name of this object.
72 HYDRODATA_EXPORT void SetName(const QString& theName);
75 * Dump object to Python script representation.
76 * Base implementation returns empty list,
77 * You should reimplement this function in your derived class if it
78 * has Python API and can be imported/exported from/to Python script.
80 HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
83 * Updates object state.
84 * Base implementation dose nothing.
85 * \param theIsForce force reupdating of data object
87 HYDRODATA_EXPORT virtual void Update( const bool theIsForce = true );
90 * Returns data of object wrapped to QVariant.
91 * Base implementation returns null value.
93 HYDRODATA_EXPORT virtual QVariant GetDataVariant();
96 * Checks is object exists in the data structure.
97 * \returns true is object is not exists in the data model
99 HYDRODATA_EXPORT bool IsRemoved() const;
102 * Removes object from the data structure.
104 HYDRODATA_EXPORT void Remove();
107 * Returns unique integer identifier of the object (may be used for ordering of objects)
109 HYDRODATA_EXPORT inline int ID() const {return myLab.Tag();}
112 * Copies all properties of this to the destinated object.
113 * Objects must be the same type.
114 * \param theDestination initialized object (from any document) - target of copying
116 HYDRODATA_EXPORT void CopyTo(Handle_HYDROData_Object theDestination) const;
119 * Returns the label of this object.
121 HYDRODATA_EXPORT TDF_Label& Label() {return myLab;}
125 friend class HYDROData_Iterator;
128 * Creates new object in the internal data structure. Use higher level objects
129 * to create objects with real content.
131 HYDRODATA_EXPORT HYDROData_Object();
134 * Destructs properties of the object and object itself, removes it from the document.
136 virtual HYDRODATA_EXPORT ~HYDROData_Object();
139 * Put the object to the label of the document.
140 * \param theLabel new label of the object
142 HYDRODATA_EXPORT virtual void SetLabel(TDF_Label theLabel);
145 * Internal method that used to store the byte array attribute
146 * \param theTag tag of a label to store attribute (for 0 this is myLab)
147 * \param theData pointer to bytes array
148 * \param theLen number of bytes in byte array that must be stored
150 void SaveByteArray(const int theTag, const char* theData, const int theLen);
153 * Internal method that used to retreive the content of byte array attribute
154 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
155 * \param theLen number of bytes in byte array
156 * \returns pointer to the internal data structure wit harray content,
157 * or NULL if array size is zero
159 const char* ByteArray(const int theTag, int& theLen) const;
162 * Internal method that used to store the reference object label attribute
163 * \param theObj pointer to reference object
164 * \param theTag tag of a label to store attribute (for 0 this is myLab)
166 int NbReferenceObjects( const int theTag = 0 ) const;
169 * Internal method that used to store the reference object label attribute
170 * \param theObj pointer to reference object
171 * \param theTag tag of a label to store attribute (for 0 this is myLab)
173 void AddReferenceObject( const Handle_HYDROData_Object& theObj,
174 const int theTag = 0 );
177 * Internal method that used to store the reference object label attribute
178 * \param theObj pointer to reference object
179 * \param theTag tag of a label to store attribute (for 0 this is myLab)
180 * \param theIndex index in the list of references
181 - if more that len then just append it to the end of list
182 - if less than zero then prepend to the list
183 - indexing starts from 0
185 void SetReferenceObject( const Handle_HYDROData_Object& theObj,
186 const int theTag = 0,
187 const int theIndex = 0 );
190 * Internal method that used to retreive the reference object(s) attribute
191 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
192 * \param theIndex index in the list of references
193 * - indexing starts from 0
194 * \returns pointer to reference object or NULL if label is not set
196 Handle_HYDROData_Object GetReferenceObject( const int theTag = 0,
197 const int theIndex = 0 ) const;
199 HYDROData_SequenceOfObjects GetReferenceObjects( const int theTag = 0 ) const;
202 * Internal method that used to remove the reference object attribute
203 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
204 * \param theIndex index in the list of references
205 * - indexing starts from 0
207 void RemoveReferenceObject( const int theTag = 0, const int theIndex = 0 );
210 * Internal method that used to clear list of the reference objects attribute
211 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
213 void ClearReferenceObjects( const int theTag = 0 );
217 Handle(TDataStd_ReferenceList) getReferenceList( const int theTag,
218 const bool theIsCreate ) const;
221 /// Array of pointers to the properties of this object; index in this array is returned by \a AddProperty.
222 TDF_Label myLab; ///< label of this object
225 ///! Is Equal for HYDROData_Object mapping
226 HYDRODATA_EXPORT bool IsEqual(const Handle_HYDROData_Object& theObj1, const Handle_HYDROData_Object& theObj2);