You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
2.2 KiB

7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. *
  3. * This file is part of QMapControl,
  4. * an open-source cross-platform map widget
  5. *
  6. * Copyright (C) 2007 - 2009 Kai Winter
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU Lesser General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU Lesser General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public License
  19. * along with QMapControl. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. * Contact e-mail: kaiwinter@gmx.de
  22. * Program URL : http://qmapcontrol.sourceforge.net/
  23. *
  24. */
  25. #include "fixedimageoverlay.h"
  26. FixedImageOverlay::FixedImageOverlay(qreal x_upperleft, qreal y_upperleft, qreal x_lowerright, qreal y_lowerright, QString filename, QString name)
  27. : ImagePoint(x_upperleft, y_upperleft, filename, name, TopLeft),
  28. x_lowerright(x_lowerright), y_lowerright(y_lowerright)
  29. {
  30. //qDebug() << "loading image: " << filename;
  31. mypixmap = QPixmap(filename);
  32. size = mypixmap.size();
  33. //qDebug() << "image size: " << size;
  34. }
  35. FixedImageOverlay::FixedImageOverlay(qreal x_upperleft, qreal y_upperleft, qreal x_lowerright, qreal y_lowerright, QPixmap pixmap, QString name)
  36. : ImagePoint(x_upperleft, y_upperleft, pixmap, name, TopLeft),
  37. x_lowerright(x_lowerright), y_lowerright(y_lowerright)
  38. {
  39. mypixmap = pixmap;
  40. size = mypixmap.size();
  41. }
  42. void FixedImageOverlay::draw(QPainter* painter, const MapAdapter* mapadapter, const QRect &, const QPoint)
  43. {
  44. if (!visible)
  45. return;
  46. const QPointF c = QPointF(X, Y);
  47. QPoint topleft = mapadapter->coordinateToDisplay(c);
  48. const QPointF c2 = QPointF(x_lowerright, y_lowerright);
  49. QPoint lowerright = mapadapter->coordinateToDisplay(c2);
  50. painter->drawPixmap(topleft.x(), topleft.y(), lowerright.x()-topleft.x(), lowerright.y()-topleft.y(), mypixmap);
  51. }
  52. FixedImageOverlay::~FixedImageOverlay()
  53. {
  54. }