27 #include "../../../color/RGBAColor.h" 28 #include "../../../common/StringUtils.h" 29 #include "../../../geometry.h" 30 #include "../../../maptools/PtMarker.h" 31 #include "../../../raster.h" 39 #include <QPaintEngine> 42 #include <QResizeEvent> 50 m_isPainterOwner(true),
51 m_isDeviceOwner(true),
52 m_bgColor(Qt::transparent),
56 m_ptColorFrom(m_ptColor),
58 m_ptImgRotated(nullptr),
59 m_ptSelectionPatternImg(nullptr),
60 m_ptClearPatternImg(nullptr),
64 m_lnColor(Qt::transparent),
66 m_polyContourColor(Qt::transparent),
67 m_polyContourPen(Qt::gray),
69 m_polyBrush(Qt::magenta),
71 m_polyRotatedImage(nullptr),
72 m_polyPatternWidth(16),
73 m_txtContourPen(Qt::black),
74 m_txtContourEnabled(false),
75 m_txtBrush(Qt::black),
76 m_txtLetterSpacing(1),
82 if(devType == QInternal::Pixmap)
84 QPixmap*
p =
new QPixmap(w, h);
90 QImage* i =
new QImage(w, h, QImage::Format_ARGB32_Premultiplied);
177 QPaintDevice* device =
m_painter->device();
195 const double& urx,
const double& ury)
197 double xScale =
static_cast<double>(
getWidth()) / (urx - llx);
198 double yScale =
static_cast<double>(
getHeight()) / (ury - lly);
209 m_painter->setTransform(transform,
true);
220 double ww = urx - llx;
221 double wh = ury - lly;
223 double widthByHeight =
static_cast<double>(
getWidth()) / static_cast<double>(
getHeight());
225 if(widthByHeight > ww / wh)
229 ww = wh * widthByHeight;
237 llx = llx - (ww - v) / 2.0;
245 wh = ww / widthByHeight;
253 lly = lly - (wh - v) / 2.0;
284 int devType =
m_painter->device()->devType();
286 if(devType != QInternal::Image && devType != QInternal::Pixmap)
289 QPaintDevice* device =
m_painter->device();
294 if(devType == QInternal::Image)
295 static_cast<QImage*
>(device)->fill(
m_bgColor.rgba());
297 static_cast<QPixmap*
>(device)->fill(
m_bgColor);
304 rec =
m_matrix.inverted().mapRect(rec);
305 m_ptPen.setWidthF(rec.width());
310 int devType =
m_painter->device()->devType();
312 if(devType != QInternal::Image && devType != QInternal::Pixmap)
318 if(devType == QInternal::Pixmap)
320 QPixmap* pixmap =
static_cast<QPixmap*
>(
m_painter->device());
323 pixmap =
new QPixmap(w, h);
329 QImage* image =
static_cast<QImage*
>(
m_painter->device());
332 image =
new QImage(w, h, QImage::Format_ARGB32_Premultiplied);
357 draw(static_cast<const te::gm::MultiPolygon*>(geom));
364 draw(static_cast<const te::gm::Point*>(geom));
371 draw(static_cast<const te::gm::LineString*>(geom));
378 draw(static_cast<const te::gm::Polygon*>(geom));
385 draw(static_cast<const te::gm::MultiLineString*>(geom));
392 draw(static_cast<const te::gm::MultiPoint*>(geom));
399 draw(static_cast<const te::gm::GeometryCollection*>(geom));
406 draw(static_cast<const te::gm::MultiSurface*>(geom));
425 rectf.moveCenter(pc);
439 p.setColor(Qt::black);
452 for(std::size_t i = 0; i < size; ++i)
458 if(
m_lnPen.brush().style() != Qt::TexturePattern)
460 const std::size_t nPoints = line->
getNPoints();
470 for (std::size_t t = 0; t < nPoints; ++t)
472 double curCoordX, curCoordY;
473 m_matrix.map(curCoordWorld[t].x, curCoordWorld[t].y, &curCoordX, &curCoordY);
475 int intCurCoordX = qRound(curCoordX);
476 int intCurCoordY = qRound(curCoordY);
478 ddx = intCurCoordX - lastPointX;
479 ddy = intCurCoordY - lastPointY;
481 if (ddx != 0 || ddy != 0)
483 qpol << QPointF(curCoordWorld[t].x, curCoordWorld[t].y);
485 lastPointX = intCurCoordX;
486 lastPointY = intCurCoordY;
505 p1.setX(coords[0].x);
506 p1.setY(coords[0].y);
508 for(std::size_t i = 1; i != size; ++i)
510 p2.setX(coords[i].x);
511 p2.setY(coords[i].y);
516 pen.setColor(Qt::red);
517 if(
m_lnPen.brush().style() == Qt::TexturePattern)
518 pen.setCapStyle(Qt::FlatCap);
524 if(
m_lnPen.brush().style() == Qt::TexturePattern)
528 QPoint dp1 =
m_matrix.map(p1).toPoint();
529 QPoint dp2 =
m_matrix.map(p2).toPoint();
530 int ddx = dp2.x() - dp1.x();
531 int ddy = dp2.y() - dp1.y();
532 if(abs(ddx) <= minPixels && abs(ddy) <= minPixels)
539 double dx = p2.x() - p1.x();
540 double dy = p2.y() - p1.y();
541 double distance = sqrt((dx * dx) + (dy * dy));
542 double scale =
m_lnPen.widthF() /
m_lnPen.brush().textureImage().height();
560 alfa = atan(dy / dx) * 180. / 3.14159265;
563 else if(alfa < 0 && dy < 0.)
571 pen.setCapStyle(Qt::FlatCap);
573 matrix.scale(scale, scale);
574 matrix.translate(
m_lnPen.brush().textureImage().width() / 2, -
m_lnPen.brush().textureImage().height() / 2.);
575 brush.setMatrix(matrix);
582 m_painter->drawLine(0., 0., static_cast<int>(distance), 0.);
585 pen.setBrush(Qt::NoBrush);
588 m_painter->drawLine(0., 0., static_cast<int>(distance), 0.);
597 QPoint dp1 =
m_matrix.map(p1).toPoint();
598 QPoint dp2 =
m_matrix.map(p2).toPoint();
599 int ddx = dp2.x() - dp1.x();
600 int ddy = dp2.y() - dp1.y();
601 double dx = p2.x() - p1.x();
602 double dy = p2.y() - p1.y();
603 double distance = sqrt((dx * dx) + (dy * dy));
604 double scale =
m_lnPen.widthF() /
m_lnPen.brush().textureImage().height();
622 alfa = atan(dy / dx) * 180. / 3.14159265;
625 else if(alfa < 0 && dy < 0.)
633 pen.setCapStyle(Qt::FlatCap);
635 matrix.scale(scale, scale);
636 matrix.translate(
m_lnPen.brush().textureImage().width() / 2, -
m_lnPen.brush().textureImage().height() / 2.);
637 brush.setMatrix(matrix);
644 m_painter->drawLine(0., 0., static_cast<int>(distance), 0.);
647 pen.setBrush(Qt::NoBrush);
650 m_painter->drawLine(0., 0., static_cast<int>(distance), 0.);
660 for(
size_t i = 0; i < size; ++i)
672 std::vector<te::gm::LinearRing*> rings;
682 int intLLX = qRound(llX);
683 int intLLY = qRound(llY);
685 int intURX = qRound(urX);
686 int intURY = qRound(urY);
690 ddx = intURX - intLLX;
694 ddy = intURY - intLLY;
705 for(std::size_t i = 0; i < nRings; ++i)
708 rings.push_back(ring);
710 const std::size_t nPoints = ring->
getNPoints();
717 for (std::size_t t = 0; t < nPoints; ++t)
719 double curCoordX, curCoordY;
720 m_matrix.map(curCoordWorld[t].x, curCoordWorld[t].y, &curCoordX, &curCoordY);
722 int intCurCoordX = qRound(curCoordX);
723 int intCurCoordY = qRound(curCoordY);
725 ddx = intCurCoordX - lastPointX;
726 ddy = intCurCoordY - lastPointY;
728 if (ddx != 0 || ddy != 0)
731 path.moveTo(curCoordWorld[t].x, curCoordWorld[t].y);
733 path.lineTo(curCoordWorld[t].x, curCoordWorld[t].y);
735 lastPointX = intCurCoordX;
736 lastPointY = intCurCoordY;
756 QPointF pc =
m_matrix.map(recf.center());
757 int transx = pc.toPoint().x();
758 int transy = pc.toPoint().y();
760 QMatrix matrix =
m_matrix.inverted();
762 matrix.scale(scale, scale);
767 matrix.translate(transx, transy);
775 matrix.translate(transx, transy);
803 std::vector<te::gm::LinearRing*>::iterator it;
804 for(it = rings.begin(); it != rings.end(); ++it)
823 QPointF p1(coords[0].x, coords[0].y);
826 for(std::size_t i = 1; i != size; ++i)
828 p2.setX(coords[i].x);
829 p2.setY(coords[i].y);
840 QPoint dp1 =
m_matrix.map(p1).toPoint();
841 QPoint dp2 =
m_matrix.map(p2).toPoint();
842 int ddx = dp2.x() - dp1.x();
843 int ddy = dp2.y() - dp1.y();
844 if(ddx == 0 && ddy == 0)
851 double dx = p2.x() - p1.x();
852 double dy = p2.y() - p1.y();
853 double distance = sqrt((dx * dx) + (dy * dy));
872 alfa = atan(dy / dx) * 180. / 3.14159265;
875 else if(alfa < 0 && dy < 0.)
881 if(alfa > 90. && alfa <= 270.)
900 pen.setCapStyle(Qt::FlatCap);
902 matrix.scale(scale, scale);
904 brush.setMatrix(matrix);
911 m_painter->drawLine(0., 0., static_cast<int>(distance), 0.);
914 pen.setBrush(Qt::NoBrush);
917 m_painter->drawLine(0., 0., static_cast<int>(distance), 0.);
927 QPoint dp1 =
m_matrix.map(p1).toPoint();
928 QPoint dp2 =
m_matrix.map(p2).toPoint();
929 int ddx = dp2.x() - dp1.x();
930 int ddy = dp2.y() - dp1.y();
931 double dx = p2.x() - p1.x();
932 double dy = p2.y() - p1.y();
933 double distance = sqrt((dx * dx) + (dy * dy));
952 alfa = atan(dy / dx) * 180. / 3.14159265;
955 else if(alfa < 0 && dy < 0.)
961 if(alfa > 90. && alfa <= 270.)
980 pen.setCapStyle(Qt::FlatCap);
982 matrix.scale(scale, scale);
984 brush.setMatrix(matrix);
991 m_painter->drawLine(0., 0., static_cast<int>(distance), 0.);
994 pen.setBrush(Qt::NoBrush);
997 m_painter->drawLine(0., 0., static_cast<int>(distance), 0.);
1006 for(std::size_t i = 0; i < size; ++i)
1013 for(
size_t i = 0; i < size; ++i)
1020 for(
size_t i = 0; i < size; ++i)
1026 int devType =
m_painter->device()->devType();
1028 if(devType != QInternal::Image && devType != QInternal::Pixmap)
1036 int devType =
m_painter->device()->devType();
1038 if(devType != QInternal::Image && devType != QInternal::Pixmap)
1042 QBuffer buffer(&bytes);
1043 buffer.open(QIODevice::WriteOnly);
1075 int nbytes = bytes.size();
1077 char* result =
new char[nbytes];
1079 memcpy(result, bytes.data(),
static_cast<size_t>(nbytes));
1081 size =
static_cast<size_t>(nbytes);
1088 int devType =
m_painter->device()->devType();
1090 if(devType != QInternal::Image && devType != QInternal::Pixmap)
1095 if(devType == QInternal::Pixmap)
1096 img =
static_cast<QPixmap*
>(
m_painter->device())->toImage();
1098 img = *(
static_cast<QImage*
>(
m_painter->device()));
1100 if(x == 0 && y == 0 && w == 0 && y == 0)
1102 int width = img.width();
1103 int height = img.height();
1106 for(
int i = 0; i < height; ++i)
1110 unsigned char* u = img.scanLine(i);
1112 for(
int j = 0; j < width; ++j)
1114 QRgb* qrgb =
reinterpret_cast<QRgb*
>(u + (j << 2));
1117 colors[i][j] = rgba;
1123 img = img.copy(x, y, w, h);
1126 for(
int i = 0; i < h; ++i)
1130 unsigned char* u = img.scanLine(i);
1132 for(
int j = 0; j < w; ++j)
1134 QRgb* qrgba =
reinterpret_cast<QRgb*
>(u + (j << 2));
1135 QRgb value = *qrgba;
1137 colors[i][j] = rgba;
1165 pix.loadFromData(reinterpret_cast<unsigned char*>(src), static_cast<uint>(size), f);
1167 m_painter->setWorldMatrixEnabled(
false);
1174 QImage img(w, h, QImage::Format_ARGB32);
1176 for(
int l = 0; l < h; ++l)
1178 for(
int c = 0; c < w; ++c)
1180 QRgb val = qRgba(src[l][c].getRed(), src[l][c].getGreen(), src[l][c].getBlue(), src[l][c].getAlpha());
1182 img.setPixel(c, l, val);
1186 m_painter->setWorldMatrixEnabled(
false);
1196 pix.loadFromData(reinterpret_cast<unsigned char*>(src), static_cast<uint>(size), f);
1198 m_painter->setWorldMatrixEnabled(
false);
1205 QImage img(srcw, srch, QImage::Format_RGB32);
1207 for(
int l = 0; l < srch; ++l)
1208 for(
int c = 0; c < srcw; ++c)
1209 img.setPixel(c, l, static_cast<uint>(src[l][c].
getRgba()));
1211 m_painter->setWorldMatrixEnabled(
false);
1212 m_painter->drawImage(QRect(x, y, w, h), img, QRect(0, 0, srcw, srch));
1216 void te::qt::widgets::Canvas::drawImage(
int x,
int y,
int w,
int h,
char* src, std::size_t size,
te::map::ImageType t,
int sx,
int sy,
int sw,
int sh)
1221 pix.loadFromData(reinterpret_cast<unsigned char*>(src), static_cast<uint>(size), f);
1223 m_painter->setWorldMatrixEnabled(
false);
1224 m_painter->drawPixmap(x, y, w, h, pix, sx, sy, sw, sh);
1230 QImage img(sw, sh, QImage::Format_RGB32);
1235 for(
int l = sy, li = 0; l < ssh; ++l, ++li)
1236 for(
int c = sx, ci = 0; c < ssw; ++c, ++ci)
1237 img.setPixel(ci, li, static_cast<uint>(src[l][c].
getRgba()));
1239 m_painter->setWorldMatrixEnabled(
false);
1240 m_painter->drawImage(QRect(x, y, w, h), img, QRect(0, 0, sw, sh));
1249 drawImage(x, y, sw, sh, src, 0, 0, sw, sh, opacity);
1255 int iw = std::min(sw, w);
1256 int ih = std::min(sh, h);
1258 QImage img(iw, ih, QImage::Format_ARGB32);
1263 double sl = std::max(1.0, sh / static_cast<double>(h));
1264 double sr = std::max(1.0, sw / static_cast<double>(w));
1268 for(
int li = 0; li < ih; dl += sl, ++li)
1271 for(
int ri = 0; ri < iw; dr += sr, ++ri)
1273 r =
static_cast<int> (dr);
1274 l =
static_cast<int> (dl);
1275 src->
getValue(static_cast<unsigned int>(r), static_cast<unsigned int>(l), pr, 0);
1276 src->
getValue(static_cast<unsigned int>(r), static_cast<unsigned int>(l), pg, 1);
1277 src->
getValue(static_cast<unsigned int>(r), static_cast<unsigned int>(l), pb, 2);
1279 pixel =
new te::color::RGBAColor(static_cast<int>(pr), static_cast<int>(pg), static_cast<int>(pb), opacity);
1282 img.setPixel(ri, li, val);
1288 m_painter->setWorldMatrixEnabled(
false);
1289 m_painter->drawImage(QRect(x, y, w, h), img, QRect(0, 0, iw, ih));
1295 m_painter->setWorldMatrixEnabled(
false);
1302 QColor c(static_cast<QRgb>(color.
getRgba()));
1303 c.setAlpha(qAlpha(static_cast<QRgb>(color.
getRgba())));
1307 m_painter->setWorldMatrixEnabled(
false);
1313 const std::string& txt,
1315 double anchorX,
double anchorY,
1316 int displacementX,
int displacementY)
1319 drawText(p, txt, angle, anchorX, anchorY, displacementX, displacementY);
1323 const std::string& txt,
1325 double anchorX,
double anchorY,
1326 int displacementX,
int displacementY)
1328 drawText(p->
getX(), p->
getY(), txt, angle, anchorX, anchorY, displacementX, displacementY);
1332 const std::string& txt,
1334 double anchorX,
double anchorY,
1335 int displacementX,
int displacementY)
1339 QPoint
p = pf.toPoint();
1340 drawText(p, txt, angle, anchorX, anchorY, displacementX, displacementY);
1346 return getTextBoundary(p, txt, angle, anchorX, anchorY, displacementX, displacementY);
1358 QPoint
p = pf.toPoint();
1359 return getTextBoundary(p, txt, angle, anchorX, anchorY, displacementX, displacementY);
1377 m_font.setFamily(family.c_str());
1382 double resolution = 0.0;
1384 if(
m_painter->device()->devType() == QInternal::Printer)
1385 resolution = static_cast<QPrinter*>(
m_painter->device())->resolution();
1387 resolution =
m_painter->device()->logicalDpiY();
1389 double PointSize = psize * resolution / 72.0;
1391 m_font.setPointSizeF(PointSize);
1396 m_font.setStyle(static_cast<QFont::Style>(style));
1401 m_font.setWeight(static_cast<QFont::Weight>(weight));
1406 m_font.setStretch(static_cast<int>(stretch));
1434 QColor cor(static_cast<QRgb>(color.
getRgba()));
1435 cor.setAlpha(qAlpha(static_cast<QRgb>(color.
getRgba())));
1466 QColor cor(static_cast<QRgb>(color.
getRgba()));
1467 cor.setAlpha(qAlpha(static_cast<QRgb>(color.
getRgba())));
1485 rec =
m_matrix.inverted().mapRect(rec);
1486 m_ptPen.setWidthF(rec.width());
1490 double scale =
static_cast<double>(
m_ptWidth) / static_cast<double>(
m_ptImg->width());
1491 int h =
static_cast<int>(
m_ptImg->height() * scale);
1504 if(pattern ==
nullptr || ncols == 0 || nrows == 0)
1519 if(pattern ==
nullptr || size == 0)
1526 if(
m_ptImg->loadFromData(reinterpret_cast<const uchar*>(pattern), static_cast<int>(size), format) ==
false)
1556 QColor cor(static_cast<QRgb>(color.
getRgba()));
1557 cor.setAlpha(qAlpha(static_cast<QRgb>(color.
getRgba())));
1564 if(pattern ==
nullptr)
1566 m_lnPen.setBrush(Qt::NoBrush);
1570 QImage* img =
GetImage(pattern, ncols, nrows);
1572 if(img->isNull() ==
false)
1575 brush.setTextureImage(*img);
1583 if(pattern ==
nullptr)
1585 m_lnPen.setBrush(Qt::NoBrush);
1593 bool result = img.loadFromData(reinterpret_cast<const uchar*>(pattern), static_cast<int>(size), format);
1595 if(result && img.isNull() ==
false)
1598 brush.setTextureImage(img);
1605 QBrush brush =
m_lnPen.brush();
1606 QImage img = brush.textureImage();
1611 matrix.translate(img.width() / 2, img.height() / 2);
1612 matrix.rotate(angle);
1613 QImage imgRot = img.transformed(matrix);
1615 brush.setTextureImage(imgRot);
1621 QBrush brush =
m_lnPen.brush();
1622 QImage img = brush.textureImage();
1629 brush.setTextureImage(img);
1635 m_lnPen.setStyle(static_cast<Qt::PenStyle>(style));
1645 m_lnPen.setCapStyle(static_cast<Qt::PenCapStyle>(style));
1650 m_lnPen.setJoinStyle(static_cast<Qt::PenJoinStyle>(style));
1655 QRectF rec(QPoint(0., 0.), QPoint(w, w));
1656 rec =
m_matrix.inverted().mapRect(rec);
1657 m_lnPen.setWidthF(rec.width());
1662 QColor cor(static_cast<QRgb>(color.
getRgba()));
1663 cor.setAlpha(qAlpha(static_cast<QRgb>(color.
getRgba())));
1665 QBrush
b(cor, Qt::SolidPattern);
1679 if(pattern ==
nullptr)
1703 if(pattern ==
nullptr)
1716 bool result =
m_polyImage->loadFromData(reinterpret_cast<const uchar*>(pattern), static_cast<int>(size), format);
1737 matrix.translate(static_cast<double>(
m_polyImage->width()) / 2., static_cast<double>(
m_polyImage->height()) / 2.);
1738 matrix.rotate(angle);
1761 QColor cor(static_cast<QRgb>(color.
getRgba()));
1762 cor.setAlpha(static_cast<int>(qAlpha(static_cast<QRgb>(color.
getRgba()))));
1770 if(pattern ==
nullptr)
1776 QImage* img =
GetImage(pattern, ncols, nrows);
1778 if(img->isNull() ==
false)
1781 brush.setTextureImage(*img);
1789 if(pattern ==
nullptr)
1799 bool result = img.loadFromData(reinterpret_cast<const uchar*>(pattern), static_cast<int>(size), format);
1801 if(result && img.isNull() ==
false)
1804 brush.setTextureImage(img);
1811 QRectF rec(QPoint(0., 0.), QPoint(w, w));
1812 rec =
m_matrix.inverted().mapRect(rec);
1819 QImage img = brush.textureImage();
1824 matrix.translate(img.width() / 2, img.height() / 2);
1825 matrix.rotate(angle);
1826 QImage imgRot = img.transformed(matrix);
1828 brush.setTextureImage(imgRot);
1835 QImage img = brush.textureImage();
1842 brush.setTextureImage(img);
1867 const std::string& txt,
1869 double anchorX,
double anchorY,
1870 int displacementX,
int displacementY)
1876 m_painter->setRenderHint(QPainter::Antialiasing,
true);
1879 QString qtx(txt.c_str());
1882 QRectF rec(fm.boundingRect(qtx));
1884 path.addText(0, 0,
m_font, qtx);
1886 ax = p.x() - path.boundingRect().width() * anchorX;
1887 ay = p.y() + path.boundingRect().height() * anchorY;
1893 double textWidth = path.boundingRect().width();
1894 double textHeight = path.boundingRect().height();
1896 path.translate(-textWidth / 2., textHeight / 2.);
1898 QTransform transform;
1899 transform.rotate(static_cast<qreal>(angle));
1901 path = transform.map(path);
1903 path.translate(textWidth / 2., -textHeight / 2.);
1906 path.translate(ax + displacementX, ay - displacementY);
1929 QString qtx(txt.c_str());
1932 path.addText(0, 0,
m_font, qtx);
1934 ax = p.x() - path.boundingRect().width() * anchorX;
1935 ay = p.y() + path.boundingRect().height() * anchorY;
1939 double textWidth = path.boundingRect().width();
1940 double textHeight = path.boundingRect().height();
1942 path.translate(-textWidth / 2., textHeight / 2.);
1944 QTransform transform;
1945 transform.rotate(static_cast<qreal>(angle));
1947 path = transform.map(path);
1949 path.translate(textWidth / 2., -textHeight / 2.);
1952 path.translate(ax + displacementX, ay - displacementY);
1954 path =
m_matrix.inverted().map(path);
1956 QPolygonF polf(path.boundingRect());
1962 lr->setPoint(0, polf.at(0).x(), polf.at(0).y());
1963 lr->setPoint(1, polf.at(1).x(), polf.at(1).y());
1964 lr->setPoint(2, polf.at(2).x(), polf.at(2).y());
1965 lr->setPoint(3, polf.at(3).x(), polf.at(3).y());
1971 if(
m_painter->device()->devType() == QInternal::Pixmap)
1972 return static_cast<QPixmap*>(
m_painter->device());
1979 if(
m_painter->device()->devType() == QInternal::Image)
1980 return static_cast<QImage*>(
m_painter->device());
2003 if(
m_painter->device()->devType() == QInternal::Printer)
2004 return static_cast<QPrinter*>(
m_painter->device())->resolution();
2006 return m_painter->device()->logicalDpiX();
2026 assert(style.size() % 2 == 0);
2027 QVector<qreal> pattern;
2028 for(std::size_t i = 0; i < style.size(); ++i)
2029 pattern << style[i];
2030 pen.setDashPattern(pattern);
2035 int o = opacity << 24;
2036 for(
int i = 0; i < img.height(); ++i)
2038 unsigned char* u = img.scanLine(i);
2039 for(
int j = 0; j < img.width(); ++j)
2041 QRgb* v =
reinterpret_cast<QRgb*
>(u + (j << 2));
2042 if(qAlpha(*v) <= opacity)
2044 *v = *v & 0x00ffffff;
2045 *v =
static_cast<unsigned int>(o) | *v;
2068 double a =
static_cast<double>(
m_ptColor.alpha()) / 255.;
2069 double b =
static_cast<double>(255 -
m_ptColor.alpha()) / 255.;
2074 for(
int i = 0; i < height; ++i)
2079 for(
int j = 0; j < width; ++j)
2081 QRgb* v =
reinterpret_cast<QRgb*
>(u + (j << 2));
2082 QRgb* vv =
reinterpret_cast<QRgb*
>(uu + (j << 2));
2083 QRgb* vvv =
reinterpret_cast<QRgb*
>(uuu + (j << 2));
2086 *vv = qRgba(0, 0, 0, 0);
2087 *vvv = qRgba(0, 0, 0, 0);
2091 int red =
static_cast<int>(
static_cast<double>(
m_ptColor.red()) * a + static_cast<double>(qRed(*v)) * b);
2092 int green =
static_cast<int>(
static_cast<double>(
m_ptColor.green()) * a + static_cast<double>(qGreen(*v)) * b);
2093 int blue =
static_cast<int>(
static_cast<double>(
m_ptColor.blue()) * a + static_cast<double>(qBlue(*v)) * b);
2094 *vv = qRgba(red, green, blue, qAlpha(*v));
2095 *vvv = qRgba(255, 255, 255, 255);
2103 m_painter->setCompositionMode(QPainter::CompositionMode_DestinationOut);
2109 m_painter->setCompositionMode(QPainter::CompositionMode_SourceOver);
void getRgba(int *r, int *g, int *b, int *a=0) const
It gets the color value.
std::size_t getNumRings() const
It returns the number of rings in this CurvePolygon.
std::size_t getNumGeometries() const
It returns the number of geometries in this GeometryCollection.
ImageType
This enum specifies the possible input and output image formats supported by the canvas API...
MultiPolygon is a MultiSurface whose elements are Polygons.
int getRed() const
It returns the red component color value (a value from 0 to 255).
Coord2D * getCoordinates() const
It returns a pointer to the internal array of coordinates.
static te::dt::Date dx(2010, 12, 31)
unsigned int getNumberOfColumns() const
Returns the raster number of columns.
GeomType getGeomTypeId() const _NOEXCEPT_OP(true)
It returns the geometry subclass type identifier.
const double & getUpperRightX() const
It returns a constant refernce to the x coordinate of the upper right corner.
int getBlue() const
It returns the blue component color value (a value from 0 to 255).
double m_urx
Upper right corner x-coordinate.
int getGreen() const
It returns the green component color value (a value from 0 to 255).
const double & getLowerLeftY() const
It returns a constant refernce to the y coordinate of the lower left corner.
double getWidth() const
It returns the envelope width.
An utility struct for representing 2D coordinates.
const double & getUpperRightY() const
It returns a constant refernce to the x coordinate of the upper right corner.
AlignType
This enum contains values to control the alignment of components (like Canvas and MapDisplay)...
LineCapStyle
This enum encodes enumerated values telling how line strings should be capped (at the two ends of the...
A LinearRing is a LineString that is both closed and simple.
MultiPoint is a GeometryCollection whose elements are restricted to points.
double m_llx
Lower left corner x-coordinate.
LineString is a curve with linear interpolation between points.
const double & getY() const
It returns the Point y-coordinate value.
A point with x and y coordinate values.
const Envelope * getMBR() const _NOEXCEPT_OP(true)
It returns the minimum bounding rectangle for the geometry in an internal representation.
An Envelope defines a 2D rectangular region.
An abstract class for raster data strucutures.
unsigned int getNumberOfRows() const
Returns the raster number of rows.
int getAlpha() const
It returns the alpha component color value (a value from 0 to 255).
std::size_t getNPoints() const
It returns the number of points (vertexes) in the linestring.
FontStyleType
It defines the style to use for a font.
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
virtual void getValue(unsigned int c, unsigned int r, double &value, std::size_t b=0) const
Returns the attribute value of a band of a cell.
double m_lly
Lower left corner y-coordinate.
Geometry * getGeometryN(std::size_t i) const
It returns the n-th geometry in this GeometryCollection.
MultiLineString is a MultiCurve whose elements are LineStrings.
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
LineDashStyle
This enum encodes enumerated values telling how lines should be drawn. e.g. as a plain line or dash l...
LineJoinStyle
This enum encodes enumerated values telling how line strings should be joined (between line segments)...
MultiSurface is a class that represents a 2-dimensional GeometryCollection whose elements are surface...
double m_ury
Upper right corner y-coordinate.
const double & getLowerLeftX() const
It returns a constant reference to the x coordinate of the lower left corner.
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
FontWeightType
It gives the amount of weight or boldness to use for a font.
It is a collection of other geometric objects.
double getHeight() const
It returns the envelope height.
const double & getX() const
It returns the Point x-coordinate value.
Curve * getRingN(std::size_t i) const
It returns the n-th ring for this curve polygon as a curve.
void setRingN(std::size_t i, Curve *r)
It sets the informed position ring to the new one.