2 #ifndef HYDROData_Image_HeaderFile
3 #define HYDROData_Image_HeaderFile
5 #include <HYDROData_Entity.h>
10 DEFINE_STANDARD_HANDLE(HYDROData_Image, HYDROData_Entity)
12 /**\class HYDROData_Image
13 * \brief Class that stores/retreives information about the image.
15 * Keeps image as binary array, transformation and other properties
16 * of image with correspondent API for forkind wit hthese properties.
18 class HYDROData_Image : public HYDROData_Entity
22 * Enumeration of tags corresponding to the persistent object parameters.
26 DataTag_First = HYDROData_Entity::DataTag_First + 100, ///< first tag, to reserve
27 DataTag_Operator, ///< name of the operator that must be executed for image update
28 DataTag_TrsfMode, ///< transformation mode (0 - Lambert93, 1 - Cartesian)
29 DataTag_TrsfPoints, ///< image transformation points (3 input + 3 output lambert + 3 output cartesian)
30 DataTag_FilePath ///< image imported file path
34 DEFINE_STANDARD_RTTI(HYDROData_Image);
37 * Returns the kind of this object. Must be redefined in all objects of known type.
39 HYDRODATA_EXPORT virtual const ObjectKind GetKind() const {return KIND_IMAGE;}
42 * Dump Image object to Python script representation.
44 HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
47 * Updates object state.
48 * Reimplemented to update an Image object in the data structure.
49 * Call this method whenever you made changes for operator or reference objects.
50 * If it is changed, sets "MustBeUpdated" flag to other depended images.
51 * \param theIsForce force reupdating of data object
53 HYDRODATA_EXPORT virtual void Update( const bool theIsForce = true );
56 * Returns data of object wrapped to QVariant.
57 * Reimplemented to wrap and return saved image.
58 * Transformation are applied to result image.
60 HYDRODATA_EXPORT virtual QVariant GetDataVariant();
64 * \param theImage new image
66 HYDRODATA_EXPORT void SetImage(const QImage& theImage);
69 * Load the image from file
70 * \param theFilePath path to image
72 HYDRODATA_EXPORT bool LoadImage(const QString& theFilePath);
75 * Returns the kept image
77 HYDRODATA_EXPORT QImage Image();
80 * Stores the image file path
81 * \param theFilePath image file path
83 HYDRODATA_EXPORT void SetFilePath(const QString& theFilePath);
86 * Returns uploaded image file path
88 HYDRODATA_EXPORT QString GetFilePath() const;
91 * Stores the image transformation
92 * \param theTrsf new transformation
94 HYDRODATA_EXPORT void SetTrsf(const QTransform& theTrsf);
97 * Returns the kept transformation, or "identity" if not yet stored
99 HYDRODATA_EXPORT QTransform Trsf() const;
102 * Stores the image transformation points (3 input + 3 output)
103 * \param thePointA input point A
104 * \param thePointB input point B
105 * \param thePointC input point C
106 * \param theLambertPointA output point A in Lambert93 coordinates
107 * \param theLambertPointB output point B in Lambert93 coordinates
108 * \param theLambertPointC output point C in Lambert93 coordinates
109 * \param theCartesianPointA output point A in Cartesian coordinates
110 * \param theCartesianPointB output point B in Cartesian coordinates
111 * \param theCartesianPointC output point C in Cartesian coordinates
113 HYDRODATA_EXPORT void SetTrsfPoints(const QPoint& thePointA,
114 const QPoint& thePointB,
115 const QPoint& thePointC,
116 const QPointF& theLambertPointA,
117 const QPointF& theLambertPointB,
118 const QPointF& theLambertPointC,
119 const QPointF& theCartesianPointA,
120 const QPointF& theCartesianPointB,
121 const QPointF& theCartesianPointC);
124 * Returns the image transformation points (3 input + 3 output)
125 * \param thePointA input point A
126 * \param thePointB input point B
127 * \param thePointC input point C
128 * \param theLambertPointA output point A in Lambert93 coordinates
129 * \param theLambertPointB output point B in Lambert93 coordinates
130 * \param theLambertPointC output point C in Lambert93 coordinates
131 * \param theCartesianPointA output point A in Cartesian coordinates
132 * \param theCartesianPointB output point B in Cartesian coordinates
133 * \param theCartesianPointC output point C in Cartesian coordinates
135 HYDRODATA_EXPORT void TrsfPoints(QPoint& thePointA,
138 QPointF& theLambertPointA,
139 QPointF& theLambertPointB,
140 QPointF& theLambertPointC,
141 QPointF& theCartesianPointA,
142 QPointF& theCartesianPointB,
143 QPointF& theCartesianPointC) const;
146 * Returns true if the image has stored transformation points
148 HYDRODATA_EXPORT bool HasTrsfPoints() const;
151 * Stores the transformation mode (0 - Lambert93, 1 - Cartesian)
153 HYDRODATA_EXPORT void SetTrsfMode(const int theMode);
156 * Returns the transformation mode (0 - Lambert93, 1 - Cartesian)
158 HYDRODATA_EXPORT int TrsfMode() const;
161 * Returns the number of referenced objects
162 * \return zero if there is no references
164 HYDRODATA_EXPORT int NbReferences() const;
167 * Appends reference to other object (image or polyline).
168 * \param theReferenced the object referenced by this
170 HYDRODATA_EXPORT void AppendReference( const Handle(HYDROData_Entity)& theReferenced );
173 * Returns reference by index.
174 * \param theIndex number of reference [0; NbReference)
175 * \returns the referenced object, or Null if index is invalid
177 HYDRODATA_EXPORT Handle(HYDROData_Entity) Reference(const int theIndex) const;
180 * Updates reference by index. If index is one-bigger than \a NbReferences,
181 * this method appends it to the end (NbReferences is incremented).
182 * \param theIndex number of reference [0; NbReference]
183 * \param theReferenced the object referenced by this
185 HYDRODATA_EXPORT void ChangeReference(
186 const int theIndex, Handle(HYDROData_Entity) theReferenced);
189 * Removes reference by index
190 * \param theIndex number of reference [0; NbReference)
192 HYDRODATA_EXPORT void RemoveReference(const int theIndex);
195 * Removes all references.
197 HYDRODATA_EXPORT void ClearReferences();
200 * Stores the operator name
201 * \param theOpName name of the operator that must be executed for image update
203 HYDRODATA_EXPORT void SetOperatorName(const QString theOpName);
206 * Returns the operator name
207 * \returns the name of the operator that must be executed for image update
209 HYDRODATA_EXPORT QString OperatorName() const;
212 * Stores the operator arguments
213 * \param theArgs array that stores the operator arguments, needed for execution
215 HYDRODATA_EXPORT void SetArgs(const QByteArray& theArgs);
218 * Returns the operator arguments
219 * \returns array that stores the operator arguments, needed for execution
221 HYDRODATA_EXPORT QByteArray Args() const;
224 * Sets the "MustBeUpdated" flag: if image is depended on updated features.
225 * \param theFlag is true for images that must be updated, false for up-to-date
227 HYDRODATA_EXPORT void MustBeUpdated(bool theFlag);
230 * Returns the "MustBeUpdated" flag: is image must be recomputed or not
231 * \returns false if image is up to date
233 HYDRODATA_EXPORT bool MustBeUpdated() const;
236 * Marks the image as self-splitted.
237 * \param theFlag is true for self-splitted image
239 HYDRODATA_EXPORT void SetIsSelfSplitted(bool theFlag);
242 * Checks that the image is self-splitted.
243 * \returns true if image is self-splitted
245 HYDRODATA_EXPORT bool IsSelfSplitted() const;
249 friend class HYDROData_Iterator;
252 * Creates new object in the internal data structure. Use higher level objects
253 * to create objects with real content.
258 * Destructs properties of the object and object itself, removes it from the document.