1 #ifndef HYDROData_Object_HeaderFile
2 #define HYDROData_Object_HeaderFile
6 #include <NCollection_Sequence.hxx>
7 #include <TDF_Label.hxx>
14 class Handle(TDataStd_ReferenceList);
15 class Handle_HYDROData_Object;
17 ///! Kind of an object in a document
18 typedef int ObjectKind;
19 ///! Unrecognized object
20 const ObjectKind KIND_UNKNOWN = 0;
21 const ObjectKind KIND_IMAGE = 1;
22 const ObjectKind KIND_POLYLINE = 2;
23 const ObjectKind KIND_VISUAL_STATE = 3;
24 const ObjectKind KIND_BATHYMETRY = 4;
25 const ObjectKind KIND_CALCULATION = 5;
26 const ObjectKind KIND_PROFILE = 6;
27 const ObjectKind KIND_PROFILES_GROUP = 7;
28 const ObjectKind KIND_GUIDE_LINE = 8;
29 const ObjectKind KIND_ZONE = 9;
30 const ObjectKind KIND_LAST = KIND_ZONE;
32 DEFINE_STANDARD_HANDLE(HYDROData_Object, MMgt_TShared)
34 typedef QMap<QString,Handle(Standard_Transient)> MapOfTreatedObjects;
36 typedef NCollection_Sequence<Handle_HYDROData_Object> HYDROData_SequenceOfObjects;
39 /**\class HYDROData_Object
40 * \brief Generic class of any object in the data model.
42 * Interface for getting access to the object that belong to the data model.
43 * Managed by Document. Provides access to the common properties:
44 * kind of an object, name.
46 class HYDROData_Object : public MMgt_TShared
50 * Enumeration of tags corresponding to the persistent object parameters.
54 DataTag_First = 0 ///< first tag, to reserve
59 DEFINE_STANDARD_RTTI(HYDROData_Object);
62 * Returns the kind of this object. Must be redefined in all objects of known type.
64 HYDRODATA_EXPORT virtual const ObjectKind GetKind() const {return KIND_UNKNOWN;}
67 * Returns the name of this object.
69 HYDRODATA_EXPORT QString GetName() const;
72 * Updates the name of this object.
74 HYDRODATA_EXPORT void SetName(const QString& theName);
77 * Dump object to Python script representation.
78 * Base implementation returns empty list,
79 * You should reimplement this function in your derived class if it
80 * has Python API and can be imported/exported from/to Python script.
82 HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
85 * Updates object state.
86 * Base implementation dose nothing.
87 * \param theIsForce force reupdating of data object
89 HYDRODATA_EXPORT virtual void Update( const bool theIsForce = true );
92 * Returns data of object wrapped to QVariant.
93 * Base implementation returns null value.
95 HYDRODATA_EXPORT virtual QVariant GetDataVariant();
98 * Checks is object exists in the data structure.
99 * \returns true is object is not exists in the data model
101 HYDRODATA_EXPORT bool IsRemoved() const;
104 * Removes object from the data structure.
106 HYDRODATA_EXPORT void Remove();
109 * Returns unique integer identifier of the object (may be used for ordering of objects)
111 HYDRODATA_EXPORT inline int ID() const {return myLab.Tag();}
114 * Copies all properties of this to the destinated object.
115 * Objects must be the same type.
116 * \param theDestination initialized object (from any document) - target of copying
118 HYDRODATA_EXPORT void CopyTo(Handle_HYDROData_Object theDestination) const;
121 * Returns the label of this object.
123 HYDRODATA_EXPORT TDF_Label& Label() {return myLab;}
127 friend class HYDROData_Iterator;
130 * Creates new object in the internal data structure. Use higher level objects
131 * to create objects with real content.
133 HYDRODATA_EXPORT HYDROData_Object();
136 * Destructs properties of the object and object itself, removes it from the document.
138 virtual HYDRODATA_EXPORT ~HYDROData_Object();
141 * Put the object to the label of the document.
142 * \param theLabel new label of the object
144 HYDRODATA_EXPORT virtual void SetLabel(TDF_Label theLabel);
147 * Internal method that used to store the byte array attribute
148 * \param theTag tag of a label to store attribute (for 0 this is myLab)
149 * \param theData pointer to bytes array
150 * \param theLen number of bytes in byte array that must be stored
152 void SaveByteArray(const int theTag, const char* theData, const int theLen);
155 * Internal method that used to retreive the content of byte array attribute
156 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
157 * \param theLen number of bytes in byte array
158 * \returns pointer to the internal data structure wit harray content,
159 * or NULL if array size is zero
161 const char* ByteArray(const int theTag, int& theLen) const;
164 * Internal method that used to store the reference object label attribute
165 * \param theObj pointer to reference object
166 * \param theTag tag of a label to store attribute (for 0 this is myLab)
168 int NbReferenceObjects( const int theTag = 0 ) const;
171 * Internal method that used to store the reference object label attribute
172 * \param theObj pointer to reference object
173 * \param theTag tag of a label to store attribute (for 0 this is myLab)
175 void AddReferenceObject( const Handle_HYDROData_Object& theObj,
176 const int theTag = 0 );
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)
182 * \param theIndex index in the list of references
183 - if more that len then just append it to the end of list
184 - if less than zero then prepend to the list
185 - indexing starts from 0
187 void SetReferenceObject( const Handle_HYDROData_Object& theObj,
188 const int theTag = 0,
189 const int theIndex = 0 );
192 * Internal method that used to store the reference object label attribute
193 * \param theObjects sequence with pointers to reference objects
194 * \param theTag tag of a label to store attribute (for 0 this is myLab)
196 void SetReferenceObjects( const HYDROData_SequenceOfObjects& theObjects,
197 const int theTag = 0 );
200 * Internal method that used to retreive the reference object(s) attribute
201 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
202 * \param theIndex index in the list of references
203 * - indexing starts from 0
204 * \returns pointer to reference object or NULL if label is not set
206 Handle_HYDROData_Object GetReferenceObject( const int theTag = 0,
207 const int theIndex = 0 ) const;
209 HYDROData_SequenceOfObjects GetReferenceObjects( const int theTag = 0 ) const;
212 * Internal method that used to remove the reference object attribute
213 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
214 * \param theIndex index in the list of references
215 * - indexing starts from 0
217 void RemoveReferenceObject( const int theTag = 0, const int theIndex = 0 );
220 * Internal method that used to clear list of the reference objects attribute
221 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
223 void ClearReferenceObjects( const int theTag = 0 );
226 * Internal method that used to store the color attribute
227 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
228 * \param theColor color to save
230 void SetColor( const QColor& theColor, const int theTag = 0 );
233 * Internal method that used to retreive the color attribute
234 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
235 * \param theDefColor default color to return if attribute has not been set before
237 QColor GetColor( const QColor& theDefColor, const int theTag = 0 ) const;
241 Handle(TDataStd_ReferenceList) getReferenceList( const int theTag,
242 const bool theIsCreate ) const;
246 /// Array of pointers to the properties of this object; index in this array is returned by \a AddProperty.
247 TDF_Label myLab; ///< label of this object
250 ///! Is Equal for HYDROData_Object mapping
251 HYDRODATA_EXPORT bool IsEqual(const Handle_HYDROData_Object& theObj1, const Handle_HYDROData_Object& theObj2);