5 #include "../canvas/MapDisplay.h" 6 #include "../canvas/Canvas.h" 9 #include <QtCore/QPropertyAnimation> 10 #include <QtGui/QPainter> 11 #include <QtGui/QImage> 12 #include <QtCore/QVector> 33 for (
size_t i = 0; i < 256; ++i)
34 m_lut[(uchar)i] = QColor((
int)i, (
int)i, (
int)i, 255);
47 double fat = ar.width() / dr.width();
49 QRectF r(0, 0, ((
double)ima.rect().width() / 4.) / fat, ((double)ima.rect().height() / 4.) / fat);
51 m_imaRect.moveCenter(p);
66 QStringList nameFilter;
67 nameFilter.append(
m_preffix +
"*" + suffix);
68 QStringList files =
m_dir.entryList(nameFilter, QDir::Files, QDir::Name);
69 size_t count = files.count();
78 for (
size_t i = 0; i < count; ++i)
80 QString f = files[(
int)i];
94 QString
file(
m_dir.path() +
"/image.ctl");
99 size_t n = fread(buf,
sizeof(
char), 500, fp);
102 QString s, ss(QString(buf).simplified());
105 if (!(ss.contains(
"suffix ", Qt::CaseInsensitive) && ss.contains(
"preffix ", Qt::CaseInsensitive) &&
106 ss.contains(
"undef ", Qt::CaseInsensitive) && ss.contains(
"srid ", Qt::CaseInsensitive) &&
107 ss.contains(
"llx ", Qt::CaseInsensitive) && ss.contains(
"lly ", Qt::CaseInsensitive) &&
108 ss.contains(
"urx ", Qt::CaseInsensitive) && ss.contains(
"ury ", Qt::CaseInsensitive)))
112 int pos = ss.indexOf(
"suffix ", Qt::CaseInsensitive) +
static_cast<int>(strlen(
"suffix "));
114 pos = ss.indexOf(
" preffix", Qt::CaseInsensitive);
120 pos = ss.indexOf(
"preffix ", Qt::CaseInsensitive) +
static_cast<int>(strlen(
"preffix "));
122 pos = ss.indexOf(
" undef", Qt::CaseInsensitive);
128 pos = ss.indexOf(
"undef ", Qt::CaseInsensitive) +
static_cast<int>(strlen(
"undef "));
130 pos = ss.indexOf(
" srid", Qt::CaseInsensitive);
134 m_undef =
static_cast<float>(atof(s.toUtf8().data()));
138 pos = ss.indexOf(
"srid ", Qt::CaseInsensitive) +
static_cast<int>(strlen(
"srid "));
140 pos = ss.indexOf(
" llx", Qt::CaseInsensitive);
142 m_SRID = atoi(s.toUtf8().data());
149 pos = ss.indexOf(
"llx ", Qt::CaseInsensitive) +
static_cast<int>(strlen(
"llx "));
151 pos = ss.indexOf(
" lly", Qt::CaseInsensitive);
153 double llx = atof(s.toUtf8().data());
157 pos = ss.indexOf(
"lly ", Qt::CaseInsensitive) +
static_cast<int>(strlen(
"lly "));
159 pos = ss.indexOf(
" urx", Qt::CaseInsensitive);
161 double lly = atof(s.toUtf8().data());
165 pos = ss.indexOf(
"urx ", Qt::CaseInsensitive) +
static_cast<int>(strlen(
"urx "));
167 pos = ss.indexOf(
" ury", Qt::CaseInsensitive);
169 double urx = atof(s.toUtf8().data());
173 pos = ss.indexOf(
"ury ", Qt::CaseInsensitive) +
static_cast<int>(strlen(
"ury "));
175 double ury = atof(ss.toUtf8().data());
177 double w = urx - llx;
178 double h = ury - lly;
182 if (
m_dir.exists(
"staticRepresentation.png"))
199 m_image =
new QImage(r.size(), QImage::Format_ARGB32);
200 m_image->fill(QColor(0, 0, 255, 100).rgba());
202 p.setPen(QPen(QColor(255, 0, 0)));
204 QFont font(p.font());
206 int w = (
int)((
double)
m_image->width() / 1.2);
209 font.setPointSize(ps);
210 QFontMetrics fm(font);
211 QRectF rec(fm.boundingRect(
m_title));
213 while (rec.width() < w && rec.height() < h)
216 font.setPointSize(ps);
217 QFontMetrics fm(font);
218 rec = fm.boundingRect(
m_title);
220 rec.moveCenter(
m_image->rect().center());
222 p.drawText(rec.toRect(), Qt::AlignLeft,
m_title);
255 painter->drawImage(r, *
m_image);
259 int width = size.width();
260 int height = size.height();
262 if (
m_image->format() == QImage::Format_ARGB32)
264 for (
int i = 0; i < height; ++i)
266 unsigned char* u =
m_image->scanLine(i);
267 for (
int j = 0; j < width; ++j)
269 QRgb* v = (QRgb*)(u + (j << 2));
271 *v = qRgba(qRed(*v), qGreen(*v), qBlue(*v),
m_opacity);
274 painter->drawImage(r, *
m_image);
278 QImage img(size, QImage::Format_ARGB32);
279 for (
int i = 0; i < height; ++i)
281 unsigned char* u =
m_image->scanLine(i);
282 unsigned char* uu = img.scanLine(i);
284 for (
int j = 0; j < width; ++j)
286 QRgb* v = (QRgb*)(u + (j << 2));
287 QRgb* uv = (QRgb*)(uu + (j << 2));
289 *uv = qRgba(qRed(*v), qGreen(*v), qBlue(*v),
m_opacity);
292 painter->drawImage(r, img);
331 QPointF ph1(p0 - p1);
332 QPointF ph2(p3 - p2);
334 QPointF pw1(p2 - p1);
335 QPointF pw2(p3 - p0);
336 QPointF prot(p6 - c);
338 double w = fabs(pw.x());
339 double h = fabs(ph.y());
341 double PI = 3.14159265;
343 painter->translate(c.toPoint());
352 else if (prot.y() == 0)
361 rad = atan(prot.y() / prot.x());
375 h /= fabs(cos(PI + rad));
379 r.moveCenter(c.toPoint());
381 if (ph1.x() != 0 && ph2.x() != 0 && ph1.y() == ph2.y())
383 double horiz = (ph1.x() + ph2.x()) / 1.35;
384 painter->shear(horiz / w, 0);
386 else if (pw1.y() != 0 && pw2.y() != 0 && pw1.x() == pw2.x())
388 double vert = (pw1.y() + pw2.y()) / 1.35;
389 painter->shear(0, vert / h);
393 double degree = rad * 180. /
PI;
394 painter->rotate(degree);
396 painter->translate(-c.toPoint());
408 size_t size =
m_time.size();
412 if (iTime > tfinal || fTime < tinicial)
416 if (tinicial > iTime)
418 for (
int i = 0; i < (
int)size; ++i)
428 size_t fim = size - 1;
431 for (
int i = (
int)fim; i > (
int)ini; --i)
441 for (
int i = (
int)ini; i <= (
int)fim; ++i)
478 double nt = (double)curTime / (
double)
m_duration;
498 r.setRect(e.getLowerLeftX(), e.getLowerLeftY(), e.getWidth(), e.getHeight());
501 return m_matrix.mapRect(r).toRect();
507 std::vector<std::pair<int, QColor> >::const_iterator it = tab.begin();
508 size_t v = (*it).first;
509 QColor c = (*it).second;
513 m_lut[(uchar)i++] = c;
524 m_lut[(uchar)i++] = c;
530 size_t count =
m_files.count();
538 double dw = w / (double)tam;
539 double dh = h / (double)tam;
545 pos -= QPointF(dw, dh);
547 pos += QPointF(dw, dh);
#define TE_UNKNOWN_SRS
A numeric value to represent a unknown SRS identification in TerraLib.
std::unique_ptr< Point > getPointN(std::size_t i) const
It returns the specified point in this LineString.
double getWidth() const
It returns the envelope width.
This file defines a abstarct class for a Image Item.
static std::string fromUTF8(const std::string &src)
Convert a string in UTF-8 to the current locale encoding.
A class to represent time instant.
double m_llx
Lower left corner x-coordinate.
This file defines a class for a Animation Scene.
LineString is a curve with linear interpolation between points.
void setPoint(std::size_t i, const double &x, const double &y)
It sets the value of the specified point.
An Envelope defines a 2D rectangular region.
TimeInstant getFinalTimeInstant() const
It gets the final time instant.
virtual int getSRID() const
It return the Spatial Reference System used by the Map Display.
TimeInstant getInitialTimeInstant() const
It gets the initial time instant.
virtual const te::gm::Envelope & getExtent() const
It returns the world extent showned by the MapDisplay.
double m_lly
Lower left corner y-coordinate.
A class to represent time period.
This file defines a class for a Trajectory Animation.
void transform(int oldsrid, int newsrid)
It will transform the coordinates of the Envelope from the old SRS to the new one.
double getHeight() const
It returns the envelope height.
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 $
void transform(int srid)
It converts the coordinate values of the linestring to the new spatial reference system.