ImageItem.h
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3 This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5 TerraLib is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9 
10 TerraLib is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14 
15 You should have received a copy of the GNU Lesser General Public License
16 along with TerraLib. See COPYING. If not, write to
17 TerraLib Team at <terralib-team@terralib.org>.
18 */
19 
20 /*!
21 \file terralib/qt/widgets/st/ImageItem.h
22 
23 \brief This file defines a abstarct class for a Image Item.
24 */
25 
26 #ifndef __TERRALIB_QT_WIDGETS_SLIDER_INTERNAL_IMAGE_ITEM_H
27 #define __TERRALIB_QT_WIDGETS_SLIDER_INTERNAL_IMAGE_ITEM_H
28 
29 // TerraLib
30 #include "AnimationItem.h"
31 #include "../Config.h"
32 #include "../../../geometry.h"
33 #include "../../../datatype.h"
34 
35 // Qt
36 #include <QtCore/QAbstractAnimation>
37 #include <QtCore/QDir>
38 
39 namespace te
40 {
41  namespace dt
42  {
43  class DateTimeInstant;
44  class TimePeriod;
45  }
46 
47  namespace qt
48  {
49  namespace widgets
50  {
51  class MapDisplay;
52  class Animation;
53 
54  /*!
55  \class This abstract class is used to make animation of temporal image on map display.
56 
57  Note: It does not use QPixmap. It uses an array of images already
58  processed to make the animation. Therefore, the pixmap() method
59  returns null. Anyway is an artifice used to animate temporal image
60  instead trajectory.
61  */
63  {
64  //Q_OBJECT
65  //Q_PROPERTY(QPointF pos READ pos WRITE setPos)
66 
67  public:
68 
69  /*!
70  \brief Empty Constructor.
71  */
72  ImageItem();
73 
74  /*!
75  \brief Constructor
76  It constructs a Image Item.
77  \param title The image item title.
78  \param folder The absolute folder path name.
79  \param display Where the pixmap item is displayed.
80  */
81  ImageItem(const QString& title, const QString& folder, te::qt::widgets::MapDisplay* display);
82 
83  /*!
84  \brief Destructor
85  It destructs a Image Item.
86  */
87  virtual ~ImageItem();
88 
89  /*!
90  \brief Load temporal raster data.
91 
92  \Return True if success.
93  */
94  virtual bool loadData();
95 
96  /*!
97  \brief Paint a image item.
98  */
99  void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*);
100 
101  /*!
102  \brief Calculate current file.
103 
104  \param curTime current time
105  */
106  void calculateCurrentFile(const unsigned int& curTime); // remover
107 
108  /*!
109  \brief Draw the current image item.
110  */
111  void draw();
112 
113  /*!
114  \brief It try do reprojection using affine transfom.
115  For small areas it gives a good result, however, for larger areas the result is not good.
116 
117  \param painter Painter that will be configured to try do reprojection.
118  */
119  void tryDoReprojectionUsingAffineTransform(QPainter* painter);
120 
121  /*!
122  \brief Adjust data for a given time animation period.
123  */
124  void adjustDataToAnimationTemporalExtent();
125 
126  void setImagePosition(const QPointF& p, const QRectF& dr);
127 
128  /*!
129  \brief Get control parameters.
130  */
131  virtual bool getCtlParameters();
132 
133  /*!
134  \brief Get current image.
135 
136  \Return pointer to current image.
137  */
138  virtual void loadCurrentImage();
139 
140  /*!
141  \brief Get current image.
142 
143  \Param p Pointer to QPainter.
144  \Param r Image rect in device coordinate.
145  \Param ima Pointer to QImage.
146  */
147  virtual void drawCurrentImage(QPainter* p);
148 
149  /*!
150  \brief It gets image rect in device coordinate.
151  */
152  QRect getRect();
153 
154  /*!
155  \brief Draw current image item.
156  \paran curTime The animation current time.
157  */
158  void drawForward(const unsigned int& curTime);
159 
160  /*!
161  \brief Draw current image item.
162  \paran curTime The animation current time.
163  */
164  void erase(const unsigned int& curTime);
165 
166  /*!
167  \brief Sets the LUT.
168  \paran tab The LUT information.
169  */
170  void setLUT(const std::vector<std::pair<int, QColor> >& tab);
171 
172  /*!
173  \brief It generate the raster route.
174 
175  \paran animation The animation control.
176  \param count The temporal data size.
177  */
178  void generateRoute();
179 
180  private:
181 
182  /*!
183  \brief Get time of the raster data.
184 
185  \Param file raster data file name.
186 
187  \Return The time instant.
188  */
189  virtual te::dt::TimeInstant getTime(QString file) = 0;
190 
191  public:
192  QDir m_dir; //!< The image data directory.
193  size_t m_nlines; //!< number of lines.
194  size_t m_ncols; //!< number of colunms.
195  float m_undef; //!< undef value.
196  QVector<QString> m_files; //!< The input files.
197  QVector<QString> m_animationFiles; //!< The png files in display projection. It contains only the portions to be animated.
198  QString m_currentImageFile; //!< Image to be displayed on paint event animation.
199  QImage* m_image; //!< current image
200  QString m_baseFile; //!< Base file name.
201  QString m_suffix; //!< File suffix.
202  QString m_preffix; //!< File preffix.
203  QRectF m_imaRect; //!< Image location.
204  std::map<uchar, QColor> m_lut; //!< LUT
205  QPointF m_imageCenterPos; //!< Center of the image.
206  QImage m_staticRepresentation; //!< Static representation of the animation.
207  };
208  } // end namespace widgets
209  } // end namespace qt
210 } // end namespace te
211 
212 #endif // __TERRALIB_QT_WIDGETS_SLIDER_INTERNAL_IMAGE_ITEM_H
QRectF m_imaRect
Image location.
Definition: ImageItem.h:203
std::map< uchar, QColor > m_lut
LUT.
Definition: ImageItem.h:204
A widget to control the display of a set of layers.
Definition: MapDisplay.h:69
A class to represent time instant.
Definition: TimeInstant.h:55
This file defines a class for a Animation Item.
URI C++ Library.
size_t m_ncols
number of colunms.
Definition: ImageItem.h:194
QVector< QString > m_files
The input files.
Definition: ImageItem.h:196
float m_undef
undef value.
Definition: ImageItem.h:195
QImage m_staticRepresentation
Static representation of the animation.
Definition: ImageItem.h:206
QDir m_dir
The image data directory.
Definition: ImageItem.h:192
size_t m_nlines
number of lines.
Definition: ImageItem.h:193
QString m_currentImageFile
Image to be displayed on paint event animation.
Definition: ImageItem.h:198
QImage * m_image
current image
Definition: ImageItem.h:199
QVector< QString > m_animationFiles
The png files in display projection. It contains only the portions to be animated.
Definition: ImageItem.h:197
QString m_baseFile
Base file name.
Definition: ImageItem.h:200
#define TEQTWIDGETSEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:63
An abstract class for Animation Item.
Definition: AnimationItem.h:64
QString m_preffix
File preffix.
Definition: ImageItem.h:202
QString m_suffix
File suffix.
Definition: ImageItem.h:201
QPointF m_imageCenterPos
Center of the image.
Definition: ImageItem.h:205