1 #ifndef HYDROData_Object_HeaderFile
2 #define HYDROData_Object_HeaderFile
6 #include <NCollection_Sequence.hxx>
7 #include <TDF_Label.hxx>
14 ///! Kind of an object in a document
15 typedef int ObjectKind;
16 ///! Unrecognized object
17 const ObjectKind KIND_UNKNOWN = 0;
18 const ObjectKind KIND_IMAGE = 1;
19 const ObjectKind KIND_POLYLINE = 2;
20 const ObjectKind KIND_VISUAL_STATE = 3;
21 const ObjectKind KIND_BATHYMETRY = 4;
23 DEFINE_STANDARD_HANDLE(HYDROData_Object, MMgt_TShared)
25 typedef QMap<QString,Handle(Standard_Transient)> MapOfTreatedObjects;
27 /**\class HYDROData_Object
28 * \brief Generic class of any object in the data model.
30 * Interface for getting access to the object that belong to the data model.
31 * Managed by Document. Provides access to the common properties:
32 * kind of an object, name.
34 class HYDROData_Object : public MMgt_TShared
38 * Enumeration of tags corresponding to the persistent object parameters.
42 DataTag_First = 0 ///< first tag, to reserve
47 DEFINE_STANDARD_RTTI(HYDROData_Object);
50 * Returns the kind of this object. Must be redefined in all objects of known type.
52 HYDRODATA_EXPORT virtual const ObjectKind GetKind() const {return KIND_UNKNOWN;}
55 * Returns the name of this object.
57 HYDRODATA_EXPORT QString GetName() const;
60 * Updates the name of this object.
62 HYDRODATA_EXPORT void SetName(const QString& theName);
65 * Dump object to Python script representation.
66 * Base implementation returns empty list,
67 * You should reimplement this function in your derived class if it
68 * has Python API and can be imported/exported from/to Python script.
70 HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
73 * Updates object state.
74 * Base implementation dose nothing.
76 HYDRODATA_EXPORT virtual void Update();
79 * Returns data of object wrapped to QVariant.
80 * Base implementation returns null value.
82 HYDRODATA_EXPORT virtual QVariant GetDataVariant();
85 * Checks is object exists in the data structure.
86 * \returns true is object is not exists in the data model
88 HYDRODATA_EXPORT bool IsRemoved() const;
91 * Removes object from the data structure.
93 HYDRODATA_EXPORT void Remove();
96 * Returns unique integer identifier of the object (may be used for ordering of objects)
98 HYDRODATA_EXPORT inline int ID() const {return myLab.Tag();}
101 * Copies all properties of this to the destinated object.
102 * Objects must be the same type.
103 * \param theDestination initialized object (from any document) - target of copying
105 HYDRODATA_EXPORT void CopyTo(Handle_HYDROData_Object theDestination) const;
108 * Returns the label of this object.
110 HYDRODATA_EXPORT TDF_Label& Label() {return myLab;}
114 friend class HYDROData_Iterator;
117 * Creates new object in the internal data structure. Use higher level objects
118 * to create objects with real content.
120 HYDRODATA_EXPORT HYDROData_Object();
123 * Destructs properties of the object and object itself, removes it from the document.
125 virtual HYDRODATA_EXPORT ~HYDROData_Object();
128 * Put the object to the label of the document.
129 * \param theLabel new label of the object
131 HYDRODATA_EXPORT virtual void SetLabel(TDF_Label theLabel);
134 * Internal method that used to store the byte array attribute
135 * \param theTag tag of a label to store attribute (for 0 this is myLab)
136 * \param theData pointer to bytes array
137 * \param theLen number of bytes in byte array that must be stored
139 void SaveByteArray(const int theTag, const char* theData, const int theLen);
142 * Internal method that used to retreive the content of byte array attribute
143 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
144 * \param theLen number of bytes in byte array
145 * \returns pointer to the internal data structure wit harray content,
146 * or NULL if array size is zero
148 const char* ByteArray(const int theTag, int& theLen) const;
151 /// Array of pointers to the properties of this object; index in this array is returned by \a AddProperty.
152 TDF_Label myLab; ///< label of this object
155 typedef NCollection_Sequence<Handle_HYDROData_Object> HYDROData_SequenceOfObjects;
157 ///! Is Equal for HYDROData_Object mapping
158 HYDRODATA_EXPORT bool IsEqual(const Handle_HYDROData_Object& theObj1, const Handle_HYDROData_Object& theObj2);