5 #include "../canvas/MapDisplay.h"
6 #include "../canvas/Canvas.h"
9 #include <QtCore/QPropertyAnimation>
10 #include <QtGui/QPainter>
11 #include <QtCore/QVector>
19 :
te::qt::widgets::
ImageItem(title, folder, display)
29 if(getCtlParameters() ==
false)
36 m_animation->m_spatialExtent =
te::gm::Envelope(m_imaRect.x(), m_imaRect.y(), m_imaRect.right(), m_imaRect.bottom());
37 m_animation->setEasingCurve(QEasingCurve::Linear);
40 QStringList nameFilter;
41 nameFilter.append(
"*.bin");
42 QStringList files = m_dir.entryList(nameFilter, QDir::Files, QDir::Name);
43 size_t count = files.count();
49 tf =
te::dt::TimeInstant(tf.getTimeInstant() + boost::posix_time::seconds(60 * 60 * 24 * 3 - 3600));
55 for (
size_t i = 0; i < count; ++i)
57 QString f = files[(int)i];
58 QFileInfo fi(m_dir.path() +
"/" + f);
59 QString baseName = fi.baseName();
63 tnext = getTime(files[(
int)i + 1]);
68 while ((t < tnext || t == tnext) && n <= 72)
73 fname = m_dir.path() +
"/" + baseName +
"_" + sn +
"." + fi.suffix();
74 m_files.push_back(fname);
87 QString file(m_dir.path() +
"/Prec5km.ctl");
88 FILE* fp = fopen(file.toStdString().c_str(),
"r");
92 fread(buf, 2000,
sizeof(
char), fp);
94 QString ss(QString(buf).simplified());
97 if (!(ss.contains(
"undef ", Qt::CaseInsensitive) && ss.contains(
"xdef", Qt::CaseInsensitive)
98 && ss.contains(
"ydef", Qt::CaseInsensitive) && ss.contains(
"linear", Qt::CaseInsensitive)
99 && ss.contains(
"zdef", Qt::CaseInsensitive)))
108 size_t pos = ss.indexOf(
"undef ", Qt::CaseInsensitive) + strlen(
"undef ");
109 ss.remove(0, (
int)pos);
110 pos = ss.indexOf(
"xdef", Qt::CaseInsensitive);
111 s = ss.left((
int)pos);
112 m_undef = atof(s.toStdString().c_str());
113 ss.remove(0, (
int)pos);
116 pos = ss.indexOf(
"xdef ", Qt::CaseInsensitive) + strlen(
"xdef ");
117 ss.remove(0, (
int)pos);
118 pos = ss.indexOf(
" ");
119 s = ss.left((
int)pos);
120 m_ncols = atoi(s.toStdString().c_str());
121 ss.remove(0, (
int)pos);
123 pos = ss.indexOf(
"linear ", Qt::CaseInsensitive) + strlen(
"linear ");
124 ss.remove(0, (
int)pos);
125 pos = ss.indexOf(
" ");
126 s = ss.left((
int)pos);
127 double llx = atof(s.toStdString().c_str());
128 ss.remove(0, (
int)pos);
129 pos = ss.indexOf(
"ydef ", Qt::CaseInsensitive);
130 s = ss.left((
int)pos);
131 double resX = atof(s.toStdString().c_str());
132 ss.remove(0, (
int)pos);
135 pos = ss.indexOf(
"ydef ", Qt::CaseInsensitive) + strlen(
"ydef ");
136 ss.remove(0, (
int)pos);
137 pos = ss.indexOf(
" ");
138 s = ss.left((
int)pos);
139 m_nlines = atoi(s.toStdString().c_str());
140 ss.remove(0, (
int)pos);
142 pos = ss.indexOf(
"linear ", Qt::CaseInsensitive) + strlen(
"linear ");
143 ss.remove(0, (
int)pos);
144 pos = ss.indexOf(
" ");
145 s = ss.left((
int)pos);
146 double lly = atof(s.toStdString().c_str());
147 ss.remove(0, (
int)pos);
148 pos = ss.indexOf(
"zdef ", Qt::CaseInsensitive);
149 s = ss.left((
int)pos);
150 double resY = atof(s.toStdString().c_str());
151 ss.remove(0, (
int)pos);
153 double w = (double)m_ncols * resX;
154 double h = (double)m_nlines * resY;
155 m_imaRect = QRectF(llx, lly, w, h);
166 QString path = m_dir.absolutePath() +
"/";
167 QString file = m_currentImageFile;
169 QString baseName = fi.baseName();
171 if (m_suffix ==
".bin" && baseName.contains(
"Prec5km"))
173 QString auxFile(file);
174 size_t pos = auxFile.indexOf(baseName);
175 auxFile.remove(0, (
int)pos);
176 pos = auxFile.indexOf(
"_");
177 size_t pp = auxFile.indexOf(
".bin");
178 int offset = atoi(auxFile.mid((
int)pos + 1, (
int)pp - (
int)pos + 1).toStdString().c_str());
179 size_t fileSize = m_nlines * m_ncols * 4 + 8;
180 offset *= (int)fileSize;
181 auxFile.remove((
int)pos, auxFile.length() - (int)pos);
182 auxFile = path + auxFile + m_suffix;
184 size_t nchars = m_ncols * 4;
185 uchar* buf =
new uchar[nchars];
186 FILE* fp = fopen(auxFile.toStdString().c_str(),
"rb");
187 fseek(fp, offset, SEEK_SET);
188 fseek(fp, 4, SEEK_CUR);
189 m_image =
new QImage((
int)m_ncols, (
int)m_nlines, QImage::Format_ARGB32);
190 m_image->fill(Qt::transparent);
194 for (
size_t j = 0; j < m_nlines; ++j)
196 uchar* u = m_image->scanLine((
int)m_nlines - 1 - (
int)j);
197 fread(buf, nchars,
sizeof(
char), fp);
199 for (
size_t i = 0; i < m_ncols; i++)
201 uc[0] = *(buf + (i << 2));
202 uc[1] = *(buf + (1 + (i << 2)));
203 uc[2] = *(buf + (2 + (i << 2)));
204 uc[3] = *(buf + (3 + (i << 2)));
205 float b = *(
float*)uc;
208 uchar a = (uchar)(b * 10000. + .5);
209 QRgb* v = (QRgb*)(u + (i << 2));
210 *v = qRgba(m_lut[a].red(), m_lut[a].green(), m_lut[a].blue(), 255);
225 QString file(fileName);
226 int ind = file.indexOf(
"Prec5km") + (int)strlen(
"Prec5km");
228 QString ano = file.mid(0, 4);
229 QString mes = file.mid(4, 2);
230 QString dia = file.mid(6, 2);
231 QString hour = file.mid(8, 2);
233 te::dt::Date date(ano.toInt(), mes.toInt(), dia.toInt());
240 std::vector<std::pair<int, QColor> > tab;
242 tab.push_back(std::pair<int, QColor>(i += 1, QColor(2, 1, 201, 255)));
243 tab.push_back(std::pair<int, QColor>(i += 1, QColor(2, 18, 213, 255)));
244 tab.push_back(std::pair<int, QColor>(i += 1, QColor(1, 24, 220, 255)));
245 tab.push_back(std::pair<int, QColor>(i += 1, QColor(1, 36, 227, 255)));
246 tab.push_back(std::pair<int, QColor>(i += 1, QColor(1, 54, 240, 255)));
247 tab.push_back(std::pair<int, QColor>(i += 1, QColor(1, 71, 254, 255)));
248 tab.push_back(std::pair<int, QColor>(i += 1, QColor(1, 90, 252, 255)));
249 tab.push_back(std::pair<int, QColor>(i += 1, QColor(3, 106, 251, 255)));
250 tab.push_back(std::pair<int, QColor>(i += 1, QColor(3, 130, 253, 255)));
251 tab.push_back(std::pair<int, QColor>(i += 1, QColor(3, 148, 250, 255)));
252 tab.push_back(std::pair<int, QColor>(i += 1, QColor(3, 160, 250, 255)));
253 tab.push_back(std::pair<int, QColor>(i += 1, QColor(4, 174, 250, 255)));
254 tab.push_back(std::pair<int, QColor>(i += 1, QColor(4, 186, 250, 255)));
255 tab.push_back(std::pair<int, QColor>(i += 1, QColor(5, 200, 251, 255)));
256 tab.push_back(std::pair<int, QColor>(i += 1, QColor(5, 214, 246, 255)));
257 tab.push_back(std::pair<int, QColor>(i += 1, QColor(3, 227, 241, 255)));
258 tab.push_back(std::pair<int, QColor>(i += 1, QColor(3, 240, 237, 255)));
259 tab.push_back(std::pair<int, QColor>(i += 1, QColor(2, 254, 233, 255)));
260 tab.push_back(std::pair<int, QColor>(i += 1, QColor(2, 254, 212, 255)));
261 tab.push_back(std::pair<int, QColor>(i += 1, QColor(1, 254, 190, 255)));
262 tab.push_back(std::pair<int, QColor>(i += 1, QColor(1, 254, 170, 255)));
263 tab.push_back(std::pair<int, QColor>(i += 1, QColor(1, 254, 160, 255)));
264 tab.push_back(std::pair<int, QColor>(i += 1, QColor(1, 254, 151, 255)));
265 tab.push_back(std::pair<int, QColor>(i += 1, QColor(1, 254, 105, 255)));
266 tab.push_back(std::pair<int, QColor>(i += 1, QColor(1, 254, 72, 255)));
267 tab.push_back(std::pair<int, QColor>(i += 1, QColor(1, 254, 37, 255)));
268 tab.push_back(std::pair<int, QColor>(i += 1, QColor(2, 254, 4, 255)));
269 tab.push_back(std::pair<int, QColor>(i += 1, QColor(25, 254, 4, 255)));
270 tab.push_back(std::pair<int, QColor>(i += 1, QColor(56, 254, 3, 255)));
271 tab.push_back(std::pair<int, QColor>(i += 1, QColor(71, 254, 3, 255)));
272 tab.push_back(std::pair<int, QColor>(i += 1, QColor(99, 254, 2, 255)));
273 tab.push_back(std::pair<int, QColor>(i += 1, QColor(125, 254, 2, 255)));
274 tab.push_back(std::pair<int, QColor>(i += 1, QColor(150, 254, 2, 255)));
275 tab.push_back(std::pair<int, QColor>(i += 1, QColor(175, 254, 2, 255)));
276 tab.push_back(std::pair<int, QColor>(i += 1, QColor(200, 255, 1, 255)));
277 tab.push_back(std::pair<int, QColor>(i += 1, QColor(209, 255, 1, 255)));
278 tab.push_back(std::pair<int, QColor>(i += 1, QColor(218, 255, 1, 255)));
279 tab.push_back(std::pair<int, QColor>(i += 1, QColor(229, 255, 1, 255)));
280 tab.push_back(std::pair<int, QColor>(i += 1, QColor(237, 255, 0, 255)));
281 tab.push_back(std::pair<int, QColor>(i += 1, QColor(240, 248, 0, 255)));
282 tab.push_back(std::pair<int, QColor>(i += 1, QColor(244, 241, 0, 255)));
283 tab.push_back(std::pair<int, QColor>(i += 1, QColor(250, 237, 0, 255)));
284 tab.push_back(std::pair<int, QColor>(i += 1, QColor(251, 232, 2, 255)));
285 tab.push_back(std::pair<int, QColor>(i += 1, QColor(251, 226, 2, 255)));
286 tab.push_back(std::pair<int, QColor>(i += 1, QColor(252, 215, 2, 255)));
287 tab.push_back(std::pair<int, QColor>(i += 1, QColor(253, 208, 2, 255)));
288 tab.push_back(std::pair<int, QColor>(i += 1, QColor(254, 199, 2, 255)));
289 tab.push_back(std::pair<int, QColor>(i += 1, QColor(254, 194, 2, 255)));
290 tab.push_back(std::pair<int, QColor>(i += 1, QColor(253, 190, 2, 255)));
291 tab.push_back(std::pair<int, QColor>(i += 1, QColor(253, 184, 2, 255)));
292 tab.push_back(std::pair<int, QColor>(i += 1, QColor(252, 179, 2, 255)));
293 tab.push_back(std::pair<int, QColor>(i += 1, QColor(252, 172, 2, 255)));
294 tab.push_back(std::pair<int, QColor>(i += 1, QColor(253, 164, 2, 255)));
295 tab.push_back(std::pair<int, QColor>(i += 1, QColor(253, 155, 2, 255)));
296 tab.push_back(std::pair<int, QColor>(i += 1, QColor(254, 147, 4, 255)));
297 tab.push_back(std::pair<int, QColor>(i += 1, QColor(254, 136, 4, 255)));
298 tab.push_back(std::pair<int, QColor>(i += 1, QColor(254, 125, 3, 255)));
299 tab.push_back(std::pair<int, QColor>(i += 1, QColor(254, 112, 3, 255)));
300 tab.push_back(std::pair<int, QColor>(i += 1, QColor(253, 99, 2, 255)));
301 tab.push_back(std::pair<int, QColor>(i += 1, QColor(253, 75, 2, 255)));
302 tab.push_back(std::pair<int, QColor>(i += 1, QColor(253, 50, 2, 255)));
303 tab.push_back(std::pair<int, QColor>(i += 1, QColor(253, 25, 2, 255)));
304 tab.push_back(std::pair<int, QColor>(i += 1, QColor(254, 1, 2, 255)));
305 tab.push_back(std::pair<int, QColor>(i += 1, QColor(254, 1, 12, 255)));
306 tab.push_back(std::pair<int, QColor>(i += 1, QColor(254, 1, 25, 255)));
307 tab.push_back(std::pair<int, QColor>(i += 1, QColor(254, 1, 37, 255)));
308 tab.push_back(std::pair<int, QColor>(i += 1, QColor(254, 0, 49, 255)));
309 tab.push_back(std::pair<int, QColor>(i += 1, QColor(254, 2, 37, 255)));
310 tab.push_back(std::pair<int, QColor>(i += 1, QColor(254, 3, 25, 255)));
311 tab.push_back(std::pair<int, QColor>(i += 1, QColor(254, 4, 12, 255)));
312 tab.push_back(std::pair<int, QColor>(i += 1, QColor(255, 5, 1, 255)));
const boost::posix_time::ptime & getTimeInstant() const
It returns the boost time instant type.
A class to represent time instant.
This file defines a class for a Animation Scene.
This file defines a class for a Eta5kmItem.
An Envelope defines a 2D rectangular region.
A base class for date data types.
A class to represent time period.
This file defines a class for a Trajectory Animation.
A class to represent time duration with nano-second/micro-second resolution.
void drawCurrentImage(QPainter *p)