1 #ifndef HYDROData_Image_HeaderFile
2 #define HYDROData_Image_HeaderFile
4 #include <HYDROData_Object.h>
9 DEFINE_STANDARD_HANDLE(HYDROData_Image, HYDROData_Object)
11 /**\class HYDROData_Image
12 * \brief Class that stores/retreives information about the image.
14 * Keeps image as binary array, transformation and other properties
15 * of image with correspondent API for forkind wit hthese properties.
17 class HYDROData_Image : public HYDROData_Object
21 * Enumeration of tags corresponding to the persistent object parameters.
25 DataTag_First = HYDROData_Object::DataTag_First + 100, ///< first tag, to reserve
26 DataTag_Operator, ///< name of the operator that must be executed for image update
27 DataTag_TrsfMode, ///< transformation mode (0 - Lambert93, 1 - Cartesian)
28 DataTag_TrsfPoints, ///< image transformation points (3 input + 3 output lambert + 3 output cartesian)
29 DataTag_FilePath ///< image imported file path
33 DEFINE_STANDARD_RTTI(HYDROData_Image);
36 * Returns the kind of this object. Must be redefined in all objects of known type.
38 HYDRODATA_EXPORT virtual const ObjectKind GetKind() const {return KIND_IMAGE;}
41 * Dump Image object to Python script representation.
43 HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
46 * Updates object state.
47 * Reimplemented to update an Image object in the data structure.
48 * Call this method whenever you made changes for operator or reference objects.
49 * If it is changed, sets "MustBeUpdated" flag to other depended images.
50 * \param theIsForce force reupdating of data object
52 HYDRODATA_EXPORT virtual void Update( const bool theIsForce = true );
55 * Returns data of object wrapped to QVariant.
56 * Reimplemented to wrap and return saved image.
57 * Transformation are applied to result image.
59 HYDRODATA_EXPORT virtual QVariant GetDataVariant();
63 * \param theImage new image
65 HYDRODATA_EXPORT void SetImage(const QImage& theImage);
68 * Load the image from file
69 * \param theFilePath path to image
71 HYDRODATA_EXPORT bool LoadImage(const QString& theFilePath);
74 * Returns the kept image
76 HYDRODATA_EXPORT QImage Image();
79 * Stores the image file path
80 * \param theFilePath image file path
82 HYDRODATA_EXPORT void SetFilePath(const QString& theFilePath);
85 * Returns uploaded image file path
87 HYDRODATA_EXPORT QString GetFilePath() const;
90 * Stores the image transformation
91 * \param theTrsf new transformation
93 HYDRODATA_EXPORT void SetTrsf(const QTransform& theTrsf);
96 * Returns the kept transformation, or "identity" if not yet stored
98 HYDRODATA_EXPORT QTransform Trsf() const;
101 * Stores the image transformation points (3 input + 3 output)
102 * \param thePointA input point A
103 * \param thePointB input point B
104 * \param thePointC input point C
105 * \param theLambertPointA output point A in Lambert93 coordinates
106 * \param theLambertPointB output point B in Lambert93 coordinates
107 * \param theLambertPointC output point C in Lambert93 coordinates
108 * \param theCartesianPointA output point A in Cartesian coordinates
109 * \param theCartesianPointB output point B in Cartesian coordinates
110 * \param theCartesianPointC output point C in Cartesian coordinates
112 HYDRODATA_EXPORT void SetTrsfPoints(const QPoint& thePointA,
113 const QPoint& thePointB,
114 const QPoint& thePointC,
115 const QPointF& theLambertPointA,
116 const QPointF& theLambertPointB,
117 const QPointF& theLambertPointC,
118 const QPointF& theCartesianPointA,
119 const QPointF& theCartesianPointB,
120 const QPointF& theCartesianPointC);
123 * Returns the image transformation points (3 input + 3 output)
124 * \param thePointA input point A
125 * \param thePointB input point B
126 * \param thePointC input point C
127 * \param theLambertPointA output point A in Lambert93 coordinates
128 * \param theLambertPointB output point B in Lambert93 coordinates
129 * \param theLambertPointC output point C in Lambert93 coordinates
130 * \param theCartesianPointA output point A in Cartesian coordinates
131 * \param theCartesianPointB output point B in Cartesian coordinates
132 * \param theCartesianPointC output point C in Cartesian coordinates
134 HYDRODATA_EXPORT void TrsfPoints(QPoint& thePointA,
137 QPointF& theLambertPointA,
138 QPointF& theLambertPointB,
139 QPointF& theLambertPointC,
140 QPointF& theCartesianPointA,
141 QPointF& theCartesianPointB,
142 QPointF& theCartesianPointC) const;
145 * Returns true if the image has stored transformation points
147 HYDRODATA_EXPORT bool HasTrsfPoints() const;
150 * Stores the transformation mode (0 - Lambert93, 1 - Cartesian)
152 HYDRODATA_EXPORT void SetTrsfMode(const int theMode);
155 * Returns the transformation mode (0 - Lambert93, 1 - Cartesian)
157 HYDRODATA_EXPORT int TrsfMode() const;
160 * Appends reference to other object (image or polyline).
161 * \param theReferenced the object referenced by this
163 HYDRODATA_EXPORT void AppendReference( const Handle(HYDROData_Object)& theReferenced );
166 * Returns the number of referenced objects
167 * \return zero if there is no references
169 HYDRODATA_EXPORT int NbReferences() const;
172 * Returns reference by index.
173 * \param theIndex number of reference [0; NbReference)
174 * \returns the referenced object, or Null if index is invalid
176 HYDRODATA_EXPORT Handle(HYDROData_Object) Reference(const int theIndex) const;
179 * Updates reference by index. If index is one-bigger than \a NbReferences,
180 * this method appends it to the end (NbReferences is incremented).
181 * \param theIndex number of reference [0; NbReference]
182 * \param theReferenced the object referenced by this
184 HYDRODATA_EXPORT void ChangeReference(
185 const int theIndex, Handle(HYDROData_Object) theReferenced);
188 * Removes reference by index
189 * \param theIndex number of reference [0; NbReference)
191 HYDRODATA_EXPORT void RemoveReference(const int theIndex);
194 * Removes all references.
196 HYDRODATA_EXPORT void ClearReferences();
199 * Stores the operator name
200 * \param theOpName name of the operator that must be executed for image update
202 HYDRODATA_EXPORT void SetOperatorName(const QString theOpName);
205 * Returns the operator name
206 * \returns the name of the operator that must be executed for image update
208 HYDRODATA_EXPORT QString OperatorName() const;
211 * Stores the operator arguments
212 * \param theArgs array that stores the operator arguments, needed for execution
214 HYDRODATA_EXPORT void SetArgs(const QByteArray& theArgs);
217 * Returns the operator arguments
218 * \returns array that stores the operator arguments, needed for execution
220 HYDRODATA_EXPORT QByteArray Args() const;
223 * Sets the "MustBeUpdated" flag: if image is depended on updated features.
224 * \param theFlag is true for images that must be updated, false for up-to-date
226 HYDRODATA_EXPORT void MustBeUpdated(bool theFlag);
229 * Returns the "MustBeUpdated" flag: is image must be recomputed or not
230 * \returns false if image is up to date
232 HYDRODATA_EXPORT bool MustBeUpdated() const;
235 * Marks the image as self-splitted.
236 * \param theFlag is true for self-splitted image
238 HYDRODATA_EXPORT void SetIsSelfSplitted(bool theFlag);
241 * Checks that the image is self-splitted.
242 * \returns true if image is self-splitted
244 HYDRODATA_EXPORT bool IsSelfSplitted() const;
248 friend class HYDROData_Iterator;
251 * Creates new object in the internal data structure. Use higher level objects
252 * to create objects with real content.
257 * Destructs properties of the object and object itself, removes it from the document.