5 #include "../canvas/MapDisplay.h" 6 #include "../canvas/Canvas.h" 7 #include "../../../core/encoding/CharEncoding.h" 10 #include <QtCore/QPropertyAnimation> 11 #include <QtGui/QPainter> 12 #include <QtCore/QVector> 20 :
te::qt::widgets::
ImageItem(title, folder, display)
39 QStringList nameFilter;
40 nameFilter.append(
"*.bin");
41 QStringList files =
m_dir.entryList(nameFilter, QDir::Files, QDir::Name);
42 size_t count = files.count();
48 tf =
te::dt::TimeInstant(tf.getTimeInstant() + boost::posix_time::seconds(60 * 60 * 24 * 3 - 3600));
54 for (
size_t i = 0; i < count; ++i)
56 QString f = files[(
int)i];
57 QFileInfo fi(
m_dir.path() +
"/" + f);
58 QString baseName = fi.baseName();
62 tnext =
getTime(files[(
int)i + 1]);
67 while ((t < tnext || t == tnext) && n <= 72)
72 fname =
m_dir.path() +
"/" + baseName +
"_" + sn +
"." + fi.suffix();
86 QString
file(
m_dir.path() +
"/Prec5km.ctl");
91 size_t n = fread(buf,
sizeof(
char), 500, 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)))
107 int pos = ss.indexOf(
"undef ", Qt::CaseInsensitive) +
static_cast<int>(strlen(
"undef "));
109 pos = ss.indexOf(
"srid ", Qt::CaseInsensitive);
113 m_undef =
static_cast<float>(atof(s.toUtf8().data()));
117 pos = ss.indexOf(
"srid ", Qt::CaseInsensitive) +
static_cast<int>(strlen(
"srid "));
119 pos = ss.indexOf(
"xdef ", Qt::CaseInsensitive);
121 m_SRID = atoi(s.toUtf8().data());
128 pos = ss.indexOf(
"xdef ", Qt::CaseInsensitive) +
static_cast<int>(strlen(
"xdef "));
130 pos = ss.indexOf(
" ");
132 m_ncols =
static_cast<size_t>(atoi(s.toUtf8().data()));
135 pos = ss.indexOf(
"linear ", Qt::CaseInsensitive) +
static_cast<int>(strlen(
"linear "));
137 pos = ss.indexOf(
" ");
138 s = ss.left((
int)pos);
139 double llx = atof(s.toUtf8().data());
140 ss.remove(0, (
int)pos);
141 pos = ss.indexOf(
"ydef ", Qt::CaseInsensitive);
142 s = ss.left((
int)pos);
143 double resX = atof(s.toUtf8().data());
144 ss.remove(0, (
int)pos);
147 pos =
static_cast<int>(ss.indexOf(
"ydef ", Qt::CaseInsensitive) + strlen(
"ydef "));
148 ss.remove(0, (
int)pos);
149 pos = ss.indexOf(
" ");
150 s = ss.left((
int)pos);
152 ss.remove(0, (
int)pos);
154 pos =
static_cast<int>(ss.indexOf(
"linear ", Qt::CaseInsensitive) + strlen(
"linear "));
155 ss.remove(0, (
int)pos);
156 pos = ss.indexOf(
" ");
157 s = ss.left((
int)pos);
158 double lly = atof(s.toUtf8().data());
159 ss.remove(0, (
int)pos);
160 pos = ss.indexOf(
"zdef ", Qt::CaseInsensitive);
161 s = ss.left((
int)pos);
162 double resY = atof(s.toUtf8().data());
163 ss.remove(0, (
int)pos);
165 double w = (double)
m_ncols * resX;
170 if (
m_dir.exists(
"staticRepresentation.png"))
187 m_image =
new QImage(r.size(), QImage::Format_ARGB32);
188 m_image->fill(QColor(0, 0, 255, 100).rgba());
190 p.setPen(QPen(QColor(255, 0, 0)));
192 QFont font(p.font());
194 int w = (
int)((
double)
m_image->width() / 1.2);
197 font.setPointSize(ps);
198 QFontMetrics fm(font);
199 QRectF rec(fm.boundingRect(
m_title));
201 while (rec.width() < w && rec.height() < h)
204 font.setPointSize(ps);
205 QFontMetrics fm(font);
206 rec = fm.boundingRect(
m_title);
208 rec.moveCenter(
m_image->rect().center());
210 p.drawText(rec.toRect(), Qt::AlignLeft,
m_title);
217 QString path =
m_dir.absolutePath() +
"/";
220 QString baseName = fi.baseName();
222 if (
m_suffix ==
".bin" && baseName.contains(
"Prec5km"))
224 QString auxFile(file);
225 size_t pos = auxFile.indexOf(baseName);
226 auxFile.remove(0, (
int)pos);
227 pos = auxFile.indexOf(
"_");
228 size_t pp = auxFile.indexOf(
".bin");
229 int offset = atoi(auxFile.mid((
int)pos + 1, (
int)pp - (
int)pos + 1).toUtf8().data());
231 offset *= (
int)fileSize;
232 auxFile.remove((
int)pos, auxFile.length() - (
int)pos);
233 auxFile = path + auxFile +
m_suffix;
235 size_t nchars = m_ncols * 4;
236 uchar* buf =
new uchar[nchars];
238 fseek(fp, offset, SEEK_SET);
239 fseek(fp, 4, SEEK_CUR);
240 m_image =
new QImage((
int)m_ncols, (
int)
m_nlines, QImage::Format_ARGB32);
241 m_image->fill(Qt::transparent);
245 for (
size_t j = 0; j <
m_nlines; ++j)
247 uchar* u =
m_image->scanLine((
int)m_nlines - 1 - (
int)j);
248 fread(buf, nchars,
sizeof(
char), fp);
250 for (
size_t i = 0; i <
m_ncols; i++)
252 uc[0] = *(buf + (i << 2));
253 uc[1] = *(buf + (1 + (i << 2)));
254 uc[2] = *(buf + (2 + (i << 2)));
255 uc[3] = *(buf + (3 + (i << 2)));
256 float b = *(
reinterpret_cast<float*
>(uc));
259 uchar a = (uchar)(b * 10000. + .5);
260 QRgb* v = (QRgb*)(u + (i << 2));
277 QString
file(fileName);
278 int ind = file.indexOf(
"Prec5km") + (
int)strlen(
"Prec5km");
280 QString ano = file.mid(0, 4);
281 QString mes = file.mid(4, 2);
282 QString dia = file.mid(6, 2);
283 QString hour = file.mid(8, 2);
285 te::dt::Date date(ano.toInt(), mes.toInt(), dia.toInt());
292 std::vector<std::pair<int, QColor> > tab;
294 tab.push_back(std::pair<int, QColor>(i += 1, QColor(2, 1, 201, 255)));
295 tab.push_back(std::pair<int, QColor>(i += 1, QColor(2, 18, 213, 255)));
296 tab.push_back(std::pair<int, QColor>(i += 1, QColor(1, 24, 220, 255)));
297 tab.push_back(std::pair<int, QColor>(i += 1, QColor(1, 36, 227, 255)));
298 tab.push_back(std::pair<int, QColor>(i += 1, QColor(1, 54, 240, 255)));
299 tab.push_back(std::pair<int, QColor>(i += 1, QColor(1, 71, 254, 255)));
300 tab.push_back(std::pair<int, QColor>(i += 1, QColor(1, 90, 252, 255)));
301 tab.push_back(std::pair<int, QColor>(i += 1, QColor(3, 106, 251, 255)));
302 tab.push_back(std::pair<int, QColor>(i += 1, QColor(3, 130, 253, 255)));
303 tab.push_back(std::pair<int, QColor>(i += 1, QColor(3, 148, 250, 255)));
304 tab.push_back(std::pair<int, QColor>(i += 1, QColor(3, 160, 250, 255)));
305 tab.push_back(std::pair<int, QColor>(i += 1, QColor(4, 174, 250, 255)));
306 tab.push_back(std::pair<int, QColor>(i += 1, QColor(4, 186, 250, 255)));
307 tab.push_back(std::pair<int, QColor>(i += 1, QColor(5, 200, 251, 255)));
308 tab.push_back(std::pair<int, QColor>(i += 1, QColor(5, 214, 246, 255)));
309 tab.push_back(std::pair<int, QColor>(i += 1, QColor(3, 227, 241, 255)));
310 tab.push_back(std::pair<int, QColor>(i += 1, QColor(3, 240, 237, 255)));
311 tab.push_back(std::pair<int, QColor>(i += 1, QColor(2, 254, 233, 255)));
312 tab.push_back(std::pair<int, QColor>(i += 1, QColor(2, 254, 212, 255)));
313 tab.push_back(std::pair<int, QColor>(i += 1, QColor(1, 254, 190, 255)));
314 tab.push_back(std::pair<int, QColor>(i += 1, QColor(1, 254, 170, 255)));
315 tab.push_back(std::pair<int, QColor>(i += 1, QColor(1, 254, 160, 255)));
316 tab.push_back(std::pair<int, QColor>(i += 1, QColor(1, 254, 151, 255)));
317 tab.push_back(std::pair<int, QColor>(i += 1, QColor(1, 254, 105, 255)));
318 tab.push_back(std::pair<int, QColor>(i += 1, QColor(1, 254, 72, 255)));
319 tab.push_back(std::pair<int, QColor>(i += 1, QColor(1, 254, 37, 255)));
320 tab.push_back(std::pair<int, QColor>(i += 1, QColor(2, 254, 4, 255)));
321 tab.push_back(std::pair<int, QColor>(i += 1, QColor(25, 254, 4, 255)));
322 tab.push_back(std::pair<int, QColor>(i += 1, QColor(56, 254, 3, 255)));
323 tab.push_back(std::pair<int, QColor>(i += 1, QColor(71, 254, 3, 255)));
324 tab.push_back(std::pair<int, QColor>(i += 1, QColor(99, 254, 2, 255)));
325 tab.push_back(std::pair<int, QColor>(i += 1, QColor(125, 254, 2, 255)));
326 tab.push_back(std::pair<int, QColor>(i += 1, QColor(150, 254, 2, 255)));
327 tab.push_back(std::pair<int, QColor>(i += 1, QColor(175, 254, 2, 255)));
328 tab.push_back(std::pair<int, QColor>(i += 1, QColor(200, 255, 1, 255)));
329 tab.push_back(std::pair<int, QColor>(i += 1, QColor(209, 255, 1, 255)));
330 tab.push_back(std::pair<int, QColor>(i += 1, QColor(218, 255, 1, 255)));
331 tab.push_back(std::pair<int, QColor>(i += 1, QColor(229, 255, 1, 255)));
332 tab.push_back(std::pair<int, QColor>(i += 1, QColor(237, 255, 0, 255)));
333 tab.push_back(std::pair<int, QColor>(i += 1, QColor(240, 248, 0, 255)));
334 tab.push_back(std::pair<int, QColor>(i += 1, QColor(244, 241, 0, 255)));
335 tab.push_back(std::pair<int, QColor>(i += 1, QColor(250, 237, 0, 255)));
336 tab.push_back(std::pair<int, QColor>(i += 1, QColor(251, 232, 2, 255)));
337 tab.push_back(std::pair<int, QColor>(i += 1, QColor(251, 226, 2, 255)));
338 tab.push_back(std::pair<int, QColor>(i += 1, QColor(252, 215, 2, 255)));
339 tab.push_back(std::pair<int, QColor>(i += 1, QColor(253, 208, 2, 255)));
340 tab.push_back(std::pair<int, QColor>(i += 1, QColor(254, 199, 2, 255)));
341 tab.push_back(std::pair<int, QColor>(i += 1, QColor(254, 194, 2, 255)));
342 tab.push_back(std::pair<int, QColor>(i += 1, QColor(253, 190, 2, 255)));
343 tab.push_back(std::pair<int, QColor>(i += 1, QColor(253, 184, 2, 255)));
344 tab.push_back(std::pair<int, QColor>(i += 1, QColor(252, 179, 2, 255)));
345 tab.push_back(std::pair<int, QColor>(i += 1, QColor(252, 172, 2, 255)));
346 tab.push_back(std::pair<int, QColor>(i += 1, QColor(253, 164, 2, 255)));
347 tab.push_back(std::pair<int, QColor>(i += 1, QColor(253, 155, 2, 255)));
348 tab.push_back(std::pair<int, QColor>(i += 1, QColor(254, 147, 4, 255)));
349 tab.push_back(std::pair<int, QColor>(i += 1, QColor(254, 136, 4, 255)));
350 tab.push_back(std::pair<int, QColor>(i += 1, QColor(254, 125, 3, 255)));
351 tab.push_back(std::pair<int, QColor>(i += 1, QColor(254, 112, 3, 255)));
352 tab.push_back(std::pair<int, QColor>(i += 1, QColor(253, 99, 2, 255)));
353 tab.push_back(std::pair<int, QColor>(i += 1, QColor(253, 75, 2, 255)));
354 tab.push_back(std::pair<int, QColor>(i += 1, QColor(253, 50, 2, 255)));
355 tab.push_back(std::pair<int, QColor>(i += 1, QColor(253, 25, 2, 255)));
356 tab.push_back(std::pair<int, QColor>(i += 1, QColor(254, 1, 2, 255)));
357 tab.push_back(std::pair<int, QColor>(i += 1, QColor(254, 1, 12, 255)));
358 tab.push_back(std::pair<int, QColor>(i += 1, QColor(254, 1, 25, 255)));
359 tab.push_back(std::pair<int, QColor>(i += 1, QColor(254, 1, 37, 255)));
360 tab.push_back(std::pair<int, QColor>(i += 1, QColor(254, 0, 49, 255)));
361 tab.push_back(std::pair<int, QColor>(i += 1, QColor(254, 2, 37, 255)));
362 tab.push_back(std::pair<int, QColor>(i += 1, QColor(254, 3, 25, 255)));
363 tab.push_back(std::pair<int, QColor>(i += 1, QColor(254, 4, 12, 255)));
364 tab.push_back(std::pair<int, QColor>(i += 1, QColor(255, 5, 1, 255)));
static std::string fromUTF8(const std::string &src)
Convert a string in UTF-8 to the current locale encoding.
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.
file(WRITE ${CMAKE_BINARY_DIR}/config_qhelp.cmake"configure_file (${TERRALIB_ABSOLUTE_ROOT_DIR}/doc/qhelp/help.qhcp.in ${CMAKE_BINARY_DIR}/share/terraview/help/help.qhcp @ONLY)") add_custom_command(OUTPUT del_dir COMMAND $